Skip to content

Leaving parts out ​

Both elements load their optional parts as separate files, the first time each is needed. The features attribute goes a step further: with it, only the parts it lists exist. A part left out is never fetched, so its files need not be deployed at all. This page is the one place features is described, for the form and for the builder.

The whole page ​

index.html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Customer intake, parts left out</title>
    <link rel="stylesheet" href="/datum/datum-form.css">
    <script type="module" src="/datum/datum-form.js"></script>
  </head>
  <body>
    <!-- minimal is a single-page form that renders, validates and submits. No journeys, PDF,
         sandbox or passkey file is fetched. Each name after it adds one part back: here,
         the data sources the Country select reads. -->
    <datum-form id="intake" features="minimal data-sources" src="/forms/customer-intake.json"></datum-form>

    <script type="module">
      const form = document.getElementById("intake");
      form.dataSources = {
        countries: [
          { value: "CA", label: "Canada" },
          { value: "US", label: "United States" },
          { value: "MX", label: "Mexico" }
        ]
      };
      form.addEventListener("datum-submit", ({ detail }) => console.log("accepted:", detail.accepted));

      // A listed part whose file the site did not deploy is reported here, with a Retry on the form.
      form.addEventListener("datum-error", ({ detail }) => console.warn(detail.message));
    </script>
  </body>
</html>
ResultThis page, running. Addresses under /forms//api/ are answered by the example.
What the page did

Nothing yet.

How the list reads ​

Without the attribute, every feature exists. With it, only the listed ones do.

  • minimal on <datum-form> is a single-page form that renders, validates and submits.
  • minimal on <datum-form-builder> is the Form workspace alone: canvas, inspector and component palette.
  • Add names to put parts back: features="minimal data-sources drafts", features="minimal logic languages".
  • A setting for a part the list leaves out is ignored, with one warning in the console. A minimal form ignores dataSources, for one, which is why the example lists data-sources.
  • A minus takes one out: features="-drafts" is everything but drafts. A list of only exclusions starts from all, so -drafts and all -drafts say the same. An exclusion wins wherever it stands in the list.
  • A word that names nothing, a mistyped exclusion included, is reported and left out. A list holding one no longer starts from all, so a typo can only narrow what exists.
  • all is every feature that is on by default. A feature that is off by default, agent, is added to it: features="all agent".
  • Lists take spaces or commas, in any case.

features is the master. An attribute that belongs to a part can only narrow it: pdf="auto" on a form whose list leaves pdf out is ignored, with one warning in the console.

The form ​

FeatureWhat it switches on, and what stops loading without it
journeysMulti-page flows. The journey engine chunk
printPrinting the form. No file of its own
translationsTranslations of the form's texts and the language switcher. No file of its own
data-sourcesOption lists from data sources. No file of its own
draftsSaving answers under a draft key. No file of its own
server-validationA journey's server check (validate-url). The server validator chunk
signingWebAuthn signing. The passkey chunk
pdfThe PDF action. The PDF service chunk, datum-pdf.js and fonts/
wasmThe in-page sandbox (wasm="auto", for development and testing). datum-wasm.js
agentTools for a browser assistant, opt in only: features="all agent". The agent chunk

A feature with no file is a behaviour switch: leaving it out changes what the form does, and there is nothing to delete.

The builder ​

The builder takes the same attribute with its own names. For each goal there is one recommended setting, and where features can do it, that is the setting.

GoalSettingWhat stops loading
Only the form, nothing elsefeatures="minimal"Every optional part below
No PDF sidefeatures="-pdf"The PDF workspace and mode, the PDF module datum-pdf.js and fonts/. The largest part
No Journeysfeatures="-journeys"The Journeys workspace and mode, and the journey engine chunks
No Logic workspacefeatures="-logic"The Logic workspace. The inspector's Rules tab and the canvas's Add logic go with it
No Data workspacefeatures="-data"The Data workspace
No Languages workspacefeatures="-languages"The Languages workspace
No header and footer panelfeatures="-header-footer"The Header & footer panel
No Variables panelfeatures="-variables"The Variables panel
No Tests panelfeatures="-tests"The Tests panel and its editor
No JSON viewfeatures="-json"The JSON view and editor, the code editor chunk
No command palettefeatures="-palette"The command palette (Ctrl+K)
No Try itfeatures="-try-it"Try it on the canvas
No data-model importfeatures="-data-model"The Data workspace's import of a JSON sample or schema. No file of its own
No pointer to Languages under a component's textsfeatures="-translations"No file of its own
No binding pickerfeatures="-binding-picker"The canvas's design-system picker. The binding property still sets the binding. No file of its own
No component id or data key in the inspectorfeatures="-advanced-fields"No file of its own
Agent tools over the builderfeatures="all agent"Opt in only: the agent chunks load only when named
Only these component typescomponent-types="text,select"Nothing: it filters the palette
No New, Open or Downloadfile-actions="none"Nothing: it hides menu items
No Components, Outline, View, Settings or Form panelhidden-panels="outline view"A hidden panel is never loaded, but these five have no feature

Take several away with one list: features="-pdf -journeys -tests".

The narrower switches ​

These can only take more away from what features allows. They never bring a part back, and asking for a side the list left out is ignored with one warning.

AttributeTakesWhat it does
pdf="off"auto, off or the URL of the PDF moduleoff removes the PDF mode
journeys="off"auto or offoff removes the Journeys mode. The definition's journeys pass through untouched
hidden-workspacesList of form, logic, data, languages, journeys, pdf, printLeaves workspaces off the bar. It does not remove their code
hidden-panelsList of form, chrome, components, outline, variables, tests, view, settingsLeaves strip panels off. A hidden panel is never loaded and never the open one
component-typesList of types. A leading - drops a type, a trailing * matches a prefixRestricts the palette. Exclusions win over inclusions. The property is componentTypeFilter
file-actionsauto, none or off (the same), or a list of new, open, downloadWhich of the builder's own file actions show. The PDF designer shows none unless named

Reach for these when the part must stay in the folder, for instance when one deployment serves the same files to two audiences. Only features lets a build step delete files, because feature-files.json is indexed by feature name.

One part, two names ​

A feature and a strip panel can name the same part differently:

Partfeatures namePanel or workspace id
Header & footer panelheader-footerpanel chrome
Variables panelvariablespanel variables
Tests paneltestspanel tests
Logic, Data, Languages, Journeys, PDF, Printlogic, data, languages, journeys, pdf, printthe same ids, as workspaces
Components, Outline, View, Settings, Form settingsnonepanels components, outline, view, settings, form

palette is the command palette (Ctrl+K), not the component palette that minimal keeps. data-model is the Data workspace's import. translations is the pointer line under a component's texts, not the Languages workspace.

Deleting the files ​

feature-files.json in the bundle folder names, for each feature, the files only that feature fetches:

json
{
  "features": {
    "journeys": { "bundle": "both", "files": ["datum-form-journey-engine-chunk-<hash>.js", "…"] },
    "pdf": { "bundle": "both", "files": ["datum-form-pdf-service-<hash>.js", "…"] }
  },
  "aliases": { "signing": "webauthn", "server-validation": "validate-url" }
}

Each entry says which bundle uses its files: form, builder or both. An alias names a feature whose files are another's. A feature with an empty files list has nothing to delete.

The Spring Boot and FastAPI hosts build this in. Their asset build takes --omit-features, and the files of those features never reach the host's folder:

npm run web-components:build
npm run jvm:assets -- --omit-features=pdf,journeys
npm run fastapi:assets -- --omit-features=pdf,journeys

The PDF fonts always ship in a host, since the PDF program embeds the same faces. For a folder you serve yourself, a build step does the same:

js
import { readFileSync, rmSync } from "node:fs";

const manifest = JSON.parse(readFileSync("dist/feature-files.json", "utf8"));
for (const feature of ["pdf", "journeys"]) {
  const name = manifest.aliases?.[feature] ?? feature;
  for (const file of manifest.features[name].files) rmSync(`dist/${file}`, { force: true });
}

The manifest also lists pdf-pages, the page images of a PDF template (datum-pdf-pages.js and pdfjs/), under a name of its own; remove it with the PDF side. Nothing asks for the deleted files, so nothing breaks. The classic-script bundles (.iife.js) carry their parts inside them and have nothing to delete.

A file that is missing ​

A feature that is listed but whose file did not arrive, because it was not deployed or a content policy blocked it, is reported as datum-error. The part shows an error with Retry in its place, and the rest of the form or builder keeps working. A later attempt fetches the file again. The exception is the journeys file for a form that runs as a journey: that form cannot be drawn without it, so the whole form is replaced by an error card with Retry.

Next ​

MIT licence. Your forms, your data, your keys.