This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm run start— runsvite build --watchtogether with the Vite dev server on port 8000, auto-opening/demo/.npm run build— production library build via Vite (entrysrc/widget-form.ts, ES format,dist/widget-form.js).npm run watch— incremental library build only.npm run types— regeneratessrc/definition-schema.d.tsfromsrc/definition-schema.jsonusingjson-schema-to-typescript. Run this wheneverdefinition-schema.jsonchanges.npm run analyze— produces acustom-elements.jsonmanifest via@custom-elements-manifest/analyzer.npm run release—build→types→npm version patch(novprefix) → push commits and tags → rebuild. Pushing the tag triggers.github/workflows/build-publish.yml, which publishes to npm and creates a GitHub Release. Requires Node>=24.9.0, npm>=10.0.2.npm run link/unlink— link the local build into a sibling../RESWARM/frontendcheckout for in-place testing.
There is no test suite or linter configured; Prettier config lives in .prettierrc.
This package ships a single Lit 3 web component, widget-form, consumed by the IronFlock/RESWARM dashboard platform. The whole component lives in src/widget-form.ts; everything else is configuration or generated.
The class is registered as widget-form-versionplaceholder. The literal string versionplaceholder is rewritten to pkg.version at build time by @rollup/plugin-replace (configured in vite.config.ts). Consumers must therefore use a version-suffixed tag matching the installed package version, e.g. <widget-form-1.0.16>. This lets multiple versions of the widget coexist on the same dashboard page. When changing the version, no source edits are needed — the build substitutes it.
src/definition-schema.json is the source of truth for the widget's configurable inputs. It is consumed two ways:
- The IronFlock dashboard editor reads it (with custom keywords like
dataDrivenDisabled,condition.relativePath/showIfValueIn,targetColumn,order,required) to render the widget's settings UI. npm run typesconverts it intosrc/definition-schema.d.ts, whichwidget-form.tsimports asInputData/FormFields.
Always edit definition-schema.json first, then run npm run types. The descriptions in the schema are written for AI/LLM consumption (see commit f2e58ea).
- Inputs:
inputData: InputData(form config + fields),theme: { theme_name, theme_object },route: string(current dashboard route, used byresolveRoutefor*segment substitution and{{label}}variable interpolation indeleteNavigationRoute). - Outputs: dispatches
data-submit(non-bubbling) with an array of{ swarm_app_databackend_key, table_name, column_name, value }mappings — one entry performFieldplus an extra entry fordeleteFlagColumnwhen present. On delete it additionally dispatches a bubbling/composednav-submitevent with the resolved route. - Each field's
targetColumn(typetargetColumnin the schema) is the platform's database column picker; the host wires its value, and submission carries the same identifiers back so the host can persist data. - Theming: reads
--re-text-colorand--re-tile-background-colorCSS variables first, then falls back totheme.theme_object. Material Web tokens (--md-sys-color-*,--md-menu-*) are then re-derived from those values insiderender(). - Form rendering uses Material Web (
@material/webis a peer dependency, externalized in the rollup output). Inline mode renders fields directly;formButtonmode renders a FAB that opens anmd-dialog.formKeyis incremented to force a full re-render on reset. - Hidden fields (
hiddenField: true) submit via<input type="hidden">; checkbox values are normalized to'on'/'off'then to booleans informatValue.
vite.config.tsexternalizes@material/web/*andlit-flatpickrso consumers provide them.tslibis aliased to its ES module entry.vite-plugin-dtsrolls up declarations intodist/widget-form.d.ts.- The demo (
demo/index.html) imports../src/widget-form.jsdirectly and computes the tag frompackage.jsonversion, mirroring how the platform consumes the published build.