@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.
- package/.pi/skills/bpmn-package-explorer/SKILL.md +120 -0
- package/.pi/skills/bpmn-package-explorer/assets/LICENSE.bpmn-io.txt +23 -0
- package/.pi/skills/bpmn-package-explorer/assets/VENDORED.md +90 -0
- package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/css/bpmn-codes.css +108 -0
- package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/css/bpmn-embedded.css +166 -0
- package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/css/bpmn.css +164 -0
- package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/font/bpmn.eot +0 -0
- package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/font/bpmn.svg +224 -0
- package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/font/bpmn.ttf +0 -0
- package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/font/bpmn.woff +0 -0
- package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-font/font/bpmn.woff2 +0 -0
- package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn-navigated-viewer.production.min.js +22 -0
- package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/bpmn.css +145 -0
- package/.pi/skills/bpmn-package-explorer/assets/bpmn-js/diagram-js.css +1249 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/diagram-js.css +1133 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/css/dmn-codes.css +41 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/css/dmn-embedded.css +98 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/css/dmn.css +97 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/font/dmn.eot +0 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/font/dmn.svg +90 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/font/dmn.ttf +0 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/font/dmn.woff +0 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-font/font/dmn.woff2 +0 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-js-decision-table.css +580 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-js-drd.css +108 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-js-literal-expression.css +165 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-js-shared.css +221 -0
- package/.pi/skills/bpmn-package-explorer/assets/dmn-js/dmn-viewer.production.min.js +16 -0
- package/.pi/skills/bpmn-package-explorer/assets/lib/bpmn-pipeline.mjs +6981 -0
- package/.pi/skills/bpmn-package-explorer/assets/lib/yaml.mjs +7372 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/geometry/g1-identical-bounds.bpmn +17 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/geometry/g2-zero-size.bpmn +17 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/geometry/g3-child-outside.bpmn +16 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/geometry/g4-negative-coord.bpmn +17 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/geometry/g5-overlap.bpmn +17 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/measured/1-linear.bpmn +12 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/measured/2-gateway.bpmn +19 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/measured/3-boundary.bpmn +13 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/measured/4-subprocess.bpmn +17 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/measured/5-pools.bpmn +21 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/measured/6-lanes-only.bpmn +16 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/measured/7-loop.bpmn +13 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/measured/8-long-chain.bpmn +32 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/nesting/expanded-subprocess-ok.bpmn +25 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/provisional/call-activity.bpmn +10 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/provisional/intermediate-catch.bpmn +10 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/provisional/intermediate-throw.bpmn +10 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/provisional/manual-task.bpmn +10 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/provisional/multi-boundary.bpmn +16 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/provisional/parallel-gateway.bpmn +10 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/provisional/receive-task.bpmn +10 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/provisional/rule-task.bpmn +10 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/provisional/script-task.bpmn +10 -0
- package/.pi/skills/bpmn-package-explorer/fixtures/provisional/send-task.bpmn +10 -0
- package/.pi/skills/bpmn-package-explorer/references/authoring-envelope.md +52 -0
- package/.pi/skills/bpmn-package-explorer/references/identifiers.md +102 -0
- package/.pi/skills/bpmn-package-explorer/references/layout-envelope.md +105 -0
- package/.pi/skills/bpmn-package-explorer/references/licensing.md +48 -0
- package/.pi/skills/bpmn-package-explorer/references/package-manifest.md +104 -0
- package/.pi/skills/bpmn-package-explorer/scripts/build-fixtures.mjs +299 -0
- package/.pi/skills/bpmn-package-explorer/scripts/demo.mjs +128 -0
- package/.pi/skills/bpmn-package-explorer/scripts/diagnostics.mjs +37 -0
- package/.pi/skills/bpmn-package-explorer/scripts/envelope.mjs +160 -0
- package/.pi/skills/bpmn-package-explorer/scripts/fixtures.mjs +140 -0
- package/.pi/skills/bpmn-package-explorer/scripts/generate-cli.mjs +31 -0
- package/.pi/skills/bpmn-package-explorer/scripts/generate.mjs +103 -0
- package/.pi/skills/bpmn-package-explorer/scripts/guard.mjs +335 -0
- package/.pi/skills/bpmn-package-explorer/scripts/harness.mjs +12 -0
- package/.pi/skills/bpmn-package-explorer/scripts/identifiers.mjs +117 -0
- package/.pi/skills/bpmn-package-explorer/scripts/ingest.mjs +95 -0
- package/.pi/skills/bpmn-package-explorer/scripts/manifest.mjs +374 -0
- package/.pi/skills/bpmn-package-explorer/scripts/pipeline.mjs +49 -0
- package/.pi/skills/bpmn-package-explorer/scripts/render.mjs +130 -0
- package/.pi/skills/bpmn-package-explorer/scripts/runguard.mjs +38 -0
- package/.pi/skills/bpmn-package-explorer/scripts/selftest-e2e.mjs +87 -0
- package/.pi/skills/bpmn-package-explorer/scripts/selftest-guard.mjs +99 -0
- package/.pi/skills/bpmn-package-explorer/scripts/selftest-manifest.mjs +170 -0
- package/.pi/skills/bpmn-package-explorer/scripts/selftest-more.mjs +87 -0
- package/.pi/skills/bpmn-package-explorer/scripts/selftest-workflow.mjs +73 -0
- package/.pi/skills/bpmn-package-explorer/scripts/selftest.mjs +57 -0
- package/.pi/skills/bpmn-package-explorer/scripts/vendor.mjs +141 -0
- package/.pi/skills/bpmn-package-explorer/scripts/view-cli.mjs +19 -0
- package/.pi/skills/bpmn-package-explorer/templates/shell.html +141 -0
- package/.pi/skills/bpmn-package-explorer/templates/viewer.js +301 -0
- package/.pi/skills/canvas-webapp/SKILL.md +104 -0
- package/.pi/skills/openforms-mui/SKILL.md +187 -0
- package/.pi/skills/openforms-mui/references/a11y.md +68 -0
- package/.pi/skills/openforms-mui/references/field-widget-map.md +64 -0
- package/.pi/skills/openforms-mui/references/hu-locale.md +45 -0
- package/.pi/skills/openforms-mui/references/logic.md +94 -0
- package/.pi/skills/openforms-mui/references/schema.md +94 -0
- package/.pi/skills/openforms-mui/references/theme-bridge.md +65 -0
- package/.pi/skills/openforms-mui/tools/canvas-serve.mjs +51 -0
- package/.pi/skills/openforms-mui/tools/demo-schema.json +80 -0
- package/.pi/skills/openforms-mui/tools/mockups/tokens.css +27 -0
- package/.pi/skills/openforms-mui/tools/mockups/ui-contract.tokens.json +16 -0
- package/.pi/skills/openforms-mui/tools/package-lock.json +5919 -0
- package/.pi/skills/openforms-mui/tools/package.json +61 -0
- package/.pi/skills/openforms-mui/tools/preview/RenderPanel.tsx +105 -0
- package/.pi/skills/openforms-mui/tools/preview/canvas-app.tsx +66 -0
- package/.pi/skills/openforms-mui/tools/preview/canvas-index.html +16 -0
- package/.pi/skills/openforms-mui/tools/preview/cli.ts +99 -0
- package/.pi/skills/openforms-mui/tools/preview/index.html +17 -0
- package/.pi/skills/openforms-mui/tools/preview/main.tsx +228 -0
- package/.pi/skills/openforms-mui/tools/preview/vite-plugin.ts +41 -0
- package/.pi/skills/openforms-mui/tools/scripts/assert-peer-deps.mjs +39 -0
- package/.pi/skills/openforms-mui/tools/src/OpenFormsMui.tsx +391 -0
- package/.pi/skills/openforms-mui/tools/src/css.d.ts +2 -0
- package/.pi/skills/openforms-mui/tools/src/fields/ErrorSummary.tsx +72 -0
- package/.pi/skills/openforms-mui/tools/src/fields/FieldRenderer.tsx +328 -0
- package/.pi/skills/openforms-mui/tools/src/fields/FieldShell.tsx +50 -0
- package/.pi/skills/openforms-mui/tools/src/fields/FileField.tsx +91 -0
- package/.pi/skills/openforms-mui/tools/src/fields/MatrixField.tsx +146 -0
- package/.pi/skills/openforms-mui/tools/src/fields/RepeaterField.tsx +82 -0
- package/.pi/skills/openforms-mui/tools/src/fields/SignatureCanvas.tsx +121 -0
- package/.pi/skills/openforms-mui/tools/src/fields/context.tsx +34 -0
- package/.pi/skills/openforms-mui/tools/src/fields/index.ts +7 -0
- package/.pi/skills/openforms-mui/tools/src/fields/label.ts +42 -0
- package/.pi/skills/openforms-mui/tools/src/fonts.ts +8 -0
- package/.pi/skills/openforms-mui/tools/src/i18n/dictionary.ts +58 -0
- package/.pi/skills/openforms-mui/tools/src/i18n/hu.ts +56 -0
- package/.pi/skills/openforms-mui/tools/src/i18n/index.ts +43 -0
- package/.pi/skills/openforms-mui/tools/src/index.ts +27 -0
- package/.pi/skills/openforms-mui/tools/src/logic/cnf.ts +206 -0
- package/.pi/skills/openforms-mui/tools/src/logic/formula.ts +285 -0
- package/.pi/skills/openforms-mui/tools/src/logic/index.ts +4 -0
- package/.pi/skills/openforms-mui/tools/src/logic/operators.ts +43 -0
- package/.pi/skills/openforms-mui/tools/src/logic/state.ts +183 -0
- package/.pi/skills/openforms-mui/tools/src/payload.ts +83 -0
- package/.pi/skills/openforms-mui/tools/src/provenance.ts +21 -0
- package/.pi/skills/openforms-mui/tools/src/schema/diagnose.ts +256 -0
- package/.pi/skills/openforms-mui/tools/src/schema/index.ts +4 -0
- package/.pi/skills/openforms-mui/tools/src/schema/normalize.ts +163 -0
- package/.pi/skills/openforms-mui/tools/src/schema/types.ts +299 -0
- package/.pi/skills/openforms-mui/tools/src/schema/walk.ts +68 -0
- package/.pi/skills/openforms-mui/tools/src/theme/from-tokens.ts +102 -0
- package/.pi/skills/openforms-mui/tools/src/theme/index.ts +1 -0
- package/.pi/skills/openforms-mui/tools/src/validation/constrain.ts +83 -0
- package/.pi/skills/openforms-mui/tools/src/validation/diagnostics.ts +62 -0
- package/.pi/skills/openforms-mui/tools/src/validation/empty.ts +53 -0
- package/.pi/skills/openforms-mui/tools/src/validation/index.ts +5 -0
- package/.pi/skills/openforms-mui/tools/src/validation/resolver.ts +14 -0
- package/.pi/skills/openforms-mui/tools/src/validation/zod-from-schema.ts +169 -0
- package/.pi/skills/openforms-mui/tools/tests/a11y.test.tsx +82 -0
- package/.pi/skills/openforms-mui/tools/tests/cli.test.ts +74 -0
- package/.pi/skills/openforms-mui/tools/tests/component.test.tsx +295 -0
- package/.pi/skills/openforms-mui/tools/tests/diagnose.test.ts +163 -0
- package/.pi/skills/openforms-mui/tools/tests/fixtures/all-field-types.json +45 -0
- package/.pi/skills/openforms-mui/tools/tests/logic.test.ts +175 -0
- package/.pi/skills/openforms-mui/tools/tests/normalize.test.ts +105 -0
- package/.pi/skills/openforms-mui/tools/tests/reference-semantics.test.ts +131 -0
- package/.pi/skills/openforms-mui/tools/tests/responsive.test.tsx +158 -0
- package/.pi/skills/openforms-mui/tools/tests/setup.ts +16 -0
- package/.pi/skills/openforms-mui/tools/tests/singleton.test.tsx +31 -0
- package/.pi/skills/openforms-mui/tools/tests/theme.test.ts +65 -0
- package/.pi/skills/openforms-mui/tools/tests/toolchain.test.ts +33 -0
- package/.pi/skills/openforms-mui/tools/tests/validation.test.ts +222 -0
- package/.pi/skills/openforms-mui/tools/tsconfig.json +21 -0
- package/.pi/skills/openforms-mui/tools/vite.canvas.config.ts +21 -0
- package/.pi/skills/openforms-mui/tools/vitest.config.ts +17 -0
- package/NOTICE +46 -0
- package/README.md +62 -0
- package/package.json +46 -0
- package/scripts/ensure-openforms-deps.mjs +38 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Non-mutating schema normalization.
|
|
3
|
+
*
|
|
4
|
+
* `normalizeSchema` accepts partial, empty, null, or legacy input and returns a
|
|
5
|
+
* fully-populated schema plus the diagnostics raised while migrating legacy
|
|
6
|
+
* forms. It deep-clones its input, so the caller's object is never mutated, and
|
|
7
|
+
* generates deterministic ids (by position), so normalizing twice equals
|
|
8
|
+
* normalizing once.
|
|
9
|
+
*/
|
|
10
|
+
import type {
|
|
11
|
+
Column,
|
|
12
|
+
ConditionalRule,
|
|
13
|
+
CrossFieldRule,
|
|
14
|
+
Diagnostic,
|
|
15
|
+
Field,
|
|
16
|
+
FormSchemaJSON,
|
|
17
|
+
LegacyVisibilityCondition,
|
|
18
|
+
Page,
|
|
19
|
+
Row,
|
|
20
|
+
Section,
|
|
21
|
+
} from "./types.js";
|
|
22
|
+
|
|
23
|
+
export interface NormalizeResult {
|
|
24
|
+
schema: FormSchemaJSON;
|
|
25
|
+
diagnostics: Diagnostic[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function migrateLegacyVisibility(legacy: LegacyVisibilityCondition): ConditionalRule {
|
|
29
|
+
return {
|
|
30
|
+
targetProperty: "visibility",
|
|
31
|
+
andGroups: [
|
|
32
|
+
{
|
|
33
|
+
conditions: [
|
|
34
|
+
{
|
|
35
|
+
dependentFieldKey: legacy.dependentFieldKey,
|
|
36
|
+
operator: legacy.operator,
|
|
37
|
+
...(legacy.compareMode ? { compareMode: legacy.compareMode } : {}),
|
|
38
|
+
...(legacy.compareToFieldKey ? { compareToFieldKey: legacy.compareToFieldKey } : {}),
|
|
39
|
+
...(Object.prototype.hasOwnProperty.call(legacy, "equalsValue")
|
|
40
|
+
? { equalsValue: legacy.equalsValue }
|
|
41
|
+
: {}),
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function normalizeField(input: Field, path: string, diagnostics: Diagnostic[]): Field {
|
|
50
|
+
// Deep clone via structuredClone so nested rules/options are never shared.
|
|
51
|
+
const field: Field = structuredClone(input);
|
|
52
|
+
if (!field.id) field.id = `${path}-field`;
|
|
53
|
+
|
|
54
|
+
// Legacy visibilityCondition -> conditionalRules (info diagnostic per element).
|
|
55
|
+
if (field.visibilityCondition) {
|
|
56
|
+
const migrated = migrateLegacyVisibility(field.visibilityCondition);
|
|
57
|
+
field.conditionalRules = [...(field.conditionalRules ?? []), migrated];
|
|
58
|
+
delete field.visibilityCondition;
|
|
59
|
+
diagnostics.push({
|
|
60
|
+
severity: "info",
|
|
61
|
+
code: "legacy-visibility-migrated",
|
|
62
|
+
message: `Field "${field.key}" migrated legacy visibilityCondition to a conditionalRules entry; update the source schema.`,
|
|
63
|
+
path,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Recurse into a repeater's nested layout.
|
|
68
|
+
if (field.type === "repeater" && field.rows) {
|
|
69
|
+
field.rows = field.rows.map((row, i) => normalizeRow(row, `${path}-repeater-row-${i}`, diagnostics));
|
|
70
|
+
}
|
|
71
|
+
return field;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function normalizeColumn(input: Column, path: string, diagnostics: Diagnostic[]): Column {
|
|
75
|
+
const column: Column = { ...input };
|
|
76
|
+
if (!column.columnId) column.columnId = `${path}-col`;
|
|
77
|
+
column.fields = (input.fields ?? []).map((f, i) =>
|
|
78
|
+
normalizeField(f, `${path}-f${i}`, diagnostics),
|
|
79
|
+
);
|
|
80
|
+
return column;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function normalizeRow(input: Row, path: string, diagnostics: Diagnostic[]): Row {
|
|
84
|
+
const row: Row = { ...input };
|
|
85
|
+
if (!row.rowId) row.rowId = `${path}-row`;
|
|
86
|
+
row.columns = (input.columns ?? []).map((c, i) =>
|
|
87
|
+
normalizeColumn(c, `${path}-c${i}`, diagnostics),
|
|
88
|
+
);
|
|
89
|
+
return row;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function normalizeSection(input: Section, path: string, diagnostics: Diagnostic[]): Section {
|
|
93
|
+
const section: Section = { ...input };
|
|
94
|
+
if (!section.sectionId) section.sectionId = `${path}-section`;
|
|
95
|
+
|
|
96
|
+
if (section.visibilityCondition) {
|
|
97
|
+
const migrated = migrateLegacyVisibility(section.visibilityCondition);
|
|
98
|
+
section.conditionalRules = [...(section.conditionalRules ?? []), migrated];
|
|
99
|
+
delete section.visibilityCondition;
|
|
100
|
+
diagnostics.push({
|
|
101
|
+
severity: "info",
|
|
102
|
+
code: "legacy-visibility-migrated",
|
|
103
|
+
message: `Section "${section.sectionId}" migrated legacy visibilityCondition to a conditionalRules entry; update the source schema.`,
|
|
104
|
+
path,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (section.conditionalRules) section.conditionalRules = structuredClone(section.conditionalRules);
|
|
108
|
+
|
|
109
|
+
section.rows = (input.rows ?? []).map((r, i) =>
|
|
110
|
+
normalizeRow(r, `${path}-r${i}`, diagnostics),
|
|
111
|
+
);
|
|
112
|
+
return section;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function normalizePage(input: Page, path: string, diagnostics: Diagnostic[]): Page {
|
|
116
|
+
const page: Page = { ...input };
|
|
117
|
+
if (!page.pageId) page.pageId = `${path}-page`;
|
|
118
|
+
|
|
119
|
+
const sections = input.sections && input.sections.length > 0 ? input.sections : [{ rows: [] }];
|
|
120
|
+
page.sections = sections.map((s, i) => normalizeSection(s, `${path}-s${i}`, diagnostics));
|
|
121
|
+
return page;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function normalizeCrossFieldRule(
|
|
125
|
+
input: CrossFieldRule,
|
|
126
|
+
index: number,
|
|
127
|
+
diagnostics: Diagnostic[],
|
|
128
|
+
): CrossFieldRule {
|
|
129
|
+
const rule: CrossFieldRule = structuredClone(input);
|
|
130
|
+
if (!rule.id) rule.id = `crossrule-${index}`;
|
|
131
|
+
if (rule.expression && !rule.andGroups) {
|
|
132
|
+
diagnostics.push({
|
|
133
|
+
severity: "info",
|
|
134
|
+
code: "legacy-expression-retained",
|
|
135
|
+
message: `Cross-field rule "${rule.id}" uses a free-text expression; migrate it to andGroups.`,
|
|
136
|
+
path: `crossFieldRules[${index}]`,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return rule;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Normalize an arbitrary schema-ish input into a complete `FormSchemaJSON`.
|
|
144
|
+
* Never mutates its input.
|
|
145
|
+
*/
|
|
146
|
+
export function normalizeSchema(input: Partial<FormSchemaJSON> | null | undefined): NormalizeResult {
|
|
147
|
+
const diagnostics: Diagnostic[] = [];
|
|
148
|
+
|
|
149
|
+
const src = input ?? {};
|
|
150
|
+
const pages = src.pages && src.pages.length > 0 ? src.pages : [{ sections: [{ rows: [] }] }];
|
|
151
|
+
|
|
152
|
+
const schema: FormSchemaJSON = {
|
|
153
|
+
...(src.formTitle !== undefined ? { formTitle: src.formTitle } : {}),
|
|
154
|
+
...(src.formDescription !== undefined ? { formDescription: src.formDescription } : {}),
|
|
155
|
+
pages: pages.map((p, i) => normalizePage(p, `p${i}`, diagnostics)),
|
|
156
|
+
...(src.crossFieldRules
|
|
157
|
+
? { crossFieldRules: src.crossFieldRules.map((r, i) => normalizeCrossFieldRule(r, i, diagnostics)) }
|
|
158
|
+
: {}),
|
|
159
|
+
...(src.translations ? { translations: structuredClone(src.translations) } : {}),
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
return { schema, diagnostics };
|
|
163
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript contract for the OpenForms `FormSchemaJSON`.
|
|
3
|
+
*
|
|
4
|
+
* The 14 field types are modelled as a discriminated union on `type`, so that a
|
|
5
|
+
* type-specific property (e.g. `matrixRows`, `formulaExpression`) is only
|
|
6
|
+
* reachable on the field types that declare it. Re-implemented from the upstream
|
|
7
|
+
* `SCHEMA_REFERENCE.md`; no upstream source is copied.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Logic primitives (shared by conditionalRules and crossFieldRules)
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
export type Operator =
|
|
15
|
+
| "equals"
|
|
16
|
+
| "notEquals"
|
|
17
|
+
| "contains"
|
|
18
|
+
| "notContains"
|
|
19
|
+
| "greaterThan"
|
|
20
|
+
| "greaterThanOrEquals"
|
|
21
|
+
| "lessThan"
|
|
22
|
+
| "lessThanOrEquals"
|
|
23
|
+
// Undocumented but genuine upstream aliases:
|
|
24
|
+
| "gte"
|
|
25
|
+
| "lte";
|
|
26
|
+
|
|
27
|
+
export type CompareMode = "value" | "field";
|
|
28
|
+
|
|
29
|
+
/** A single condition inspecting one field's answer. */
|
|
30
|
+
export interface Condition {
|
|
31
|
+
dependentFieldKey: string;
|
|
32
|
+
operator: Operator | string; // string tolerated: unknown operators fall back to `equals`.
|
|
33
|
+
compareMode?: CompareMode;
|
|
34
|
+
/** Static operand, used when compareMode is `"value"` or absent. */
|
|
35
|
+
equalsValue?: unknown;
|
|
36
|
+
/** Field whose live answer is the operand, used when compareMode is `"field"`. */
|
|
37
|
+
compareToFieldKey?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A CNF group: OR within, satisfied when at least one condition is satisfied. */
|
|
41
|
+
export interface ConditionGroup {
|
|
42
|
+
conditions: Condition[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type TargetProperty = "visibility" | "required" | "disabled";
|
|
46
|
+
|
|
47
|
+
/** Field/section conditional rule. AND between groups, OR within a group. */
|
|
48
|
+
export interface ConditionalRule {
|
|
49
|
+
targetProperty: TargetProperty;
|
|
50
|
+
andGroups: ConditionGroup[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Root-level cross-field rule; a satisfied rule is a *violation* that blocks. */
|
|
54
|
+
export interface CrossFieldRule {
|
|
55
|
+
id?: string;
|
|
56
|
+
andGroups?: ConditionGroup[];
|
|
57
|
+
/** Legacy free-text form, retained for evaluation and flagged by diagnostics. */
|
|
58
|
+
expression?: string;
|
|
59
|
+
targetFields: string[];
|
|
60
|
+
errorMessage: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Legacy visibility form migrated by `normalizeSchema`. */
|
|
64
|
+
export interface LegacyVisibilityCondition {
|
|
65
|
+
dependentFieldKey: string;
|
|
66
|
+
operator: Operator | string;
|
|
67
|
+
compareMode?: CompareMode;
|
|
68
|
+
equalsValue?: unknown;
|
|
69
|
+
compareToFieldKey?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Options
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
export interface FieldOption {
|
|
77
|
+
value: string;
|
|
78
|
+
label: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type OptionsType = "static" | "api";
|
|
82
|
+
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
// Field base + per-type fields (discriminated union on `type`)
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
|
|
87
|
+
export interface FieldBase {
|
|
88
|
+
id?: string;
|
|
89
|
+
key: string;
|
|
90
|
+
label?: string;
|
|
91
|
+
placeholder?: string;
|
|
92
|
+
helpText?: string;
|
|
93
|
+
required?: boolean;
|
|
94
|
+
disabled?: boolean;
|
|
95
|
+
conditionalRules?: ConditionalRule[];
|
|
96
|
+
/** Legacy alternative to conditionalRules; migrated on normalization. */
|
|
97
|
+
visibilityCondition?: LegacyVisibilityCondition;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface HeaderField extends FieldBase {
|
|
101
|
+
type: "header";
|
|
102
|
+
}
|
|
103
|
+
export interface ParagraphField extends FieldBase {
|
|
104
|
+
type: "paragraph";
|
|
105
|
+
}
|
|
106
|
+
export interface TextField extends FieldBase {
|
|
107
|
+
type: "text";
|
|
108
|
+
mask?: string;
|
|
109
|
+
validationRegex?: string;
|
|
110
|
+
errorMessage?: string;
|
|
111
|
+
maxLength?: number;
|
|
112
|
+
}
|
|
113
|
+
export interface TextareaField extends FieldBase {
|
|
114
|
+
type: "textarea";
|
|
115
|
+
validationRegex?: string;
|
|
116
|
+
errorMessage?: string;
|
|
117
|
+
maxLength?: number;
|
|
118
|
+
rows?: number;
|
|
119
|
+
}
|
|
120
|
+
export interface NumberField extends FieldBase {
|
|
121
|
+
type: "number";
|
|
122
|
+
min?: number;
|
|
123
|
+
max?: number;
|
|
124
|
+
/** Calculated fields derive their value and accept no direct input. */
|
|
125
|
+
isCalculated?: boolean;
|
|
126
|
+
formulaExpression?: string;
|
|
127
|
+
/** Meaningful only alongside `isCalculated: true`. */
|
|
128
|
+
isVisibleOnForm?: boolean;
|
|
129
|
+
}
|
|
130
|
+
export interface DateField extends FieldBase {
|
|
131
|
+
type: "date";
|
|
132
|
+
min?: string;
|
|
133
|
+
max?: string;
|
|
134
|
+
}
|
|
135
|
+
export interface BooleanField extends FieldBase {
|
|
136
|
+
type: "boolean";
|
|
137
|
+
}
|
|
138
|
+
export interface DropdownField extends FieldBase {
|
|
139
|
+
type: "dropdown";
|
|
140
|
+
options?: FieldOption[];
|
|
141
|
+
optionsType?: OptionsType;
|
|
142
|
+
optionsUrl?: string;
|
|
143
|
+
}
|
|
144
|
+
export interface RadioField extends FieldBase {
|
|
145
|
+
type: "radio";
|
|
146
|
+
options?: FieldOption[];
|
|
147
|
+
optionsType?: OptionsType;
|
|
148
|
+
optionsUrl?: string;
|
|
149
|
+
}
|
|
150
|
+
export interface CheckboxField extends FieldBase {
|
|
151
|
+
type: "checkbox";
|
|
152
|
+
options?: FieldOption[];
|
|
153
|
+
optionsType?: OptionsType;
|
|
154
|
+
optionsUrl?: string;
|
|
155
|
+
}
|
|
156
|
+
export interface MatrixField extends FieldBase {
|
|
157
|
+
type: "matrix";
|
|
158
|
+
matrixRows?: FieldOption[];
|
|
159
|
+
matrixColumns?: FieldOption[];
|
|
160
|
+
}
|
|
161
|
+
export interface RepeaterField extends FieldBase {
|
|
162
|
+
type: "repeater";
|
|
163
|
+
/** Nested layout; its own rows/columns/fields. */
|
|
164
|
+
rows?: Row[];
|
|
165
|
+
minItems?: number;
|
|
166
|
+
maxItems?: number;
|
|
167
|
+
addLabel?: string;
|
|
168
|
+
removeLabel?: string;
|
|
169
|
+
}
|
|
170
|
+
export interface SignatureField extends FieldBase {
|
|
171
|
+
type: "signature";
|
|
172
|
+
}
|
|
173
|
+
export interface FileField extends FieldBase {
|
|
174
|
+
type: "file";
|
|
175
|
+
acceptedTypes?: string[];
|
|
176
|
+
maxFileSizeMB?: number;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export type Field =
|
|
180
|
+
| HeaderField
|
|
181
|
+
| ParagraphField
|
|
182
|
+
| TextField
|
|
183
|
+
| TextareaField
|
|
184
|
+
| NumberField
|
|
185
|
+
| DateField
|
|
186
|
+
| BooleanField
|
|
187
|
+
| DropdownField
|
|
188
|
+
| RadioField
|
|
189
|
+
| CheckboxField
|
|
190
|
+
| MatrixField
|
|
191
|
+
| RepeaterField
|
|
192
|
+
| SignatureField
|
|
193
|
+
| FileField;
|
|
194
|
+
|
|
195
|
+
export type FieldType = Field["type"];
|
|
196
|
+
|
|
197
|
+
/** Field types that never contribute an answer entry. */
|
|
198
|
+
export const STATIC_FIELD_TYPES = ["header", "paragraph"] as const;
|
|
199
|
+
|
|
200
|
+
/** Field types that carry a selectable option list. */
|
|
201
|
+
export const OPTION_FIELD_TYPES = ["dropdown", "radio", "checkbox"] as const;
|
|
202
|
+
|
|
203
|
+
// ---------------------------------------------------------------------------
|
|
204
|
+
// Layout hierarchy
|
|
205
|
+
// ---------------------------------------------------------------------------
|
|
206
|
+
|
|
207
|
+
export interface Column {
|
|
208
|
+
columnId?: string;
|
|
209
|
+
/** Span out of 12 at the `md` breakpoint and above. */
|
|
210
|
+
width?: number;
|
|
211
|
+
fields: Field[];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface Row {
|
|
215
|
+
rowId?: string;
|
|
216
|
+
columns: Column[];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface Section {
|
|
220
|
+
sectionId?: string;
|
|
221
|
+
title?: string;
|
|
222
|
+
description?: string;
|
|
223
|
+
rows: Row[];
|
|
224
|
+
conditionalRules?: ConditionalRule[];
|
|
225
|
+
visibilityCondition?: LegacyVisibilityCondition;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface Page {
|
|
229
|
+
pageId?: string;
|
|
230
|
+
title?: string;
|
|
231
|
+
description?: string;
|
|
232
|
+
sections: Section[];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface FormSchemaJSON {
|
|
236
|
+
formTitle?: string;
|
|
237
|
+
formDescription?: string;
|
|
238
|
+
pages: Page[];
|
|
239
|
+
crossFieldRules?: CrossFieldRule[];
|
|
240
|
+
translations?: TranslationsDictionary;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** locale -> (translation key -> text). */
|
|
244
|
+
export type TranslationsDictionary = Record<string, Record<string, string>>;
|
|
245
|
+
|
|
246
|
+
// ---------------------------------------------------------------------------
|
|
247
|
+
// Answer-shape types (task 2.2)
|
|
248
|
+
// ---------------------------------------------------------------------------
|
|
249
|
+
|
|
250
|
+
export type MatrixAnswer = { [rowKey: string]: string };
|
|
251
|
+
export type RepeaterAnswer = Array<{ [childKey: string]: AnswerValue }>;
|
|
252
|
+
export interface FileAnswer {
|
|
253
|
+
name: string;
|
|
254
|
+
size: number;
|
|
255
|
+
type: string;
|
|
256
|
+
/** base64 data URL. */
|
|
257
|
+
content: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export type AnswerValue =
|
|
261
|
+
| string
|
|
262
|
+
| number
|
|
263
|
+
| boolean
|
|
264
|
+
| string[]
|
|
265
|
+
| MatrixAnswer
|
|
266
|
+
| RepeaterAnswer
|
|
267
|
+
| FileAnswer
|
|
268
|
+
| null;
|
|
269
|
+
|
|
270
|
+
/** Maps a field type to the shape of its submitted value. */
|
|
271
|
+
export type AnswerOf<F extends Field> = F extends { type: "text" | "textarea" | "date" | "signature" }
|
|
272
|
+
? string
|
|
273
|
+
: F extends { type: "number" }
|
|
274
|
+
? number | null
|
|
275
|
+
: F extends { type: "boolean" }
|
|
276
|
+
? boolean
|
|
277
|
+
: F extends { type: "dropdown" | "radio" }
|
|
278
|
+
? string
|
|
279
|
+
: F extends { type: "checkbox" }
|
|
280
|
+
? string[]
|
|
281
|
+
: F extends { type: "matrix" }
|
|
282
|
+
? MatrixAnswer
|
|
283
|
+
: F extends { type: "repeater" }
|
|
284
|
+
? RepeaterAnswer
|
|
285
|
+
: F extends { type: "file" }
|
|
286
|
+
? FileAnswer | null
|
|
287
|
+
: never;
|
|
288
|
+
|
|
289
|
+
/** A loosely-typed answers object keyed by field `key`. */
|
|
290
|
+
export type FormAnswers = Record<string, AnswerValue>;
|
|
291
|
+
|
|
292
|
+
/** Diagnostic finding shape shared by `normalizeSchema` and `diagnose`. */
|
|
293
|
+
export type Severity = "error" | "warning" | "info";
|
|
294
|
+
export interface Diagnostic {
|
|
295
|
+
severity: Severity;
|
|
296
|
+
code: string;
|
|
297
|
+
message: string;
|
|
298
|
+
path: string;
|
|
299
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Depth-first traversal helpers shared by diagnostics, validation and rendering.
|
|
3
|
+
* A single traversal definition keeps path strings and nesting context
|
|
4
|
+
* consistent across every consumer.
|
|
5
|
+
*/
|
|
6
|
+
import type { Field, FormSchemaJSON, Section } from "./types.js";
|
|
7
|
+
|
|
8
|
+
export interface FieldVisit {
|
|
9
|
+
field: Field;
|
|
10
|
+
path: string;
|
|
11
|
+
/** Depth of enclosing repeaters (0 at top level, >=1 inside a repeater). */
|
|
12
|
+
repeaterDepth: number;
|
|
13
|
+
/** Depth of enclosing matrices via repeaters is not possible; kept for symmetry. */
|
|
14
|
+
insideRepeater: boolean;
|
|
15
|
+
sectionPath: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Visit every field, descending into repeater sub-layouts. */
|
|
19
|
+
export function walkFields(schema: FormSchemaJSON, visit: (v: FieldVisit) => void): void {
|
|
20
|
+
schema.pages.forEach((page, pi) => {
|
|
21
|
+
page.sections.forEach((section, si) => {
|
|
22
|
+
walkSectionFields(section, `pages[${pi}].sections[${si}]`, 0, visit);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function walkSectionFields(
|
|
28
|
+
section: Section,
|
|
29
|
+
sectionPath: string,
|
|
30
|
+
repeaterDepth: number,
|
|
31
|
+
visit: (v: FieldVisit) => void,
|
|
32
|
+
): void {
|
|
33
|
+
section.rows.forEach((row, ri) => {
|
|
34
|
+
row.columns.forEach((col, ci) => {
|
|
35
|
+
col.fields.forEach((field, fi) => {
|
|
36
|
+
const path = `${sectionPath}.rows[${ri}].columns[${ci}].fields[${fi}]`;
|
|
37
|
+
visit({ field, path, repeaterDepth, insideRepeater: repeaterDepth > 0, sectionPath });
|
|
38
|
+
if (field.type === "repeater" && field.rows) {
|
|
39
|
+
field.rows.forEach((rrow, rri) => {
|
|
40
|
+
rrow.columns.forEach((rcol, rci) => {
|
|
41
|
+
rcol.fields.forEach((rfield, rfi) => {
|
|
42
|
+
const rpath = `${path}.rows[${rri}].columns[${rci}].fields[${rfi}]`;
|
|
43
|
+
visit({
|
|
44
|
+
field: rfield,
|
|
45
|
+
path: rpath,
|
|
46
|
+
repeaterDepth: repeaterDepth + 1,
|
|
47
|
+
insideRepeater: true,
|
|
48
|
+
sectionPath,
|
|
49
|
+
});
|
|
50
|
+
// A repeater nested inside a repeater is diagnosed elsewhere; do
|
|
51
|
+
// not descend further to avoid unbounded surprising traversal.
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Collect every field key across the whole schema, including repeater children. */
|
|
62
|
+
export function collectFieldKeys(schema: FormSchemaJSON): string[] {
|
|
63
|
+
const keys: string[] = [];
|
|
64
|
+
walkFields(schema, ({ field }) => {
|
|
65
|
+
if (field.type !== "header" && field.type !== "paragraph") keys.push(field.key);
|
|
66
|
+
});
|
|
67
|
+
return keys;
|
|
68
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge a `ui-contract.tokens.json` (DTCG design-token) file to a MUI theme.
|
|
3
|
+
*
|
|
4
|
+
* MUI's control plane is the theme object, not utility classes (design D9).
|
|
5
|
+
* Tokens map into `createTheme()` here once; widgets then read colour, spacing
|
|
6
|
+
* and typography from the theme and carry no literal values, which keeps the
|
|
7
|
+
* token-lint gate (task 5.3) satisfiable and lets a form inherit any project's
|
|
8
|
+
* design system unchanged.
|
|
9
|
+
*/
|
|
10
|
+
import { createTheme, type Theme, type ThemeOptions } from "@mui/material/styles";
|
|
11
|
+
|
|
12
|
+
/** A DTCG token node: `{ "$value": ... , "$type"?: ... }` or a nested group. */
|
|
13
|
+
export interface DtcgNode {
|
|
14
|
+
$value?: unknown;
|
|
15
|
+
$type?: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface UiContractTokens {
|
|
20
|
+
[group: string]: DtcgNode | UiContractTokens | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function tokenValue(root: UiContractTokens | undefined, path: string[]): string | number | undefined {
|
|
24
|
+
let node: unknown = root;
|
|
25
|
+
for (const seg of path) {
|
|
26
|
+
if (!node || typeof node !== "object") return undefined;
|
|
27
|
+
node = (node as Record<string, unknown>)[seg];
|
|
28
|
+
}
|
|
29
|
+
if (node && typeof node === "object" && "$value" in (node as object)) {
|
|
30
|
+
const v = (node as DtcgNode).$value;
|
|
31
|
+
return typeof v === "string" || typeof v === "number" ? v : undefined;
|
|
32
|
+
}
|
|
33
|
+
return typeof node === "string" || typeof node === "number" ? node : undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The documented default theme used when no token file is present (task 5.2). */
|
|
37
|
+
export function defaultTheme(): Theme {
|
|
38
|
+
return createTheme({
|
|
39
|
+
palette: {
|
|
40
|
+
mode: "light",
|
|
41
|
+
primary: { main: "#1565c0" },
|
|
42
|
+
secondary: { main: "#6a1b9a" },
|
|
43
|
+
error: { main: "#c62828" },
|
|
44
|
+
warning: { main: "#ed6c02" },
|
|
45
|
+
success: { main: "#2e7d32" },
|
|
46
|
+
background: { default: "#ffffff", paper: "#ffffff" },
|
|
47
|
+
},
|
|
48
|
+
shape: { borderRadius: 8 },
|
|
49
|
+
typography: {
|
|
50
|
+
fontFamily: 'Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
51
|
+
},
|
|
52
|
+
spacing: 8,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Build a MUI theme from a DTCG token object. Missing tokens fall back to the
|
|
58
|
+
* default theme's values, so a partial token file still yields a complete theme.
|
|
59
|
+
*/
|
|
60
|
+
export function themeFromTokens(tokens: UiContractTokens | null | undefined): Theme {
|
|
61
|
+
if (!tokens) return defaultTheme();
|
|
62
|
+
const base = defaultTheme();
|
|
63
|
+
|
|
64
|
+
const pick = (path: string[], fallback: string | number): string | number =>
|
|
65
|
+
tokenValue(tokens, path) ?? fallback;
|
|
66
|
+
|
|
67
|
+
const options: ThemeOptions = {
|
|
68
|
+
palette: {
|
|
69
|
+
mode: (tokenValue(tokens, ["color", "mode"]) as "light" | "dark") ?? "light",
|
|
70
|
+
primary: { main: String(pick(["color", "primary"], base.palette.primary.main)) },
|
|
71
|
+
secondary: { main: String(pick(["color", "secondary"], base.palette.secondary.main)) },
|
|
72
|
+
error: { main: String(pick(["color", "error"], base.palette.error.main)) },
|
|
73
|
+
warning: { main: String(pick(["color", "warning"], base.palette.warning.main)) },
|
|
74
|
+
success: { main: String(pick(["color", "success"], base.palette.success.main)) },
|
|
75
|
+
background: {
|
|
76
|
+
default: String(pick(["color", "background", "default"], base.palette.background.default)),
|
|
77
|
+
paper: String(pick(["color", "background", "paper"], base.palette.background.paper)),
|
|
78
|
+
},
|
|
79
|
+
...(tokenValue(tokens, ["color", "text", "primary"])
|
|
80
|
+
? { text: { primary: String(tokenValue(tokens, ["color", "text", "primary"])) } }
|
|
81
|
+
: {}),
|
|
82
|
+
},
|
|
83
|
+
shape: {
|
|
84
|
+
borderRadius: Number(pick(["radius", "base"], base.shape.borderRadius)),
|
|
85
|
+
},
|
|
86
|
+
typography: {
|
|
87
|
+
fontFamily: String(pick(["font", "family", "base"], base.typography.fontFamily ?? "Roboto")),
|
|
88
|
+
},
|
|
89
|
+
spacing: Number(pick(["spacing", "unit"], 8)),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return createTheme(options);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Convenience: parse a raw JSON string token file into a theme. */
|
|
96
|
+
export function themeFromTokensJson(json: string): Theme {
|
|
97
|
+
try {
|
|
98
|
+
return themeFromTokens(JSON.parse(json) as UiContractTokens);
|
|
99
|
+
} catch {
|
|
100
|
+
return defaultTheme();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./from-tokens.js";
|