@blackbelt-technology/pi-dashboard-forms-bpmn 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/.pi/skills/bpmn-package-explorer/SKILL.md +120 -0
  2. package/.pi/skills/bpmn-package-explorer/assets/LICENSE.bpmn-io.txt +23 -0
  3. package/.pi/skills/bpmn-package-explorer/assets/VENDORED.md +90 -0
  4. package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/css/bpmn-codes.css +108 -0
  5. package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/css/bpmn-embedded.css +166 -0
  6. package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/css/bpmn.css +164 -0
  7. package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/font/bpmn.eot +0 -0
  8. package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/font/bpmn.svg +224 -0
  9. package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/font/bpmn.ttf +0 -0
  10. package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/font/bpmn.woff +0 -0
  11. package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/font/bpmn.woff2 +0 -0
  12. package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-navigated-viewer.production.min.js +22 -0
  13. package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn.css +145 -0
  14. package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/diagram-js.css +1249 -0
  15. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/diagram-js.css +1133 -0
  16. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/css/dmn-codes.css +41 -0
  17. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/css/dmn-embedded.css +98 -0
  18. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/css/dmn.css +97 -0
  19. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/font/dmn.eot +0 -0
  20. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/font/dmn.svg +90 -0
  21. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/font/dmn.ttf +0 -0
  22. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/font/dmn.woff +0 -0
  23. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/font/dmn.woff2 +0 -0
  24. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-js-decision-table.css +580 -0
  25. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-js-drd.css +108 -0
  26. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-js-literal-expression.css +165 -0
  27. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-js-shared.css +221 -0
  28. package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-viewer.production.min.js +16 -0
  29. package/.pi/skills/bpmn-package-explorer/assets/lib/bpmn-pipeline.mjs +6981 -0
  30. package/.pi/skills/bpmn-package-explorer/assets/lib/yaml.mjs +7372 -0
  31. package/.pi/skills/bpmn-package-explorer/fixtures/geometry/g1-identical-bounds.bpmn +17 -0
  32. package/.pi/skills/bpmn-package-explorer/fixtures/geometry/g2-zero-size.bpmn +17 -0
  33. package/.pi/skills/bpmn-package-explorer/fixtures/geometry/g3-child-outside.bpmn +16 -0
  34. package/.pi/skills/bpmn-package-explorer/fixtures/geometry/g4-negative-coord.bpmn +17 -0
  35. package/.pi/skills/bpmn-package-explorer/fixtures/geometry/g5-overlap.bpmn +17 -0
  36. package/.pi/skills/bpmn-package-explorer/fixtures/measured/1-linear.bpmn +12 -0
  37. package/.pi/skills/bpmn-package-explorer/fixtures/measured/2-gateway.bpmn +19 -0
  38. package/.pi/skills/bpmn-package-explorer/fixtures/measured/3-boundary.bpmn +13 -0
  39. package/.pi/skills/bpmn-package-explorer/fixtures/measured/4-subprocess.bpmn +17 -0
  40. package/.pi/skills/bpmn-package-explorer/fixtures/measured/5-pools.bpmn +21 -0
  41. package/.pi/skills/bpmn-package-explorer/fixtures/measured/6-lanes-only.bpmn +16 -0
  42. package/.pi/skills/bpmn-package-explorer/fixtures/measured/7-loop.bpmn +13 -0
  43. package/.pi/skills/bpmn-package-explorer/fixtures/measured/8-long-chain.bpmn +32 -0
  44. package/.pi/skills/bpmn-package-explorer/fixtures/nesting/expanded-subprocess-ok.bpmn +25 -0
  45. package/.pi/skills/bpmn-package-explorer/fixtures/provisional/call-activity.bpmn +10 -0
  46. package/.pi/skills/bpmn-package-explorer/fixtures/provisional/intermediate-catch.bpmn +10 -0
  47. package/.pi/skills/bpmn-package-explorer/fixtures/provisional/intermediate-throw.bpmn +10 -0
  48. package/.pi/skills/bpmn-package-explorer/fixtures/provisional/manual-task.bpmn +10 -0
  49. package/.pi/skills/bpmn-package-explorer/fixtures/provisional/multi-boundary.bpmn +16 -0
  50. package/.pi/skills/bpmn-package-explorer/fixtures/provisional/parallel-gateway.bpmn +10 -0
  51. package/.pi/skills/bpmn-package-explorer/fixtures/provisional/receive-task.bpmn +10 -0
  52. package/.pi/skills/bpmn-package-explorer/fixtures/provisional/rule-task.bpmn +10 -0
  53. package/.pi/skills/bpmn-package-explorer/fixtures/provisional/script-task.bpmn +10 -0
  54. package/.pi/skills/bpmn-package-explorer/fixtures/provisional/send-task.bpmn +10 -0
  55. package/.pi/skills/bpmn-package-explorer/references/authoring-envelope.md +52 -0
  56. package/.pi/skills/bpmn-package-explorer/references/identifiers.md +102 -0
  57. package/.pi/skills/bpmn-package-explorer/references/layout-envelope.md +105 -0
  58. package/.pi/skills/bpmn-package-explorer/references/licensing.md +48 -0
  59. package/.pi/skills/bpmn-package-explorer/references/package-manifest.md +104 -0
  60. package/.pi/skills/bpmn-package-explorer/scripts/build-fixtures.mjs +299 -0
  61. package/.pi/skills/bpmn-package-explorer/scripts/demo.mjs +128 -0
  62. package/.pi/skills/bpmn-package-explorer/scripts/diagnostics.mjs +37 -0
  63. package/.pi/skills/bpmn-package-explorer/scripts/envelope.mjs +160 -0
  64. package/.pi/skills/bpmn-package-explorer/scripts/fixtures.mjs +140 -0
  65. package/.pi/skills/bpmn-package-explorer/scripts/generate-cli.mjs +31 -0
  66. package/.pi/skills/bpmn-package-explorer/scripts/generate.mjs +103 -0
  67. package/.pi/skills/bpmn-package-explorer/scripts/guard.mjs +335 -0
  68. package/.pi/skills/bpmn-package-explorer/scripts/harness.mjs +12 -0
  69. package/.pi/skills/bpmn-package-explorer/scripts/identifiers.mjs +117 -0
  70. package/.pi/skills/bpmn-package-explorer/scripts/ingest.mjs +95 -0
  71. package/.pi/skills/bpmn-package-explorer/scripts/manifest.mjs +374 -0
  72. package/.pi/skills/bpmn-package-explorer/scripts/pipeline.mjs +49 -0
  73. package/.pi/skills/bpmn-package-explorer/scripts/render.mjs +130 -0
  74. package/.pi/skills/bpmn-package-explorer/scripts/runguard.mjs +38 -0
  75. package/.pi/skills/bpmn-package-explorer/scripts/selftest-e2e.mjs +87 -0
  76. package/.pi/skills/bpmn-package-explorer/scripts/selftest-guard.mjs +99 -0
  77. package/.pi/skills/bpmn-package-explorer/scripts/selftest-manifest.mjs +170 -0
  78. package/.pi/skills/bpmn-package-explorer/scripts/selftest-more.mjs +87 -0
  79. package/.pi/skills/bpmn-package-explorer/scripts/selftest-workflow.mjs +73 -0
  80. package/.pi/skills/bpmn-package-explorer/scripts/selftest.mjs +57 -0
  81. package/.pi/skills/bpmn-package-explorer/scripts/vendor.mjs +141 -0
  82. package/.pi/skills/bpmn-package-explorer/scripts/view-cli.mjs +19 -0
  83. package/.pi/skills/bpmn-package-explorer/templates/shell.html +141 -0
  84. package/.pi/skills/bpmn-package-explorer/templates/viewer.js +301 -0
  85. package/.pi/skills/canvas-webapp/SKILL.md +104 -0
  86. package/.pi/skills/openforms-mui/SKILL.md +187 -0
  87. package/.pi/skills/openforms-mui/references/a11y.md +68 -0
  88. package/.pi/skills/openforms-mui/references/field-widget-map.md +64 -0
  89. package/.pi/skills/openforms-mui/references/hu-locale.md +45 -0
  90. package/.pi/skills/openforms-mui/references/logic.md +94 -0
  91. package/.pi/skills/openforms-mui/references/schema.md +94 -0
  92. package/.pi/skills/openforms-mui/references/theme-bridge.md +65 -0
  93. package/.pi/skills/openforms-mui/tools/canvas-serve.mjs +51 -0
  94. package/.pi/skills/openforms-mui/tools/demo-schema.json +80 -0
  95. package/.pi/skills/openforms-mui/tools/mockups/tokens.css +27 -0
  96. package/.pi/skills/openforms-mui/tools/mockups/ui-contract.tokens.json +16 -0
  97. package/.pi/skills/openforms-mui/tools/package-lock.json +5919 -0
  98. package/.pi/skills/openforms-mui/tools/package.json +61 -0
  99. package/.pi/skills/openforms-mui/tools/preview/RenderPanel.tsx +105 -0
  100. package/.pi/skills/openforms-mui/tools/preview/canvas-app.tsx +66 -0
  101. package/.pi/skills/openforms-mui/tools/preview/canvas-index.html +16 -0
  102. package/.pi/skills/openforms-mui/tools/preview/cli.ts +99 -0
  103. package/.pi/skills/openforms-mui/tools/preview/index.html +17 -0
  104. package/.pi/skills/openforms-mui/tools/preview/main.tsx +228 -0
  105. package/.pi/skills/openforms-mui/tools/preview/vite-plugin.ts +41 -0
  106. package/.pi/skills/openforms-mui/tools/scripts/assert-peer-deps.mjs +39 -0
  107. package/.pi/skills/openforms-mui/tools/src/OpenFormsMui.tsx +391 -0
  108. package/.pi/skills/openforms-mui/tools/src/css.d.ts +2 -0
  109. package/.pi/skills/openforms-mui/tools/src/fields/ErrorSummary.tsx +72 -0
  110. package/.pi/skills/openforms-mui/tools/src/fields/FieldRenderer.tsx +328 -0
  111. package/.pi/skills/openforms-mui/tools/src/fields/FieldShell.tsx +50 -0
  112. package/.pi/skills/openforms-mui/tools/src/fields/FileField.tsx +91 -0
  113. package/.pi/skills/openforms-mui/tools/src/fields/MatrixField.tsx +146 -0
  114. package/.pi/skills/openforms-mui/tools/src/fields/RepeaterField.tsx +82 -0
  115. package/.pi/skills/openforms-mui/tools/src/fields/SignatureCanvas.tsx +121 -0
  116. package/.pi/skills/openforms-mui/tools/src/fields/context.tsx +34 -0
  117. package/.pi/skills/openforms-mui/tools/src/fields/index.ts +7 -0
  118. package/.pi/skills/openforms-mui/tools/src/fields/label.ts +42 -0
  119. package/.pi/skills/openforms-mui/tools/src/fonts.ts +8 -0
  120. package/.pi/skills/openforms-mui/tools/src/i18n/dictionary.ts +58 -0
  121. package/.pi/skills/openforms-mui/tools/src/i18n/hu.ts +56 -0
  122. package/.pi/skills/openforms-mui/tools/src/i18n/index.ts +43 -0
  123. package/.pi/skills/openforms-mui/tools/src/index.ts +27 -0
  124. package/.pi/skills/openforms-mui/tools/src/logic/cnf.ts +206 -0
  125. package/.pi/skills/openforms-mui/tools/src/logic/formula.ts +285 -0
  126. package/.pi/skills/openforms-mui/tools/src/logic/index.ts +4 -0
  127. package/.pi/skills/openforms-mui/tools/src/logic/operators.ts +43 -0
  128. package/.pi/skills/openforms-mui/tools/src/logic/state.ts +183 -0
  129. package/.pi/skills/openforms-mui/tools/src/payload.ts +83 -0
  130. package/.pi/skills/openforms-mui/tools/src/provenance.ts +21 -0
  131. package/.pi/skills/openforms-mui/tools/src/schema/diagnose.ts +256 -0
  132. package/.pi/skills/openforms-mui/tools/src/schema/index.ts +4 -0
  133. package/.pi/skills/openforms-mui/tools/src/schema/normalize.ts +163 -0
  134. package/.pi/skills/openforms-mui/tools/src/schema/types.ts +299 -0
  135. package/.pi/skills/openforms-mui/tools/src/schema/walk.ts +68 -0
  136. package/.pi/skills/openforms-mui/tools/src/theme/from-tokens.ts +102 -0
  137. package/.pi/skills/openforms-mui/tools/src/theme/index.ts +1 -0
  138. package/.pi/skills/openforms-mui/tools/src/validation/constrain.ts +83 -0
  139. package/.pi/skills/openforms-mui/tools/src/validation/diagnostics.ts +62 -0
  140. package/.pi/skills/openforms-mui/tools/src/validation/empty.ts +53 -0
  141. package/.pi/skills/openforms-mui/tools/src/validation/index.ts +5 -0
  142. package/.pi/skills/openforms-mui/tools/src/validation/resolver.ts +14 -0
  143. package/.pi/skills/openforms-mui/tools/src/validation/zod-from-schema.ts +169 -0
  144. package/.pi/skills/openforms-mui/tools/tests/a11y.test.tsx +82 -0
  145. package/.pi/skills/openforms-mui/tools/tests/cli.test.ts +74 -0
  146. package/.pi/skills/openforms-mui/tools/tests/component.test.tsx +295 -0
  147. package/.pi/skills/openforms-mui/tools/tests/diagnose.test.ts +163 -0
  148. package/.pi/skills/openforms-mui/tools/tests/fixtures/all-field-types.json +45 -0
  149. package/.pi/skills/openforms-mui/tools/tests/logic.test.ts +175 -0
  150. package/.pi/skills/openforms-mui/tools/tests/normalize.test.ts +105 -0
  151. package/.pi/skills/openforms-mui/tools/tests/reference-semantics.test.ts +131 -0
  152. package/.pi/skills/openforms-mui/tools/tests/responsive.test.tsx +158 -0
  153. package/.pi/skills/openforms-mui/tools/tests/setup.ts +16 -0
  154. package/.pi/skills/openforms-mui/tools/tests/singleton.test.tsx +31 -0
  155. package/.pi/skills/openforms-mui/tools/tests/theme.test.ts +65 -0
  156. package/.pi/skills/openforms-mui/tools/tests/toolchain.test.ts +33 -0
  157. package/.pi/skills/openforms-mui/tools/tests/validation.test.ts +222 -0
  158. package/.pi/skills/openforms-mui/tools/tsconfig.json +21 -0
  159. package/.pi/skills/openforms-mui/tools/vite.canvas.config.ts +21 -0
  160. package/.pi/skills/openforms-mui/tools/vitest.config.ts +17 -0
  161. package/NOTICE +46 -0
  162. package/README.md +62 -0
  163. package/package.json +46 -0
  164. package/scripts/ensure-openforms-deps.mjs +38 -0
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: canvas-webapp
3
+ description: >-
4
+ Render a React/Vite (or any bundled) web app on the pi-dashboard canvas, which
5
+ loads loopback URLs in a sandboxed opaque-origin iframe. Use when a
6
+ canvas(target:{kind:"url"|"server"}) target shows up blank white, an empty
7
+ surface, or a /live/<id> 500 ECONNREFUSED. Covers why Vite dev servers and
8
+ non-CORS static servers fail there, and the static-build + CORS-server recipe
9
+ that works.
10
+ license: MIT
11
+ ---
12
+
13
+ # canvas-webapp — show a web app on the dashboard canvas
14
+
15
+ The dashboard opens a loopback `canvas(kind:"url")` target inside a
16
+ `sandbox="allow-scripts"` iframe with **no `allow-same-origin`** (opaque origin),
17
+ proxied under `/live/<id>/` (`LiveServerViewer.tsx` → `live-server-proxy`). That
18
+ sandbox breaks two common serving strategies; this skill is the fix.
19
+
20
+ ## When to Use
21
+
22
+ Use when you must display a running web app / React / Vite / MUI mockup on the
23
+ pi-dashboard canvas via `canvas(target:{kind:"url"|"server"})` and it shows up
24
+ blank white, an empty surface, or a `/live/<id>` 500 ECONNREFUSED.
25
+
26
+ ## Procedure
27
+
28
+ 1. **Do NOT point the canvas at a Vite DEV server.** The dashboard proxies
29
+ loopback targets under `/live/<id>/`, but Vite dev emits ABSOLUTE asset paths
30
+ (`/main.tsx`, `/@vite/client`, and runtime fetches like `/__schema.json`) that
31
+ resolve against the dashboard root, not the proxy prefix → 404 → blank page.
32
+ 2. **Produce a STATIC production build with a RELATIVE base:** a vite config with
33
+ `base:'./'`, a dedicated `index.html` entry, and the runtime data
34
+ (schema/props) IMPORTED statically (no fetch of an absolute path). Run
35
+ `npx vite build --config <config>`.
36
+ 3. **Verify** the built `index.html` references `./assets/...` (relative). Copy
37
+ the entry html to `index.html` so the proxy root (`/live/<id>/`) serves it.
38
+ 4. **Serve the dist with a tiny node static server that sets
39
+ `Access-Control-Allow-Origin: *`** (and `Cross-Origin-Resource-Policy:
40
+ cross-origin`) on every response. This is REQUIRED: the opaque-origin iframe
41
+ fetches `<script type=module>` in CORS mode with `Origin: null`, so without
42
+ ACAO:* the module is blocked → blank white even though the build is correct. A
43
+ plain `python3 -m http.server` does NOT set CORS and renders blank.
44
+ 5. **Point the canvas:** `canvas(target:{kind:'url',
45
+ url:'http://127.0.0.1:<port>/'}, mode:'replace')`. Loopback is required (SSRF
46
+ gate); `127.0.0.1` is safest.
47
+ 6. **Self-verify** by iframing your own harness before touching the canvas:
48
+ serve an HTML with `<iframe sandbox="allow-scripts allow-forms allow-popups"
49
+ src="http://127.0.0.1:<port>/">` on another port, open it in the browser tool,
50
+ and screenshot — this reproduces the exact dashboard sandbox.
51
+
52
+ ## Minimal CORS static server
53
+
54
+ ```js
55
+ // canvas-serve.mjs — node canvas-serve.mjs <port> (serves ./canvas-dist/)
56
+ import { createServer } from "node:http";
57
+ import { readFile, stat } from "node:fs/promises";
58
+ import { extname, join, normalize } from "node:path";
59
+ const ROOT = new URL("./canvas-dist/", import.meta.url).pathname;
60
+ const PORT = Number(process.argv[2] ?? 5181);
61
+ const MIME = { ".html":"text/html;charset=utf-8", ".js":"text/javascript;charset=utf-8",
62
+ ".css":"text/css;charset=utf-8", ".json":"application/json", ".woff":"font/woff",
63
+ ".woff2":"font/woff2", ".svg":"image/svg+xml", ".png":"image/png", ".ico":"image/x-icon" };
64
+ createServer(async (req, res) => {
65
+ res.setHeader("Access-Control-Allow-Origin", "*");
66
+ res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
67
+ let p = decodeURIComponent((req.url ?? "/").split("?")[0]);
68
+ if (p.endsWith("/")) p += "index.html";
69
+ const full = normalize(join(ROOT, p));
70
+ if (!full.startsWith(ROOT)) { res.statusCode = 403; return res.end("forbidden"); }
71
+ const s = await stat(full).catch(() => null);
72
+ if (!s?.isFile()) { res.statusCode = 404; return res.end("not found"); }
73
+ res.setHeader("Content-Type", MIME[extname(full)] ?? "application/octet-stream");
74
+ res.end(await readFile(full));
75
+ }).listen(PORT, "127.0.0.1", () => console.log(`CORS static on http://127.0.0.1:${PORT}/`));
76
+ ```
77
+
78
+ ## Pitfalls
79
+
80
+ - bash `kill %1` job control does NOT carry across separate Bash tool calls — a
81
+ dev server started in one call cannot be killed by `%1` in another. Kill stale
82
+ servers by PID: `lsof -tiTCP:<port> -sTCP:LISTEN | xargs kill -9`.
83
+ - Vite dev may bind IPv6 `[::1]:<port>` only, while the dashboard proxy dials
84
+ IPv4 `127.0.0.1:<port>` → the `/live/<id>` route returns 500
85
+ `FST_REPLY_FROM_INTERNAL_SERVER_ERROR 'connect ECONNREFUSED 127.0.0.1:<port>'`.
86
+ Another reason to avoid dev servers and bind static servers explicitly to
87
+ `127.0.0.1`.
88
+ - `canvas(target:{kind:'server', port})` produces a tap-to-open CHIP on desktop,
89
+ not an auto-opened view; `kind:'url'` with a loopback URL auto-opens via
90
+ `openLiveTarget`. Prefer `kind:'url'`.
91
+ - The build succeeds and renders fine in a NORMAL browser tab yet is blank in the
92
+ dashboard — that difference is the sandbox/CORS issue, not a build bug. Don't
93
+ chase the build.
94
+ - Non-loopback/remote URLs are refused by the dashboard SSRF gate
95
+ (`validateLiveTarget`).
96
+
97
+ ## Verification
98
+
99
+ 1. The static server responds 200 with header `Access-Control-Allow-Origin: *`
100
+ (`curl -D - -o /dev/null`).
101
+ 2. An `<iframe sandbox="allow-scripts">` pointed at the server renders the app
102
+ (browser-tool screenshot), matching the dashboard's opaque-origin sandbox.
103
+ 3. After `canvas(kind:'url')`, the user confirms the app is visible on the canvas
104
+ (not blank, no 500).
@@ -0,0 +1,187 @@
1
+ ---
2
+ name: openforms-mui
3
+ description: >-
4
+ Author, render, preview and debug OpenForms FormSchemaJSON form definitions as
5
+ idiomatic, themed, accessible MUI (React). Use when the user wants to design an
6
+ OpenForms form, render an OpenForms schema with Material UI, convert an
7
+ OpenForms JSON schema into a React MUI form, preview a form schema, or debug
8
+ conditional-logic / calculated fields / cross-field validation in an OpenForms
9
+ schema. This is the OpenForms *form-builder* schema (github.com/henriquefps/open-forms) —
10
+ NOT the "open-form.dev" documents-as-code framework, which this skill does not cover.
11
+ ---
12
+
13
+ # openforms-mui
14
+
15
+ Runtime interpreter that renders an OpenForms `FormSchemaJSON` as MUI. Walk the
16
+ schema on every render — **no code generation, no emitted per-form files**. The
17
+ component mirrors the upstream `OpenFormRenderer` API so migration is a
18
+ mechanical substitution.
19
+
20
+ ## What this skill is (and is not)
21
+
22
+ - **Is:** a React + MUI runtime for the visual **form-builder** schema from
23
+ `github.com/henriquefps/open-forms` (Apache 2.0). It implements all 14 field
24
+ types, both conditional-logic systems, calculated fields, and validation.
25
+ - **Is not:** the `open-form.dev` "documents as code" framework. If a request is
26
+ about `open-form.dev`, this skill does not apply.
27
+
28
+ ## Where it lives
29
+
30
+ ```
31
+ ~/.pi/agent/skills/openforms-mui/
32
+ SKILL.md
33
+ references/ # load only the one you need
34
+ schema.md # FormSchemaJSON structure
35
+ field-widget-map.md # 14 types → MUI widget → value shape
36
+ logic.md # CNF andGroups, operators, formula grammar
37
+ theme-bridge.md # tokens → createTheme(); host theme provider
38
+ a11y.md # matrix / repeater / signature pitfalls
39
+ hu-locale.md # Hungarian conventions (opt-in via locale)
40
+ tools/ # the TypeScript library + preview harness
41
+ src/ # component, schema, logic, validation, theme, i18n
42
+ preview/ # Vite three-panel harness + CLI
43
+ tests/ # vitest suite
44
+ mockups/ # approved token layer (tokens.css, ui-contract.tokens.json)
45
+ ```
46
+
47
+ The skill is **user-global** — usable from any working directory, with no
48
+ assumption about any particular project or document archive.
49
+
50
+ ## Using the component in a project
51
+
52
+ ```tsx
53
+ import { OpenFormsMui } from "openforms-mui"; // resolves to tools/src/index.ts
54
+
55
+ <OpenFormsMui
56
+ schema={schema}
57
+ answers={initialAnswers}
58
+ readOnly={false}
59
+ locale="en" // "hu" enables the Hungarian UI dictionary
60
+ onSubmit={(answers, meta) => {
61
+ // answers: upstream-shaped, keyed by field key (applicable fields only)
62
+ // meta.submissionContext: your supplementary data, segregated from answers
63
+ // meta.diagnostics: non-blocking findings (e.g. disabled/calculated violations)
64
+ }}
65
+ onFieldChange={(all) => {/* COMPLETE state incl. retained hidden values — not the payload */}}
66
+ />
67
+ ```
68
+
69
+ ### Single-instance resolution (required)
70
+
71
+ This is the **first** user-global skill to ship a `package.json` with installed
72
+ dependencies. A consuming project that imports the component out of this
73
+ directory must resolve React, `react-dom`, `@mui/material`, `@mui/x-date-pickers`,
74
+ `@emotion/react` and `@emotion/styled` to **one** instance — a second React
75
+ instance makes hooks throw an *invalid hook call*, and Emotion/MUI theme context
76
+ break because they rely on module-level singletons.
77
+
78
+ These packages are declared as **`peerDependencies`** (the consumer supplies
79
+ them) and additionally as **`devDependencies`** (so the preview harness runs
80
+ standalone). They are **never** plain `dependencies`.
81
+
82
+ Resolve to one instance at the bundler level:
83
+
84
+ - **Vite:** `resolve.dedupe: ["react", "react-dom", "@mui/material", "@emotion/react", "@emotion/styled"]`
85
+ - **Webpack:** `resolve.alias` each of the above to the consumer's copy, or use
86
+ `resolve.dedupe`/a single `node_modules`.
87
+ - **A monorepo:** hoist these packages so one copy is shared.
88
+
89
+ The preview harness and the vitest config already dedupe; a regression test
90
+ (`tests/singleton.test.tsx`) pins single-instance resolution.
91
+
92
+ ## Preview & diagnose (CLI)
93
+
94
+ From `tools/`:
95
+
96
+ ```bash
97
+ npm run diagnose -- path/to/schema.json # print findings; exit 1 on any error
98
+ npm run preview -- path/to/schema.json # three-panel Vite harness
99
+ npm run preview -- path/to/schema.json --reference # side-by-side upstream 1.0.7
100
+ ```
101
+
102
+ The harness shows: the rendered MUI form (with a **Rendered form ↔ Schema
103
+ source** view switch), the live `answers` JSON with validation errors, and a
104
+ CNF rule-debug panel showing each condition's operand values and outcome. It
105
+ reloads on schema-file save (answers preserved) and inspects mobile/tablet/
106
+ desktop widths. `--reference` loads the pinned upstream vanilla renderer in an
107
+ isolated frame for fidelity checking — this is the only place upstream code is
108
+ loaded and it is **never** part of the shipped library.
109
+
110
+ ## Rendering a form on the pi-dashboard canvas
111
+
112
+ The `npm run preview` harness is a **Vite dev server** — great for local
113
+ inspection, but it does **not** render on the pi-dashboard canvas. The dashboard
114
+ loads a loopback `canvas(kind:"url")` target inside a `sandbox="allow-scripts"`
115
+ iframe with **no `allow-same-origin`** (opaque origin), proxied under
116
+ `/live/<id>/`. Two things break there:
117
+
118
+ 1. **Vite dev → blank.** Vite emits absolute asset paths (`/main.tsx`,
119
+ `/@vite/client`) and the harness fetches `/__schema.json`; under the
120
+ `/live/<id>/` prefix these resolve to the dashboard root → 404 → blank.
121
+ 2. **Static build without CORS → blank.** In the opaque-origin iframe a
122
+ `<script type="module">` is fetched in CORS mode with `Origin: null`, so the
123
+ static server **must** send `Access-Control-Allow-Origin: *` or the module is
124
+ blocked (a plain `python3 -m http.server` renders blank).
125
+
126
+ **Working recipe** (reusable assets live in `tools/`):
127
+
128
+ ```bash
129
+ cd tools
130
+ # 1. Static build with RELATIVE base + statically-imported schema:
131
+ # preview/canvas-app.tsx, preview/canvas-index.html, vite.canvas.config.ts
132
+ npx vite build --config vite.canvas.config.ts # → canvas-dist/
133
+ cp canvas-dist/canvas-index.html canvas-dist/index.html # proxy root serves it
134
+ # 2. Serve with CORS headers (canvas-serve.mjs sets Access-Control-Allow-Origin: *)
135
+ node canvas-serve.mjs 5181
136
+ ```
137
+
138
+ Then `canvas(target:{kind:"url", url:"http://127.0.0.1:5181/"})`. To point the
139
+ canvas at a *different* schema, edit the static import in `preview/canvas-app.tsx`
140
+ (it imports `../demo-schema.json`) and rebuild. Self-verify before touching the
141
+ canvas by iframing your own server with `sandbox="allow-scripts"` and
142
+ screenshotting — that reproduces the exact dashboard sandbox. See the global
143
+ skill **`canvas-webapp`** (bundled with the pi-dashboard extension) for the full
144
+ rationale and pitfalls (IPv6-only Vite binds, `kill %1` not persisting across
145
+ tool calls).
146
+
147
+ ## Guided schema authoring (natural language → FormSchemaJSON)
148
+
149
+ 1. Read the description; enumerate the fields, their types, and any repetition,
150
+ conditional visibility, requiredness, or cross-field constraints.
151
+ 2. Choose types from `references/field-widget-map.md`. Model a repeating group as
152
+ a **`repeater`**, a single-choice grid as a **`matrix`**, a derived number as a
153
+ calculated `number` (`isCalculated` + `formulaExpression`).
154
+ 3. Express conditions as CNF `andGroups` (AND between groups, OR within) per
155
+ `references/logic.md`. Cross-form constraints go in root `crossFieldRules`.
156
+ 4. Run `npm run diagnose -- schema.json`. **Resolve every `error` finding**
157
+ before presenting the schema as complete (warnings/infos are advisory).
158
+ 5. `npm run preview -- schema.json` and iterate.
159
+
160
+ ## Iteration loop
161
+
162
+ Interpret → serve preview → run the automated accessibility check → correct
163
+ findings → repeat until **no serious or critical** violations remain. The
164
+ bundled a11y test (`tests/a11y.test.tsx`) runs axe over a schema covering all 14
165
+ field types; use it as the gate.
166
+
167
+ ## Deferred scope (do not attempt)
168
+
169
+ - **Remote option loading** (`optionsType: "api"` / `optionsUrl`): unsupported.
170
+ Such a field renders **disabled with an empty option list and a diagnostic** —
171
+ that diagnostic is *expected*, not a bug to fix.
172
+ - **Upstream visual builder** (`builder.js`): not integrated. Schemas are
173
+ authored by hand, by an agent, or exported from the upstream builder.
174
+
175
+ ## Attribution & provenance
176
+
177
+ The schema contract originates from **OpenForms**
178
+ (`github.com/henriquefps/open-forms`), which is **Apache 2.0** licensed. This
179
+ skill is a **clean-room re-implementation** from the published schema reference
180
+ and observed semantics — **no upstream renderer or builder source is vendored**.
181
+ The pinned reference version is **1.0.7** (see `tools/src/provenance.ts`, the
182
+ single source of truth used by both this attribution and `--reference` mode).
183
+
184
+ Upstream publishes no npm package and its public repository is a single squashed
185
+ commit mirrored from a private repo, so no release cadence can be assumed. Our
186
+ TypeScript types and diagnostics pin the schema contract; `--reference` mode is
187
+ the mechanism for detecting upstream behavioural drift.
@@ -0,0 +1,68 @@
1
+ # Accessibility guidance
2
+
3
+ The component targets **no serious or critical** axe violations across all 14
4
+ field types. The composite widgets carry the pitfalls; this page records them.
5
+
6
+ ## General
7
+
8
+ - Every input has a programmatically associated label. Validation errors are
9
+ associated with their field and announced to assistive technology.
10
+ - **Required/optional marking is truthful:** the component marks whichever is the
11
+ *minority* among currently-visible fields, and never states a convention the
12
+ rendered fields do not use. When every visible field is required, no per-field
13
+ marker is shown and a single statement says so.
14
+ - **Conditional reveals are announced** (WCAG 4.1.3) via a polite live region,
15
+ and the revealed field states *why* it appeared, so the change does not read as
16
+ an unexplained layout shift.
17
+ - **Calculated fields** are visually distinct and carry text stating the value is
18
+ computed; **disabled** state is conveyed by a non-colour cue as well as colour.
19
+ - **Severity tint matches severity:** a warning is never drawn on the error
20
+ surface, because the tint is itself a signal. The blocked-submit summary uses
21
+ the error surface only.
22
+
23
+ ## Error summary
24
+
25
+ On a blocked submit or page advance, a summary lists every blocking error above
26
+ the form and **receives focus**, so a keyboard/AT user is told why the form did
27
+ not advance. Each entry that names a reachable field links to it and moves focus
28
+ there on activation. An entry with no reachable control (a cross-field rule whose
29
+ targets are all hidden/disabled, or a duplicated `key`) is still listed and reads
30
+ as a form-level problem rather than a dead link. Error text states **how to
31
+ correct** the value, not merely that it is invalid.
32
+
33
+ ## Matrix
34
+
35
+ - Renders as a `Table` with a single-choice group per row; **collapses to one
36
+ card per row below the `md` breakpoint**.
37
+ - The **row label stays programmatically associated** with its options in both
38
+ presentations (table row header ↔ card `FormLabel`/`aria-labelledby`).
39
+ - Only **one** presentation exists as a control at a time, and the submitted
40
+ value is identical whichever was used.
41
+ - In the table, the **whole cell is the activation target** (a `label` spanning
42
+ the cell), and every interactive element clears the **48px** touch floor.
43
+
44
+ ## Repeater
45
+
46
+ - `useFieldArray` with add/remove controls honouring `minItems`/`maxItems` (the
47
+ add control disappears at `maxItems`; below `minItems` fails validation).
48
+ - Each item is a labelled card; child field errors are addressable at their array
49
+ path (`people.0.name`) and shown on the specific sub-field instance.
50
+ - **Child fields have no conditional logic** — the upstream renderer never
51
+ evaluates rule state for repeater children (diagnosed `inert-repeater-child-rule`).
52
+
53
+ ## Signature
54
+
55
+ - Default canvas exposes `role="img"` with an accessible name and a
56
+ **keyboard-reachable Clear button**; the canvas is focusable.
57
+ - It draws with `currentColor` (theme-driven), never a literal colour.
58
+ - MUI has no signature primitive, so a **documented accessible alternative** is
59
+ the `SignatureComponent` prop — supply a component that offers whatever richer,
60
+ accessible interaction you need; it must still emit a base64 PNG.
61
+
62
+ ## Responsiveness
63
+
64
+ - Columns occupy their `width` span at `md`+ and full width below `md`.
65
+ - Visual order matches DOM and focus order at every breakpoint, including where
66
+ the action bar stacks (WCAG 2.4.3): **Back precedes** the primary action.
67
+ - The multi-page stepper uses a compact vertical variant below `md` so step
68
+ labels cannot collide with adjacent markers.
@@ -0,0 +1,64 @@
1
+ # Field type → MUI widget → value shape
2
+
3
+ All 14 upstream field types, the MUI widget each renders as, and the **exact**
4
+ submitted value shape. Value shapes are preserved so answers stay interchangeable
5
+ with upstream consumers.
6
+
7
+ | `type` | MUI widget | Submitted value | Empty value |
8
+ |---|---|---|---|
9
+ | `header` | `Typography` + `Divider` | *(no key)* | — |
10
+ | `paragraph` | `Typography` | *(no key)* | — |
11
+ | `text` | `TextField` | `string` | `""` |
12
+ | `textarea` | `TextField multiline` | `string` | `""` |
13
+ | `number` | `TextField type=number` | `number \| null` | `null` |
14
+ | `date` | `DatePicker` (x-date-pickers) | `string` `YYYY-MM-DD` | `""` |
15
+ | `boolean` | `Switch` + `FormControlLabel` | `boolean` | `false` |
16
+ | `dropdown` | `TextField select` | `string` | `""` |
17
+ | `radio` | `RadioGroup` | `string` | `""` |
18
+ | `checkbox` | `FormGroup` of `Checkbox` | `string[]` | `[]` |
19
+ | `matrix` | `Table` (cards below `md`) | `{ [rowKey]: columnValue }` | `{}` |
20
+ | `repeater` | `useFieldArray` cards | `Array<{ [childKey]: value }>` | `[]` |
21
+ | `signature` | self-contained canvas | `string` (base64 PNG data URL) | `""` |
22
+ | `file` | `Button` + hidden `input[type=file]` | `{ name, size, type, content }` (`content` = base64 data URL) | `null` |
23
+
24
+ ## Value-shape rules that bite
25
+
26
+ - **`header` / `paragraph` contribute no answer key.**
27
+ - **`number` empty is `null`**, not `""` — including calculated fields. Validators
28
+ accept `null` (and `""`) for a non-required number before applying shape rules.
29
+ - **`checkbox` is always `string[]`**, even for a single selection.
30
+ - **`matrix`** submits only the rows the user answered; an unanswered matrix is `{}`.
31
+ - **`repeater`** contributes exactly **one** top-level array. Each row object
32
+ carries **every** child key using the empty-value table above, so a `number`
33
+ child is `null` (this deliberately deviates from upstream's `""`; one
34
+ empty-value definition avoids a shape a `number` validator would reject). No
35
+ child key ever appears at the top level.
36
+ - **`file`** is never a raw browser `File` — always the descriptor object with a
37
+ base64 `content`. Size/type are enforced **before** encoding: an oversized file
38
+ (`maxFileSizeMB`, default 5) or a disallowed `acceptedTypes` is rejected and
39
+ not encoded into state.
40
+ - **`signature`** default is a ~60-line pointer-event canvas (no dependency).
41
+ Supply an alternative via the `SignatureComponent` prop; it must still emit a
42
+ base64 PNG data URL.
43
+
44
+ ## Applicability (what is actually submitted)
45
+
46
+ The payload keys on **applicability**, not rendering:
47
+
48
+ - A field hidden by a rule (or a hidden section) is **omitted**; its value is
49
+ retained in form state and restored if it becomes visible again.
50
+ - A **disabled** field **is** included (it commonly carries prefilled/system
51
+ data) — this overrides react-hook-form's default of stripping disabled inputs.
52
+ - A calculated `isVisibleOnForm: false` field **is** included when effectively
53
+ visible; **omission wins** when it also sits in a hidden branch.
54
+ - Every applicable field contributes its empty value rather than `undefined`, so
55
+ no key is dropped by JSON serialisation.
56
+ - `onFieldChange` receives the **complete** state (retained hidden values
57
+ included) — this is *not* the payload; do not forward it as one.
58
+ - Supplementary data travels as the **second `onSubmit` argument**
59
+ (`{ submissionContext, diagnostics }`), structurally segregated from answers.
60
+
61
+ ## `optionsType: "api"`
62
+
63
+ Renders **disabled with an empty option list and a visible explanation**, plus a
64
+ diagnostic. This is deferred scope, not a bug — never a silently empty control.
@@ -0,0 +1,45 @@
1
+ # Hungarian localization (opt-in)
2
+
3
+ Hungarian support is **opt-in via an explicit `locale="hu"`** and is **never an
4
+ ambient default** — this skill is user-global and must not assume the Hungarian
5
+ document archive. English (`en`) is the default UI dictionary.
6
+
7
+ ```tsx
8
+ <OpenFormsMui schema={schema} locale="hu" />
9
+ ```
10
+
11
+ ## What `locale="hu"` changes
12
+
13
+ - The component's own **UI chrome** (buttons, markers, notices, the error-summary
14
+ title, computed/disabled hints) uses the Hungarian dictionary
15
+ (`tools/src/i18n/hu.ts`). Author-supplied content (labels, options, rule
16
+ messages) is localized separately by the schema's `translations` dictionary.
17
+ - Missing translations fall back to the schema's base text (never an empty label).
18
+
19
+ ## HU formatting conventions
20
+
21
+ - **Date:** storage stays ISO `YYYY-MM-DD`; the Hungarian display convention is
22
+ `YYYY. MM. DD.` (`HU_DATE_DISPLAY_FORMAT`).
23
+ - **Currency (HUF):** `formatHuf(1234567)` → `"1 234 567 Ft"` (space grouping, no
24
+ decimals, `Ft` suffix), via `Intl.NumberFormat("hu-HU")`.
25
+
26
+ ## Optional input masks (opt-in patterns)
27
+
28
+ Exported as `HU_MASKS` (apply via a field `mask` where useful; never enforced by
29
+ default):
30
+
31
+ | Field | Pattern | Notes |
32
+ |---|---|---|
33
+ | Tax ID (adóazonosító jel) | `##########` | 10 digits |
34
+ | Postal code (irányítószám) | `####` | 4 digits |
35
+ | Phone | `+36 ## ### ####` | national format |
36
+
37
+ These are conveniences for Hungarian forms; they remain opt-in and are not a
38
+ default of the component.
39
+
40
+ ## Adding another locale
41
+
42
+ Supply a `translations` dictionary on the schema for author content, and pass the
43
+ matching `locale`. Only `en` and `hu` ship a built-in **UI** dictionary; an
44
+ unknown locale falls back to the English UI dictionary while still applying the
45
+ schema's `translations` for that locale.
@@ -0,0 +1,94 @@
1
+ # Conditional logic & formula grammar
2
+
3
+ Two systems share one CNF evaluator: field/section `conditionalRules`
4
+ (`visibility` / `required` / `disabled`) and root `crossFieldRules`. Semantics
5
+ below were read from the reference source (design D15), not from documentation —
6
+ several are surprising and were verified against `src/renderer.js`.
7
+
8
+ ## CNF: `andGroups`
9
+
10
+ - **AND between groups, OR within a group.** A rule is satisfied when **every**
11
+ group holds **at least one** satisfied condition.
12
+ - An **empty `andGroups` is NOT inert — it evaluates to *not satisfied*.** A
13
+ visibility rule so declared therefore **hides** its target. Diagnosed as
14
+ `empty-and-groups`.
15
+ - A group with **no conditions** makes the whole rule not satisfied
16
+ (`empty-condition-group`).
17
+
18
+ ## Rules replace the static value
19
+
20
+ When **any** rule targets a property, the OR of those rules **replaces** the
21
+ field's static value for that property (it does not augment it). So a statically
22
+ `required: true` field with an *unsatisfied* `required` rule becomes **optional**.
23
+ With no rule for a property, the static value stands (default: visible, not
24
+ required, not disabled). A field is visible only when **both** its own visibility
25
+ and its **section's** visibility are visible.
26
+
27
+ ## Operators
28
+
29
+ | Operator | Semantics |
30
+ |---|---|
31
+ | `equals` | strict equality **or** equality of string coercions |
32
+ | `notEquals` | exact negation of `equals` |
33
+ | `contains` | **case-insensitive substring** of the *stringified* operands (`null`/`undefined` → `""`). Arrays are joined first, so on a `checkbox` this matches the joined string, **not** array membership (diagnosed `contains-on-checkbox`). |
34
+ | `notContains` | exact negation of `contains` |
35
+ | `greaterThan` / `greaterThanOrEquals` / `lessThan` / `lessThanOrEquals` | ordinal comparison (below) |
36
+ | `gte` / `lte` | undocumented aliases of `greaterThanOrEquals` / `lessThanOrEquals` (accepted silently) |
37
+
38
+ An **unrecognised operator falls back to `equals`** (matching upstream) and
39
+ raises a `warning` diagnostic — it does **not** throw.
40
+
41
+ ## Ordering (three-tier fallback)
42
+
43
+ Applied **regardless of field type and `compareMode`**, in order:
44
+
45
+ 1. **numeric** — when neither operand is the empty string and both coerce to
46
+ finite numbers (so `"9" < "10"` is numeric, not string);
47
+ 2. **chronological** — when both operands parse as dates (`Date.parse`);
48
+ 3. **locale-aware string** comparison otherwise.
49
+
50
+ When **either operand is `undefined`** the ordering is **indeterminate** and all
51
+ four ordering operators are **false** — an unanswered field never spuriously
52
+ satisfies a comparison.
53
+
54
+ ## Comparison modes
55
+
56
+ - `compareMode: "value"` (or absent): compare against the static `equalsValue`.
57
+ - `compareMode: "field"`: compare against the **live** answer of
58
+ `compareToFieldKey`; the result updates when that field changes. An unresolved
59
+ reference evaluates the condition as not satisfied and is diagnosed.
60
+
61
+ ## Cross-field rules
62
+
63
+ A `crossFieldRule` whose `andGroups` are **satisfied** is a **violation** and
64
+ **blocks** submission. Its `errorMessage` attaches to **every** currently-visible,
65
+ non-disabled key in `targetFields`. A target that is hidden, disabled, dangling,
66
+ static (`header`/`paragraph`), or nested in a repeater receives no field-level
67
+ error — the rule still blocks and its message appears in the **error summary**.
68
+ An empty `andGroups` never blocks.
69
+
70
+ ## Calculated fields & the formula grammar
71
+
72
+ A `number` with `isCalculated: true` derives its value from `formulaExpression`
73
+ and accepts no direct input. With `isVisibleOnForm: false` it is not rendered but
74
+ **still computes** and participates in rules and the payload. Values recompute
75
+ when any referenced answer changes.
76
+
77
+ Formulas are evaluated by a **purpose-written recursive-descent parser** — never
78
+ `eval` / `new Function`. Grammar:
79
+
80
+ ```
81
+ numeric literals · {fieldKey} references
82
+ + - * / % · parentheses
83
+ comparisons > < >= <= == != · ternary cond ? a : b
84
+ Math.min | Math.max | Math.round | Math.abs | Math.floor | Math.ceil
85
+ ```
86
+
87
+ Anything outside the grammar (property access, arbitrary calls, identifiers)
88
+ evaluates to **`0`** and raises an `unparseable-formula` diagnostic. Division or
89
+ modulo by zero yields `0`.
90
+
91
+ ## Inspecting rules
92
+
93
+ `explainRules(schema, answers)` returns each rule's outcome with per-condition
94
+ operand values — this drives the preview harness's rule-debug panel.
@@ -0,0 +1,94 @@
1
+ # FormSchemaJSON reference
2
+
3
+ The complete schema contract, as implemented by this skill's TypeScript types
4
+ (`tools/src/schema/types.ts`). Re-implemented from the upstream
5
+ `SCHEMA_REFERENCE.md`; no upstream source is copied.
6
+
7
+ ## Top level
8
+
9
+ ```jsonc
10
+ {
11
+ "formTitle": "string?",
12
+ "formDescription": "string?",
13
+ "pages": [Page, ...], // required; normalization supplies one empty page if absent
14
+ "crossFieldRules": [CrossFieldRule, ...],
15
+ "translations": { "<locale>": { "<key>": "text" } }
16
+ }
17
+ ```
18
+
19
+ ## Layout hierarchy
20
+
21
+ ```
22
+ Page → Section → Row → Column → Field
23
+ ```
24
+
25
+ ```jsonc
26
+ Page = { "pageId?": string, "title?": string, "description?": string, "sections": [Section] }
27
+ Section = { "sectionId?": string, "title?": string, "description?": string,
28
+ "rows": [Row], "conditionalRules?": [ConditionalRule] } // visibility only
29
+ Row = { "rowId?": string, "columns": [Column] }
30
+ Column = { "columnId?": string, "width?": number /* span out of 12 at md+ */, "fields": [Field] }
31
+ ```
32
+
33
+ Identifiers (`pageId`, `sectionId`, `rowId`, field `id`) are optional; `normalizeSchema`
34
+ generates deterministic ones where absent and preserves existing ones.
35
+
36
+ ## Fields (discriminated union on `type`)
37
+
38
+ Common to every field: `id?`, `key` (answer key), `label?`, `placeholder?`,
39
+ `helpText?`, `required?`, `disabled?`, `conditionalRules?`.
40
+
41
+ | `type` | Type-specific properties |
42
+ |---|---|
43
+ | `header` | — (static; no answer) |
44
+ | `paragraph` | — (static; no answer) |
45
+ | `text` | `mask?`, `validationRegex?`, `errorMessage?`, `maxLength?` |
46
+ | `textarea` | `validationRegex?`, `errorMessage?`, `maxLength?`, `rows?` |
47
+ | `number` | `min?`, `max?`, `isCalculated?`, `formulaExpression?`, `isVisibleOnForm?` |
48
+ | `date` | `min?`, `max?` (`YYYY-MM-DD`) |
49
+ | `boolean` | — |
50
+ | `dropdown` | `options?`, `optionsType?` (`static`\|`api`), `optionsUrl?` |
51
+ | `radio` | `options?`, `optionsType?`, `optionsUrl?` |
52
+ | `checkbox` | `options?`, `optionsType?`, `optionsUrl?` |
53
+ | `matrix` | `matrixRows?` (options), `matrixColumns?` (options) |
54
+ | `repeater` | `rows?` (nested layout), `minItems?`, `maxItems?`, `addLabel?`, `removeLabel?` |
55
+ | `signature` | — |
56
+ | `file` | `acceptedTypes?` (string[]), `maxFileSizeMB?` (default 5) |
57
+
58
+ `isCalculated`, `formulaExpression` and `isVisibleOnForm` are reachable **only**
59
+ on `number`. `isVisibleOnForm: false` is honoured **only alongside**
60
+ `isCalculated: true`; elsewhere it is inert and the field renders normally.
61
+
62
+ ## Conditions & rules
63
+
64
+ ```jsonc
65
+ Condition = {
66
+ "dependentFieldKey": "string", // field whose answer is inspected
67
+ "operator": "equals|notEquals|contains|notContains|greaterThan|greaterThanOrEquals|lessThan|lessThanOrEquals" | "gte" | "lte",
68
+ "compareMode?": "value" | "field", // default "value"
69
+ "equalsValue?": any, // operand when compareMode = "value"
70
+ "compareToFieldKey?": "string" // operand field when compareMode = "field"
71
+ }
72
+ ConditionGroup = { "conditions": [Condition] } // OR within
73
+ ConditionalRule = { "targetProperty": "visibility|required|disabled", "andGroups": [ConditionGroup] } // AND between
74
+ CrossFieldRule = { "id?": string, "andGroups": [ConditionGroup], "targetFields": [string], "errorMessage": string }
75
+ ```
76
+
77
+ See `logic.md` for evaluation semantics (they matter — several are surprising).
78
+
79
+ ## Legacy forms (migrated on normalization, with an `info` diagnostic)
80
+
81
+ - `visibilityCondition` on a Field/Section → an equivalent `conditionalRules`
82
+ entry with `targetProperty: "visibility"`.
83
+ - a free-text `expression` on a cross-field rule → retained for evaluation.
84
+
85
+ ## Normalization & diagnostics
86
+
87
+ - `normalizeSchema(input)` → `{ schema, diagnostics }`. Non-mutating; idempotent.
88
+ - `diagnose(schema)` → findings `{ severity, code, message, path }`. Resolve
89
+ every `error` before treating a schema as complete. Codes include:
90
+ `duplicate-key`, `repeater-in-repeater`, `matrix-in-repeater`,
91
+ `empty-and-groups`, `empty-condition-group`, `unrecognised-operator`,
92
+ `contains-on-checkbox`, `options-api-unsupported`, `dangling-dependent-field`,
93
+ `dangling-compare-field`, `dangling-target-field`, `inert-repeater-child-rule`,
94
+ `isvisibleonform-without-calculated`, `unparseable-formula`.