@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,82 @@
1
+ import type { JSX } from "react";
2
+ import Box from "@mui/material/Box";
3
+ import Button from "@mui/material/Button";
4
+ import Card from "@mui/material/Card";
5
+ import CardContent from "@mui/material/CardContent";
6
+ import FormLabel from "@mui/material/FormLabel";
7
+ import Stack from "@mui/material/Stack";
8
+ import { useFieldArray, useFormContext } from "react-hook-form";
9
+ import type { Field, RepeaterField as RepeaterFieldType } from "../schema/types.js";
10
+ import { emptyValueFor } from "../validation/empty.js";
11
+ import { useOpenForms } from "./context.js";
12
+ import { FieldShell } from "./FieldShell.js";
13
+ import { FieldRenderer } from "./FieldRenderer.js";
14
+
15
+ /** Build one empty row object with every child key present (payload contract). */
16
+ export function emptyRepeaterRow(field: RepeaterFieldType): Record<string, unknown> {
17
+ const row: Record<string, unknown> = {};
18
+ for (const r of field.rows ?? []) {
19
+ for (const col of r.columns) {
20
+ for (const child of col.fields) {
21
+ if (child.type === "header" || child.type === "paragraph") continue;
22
+ row[child.key] = emptyValueFor(child.type);
23
+ }
24
+ }
25
+ }
26
+ return row;
27
+ }
28
+
29
+ export function RepeaterFieldWidget({ field, name }: { field: RepeaterFieldType; name: string }): JSX.Element {
30
+ const { control } = useFormContext();
31
+ const { t, readOnly, state } = useOpenForms();
32
+ const fs = state.fields.get(field.key);
33
+ const disabled = readOnly || fs?.disabled;
34
+ const { fields, append, remove } = useFieldArray({ control, name });
35
+
36
+ const min = field.minItems ?? 0;
37
+ const max = field.maxItems ?? Infinity;
38
+ const canAdd = !disabled && fields.length < max;
39
+ const canRemove = (index: number) => !disabled && fields.length > min && fields.length - 1 >= min && index >= 0;
40
+
41
+ const childFields: Field[] = (field.rows ?? []).flatMap((r) =>
42
+ r.columns.flatMap((c) => c.fields),
43
+ );
44
+
45
+ return (
46
+ <FieldShell field={field}>
47
+ <FormLabel component="legend" sx={{ mb: 1, display: "block" }}>
48
+ {t.text(field.label, field.key) || field.key}
49
+ </FormLabel>
50
+ <Stack spacing={2}>
51
+ {fields.map((item, index) => (
52
+ <Card key={item.id} variant="outlined">
53
+ <CardContent>
54
+ {childFields.map((child, ci) => (
55
+ <FieldRenderer key={`${child.key}-${ci}`} field={child} namePrefix={`${name}.${index}.`} inRepeater />
56
+ ))}
57
+ {!readOnly && (
58
+ <Box sx={{ mt: 1 }}>
59
+ <Button
60
+ size="small"
61
+ color="error"
62
+ onClick={() => remove(index)}
63
+ disabled={!canRemove(index)}
64
+ >
65
+ {t.text(field.removeLabel) || t.ui.removeItem}
66
+ </Button>
67
+ </Box>
68
+ )}
69
+ </CardContent>
70
+ </Card>
71
+ ))}
72
+ {!readOnly && (
73
+ <Box>
74
+ <Button variant="outlined" onClick={() => append(emptyRepeaterRow(field))} disabled={!canAdd}>
75
+ {t.text(field.addLabel) || t.ui.addItem}
76
+ </Button>
77
+ </Box>
78
+ )}
79
+ </Stack>
80
+ </FieldShell>
81
+ );
82
+ }
@@ -0,0 +1,121 @@
1
+ import type { JSX } from "react";
2
+ import { useCallback, useEffect, useRef } from "react";
3
+ import Box from "@mui/material/Box";
4
+ import Button from "@mui/material/Button";
5
+ import Stack from "@mui/material/Stack";
6
+ import type { SignatureComponentProps } from "./context.js";
7
+
8
+ /**
9
+ * Self-contained pointer-event signature canvas exporting a base64 PNG data URL.
10
+ * Zero third-party dependency (design D10). Colours come from the theme via
11
+ * `currentColor`, never a literal, so the token-lint gate stays satisfied.
12
+ */
13
+ export function SignatureCanvas({
14
+ value,
15
+ onChange,
16
+ disabled,
17
+ readOnly,
18
+ ariaLabel,
19
+ clearLabel,
20
+ }: SignatureComponentProps): JSX.Element {
21
+ const canvasRef = useRef<HTMLCanvasElement | null>(null);
22
+ const drawing = useRef(false);
23
+ const last = useRef<{ x: number; y: number } | null>(null);
24
+
25
+ const ctx = useCallback(() => {
26
+ const canvas = canvasRef.current;
27
+ return canvas ? canvas.getContext("2d") : null;
28
+ }, []);
29
+
30
+ // Restore an existing value (prefill / read-only).
31
+ useEffect(() => {
32
+ const canvas = canvasRef.current;
33
+ const c = ctx();
34
+ if (!canvas || !c) return;
35
+ c.clearRect(0, 0, canvas.width, canvas.height);
36
+ if (value) {
37
+ const img = new Image();
38
+ img.onload = () => c.drawImage(img, 0, 0, canvas.width, canvas.height);
39
+ img.onerror = () => {}; // ignore decode failures (e.g. non-DOM test envs)
40
+ img.src = value;
41
+ }
42
+ }, [value, ctx]);
43
+
44
+ const pos = (e: React.PointerEvent<HTMLCanvasElement>) => {
45
+ const rect = e.currentTarget.getBoundingClientRect();
46
+ return { x: e.clientX - rect.left, y: e.clientY - rect.top };
47
+ };
48
+
49
+ const start = (e: React.PointerEvent<HTMLCanvasElement>) => {
50
+ if (disabled || readOnly) return;
51
+ drawing.current = true;
52
+ last.current = pos(e);
53
+ e.currentTarget.setPointerCapture(e.pointerId);
54
+ };
55
+
56
+ const move = (e: React.PointerEvent<HTMLCanvasElement>) => {
57
+ if (!drawing.current || disabled || readOnly) return;
58
+ const c = ctx();
59
+ const p = pos(e);
60
+ if (!c || !last.current) return;
61
+ c.strokeStyle = "currentColor";
62
+ c.lineWidth = 2;
63
+ c.lineCap = "round";
64
+ c.beginPath();
65
+ c.moveTo(last.current.x, last.current.y);
66
+ c.lineTo(p.x, p.y);
67
+ c.stroke();
68
+ last.current = p;
69
+ };
70
+
71
+ const end = () => {
72
+ if (!drawing.current) return;
73
+ drawing.current = false;
74
+ last.current = null;
75
+ const canvas = canvasRef.current;
76
+ if (canvas) onChange(canvas.toDataURL("image/png"));
77
+ };
78
+
79
+ const clear = () => {
80
+ const canvas = canvasRef.current;
81
+ const c = ctx();
82
+ if (canvas && c) c.clearRect(0, 0, canvas.width, canvas.height);
83
+ onChange("");
84
+ };
85
+
86
+ return (
87
+ <Stack spacing={1}>
88
+ <Box
89
+ component="canvas"
90
+ ref={canvasRef}
91
+ width={480}
92
+ height={160}
93
+ role="img"
94
+ aria-label={ariaLabel}
95
+ tabIndex={disabled || readOnly ? -1 : 0}
96
+ onPointerDown={start}
97
+ onPointerMove={move}
98
+ onPointerUp={end}
99
+ onPointerLeave={end}
100
+ sx={{
101
+ border: 1,
102
+ borderColor: "divider",
103
+ borderRadius: 1,
104
+ width: "100%",
105
+ maxWidth: 480,
106
+ touchAction: "none",
107
+ color: "text.primary",
108
+ cursor: disabled || readOnly ? "not-allowed" : "crosshair",
109
+ bgcolor: "background.paper",
110
+ }}
111
+ />
112
+ {!readOnly && (
113
+ <Box>
114
+ <Button size="small" onClick={clear} disabled={disabled}>
115
+ {clearLabel}
116
+ </Button>
117
+ </Box>
118
+ )}
119
+ </Stack>
120
+ );
121
+ }
@@ -0,0 +1,34 @@
1
+ import type { JSX } from "react";
2
+ import { createContext, useContext } from "react";
3
+ import type { Translator } from "../i18n/index.js";
4
+ import type { FormLogicState } from "../logic/state.js";
5
+
6
+ /** A pluggable signature implementation (design D10). */
7
+ export interface SignatureComponentProps {
8
+ value: string;
9
+ onChange: (dataUrl: string) => void;
10
+ disabled?: boolean;
11
+ readOnly?: boolean;
12
+ ariaLabel: string;
13
+ clearLabel: string;
14
+ }
15
+
16
+ export interface OpenFormsContextValue {
17
+ t: Translator;
18
+ readOnly: boolean;
19
+ state: FormLogicState;
20
+ /** Optional replacement for the built-in signature canvas. */
21
+ SignatureComponent?: (props: SignatureComponentProps) => JSX.Element;
22
+ /** Which marker convention is in force for the currently-visible fields. */
23
+ markerMode: "mark-required" | "mark-optional" | "all-required" | "none";
24
+ }
25
+
26
+ const OpenFormsContext = createContext<OpenFormsContextValue | null>(null);
27
+
28
+ export const OpenFormsProvider = OpenFormsContext.Provider;
29
+
30
+ export function useOpenForms(): OpenFormsContextValue {
31
+ const ctx = useContext(OpenFormsContext);
32
+ if (!ctx) throw new Error("OpenForms field rendered outside of <OpenFormsMui>.");
33
+ return ctx;
34
+ }
@@ -0,0 +1,7 @@
1
+ export { FieldRenderer } from "./FieldRenderer.js";
2
+ export { OpenFormsProvider, useOpenForms } from "./context.js";
3
+ export type { OpenFormsContextValue, SignatureComponentProps } from "./context.js";
4
+ export { SignatureCanvas } from "./SignatureCanvas.js";
5
+ export { decideMarkerMode, labelWithMarker } from "./label.js";
6
+ export type { MarkerMode } from "./label.js";
7
+ export { emptyRepeaterRow } from "./RepeaterField.js";
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Truthful required/optional marking (renderer spec, task 7.12): the component
3
+ * marks whichever of required/optional is the *minority* among currently-visible
4
+ * fields, and never states a convention the rendered fields do not use.
5
+ */
6
+ import type { Field } from "../schema/types.js";
7
+ import type { FieldLogicState, FormLogicState } from "../logic/state.js";
8
+ import type { Translator } from "../i18n/index.js";
9
+
10
+ export type MarkerMode = "mark-required" | "mark-optional" | "all-required" | "none";
11
+
12
+ /** Decide the marker convention from the set of currently-visible fields. */
13
+ export function decideMarkerMode(state: FormLogicState): MarkerMode {
14
+ let visible = 0;
15
+ let required = 0;
16
+ for (const fs of state.fields.values()) {
17
+ if (!fs.visible || fs.hiddenCalculated) continue;
18
+ // Static content and calculated read-only fields do not take part.
19
+ if (fs.type === "header" || fs.type === "paragraph") continue;
20
+ visible++;
21
+ if (fs.required) required++;
22
+ }
23
+ if (visible === 0) return "none";
24
+ if (required === visible) return "all-required";
25
+ const optional = visible - required;
26
+ // Mark the minority; ties mark optional (the less alarming choice).
27
+ return required < optional ? "mark-required" : "mark-optional";
28
+ }
29
+
30
+ /** Compose a field label with the appropriate marker for the active mode. */
31
+ export function labelWithMarker(
32
+ field: Field,
33
+ fs: FieldLogicState | undefined,
34
+ t: Translator,
35
+ mode: MarkerMode,
36
+ ): string {
37
+ const base = t.text(field.label, field.key) || field.key;
38
+ if (!fs) return base;
39
+ if (mode === "mark-required" && fs.required) return `${base} ${t.ui.requiredMarker}`;
40
+ if (mode === "mark-optional" && !fs.required) return `${base} (${t.ui.optional.toLowerCase()})`;
41
+ return base;
42
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Bundles the Roboto webfont (400/500/700) with the component so typography does
3
+ * not silently fall back to a system face (task 10.6). Importing this module
4
+ * (done by OpenFormsMui) pulls the font files into the consuming bundle.
5
+ */
6
+ import "@fontsource/roboto/400.css";
7
+ import "@fontsource/roboto/500.css";
8
+ import "@fontsource/roboto/700.css";
@@ -0,0 +1,58 @@
1
+ /**
2
+ * UI string dictionary contract for the component's own chrome (buttons,
3
+ * markers, notices). Distinct from the schema's `translations`, which localizes
4
+ * author-supplied content (labels, options, rule messages).
5
+ */
6
+ export interface UiDictionary {
7
+ required: string;
8
+ optional: string;
9
+ requiredMarker: string;
10
+ allFieldsRequired: string;
11
+ optionalHint: string;
12
+ next: string;
13
+ previous: string;
14
+ submit: string;
15
+ addItem: string;
16
+ removeItem: string;
17
+ clear: string;
18
+ errorSummaryTitle: string;
19
+ computedValue: string;
20
+ computedHint: string;
21
+ disabledHint: string;
22
+ apiUnsupported: string;
23
+ fileTooLarge: (limitMb: number) => string;
24
+ fileTypeRejected: (accepted: string) => string;
25
+ revealedAnnouncement: (label: string) => string;
26
+ revealedReason: string;
27
+ noOptions: string;
28
+ matrixRowLabel: string;
29
+ selectPlaceholder: string;
30
+ formLevelErrors: string;
31
+ }
32
+
33
+ export const en: UiDictionary = {
34
+ required: "Required",
35
+ optional: "Optional",
36
+ requiredMarker: "*",
37
+ allFieldsRequired: "All fields on this form are required.",
38
+ optionalHint: "Fields marked optional may be left blank.",
39
+ next: "Next",
40
+ previous: "Back",
41
+ submit: "Submit",
42
+ addItem: "Add",
43
+ removeItem: "Remove",
44
+ clear: "Clear",
45
+ errorSummaryTitle: "There is a problem",
46
+ computedValue: "Computed value",
47
+ computedHint: "This value is calculated automatically and cannot be edited.",
48
+ disabledHint: "This field is read-only.",
49
+ apiUnsupported: "Remote option loading is not supported; this field is disabled.",
50
+ fileTooLarge: (limitMb) => `File is too large. The maximum size is ${limitMb} MB.`,
51
+ fileTypeRejected: (accepted) => `This file type is not allowed. Accepted types: ${accepted}.`,
52
+ revealedAnnouncement: (label) => `${label} is now shown.`,
53
+ revealedReason: "Shown because of your previous answers.",
54
+ noOptions: "No options available.",
55
+ matrixRowLabel: "Row",
56
+ selectPlaceholder: "Select…",
57
+ formLevelErrors: "Please review the following before continuing:",
58
+ };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Hungarian UI dictionary and HU formatting conventions.
3
+ *
4
+ * Hungarian is OPT-IN via an explicit `locale` (design D14): because the skill
5
+ * is user-global it must not assume the Hungarian archive, so these conventions
6
+ * are never an ambient default.
7
+ */
8
+ import type { UiDictionary } from "./dictionary.js";
9
+
10
+ export const hu: UiDictionary = {
11
+ required: "Kötelező",
12
+ optional: "Nem kötelező",
13
+ requiredMarker: "*",
14
+ allFieldsRequired: "Az űrlap minden mezője kötelező.",
15
+ optionalHint: "A nem kötelezőként jelölt mezők üresen hagyhatók.",
16
+ next: "Tovább",
17
+ previous: "Vissza",
18
+ submit: "Beküldés",
19
+ addItem: "Hozzáadás",
20
+ removeItem: "Eltávolítás",
21
+ clear: "Törlés",
22
+ errorSummaryTitle: "Hiba történt",
23
+ computedValue: "Számított érték",
24
+ computedHint: "Ez az érték automatikusan számított, nem szerkeszthető.",
25
+ disabledHint: "Ez a mező csak olvasható.",
26
+ apiUnsupported: "A távoli beállítás-betöltés nem támogatott; ez a mező le van tiltva.",
27
+ fileTooLarge: (limitMb) => `A fájl túl nagy. A megengedett legnagyobb méret ${limitMb} MB.`,
28
+ fileTypeRejected: (accepted) => `Ez a fájltípus nem engedélyezett. Elfogadott típusok: ${accepted}.`,
29
+ revealedAnnouncement: (label) => `A(z) ${label} mező most megjelent.`,
30
+ revealedReason: "A korábbi válaszai alapján jelent meg.",
31
+ noOptions: "Nincs elérhető lehetőség.",
32
+ matrixRowLabel: "Sor",
33
+ selectPlaceholder: "Válasszon…",
34
+ formLevelErrors: "A folytatás előtt tekintse át a következőket:",
35
+ };
36
+
37
+ // --- HU formatting conventions -------------------------------------------
38
+
39
+ /** Hungarian date format: YYYY. MM. DD. for display; storage stays YYYY-MM-DD. */
40
+ export const HU_DATE_DISPLAY_FORMAT = "YYYY. MM. DD.";
41
+
42
+ /** Format a HUF amount the Hungarian way: "1 234 567 Ft". */
43
+ export function formatHuf(amount: number): string {
44
+ const grouped = new Intl.NumberFormat("hu-HU", { maximumFractionDigits: 0 }).format(amount);
45
+ return `${grouped} Ft`;
46
+ }
47
+
48
+ /** Optional HU input masks (opt-in; documented in references/hu-locale.md). */
49
+ export const HU_MASKS = {
50
+ /** Tax ID (adóazonosító jel): 10 digits. */
51
+ taxId: "##########",
52
+ /** Postal code (irányítószám): 4 digits. */
53
+ postalCode: "####",
54
+ /** Phone: +36 ## ### ####. */
55
+ phone: "+36 ## ### ####",
56
+ } as const;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Translation resolution: the schema's `translations` dictionary localizes
3
+ * author content (resolved by locale then key, falling back to the schema's base
4
+ * text when a key is absent); the built-in UI dictionaries localize the
5
+ * component's own chrome. Structural values (keys, operators, formulas) are
6
+ * never translated.
7
+ */
8
+ import type { TranslationsDictionary } from "../schema/types.js";
9
+ import { en, type UiDictionary } from "./dictionary.js";
10
+ import { hu } from "./hu.js";
11
+
12
+ export type { UiDictionary } from "./dictionary.js";
13
+ export { en } from "./dictionary.js";
14
+ export { hu, formatHuf, HU_DATE_DISPLAY_FORMAT, HU_MASKS } from "./hu.js";
15
+
16
+ const UI_DICTIONARIES: Record<string, UiDictionary> = { en, hu };
17
+
18
+ export interface Translator {
19
+ /** A UI-chrome string in the active locale (falls back to English). */
20
+ ui: UiDictionary;
21
+ /** Locale code in effect. */
22
+ locale: string;
23
+ /**
24
+ * Resolve author-supplied display text. Looks up
25
+ * `translations[locale][key]`, else returns the schema's base text.
26
+ */
27
+ text(baseText: string | undefined, key?: string): string;
28
+ }
29
+
30
+ export function createTranslator(
31
+ translations: TranslationsDictionary | undefined,
32
+ locale: string,
33
+ ): Translator {
34
+ const ui = UI_DICTIONARIES[locale] ?? en;
35
+ return {
36
+ ui,
37
+ locale,
38
+ text(baseText, key) {
39
+ if (key && translations?.[locale]?.[key] !== undefined) return translations[locale][key];
40
+ return baseText ?? "";
41
+ },
42
+ };
43
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * openforms-mui — runtime interpreter rendering an OpenForms FormSchemaJSON as
3
+ * idiomatic, themed, accessible MUI. Re-implemented from the upstream schema
4
+ * reference; no upstream source is vendored (see provenance).
5
+ */
6
+ export { OpenFormsMui } from "./OpenFormsMui.js";
7
+ export type { OpenFormsMuiProps } from "./OpenFormsMui.js";
8
+ export type { SubmissionMeta } from "./payload.js";
9
+ export { composePayload } from "./payload.js";
10
+
11
+ export * from "./schema/index.js";
12
+ export * from "./logic/index.js";
13
+ export {
14
+ deriveZodSchema,
15
+ createMemoizedDeriver,
16
+ stateSignature,
17
+ FORM_LEVEL_PATH,
18
+ } from "./validation/zod-from-schema.js";
19
+ export { collectFieldDiagnostics } from "./validation/diagnostics.js";
20
+ export { emptyValueFor, isEmptyValue } from "./validation/empty.js";
21
+ export { makeResolver } from "./validation/resolver.js";
22
+ export { themeFromTokens, themeFromTokensJson, defaultTheme } from "./theme/from-tokens.js";
23
+ export { createTranslator, en, hu, formatHuf, HU_MASKS } from "./i18n/index.js";
24
+ export type { Translator } from "./i18n/index.js";
25
+ export type { SignatureComponentProps } from "./fields/context.js";
26
+ export { SignatureCanvas } from "./fields/SignatureCanvas.js";
27
+ export { UPSTREAM_PROVENANCE } from "./provenance.js";