@formhaus/core 0.11.1 → 0.11.2
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/dist/{check-definition-BTMV3Ziq.d.ts → check-definition-B-YU_XN6.d.ts} +2 -2
- package/dist/chunk-NAKPTXVB.js +5 -0
- package/dist/chunk-NAKPTXVB.js.map +1 -0
- package/dist/{chunk-IVSO5ANU.js → chunk-TTELQZQA.js} +3 -3
- package/dist/{chunk-IVSO5ANU.js.map → chunk-TTELQZQA.js.map} +1 -1
- package/dist/chunk-XLTPGPGA.js +3 -0
- package/dist/chunk-XLTPGPGA.js.map +1 -0
- package/dist/cloud.d.ts +3 -3
- package/dist/cloud.js +1 -1
- package/dist/{controller-CUZ5bMpv.d.ts → controller-DXb698eH.d.ts} +1 -1
- package/dist/{definition-Bufih_Bx.d.ts → definition-PdtKhxBh.d.ts} +2 -1
- package/dist/index.d.ts +11 -7
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +4 -4
- package/dist/internal.js +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/{runtime-LNJU0Dra.d.ts → runtime-Bmzuud3o.d.ts} +2 -2
- package/dist/server.d.ts +4 -4
- package/dist/server.iife.js +3 -3
- package/dist/server.iife.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/{validate-field-glVVoN3E.d.ts → validate-field-dZd5yZAp.d.ts} +3 -3
- package/package.json +1 -1
- package/schema/form-definition.schema.json +5 -0
- package/style.css +28 -32
- package/dist/chunk-47C7QX7J.js +0 -5
- package/dist/chunk-47C7QX7J.js.map +0 -1
- package/dist/chunk-YXQFFAXK.js +0 -3
- package/dist/chunk-YXQFFAXK.js.map +0 -1
package/dist/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {d,g,f}from'./chunk-NAKPTXVB.js';export{a as FormDefinitionError,c as checkDefinition,d as parseDefinition}from'./chunk-NAKPTXVB.js';import {b,l,m as m$1,z}from'./chunk-XLTPGPGA.js';var V='Pass the values object as the second argument, not the request body with "values" and "skippedSteps".',h=()=>null,m=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function D(e,t,n){let o=n!==null&&typeof n=="object"&&!Array.isArray(n)?n:{},i=f(e),r=[...new Set(t.map(({key:a})=>a))].filter(a=>m(o,a)),c={values:{},active:new Map};for(let a=0;a<=t.length;a++){let l$1={};for(let s of r)l$1[s]=l(c.active.get(s)??t.find(f=>f.key===s),o[s]);let u=new Map;for(let s of r){let f=i.activeField(s,l$1);f&&u.set(s,f);}let p=r.every(s=>u.get(s)===c.active.get(s));if(c={values:l$1,active:u},p)break}return c}function R({values:e,active:t}){let n=new Map;for(let[o,i]of t){let r=m$1(i,e[o]);r&&n.set(o,r);}return n}function A(e,t){let n=i=>i.map(r=>t.has(r.key)?{...r,validation:void 0}:r),o=e.steps?.map(i=>({...i,fields:n(i.fields)}));return {...e,...e.fields&&{fields:n(e.fields)},...o&&{steps:o}}}function E(e,t={}){let n={};for(let{validation:o}of e)o?.validator&&(n[o.validator]=h);return {...n,...t}}function O(e,t){return t===null||typeof t!="object"||!m(t,"values")?false:!e.some(n=>n.key==="values"||n.key==="skippedSteps")}function M(e,t){if(!Array.isArray(t))return;let n=new Set(t);for(let o=0;o<e.visibleSteps.length;o++){let i=e.visibleSteps[o];i.skip&&n.has(i.id)&&z(e,o);}}function x(e,t,n={}){d(e);let o=b(e),i=D(e,o,t),r=R(i),c={validators:E(o,n.validators),onWarning:()=>{}},a=new g(A(e,r),i.values,c);M(a,n.skippedSteps);let l=a.validate(),u=a.getSubmitValues();for(let[p,s]of r)m(u,p)&&(l[p]=s);return O(o,t)&&(l.values=V),{values:u,errors:l}}export{x as validateSubmission};//# sourceMappingURL=server.js.map
|
|
2
2
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/validate-submission.ts"],"names":["BODY_MESSAGE","allow","hasOwn","source","key","
|
|
1
|
+
{"version":3,"sources":["../src/server/validate-submission.ts"],"names":["BODY_MESSAGE","allow","hasOwn","source","key","activeValues","definition","fields","input","visibility","createVisibility","keys","result","round","values","normalizeValue","field","active","settled","typeErrors","errors","error","typeError","withoutRules","invalid","strip","steps","step","ignoredValidators","given","validators","validation","isBody","applySkips","engine","skippedSteps","requested","index","skipStepAt","validateSubmission","options","parseDefinition","getAllFields","resolved","engineOptions","FormEngine","submitted"],"mappings":"6LAeA,IAAMA,CAAAA,CAAe,uGAAA,CAOfC,CAAAA,CAAqB,IAAM,IAAA,CAE3BC,EAAS,CAACC,CAAAA,CAAgBC,CAAAA,GAAgB,MAAA,CAAO,SAAA,CAAU,cAAA,CAAe,KAAKD,CAAAA,CAAQC,CAAG,CAAA,CAOhG,SAASC,CAAAA,CAAaC,CAAAA,CAA4BC,EAAqBC,CAAAA,CAA8B,CACnG,IAAML,CAAAA,CAASK,CAAAA,GAAU,IAAA,EAAQ,OAAOA,CAAAA,EAAU,QAAA,EAAY,CAAC,KAAA,CAAM,OAAA,CAAQA,CAAK,EAAIA,CAAAA,CAAmC,EAAC,CACpHC,CAAAA,CAAaC,CAAAA,CAAiBJ,CAAU,EACxCK,CAAAA,CAAO,CAAC,GAAG,IAAI,GAAA,CAAIJ,CAAAA,CAAO,GAAA,CAAI,CAAC,CAAE,GAAA,CAAAH,CAAI,CAAA,GAAMA,CAAG,CAAC,CAAC,CAAA,CAAE,MAAA,CAAQA,CAAAA,EAAQF,CAAAA,CAAOC,CAAAA,CAAQC,CAAG,CAAC,CAAA,CACvFQ,CAAAA,CAAuB,CAAE,MAAA,CAAQ,EAAC,CAAG,OAAQ,IAAI,GAAM,CAAA,CAC3D,IAAA,IAASC,CAAAA,CAAQ,CAAA,CAAGA,CAAAA,EAASN,CAAAA,CAAO,MAAA,CAAQM,CAAAA,EAAAA,CAAS,CACnD,IAAMC,GAAAA,CAAkC,GACxC,IAAA,IAAWV,CAAAA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A,CAAIiB,CAAAA,CAAAA,CAC9E,OAAIW,CAAAA,CAAOzB,CAAAA,CAAQO,CAAM,CAAA,GAAGM,CAAAA,CAAO,MAAA,CAASpB,CAAAA,CAAAA,CACrC,CAAE,MAAA,CAAQ8C,CAAAA,CAAW,MAAA,CAAA1B,CAAO,CACrC","file":"server.js","sourcesContent":["import type { FormDefinition, FormField } from '../types';\nimport type { ValidatorFn } from '../validation';\nimport { parseDefinition } from '../definition-validation';\nimport { getAllFields } from '../engine/engine-utils';\nimport type { EngineInternals } from '../engine/runtime-internals';\nimport { FormEngine } from '../engine/runtime';\nimport { skipStepAt } from '../engine/step-skip';\nimport { createVisibility } from '../engine/visibility-state';\nimport { normalizeValue, typeError } from '../validation/type-checks';\n\nexport interface SubmissionOptions {\n skippedSteps?: string[];\n validators?: Record<string, ValidatorFn>;\n}\n\nconst BODY_MESSAGE = 'Pass the values object as the second argument, not the request body with \"values\" and \"skippedSteps\".';\n\nexport interface SubmissionResult {\n values: Record<string, unknown>;\n errors: Record<string, string>;\n}\n\nconst allow: ValidatorFn = () => null;\n\nconst hasOwn = (source: object, key: string) => Object.prototype.hasOwnProperty.call(source, key);\n\ninterface ActiveValues {\n values: Record<string, unknown>;\n active: Map<string, FormField>;\n}\n\nfunction activeValues(definition: FormDefinition, fields: FormField[], input: unknown): ActiveValues {\n const source = input !== null && typeof input === 'object' && !Array.isArray(input) ? input as Record<string, unknown> : {};\n const visibility = createVisibility(definition);\n const keys = [...new Set(fields.map(({ key }) => key))].filter((key) => hasOwn(source, key));\n let result: ActiveValues = { values: {}, active: new Map() };\n for (let round = 0; round <= fields.length; round++) {\n const values: Record<string, unknown> = {};\n for (const key of keys) values[key] = normalizeValue(result.active.get(key) ?? fields.find((field) => field.key === key)!, source[key]);\n const active = new Map<string, FormField>();\n for (const key of keys) {\n const field = visibility.activeField(key, values);\n if (field) active.set(key, field);\n }\n const settled = keys.every((key) => active.get(key) === result.active.get(key));\n result = { values, active };\n if (settled) break;\n }\n return result;\n}\n\nfunction typeErrors({ values, active }: ActiveValues): Map<string, string> {\n const errors = new Map<string, string>();\n for (const [key, field] of active) {\n const error = typeError(field, values[key]);\n if (error) errors.set(key, error);\n }\n return errors;\n}\n\nfunction withoutRules(definition: FormDefinition, invalid: Map<string, string>): FormDefinition {\n const strip = (fields: FormField[]) => fields.map((field) => (invalid.has(field.key) ? { ...field, validation: undefined } : field));\n const steps = definition.steps?.map((step) => ({ ...step, fields: strip(step.fields) }));\n return { ...definition, ...(definition.fields && { fields: strip(definition.fields) }), ...(steps && { steps }) };\n}\n\nfunction ignoredValidators(fields: FormField[], given: Record<string, ValidatorFn> = {}): Record<string, ValidatorFn> {\n const validators: Record<string, ValidatorFn> = {};\n for (const { validation } of fields) if (validation?.validator) validators[validation.validator] = allow;\n return { ...validators, ...given };\n}\n\nfunction isBody(fields: FormField[], input: unknown): boolean {\n if (input === null || typeof input !== 'object' || !hasOwn(input, 'values')) return false;\n return !fields.some((field) => field.key === 'values' || field.key === 'skippedSteps');\n}\n\nfunction applySkips(engine: FormEngine, skippedSteps: unknown): void {\n if (!Array.isArray(skippedSteps)) return;\n const requested = new Set(skippedSteps);\n for (let index = 0; index < engine.visibleSteps.length; index++) {\n const step = engine.visibleSteps[index];\n if (step.skip && requested.has(step.id)) skipStepAt(engine as unknown as EngineInternals, index);\n }\n}\n\nexport function validateSubmission(\n definition: FormDefinition,\n values: unknown,\n options: SubmissionOptions = {},\n): SubmissionResult {\n parseDefinition(definition);\n const fields = getAllFields(definition);\n const resolved = activeValues(definition, fields, values);\n const invalid = typeErrors(resolved);\n const engineOptions = { validators: ignoredValidators(fields, options.validators), onWarning: () => {} };\n const engine = new FormEngine(withoutRules(definition, invalid), resolved.values, engineOptions);\n applySkips(engine, options.skippedSteps);\n const errors = engine.validate();\n const submitted = engine.getSubmitValues();\n for (const [key, error] of invalid) if (hasOwn(submitted, key)) errors[key] = error;\n if (isBody(fields, values)) errors.values = BODY_MESSAGE;\n return { values: submitted, errors };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { F as FormField } from './definition-
|
|
1
|
+
import { F as FormField } from './definition-PdtKhxBh.js';
|
|
2
2
|
|
|
3
|
-
type DefinitionIssueCode = 'invalid-type' | 'missing-property' | 'fields-and-steps' | 'duplicate-step-id' | 'duplicate-key' | 'reserved-key' | 'route-target' | 'unknown-field' | 'forward-reference' | 'condition-operator-count' | 'unknown-operator' | 'condition-value-mismatch' | 'condition-cycle' | 'invalid-pattern' | 'invalid-range' | 'rule-not-applicable' | 'missing-options' | 'default-not-in-options' | 'unknown-field-type' | 'unknown-validator' | 'skip-unreachable' | 'route-fallthrough';
|
|
3
|
+
type DefinitionIssueCode = 'invalid-type' | 'missing-property' | 'fields-and-steps' | 'duplicate-step-id' | 'duplicate-key' | 'reserved-key' | 'route-target' | 'unknown-field' | 'forward-reference' | 'condition-operator-count' | 'unknown-operator' | 'condition-value-mismatch' | 'condition-cycle' | 'invalid-pattern' | 'invalid-range' | 'rule-not-applicable' | 'missing-options' | 'default-not-in-options' | 'unknown-field-type' | 'unknown-validator' | 'skip-unreachable' | 'route-fallthrough' | 'unsupported-format-version';
|
|
4
4
|
interface DefinitionIssue {
|
|
5
5
|
code: DefinitionIssueCode;
|
|
6
6
|
severity: 'error' | 'warning';
|
|
@@ -14,6 +14,6 @@ declare class FormDefinitionError extends Error {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
type ValidatorFn = (value: unknown, allValues: Record<string, unknown>) => string | null;
|
|
17
|
-
declare function validateFieldValue(field: FormField,
|
|
17
|
+
declare function validateFieldValue(field: FormField, input: unknown, allValues: Record<string, unknown>, validators?: Record<string, ValidatorFn>): string | null;
|
|
18
18
|
|
|
19
19
|
export { type DefinitionIssue as D, FormDefinitionError as F, type ValidatorFn as V, type DefinitionIssueCode as a, validateFieldValue as v };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formhaus/core",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "JSON form definition engine: validation, conditional visibility, multi-step and branching routes. Zero dependencies, works in React, Vue, Svelte or vanilla.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
"$schema": {
|
|
8
8
|
"type": "string"
|
|
9
9
|
},
|
|
10
|
+
"formatVersion": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Format version of the definition, such as \"1.0\". Core rejects a newer major version.",
|
|
13
|
+
"pattern": "^[1-9]\\d*(\\.\\d+)?$"
|
|
14
|
+
},
|
|
10
15
|
"id": {
|
|
11
16
|
"type": "string",
|
|
12
17
|
"description": "Unique form identifier."
|
package/style.css
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
--fh-color-text-muted: #5f5f68;
|
|
4
4
|
--fh-color-border: #d4d4d8;
|
|
5
5
|
--fh-color-border-hover: #a1a1aa;
|
|
6
|
+
--fh-color-control-hover: #71717a;
|
|
6
7
|
--fh-color-border-focus: var(--fh-color-primary);
|
|
7
8
|
--fh-color-error: #c0352d;
|
|
8
9
|
--fh-color-bg: #ffffff;
|
|
9
10
|
--fh-color-bg-disabled: #f4f4f5;
|
|
11
|
+
--fh-color-bg-hover: #f6f6f7;
|
|
10
12
|
--fh-color-primary: #5502fb;
|
|
11
13
|
--fh-color-primary-hover: #4400cc;
|
|
12
14
|
--fh-color-primary-text: #ffffff;
|
|
@@ -26,9 +28,11 @@
|
|
|
26
28
|
--fh-color-text-muted: #a8a8b3;
|
|
27
29
|
--fh-color-border: #3a3a41;
|
|
28
30
|
--fh-color-border-hover: #5a5a63;
|
|
31
|
+
--fh-color-control-hover: #80808b;
|
|
29
32
|
--fh-color-error: #f2736a;
|
|
30
33
|
--fh-color-bg: #18181c;
|
|
31
34
|
--fh-color-bg-disabled: #232328;
|
|
35
|
+
--fh-color-bg-hover: #212126;
|
|
32
36
|
--fh-color-primary: #7c4dff;
|
|
33
37
|
--fh-color-primary-hover: #8d63ff;
|
|
34
38
|
--fh-color-primary-text: #ffffff;
|
|
@@ -67,11 +71,10 @@ legend.fh-field__label { padding: 0; margin-bottom: 8px; }
|
|
|
67
71
|
color: inherit;
|
|
68
72
|
font: inherit;
|
|
69
73
|
font-size: var(--fh-font-size);
|
|
70
|
-
transition: border-color
|
|
74
|
+
transition: border-color 140ms;
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
.fh-field__input::placeholder { color: var(--fh-color-text-muted); opacity: 0.8; }
|
|
74
|
-
.fh-field__input:hover:not(:disabled, :focus) { border-color: var(--fh-color-border-hover); }
|
|
75
78
|
.fh-field__input:focus { outline: 2px solid var(--fh-color-border-focus); outline-offset: 1px; border-color: var(--fh-color-border-focus); }
|
|
76
79
|
.fh-field__input:disabled { background: var(--fh-color-bg-disabled); cursor: not-allowed; }
|
|
77
80
|
.fh-field__input--textarea { min-height: 112px; resize: vertical; }
|
|
@@ -92,20 +95,12 @@ legend.fh-field__label { padding: 0; margin-bottom: 8px; }
|
|
|
92
95
|
.fh-field__radio-group, .fh-field__multiselect-group { display: flex; flex-direction: column; gap: 8px; }
|
|
93
96
|
.fh-field__radio-group--inline, .fh-field__multiselect-group--inline { flex-flow: row wrap; }
|
|
94
97
|
|
|
95
|
-
.fh-field__radio-option,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
align-items: flex-start;
|
|
100
|
-
gap: 12px;
|
|
101
|
-
padding: 12px 14px;
|
|
102
|
-
border: 1px solid var(--fh-color-border);
|
|
103
|
-
border-radius: var(--fh-radius);
|
|
104
|
-
background: var(--fh-color-bg);
|
|
105
|
-
transition: border-color 120ms, background-color 120ms;
|
|
98
|
+
.fh-field__radio-option, .fh-field__multiselect-option {
|
|
99
|
+
position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
|
|
100
|
+
border: 1px solid var(--fh-color-border); border-radius: var(--fh-radius); background: var(--fh-color-bg);
|
|
101
|
+
transition: border-color 140ms, background-color 140ms;
|
|
106
102
|
}
|
|
107
103
|
|
|
108
|
-
:is(.fh-field__radio-option, .fh-field__multiselect-option):hover { border-color: var(--fh-color-border-hover); }
|
|
109
104
|
:is(.fh-field__radio-option, .fh-field__multiselect-option):has(:checked) { border-color: var(--fh-color-primary); background: var(--fh-color-primary-soft); }
|
|
110
105
|
:is(.fh-field__radio-option, .fh-field__multiselect-option):has(:disabled) { opacity: 0.6; }
|
|
111
106
|
:is(.fh-field__radio-option, .fh-field__multiselect-option):has(:focus-visible) { outline: 2px solid var(--fh-color-border-focus); outline-offset: 2px; }
|
|
@@ -130,7 +125,7 @@ legend.fh-field__label { padding: 0; margin-bottom: 8px; }
|
|
|
130
125
|
background: var(--fh-color-bg);
|
|
131
126
|
appearance: none;
|
|
132
127
|
cursor: pointer;
|
|
133
|
-
transition: background-color
|
|
128
|
+
transition: background-color 140ms, border-color 140ms;
|
|
134
129
|
}
|
|
135
130
|
|
|
136
131
|
.fh-field__radio { border-width: 2px; border-radius: 50%; }
|
|
@@ -139,9 +134,7 @@ legend.fh-field__label { padding: 0; margin-bottom: 8px; }
|
|
|
139
134
|
.fh-field__checkbox:checked { border-color: var(--fh-color-primary); background: var(--fh-color-primary); }
|
|
140
135
|
|
|
141
136
|
.fh-field__checkbox:checked::after {
|
|
142
|
-
content: "";
|
|
143
|
-
position: absolute;
|
|
144
|
-
inset: 0;
|
|
137
|
+
content: ""; position: absolute; inset: 0;
|
|
145
138
|
background: var(--fh-color-primary-text);
|
|
146
139
|
--fh-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
|
147
140
|
-webkit-mask: var(--fh-check) center / 14px no-repeat;
|
|
@@ -155,6 +148,18 @@ legend.fh-field__label { padding: 0; margin-bottom: 8px; }
|
|
|
155
148
|
:is(.fh-field__radio, .fh-field__checkbox, .fh-field__switch):focus-visible { outline: 2px solid var(--fh-color-border-focus); outline-offset: 2px; }
|
|
156
149
|
:is(.fh-field__radio, .fh-field__checkbox, .fh-field__switch):disabled { cursor: not-allowed; }
|
|
157
150
|
|
|
151
|
+
@media (hover: hover) and (pointer: fine) {
|
|
152
|
+
.fh-field__input:hover:not(:disabled, :focus, [aria-invalid="true"]) { border-color: var(--fh-color-border-hover); }
|
|
153
|
+
:is(.fh-field__input--select, .fh-field__input--date, .fh-field__input--datetime):not(:disabled) { cursor: pointer; }
|
|
154
|
+
:is(.fh-field__radio-option, .fh-field__multiselect-option):hover:not(:has(:checked, :disabled)) { border-color: var(--fh-color-border-hover); background: var(--fh-color-bg-hover); }
|
|
155
|
+
:is(.fh-field__checkbox-wrapper, .fh-field__radio-option, .fh-field__multiselect-option):hover :is(.fh-field__radio, .fh-field__checkbox):not(:checked, :disabled, [aria-invalid="true"]) { border-color: var(--fh-color-control-hover); }
|
|
156
|
+
.fh-field__switch-wrapper:hover .fh-field__switch:not(:disabled) { background-color: var(--fh-color-border-hover); }
|
|
157
|
+
.fh-field__switch-wrapper:hover .fh-field__switch:checked:not(:disabled) { background-color: var(--fh-color-primary-hover); }
|
|
158
|
+
.fh-form-actions__button--primary:hover:not(:disabled) { background: var(--fh-color-primary-hover); }
|
|
159
|
+
.fh-form-actions__button--secondary:hover:not(:disabled) { border-color: var(--fh-color-border-hover); background: var(--fh-color-bg-hover); }
|
|
160
|
+
.fh-form-actions__button--text:hover:not(:disabled) { background: var(--fh-color-bg-hover); color: var(--fh-color-text); }
|
|
161
|
+
}
|
|
162
|
+
|
|
158
163
|
.fh-field__input[aria-invalid="true"],
|
|
159
164
|
.fh-field__checkbox[aria-invalid="true"],
|
|
160
165
|
.fh-field[aria-invalid="true"] :is(.fh-field__radio-option, .fh-field__multiselect-option) {
|
|
@@ -166,27 +171,16 @@ legend.fh-field__label { padding: 0; margin-bottom: 8px; }
|
|
|
166
171
|
.fh-form-actions__secondary:empty { display: none; }
|
|
167
172
|
|
|
168
173
|
.fh-form-actions__button {
|
|
169
|
-
min-height: var(--fh-control-height);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
border-radius: var(--fh-radius);
|
|
173
|
-
background: transparent;
|
|
174
|
-
color: inherit;
|
|
175
|
-
font: inherit;
|
|
176
|
-
font-size: var(--fh-font-size);
|
|
177
|
-
font-weight: 600;
|
|
178
|
-
cursor: pointer;
|
|
179
|
-
transition: background-color 120ms, border-color 120ms, box-shadow 120ms;
|
|
174
|
+
min-height: var(--fh-control-height); padding: 0 20px; border: 1px solid transparent; border-radius: var(--fh-radius);
|
|
175
|
+
background: transparent; color: inherit; font: inherit; font-size: var(--fh-font-size); font-weight: 600; cursor: pointer;
|
|
176
|
+
transition: background-color 140ms, border-color 140ms, color 140ms;
|
|
180
177
|
}
|
|
181
178
|
|
|
182
179
|
.fh-form-actions__button:focus-visible { outline: 2px solid var(--fh-color-border-focus); outline-offset: 2px; }
|
|
183
180
|
.fh-form-actions__button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
184
181
|
.fh-form-actions__button--primary { margin-left: auto; background: var(--fh-color-primary); color: var(--fh-color-primary-text); }
|
|
185
|
-
.fh-form-actions__button--primary:hover:not(:disabled) { background: var(--fh-color-primary-hover); }
|
|
186
182
|
.fh-form-actions__button--secondary { border-color: var(--fh-color-secondary-border); background: var(--fh-color-bg); }
|
|
187
|
-
.fh-form-actions__button--secondary:hover:not(:disabled) { border-color: var(--fh-color-border-hover); }
|
|
188
183
|
.fh-form-actions__button--text { padding: 0 10px; color: var(--fh-color-text-muted); font-weight: 500; }
|
|
189
|
-
.fh-form-actions__button--text:hover:not(:disabled) { color: var(--fh-color-text); }
|
|
190
184
|
|
|
191
185
|
@media (max-width: 480px) {
|
|
192
186
|
.fh-form-actions__button--primary, .fh-form-actions__secondary { flex: 1 0 100%; }
|
|
@@ -218,3 +212,5 @@ legend.fh-field__label { padding: 0; margin-bottom: 8px; }
|
|
|
218
212
|
.fh-form__notice { display: grid; gap: 8px; justify-items: start; margin-bottom: var(--fh-gap); padding: 12px 14px; border: 1px solid var(--fh-color-error); border-radius: var(--fh-radius); color: var(--fh-color-text); }
|
|
219
213
|
.fh-form__notice--info { border-color: var(--fh-color-border-focus); }
|
|
220
214
|
.fh-form__notice > p, .fh-form__notice > ul { margin: 0; }
|
|
215
|
+
|
|
216
|
+
@media (prefers-reduced-motion: reduce) { .fh-form *, .fh-form ::after { transition: none; } }
|
package/dist/chunk-47C7QX7J.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import {c,q as q$1,w as w$1,r,p,B as B$1,A,z as z$1,s,t,u,C,v as v$1,b,x as x$1,a,n,h,f as f$1,j,i}from'./chunk-YXQFFAXK.js';var w=class extends Error{constructor(t){super(`Invalid form definition:
|
|
2
|
-
${t.map(n=>n.message).join(`
|
|
3
|
-
`)}`),this.name="FormDefinitionError",this.issues=t;}};function me(e){return (t,n,i,s)=>({code:t,severity:e,path:n,message:`${n||"/"}: ${i}.${s?` ${s}.`:""}`,...s&&{hint:`${s}.`}})}var f=me("error"),v=me("warning");function M(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ge(e){return e.severity==="error"}function I(e){if(e.length===1)return `Use ${JSON.stringify(e[0])}`;let t=e.slice(0,10).map(n=>JSON.stringify(n)).join(", ");return e.length>10?`Use one of: ${t}, ...`:`Use one of: ${t}`}function Me(e,t){let n=Array.from({length:t.length+1},(i,s)=>s);for(let i=1;i<=e.length;i++){let s=[i];for(let r=1;r<=t.length;r++)s[r]=Math.min(n[r]+1,s[r-1]+1,n[r-1]+(e[i-1]===t[r-1]?0:1));n=s;}return n[t.length]}function U(e,t){let n=e.toLowerCase();return t.find(i=>i!==e&&Me(n,i.toLowerCase())<=(i.length>4?2:1))}function x(e,t){let n=U(e,t);return n!==void 0?`Use ${JSON.stringify(n)}`:t.length?I(t):void 0}var D=f$1;function Ne({suggest:e},t,n){let i=Object.keys(t).filter(a=>a!=="field"),s=i.filter(a=>!D.includes(a)),r=s.map(a=>f("unknown-operator",`${n}/${M(a)}`,`"${a}" is not a condition operator`,e(a,[...D]))),o=i.length-s.length;if(o!==1&&!(o===0&&s.length)){let a=o?`the condition has ${o} operators`:"the condition has no operator";r.push(f("condition-operator-count",n,a,`Use exactly one of: ${D.join(", ")}`));}return r}function je(e,{condition:t,path:n,owner:i,step:s,key:r}){let o=e.keys.get(t.field);if(!o){let d=e.keyList.filter(l=>l!==r);return [f("unknown-field",`${n}/field`,`"${t.field}" is not a field key`,e.suggest(t.field,d))]}if(s<0||i==="action")return [];let a=i==="step"?"this or a later step":"a later step";if(o.step<s||i!=="step"&&o.step===s)return [];let u=i==="step"?"earlier steps":"this or an earlier step";return [f("forward-reference",`${n}/field`,`"${t.field}" belongs to ${a}`,`${i==="route"?"Route":i==="step"?"Step":"Field"} conditions can use fields of ${u}`)]}function G(e,t){let{condition:n,path:i}=t;return typeof n.field!="string"?[f("missing-property",`${i}/field`,'the condition has no "field"',"Add the key of the field to test")]:[...Ne(e,n,i),...je(e,t)]}function he(e){return e.conditions.flatMap(t=>G(e,t))}function K(e,t,n,i,s,r){for(let o of ["show","showAny"])(t[o]??[]).forEach((a,u)=>e.push({condition:a,path:`${n}/${o}/${u}`,owner:i,step:s,key:r}));}function W(e,t,n,i){(t?t.disabled??[]:[]).forEach((s,r)=>e.push({condition:s,path:`${n}/disabled/${r}`,owner:"action",step:i}));}function ye(e,t,n=()=>{}){let i=e.steps??[],s=i.length?i.flatMap((a,u)=>a.fields.map((d,l)=>({field:d,path:`/steps/${u}/fields/${l}`,step:u}))):(e.fields??[]).map((a,u)=>({field:a,path:`/fields/${u}`,step:-1})),r=new Map;for(let a of s)r.has(a.field.key)||r.set(a.field.key,a);let o=[];for(let a of s)K(o,a.field,a.path,"field",a.step,a.field.key);return i.forEach((a,u)=>{K(o,a,`/steps/${u}`,"step",u),(a.routes??[]).forEach((d,l)=>K(o,d,`/steps/${u}/routes/${l}`,"route",u));for(let d of ["next","back","skip"])W(o,a[d],`/steps/${u}/${d}`,u);}),W(o,e.submit,"/submit",-1),W(o,e.cancel,"/cancel",-1),{definition:e,entries:s,keys:r,keyList:[...r.keys()],conditions:o,validators:t,suggest:n}}function be(e,t,n,i){let s=e[n],r=e[i];return s===void 0||r===void 0||s<=r?[]:[f("invalid-range",`${t}/validation/${n}`,`${n} (${s}) is greater than ${i} (${r})`,`Lower ${n} or raise ${i}`)]}function Pe(e,t){if(e===void 0)return [];try{return new RegExp(e),[]}catch{return [f("invalid-pattern",`${t}/validation/pattern`,`${JSON.stringify(e)} is not a valid regular expression`,"Fix the pattern or escape special characters with a backslash")]}}function Te(e,{field:t,path:n}){let i=t.validation;if(!i)return [];let s=i.matchField;return [...be(i,n,"minLength","maxLength"),...be(i,n,"min","max"),...Pe(i.pattern,n),...s===void 0||e.keys.has(s)?[]:[f("unknown-field",`${n}/validation/matchField`,`"${s}" is not a field key`,e.suggest(s,e.keyList))]]}function ve(e){return e.entries.flatMap(t=>Te(e,t))}function Ue({definition:e,entries:t,keys:n}){let i=new Map,s=(o,a)=>{let u=a.filter(d=>n.has(d));if(u.length)for(let d of o)i.set(d,[...i.get(d)??[],...u]);},r=o=>[...o.show??[],...o.showAny??[]].map(a=>a.field);for(let{field:o}of t)s([o.key],r(o));for(let o of e.steps??[])s(o.fields.map(a=>a.key),r(o));return i}function Ge(e){let t=new Map,n=[];for(let i of e.keys()){if(t.has(i))continue;t.set(i,true);let s=[[i,0]];for(;s.length>0;){let r=s[s.length-1],o=e.get(r[0])?.[r[1]++];if(o===void 0)t.set(r[0],false),s.pop();else if(t.get(o)){let a=s.map(([u])=>u);n.push([...a.slice(a.indexOf(o)),o]);}else t.has(o)||(t.set(o,true),s.push([o,0]));}}return n}function Ke(e){return Ge(Ue(e)).map(t=>f("condition-cycle",e.keys.get(t[0]).path,`show conditions form a cycle: ${t.join(" -> ")}`,"Remove one of the conditions in the cycle"))}function ke(e){return Ke(e)}var O=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),We={string:[e=>typeof e=="string","a string"],number:[e=>typeof e=="number"&&Number.isFinite(e),"a number"],boolean:[e=>typeof e=="boolean","true or false"],scalar:[e=>["string","number","boolean"].includes(typeof e),"a string, number or boolean"],list:[e=>Array.isArray(e)&&e.every(t=>["string","number"].includes(typeof t)),"an array of strings or numbers"]};function Se(e,t,n){return Object.entries(t).flatMap(([i,s])=>{let[r,o]=We[s];return e[i]===void 0||r(e[i])?[]:[f("invalid-type",`${n}/${M(i)}`,`"${i}" must be ${o}`)]})}function F(e,t,n,i,s=false){return e==null&&!s?[]:Array.isArray(e)?e.flatMap((r,o)=>O(r)?i(r,`${t}/${o}`):[f("invalid-type",`${t}/${o}`,`must be ${n}`)]):[f("invalid-type",t,"must be an array",s?"Use [] when there is nothing to list":void 0)]}function E(e,t,n){return typeof e[t]=="string"?[]:[f("missing-property",`${n}/${t}`,`"${t}" must be a string`)]}var _=(e,t)=>Se(e,{field:"string",eq:"scalar",neq:"scalar",in:"list",notIn:"list",notEmpty:"boolean",gt:"number",gte:"number",lt:"number",lte:"number"},t);function q(e,t){return [...F(e.show,`${t}/show`,"a condition object",_),...F(e.showAny,`${t}/showAny`,"a condition object",_)]}function J(e,t){return O(e)?F(e.disabled,`${t}/disabled`,"a condition object",_):[]}var _e=(e,t)=>E(e,"value",t),Je={minLength:"number",maxLength:"number",min:"number",max:"number",pattern:"string",matchField:"string",validator:"string"};function qe(e,t){return e===void 0?[]:O(e)?Se(e,Je,t):[f("invalid-type",t,"must be an object of validation rules")]}function ze(e,t){return e===void 0||Array.isArray(e)&&e.every(i=>typeof i=="string")?[]:[f("invalid-type",t,"must be an array of field keys")]}var Fe=(e,t)=>[...E(e,"key",t),...E(e,"type",t),...q(e,t),...F(e.options,`${t}/options`,"an option object",_e),...qe(e.validation,`${t}/validation`),...ze(e.optionsDependsOn,`${t}/optionsDependsOn`)],Be=(e,t)=>[...e.to===null||typeof e.to=="string"?[]:[f("missing-property",`${t}/to`,'"to" must be a step id or null')],...q(e,t)],He=(e,t)=>[...E(e,"id",t),...F(e.fields,`${t}/fields`,"a field object",Fe,true),...q(e,t),...F(e.routes,`${t}/routes`,"a route object",Be),...["next","back","skip"].flatMap(n=>J(e[n],`${t}/${n}`))];function $e(e){return O(e)?[...F(e.fields,"/fields","a field object",Fe),...F(e.steps,"/steps","a step object",He),...J(e.submit,"/submit"),...J(e.cancel,"/cancel")]:[f("invalid-type","","the form definition must be an object")]}function we(e){return [...E(e,"id",""),...O(e.submit)?[]:[f("missing-property","/submit","the submit action is missing",'Add "submit": { "label": "Submit" }')]]}var N=e=>!!(e.show?.length||e.showAny?.length);function Ie(e,t,n){let i=[];for(let s of e[n].routes??[]){let r=s.to===null?null:t.get(s.to);if(r===null&&!N(s))return i;if(!(r==null||r<=n)&&(i.push(r),!N(s)&&!N(e[r])))return i}return n+1<e.length?[...i,n+1]:i}function Ce(e){let t=new Map(e.map((n,i)=>[n.id,i]));return e.map((n,i)=>{let s=new Set,r=Ie(e,t,i);for(;r.length;){let o=r.pop();s.has(o)||(s.add(o),r.push(...Ie(e,t,o)),N(e[o])&&o+1<e.length&&r.push(o+1));}return s})}var Ye=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]);function Qe({definition:e}){let t=[],n=e.steps??[],i=new Map;return n.forEach((s,r)=>{let o=i.get(s.id);o===void 0?i.set(s.id,r):t.push(f("duplicate-step-id",`/steps/${r}/id`,`step id "${s.id}" is already used by /steps/${o}`,"Give each step a unique id"));}),n.forEach((s,r)=>(s.routes??[]).forEach((o,a)=>{if(o.to===null)return;let u=i.get(o.to);if(u!==void 0&&u>r)return;let d=n.slice(r+1).map(y=>y.id),l=u===void 0?`"${o.to}" is not a step id`:`"${o.to}" is not a later step`,m=d.length?`${I(d)}, or null to end the form here`:"Use null to end the form here";t.push(f("route-target",`/steps/${r}/routes/${a}/to`,l,m));})),t}function Xe({definition:e,entries:t}){let n=[],i=Ce(e.steps??[]),s=(r,o)=>r.step!==o.step&&!i[r.step]?.has(o.step);return t.forEach((r,o)=>{let{field:a,path:u}=r,d=t.slice(0,o).find(l=>l.field.key===a.key&&!s(l,r));Ye.has(a.key)?n.push(f("reserved-key",`${u}/key`,`"${a.key}" is a built-in object property name`,"Rename the field key")):d&&n.push(f("duplicate-key",`${u}/key`,`key "${a.key}" is already used by ${d.path} on the same path`,"Rename one of the fields, or move them to route branches that never meet"));}),n}function xe(e){let{definition:t}=e;return [...!!t.fields?.length&&!!t.steps?.length?[f("fields-and-steps","",'the definition has both "fields" and "steps"','Move the top-level fields into a step, or remove "steps"')]:[],...Qe(e),...Xe(e)]}var Ze=["in","notIn"],et=["gt","gte","lt","lte"],tt=["text","email","phone","password","textarea","date","datetime","select","radio","autocomplete"];function nt(e){return e.type==="number"?"number":i.includes(e.type)?"boolean":tt.includes(e.type)?"string":void 0}function it(e,t,n,i$1){let s=(l,m)=>[v("condition-value-mismatch",i$1,l,m)];if(t==="notEmpty")return [];if(et.includes(t))return e.type!=="multiselect"&&!i.includes(e.type)?[]:s(`"${e.key}" is a ${e.type} field, so "${t}" never matches it`,"Compare a number, text, radio or select field");if(e.type==="multiselect"){let l=t==="neq"||t==="notIn"?"always":"never";return s(`"${e.key}" holds a list of values, so "${t}" ${l} matches it`,"Use notEmpty, or a select or radio field")}let r=Ze.includes(t)&&Array.isArray(n)?n:[n],o=nt(e),a=o&&r.find(l=>typeof l!==o);if(o&&a!==void 0)return s(`${JSON.stringify(a)} is a ${typeof a}, but "${e.key}" holds a ${o}`,`Use a ${o} value`);let u=o==="string"&&!e.optionsFrom&&e.options?.length?e.options.map(l=>l.value):null,d=u&&r.find(l=>!u.includes(l));return u&&d!==void 0?s(`${JSON.stringify(d)} is not an option of "${e.key}"`,I(u)):[]}function st(e,t){let{condition:n,path:i}=t;if(G(e,t).length)return [];let s=D.find(r=>r in n);return it(e.keys.get(n.field).field,s,n[s],`${i}/${s}`)}function ot({field:e,path:t}){if(!["select","radio","multiselect"].includes(e.type))return [];if(!Array.isArray(e.options))return e.optionsFrom?[]:[v("missing-options",`${t}/options`,`the ${e.type} field "${e.key}" has no options`,'Add "options" or "optionsFrom"')];let n=e.options.map(r=>r.value),i=e.type==="multiselect"&&Array.isArray(e.defaultValue)?e.defaultValue:[e.defaultValue],s=e.defaultValue===void 0||!n.length||e.optionsFrom?void 0:i.find(r=>!n.includes(r));return s===void 0?[]:[v("default-not-in-options",`${t}/defaultValue`,`${JSON.stringify(s)} is not an option of "${e.key}"`,I(n))]}function rt(e,{field:t,path:n}){let i=t.validation??{},s=(m,y,S)=>v("rule-not-applicable",`${n}/validation/${m}`,y,S),r=j.includes(t.type),o=t.type==="number",a=r&&!o?["min","max"].filter(m=>i[m]!==void 0):[],u=r&&["number","checkbox","switch"].includes(t.type)?["minLength","maxLength"].filter(m=>i[m]!==void 0):[],d=[...a.map(m=>s(m,`"${m}" applies to number fields only`,`Use ${m}Length to limit text length`)),...u.map(m=>s(m,`"${m}" does not apply to ${t.type} fields`,o?"Use min and max for numbers":`Remove ${m}`))],{validators:l}=e;return i.validator!==void 0&&l&&!Object.prototype.hasOwnProperty.call(l,i.validator)&&d.push(v("unknown-validator",`${n}/validation/validator`,`the validator "${i.validator}" is not registered`,'Pass it in the "validators" option')),d}function at(e,t){let{field:n,path:i}=t,s=j.includes(n.type)?void 0:U(n.type,j);return [...s===void 0?[]:[v("unknown-field-type",`${i}/type`,`"${n.type}" is not a built-in field type`,`Use "${s}", or register a component for "${n.type}"`)],...ot(t),...rt(e,t),...(n.optionsDependsOn??[]).flatMap((r,o)=>e.keys.has(r)?[]:[v("unknown-field",`${i}/optionsDependsOn/${o}`,`"${r}" is not a field key`,x(r,e.keyList))])]}function ut({definition:e}){let t=e.steps??[];return t.flatMap((n,i)=>{let s=[],r=new Set((n.routes??[]).map(o=>o.to).filter(o=>o!==null));for(let o of r){let a=t.findIndex(l=>l.id===o),u=t[a+1],d=t[a]?.routes?.some(l=>!l.show?.length&&!l.showAny?.length);!u||!r.has(u.id)||d||s.push(v("route-fallthrough",`/steps/${a}`,`branch "${o}" from "${n.id}" continues into the sibling branch "${u.id}"`,`Add an unconditional route on "${o}" to the step where the branches meet`));}return n.skip&&(n.next===false||!t[1])&&s.push(v("skip-unreachable",`/steps/${i}/skip`,`step "${n.id}" has "skip" but no Continue button or later step`,'Remove "skip", or remove "next": false')),s})}function De(e){return [...typeof e.definition.title=="string"?[]:[v("missing-property","/title",'"title" must be a string',"Add a title for host UI and editors")],...e.conditions.flatMap(t=>st(e,t)),...e.entries.flatMap(t=>at(e,t)),...ut(e)]}function z(e,{validators:t,suggest:n,warnings:i}={}){let s=$e(e);if(s.length)return s;let r=ye(e,t,n);return [...we(e),...xe(r),...he(r),...ve(r),...ke(r),...i?i(r):[]]}function Ee(e){return z(e)}function V(e,t={}){return z(e,{validators:t.validators,suggest:x,warnings:De})}function lt(e,t){let n=z(e,{suggest:x});if(n.length)throw new w(n);return e}function ct(e){return V(e).map(t=>t.message)}function Oe(e,t){return e.add(t),()=>e.delete(t)}function Ve(){let e=0,t=0,n=new Set,i=new Set,s=new Map,r=new Map;return {subscribe:o=>Oe(n,o),getSnapshot:()=>e,subscribeStructure:o=>Oe(i,o),getStructureSnapshot:()=>t,getFieldSnapshot:o=>s.get(o)??0,subscribeField(o,a){let u=r.get(o)??new Set;return u.add(a),r.set(o,u),()=>{u.delete(a),u.size===0&&r.delete(o);}},notify({fieldKeys:o=[],structureChanged:a=false}={}){for(let u of new Set(o)){s.set(u,(s.get(u)??0)+1);for(let d of r.get(u)??[])d();}if(a){t++;for(let u of i)u();}e++;for(let u of n)u();}}}function dt(e,t){try{if(process.env.NODE_ENV!=="production")return V(e,{validators:t})}catch(n){if(!(n instanceof ReferenceError))throw n}}function Re(e,t,n){let i=dt(e,n)??Ee(e),s=i.filter(ge);if(s.length)throw new w(s);let r=t.onWarning??(o=>console.warn(`[formhaus] ${o.message}`));for(let o of i)r(o);}function B(e,t){for(let n of a(e)){let i=t.get(n)??new Set;i.add(e),t.set(n,i);}}function Le(e){let t=b(e),n$1=new Map,i=new Set,s=x$1(e),r=new Map,o=new Map,a$1=new Map,u=true,d=true,l={visibleSteps:[],currentStep:null,visibleFields:[],canGoNext:false};for(let c of t)n$1.set(c.key,[...n$1.get(c.key)??[],c]),B(c,r);for(let c of e.steps??[]){for(let p of c.fields)a$1.set(p,c);B(c,o);for(let p of c.routes??[])for(let g of a(p))i.add(g);}let m=()=>(e.steps??[]).length>0,y=(c,p)=>h(c,s.values(p)),S=(c,p)=>{let g=a$1.get(c);return !g||s.steps(p).includes(g)};function C(c,p){if(!u)return l;if(u=false,!m())return l.visibleSteps=[],l.currentStep=null,l.visibleFields=(e.fields??[]).filter(k=>y(k,c)),l;let g=l.visibleSteps=s.steps(c),b=l.currentStep=g[p]??g[g.length-1]??null;return l.visibleFields=b?b.fields.filter(k=>y(k,c)):[],l}return {allFields:t,conditionValues:s.values,state:C,markChanged(c,p){(c||p)&&s.invalidate(),c&&(u=true),(c||p)&&(d=true);},getCanGoNext(c,p,g){let b=C(c,p).currentStep;if(!d)return l.canGoNext;d=false;let k=b?n(b,s.values(c),g):{};return l.canGoNext=m()&&Object.keys(k).length===0},findStepIndex(c,p,g){let b=C(p,g).visibleSteps.findIndex(k=>k.fields.some(R=>R.key===c));return b===-1?null:b},affectsStructure(c,p){return i.has(c)||r.has(c)||o.has(c)||p.size>0},activeField(c,p){return n$1.get(c)?.find(g=>S(g,p)&&y(g,p))},reconcileHidden(c,p){s.invalidate();let g=[...new Set([...r.keys(),...o.keys()])],b=new Set(g),k=new Set,R=h=>c[h]!==void 0||p[h]!==void 0,H=h=>{delete c[h],delete p[h],s.invalidate(),k.add(h),!b.has(h)&&(b.add(h),g.push(h));};for(let h=0;h<g.length;h++){let j=g[h];b.delete(j);for(let $ of r.get(j)??[])S($,c)&&!y($,c)&&R($.key)&&H($.key);for(let $ of o.get(j)??[])if(!y($,c))for(let Y of $.fields)R(Y.key)&&H(Y.key);}return k}}}var Ae=class{constructor(t,n,i){this.definition=t;this.skipped=new Map;this.validationEpoch=0;this.operationEpoch=0;this.subscriptions=Ve();this.lifecycle=i??{},this.validators=i?.validators??{},Re(t,this.lifecycle,this.validators),this.visibility=Le(t);let s=c(this.visibility.allFields,n);this.state={values:s,errors:{},topLevelErrors:[],currentStepIndex:0,fieldLoading:{},stepValidating:false,submitting:false},this.visibility.reconcileHidden(s,this.state.errors);}get onStepValidate(){return this.lifecycle.onStepValidate}get values(){return this.state.values}get errors(){return this.state.errors}get topLevelErrors(){return this.state.topLevelErrors}get currentStepIndex(){return this.state.currentStepIndex}get fieldLoading(){return this.state.fieldLoading}get stepValidating(){return this.state.stepValidating}get submitting(){return this.state.submitting}get isMultiStep(){return (this.definition.steps??[]).length>0}get visibleSteps(){return this.view.visibleSteps}get currentStep(){return this.view.currentStep}get visibleFields(){return this.view.visibleFields}get isFirstStep(){return this.currentStepIndex===0}get isLastStep(){return this.currentStepIndex>=this.visibleSteps.length-1}get canGoNext(){return this.visibility.getCanGoNext(this.state.values,this.currentStepIndex,this.validators)}get progress(){let t=this.visibleSteps.length;return {current:Math.min(this.currentStepIndex+1,t),total:t}}subscribe(t){return this.subscriptions.subscribe(t)}getSnapshot(){return this.subscriptions.getSnapshot()}subscribeField(t,n){return this.subscriptions.subscribeField(t,n)}getFieldSnapshot(t){return this.subscriptions.getFieldSnapshot(t)}subscribeStructure(t){return this.subscriptions.subscribeStructure(t)}getStructureSnapshot(){return this.subscriptions.getStructureSnapshot()}setValue(t,n){let{values:i,errors:s}=this.state,r$1=this.isMultiStep?this.visibleSteps:null,o=!Object.is(i[t],n),a=s[t]!==void 0;i[t]=n,delete s[t];for(let[S,C]of this.skipped)o&&C.includes(t)&&this.skipped.delete(S);let u=this.visibility.reconcileHidden(i,s),d=q$1(this.internals,t),l=new Set([...u,...d]);(o||a)&&l.add(t);let m=o||u.size>0,y=m&&this.visibility.affectsStructure(t,u);if(r$1&&y){this.visibility.markChanged(true,true),this.state.currentStepIndex=w$1(r$1,this.visibleSteps,this.currentStepIndex);for(let S of r(this.internals))l.add(S);}this.notify({fieldKeys:l,structureChanged:y,valuesChanged:m});}setErrors(t){p(this.internals,t,true);}setFieldLoading(t,n){let i=this.state.fieldLoading[t]===true;n?this.state.fieldLoading[t]=true:delete this.state.fieldLoading[t],this.notify({fieldKeys:i===n?[]:[t]});}cancelPendingActions(){this.validationEpoch++,this.operationEpoch++,this.state.stepValidating=false,this.state.submitting=false,this.notify();}next(){return B$1(this.internals,"next")}back(){return B$1(this.internals,"back")}skip(t){return A(this.internals,t)}submit(t){return z$1(this.internals,t)}isStepSkipped(t){return this.skipped.has(t)}validate(){return s(this.internals)}validateField(t$1){return t(this.internals,t$1)}getSubmitValues(){return u(this.internals)}goToStepWithField(t){C(this.internals,t);}reset(t){v$1(this.internals,t);}get view(){return this.visibility.state(this.state.values,this.currentStepIndex)}get internals(){return this}notify(t={}){this.visibility.markChanged(!!t.structureChanged,!!t.valuesChanged),this.subscriptions.notify(t);}};
|
|
4
|
-
export{w as a,V as b,lt as c,ct as d,Ae as e};//# sourceMappingURL=chunk-47C7QX7J.js.map
|
|
5
|
-
//# sourceMappingURL=chunk-47C7QX7J.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/definition-validation/issues.ts","../src/definition-validation/conditions.ts","../src/definition-validation/context.ts","../src/definition-validation/fields.ts","../src/definition-validation/graph.ts","../src/definition-validation/shape.ts","../src/definition-validation/paths.ts","../src/definition-validation/structure.ts","../src/definition-validation/warnings.ts","../src/definition-validation/check-definition.ts","../src/definition-validation/validate-definition.ts","../src/engine/subscriptions.ts","../src/engine/warnings.ts","../src/engine/visibility-index.ts","../src/engine/visibility-state.ts","../src/engine/runtime.ts"],"names":["FormDefinitionError","issues","issue","create","severity","code","path","problem","hint","error","warning","pointer","key","isError","oneOf","values","shown","value","distance","a","b","row","_","index","next","j","closest","candidates","lower","candidate","suggest","match","OPERATORS","CONDITION_OPERATORS","operatorIssues","condition","keys","unknown","count","referenceIssues","context","owner","step","target","sameStep","allowed","conditionErrors","entry","conditionIssues","collect","source","name","collectAction","action","createContext","definition","validators","steps","entries","field","position","conditions","route","rangeIssue","rules","min","max","low","high","patternIssue","pattern","ruleIssues","fieldIssues","dependencyGraph","graph","link","owners","dependencies","known","fieldsOf","findCycles","visiting","cycles","start","stack","frame","neighbor","nodes","node","cycleIssues","cycle","graphIssues","isEntry","KINDS","item","typed","kind","valid","list","check","required","text","option","RULES","validation","shapeIssues","input","metaIssues","conditional","successors","indexes","from","reachableSteps","seen","queue","RESERVED","stepIssues","first","later","keyIssues","reachable","exclusive","clash","other","structureIssues","LIST_OPERATORS","COMPARISONS","STRING_TYPES","expectedType","BOOLEAN_TYPES","valueIssue","operator","operand","mismatch","result","operands","expected","wrong","options","missing","conditionWarnings","optionIssues","defaults","ruleWarnings","rule","BUILT_IN_TYPES","numeric","ranges","sized","fieldWarnings","routeWarnings","targets","to","sibling","exits","definitionWarnings","warnings","shape","definitionErrors","checkDefinition","parseDefinition","errors","validateDefinition","listen","listeners","listener","createSubscriptions","version","structureVersion","structureListeners","fieldVersions","fieldListeners","set","fieldKeys","structureChanged","developmentIssues","assertDefinition","warn","indexConditions","dependent","conditionFields","dependents","createVisibility","allFields","getAllFields","fieldsByKey","routeFields","createActivePath","fieldDependents","stepDependents","stepOfField","visibilityDirty","canGoNextDirty","cache","isMultiStep","visible","isVisible","onPath","state","stepIndex","current","valuesChanged","validateStep","fieldKey","clearedFields","queued","cleared","held","clear","FormEngine","initialValues","createValues","total","previousSteps","valueChanged","hadError","stepId","revalidated","clearResolvedMatchErrors","changedFields","reconcileStepIndex","pruned","pruneOffPathErrors","applyValidationErrors","loading","previous","changeStep","submit","skipStep","handler","submitForm","validateForm","validateOne","getSubmitValues","goToStepWithField","resetEngine"],"mappings":"6HAgCO,IAAMA,EAAN,cAAkC,KAAM,CAG7C,WAAA,CAAYC,CAAAA,CAA2B,CACrC,KAAA,CAAM,CAAA;AAAA,EAA6BA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AG,CAC1F,aAAA,CAAcb,CAAAA,CAAyB,CAAE,OAAO,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAIA,CAAM,CAAG,CAC1E,QAAA,EAAmC,CAAE,OAAOe,CAAAA,CAAa,IAAA,CAAK,SAAS,CAAG,CAC1E,aAAA,CAAc3N,GAAAA,CAA4B,CAAE,OAAO4N,CAAAA,CAAY,IAAA,CAAK,SAAA,CAAW5N,GAAG,CAAG,CACrF,eAAA,EAAoC,CAAE,OAAO6N,CAAAA,CAAgB,IAAA,CAAK,SAAS,CAAuB,CAClG,iBAAA,CAAkB7N,CAAAA,CAAmB,CAAE8N,EAAkB,IAAA,CAAK,SAAA,CAAW9N,CAAG,EAAG,CAC/E,KAAA,CAAMG,CAAAA,CAAwC,CAAE4N,IAAY,IAAA,CAAK,SAAA,CAAW5N,CAAM,EAAG,CAErF,IAAY,IAAA,EAAO,CACjB,OAAO,KAAK,UAAA,CAAW,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,MAAA,CAAQ,IAAA,CAAK,gBAAgB,CACvE,CAEA,IAAY,SAAA,EAA6B,CACvC,OAAO,IACT,CAEQ,MAAA,CAAO2H,CAAAA,CAAgC,EAAC,CAAS,CACvD,IAAA,CAAK,UAAA,CAAW,WAAA,CAAY,CAAC,CAACA,CAAAA,CAAQ,iBAAkB,CAAC,CAACA,CAAAA,CAAQ,aAAa,EAC/E,IAAA,CAAK,aAAA,CAAc,MAAA,CAAOA,CAAO,EACnC,CACF","file":"chunk-47C7QX7J.js","sourcesContent":["export type DefinitionIssueCode =\n | 'invalid-type'\n | 'missing-property'\n | 'fields-and-steps'\n | 'duplicate-step-id'\n | 'duplicate-key'\n | 'reserved-key'\n | 'route-target'\n | 'unknown-field'\n | 'forward-reference'\n | 'condition-operator-count'\n | 'unknown-operator'\n | 'condition-value-mismatch'\n | 'condition-cycle'\n | 'invalid-pattern'\n | 'invalid-range'\n | 'rule-not-applicable'\n | 'missing-options'\n | 'default-not-in-options'\n | 'unknown-field-type'\n | 'unknown-validator'\n | 'skip-unreachable'\n | 'route-fallthrough';\n\nexport interface DefinitionIssue {\n code: DefinitionIssueCode;\n severity: 'error' | 'warning';\n path: string;\n message: string;\n hint?: string;\n}\n\nexport class FormDefinitionError extends Error {\n readonly issues: DefinitionIssue[];\n\n constructor(issues: DefinitionIssue[]) {\n super(`Invalid form definition:\\n${issues.map((issue) => issue.message).join('\\n')}`);\n this.name = 'FormDefinitionError';\n this.issues = issues;\n }\n}\n\nfunction create(severity: DefinitionIssue['severity']) {\n return (code: DefinitionIssueCode, path: string, problem: string, hint?: string): DefinitionIssue => ({\n code,\n severity,\n path,\n message: `${path || '/'}: ${problem}.${hint ? ` ${hint}.` : ''}`,\n ...(hint && { hint: `${hint}.` }),\n });\n}\n\nexport const error = create('error');\nexport const warning = create('warning');\n\nexport function pointer(key: string): string {\n return key.replace(/~/g, '~0').replace(/\\//g, '~1');\n}\n\nexport function isError(issue: DefinitionIssue): boolean {\n return issue.severity === 'error';\n}\n\nexport function oneOf(values: string[]): string {\n if (values.length === 1) return `Use ${JSON.stringify(values[0])}`;\n const shown = values.slice(0, 10).map((value) => JSON.stringify(value)).join(', ');\n return values.length > 10 ? `Use one of: ${shown}, ...` : `Use one of: ${shown}`;\n}\n\nfunction distance(a: string, b: string): number {\n let row = Array.from({ length: b.length + 1 }, (_, index) => index);\n for (let i = 1; i <= a.length; i++) {\n const next = [i];\n for (let j = 1; j <= b.length; j++) {\n next[j] = Math.min(row[j] + 1, next[j - 1] + 1, row[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));\n }\n row = next;\n }\n return row[b.length];\n}\n\nexport function closest(value: string, candidates: string[]): string | undefined {\n const lower = value.toLowerCase();\n return candidates.find((candidate) => candidate !== value && distance(lower, candidate.toLowerCase()) <= (candidate.length > 4 ? 2 : 1));\n}\n\nexport function suggest(value: string, candidates: string[]): string | undefined {\n const match = closest(value, candidates);\n if (match !== undefined) return `Use ${JSON.stringify(match)}`;\n return candidates.length ? oneOf(candidates) : undefined;\n}\n","import { CONDITION_OPERATORS } from '../visibility/evaluate-condition';\nimport type { ShowCondition } from '../types';\nimport type { CheckContext, ConditionEntry } from './context';\nimport type { DefinitionIssue } from './issues';\nimport { error, pointer } from './issues';\n\nexport const OPERATORS: readonly string[] = CONDITION_OPERATORS;\n\nfunction operatorIssues({ suggest }: CheckContext, condition: ShowCondition, path: string): DefinitionIssue[] {\n const keys = Object.keys(condition).filter((key) => key !== 'field');\n const unknown = keys.filter((key) => !OPERATORS.includes(key));\n const issues = unknown.map((key) => error('unknown-operator', `${path}/${pointer(key)}`, `\"${key}\" is not a condition operator`, suggest(key, [...OPERATORS])));\n const count = keys.length - unknown.length;\n if (count !== 1 && !(count === 0 && unknown.length)) {\n const problem = count ? `the condition has ${count} operators` : 'the condition has no operator';\n issues.push(error('condition-operator-count', path, problem, `Use exactly one of: ${OPERATORS.join(', ')}`));\n }\n return issues;\n}\n\nfunction referenceIssues(context: CheckContext, { condition, path, owner, step, key }: ConditionEntry): DefinitionIssue[] {\n const target = context.keys.get(condition.field);\n if (!target) {\n const candidates = context.keyList.filter((candidate) => candidate !== key);\n return [error('unknown-field', `${path}/field`, `\"${condition.field}\" is not a field key`, context.suggest(condition.field, candidates))];\n }\n if (step < 0 || owner === 'action') return [];\n const sameStep = owner === 'step' ? 'this or a later step' : 'a later step';\n if (target.step < step || (owner !== 'step' && target.step === step)) return [];\n const allowed = owner === 'step' ? 'earlier steps' : 'this or an earlier step';\n return [error('forward-reference', `${path}/field`, `\"${condition.field}\" belongs to ${sameStep}`, `${owner === 'route' ? 'Route' : owner === 'step' ? 'Step' : 'Field'} conditions can use fields of ${allowed}`)];\n}\n\nexport function conditionErrors(context: CheckContext, entry: ConditionEntry): DefinitionIssue[] {\n const { condition, path } = entry;\n if (typeof condition.field !== 'string') return [error('missing-property', `${path}/field`, 'the condition has no \"field\"', 'Add the key of the field to test')];\n return [...operatorIssues(context, condition, path), ...referenceIssues(context, entry)];\n}\n\nexport function conditionIssues(context: CheckContext): DefinitionIssue[] {\n return context.conditions.flatMap((entry) => conditionErrors(context, entry));\n}\n","import type { FormAction, FormDefinition, FormField, ShowCondition } from '../types';\n\nexport interface FieldEntry {\n field: FormField;\n path: string;\n step: number;\n}\n\nexport interface ConditionEntry {\n condition: ShowCondition;\n path: string;\n owner: 'field' | 'step' | 'route' | 'action';\n step: number;\n key?: string;\n}\n\nexport interface CheckContext {\n definition: FormDefinition;\n entries: FieldEntry[];\n keys: Map<string, FieldEntry>;\n keyList: string[];\n conditions: ConditionEntry[];\n validators?: Record<string, unknown>;\n suggest: (value: string, candidates: string[]) => string | undefined;\n}\n\ntype Owner = { show?: ShowCondition[]; showAny?: ShowCondition[] };\n\nfunction collect(target: ConditionEntry[], source: Owner, path: string, owner: ConditionEntry['owner'], step: number, key?: string): void {\n for (const name of ['show', 'showAny'] as const) {\n (source[name] ?? []).forEach((condition, index) => target.push({ condition, path: `${path}/${name}/${index}`, owner, step, key }));\n }\n}\n\nfunction collectAction(target: ConditionEntry[], action: FormAction | false | undefined, path: string, step: number): void {\n (action ? action.disabled ?? [] : []).forEach((condition, index) => (\n target.push({ condition, path: `${path}/disabled/${index}`, owner: 'action', step })\n ));\n}\n\nexport function createContext(definition: FormDefinition, validators?: Record<string, unknown>, suggest: CheckContext['suggest'] = () => undefined): CheckContext {\n const steps = definition.steps ?? [];\n const entries: FieldEntry[] = steps.length\n ? steps.flatMap((step, index) => step.fields.map((field, position) => ({ field, path: `/steps/${index}/fields/${position}`, step: index })))\n : (definition.fields ?? []).map((field, position) => ({ field, path: `/fields/${position}`, step: -1 }));\n const keys = new Map<string, FieldEntry>();\n for (const entry of entries) if (!keys.has(entry.field.key)) keys.set(entry.field.key, entry);\n const conditions: ConditionEntry[] = [];\n for (const entry of entries) collect(conditions, entry.field, entry.path, 'field', entry.step, entry.field.key);\n steps.forEach((step, index) => {\n collect(conditions, step, `/steps/${index}`, 'step', index);\n (step.routes ?? []).forEach((route, position) => collect(conditions, route, `/steps/${index}/routes/${position}`, 'route', index));\n for (const name of ['next', 'back', 'skip'] as const) collectAction(conditions, step[name], `/steps/${index}/${name}`, index);\n });\n collectAction(conditions, definition.submit, '/submit', -1);\n collectAction(conditions, definition.cancel, '/cancel', -1);\n return {\n definition,\n entries,\n keys,\n keyList: [...keys.keys()],\n conditions,\n validators,\n suggest,\n };\n}\n","import type { FieldValidation } from '../types';\nimport type { CheckContext, FieldEntry } from './context';\nimport type { DefinitionIssue } from './issues';\nimport { error } from './issues';\n\nfunction rangeIssue(rules: FieldValidation, path: string, min: 'min' | 'minLength', max: 'max' | 'maxLength'): DefinitionIssue[] {\n const low = rules[min];\n const high = rules[max];\n if (low === undefined || high === undefined || low <= high) return [];\n return [error('invalid-range', `${path}/validation/${min}`, `${min} (${low}) is greater than ${max} (${high})`, `Lower ${min} or raise ${max}`)];\n}\n\nfunction patternIssue(pattern: string | undefined, path: string): DefinitionIssue[] {\n if (pattern === undefined) return [];\n try {\n new RegExp(pattern);\n return [];\n } catch {\n return [error('invalid-pattern', `${path}/validation/pattern`, `${JSON.stringify(pattern)} is not a valid regular expression`, 'Fix the pattern or escape special characters with a backslash')];\n }\n}\n\nfunction ruleIssues(context: CheckContext, { field, path }: FieldEntry): DefinitionIssue[] {\n const rules = field.validation;\n if (!rules) return [];\n const match = rules.matchField;\n return [\n ...rangeIssue(rules, path, 'minLength', 'maxLength'),\n ...rangeIssue(rules, path, 'min', 'max'),\n ...patternIssue(rules.pattern, path),\n ...(match === undefined || context.keys.has(match) ? [] : [error('unknown-field', `${path}/validation/matchField`, `\"${match}\" is not a field key`, context.suggest(match, context.keyList))]),\n ];\n}\n\nexport function fieldIssues(context: CheckContext): DefinitionIssue[] {\n return context.entries.flatMap((entry) => ruleIssues(context, entry));\n}\n","import type { CheckContext } from './context';\nimport type { DefinitionIssue } from './issues';\nimport { error } from './issues';\n\nfunction dependencyGraph({ definition, entries, keys }: CheckContext): Map<string, string[]> {\n const graph = new Map<string, string[]>();\n const link = (owners: string[], dependencies: string[]) => {\n const known = dependencies.filter((key) => keys.has(key));\n if (known.length) for (const owner of owners) graph.set(owner, [...(graph.get(owner) ?? []), ...known]);\n };\n const fieldsOf = (source: { show?: { field: string }[]; showAny?: { field: string }[] }) => (\n [...(source.show ?? []), ...(source.showAny ?? [])].map((condition) => condition.field)\n );\n for (const { field } of entries) link([field.key], fieldsOf(field));\n for (const step of definition.steps ?? []) link(step.fields.map((field) => field.key), fieldsOf(step));\n return graph;\n}\n\nfunction findCycles(graph: Map<string, string[]>): string[][] {\n const visiting = new Map<string, boolean>();\n const cycles: string[][] = [];\n for (const start of graph.keys()) {\n if (visiting.has(start)) continue;\n visiting.set(start, true);\n const stack: [string, number][] = [[start, 0]];\n while (stack.length > 0) {\n const frame = stack[stack.length - 1];\n const neighbor = graph.get(frame[0])?.[frame[1]++];\n if (neighbor === undefined) {\n visiting.set(frame[0], false);\n stack.pop();\n } else if (visiting.get(neighbor)) {\n const nodes = stack.map(([node]) => node);\n cycles.push([...nodes.slice(nodes.indexOf(neighbor)), neighbor]);\n } else if (!visiting.has(neighbor)) {\n visiting.set(neighbor, true);\n stack.push([neighbor, 0]);\n }\n }\n }\n return cycles;\n}\n\nfunction cycleIssues(context: CheckContext): DefinitionIssue[] {\n return findCycles(dependencyGraph(context)).map((cycle) => (\n error('condition-cycle', context.keys.get(cycle[0])!.path, `show conditions form a cycle: ${cycle.join(' -> ')}`, 'Remove one of the conditions in the cycle')\n ));\n}\n\nexport function graphIssues(context: CheckContext): DefinitionIssue[] {\n return cycleIssues(context);\n}\n","import type { DefinitionIssue } from './issues';\nimport { error, pointer } from './issues';\n\ntype Entry = Record<string, unknown>;\ntype Check = (value: Entry, path: string) => DefinitionIssue[];\ntype Kind = 'string' | 'number' | 'boolean' | 'scalar' | 'list';\n\nexport const isEntry = (value: unknown): value is Entry =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst KINDS: Record<Kind, [(value: unknown) => boolean, string]> = {\n string: [(value) => typeof value === 'string', 'a string'],\n number: [(value) => typeof value === 'number' && Number.isFinite(value), 'a number'],\n boolean: [(value) => typeof value === 'boolean', 'true or false'],\n scalar: [(value) => ['string', 'number', 'boolean'].includes(typeof value), 'a string, number or boolean'],\n list: [(value) => Array.isArray(value) && value.every((item) => ['string', 'number'].includes(typeof item)), 'an array of strings or numbers'],\n};\n\nfunction typed(value: Entry, rules: Record<string, Kind>, path: string): DefinitionIssue[] {\n return Object.entries(rules).flatMap(([key, kind]) => {\n const [valid, name] = KINDS[kind];\n return value[key] === undefined || valid(value[key]) ? [] : [error('invalid-type', `${path}/${pointer(key)}`, `\"${key}\" must be ${name}`)];\n });\n}\n\nfunction list(value: unknown, path: string, name: string, check: Check, required = false): DefinitionIssue[] {\n if (value == null && !required) return [];\n if (!Array.isArray(value)) return [error('invalid-type', path, 'must be an array', required ? 'Use [] when there is nothing to list' : undefined)];\n return value.flatMap((item, index) => (\n isEntry(item) ? check(item, `${path}/${index}`) : [error('invalid-type', `${path}/${index}`, `must be ${name}`)]\n ));\n}\n\nfunction text(value: Entry, key: string, path: string): DefinitionIssue[] {\n return typeof value[key] === 'string' ? [] : [error('missing-property', `${path}/${key}`, `\"${key}\" must be a string`)];\n}\n\nconst condition: Check = (value, path) => typed(value, { field: 'string', eq: 'scalar', neq: 'scalar', in: 'list', notIn: 'list', notEmpty: 'boolean', gt: 'number', gte: 'number', lt: 'number', lte: 'number' }, path);\n\nfunction conditions(value: Entry, path: string): DefinitionIssue[] {\n return [\n ...list(value.show, `${path}/show`, 'a condition object', condition),\n ...list(value.showAny, `${path}/showAny`, 'a condition object', condition),\n ];\n}\n\nfunction action(value: unknown, path: string): DefinitionIssue[] {\n return isEntry(value) ? list(value.disabled, `${path}/disabled`, 'a condition object', condition) : [];\n}\n\nconst option: Check = (value, path) => text(value, 'value', path);\n\nconst RULES: Record<string, Kind> = {\n minLength: 'number', maxLength: 'number', min: 'number', max: 'number', pattern: 'string', matchField: 'string', validator: 'string',\n};\n\nfunction validation(value: unknown, path: string): DefinitionIssue[] {\n if (value === undefined) return [];\n return isEntry(value) ? typed(value, RULES, path) : [error('invalid-type', path, 'must be an object of validation rules')];\n}\n\nfunction dependencies(value: unknown, path: string): DefinitionIssue[] {\n const valid = value === undefined || (Array.isArray(value) && value.every((key) => typeof key === 'string'));\n return valid ? [] : [error('invalid-type', path, 'must be an array of field keys')];\n}\n\nconst field: Check = (value, path) => [\n ...text(value, 'key', path),\n ...text(value, 'type', path),\n ...conditions(value, path),\n ...list(value.options, `${path}/options`, 'an option object', option),\n ...validation(value.validation, `${path}/validation`),\n ...dependencies(value.optionsDependsOn, `${path}/optionsDependsOn`),\n];\n\nconst route: Check = (value, path) => [\n ...(value.to === null || typeof value.to === 'string' ? [] : [error('missing-property', `${path}/to`, '\"to\" must be a step id or null')]),\n ...conditions(value, path),\n];\n\nconst step: Check = (value, path) => [\n ...text(value, 'id', path),\n ...list(value.fields, `${path}/fields`, 'a field object', field, true),\n ...conditions(value, path),\n ...list(value.routes, `${path}/routes`, 'a route object', route),\n ...['next', 'back', 'skip'].flatMap((name) => action(value[name], `${path}/${name}`)),\n];\n\nexport function shapeIssues(input: unknown): DefinitionIssue[] {\n if (!isEntry(input)) return [error('invalid-type', '', 'the form definition must be an object')];\n return [\n ...list(input.fields, '/fields', 'a field object', field),\n ...list(input.steps, '/steps', 'a step object', step),\n ...action(input.submit, '/submit'),\n ...action(input.cancel, '/cancel'),\n ];\n}\n\nexport function metaIssues(input: Entry): DefinitionIssue[] {\n return [\n ...text(input, 'id', ''),\n ...(isEntry(input.submit) ? [] : [error('missing-property', '/submit', 'the submit action is missing', 'Add \"submit\": { \"label\": \"Submit\" }')]),\n ];\n}\n","import type { FormStep, StepRoute } from '../types';\n\nconst conditional = (source: Pick<StepRoute, 'show' | 'showAny'>) => !!(source.show?.length || source.showAny?.length);\n\nfunction successors(steps: FormStep[], indexes: Map<string, number>, from: number): number[] {\n const next: number[] = [];\n for (const route of steps[from].routes ?? []) {\n const target = route.to === null ? null : indexes.get(route.to);\n if (target === null && !conditional(route)) return next;\n if (target === null || target === undefined || target <= from) continue;\n next.push(target);\n if (!conditional(route) && !conditional(steps[target])) return next;\n }\n return from + 1 < steps.length ? [...next, from + 1] : next;\n}\n\nexport function reachableSteps(steps: FormStep[]): Set<number>[] {\n const indexes = new Map(steps.map((step, index) => [step.id, index]));\n return steps.map((_, start) => {\n const seen = new Set<number>();\n const queue = successors(steps, indexes, start);\n while (queue.length) {\n const index = queue.pop()!;\n if (seen.has(index)) continue;\n seen.add(index);\n queue.push(...successors(steps, indexes, index));\n if (conditional(steps[index]) && index + 1 < steps.length) queue.push(index + 1);\n }\n return seen;\n });\n}\n","import type { CheckContext, FieldEntry } from './context';\nimport type { DefinitionIssue } from './issues';\nimport { error, oneOf } from './issues';\nimport { reachableSteps } from './paths';\n\nconst RESERVED = new Set([...Object.getOwnPropertyNames(Object.prototype), 'prototype']);\n\nfunction stepIssues({ definition }: CheckContext): DefinitionIssue[] {\n const issues: DefinitionIssue[] = [];\n const steps = definition.steps ?? [];\n const seen = new Map<string, number>();\n steps.forEach((step, index) => {\n const first = seen.get(step.id);\n if (first === undefined) seen.set(step.id, index);\n else issues.push(error('duplicate-step-id', `/steps/${index}/id`, `step id \"${step.id}\" is already used by /steps/${first}`, 'Give each step a unique id'));\n });\n steps.forEach((step, index) => (step.routes ?? []).forEach((route, position) => {\n if (route.to === null) return;\n const target = seen.get(route.to);\n if (target !== undefined && target > index) return;\n const later = steps.slice(index + 1).map((candidate) => candidate.id);\n const problem = target === undefined ? `\"${route.to}\" is not a step id` : `\"${route.to}\" is not a later step`;\n const hint = later.length ? `${oneOf(later)}, or null to end the form here` : 'Use null to end the form here';\n issues.push(error('route-target', `/steps/${index}/routes/${position}/to`, problem, hint));\n }));\n return issues;\n}\n\nfunction keyIssues({ definition, entries }: CheckContext): DefinitionIssue[] {\n const issues: DefinitionIssue[] = [];\n const reachable = reachableSteps(definition.steps ?? []);\n const exclusive = (a: FieldEntry, b: FieldEntry) => a.step !== b.step && !reachable[a.step]?.has(b.step);\n entries.forEach((entry, index) => {\n const { field, path } = entry;\n const clash = entries.slice(0, index).find((other) => other.field.key === field.key && !exclusive(other, entry));\n if (RESERVED.has(field.key)) {\n issues.push(error('reserved-key', `${path}/key`, `\"${field.key}\" is a built-in object property name`, 'Rename the field key'));\n } else if (clash) {\n issues.push(error('duplicate-key', `${path}/key`, `key \"${field.key}\" is already used by ${clash.path} on the same path`, 'Rename one of the fields, or move them to route branches that never meet'));\n }\n });\n return issues;\n}\n\nexport function structureIssues(context: CheckContext): DefinitionIssue[] {\n const { definition } = context;\n const both = !!definition.fields?.length && !!definition.steps?.length;\n return [\n ...(both ? [error('fields-and-steps', '', 'the definition has both \"fields\" and \"steps\"', 'Move the top-level fields into a step, or remove \"steps\"')] : []),\n ...stepIssues(context),\n ...keyIssues(context),\n ];\n}\n","import type { FormField } from '../types';\nimport { BOOLEAN_TYPES, BUILT_IN_TYPES } from '../validation/type-checks';\nimport { conditionErrors, OPERATORS } from './conditions';\nimport type { CheckContext, ConditionEntry, FieldEntry } from './context';\nimport type { DefinitionIssue } from './issues';\nimport { closest, oneOf, suggest, warning } from './issues';\n\nconst LIST_OPERATORS = ['in', 'notIn'];\nconst COMPARISONS = ['gt', 'gte', 'lt', 'lte'];\nconst STRING_TYPES = ['text', 'email', 'phone', 'password', 'textarea', 'date', 'datetime', 'select', 'radio', 'autocomplete'];\n\nfunction expectedType(field: FormField): string | undefined {\n if (field.type === 'number') return 'number';\n if (BOOLEAN_TYPES.includes(field.type)) return 'boolean';\n return STRING_TYPES.includes(field.type) ? 'string' : undefined;\n}\n\nfunction valueIssue(target: FormField, operator: string, operand: unknown, path: string): DefinitionIssue[] {\n const mismatch = (problem: string, hint: string) => [warning('condition-value-mismatch', path, problem, hint)];\n if (operator === 'notEmpty') return [];\n if (COMPARISONS.includes(operator)) {\n if (target.type !== 'multiselect' && !BOOLEAN_TYPES.includes(target.type)) return [];\n return mismatch(`\"${target.key}\" is a ${target.type} field, so \"${operator}\" never matches it`, 'Compare a number, text, radio or select field');\n }\n if (target.type === 'multiselect') {\n const result = operator === 'neq' || operator === 'notIn' ? 'always' : 'never';\n return mismatch(`\"${target.key}\" holds a list of values, so \"${operator}\" ${result} matches it`, 'Use notEmpty, or a select or radio field');\n }\n const operands = LIST_OPERATORS.includes(operator) && Array.isArray(operand) ? operand : [operand];\n const expected = expectedType(target);\n const wrong = expected && operands.find((item) => typeof item !== expected);\n if (expected && wrong !== undefined) return mismatch(`${JSON.stringify(wrong)} is a ${typeof wrong}, but \"${target.key}\" holds a ${expected}`, `Use a ${expected} value`);\n const options = expected === 'string' && !target.optionsFrom && target.options?.length ? target.options.map((option) => option.value) : null;\n const missing = options && operands.find((item) => !options.includes(item as string));\n return options && missing !== undefined ? mismatch(`${JSON.stringify(missing)} is not an option of \"${target.key}\"`, oneOf(options)) : [];\n}\n\nfunction conditionWarnings(context: CheckContext, entry: ConditionEntry): DefinitionIssue[] {\n const { condition, path } = entry;\n if (conditionErrors(context, entry).length) return [];\n const operator = OPERATORS.find((key) => key in condition)!;\n return valueIssue(context.keys.get(condition.field)!.field, operator, condition[operator as keyof typeof condition], `${path}/${operator}`);\n}\n\nfunction optionIssues({ field, path }: FieldEntry): DefinitionIssue[] {\n if (!['select', 'radio', 'multiselect'].includes(field.type)) return [];\n if (!Array.isArray(field.options)) {\n return field.optionsFrom ? [] : [warning('missing-options', `${path}/options`, `the ${field.type} field \"${field.key}\" has no options`, 'Add \"options\" or \"optionsFrom\"')];\n }\n const values = field.options.map((option) => option.value);\n const defaults = field.type === 'multiselect' && Array.isArray(field.defaultValue) ? field.defaultValue : [field.defaultValue];\n const missing = field.defaultValue === undefined || !values.length || field.optionsFrom ? undefined : defaults.find((value) => !values.includes(value as string));\n if (missing === undefined) return [];\n return [warning('default-not-in-options', `${path}/defaultValue`, `${JSON.stringify(missing)} is not an option of \"${field.key}\"`, oneOf(values))];\n}\n\nfunction ruleWarnings(context: CheckContext, { field, path }: FieldEntry): DefinitionIssue[] {\n const rules = field.validation ?? {};\n const rule = (name: string, problem: string, hint: string) => warning('rule-not-applicable', `${path}/validation/${name}`, problem, hint);\n const known = BUILT_IN_TYPES.includes(field.type);\n const numeric = field.type === 'number';\n const ranges = known && !numeric ? (['min', 'max'] as const).filter((name) => rules[name] !== undefined) : [];\n const sized = known && ['number', 'checkbox', 'switch'].includes(field.type) ? (['minLength', 'maxLength'] as const).filter((name) => rules[name] !== undefined) : [];\n const issues = [\n ...ranges.map((name) => rule(name, `\"${name}\" applies to number fields only`, `Use ${name}Length to limit text length`)),\n ...sized.map((name) => rule(name, `\"${name}\" does not apply to ${field.type} fields`, numeric ? 'Use min and max for numbers' : `Remove ${name}`)),\n ];\n const { validators } = context;\n if (rules.validator !== undefined && validators && !Object.prototype.hasOwnProperty.call(validators, rules.validator)) {\n issues.push(warning('unknown-validator', `${path}/validation/validator`, `the validator \"${rules.validator}\" is not registered`, 'Pass it in the \"validators\" option'));\n }\n return issues;\n}\n\nfunction fieldWarnings(context: CheckContext, entry: FieldEntry): DefinitionIssue[] {\n const { field, path } = entry;\n const match = BUILT_IN_TYPES.includes(field.type) ? undefined : closest(field.type, BUILT_IN_TYPES);\n return [\n ...(match === undefined ? [] : [warning('unknown-field-type', `${path}/type`, `\"${field.type}\" is not a built-in field type`, `Use \"${match}\", or register a component for \"${field.type}\"`)]),\n ...optionIssues(entry),\n ...ruleWarnings(context, entry),\n ...(field.optionsDependsOn ?? []).flatMap((key, index) => (\n context.keys.has(key) ? [] : [warning('unknown-field', `${path}/optionsDependsOn/${index}`, `\"${key}\" is not a field key`, suggest(key, context.keyList))]\n )),\n ];\n}\n\nfunction routeWarnings({ definition }: CheckContext): DefinitionIssue[] {\n const steps = definition.steps ?? [];\n return steps.flatMap((step, index) => {\n const issues: DefinitionIssue[] = [];\n const targets = new Set((step.routes ?? []).map((route) => route.to).filter((to) => to !== null));\n for (const target of targets) {\n const position = steps.findIndex((candidate) => candidate.id === target);\n const sibling = steps[position + 1];\n const exits = steps[position]?.routes?.some((route) => !route.show?.length && !route.showAny?.length);\n if (!sibling || !targets.has(sibling.id) || exits) continue;\n issues.push(warning('route-fallthrough', `/steps/${position}`, `branch \"${target}\" from \"${step.id}\" continues into the sibling branch \"${sibling.id}\"`, `Add an unconditional route on \"${target}\" to the step where the branches meet`));\n }\n if (step.skip && (step.next === false || !steps[1])) {\n issues.push(warning('skip-unreachable', `/steps/${index}/skip`, `step \"${step.id}\" has \"skip\" but no Continue button or later step`, 'Remove \"skip\", or remove \"next\": false'));\n }\n return issues;\n });\n}\n\nexport function definitionWarnings(context: CheckContext): DefinitionIssue[] {\n return [\n ...(typeof context.definition.title === 'string' ? [] : [warning('missing-property', '/title', '\"title\" must be a string', 'Add a title for host UI and editors')]),\n ...context.conditions.flatMap((entry) => conditionWarnings(context, entry)),\n ...context.entries.flatMap((entry) => fieldWarnings(context, entry)),\n ...routeWarnings(context),\n ];\n}\n","import type { FormDefinition } from '../types';\nimport { conditionIssues } from './conditions';\nimport { createContext, type CheckContext } from './context';\nimport { fieldIssues } from './fields';\nimport { graphIssues } from './graph';\nimport { FormDefinitionError, suggest, type DefinitionIssue } from './issues';\nimport { metaIssues, shapeIssues } from './shape';\nimport { structureIssues } from './structure';\nimport { definitionWarnings } from './warnings';\n\nexport interface CheckDefinitionOptions {\n validators?: Record<string, unknown>;\n}\n\ninterface Checks {\n validators?: Record<string, unknown>;\n suggest?: CheckContext['suggest'];\n warnings?: (context: CheckContext) => DefinitionIssue[];\n}\n\nfunction issues(input: unknown, { validators, suggest, warnings }: Checks = {}): DefinitionIssue[] {\n const shape = shapeIssues(input);\n if (shape.length) return shape;\n const context = createContext(input as FormDefinition, validators, suggest);\n return [\n ...metaIssues(input as Record<string, unknown>),\n ...structureIssues(context),\n ...conditionIssues(context),\n ...fieldIssues(context),\n ...graphIssues(context),\n ...(warnings ? warnings(context) : []),\n ];\n}\n\nexport function definitionErrors(input: unknown): DefinitionIssue[] {\n return issues(input);\n}\n\nexport function checkDefinition(input: unknown, options: CheckDefinitionOptions = {}): DefinitionIssue[] {\n return issues(input, { validators: options.validators, suggest, warnings: definitionWarnings });\n}\n\nexport function parseDefinition(input: unknown, options?: CheckDefinitionOptions): FormDefinition {\n const errors = issues(input, { suggest });\n if (errors.length) throw new FormDefinitionError(errors);\n return input as FormDefinition;\n}\n","import { checkDefinition } from './check-definition';\n\nexport function validateDefinition(input: unknown): string[] {\n return checkDefinition(input).map((issue) => issue.message);\n}\n","export interface NotifyOptions {\n fieldKeys?: Iterable<string>;\n structureChanged?: boolean;\n}\n\ntype Listener = () => void;\n\nfunction listen(listeners: Set<Listener>, listener: Listener): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\nexport function createSubscriptions() {\n let version = 0;\n let structureVersion = 0;\n const listeners = new Set<Listener>();\n const structureListeners = new Set<Listener>();\n const fieldVersions = new Map<string, number>();\n const fieldListeners = new Map<string, Set<Listener>>();\n\n return {\n subscribe: (listener: Listener) => listen(listeners, listener),\n getSnapshot: () => version,\n subscribeStructure: (listener: Listener) => listen(structureListeners, listener),\n getStructureSnapshot: () => structureVersion,\n getFieldSnapshot: (key: string) => fieldVersions.get(key) ?? 0,\n\n subscribeField(key: string, listener: Listener): () => void {\n const set = fieldListeners.get(key) ?? new Set();\n set.add(listener);\n fieldListeners.set(key, set);\n return () => {\n set.delete(listener);\n if (set.size === 0) fieldListeners.delete(key);\n };\n },\n\n notify({ fieldKeys = [], structureChanged = false }: NotifyOptions = {}): void {\n for (const key of new Set(fieldKeys)) {\n fieldVersions.set(key, (fieldVersions.get(key) ?? 0) + 1);\n for (const listener of fieldListeners.get(key) ?? []) listener();\n }\n if (structureChanged) {\n structureVersion++;\n for (const listener of structureListeners) listener();\n }\n version++;\n for (const listener of listeners) listener();\n },\n };\n}\n","import { checkDefinition, FormDefinitionError, type DefinitionIssue } from '../definition-validation';\nimport { definitionErrors } from '../definition-validation/check-definition';\nimport { isError } from '../definition-validation/issues';\nimport type { FormDefinition } from '../types';\nimport type { FormEngineOptions } from './engine-options';\n\nfunction developmentIssues(definition: FormDefinition, validators: Record<string, unknown>): DefinitionIssue[] | undefined {\n try {\n if (process.env.NODE_ENV !== 'production') return checkDefinition(definition, { validators });\n } catch (error) {\n if (!(error instanceof ReferenceError)) throw error;\n }\n return undefined;\n}\n\nexport function assertDefinition(definition: FormDefinition, options: FormEngineOptions, validators: Record<string, unknown>): void {\n const issues = developmentIssues(definition, validators) ?? definitionErrors(definition);\n const errors = issues.filter(isError);\n if (errors.length) throw new FormDefinitionError(errors);\n const warn = options.onWarning ?? ((issue: DefinitionIssue) => console.warn(`[formhaus] ${issue.message}`));\n for (const issue of issues) warn(issue);\n}\n","import type { FormField, FormStep } from '../types';\nimport { conditionFields } from './engine-utils';\n\nexport function indexConditions<T extends FormField | FormStep>(dependent: T, index: Map<string, Set<T>>): void {\n for (const field of conditionFields(dependent)) {\n const dependents = index.get(field) ?? new Set<T>();\n dependents.add(dependent);\n index.set(field, dependents);\n }\n}\n","import { conditionFields, getAllFields } from './engine-utils';\nimport { indexConditions } from './visibility-index';\nimport { createActivePath } from './step-routes';\nimport type { ValidatorFn } from '../validation';\nimport { validateStep } from '../validation';\nimport type { FormDefinition, FormField, FormStep } from '../types';\nimport { isVisible } from '../visibility';\n\ninterface VisibilityCache {\n visibleSteps: FormStep[];\n currentStep: FormStep | null;\n visibleFields: FormField[];\n canGoNext: boolean;\n}\n\ntype Values = Record<string, unknown>;\n\nexport type VisibilityState = ReturnType<typeof createVisibility>;\n\nexport function createVisibility(definition: FormDefinition) {\n const allFields = getAllFields(definition);\n const fieldsByKey = new Map<string, FormField[]>();\n const routeFields = new Set<string>();\n const path = createActivePath(definition);\n const fieldDependents = new Map<string, Set<FormField>>();\n const stepDependents = new Map<string, Set<FormStep>>();\n const stepOfField = new Map<FormField, FormStep>();\n let visibilityDirty = true;\n let canGoNextDirty = true;\n const cache: VisibilityCache = { visibleSteps: [], currentStep: null, visibleFields: [], canGoNext: false };\n\n for (const field of allFields) {\n fieldsByKey.set(field.key, [...(fieldsByKey.get(field.key) ?? []), field]);\n indexConditions(field, fieldDependents);\n }\n for (const step of definition.steps ?? []) {\n for (const field of step.fields) stepOfField.set(field, step);\n indexConditions(step, stepDependents);\n for (const route of step.routes ?? []) for (const key of conditionFields(route)) routeFields.add(key);\n }\n\n const isMultiStep = () => (definition.steps ?? []).length > 0;\n const visible = (source: FormField | FormStep, values: Values) => isVisible(source, path.values(values));\n const onPath = (field: FormField, values: Values) => {\n const step = stepOfField.get(field);\n return !step || path.steps(values).includes(step);\n };\n\n function state(values: Values, stepIndex: number): VisibilityCache {\n if (!visibilityDirty) return cache;\n visibilityDirty = false;\n if (!isMultiStep()) {\n cache.visibleSteps = [];\n cache.currentStep = null;\n cache.visibleFields = (definition.fields ?? []).filter((field) => visible(field, values));\n return cache;\n }\n const steps = cache.visibleSteps = path.steps(values);\n const current = cache.currentStep = steps[stepIndex] ?? steps[steps.length - 1] ?? null;\n cache.visibleFields = current ? current.fields.filter((field) => visible(field, values)) : [];\n return cache;\n }\n\n return {\n allFields,\n conditionValues: path.values,\n state,\n\n markChanged(structureChanged: boolean, valuesChanged: boolean): void {\n if (structureChanged || valuesChanged) path.invalidate();\n if (structureChanged) visibilityDirty = true;\n if (structureChanged || valuesChanged) canGoNextDirty = true;\n },\n\n getCanGoNext(values: Values, stepIndex: number, validators: Record<string, ValidatorFn>): boolean {\n const step = state(values, stepIndex).currentStep;\n if (!canGoNextDirty) return cache.canGoNext;\n canGoNextDirty = false;\n const errors = step ? validateStep(step, path.values(values), validators) : {};\n return cache.canGoNext = isMultiStep() && Object.keys(errors).length === 0;\n },\n\n findStepIndex(fieldKey: string, values: Values, stepIndex: number): number | null {\n const target = state(values, stepIndex).visibleSteps.findIndex((step) => step.fields.some((field) => field.key === fieldKey));\n return target === -1 ? null : target;\n },\n\n affectsStructure(key: string, clearedFields: Set<string>): boolean {\n return routeFields.has(key) || fieldDependents.has(key) || stepDependents.has(key) || clearedFields.size > 0;\n },\n\n activeField(key: string, values: Values): FormField | undefined {\n return fieldsByKey.get(key)?.find((field) => onPath(field, values) && visible(field, values));\n },\n\n reconcileHidden(values: Values, errors: Record<string, string>): Set<string> {\n path.invalidate();\n const queue = [...new Set([...fieldDependents.keys(), ...stepDependents.keys()])];\n const queued = new Set(queue);\n const cleared = new Set<string>();\n const held = (key: string) => values[key] !== undefined || errors[key] !== undefined;\n const clear = (key: string) => {\n delete values[key];\n delete errors[key];\n path.invalidate();\n cleared.add(key);\n if (queued.has(key)) return;\n queued.add(key);\n queue.push(key);\n };\n for (let index = 0; index < queue.length; index++) {\n const key = queue[index];\n queued.delete(key);\n for (const field of fieldDependents.get(key) ?? []) {\n if (onPath(field, values) && !visible(field, values) && held(field.key)) clear(field.key);\n }\n for (const step of stepDependents.get(key) ?? []) {\n if (!visible(step, values)) for (const field of step.fields) if (held(field.key)) clear(field.key);\n }\n }\n return cleared;\n },\n };\n}\n","import type { ValidatorFn } from '../validation';\nimport type { FormDefinition, FormField, FormStep } from '../types';\nimport type { FormEngineOptions, StepValidateFn, SubmitFn } from './engine-options';\nimport { createValues } from './engine-utils';\nimport { changeStep, goToStepWithField, skipStep } from './navigation';\nimport type { EngineInternals, EngineState, RuntimeNotifyOptions } from './runtime-internals';\nimport { createSubscriptions, type NotifyOptions } from './subscriptions';\nimport {\n applyValidationErrors,\n getSubmitValues,\n resetEngine,\n validateForm,\n validateOne,\n clearResolvedMatchErrors,\n pruneOffPathErrors,\n} from './validation-state';\nimport { submitForm } from './submission';\nimport { reconcileStepIndex } from './step-routes';\nimport { assertDefinition } from './warnings';\nimport { createVisibility, type VisibilityState } from './visibility-state';\n\nexport class FormEngine<TValues extends object = Record<string, unknown>> {\n private readonly state: EngineState;\n private readonly skipped = new Map<string, string[]>();\n private validationEpoch = 0;\n private operationEpoch = 0;\n private readonly lifecycle: FormEngineOptions;\n\n private readonly validators: Record<string, ValidatorFn>;\n private get onStepValidate(): StepValidateFn | undefined { return this.lifecycle.onStepValidate; }\n private readonly visibility: VisibilityState;\n private readonly subscriptions = createSubscriptions();\n\n constructor(\n readonly definition: FormDefinition,\n initialValues?: Partial<NoInfer<TValues>>,\n options?: FormEngineOptions,\n ) {\n this.lifecycle = options ?? {};\n this.validators = options?.validators ?? {};\n assertDefinition(definition, this.lifecycle, this.validators);\n this.visibility = createVisibility(definition);\n const values = createValues(this.visibility.allFields, initialValues as Record<string, unknown> | undefined);\n this.state = { values, errors: {}, topLevelErrors: [], currentStepIndex: 0, fieldLoading: {}, stepValidating: false, submitting: false };\n this.visibility.reconcileHidden(values, this.state.errors);\n }\n\n get values(): Readonly<Partial<TValues>> { return this.state.values as Partial<TValues>; }\n get errors(): Readonly<Record<string, string>> { return this.state.errors; }\n get topLevelErrors(): readonly string[] { return this.state.topLevelErrors; }\n get currentStepIndex(): number { return this.state.currentStepIndex; }\n get fieldLoading(): Readonly<Record<string, boolean>> { return this.state.fieldLoading; }\n get stepValidating(): boolean { return this.state.stepValidating; }\n get submitting(): boolean { return this.state.submitting; }\n\n get isMultiStep(): boolean {\n return (this.definition.steps ?? []).length > 0;\n }\n\n get visibleSteps(): FormStep[] {\n return this.view.visibleSteps;\n }\n\n get currentStep(): FormStep | null {\n return this.view.currentStep;\n }\n\n get visibleFields(): FormField[] {\n return this.view.visibleFields;\n }\n\n get isFirstStep(): boolean {\n return this.currentStepIndex === 0;\n }\n\n get isLastStep(): boolean {\n return this.currentStepIndex >= this.visibleSteps.length - 1;\n }\n\n get canGoNext(): boolean {\n return this.visibility.getCanGoNext(this.state.values, this.currentStepIndex, this.validators);\n }\n\n get progress(): { current: number; total: number } {\n const total = this.visibleSteps.length;\n return { current: Math.min(this.currentStepIndex + 1, total), total };\n }\n\n subscribe(listener: () => void): () => void {\n return this.subscriptions.subscribe(listener);\n }\n\n getSnapshot(): number {\n return this.subscriptions.getSnapshot();\n }\n\n subscribeField(key: string, listener: () => void): () => void {\n return this.subscriptions.subscribeField(key, listener);\n }\n\n getFieldSnapshot(key: string): number {\n return this.subscriptions.getFieldSnapshot(key);\n }\n\n subscribeStructure(listener: () => void): () => void {\n return this.subscriptions.subscribeStructure(listener);\n }\n\n getStructureSnapshot(): number {\n return this.subscriptions.getStructureSnapshot();\n }\n\n setValue(key: string, value: unknown): void {\n const { values, errors } = this.state;\n const previousSteps = this.isMultiStep ? this.visibleSteps : null;\n const valueChanged = !Object.is(values[key], value);\n const hadError = errors[key] !== undefined;\n values[key] = value;\n delete errors[key];\n for (const [stepId, keys] of this.skipped) if (valueChanged && keys.includes(key)) this.skipped.delete(stepId);\n const clearedFields = this.visibility.reconcileHidden(values, errors);\n const revalidated = clearResolvedMatchErrors(this.internals, key);\n const changedFields = new Set([...clearedFields, ...revalidated]);\n if (valueChanged || hadError) changedFields.add(key);\n const valuesChanged = valueChanged || clearedFields.size > 0;\n const structureChanged = valuesChanged && this.visibility.affectsStructure(key, clearedFields);\n if (previousSteps && structureChanged) {\n this.visibility.markChanged(true, true);\n this.state.currentStepIndex = reconcileStepIndex(previousSteps, this.visibleSteps, this.currentStepIndex);\n for (const pruned of pruneOffPathErrors(this.internals)) changedFields.add(pruned);\n }\n this.notify({ fieldKeys: changedFields, structureChanged, valuesChanged });\n }\n\n setErrors(errors: Record<string, string>): void {\n applyValidationErrors(this.internals, errors, true);\n }\n\n setFieldLoading(key: string, loading: boolean): void {\n const previous = this.state.fieldLoading[key] === true;\n if (loading) this.state.fieldLoading[key] = true;\n else delete this.state.fieldLoading[key];\n this.notify({ fieldKeys: previous === loading ? [] : [key] });\n }\n\n cancelPendingActions(): void {\n this.validationEpoch++;\n this.operationEpoch++;\n this.state.stepValidating = false;\n this.state.submitting = false;\n this.notify();\n }\n\n next(): Promise<boolean> { return changeStep(this.internals, 'next'); }\n back(): Promise<boolean> { return changeStep(this.internals, 'back'); }\n skip(submit?: SubmitFn): Promise<boolean> { return skipStep(this.internals, submit); }\n submit(handler: SubmitFn): Promise<boolean> { return submitForm(this.internals, handler); }\n isStepSkipped(stepId: string): boolean { return this.skipped.has(stepId); }\n validate(): Record<string, string> { return validateForm(this.internals); }\n validateField(key: string): string | null { return validateOne(this.internals, key); }\n getSubmitValues(): Partial<TValues> { return getSubmitValues(this.internals) as Partial<TValues>; }\n goToStepWithField(key: string): void { goToStepWithField(this.internals, key); }\n reset(values?: Record<string, unknown>): void { resetEngine(this.internals, values); }\n\n private get view() {\n return this.visibility.state(this.state.values, this.currentStepIndex);\n }\n\n private get internals(): EngineInternals {\n return this as unknown as EngineInternals;\n }\n\n private notify(options: RuntimeNotifyOptions = {}): void {\n this.visibility.markChanged(!!options.structureChanged, !!options.valuesChanged);\n this.subscriptions.notify(options);\n }\n}\n"]}
|
package/dist/chunk-YXQFFAXK.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var T=class extends Error{constructor(e,n){super(`The action completed, but ${e} failed: ${n instanceof Error?n.message:String(n)}`);this.phase=e;this.committed=true;this.name="FormLifecycleError",this.cause=n;}};async function v(t,r){try{await r();}catch(e){throw new T(t,e)}}var d={email:"Enter a valid email",number:"Enter a number",boolean:"Must be true or false",option:"Select one of the available options",options:"Must be a list of available options",string:"Must be text",date:"Enter a valid date",datetime:"Enter a valid date and time",file:"Must be a file reference",value:"Invalid value"};function c(t,r){switch(t){case "required":return "This field is required";case "minLength":return `Must be at least ${r?.min} ${r?.unit??"characters"}`;case "maxLength":return `Must be at most ${r?.max} ${r?.unit??"characters"}`;case "min":return `Must be at least ${r?.min}`;case "max":return `Must be at most ${r?.max}`;case "pattern":return "Invalid format";case "matchField":return "Fields must match";default:return "Invalid value"}}var wt=["eq","neq","in","notIn","notEmpty","gt","gte","lt","lte"];function S(t){return t==null||t===""||Array.isArray(t)&&!t.length}function et(t){let r=typeof t=="string"&&t.trim()!==""?Number(t):t;return typeof r=="number"&&Number.isFinite(r)?r:void 0}function I(t,r,e){let n=et(t);return n!==void 0&&e(n,r)}function L(t,r){let e=r[t.field];return t.eq!==void 0?e===t.eq:t.neq!==void 0?e!==t.neq:t.in!==void 0?t.in.includes(e):t.notIn!==void 0?!t.notIn.includes(e):t.notEmpty!==void 0?!t.notEmpty||!S(e):t.gt!==void 0?I(e,t.gt,(n,o)=>n>o):t.gte!==void 0?I(e,t.gte,(n,o)=>n>=o):t.lt!==void 0?I(e,t.lt,(n,o)=>n<o):t.lte!==void 0?I(e,t.lte,(n,o)=>n<=o):false}function p(t,r){let e=n=>L(n,r);return (t.show??[]).every(e)&&(!t.showAny?.length||t.showAny.some(e))}var j=["checkbox","switch"],nt=["text","email","phone","number","password","select","autocomplete","multiselect","checkbox","radio","switch","file","date","datetime","textarea"],E=1e4,ot=254,st=1e3,it=/^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/,at=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,D="\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\\d|3[01])",ut=new RegExp(`^${D}$`),lt=new RegExp(`^${D}T(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d{1,3})?)?(?:Z|[+-](?:[01]\\d|2[0-3]):[0-5]\\d)?$`),dt=new Set(["text","phone","password","textarea","autocomplete"]),ft=new Map([["email",[it,d.email,ot]],["date",[ut,d.date,E]],["datetime",[lt,d.datetime,E]]]);function At(t,r){if(t.type!=="number"||typeof r!="string"||!at.test(r))return r;let e=Number(r);return Number.isFinite(e)?e:r}function q(t,r){return !t.options||t.options.some(e=>e.value===r)}function B(t,r){let e=Math.min(E,t.validation?.maxLength??E);return r.length<=e?null:t.validation?.maxLengthMessage??c("maxLength",{max:e})}function ct(t,r){return Array.isArray(r)?r.length>(t.options?.length??st)?d.option:r.every(n=>typeof n=="string"&&n.length<=E&&q(t,n))?null:d.option:d.options}function R(t,r,e){return typeof r=="string"?B(t,r):e}function pt(t,r,[e,n,o]){return typeof r!="string"?n:B(t,r)??(r.length<=o&&e.test(r)?null:n)}function mt(t,r){return typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r)?null:R(t,r,d.value)}function yt(t,r){return r==null||r===""||t.type==="multiselect"&&Array.isArray(r)&&!r.length}function ht(t,r){if(yt(t,r))return null;if(j.includes(t.type))return typeof r=="boolean"?null:d.boolean;if(t.type==="number")return typeof r=="number"&&Number.isFinite(r)?null:d.number;if(t.type==="multiselect")return ct(t,r);if(t.type==="file")return R(t,r,d.file);let e=ft.get(t.type);return e?pt(t,r,e):t.type==="select"||t.type==="radio"?R(t,r,d.option)??(q(t,r)?null:d.option):dt.has(t.type)?R(t,r,d.string):mt(t,r)}function K(t,r){return t.type==="file"||!nt.includes(t.type)?null:ht(t.optionsFrom?{...t,options:void 0}:t,r)}function bt(t,r){return S(t)||t===false&&j.includes(r.type)}function Y(t,r,e,n){let o=e[`min${r}`],s=e[`max${r}`];if(o!==void 0&&t<o)return e[`min${r}Message`]??c(`min${r}`,{min:o,unit:n});if(s!==void 0&&t>s)return e[`max${r}Message`]??c(`max${r}`,{max:s,unit:n})}function Ft(t,r){if(r.pattern!==void 0)try{return new RegExp(r.pattern).test(String(t))?void 0:r.patternMessage??c("pattern")}catch{return}}function b(t,r,e,n){let o=t.validation??{},s=o.matchFieldMessage??c("matchField");if(bt(r,t))return o.required?typeof o.required=="string"?o.required:c("required"):o.matchField!==void 0&&!S(e[o.matchField])?s:null;let i=K(t,r);if(i)return i;let a=typeof r=="string"||Array.isArray(r)?Y(r.length,"Length",o,Array.isArray(r)?"items":void 0):typeof r=="number"?Y(r,"",o):void 0,u=o.matchField!==void 0&&r!==e[o.matchField]?s:void 0;return (a??Ft(r,o)??u??(o.validator?n?.[o.validator]?.(r,e):void 0))||null}function k(t,r,e){return C(t.fields,r,e)}function C(t,r,e){let n={};for(let o of t){if(!p(o,r))continue;let s=b(o,r[o.key],r,e);s&&(n[o.key]=s);}return n}function Yt(t){return [...t.show??[],...t.showAny??[]].map(r=>r.field)}function Gt(t){return t.steps?.length?t.steps.flatMap(r=>r.fields):t.fields??[]}function V(t,r){let e={};for(let n of t)n.defaultValue!==void 0&&(e[n.key]=n.defaultValue);return Object.assign(e,r)}function y(t,r){let e=new Set([...Object.keys(t),...Object.keys(r)]);return new Set([...e].filter(n=>!Object.is(t[n],r[n])))}function G(t){return t.visibleSteps.map(r=>r.id).join(`
|
|
2
|
-
`)}function x(t,r){let e=G(t);return ()=>G(t)!==e||Object.keys(r).some(n=>r[n]!==void 0&&!Object.is(t.values[n],r[n]))}function H(t,r,e=false){let n=t.errors;t.state.errors={},t.state.topLevelErrors=[];for(let[s,i]of Object.entries(r))t.visibility.activeField(s,t.values)?t.errors[s]=i:t.topLevelErrors.push(i);let o=e&&X(t,r);t.notify({fieldKeys:y(n,t.errors),structureChanged:o});}function X(t,r){let e=Object.keys(r).find(o=>t.errors[o]!==void 0),n=e&&t.isMultiStep?t.visibility.findStepIndex(e,t.values,t.currentStepIndex):null;return n===null||n===t.currentStepIndex?false:(t.state.currentStepIndex=n,true)}function Wt(t,r){let e=[];for(let n of t.visibility.allFields)n.validation?.matchField!==r||t.errors[n.key]===void 0||b(n,t.values[n.key],h(t),t.validators)||(delete t.errors[n.key],e.push(n.key));return e}function z(t){let r=new Set(t.visibleSteps.flatMap(n=>n.fields.map(o=>o.key))),e=Object.keys(t.errors).filter(n=>!r.has(n));for(let n of e)delete t.errors[n];return e}function h(t){return M(t)}function St(t,r){for(let e of [...t.skipped.values()].flat())delete r[e];return r}function $(t,r=false){let e=t.errors,n={};if(t.isMultiStep)for(let s of t.visibleSteps)t.skipped.has(s.id)||Object.assign(n,k(s,h(t),t.validators));else Object.assign(n,C(t.definition.fields??[],h(t),t.validators));t.state.errors=n;let o=r&&X(t,n);return t.notify({fieldKeys:y(e,n),structureChanged:o}),n}function Zt(t,r){let e=t.visibility.activeField(r,t.values);if(!e)return null;let n=t.errors[r],o=b(e,t.values[r],h(t),t.validators);o?t.errors[r]=o:delete t.errors[r];let s=Object.is(n,t.errors[r])?[]:[r];return t.notify({fieldKeys:s}),o}function M(t){return St(t,{...t.visibility.conditionValues(t.values)})}function Jt(t,r){let e=t.values,n=t.errors,o=Object.keys(t.fieldLoading);t.validationEpoch++,t.operationEpoch++,t.state.submitting=false,t.state.values=V(t.visibility.allFields,r),t.state.errors={},t.state.topLevelErrors=[],t.state.fieldLoading={},t.state.stepValidating=false,t.state.currentStepIndex=0,t.skipped.clear(),t.visibility.reconcileHidden(t.values,t.errors);let s=y(e,t.values),i=new Set([...s,...y(n,t.errors),...o]);t.notify({fieldKeys:i,structureChanged:true,valuesChanged:s.size>0});}function P(t,r){let e=t.steps??[],n=new Map(e.map((i,a)=>[i.id,a])),o=[],s={};for(let i=0;i<e.length;){let a=e[i];if(!p(a,s)){i++;continue}o.push(a),Object.assign(s,U(a,r,s));let u=a.routes?.find(l=>p(l,s)&&(l.to===null||(n.get(l.to)??-1)>i&&p(e[n.get(l.to)],s)));if(u?.to===null)break;i=u?n.get(u.to):i+1;}return o}function rr(t,r,e){let n=t[e]??t[t.length-1],o=r.findIndex(i=>i.id===n?.id);if(o!==-1)return o;let s=new Map(r.map((i,a)=>[i.id,a]));for(let i=Math.min(e-1,t.length-1);i>=0;i--){let a=s.get(t[i].id);if(a!==void 0)return a}return 0}function U(t,r,e){let n={...e};for(let s of t.fields)n[s.key]=r[s.key];let o={};for(let s of t.fields)p(s,n)&&r[s.key]!==void 0&&(o[s.key]=r[s.key]);return o}function er(t){let r=null,e=[],n={},o=s=>{if(r===s)return;r=s,e=P(t,s);let i={},a=t.steps?.length?e:[{fields:t.fields??[]}];for(let u of a)Object.assign(i,U(u,s,i));n=i;};return {invalidate(){r=null;},steps(s){return o(s),e},values(s){return o(s),n}}}function W(t){let r=t.currentStep?.fields??[],e={...t.values};for(let{key:n}of r)delete e[n];return Object.assign(e,V(r))}function N(t){return P(t.definition,W(t))[t.currentStepIndex+1]}function A(t){let r=t.currentStep,e=r.fields.map(({key:o})=>o);t.state.values=W(t);for(let o of e)delete t.errors[o];t.skipped.set(r.id,e),t.visibility.reconcileHidden(t.values,t.errors),t.visibility.markChanged(true,true);let n=z(t);return t.notify({fieldKeys:[...e,...n],structureChanged:true,valuesChanged:true}),e}function O(t){let r=t.currentStep;r&&t.skipped.delete(r.id);}function ar(t,r){return t.state.currentStepIndex=r,t.notify({structureChanged:true}),A(t)}async function Z(t,r,e=false){if(t.submitting||t.stepValidating)return false;e||O(t);let n={...t.lifecycle},o=false,s=t.validationEpoch,i=++t.operationEpoch,a=M(t),u=x(t,a),l=()=>s!==t.validationEpoch||i!==t.operationEpoch||u();t.state.submitting=true,t.notify();try{if(l()||Object.keys($(t,!0)).length>0||l())return !1;if(n.onBeforeSubmit){let w=await n.onBeforeSubmit(a);if(l()||w===!1)return !1}if(l())return !1;if(n.onBeforeSubmit){if(Object.keys($(t,!0)).length>0||l())return !1;a=M(t);}o=!0;let f=[...t.skipped.keys()];return await r(a,[...f]),i!==t.operationEpoch||await v("afterSubmit",()=>n.onAfterSubmit?.(a,f)),!0}catch(f){if(!o&&l())return false;throw f}finally{i===t.operationEpoch&&(t.state.submitting=false,t.notify());}}function J(t){let r=t.currentStep;if(!r)return true;let e=k(r,h(t),t.validators);if(Object.keys(e).length===0)return false;let n={...t.errors};return Object.assign(t.errors,e),t.notify({fieldKeys:y(n,t.errors)}),true}function Q(t,r){t.validationEpoch++,t.state.currentStepIndex=r,t.notify({structureChanged:true});}async function kr(t,r){if(!t.isMultiStep||t.stepValidating||t.submitting||!t.currentStep?.skip)return false;if(N(t))return Et(t,"next","skip");let e=t.currentStep;if(!r||!e)return false;let n=t.values,o={...t.errors},s=false,i=A(t),a=t.values,u=x(t,{...a});try{return await Z(t,async(l,f)=>{await r(l,f),s=!0;},!0)}finally{!s&&t.values===a&&!u()&&(t.state.values=n,t.state.errors={...o,...t.errors},t.skipped.delete(e.id),t.notify({fieldKeys:i,structureChanged:true,valuesChanged:true}));}}async function Et(t,r,e=r){let n=e==="skip";if(!t.isMultiStep||t.stepValidating||t.submitting||!n&&(r==="next"?t.isLastStep:t.isFirstStep))return false;let o=t.currentStep,s=r==="next"&&!n;if(s&&O(t),s&&J(t))return false;let i={...t.lifecycle},a=t.onStepValidate,u=false,f=t.currentStepIndex+(r==="next"?1:-1),w=n?N(t):t.visibleSteps[f];if(!w)return false;let g={fromStepId:o.id,toStepId:w.id,reason:e,values:{...h(t)}},tt=t.validationEpoch,_=++t.operationEpoch,rt=x(t,g.values),F=()=>tt!==t.validationEpoch||_!==t.operationEpoch||t.currentStep?.id!==o.id||rt();t.state.stepValidating=true,t.notify();try{if(F())return !1;if(s&&a){let m=await a(o.id,g.values);if(F())return !1;if(m&&Object.keys(m).length>0)return H(t,m),!1}if(i.onBeforeStepChange){let m=await i.onBeforeStepChange(g);if(F()||m===!1)return !1}return F()||s&&J(t)?!1:(u=!0,n&&A(t),Q(t,f),await v("afterStepChange",()=>i.onAfterStepChange?.(g)),!0)}catch(m){if(!u&&F())return false;throw m}finally{_===t.operationEpoch&&(t.state.stepValidating=false,t.notify());}}function xr(t,r){if(!t.isMultiStep)return;let e=t.visibility.findStepIndex(r,t.values,t.currentStepIndex);e===t.currentStepIndex?t.notify():e!==null&&Q(t,e);}export{kr as A,Et as B,xr as C,Yt as a,Gt as b,V as c,T as d,c as e,wt as f,L as g,p as h,j as i,nt as j,At as k,ht as l,b as m,k as n,C as o,H as p,Wt as q,z as r,$ as s,Zt as t,M as u,Jt as v,rr as w,er as x,ar as y,Z as z};//# sourceMappingURL=chunk-YXQFFAXK.js.map
|
|
3
|
-
//# sourceMappingURL=chunk-YXQFFAXK.js.map
|