@digiform/wizard 0.2.10 → 0.2.16
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/core/src/types/api.js +12 -0
- package/core/src/types/form-config.js +60 -0
- package/core/src/types/form-wizard-config-schema.js +113 -0
- package/core/src/types/guards.js +19 -0
- package/core/src/types/validation.js +61 -0
- package/core/src/utils/apiBodyUtils.js +95 -0
- package/features/api-integration.d.ts +2 -0
- package/features/api-integration.js +17 -0
- package/features/dialog-system.d.ts +2 -0
- package/features/dialog-system.js +9 -0
- package/features/form-runtime.d.ts +2 -0
- package/features/form-runtime.js +63 -0
- package/features/state-management.d.ts +2 -0
- package/features/state-management.js +21 -0
- package/features/trigger-action-system.d.ts +2 -0
- package/features/trigger-action-system.js +12 -0
- package/features/validation-system.d.ts +2 -0
- package/features/validation-system.js +23 -0
- package/index.js +108 -17470
- package/package.json +41 -30
- package/styles.css +1 -4
- package/ui/src/component-registry/renderComponent.js +11 -0
- package/ui/src/components/FormLayout/FormLayout.js +135 -0
- package/ui/src/components/FormLayout/FormLayout.module.css.js +20 -0
- package/ui/src/components/GridLayout/GridLayout.js +62 -0
- package/ui/src/components/GridLayout/GridLayout.module.css.js +16 -0
- package/ui/src/components/GridLayoutColumn/GridLayoutColumn.js +37 -0
- package/ui/src/components/GridLayoutColumn/GridLayoutColumn.module.css.js +10 -0
- package/ui/src/components/ProgressLoaderBar/ProgressLoaderBar.js +108 -0
- package/ui/src/components/ProgressLoaderBar/ProgressLoaderBar.module.css.js +20 -0
- package/ui/src/components/ProgressLoaderBar/useProgressAnimation.js +31 -0
- package/ui/src/components/ValidationCode/ValidationCode.js +198 -0
- package/ui/src/components/ValidationCode/ValidationCode.module.css.js +20 -0
- package/ui/src/components/alert/alert.js +30 -0
- package/ui/src/components/alert/alert.module.css.js +14 -0
- package/ui/src/components/badge/badge.js +20 -0
- package/ui/src/components/badge/badge.module.css.js +12 -0
- package/ui/src/components/box/box.js +8 -0
- package/ui/src/components/box/box.module.css.js +8 -0
- package/ui/src/components/button/button.js +25 -0
- package/ui/src/components/button/button.module.css.js +18 -0
- package/ui/src/components/card/card.js +106 -0
- package/ui/src/components/card/card.module.css.js +44 -0
- package/ui/src/components/checkbox/checkbox.js +20 -0
- package/ui/src/components/checkbox/checkbox.module.css.js +10 -0
- package/ui/src/components/dialog/dialog.js +67 -0
- package/ui/src/components/dialog/dialog.module.css.js +20 -0
- package/ui/src/components/form-header-base/form-header-base.js +59 -0
- package/ui/src/components/form-header-base/form-header-base.module.css.js +14 -0
- package/ui/src/components/input/input.js +20 -0
- package/ui/src/components/input/input.module.css.js +8 -0
- package/ui/src/components/radio-group/radio-group.js +30 -0
- package/ui/src/components/radio-group/radio-group.module.css.js +14 -0
- package/ui/src/components/select/select.js +115 -0
- package/ui/src/components/select/select.module.css.js +32 -0
- package/ui/src/components/sheet/sheet.js +71 -0
- package/ui/src/components/sheet/sheet.module.css.js +46 -0
- package/ui/src/components/textarea/textarea.js +19 -0
- package/ui/src/components/textarea/textarea.module.css.js +8 -0
- package/ui/src/design-system/components/FormFieldWrapper.js +16 -0
- package/ui/src/lib/assets/icons/Check.js +26 -0
- package/ui/src/lib/assets/icons/ChevronRight.js +26 -0
- package/ui/src/lib/error-boundaries/BaseErrorBoundary.js +155 -0
- package/ui/src/lib/error-boundaries/ComponentErrorBoundary.js +153 -0
- package/ui/src/lib/error-boundaries/FormWizardErrorBoundary.js +107 -0
- package/ui/src/lib/logger.js +106 -0
- package/ui/src/lib/providers/FormEditingContext.js +21 -0
- package/ui/src/lib/queryClient.js +26 -0
- package/ui/src/lib/types/guards.js +11 -0
- package/ui/src/lib/utils/componentUtils.js +38 -0
- package/ui/src/lib/utils/templateDialogResolver.js +85 -0
- package/ui/src/lib/utils/templateUtils.js +52 -0
- package/ui/src/theme/ThemeProvider.js +15 -0
- package/wizard/src/features/api-integration/components/EnhancedActionExecutor/EnhancedActionExecutor.js +370 -0
- package/wizard/src/features/api-integration/services/ActionExecutor.js +339 -0
- package/wizard/src/features/api-integration/services/ApiCallExecutor.js +6 -0
- package/wizard/src/features/api-integration/services/ApiCallService.js +309 -0
- package/wizard/src/features/api-integration/services/DialogExecutor.js +6 -0
- package/wizard/src/features/api-integration/services/GenericTriggerService.js +284 -0
- package/wizard/src/features/api-integration/services/NavigationExecutor.js +6 -0
- package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.js +115 -0
- package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.module.css.js +29 -0
- package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js +64 -0
- package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.module.css.js +22 -0
- package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.js +149 -0
- package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.module.css.js +40 -0
- package/wizard/src/features/form-runtime/ComponentAdapterComplete/ComponentAdapterComplete.js +107 -0
- package/wizard/src/features/form-runtime/ComponentAdapterComplete/ComponentAdapterComplete.module.css.js +10 -0
- package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +107 -0
- package/wizard/src/features/form-runtime/FormWizard/FormWizard.module.css.js +16 -0
- package/wizard/src/features/form-runtime/components/FormField.js +405 -0
- package/wizard/src/features/form-runtime/components/FormFooter.js +209 -0
- package/wizard/src/features/form-runtime/components/FormHeader.js +29 -0
- package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +279 -0
- package/wizard/src/features/form-runtime/components/FormSection/FormSection.module.css.js +20 -0
- package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +167 -0
- package/wizard/src/features/form-runtime/components/FormStep/FormStep.module.css.js +12 -0
- package/wizard/src/features/form-runtime/components/ProgressLoaderRuntime.js +88 -0
- package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +61 -0
- package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.module.css.js +34 -0
- package/wizard/src/features/form-runtime/components/displayValue/displayValue.js +21 -0
- package/wizard/src/features/form-runtime/components/displayValue/displayValue.module.css.js +10 -0
- package/wizard/src/features/form-runtime/components/renderers/DisplayModeRenderer/DisplayModeRenderer.js +28 -0
- package/wizard/src/features/form-runtime/components/renderers/DisplayModeRenderer/DisplayModeRenderer.module.css.js +8 -0
- package/wizard/src/features/form-runtime/components/renderers/InteractiveFieldRenderer/InteractiveFieldRenderer.js +56 -0
- package/wizard/src/features/form-runtime/components/renderers/InteractiveFieldRenderer/InteractiveFieldRenderer.module.css.js +8 -0
- package/wizard/src/features/form-runtime/config/configResolver.js +38 -0
- package/wizard/src/features/form-runtime/config/templateConfig.js +156 -0
- package/wizard/src/features/form-runtime/config/templateLoader.js +265 -0
- package/wizard/src/features/form-runtime/config/templateUtils.js +14 -0
- package/wizard/src/features/form-runtime/context/LoaderContext.js +36 -0
- package/wizard/src/features/form-runtime/hooks/useApiActions.js +60 -0
- package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +102 -0
- package/wizard/src/features/form-runtime/hooks/useComponentVisibility.js +18 -0
- package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +61 -0
- package/wizard/src/features/form-runtime/hooks/useFormContext.js +13 -0
- package/wizard/src/features/form-runtime/hooks/useFormFieldState.js +40 -0
- package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +39 -0
- package/wizard/src/features/form-runtime/utils/componentDisplayValue.js +22 -0
- package/wizard/src/features/form-runtime/utils/errorUtils.js +93 -0
- package/wizard/src/features/form-runtime/utils/fieldHelpers.js +17 -0
- package/wizard/src/features/form-runtime/utils/formDataBuilder.js +10 -0
- package/wizard/src/features/form-runtime/utils/formDirtyStateSync.js +52 -0
- package/wizard/src/features/form-runtime/utils/logger.js +111 -0
- package/wizard/src/features/form-runtime/utils/validation.js +100 -0
- package/wizard/src/features/form-runtime/utils/validationUX.js +58 -0
- package/wizard/src/features/form-runtime/utils/visibilityUtils.js +77 -0
- package/wizard/src/features/state-management/machines/actions/componentActions.js +215 -0
- package/wizard/src/features/state-management/machines/actions/navigationActions.js +122 -0
- package/wizard/src/features/state-management/machines/actions/saveActions.js +101 -0
- package/wizard/src/features/state-management/machines/componentTriggerEngine.js +598 -0
- package/wizard/src/features/state-management/machines/formMachine.js +1565 -0
- package/wizard/src/features/state-management/machines/guards/navigationGuards.js +59 -0
- package/wizard/src/features/state-management/machines/guards/saveGuards.js +21 -0
- package/wizard/src/features/state-management/machines/guards/triggerGuards.js +11 -0
- package/wizard/src/features/state-management/machines/helpers/triggerHelpers.js +12 -0
- package/wizard/src/features/state-management/machines/performance.js +56 -0
- package/wizard/src/features/state-management/machines/useFormMachine.js +412 -0
- package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.js +46 -0
- package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.module.css.js +30 -0
- package/wizard/src/features/trigger-action-system/components/ActionManager.js +108 -0
- package/wizard/src/features/trigger-action-system/components/ComponentAlert/ComponentAlert.js +10 -0
- package/wizard/src/features/trigger-action-system/components/ComponentAlert/ComponentAlert.module.css.js +8 -0
- package/wizard/src/features/trigger-action-system/utils/GenericTriggerEngine.js +376 -0
- package/wizard/src/features/validation-system/components/ValidationDebugger.js +69 -0
- package/wizard/src/features/validation-system/validation/ActionValidation.js +234 -0
- package/wizard/src/features/validation-system/validation/SchemaBuilder.js +239 -0
- package/wizard/src/features/validation-system/validation/ValidationCache.js +76 -0
- package/wizard/src/features/validation-system/validation/ValidationEngine.js +97 -0
- package/wizard/src/features/validation-system/validation/ValidationExecutor.js +138 -0
- package/wizard/src/features/validation-system/validation/tanstackSchemaAdapter.js +17 -0
- package/wizard/src/features/validation-system/validation/validationService.js +74 -0
- package/wizard/src/renderer/wizardRenderer.js +123 -0
- package/README.md +0 -147
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useFormMachine as B } from "../../state-management/machines/useFormMachine.js";
|
|
3
|
+
import { useCallback as g } from "react";
|
|
4
|
+
import { markFieldAsUserInteracted as u } from "../utils/validationUX.js";
|
|
5
|
+
import { useComponentTriggers as F } from "./useComponentTriggers.js";
|
|
6
|
+
const E = ({
|
|
7
|
+
componentId: s,
|
|
8
|
+
hasIsDirtyTriggers: r,
|
|
9
|
+
originalValueFromMachine: i,
|
|
10
|
+
getEnhancedIsDirty: n,
|
|
11
|
+
resetValidationState: f
|
|
12
|
+
}) => {
|
|
13
|
+
const [, , d] = B(), { setData: h } = d, t = F({ componentId: s }), C = g(
|
|
14
|
+
(a) => (e) => {
|
|
15
|
+
const l = a.state.value;
|
|
16
|
+
if (console.log(
|
|
17
|
+
`🔍 [useFieldEventHandlers] handleChange for ${s}:`,
|
|
18
|
+
{
|
|
19
|
+
oldValue: l,
|
|
20
|
+
newValue: e,
|
|
21
|
+
valueType: typeof e,
|
|
22
|
+
isSameValue: l === e
|
|
23
|
+
}
|
|
24
|
+
), u(s), a.handleChange(e), console.log(
|
|
25
|
+
`🔍 [useFieldEventHandlers] AFTER field.handleChange for ${s}:`,
|
|
26
|
+
{
|
|
27
|
+
fieldStateValue: a.state.value,
|
|
28
|
+
fieldStateMeta: a.state.meta
|
|
29
|
+
}
|
|
30
|
+
), l !== e && h(s, e), f(), r && i !== void 0) {
|
|
31
|
+
const c = n(
|
|
32
|
+
l,
|
|
33
|
+
a.state.meta.isDirty
|
|
34
|
+
), o = e !== i;
|
|
35
|
+
o !== c && (o ? t.evaluateTriggers("valueChange", e) : t.dismissAlert());
|
|
36
|
+
}
|
|
37
|
+
t.hasTriggers && !r && l !== e && t.handleValueChange(e);
|
|
38
|
+
},
|
|
39
|
+
[
|
|
40
|
+
s,
|
|
41
|
+
h,
|
|
42
|
+
f,
|
|
43
|
+
r,
|
|
44
|
+
i,
|
|
45
|
+
n,
|
|
46
|
+
t
|
|
47
|
+
]
|
|
48
|
+
), m = g(
|
|
49
|
+
(a) => () => {
|
|
50
|
+
u(s), a.handleBlur(), t.hasTriggers && t.handleBlur();
|
|
51
|
+
},
|
|
52
|
+
[s, t]
|
|
53
|
+
);
|
|
54
|
+
return {
|
|
55
|
+
handleChange: C,
|
|
56
|
+
handleBlur: m
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
E as useFieldEventHandlers
|
|
61
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext as t, useContext as e } from "react";
|
|
3
|
+
const r = t(null), s = r.Provider, m = () => {
|
|
4
|
+
const o = e(r);
|
|
5
|
+
if (!o)
|
|
6
|
+
throw new Error("useFormContext must be used within a FormProvider");
|
|
7
|
+
return o;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
r as FormContext,
|
|
11
|
+
s as FormProvider,
|
|
12
|
+
m as useFormContext
|
|
13
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useFormMachine as p } from "../../state-management/machines/useFormMachine.js";
|
|
3
|
+
import { useRef as F, useCallback as u, useEffect as O } from "react";
|
|
4
|
+
import { useFormContext as h } from "./useFormContext.js";
|
|
5
|
+
const b = ({
|
|
6
|
+
componentId: r,
|
|
7
|
+
hasIsDirtyTriggers: s
|
|
8
|
+
}) => {
|
|
9
|
+
const [V] = p(), t = h(), a = F(!1), c = F(), d = (e) => typeof e == "string" || typeof e == "boolean" || typeof e == "number" || e === null || e === void 0, f = V.context.componentOriginalValues[r]?.value, i = d(f) ? f : void 0, g = u(() => {
|
|
10
|
+
if (a.current) return;
|
|
11
|
+
const e = t.getFieldValue(r);
|
|
12
|
+
return a.current = !0, e;
|
|
13
|
+
}, [r, t]), o = u(() => {
|
|
14
|
+
const e = i, l = c.current;
|
|
15
|
+
if (s && e !== void 0 && e !== l)
|
|
16
|
+
try {
|
|
17
|
+
const n = t.getFieldValue(r);
|
|
18
|
+
t.resetField(r), n != null && n !== "" && t.setFieldValue(r, n, {
|
|
19
|
+
dontUpdateMeta: !0
|
|
20
|
+
});
|
|
21
|
+
} catch (n) {
|
|
22
|
+
console.error(`Error resetting form state for ${r}:`, n);
|
|
23
|
+
}
|
|
24
|
+
c.current = e;
|
|
25
|
+
}, [i, r, t, s]), m = u(
|
|
26
|
+
(e, l) => i !== void 0 ? e !== i : l,
|
|
27
|
+
[i]
|
|
28
|
+
);
|
|
29
|
+
return O(() => {
|
|
30
|
+
o();
|
|
31
|
+
}, [o]), {
|
|
32
|
+
originalValueFromMachine: i,
|
|
33
|
+
initializeField: g,
|
|
34
|
+
handleFormReset: o,
|
|
35
|
+
getEnhancedIsDirty: m
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
b as useFormFieldState
|
|
40
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState as s, useRef as u, useCallback as c, useEffect as f } from "react";
|
|
3
|
+
const w = ({
|
|
4
|
+
componentId: t
|
|
5
|
+
}) => {
|
|
6
|
+
const [d, i] = s(!1), a = u(null), o = c(() => {
|
|
7
|
+
i(!1);
|
|
8
|
+
}, []);
|
|
9
|
+
return f(() => {
|
|
10
|
+
const r = (n) => {
|
|
11
|
+
const { fieldId: e } = n.detail;
|
|
12
|
+
e === t && i(!0);
|
|
13
|
+
}, l = (n) => {
|
|
14
|
+
const { fieldIds: e } = n.detail;
|
|
15
|
+
Array.isArray(e) && e.includes(t) && i(!0);
|
|
16
|
+
};
|
|
17
|
+
return a.current = r, window.addEventListener(
|
|
18
|
+
"triggerFieldValidation",
|
|
19
|
+
r
|
|
20
|
+
), window.addEventListener(
|
|
21
|
+
"triggerStepValidation",
|
|
22
|
+
l
|
|
23
|
+
), () => {
|
|
24
|
+
window.removeEventListener(
|
|
25
|
+
"triggerFieldValidation",
|
|
26
|
+
r
|
|
27
|
+
), window.removeEventListener(
|
|
28
|
+
"triggerStepValidation",
|
|
29
|
+
l
|
|
30
|
+
), a.current = null;
|
|
31
|
+
};
|
|
32
|
+
}, [t]), {
|
|
33
|
+
forceShowValidation: d,
|
|
34
|
+
resetValidationState: o
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
w as useValidationEvents
|
|
39
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { renderDefaultDisplayValue as a, renderDropdownDisplayValue as n, renderRadioGroupDisplayValue as t, renderCheckboxDisplayValue as u, renderTextDisplayValue as l } from "../components/displayValue/displayValue.js";
|
|
3
|
+
const s = (e) => {
|
|
4
|
+
switch (e) {
|
|
5
|
+
case "text":
|
|
6
|
+
case "email":
|
|
7
|
+
case "number":
|
|
8
|
+
return l;
|
|
9
|
+
case "checkbox":
|
|
10
|
+
return u;
|
|
11
|
+
case "radioGroup":
|
|
12
|
+
return t;
|
|
13
|
+
case "dropdown":
|
|
14
|
+
return n;
|
|
15
|
+
default:
|
|
16
|
+
return a;
|
|
17
|
+
}
|
|
18
|
+
}, p = (e, r) => s(e.type)(e, r);
|
|
19
|
+
export {
|
|
20
|
+
s as getDisplayValueRenderer,
|
|
21
|
+
p as renderComponentDisplayValue
|
|
22
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { z as a } from "zod";
|
|
3
|
+
const u = {
|
|
4
|
+
required: 10,
|
|
5
|
+
minLength: 8,
|
|
6
|
+
maxLength: 7,
|
|
7
|
+
min: 6,
|
|
8
|
+
max: 5,
|
|
9
|
+
pattern: 4,
|
|
10
|
+
email: 3,
|
|
11
|
+
custom: 2,
|
|
12
|
+
default: 1
|
|
13
|
+
}, i = (t) => {
|
|
14
|
+
if (typeof t == "string")
|
|
15
|
+
return t.includes("verplicht") || t.includes("required") ? "required" : t.includes("minimaal") && t.includes("tekens") ? "minLength" : t.includes("maximaal") && t.includes("tekens") ? "maxLength" : t.includes("minimaal") && !t.includes("tekens") ? "min" : t.includes("maximaal") && !t.includes("tekens") ? "max" : t.includes("formaat") || t.includes("format") || t.includes("pattern") ? "pattern" : t.includes("e-mail") || t.includes("email") ? "email" : "default";
|
|
16
|
+
if (t instanceof a.ZodError) {
|
|
17
|
+
const e = t.errors[0];
|
|
18
|
+
if (e?.code)
|
|
19
|
+
switch (e.code) {
|
|
20
|
+
case "too_small":
|
|
21
|
+
return e.type === "string" ? "minLength" : "min";
|
|
22
|
+
case "too_big":
|
|
23
|
+
return e.type === "string" ? "maxLength" : "max";
|
|
24
|
+
case "invalid_string":
|
|
25
|
+
return e.validation === "email" ? "email" : "pattern";
|
|
26
|
+
case "custom":
|
|
27
|
+
return "custom";
|
|
28
|
+
default:
|
|
29
|
+
return "default";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (typeof t == "object" && t !== null && "code" in t) {
|
|
33
|
+
const e = t.code;
|
|
34
|
+
if (e === "too_small") return "minLength";
|
|
35
|
+
if (e === "too_big") return "maxLength";
|
|
36
|
+
if (e === "invalid_string") return "email";
|
|
37
|
+
}
|
|
38
|
+
return "default";
|
|
39
|
+
}, s = (t) => {
|
|
40
|
+
if (t == null) return "";
|
|
41
|
+
if (typeof t == "string")
|
|
42
|
+
return t;
|
|
43
|
+
if (t instanceof a.ZodError)
|
|
44
|
+
return t.errors.map((e) => e.message).join(", ");
|
|
45
|
+
if (typeof t == "object" && t !== null) {
|
|
46
|
+
if ("message" in t && typeof t.message == "string")
|
|
47
|
+
return t.message;
|
|
48
|
+
if ("_errors" in t && Array.isArray(t._errors))
|
|
49
|
+
return t._errors.filter(Boolean).join(", ");
|
|
50
|
+
if ("issues" in t && Array.isArray(t.issues))
|
|
51
|
+
return t.issues.map((e) => e.message || "Validation error").join(", ");
|
|
52
|
+
if ("error" in t)
|
|
53
|
+
return s(t.error);
|
|
54
|
+
try {
|
|
55
|
+
if (Object.keys(t).length > 0) {
|
|
56
|
+
for (const n of ["message", "msg", "error", "description"])
|
|
57
|
+
if (n in t && typeof t[n] == "string")
|
|
58
|
+
return t[n];
|
|
59
|
+
}
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const e = JSON.stringify(t);
|
|
65
|
+
if (e.length < 200)
|
|
66
|
+
return e;
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
return "Validation error occurred";
|
|
70
|
+
}, c = (t) => t.filter((e) => e != null).map((e) => s(e)).filter((e) => e.length > 0), m = (t) => {
|
|
71
|
+
if (!t || t.length === 0) return "";
|
|
72
|
+
const e = t.filter((n) => n != null).map((n) => ({
|
|
73
|
+
message: s(n),
|
|
74
|
+
type: i(n),
|
|
75
|
+
priority: u[i(n)]
|
|
76
|
+
})).filter((n) => n.message.length > 0);
|
|
77
|
+
return e.length === 0 ? "" : (e.sort((n, l) => l.priority - n.priority), e[0].message);
|
|
78
|
+
}, g = (t) => c(t)[0] || "", d = (t) => t.map((e, n) => ({
|
|
79
|
+
index: n,
|
|
80
|
+
type: typeof e,
|
|
81
|
+
constructor: e?.constructor?.name,
|
|
82
|
+
raw: e,
|
|
83
|
+
parsed: s(e),
|
|
84
|
+
validationType: i(e),
|
|
85
|
+
priority: u[i(e)]
|
|
86
|
+
}));
|
|
87
|
+
export {
|
|
88
|
+
d as getErrorDebugInfo,
|
|
89
|
+
g as getFirstErrorMessage,
|
|
90
|
+
m as getMostRelevantError,
|
|
91
|
+
c as parseAllErrors,
|
|
92
|
+
s as parseError
|
|
93
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const n = (r) => !(r.type === "button" || r.type === "submit" || r.type === "reset" || r.type === "paragraph" || r.type === "heading" || r.type === "alert"), g = (r) => (r.triggerActions?.triggers || r.triggers || []).some((e) => e.type === "isDirty"), o = (r, t) => r == null ? !1 : t === "checkbox" ? !0 : r !== "", a = (r, t) => r && t, l = (r, t, e) => {
|
|
3
|
+
const s = r.errors || [], i = !r.isValid && s.length > 0, u = e || t.isSubmitting;
|
|
4
|
+
return {
|
|
5
|
+
fieldErrors: s,
|
|
6
|
+
isInvalid: i,
|
|
7
|
+
isSubmitAttempted: u
|
|
8
|
+
};
|
|
9
|
+
}, y = (r, t, e) => r ? t && e > 0 : e > 0;
|
|
10
|
+
export {
|
|
11
|
+
o as checkFieldHasValue,
|
|
12
|
+
g as checkHasIsDirtyTriggers,
|
|
13
|
+
l as getValidationDisplayState,
|
|
14
|
+
n as shouldBeFormField,
|
|
15
|
+
y as shouldShowComponentAlerts,
|
|
16
|
+
a as shouldShowDisplayMode
|
|
17
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { isFormField as r, getDefaultValue as s } from "../../../../../ui/src/lib/utils/componentUtils.js";
|
|
4
|
+
const u = (i) => (i.sections ?? []).flatMap((e) => e.components).filter((e) => r(e.type)).reduce(
|
|
5
|
+
(e, t) => (e[t.id] = s(t.type), e),
|
|
6
|
+
{}
|
|
7
|
+
);
|
|
8
|
+
export {
|
|
9
|
+
u as buildDefaultValues
|
|
10
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function n(u, f = {}) {
|
|
3
|
+
const t = u, { updatedFields: a, debug: r = !1 } = f;
|
|
4
|
+
r && console.log("🔄 [formDirtyStateSync] Starting dirty state reset:", {
|
|
5
|
+
updatedFields: a,
|
|
6
|
+
formState: {
|
|
7
|
+
isDirty: t.state.isDirty,
|
|
8
|
+
dirtyFields: t.state.dirtyFields,
|
|
9
|
+
values: t.state.values
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
try {
|
|
13
|
+
const i = Object.keys(t.state.values), c = a || i;
|
|
14
|
+
r && console.log("🔄 [formDirtyStateSync] Fields to reset:", c), c.forEach((e) => {
|
|
15
|
+
const s = t.getFieldValue(e), o = t.getFieldMeta(e);
|
|
16
|
+
if (r && console.log(`🔄 [formDirtyStateSync] Resetting field ${e}:`, {
|
|
17
|
+
currentValue: s,
|
|
18
|
+
isDirtyBefore: o?.isDirty,
|
|
19
|
+
isTouchedBefore: o?.isTouched,
|
|
20
|
+
isDefaultValueBefore: o?.isDefaultValue
|
|
21
|
+
}), t.resetField(e), s != null && s !== "" && t.setFieldValue(e, s, {
|
|
22
|
+
dontUpdateMeta: !0
|
|
23
|
+
// This prevents updating isDirty/isTouched flags
|
|
24
|
+
}), r) {
|
|
25
|
+
const l = t.getFieldMeta(e);
|
|
26
|
+
console.log(
|
|
27
|
+
`✅ [formDirtyStateSync] Field ${e} reset complete:`,
|
|
28
|
+
{
|
|
29
|
+
isDirtyAfter: l?.isDirty,
|
|
30
|
+
isTouchedAfter: l?.isTouched,
|
|
31
|
+
isDefaultValueAfter: l?.isDefaultValue,
|
|
32
|
+
currentValueAfter: t.getFieldValue(e)
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}), r && console.log("✅ [formDirtyStateSync] Dirty state reset complete:", {
|
|
37
|
+
formStateAfter: {
|
|
38
|
+
isDirty: t.state.isDirty,
|
|
39
|
+
dirtyFields: t.state.dirtyFields,
|
|
40
|
+
values: t.state.values
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
} catch (i) {
|
|
44
|
+
throw console.error(
|
|
45
|
+
"❌ [formDirtyStateSync] Error during dirty state reset:",
|
|
46
|
+
i
|
|
47
|
+
), i;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
n as resetFormDirtyStateAfterApiPopulation
|
|
52
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
class n {
|
|
3
|
+
config;
|
|
4
|
+
constructor() {
|
|
5
|
+
this.config = {
|
|
6
|
+
enabled: this.getInitialEnabledState(),
|
|
7
|
+
level: "debug"
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
getInitialEnabledState() {
|
|
11
|
+
if (typeof process < "u" && process.env?.VITE_FORM_FIELD_DEBUG === "true")
|
|
12
|
+
return !0;
|
|
13
|
+
if (typeof window < "u" && window.localStorage) {
|
|
14
|
+
const e = window.localStorage.getItem("form-field-debug");
|
|
15
|
+
if (e !== null)
|
|
16
|
+
return e === "true";
|
|
17
|
+
}
|
|
18
|
+
return !1;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Enable or disable logging
|
|
22
|
+
*/
|
|
23
|
+
setEnabled(e) {
|
|
24
|
+
this.config.enabled = e, typeof window < "u" && window.localStorage && window.localStorage.setItem("form-field-debug", e.toString());
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check if logging is enabled
|
|
28
|
+
*/
|
|
29
|
+
isEnabled() {
|
|
30
|
+
return this.config.enabled;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Set logging level
|
|
34
|
+
*/
|
|
35
|
+
setLevel(e) {
|
|
36
|
+
this.config.level = e;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Debug level logging
|
|
40
|
+
*/
|
|
41
|
+
debug(e, o) {
|
|
42
|
+
this.config.enabled && console.log(`🔧 [FormField] ${e}`, o);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Info level logging
|
|
46
|
+
*/
|
|
47
|
+
info(e, o) {
|
|
48
|
+
this.config.enabled && console.log(`ℹ️ [FormField] ${e}`, o);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Warning level logging
|
|
52
|
+
*/
|
|
53
|
+
warn(e, o) {
|
|
54
|
+
this.config.enabled && console.warn(`⚠️ [FormField] ${e}`, o);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Error level logging (always shown regardless of enabled state)
|
|
58
|
+
*/
|
|
59
|
+
error(e, o) {
|
|
60
|
+
console.error(`❌ [FormField] ${e}`, o);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Critical error logging (always shown regardless of enabled state)
|
|
64
|
+
*/
|
|
65
|
+
critical(e, o) {
|
|
66
|
+
console.error(`🚨 [FormField] ${e}`, o);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Validation specific logging
|
|
70
|
+
*/
|
|
71
|
+
validation(e, o) {
|
|
72
|
+
this.config.enabled && console.log(`🔍 [FormField] ${e}`, o);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* State management specific logging
|
|
76
|
+
*/
|
|
77
|
+
state(e, o) {
|
|
78
|
+
this.config.enabled && console.log(`📋 [FormField] ${e}`, o);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Component lifecycle logging
|
|
82
|
+
*/
|
|
83
|
+
lifecycle(e, o) {
|
|
84
|
+
this.config.enabled && console.log(`🏁 [FormField] ${e}`, o);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Change event logging
|
|
88
|
+
*/
|
|
89
|
+
change(e, o) {
|
|
90
|
+
this.config.enabled && console.log(`🔄 [FormField] ${e}`, o);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Test/experimental logging
|
|
94
|
+
*/
|
|
95
|
+
test(e, o) {
|
|
96
|
+
this.config.enabled && console.log(`🧪 [FormField] ${e}`, o);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const i = new n(), l = () => i.setEnabled(!0), t = () => i.setEnabled(!1), d = () => i.isEnabled();
|
|
100
|
+
typeof window < "u" && (window.formFieldLogger = {
|
|
101
|
+
enable: l,
|
|
102
|
+
disable: t,
|
|
103
|
+
isEnabled: d,
|
|
104
|
+
logger: i
|
|
105
|
+
});
|
|
106
|
+
export {
|
|
107
|
+
t as disableFormFieldLogging,
|
|
108
|
+
l as enableFormFieldLogging,
|
|
109
|
+
d as isFormFieldLoggingEnabled,
|
|
110
|
+
i as logger
|
|
111
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const o = (r) => r === void 0 ? { value: void 0 } : typeof r == "object" && r !== null && "value" in r ? {
|
|
3
|
+
value: r.value,
|
|
4
|
+
message: r.message
|
|
5
|
+
} : { value: r }, y = (r, t, a) => {
|
|
6
|
+
if (!r.validation)
|
|
7
|
+
return [];
|
|
8
|
+
const i = [], n = r.validation;
|
|
9
|
+
if (n.required) {
|
|
10
|
+
const { value: e, message: s } = o(
|
|
11
|
+
n.required
|
|
12
|
+
);
|
|
13
|
+
e && !u(t) && i.push(s || "This field is required");
|
|
14
|
+
}
|
|
15
|
+
if (n.minLength) {
|
|
16
|
+
const { value: e, message: s } = o(
|
|
17
|
+
n.minLength
|
|
18
|
+
);
|
|
19
|
+
e !== void 0 && !d(t, e) && i.push(s || `Minimum length is ${e} characters`);
|
|
20
|
+
}
|
|
21
|
+
if (n.maxLength) {
|
|
22
|
+
const { value: e, message: s } = o(
|
|
23
|
+
n.maxLength
|
|
24
|
+
);
|
|
25
|
+
e !== void 0 && !m(t, e) && i.push(s || `Maximum length is ${e} characters`);
|
|
26
|
+
}
|
|
27
|
+
if (n.pattern) {
|
|
28
|
+
const { value: e, message: s } = o(
|
|
29
|
+
n.pattern
|
|
30
|
+
);
|
|
31
|
+
e && !c(t, e) && i.push(s || "Invalid format");
|
|
32
|
+
}
|
|
33
|
+
if (n.email) {
|
|
34
|
+
const { value: e, message: s } = o(
|
|
35
|
+
n.email
|
|
36
|
+
);
|
|
37
|
+
e && !l(t) && i.push(s || "Invalid email address");
|
|
38
|
+
}
|
|
39
|
+
if (n.min) {
|
|
40
|
+
const { value: e, message: s } = o(n.min);
|
|
41
|
+
e !== void 0 && !f(t, e) && i.push(s || `Minimum value is ${e}`);
|
|
42
|
+
}
|
|
43
|
+
if (n.max) {
|
|
44
|
+
const { value: e, message: s } = o(n.max);
|
|
45
|
+
e !== void 0 && !g(t, e) && i.push(s || `Maximum value is ${e}`);
|
|
46
|
+
}
|
|
47
|
+
if (n.rules && n.rules.length > 0)
|
|
48
|
+
for (const e of n.rules)
|
|
49
|
+
h(e, t, a) || i.push(e.message || "Validation failed");
|
|
50
|
+
return i;
|
|
51
|
+
}, h = (r, t, a) => {
|
|
52
|
+
const i = r.params;
|
|
53
|
+
switch (r.type) {
|
|
54
|
+
case "required":
|
|
55
|
+
return u(t);
|
|
56
|
+
case "minLength":
|
|
57
|
+
return d(t, i?.min);
|
|
58
|
+
case "maxLength":
|
|
59
|
+
return m(t, i?.max);
|
|
60
|
+
case "pattern":
|
|
61
|
+
return c(t, i?.pattern);
|
|
62
|
+
case "email":
|
|
63
|
+
return l(t);
|
|
64
|
+
case "number":
|
|
65
|
+
return p(t);
|
|
66
|
+
case "min":
|
|
67
|
+
return f(t, i?.min);
|
|
68
|
+
case "max":
|
|
69
|
+
return g(t, i?.max);
|
|
70
|
+
case "custom":
|
|
71
|
+
return x(t, i?.validator, a);
|
|
72
|
+
default:
|
|
73
|
+
return !0;
|
|
74
|
+
}
|
|
75
|
+
}, u = (r) => r == null ? !1 : typeof r == "string" ? r.trim() !== "" : Array.isArray(r) ? r.length > 0 : !0, d = (r, t) => t === void 0 || r === void 0 || r === null ? !0 : typeof r == "string" || Array.isArray(r) ? r.length >= t : !0, m = (r, t) => t === void 0 || r === void 0 || r === null ? !0 : typeof r == "string" || Array.isArray(r) ? r.length <= t : !0, c = (r, t) => {
|
|
76
|
+
if (t === void 0 || r === void 0 || r === null || typeof r != "string") return !0;
|
|
77
|
+
try {
|
|
78
|
+
return new RegExp(t).test(r);
|
|
79
|
+
} catch {
|
|
80
|
+
return console.error("Invalid regex pattern:", t), !0;
|
|
81
|
+
}
|
|
82
|
+
}, l = (r) => r == null || r === "" ? !0 : typeof r != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r), p = (r) => r == null || r === "" ? !0 : !Number.isNaN(Number(r)), f = (r, t) => t === void 0 || r === void 0 || r === null || r === "" ? !0 : Number(r) >= t, g = (r, t) => t === void 0 || r === void 0 || r === null || r === "" ? !0 : Number(r) <= t, x = (r, t, a) => {
|
|
83
|
+
if (!t) return !0;
|
|
84
|
+
console.warn(
|
|
85
|
+
"[DEPRECATED] String-based custom validators are deprecated and pose security risks. Please migrate to function-based validators using the ValidationEngine."
|
|
86
|
+
);
|
|
87
|
+
try {
|
|
88
|
+
return new Function(
|
|
89
|
+
"value",
|
|
90
|
+
"formData",
|
|
91
|
+
`return ${t}`
|
|
92
|
+
)(r, a);
|
|
93
|
+
} catch (i) {
|
|
94
|
+
return console.error("Error in custom validator:", i), !1;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
export {
|
|
98
|
+
y as validateComponentValue,
|
|
99
|
+
h as validateRule
|
|
100
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getMostRelevantError as l } from "./errorUtils.js";
|
|
3
|
+
const a = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), g = (r) => {
|
|
4
|
+
s.add(r);
|
|
5
|
+
}, u = (r) => s.has(r), w = () => {
|
|
6
|
+
s.clear();
|
|
7
|
+
}, h = (r, t = !1, e) => {
|
|
8
|
+
const { errors: i, isTouched: n, isValid: c } = r;
|
|
9
|
+
return e && a.has(e) && a.get(e) ? !1 : c ? (e && a.set(e, !0), !1) : !i || i.length === 0 ? !1 : (e && a.set(e, !1), t ? !0 : e && !u(e) ? !1 : n);
|
|
10
|
+
}, A = (r, t) => {
|
|
11
|
+
a.set(r, t);
|
|
12
|
+
}, E = (r, t = !1) => h(r, t) ? l(r.errors || []) : "", o = {
|
|
13
|
+
// Text inputs: validate on blur, show errors after touch
|
|
14
|
+
textInput: {
|
|
15
|
+
validateOn: "blur",
|
|
16
|
+
showErrorsAfter: "touch"
|
|
17
|
+
},
|
|
18
|
+
// Email: validate on blur, show errors after touch
|
|
19
|
+
email: {
|
|
20
|
+
validateOn: "blur",
|
|
21
|
+
showErrorsAfter: "touch"
|
|
22
|
+
},
|
|
23
|
+
// Numbers: validate on blur, show errors after touch
|
|
24
|
+
number: {
|
|
25
|
+
validateOn: "blur",
|
|
26
|
+
showErrorsAfter: "touch"
|
|
27
|
+
},
|
|
28
|
+
// Radio groups: validate on change, show errors after touch
|
|
29
|
+
radioGroup: {
|
|
30
|
+
validateOn: "change",
|
|
31
|
+
showErrorsAfter: "touch"
|
|
32
|
+
},
|
|
33
|
+
// Selects: validate on change, show errors after touch
|
|
34
|
+
select: {
|
|
35
|
+
validateOn: "change",
|
|
36
|
+
showErrorsAfter: "touch"
|
|
37
|
+
},
|
|
38
|
+
// Checkboxes: validate on change, show errors after touch
|
|
39
|
+
checkbox: {
|
|
40
|
+
validateOn: "change",
|
|
41
|
+
showErrorsAfter: "touch"
|
|
42
|
+
},
|
|
43
|
+
// Multi-select: validate on change, show errors after touch
|
|
44
|
+
multiselect: {
|
|
45
|
+
validateOn: "change",
|
|
46
|
+
showErrorsAfter: "touch"
|
|
47
|
+
}
|
|
48
|
+
}, v = (r) => o[r] || o.textInput;
|
|
49
|
+
export {
|
|
50
|
+
o as VALIDATION_TIMING,
|
|
51
|
+
w as clearUserInteractionTracking,
|
|
52
|
+
E as getDisplayErrorMessage,
|
|
53
|
+
v as getValidationTiming,
|
|
54
|
+
u as hasUserInteracted,
|
|
55
|
+
g as markFieldAsUserInteracted,
|
|
56
|
+
h as shouldShowValidationError,
|
|
57
|
+
A as updateValidationCache
|
|
58
|
+
};
|