@digiform/wizard 0.3.2 → 0.3.3
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/features/form-runtime/index.d.ts +0 -1
- package/features/state-management/machines/useFormMachine.d.ts +6 -6
- package/package.json +31 -13
- package/ui/src/lib/types/guards.js +1 -5
- package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +47 -69
- package/wizard/src/features/form-runtime/FormWizard/FormWizard.module.css.js +4 -12
- package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +94 -101
- package/wizard/src/features/state-management/machines/useFormMachine.js +3 -3
- package/wizard/src/features/validation-system/validation/ValidationExecutor.js +36 -44
- package/core/src/types/guards.js +0 -7
- package/features/form-runtime/config/configResolver.d.ts +0 -14
- package/features/form-runtime/config/index.d.ts +0 -9
- package/features/form-runtime/config/templateConfig.d.ts +0 -148
- package/features/form-runtime/config/templateLoader.d.ts +0 -25
- package/features/form-runtime/config/templateUtils.d.ts +0 -12
- package/ui/src/lib/utils/templateUtils.js +0 -20
- package/wizard/src/features/form-runtime/config/configResolver.js +0 -34
- package/wizard/src/features/form-runtime/config/templateLoader.js +0 -228
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { default as ComponentAdapterComplete } from './ComponentAdapterComplete/ComponentAdapterComplete';
|
|
7
7
|
export * from './components';
|
|
8
|
-
export * from './config';
|
|
9
8
|
export type { FormWizardProps } from './FormWizard/FormWizard';
|
|
10
9
|
export { default as FormWizard } from './FormWizard/FormWizard';
|
|
11
10
|
export * from './hooks';
|
|
@@ -442,7 +442,7 @@ export declare const useFormMachineProvider: ({ config, initialData, onSubmit, }
|
|
|
442
442
|
type: "TRIGGER_STEP_VALIDATION";
|
|
443
443
|
fieldIds: string[];
|
|
444
444
|
}) => void;
|
|
445
|
-
currentStep: import('../../../../../core/src/index.ts').FormStepConfig
|
|
445
|
+
currentStep: import('../../../../../core/src/index.ts').FormStepConfig;
|
|
446
446
|
currentStepId: string;
|
|
447
447
|
currentStepIndex: number;
|
|
448
448
|
data: FormData;
|
|
@@ -453,7 +453,7 @@ export declare const useFormMachineProvider: ({ config, initialData, onSubmit, }
|
|
|
453
453
|
touchedFields: Record<string, boolean>;
|
|
454
454
|
isFirstStep: boolean;
|
|
455
455
|
isLastStep: boolean;
|
|
456
|
-
steps:
|
|
456
|
+
steps: import('../../../../../core/src/index.ts').FormStepConfig[];
|
|
457
457
|
config: FormWizardConfig;
|
|
458
458
|
validationEngine: ValidationEngine;
|
|
459
459
|
findComponentById: (componentId: string) => ComponentConfig | null;
|
|
@@ -951,7 +951,7 @@ export declare const FormMachineContext: {
|
|
|
951
951
|
type: "TRIGGER_STEP_VALIDATION";
|
|
952
952
|
fieldIds: string[];
|
|
953
953
|
}) => void;
|
|
954
|
-
currentStep: import('../../../../../core/src/index.ts').FormStepConfig
|
|
954
|
+
currentStep: import('../../../../../core/src/index.ts').FormStepConfig;
|
|
955
955
|
currentStepId: string;
|
|
956
956
|
currentStepIndex: number;
|
|
957
957
|
data: FormData;
|
|
@@ -962,7 +962,7 @@ export declare const FormMachineContext: {
|
|
|
962
962
|
touchedFields: Record<string, boolean>;
|
|
963
963
|
isFirstStep: boolean;
|
|
964
964
|
isLastStep: boolean;
|
|
965
|
-
steps:
|
|
965
|
+
steps: import('../../../../../core/src/index.ts').FormStepConfig[];
|
|
966
966
|
config: FormWizardConfig;
|
|
967
967
|
validationEngine: ValidationEngine;
|
|
968
968
|
findComponentById: (componentId: string) => ComponentConfig | null;
|
|
@@ -1454,7 +1454,7 @@ export declare const useFormMachine: () => readonly [import('xstate').MachineSna
|
|
|
1454
1454
|
type: "TRIGGER_STEP_VALIDATION";
|
|
1455
1455
|
fieldIds: string[];
|
|
1456
1456
|
}) => void, {
|
|
1457
|
-
currentStep: import('../../../../../core/src/index.ts').FormStepConfig
|
|
1457
|
+
currentStep: import('../../../../../core/src/index.ts').FormStepConfig;
|
|
1458
1458
|
currentStepId: string;
|
|
1459
1459
|
currentStepIndex: number;
|
|
1460
1460
|
data: FormData;
|
|
@@ -1465,7 +1465,7 @@ export declare const useFormMachine: () => readonly [import('xstate').MachineSna
|
|
|
1465
1465
|
touchedFields: Record<string, boolean>;
|
|
1466
1466
|
isFirstStep: boolean;
|
|
1467
1467
|
isLastStep: boolean;
|
|
1468
|
-
steps:
|
|
1468
|
+
steps: import('../../../../../core/src/index.ts').FormStepConfig[];
|
|
1469
1469
|
config: FormWizardConfig;
|
|
1470
1470
|
validationEngine: ValidationEngine;
|
|
1471
1471
|
findComponentById: (componentId: string) => ComponentConfig | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digiform/wizard",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "React component for rendering configurable multi-step forms from a JSON config",
|
|
5
5
|
"author": "VladAfanasev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,23 +36,41 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
|
|
41
|
-
"react": "
|
|
42
|
-
"react-
|
|
43
|
-
"
|
|
44
|
-
"@
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@radix-ui/react-accordion": "^1.0.0",
|
|
41
|
+
"@radix-ui/react-alert-dialog": "^1.0.0",
|
|
42
|
+
"@radix-ui/react-checkbox": "^1.0.0",
|
|
43
|
+
"@radix-ui/react-context-menu": "^2.0.0",
|
|
44
|
+
"@radix-ui/react-dialog": "^1.0.0",
|
|
45
|
+
"@radix-ui/react-dropdown-menu": "^2.0.0",
|
|
46
|
+
"@radix-ui/react-hover-card": "^1.0.0",
|
|
47
|
+
"@radix-ui/react-label": "^2.0.0",
|
|
48
|
+
"@radix-ui/react-navigation-menu": "^1.0.0",
|
|
49
|
+
"@radix-ui/react-popover": "^1.0.0",
|
|
50
|
+
"@radix-ui/react-progress": "^1.0.0",
|
|
51
|
+
"@radix-ui/react-radio-group": "^1.0.0",
|
|
52
|
+
"@radix-ui/react-scroll-area": "^1.0.0",
|
|
53
|
+
"@radix-ui/react-select": "^2.0.0",
|
|
54
|
+
"@radix-ui/react-separator": "^1.0.0",
|
|
55
|
+
"@radix-ui/react-slot": "^1.0.0",
|
|
56
|
+
"@radix-ui/react-switch": "^1.0.0",
|
|
57
|
+
"@radix-ui/react-tabs": "^1.0.0",
|
|
58
|
+
"@radix-ui/react-toast": "^1.0.0",
|
|
59
|
+
"@radix-ui/react-toggle": "^1.0.0",
|
|
60
|
+
"@radix-ui/react-toggle-group": "^1.0.0",
|
|
61
|
+
"@radix-ui/react-tooltip": "^1.0.0",
|
|
45
62
|
"@tanstack/react-form": "^1.0.0",
|
|
46
63
|
"@tanstack/zod-form-adapter": "^0.40.0",
|
|
47
|
-
"
|
|
48
|
-
"@radix-ui/react-checkbox": "^1.3.0",
|
|
49
|
-
"@radix-ui/react-dialog": "^1.1.0",
|
|
50
|
-
"@radix-ui/react-radio-group": "^1.3.0",
|
|
51
|
-
"@radix-ui/react-select": "^2.2.0",
|
|
52
|
-
"@radix-ui/react-slot": "^1.2.0",
|
|
64
|
+
"@xstate/react": "^5.0.0",
|
|
53
65
|
"clsx": "^2.1.0",
|
|
54
66
|
"date-fns": "^3.6.0",
|
|
55
67
|
"lucide-react": "^0.462.0",
|
|
68
|
+
"xstate": "^5.0.0",
|
|
69
|
+
"zod": "^3.20.0"
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"react": ">=18.0.0",
|
|
73
|
+
"react-dom": ">=18.0.0",
|
|
56
74
|
"@rijkshuisstijl-community/components-react": ">=7.0.0"
|
|
57
75
|
}
|
|
58
76
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
function t(e) {
|
|
3
|
-
return typeof e == "object" && e !== null && "templateId" in e;
|
|
4
|
-
}
|
|
5
|
-
function l(e) {
|
|
6
3
|
return e && typeof e.template == "object" && typeof e.template.typeId == "string";
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
10
|
-
t as isTemplateStep
|
|
6
|
+
t as isTemplateDialogConfig
|
|
11
7
|
};
|
|
@@ -1,85 +1,63 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as r, jsxs as
|
|
3
|
-
import { wizardDefaultRenderer as
|
|
2
|
+
import { jsx as r, jsxs as d } from "react/jsx-runtime";
|
|
3
|
+
import { wizardDefaultRenderer as u } from "../../../renderer/wizardRenderer.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import { FormLayout as
|
|
6
|
-
import { formWizardQueryClient as
|
|
7
|
-
import { QueryClientProvider as
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Q(E);
|
|
24
|
-
const v = M(
|
|
5
|
+
import { FormLayout as m } from "../../../../../ui/src/components/FormLayout/FormLayout.js";
|
|
6
|
+
import { formWizardQueryClient as g } from "../../../../../ui/src/lib/queryClient.js";
|
|
7
|
+
import { QueryClientProvider as y } from "@tanstack/react-query";
|
|
8
|
+
import { memo as C, useMemo as s } from "react";
|
|
9
|
+
import F from "./FormWizard.module.css.js";
|
|
10
|
+
import v from "../components/FormStep/FormStep.js";
|
|
11
|
+
import S from "../components/StepProgressIndicator/StepProgressIndicator.js";
|
|
12
|
+
import { ThemeProvider as M, useThemeConfig as z } from "../../../../../ui/src/theme/ThemeProvider.js";
|
|
13
|
+
import { useFormMachineProvider as P, FormMachineContext as N } from "../../state-management/machines/useFormMachine.js";
|
|
14
|
+
import W from "../../../../../ui/src/lib/error-boundaries/FormWizardErrorBoundary.js";
|
|
15
|
+
import { FormEditingProvider as E } from "../../../../../ui/src/lib/providers/FormEditingContext.js";
|
|
16
|
+
import i from "../../../../../ui/src/lib/error-boundaries/ComponentErrorBoundary.js";
|
|
17
|
+
import { ActionManager as x } from "../../trigger-action-system/components/ActionManager.js";
|
|
18
|
+
import { registerRenderComponent as L } from "../../../../../ui/src/component-registry/renderComponent.js";
|
|
19
|
+
import { ValidationEngine as w } from "../../validation-system/validation/ValidationEngine.js";
|
|
20
|
+
import { Heading as I } from "@rijkshuisstijl-community/components-react";
|
|
21
|
+
L(u);
|
|
22
|
+
const p = C(
|
|
25
23
|
({
|
|
26
24
|
config: e,
|
|
27
|
-
initialData:
|
|
28
|
-
onSubmit:
|
|
29
|
-
queryClient:
|
|
25
|
+
initialData: o = {},
|
|
26
|
+
onSubmit: l,
|
|
27
|
+
queryClient: c = g
|
|
30
28
|
}) => {
|
|
31
|
-
const
|
|
32
|
-
P(() => {
|
|
33
|
-
(async () => {
|
|
34
|
-
try {
|
|
35
|
-
if (f(null), x(e)) {
|
|
36
|
-
const o = await L(e);
|
|
37
|
-
d(o);
|
|
38
|
-
} else
|
|
39
|
-
d(e);
|
|
40
|
-
} catch (o) {
|
|
41
|
-
f(
|
|
42
|
-
o instanceof Error ? o.message : "Failed to resolve configuration"
|
|
43
|
-
), console.error("Error resolving form configuration:", o);
|
|
44
|
-
}
|
|
45
|
-
})();
|
|
46
|
-
}, [e]);
|
|
47
|
-
const p = g(() => new b({
|
|
29
|
+
const n = s(() => new w({
|
|
48
30
|
messageStyle: e.validationMessageStyle || "withLabel"
|
|
49
|
-
}), [e.validationMessageStyle]),
|
|
50
|
-
...
|
|
51
|
-
steps:
|
|
52
|
-
const
|
|
31
|
+
}), [e.validationMessageStyle]), f = s(() => ({
|
|
32
|
+
...e,
|
|
33
|
+
steps: e.steps.map((a) => {
|
|
34
|
+
const t = a;
|
|
53
35
|
return {
|
|
54
|
-
...
|
|
55
|
-
schema:
|
|
36
|
+
...t,
|
|
37
|
+
schema: t.schema || n.getStepSchema(t)
|
|
56
38
|
};
|
|
57
39
|
})
|
|
58
|
-
}
|
|
59
|
-
config:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
onSubmit: C
|
|
40
|
+
}), [e, n]), h = P({
|
|
41
|
+
config: f,
|
|
42
|
+
initialData: o,
|
|
43
|
+
onSubmit: l
|
|
63
44
|
});
|
|
64
|
-
return c
|
|
65
|
-
/* @__PURE__ */ r(
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/* @__PURE__ */ r(s.Title, { children: /* @__PURE__ */ r(D, { level: 1, children: e.title }) }),
|
|
71
|
-
/* @__PURE__ */ r(s.LeftColumn, { children: /* @__PURE__ */ r(l, { componentName: "StepProgressIndicator", children: /* @__PURE__ */ r(w, {}) }) }),
|
|
72
|
-
/* @__PURE__ */ r(l, { componentName: "FormStep", children: /* @__PURE__ */ r(W, {}) })
|
|
45
|
+
return /* @__PURE__ */ r(y, { client: c, children: /* @__PURE__ */ r(W, { formId: e.id, children: /* @__PURE__ */ r(E, { children: /* @__PURE__ */ d(N.Provider, { value: h, children: [
|
|
46
|
+
/* @__PURE__ */ r(i, { componentName: "ActionManager", children: /* @__PURE__ */ r(x, {}) }),
|
|
47
|
+
/* @__PURE__ */ d(m, { className: F.formLayout, children: [
|
|
48
|
+
/* @__PURE__ */ r(m.Title, { children: /* @__PURE__ */ r(I, { level: 1, children: e.title }) }),
|
|
49
|
+
/* @__PURE__ */ r(m.LeftColumn, { children: /* @__PURE__ */ r(i, { componentName: "StepProgressIndicator", children: /* @__PURE__ */ r(S, {}) }) }),
|
|
50
|
+
/* @__PURE__ */ r(i, { componentName: "FormStep", children: /* @__PURE__ */ r(v, {}) })
|
|
73
51
|
] })
|
|
74
|
-
] }) }) }) })
|
|
52
|
+
] }) }) }) });
|
|
75
53
|
}
|
|
76
54
|
);
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
return /* @__PURE__ */ r(
|
|
55
|
+
p.displayName = "FormWizardCore";
|
|
56
|
+
const T = (e) => {
|
|
57
|
+
const o = z();
|
|
58
|
+
return /* @__PURE__ */ r(M, { config: o, children: /* @__PURE__ */ r(p, { ...e }) });
|
|
81
59
|
};
|
|
82
|
-
|
|
60
|
+
T.displayName = "FormWizard";
|
|
83
61
|
export {
|
|
84
|
-
|
|
62
|
+
T as default
|
|
85
63
|
};
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const o = "fb-
|
|
3
|
-
|
|
4
|
-
errorHeading: t,
|
|
5
|
-
loadingState: e,
|
|
6
|
-
loadingPulse: r,
|
|
7
|
-
formLayout: a
|
|
2
|
+
const o = "fb-formLayout_JzC8E", t = {
|
|
3
|
+
formLayout: o
|
|
8
4
|
};
|
|
9
5
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
o as errorState,
|
|
13
|
-
a as formLayout,
|
|
14
|
-
r as loadingPulse,
|
|
15
|
-
e as loadingState
|
|
6
|
+
t as default,
|
|
7
|
+
o as formLayout
|
|
16
8
|
};
|
|
@@ -1,158 +1,151 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import
|
|
2
|
+
import { jsxs as f, jsx as r, Fragment as _ } from "react/jsx-runtime";
|
|
3
|
+
import g from "./FormStep.module.css.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { useForm as U } from "@tanstack/react-form";
|
|
5
|
+
import { logger as w } from "../../../../../../ui/src/lib/logger.js";
|
|
6
|
+
import { useForm as I } from "@tanstack/react-form";
|
|
8
7
|
import { useRef as p } from "react";
|
|
9
|
-
import { LoaderProvider as
|
|
10
|
-
import { FormProvider as
|
|
11
|
-
import { buildDefaultValues as
|
|
12
|
-
import { resetFormDirtyStateAfterApiPopulation as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { ProgressLoaderRuntime as
|
|
17
|
-
import { useFormMachine as
|
|
18
|
-
import { EnhancedActionExecutor as
|
|
19
|
-
import { ValidationEngine as
|
|
20
|
-
const
|
|
21
|
-
currentStep:
|
|
8
|
+
import { LoaderProvider as M, useLoaderContext as C } from "../../context/LoaderContext.js";
|
|
9
|
+
import { FormProvider as U } from "../../hooks/useFormContext.js";
|
|
10
|
+
import { buildDefaultValues as k } from "../../utils/formDataBuilder.js";
|
|
11
|
+
import { resetFormDirtyStateAfterApiPopulation as W } from "../../utils/formDirtyStateSync.js";
|
|
12
|
+
import j from "../FormFooter.js";
|
|
13
|
+
import z from "../FormHeader.js";
|
|
14
|
+
import G from "../FormSection/FormSection.js";
|
|
15
|
+
import { ProgressLoaderRuntime as H } from "../ProgressLoaderRuntime.js";
|
|
16
|
+
import { useFormMachine as K } from "../../../state-management/machines/useFormMachine.js";
|
|
17
|
+
import { EnhancedActionExecutor as Q } from "../../../api-integration/components/EnhancedActionExecutor/EnhancedActionExecutor.js";
|
|
18
|
+
import { ValidationEngine as X } from "../../../validation-system/validation/ValidationEngine.js";
|
|
19
|
+
const q = ({
|
|
20
|
+
currentStep: n,
|
|
22
21
|
hasStepLoader: s,
|
|
23
|
-
loaderConfig:
|
|
22
|
+
loaderConfig: t
|
|
24
23
|
}) => {
|
|
25
|
-
const { isLoadingComplete:
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
s && /* @__PURE__ */
|
|
28
|
-
|
|
24
|
+
const { isLoadingComplete: o } = C(), l = n.sections || [];
|
|
25
|
+
return /* @__PURE__ */ f("div", { className: g.stepContent, children: [
|
|
26
|
+
s && /* @__PURE__ */ r("div", { className: g.loaderWrapper, children: /* @__PURE__ */ r(
|
|
27
|
+
H,
|
|
29
28
|
{
|
|
30
29
|
properties: {
|
|
31
|
-
label:
|
|
32
|
-
showPercentage:
|
|
33
|
-
duration:
|
|
34
|
-
size:
|
|
35
|
-
variant:
|
|
36
|
-
animationSpeed:
|
|
30
|
+
label: t?.label,
|
|
31
|
+
showPercentage: t?.showPercentage ?? !0,
|
|
32
|
+
duration: t?.duration ?? 3,
|
|
33
|
+
size: t?.size ?? "md",
|
|
34
|
+
variant: t?.variant ?? "default",
|
|
35
|
+
animationSpeed: t?.animationSpeed ?? "normal",
|
|
37
36
|
autoStart: !0,
|
|
38
37
|
hideOnComplete: !0,
|
|
39
|
-
onComplete:
|
|
38
|
+
onComplete: t?.completionMessage ? {
|
|
40
39
|
showMessage: {
|
|
41
40
|
enabled: !0,
|
|
42
|
-
text:
|
|
41
|
+
text: t.completionMessage,
|
|
43
42
|
type: "success"
|
|
44
43
|
}
|
|
45
44
|
} : void 0
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
) }),
|
|
49
|
-
(!s ||
|
|
48
|
+
(!s || o) && /* @__PURE__ */ r(_, { children: l.map((c) => /* @__PURE__ */ r(G, { section: c }, c.id)) })
|
|
50
49
|
] });
|
|
51
|
-
},
|
|
52
|
-
const [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}) : v(e), ...o.data }, y = (t) => {
|
|
61
|
-
(e.actions || []).length > 0 && s({ type: "EXECUTE_ACTIONS", trigger: t });
|
|
62
|
-
}, x = p(), f = p(!1);
|
|
63
|
-
e.id !== x.current && (e.actions || []).length > 0 && !f.current && (x.current = e.id, f.current = !0, setTimeout(() => {
|
|
64
|
-
y("onStepLoad"), setTimeout(() => {
|
|
65
|
-
f.current = !1;
|
|
50
|
+
}, B = () => {
|
|
51
|
+
const [n, s, t] = K(), { currentStep: o, config: l } = t, c = p(), h = p(), S = p(), A = l.validationMessageStyle || "withLabel";
|
|
52
|
+
c.current || (c.current = new X({ messageStyle: A })), (!h.current || S.current !== o.id) && (h.current = c.current.getStepSchema(o), S.current = o.id);
|
|
53
|
+
const E = { ...k(o), ...t.data }, v = (e) => {
|
|
54
|
+
(o.actions || []).length > 0 && s({ type: "EXECUTE_ACTIONS", trigger: e });
|
|
55
|
+
}, F = p(), u = p(!1);
|
|
56
|
+
o.id !== F.current && (o.actions || []).length > 0 && !u.current && (F.current = o.id, u.current = !0, setTimeout(() => {
|
|
57
|
+
v("onStepLoad"), setTimeout(() => {
|
|
58
|
+
u.current = !1;
|
|
66
59
|
}, 1e3);
|
|
67
60
|
}, 0));
|
|
68
|
-
const
|
|
69
|
-
value:
|
|
61
|
+
const b = async ({
|
|
62
|
+
value: e
|
|
70
63
|
}) => {
|
|
71
|
-
(
|
|
72
|
-
(
|
|
73
|
-
) ? s({ type: "REQUEST_NAVIGATION", navigationType: "next" }) :
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
s({ type: "SHOW_ACTION_DIALOG", dialogConfig:
|
|
79
|
-
},
|
|
80
|
-
switch (
|
|
64
|
+
(o.actions || []).some(
|
|
65
|
+
(d) => d.trigger === "onStepFinish"
|
|
66
|
+
) ? s({ type: "REQUEST_NAVIGATION", navigationType: "next" }) : t.nextStep();
|
|
67
|
+
}, y = (e) => {
|
|
68
|
+
}, T = (e) => {
|
|
69
|
+
w.error("Action execution failed", { error: e.message }, e);
|
|
70
|
+
}, L = (e) => {
|
|
71
|
+
s({ type: "SHOW_ACTION_DIALOG", dialogConfig: e });
|
|
72
|
+
}, N = (e) => {
|
|
73
|
+
switch (e.type) {
|
|
81
74
|
case "next":
|
|
82
|
-
|
|
75
|
+
t.nextStep();
|
|
83
76
|
break;
|
|
84
77
|
case "previous":
|
|
85
|
-
|
|
78
|
+
t.previousStep();
|
|
86
79
|
break;
|
|
87
80
|
case "step":
|
|
88
|
-
|
|
81
|
+
e.targetStep && t.goToStep(e.targetStep);
|
|
89
82
|
break;
|
|
90
83
|
}
|
|
91
|
-
}, m =
|
|
92
|
-
defaultValues:
|
|
93
|
-
onSubmit:
|
|
94
|
-
}),
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
98
|
-
|
|
84
|
+
}, m = I({
|
|
85
|
+
defaultValues: E,
|
|
86
|
+
onSubmit: b
|
|
87
|
+
}), D = (e, i) => {
|
|
88
|
+
const a = e, d = m.getFieldValue(a), V = n.context.componentOriginalValues[a]?.value;
|
|
89
|
+
if (d !== i) {
|
|
90
|
+
const P = i;
|
|
91
|
+
t.setData(a, P), m.setFieldValue(a, i);
|
|
99
92
|
try {
|
|
100
|
-
|
|
101
|
-
updatedFields: [
|
|
93
|
+
W(m, {
|
|
94
|
+
updatedFields: [a],
|
|
102
95
|
debug: process.env.NODE_ENV === "development"
|
|
103
96
|
});
|
|
104
|
-
} catch (
|
|
105
|
-
console.error("❌ Failed to reset dirty state:",
|
|
97
|
+
} catch (R) {
|
|
98
|
+
console.error("❌ Failed to reset dirty state:", R);
|
|
106
99
|
}
|
|
107
100
|
}
|
|
108
|
-
|
|
101
|
+
V !== i && setTimeout(() => {
|
|
109
102
|
s({
|
|
110
103
|
type: "MARK_COMPONENT_AS_POPULATED",
|
|
111
|
-
componentId:
|
|
112
|
-
value:
|
|
104
|
+
componentId: a,
|
|
105
|
+
value: i
|
|
113
106
|
});
|
|
114
107
|
}, 0);
|
|
115
|
-
},
|
|
116
|
-
return /* @__PURE__ */
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
}, x = o.waitForLoader === !0, O = x ? o.loaderConfig : void 0;
|
|
109
|
+
return /* @__PURE__ */ f(U, { value: m, children: [
|
|
110
|
+
n.matches("executingActions") && (n.context.executingTrigger === "onStepLoad" || n.context.executingTrigger === "onStepFinish") && /* @__PURE__ */ r(
|
|
111
|
+
Q,
|
|
119
112
|
{
|
|
120
|
-
actions:
|
|
121
|
-
trigger:
|
|
122
|
-
formData:
|
|
123
|
-
onComplete:
|
|
124
|
-
onError:
|
|
125
|
-
onFieldUpdate:
|
|
126
|
-
onShowDialog:
|
|
127
|
-
onNavigate:
|
|
113
|
+
actions: o.actions || [],
|
|
114
|
+
trigger: n.context.executingTrigger || "onStepLoad",
|
|
115
|
+
formData: n.context.data,
|
|
116
|
+
onComplete: y,
|
|
117
|
+
onError: T,
|
|
118
|
+
onFieldUpdate: D,
|
|
119
|
+
onShowDialog: L,
|
|
120
|
+
onNavigate: N,
|
|
128
121
|
machineRef: {
|
|
129
122
|
send: s
|
|
130
123
|
}
|
|
131
124
|
}
|
|
132
125
|
),
|
|
133
|
-
/* @__PURE__ */
|
|
126
|
+
/* @__PURE__ */ f(
|
|
134
127
|
"form",
|
|
135
128
|
{
|
|
136
|
-
onSubmit: (
|
|
137
|
-
|
|
129
|
+
onSubmit: (e) => {
|
|
130
|
+
e.preventDefault(), e.stopPropagation(), m.handleSubmit();
|
|
138
131
|
},
|
|
139
132
|
children: [
|
|
140
|
-
/* @__PURE__ */
|
|
141
|
-
/* @__PURE__ */
|
|
142
|
-
|
|
133
|
+
/* @__PURE__ */ r(z, {}),
|
|
134
|
+
/* @__PURE__ */ r(M, { children: /* @__PURE__ */ r(
|
|
135
|
+
q,
|
|
143
136
|
{
|
|
144
|
-
currentStep:
|
|
145
|
-
hasStepLoader:
|
|
146
|
-
loaderConfig:
|
|
137
|
+
currentStep: o,
|
|
138
|
+
hasStepLoader: x,
|
|
139
|
+
loaderConfig: O
|
|
147
140
|
}
|
|
148
141
|
) }),
|
|
149
|
-
/* @__PURE__ */
|
|
142
|
+
/* @__PURE__ */ r(j, { className: g.footer })
|
|
150
143
|
]
|
|
151
144
|
}
|
|
152
145
|
)
|
|
153
146
|
] });
|
|
154
147
|
};
|
|
155
|
-
|
|
148
|
+
B.displayName = "FormStep";
|
|
156
149
|
export {
|
|
157
|
-
|
|
150
|
+
B as default
|
|
158
151
|
};
|
|
@@ -31,7 +31,7 @@ const vt = ({
|
|
|
31
31
|
), D = g(() => i.steps, [i.steps]), L = E === 0, P = E === i.steps.length - 1, T = o(
|
|
32
32
|
(t) => {
|
|
33
33
|
for (const e of i.steps) {
|
|
34
|
-
const r =
|
|
34
|
+
const r = e.sections || [];
|
|
35
35
|
for (const l of r || []) {
|
|
36
36
|
const a = l.components?.find(
|
|
37
37
|
(c) => c.id === t
|
|
@@ -85,7 +85,7 @@ const vt = ({
|
|
|
85
85
|
(t) => {
|
|
86
86
|
let e = !0;
|
|
87
87
|
for (const r of i.steps) {
|
|
88
|
-
const a = (
|
|
88
|
+
const a = (r.sections || []).find(
|
|
89
89
|
(c) => c.id === t
|
|
90
90
|
);
|
|
91
91
|
if (a) {
|
|
@@ -100,7 +100,7 @@ const vt = ({
|
|
|
100
100
|
), W = o(
|
|
101
101
|
async (t) => {
|
|
102
102
|
const e = i.steps.find((a) => a.id === t);
|
|
103
|
-
if (!e
|
|
103
|
+
if (!e) return !0;
|
|
104
104
|
const r = await d.validateStep(e, u);
|
|
105
105
|
for (const [a, c] of Object.entries(
|
|
106
106
|
r.fieldErrors
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import { isTemplateStep as c } from "../../../../../ui/src/lib/types/guards.js";
|
|
4
|
-
class u {
|
|
2
|
+
class d {
|
|
5
3
|
schemaBuilder;
|
|
6
4
|
constructor(s) {
|
|
7
5
|
this.schemaBuilder = s;
|
|
@@ -9,19 +7,19 @@ class u {
|
|
|
9
7
|
/**
|
|
10
8
|
* Validates a single field
|
|
11
9
|
*/
|
|
12
|
-
async validateField(s,
|
|
10
|
+
async validateField(s, o) {
|
|
13
11
|
try {
|
|
14
|
-
const
|
|
12
|
+
const r = await o.parseAsync(s);
|
|
15
13
|
return {
|
|
16
14
|
isValid: !0,
|
|
17
15
|
errors: [],
|
|
18
|
-
value:
|
|
16
|
+
value: r
|
|
19
17
|
};
|
|
20
|
-
} catch (
|
|
21
|
-
let
|
|
22
|
-
return
|
|
18
|
+
} catch (r) {
|
|
19
|
+
let e = [];
|
|
20
|
+
return r && typeof r == "object" && "errors" in r ? e = r.errors.map((i) => i.message) : e = ["Validation failed"], {
|
|
23
21
|
isValid: !1,
|
|
24
|
-
errors:
|
|
22
|
+
errors: e,
|
|
25
23
|
value: s
|
|
26
24
|
};
|
|
27
25
|
}
|
|
@@ -29,51 +27,51 @@ class u {
|
|
|
29
27
|
/**
|
|
30
28
|
* Validates a single field synchronously
|
|
31
29
|
*/
|
|
32
|
-
validateFieldSync(s,
|
|
33
|
-
let
|
|
34
|
-
s == null && (
|
|
30
|
+
validateFieldSync(s, o) {
|
|
31
|
+
let r = s;
|
|
32
|
+
s == null && (r = "");
|
|
35
33
|
try {
|
|
36
|
-
const
|
|
34
|
+
const e = o.parse(r);
|
|
37
35
|
return {
|
|
38
36
|
isValid: !0,
|
|
39
37
|
errors: [],
|
|
40
|
-
value:
|
|
38
|
+
value: e
|
|
41
39
|
};
|
|
42
|
-
} catch (
|
|
40
|
+
} catch (e) {
|
|
43
41
|
let t = [];
|
|
44
|
-
return
|
|
42
|
+
return e && typeof e == "object" && "errors" in e ? t = e.errors.map((a) => a.message) : t = ["Validation failed"], {
|
|
45
43
|
isValid: !1,
|
|
46
44
|
errors: t,
|
|
47
|
-
value:
|
|
45
|
+
value: r
|
|
48
46
|
};
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
/**
|
|
52
50
|
* Validates a step
|
|
53
51
|
*/
|
|
54
|
-
async validateStep(s,
|
|
52
|
+
async validateStep(s, o) {
|
|
55
53
|
try {
|
|
56
|
-
return await
|
|
54
|
+
return await o.parseAsync(s), {
|
|
57
55
|
isValid: !0,
|
|
58
56
|
fieldErrors: {},
|
|
59
57
|
generalErrors: []
|
|
60
58
|
};
|
|
61
|
-
} catch (
|
|
62
|
-
const
|
|
59
|
+
} catch (r) {
|
|
60
|
+
const e = {};
|
|
63
61
|
let t = [];
|
|
64
|
-
if (
|
|
65
|
-
const
|
|
66
|
-
for (const
|
|
67
|
-
if (
|
|
68
|
-
const l =
|
|
69
|
-
|
|
62
|
+
if (r && typeof r == "object" && "errors" in r) {
|
|
63
|
+
const i = r;
|
|
64
|
+
for (const a of i.errors)
|
|
65
|
+
if (a.path.length > 0) {
|
|
66
|
+
const l = a.path[0].toString();
|
|
67
|
+
e[l] || (e[l] = []), e[l].push(a.message);
|
|
70
68
|
} else
|
|
71
|
-
t.push(
|
|
69
|
+
t.push(a.message);
|
|
72
70
|
} else
|
|
73
71
|
t = ["Step validation failed"];
|
|
74
72
|
return {
|
|
75
73
|
isValid: !1,
|
|
76
|
-
fieldErrors:
|
|
74
|
+
fieldErrors: e,
|
|
77
75
|
generalErrors: t
|
|
78
76
|
};
|
|
79
77
|
}
|
|
@@ -81,26 +79,20 @@ class u {
|
|
|
81
79
|
/**
|
|
82
80
|
* Validates a form
|
|
83
81
|
*/
|
|
84
|
-
async validateForm(s,
|
|
85
|
-
const
|
|
82
|
+
async validateForm(s, o) {
|
|
83
|
+
const r = {}, e = [];
|
|
86
84
|
let t = !0;
|
|
87
|
-
for (const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
`Template step '${a.id}' needs to be resolved before validation`
|
|
91
|
-
), t = !1;
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
const o = a, l = this.schemaBuilder.createStepSchema(o), n = await this.validateStep(i, l);
|
|
95
|
-
n.isValid || (t = !1, Object.assign(e, n.fieldErrors), r.push(...n.generalErrors));
|
|
85
|
+
for (const i of s.steps) {
|
|
86
|
+
const a = i, l = this.schemaBuilder.createStepSchema(a), n = await this.validateStep(o, l);
|
|
87
|
+
n.isValid || (t = !1, Object.assign(r, n.fieldErrors), e.push(...n.generalErrors));
|
|
96
88
|
}
|
|
97
89
|
return {
|
|
98
90
|
isValid: t,
|
|
99
|
-
fieldErrors:
|
|
100
|
-
generalErrors:
|
|
91
|
+
fieldErrors: r,
|
|
92
|
+
generalErrors: e
|
|
101
93
|
};
|
|
102
94
|
}
|
|
103
95
|
}
|
|
104
96
|
export {
|
|
105
|
-
|
|
97
|
+
d as ValidationExecutor
|
|
106
98
|
};
|
package/core/src/types/guards.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FormWizardConfig } from '../../../../../core/src/index.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Resolves a form wizard configuration, expanding any template step references
|
|
4
|
-
* to their full step configurations
|
|
5
|
-
*/
|
|
6
|
-
export declare function resolveFormWizardConfig(config: FormWizardConfig): Promise<FormWizardConfig>;
|
|
7
|
-
/**
|
|
8
|
-
* Checks if a configuration contains template step references
|
|
9
|
-
*/
|
|
10
|
-
export declare function hasTemplateSteps(config: FormWizardConfig): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Gets template IDs used in a configuration
|
|
13
|
-
*/
|
|
14
|
-
export declare function getUsedTemplateIds(config: FormWizardConfig): string[];
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Form Runtime Configuration
|
|
3
|
-
*
|
|
4
|
-
* Configuration resolvers and template utilities
|
|
5
|
-
*/
|
|
6
|
-
export * from './configResolver';
|
|
7
|
-
export * from './templateConfig';
|
|
8
|
-
export * from './templateLoader';
|
|
9
|
-
export { getAvailableGenericTemplatesSync, getTemplateInfo, validateTemplateReferences, } from './templateUtils';
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { FormStepConfig, TemplateStepConfig } from '../../../../../core/src/index.ts';
|
|
2
|
-
export type TemplateType = "generic" | "team" | null;
|
|
3
|
-
/**
|
|
4
|
-
* Template permissions configuration
|
|
5
|
-
*/
|
|
6
|
-
export interface TemplatePermissions {
|
|
7
|
-
/** Can add new components to sections */
|
|
8
|
-
canAddComponents: boolean;
|
|
9
|
-
/** Can remove existing components */
|
|
10
|
-
canRemoveComponents: boolean;
|
|
11
|
-
/** Can edit component properties */
|
|
12
|
-
canEditComponentProperties: boolean;
|
|
13
|
-
/** Can add new sections */
|
|
14
|
-
canAddSections: boolean;
|
|
15
|
-
/** Can remove existing sections */
|
|
16
|
-
canRemoveSections: boolean;
|
|
17
|
-
/** Can edit section properties */
|
|
18
|
-
canEditSectionProperties: boolean;
|
|
19
|
-
/** Can edit step title */
|
|
20
|
-
canEditStepTitle: boolean;
|
|
21
|
-
/** Can edit navigation settings */
|
|
22
|
-
canEditNavigation: boolean;
|
|
23
|
-
/** Can add/edit actions */
|
|
24
|
-
canEditActions: boolean;
|
|
25
|
-
/** Can duplicate the step */
|
|
26
|
-
canDuplicate: boolean;
|
|
27
|
-
/** Can delete the step */
|
|
28
|
-
canDelete: boolean;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Template display configuration
|
|
32
|
-
*/
|
|
33
|
-
export interface TemplateDisplayConfig {
|
|
34
|
-
/** Template type for UI display */
|
|
35
|
-
type: TemplateType;
|
|
36
|
-
/** Whether template is readonly */
|
|
37
|
-
isReadonly: boolean;
|
|
38
|
-
/** Whether to show lock icon */
|
|
39
|
-
showLockIcon: boolean;
|
|
40
|
-
/** CSS classes for theme styling */
|
|
41
|
-
themeClass: string;
|
|
42
|
-
/** Icon color classes */
|
|
43
|
-
iconColor: string;
|
|
44
|
-
/** Tooltip text for locked templates */
|
|
45
|
-
lockTooltip?: string;
|
|
46
|
-
/** Badge text for template type */
|
|
47
|
-
badgeText?: string;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Complete template configuration
|
|
51
|
-
*/
|
|
52
|
-
export interface TemplateConfig {
|
|
53
|
-
permissions: TemplatePermissions;
|
|
54
|
-
display: TemplateDisplayConfig;
|
|
55
|
-
rules: {
|
|
56
|
-
/** Message shown when user tries to edit locked content */
|
|
57
|
-
lockMessage: string;
|
|
58
|
-
/** Whether this template type supports multiple steps */
|
|
59
|
-
supportsMultipleSteps: boolean;
|
|
60
|
-
/** Default navigation behavior */
|
|
61
|
-
defaultNavigation: {
|
|
62
|
-
next: {
|
|
63
|
-
label: string;
|
|
64
|
-
enabled: boolean;
|
|
65
|
-
};
|
|
66
|
-
previous: {
|
|
67
|
-
label: string;
|
|
68
|
-
enabled: boolean;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Gets the complete template configuration for a given template ID or step
|
|
75
|
-
*/
|
|
76
|
-
export declare function getTemplateConfig(templateIdOrStep: string | FormStepConfig | TemplateStepConfig): TemplateConfig;
|
|
77
|
-
/**
|
|
78
|
-
* Gets template permissions for a given template ID or step
|
|
79
|
-
*/
|
|
80
|
-
export declare function getTemplatePermissions(templateIdOrStep: string | FormStepConfig | TemplateStepConfig): TemplatePermissions;
|
|
81
|
-
/**
|
|
82
|
-
* Gets template display configuration for a given template ID or step
|
|
83
|
-
*/
|
|
84
|
-
export declare function getTemplateDisplayConfig(templateIdOrStep: string | FormStepConfig | TemplateStepConfig): TemplateDisplayConfig;
|
|
85
|
-
/**
|
|
86
|
-
* Checks if a specific action is allowed for a template or step
|
|
87
|
-
*/
|
|
88
|
-
export declare function isActionAllowed(templateIdOrStep: string | FormStepConfig | TemplateStepConfig, action: keyof TemplatePermissions): boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Checks if a step is locked for editing
|
|
91
|
-
*/
|
|
92
|
-
export declare function isStepLocked(step: FormStepConfig | TemplateStepConfig, templateOrigin?: {
|
|
93
|
-
templateId: string;
|
|
94
|
-
stepIndex?: number;
|
|
95
|
-
}): boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Gets the lock message for a template
|
|
98
|
-
*/
|
|
99
|
-
export declare function getLockMessage(templateIdOrStep: string | FormStepConfig | TemplateStepConfig): string;
|
|
100
|
-
/**
|
|
101
|
-
* Validates if a template action should be blocked and returns appropriate message
|
|
102
|
-
*/
|
|
103
|
-
export declare function validateTemplateAction(templateIdOrStep: string | FormStepConfig | TemplateStepConfig, action: keyof TemplatePermissions): {
|
|
104
|
-
allowed: boolean;
|
|
105
|
-
message?: string;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Gets template type from various input formats
|
|
109
|
-
*/
|
|
110
|
-
export declare function getTemplateTypeFromInput(input: string | FormStepConfig | TemplateStepConfig): TemplateType;
|
|
111
|
-
/**
|
|
112
|
-
* Utility to check if input represents a generic template
|
|
113
|
-
*/
|
|
114
|
-
export declare function isGenericTemplateInput(input: string | FormStepConfig | TemplateStepConfig): boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Utility to check if input represents a team template
|
|
117
|
-
*/
|
|
118
|
-
export declare function isTeamTemplateInput(input: string | FormStepConfig | TemplateStepConfig): boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Creates a comprehensive template info object for UI components
|
|
121
|
-
*/
|
|
122
|
-
export declare function getTemplateInfo(templateIdOrStep: string | FormStepConfig | TemplateStepConfig): {
|
|
123
|
-
type: TemplateType;
|
|
124
|
-
permissions: TemplatePermissions;
|
|
125
|
-
display: TemplateDisplayConfig;
|
|
126
|
-
rules: {
|
|
127
|
-
/** Message shown when user tries to edit locked content */
|
|
128
|
-
lockMessage: string;
|
|
129
|
-
/** Whether this template type supports multiple steps */
|
|
130
|
-
supportsMultipleSteps: boolean;
|
|
131
|
-
/** Default navigation behavior */
|
|
132
|
-
defaultNavigation: {
|
|
133
|
-
next: {
|
|
134
|
-
label: string;
|
|
135
|
-
enabled: boolean;
|
|
136
|
-
};
|
|
137
|
-
previous: {
|
|
138
|
-
label: string;
|
|
139
|
-
enabled: boolean;
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
isLocked: boolean;
|
|
144
|
-
canEdit: boolean;
|
|
145
|
-
isGeneric: boolean;
|
|
146
|
-
isTeam: boolean;
|
|
147
|
-
isRegularStep: boolean;
|
|
148
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { FormStepConfig, FormTemplate, StepNavigation, TemplateStepConfig } from '../../../../../core/src/index.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Loads a template by ID, handling both generic and team templates
|
|
4
|
-
*/
|
|
5
|
-
export declare function loadTemplate(templateId: string): Promise<FormTemplate>;
|
|
6
|
-
/**
|
|
7
|
-
* Resolves a template step reference to a full FormStepConfig
|
|
8
|
-
*/
|
|
9
|
-
export declare function resolveTemplateStep(templateStep: TemplateStepConfig, defaultNavigation?: StepNavigation, stepIndex?: number): Promise<FormStepConfig>;
|
|
10
|
-
/**
|
|
11
|
-
* Gets template metadata without loading the full template
|
|
12
|
-
*/
|
|
13
|
-
export declare function getTemplateMetadata(templateId: string): Promise<import('../../../../../core/src/index.ts').TemplateMetadata>;
|
|
14
|
-
/**
|
|
15
|
-
* Lists available templates from both generic and team sources
|
|
16
|
-
*/
|
|
17
|
-
export declare function getAvailableTemplates(): Promise<string[]>;
|
|
18
|
-
/**
|
|
19
|
-
* Lists available generic templates only (for backward compatibility)
|
|
20
|
-
*/
|
|
21
|
-
export declare function getAvailableGenericTemplates(): string[];
|
|
22
|
-
/**
|
|
23
|
-
* Clears the template cache (useful for development/testing)
|
|
24
|
-
*/
|
|
25
|
-
export declare function clearTemplateCache(): void;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loader-specific template functions for form-wizard-component
|
|
3
|
-
*
|
|
4
|
-
* This file only contains functions that depend on the local templateLoader.
|
|
5
|
-
* All other template utilities should be imported directly from @libs/shared/utils
|
|
6
|
-
*/
|
|
7
|
-
export declare const getAvailableGenericTemplatesSync: () => string[];
|
|
8
|
-
export declare const getTemplateInfo: (templateId: string) => Promise<any>;
|
|
9
|
-
export declare const validateTemplateReferences: (config: import('../../../../../core/src/index.ts').FormWizardConfig) => Promise<{
|
|
10
|
-
isValid: boolean;
|
|
11
|
-
errors: string[];
|
|
12
|
-
}>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
const t = {
|
|
3
|
-
GENERIC: "generic-",
|
|
4
|
-
TEAM: "team-"
|
|
5
|
-
};
|
|
6
|
-
function n(e) {
|
|
7
|
-
return e.startsWith(t.GENERIC) ? "generic" : e.startsWith(t.TEAM) ? "team" : null;
|
|
8
|
-
}
|
|
9
|
-
function r(e) {
|
|
10
|
-
return n(e) === "generic";
|
|
11
|
-
}
|
|
12
|
-
function i(e) {
|
|
13
|
-
return n(e) === "team";
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
t as TEMPLATE_PREFIXES,
|
|
17
|
-
n as getTemplateTypeFromId,
|
|
18
|
-
r as isGenericTemplate,
|
|
19
|
-
i as isTeamTemplate
|
|
20
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { resolveTemplateStep as i } from "./templateLoader.js";
|
|
3
|
-
import { isTemplateStep as n } from "../../../../../core/src/types/guards.js";
|
|
4
|
-
async function m(e) {
|
|
5
|
-
const s = {
|
|
6
|
-
next: { label: "Next", enabled: !0 },
|
|
7
|
-
previous: { label: "Previous", enabled: !0 }
|
|
8
|
-
}, l = await Promise.all(
|
|
9
|
-
e.steps.map(async (t, r) => {
|
|
10
|
-
if (n(t)) {
|
|
11
|
-
const a = { ...s };
|
|
12
|
-
r === 0 && (a.previous.enabled = !1), r === e.steps.length - 1 && (a.next.label = "Submit");
|
|
13
|
-
const o = t.stepIndex;
|
|
14
|
-
return await i(
|
|
15
|
-
t,
|
|
16
|
-
a,
|
|
17
|
-
o
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
})
|
|
22
|
-
);
|
|
23
|
-
return {
|
|
24
|
-
...e,
|
|
25
|
-
steps: l
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function f(e) {
|
|
29
|
-
return e.steps.some((s) => n(s));
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
f as hasTemplateSteps,
|
|
33
|
-
m as resolveFormWizardConfig
|
|
34
|
-
};
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
/* empty css */
|
|
3
|
-
import { isGenericTemplate as v, isTeamTemplate as h } from "../../../../../ui/src/lib/utils/templateUtils.js";
|
|
4
|
-
async function g() {
|
|
5
|
-
try {
|
|
6
|
-
const { templateStorageService: e } = await import("@formbuilder/builder");
|
|
7
|
-
return e;
|
|
8
|
-
} catch (e) {
|
|
9
|
-
return console.warn("Template storage service not available:", e), null;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
async function y() {
|
|
13
|
-
try {
|
|
14
|
-
const e = await g();
|
|
15
|
-
if (!e) return;
|
|
16
|
-
if (!e.isReady()) {
|
|
17
|
-
const a = await fetch("/form.config.json");
|
|
18
|
-
if (a.ok) {
|
|
19
|
-
const r = (await a.json()).storage?.paths?.templates;
|
|
20
|
-
r && await e.initialize(r);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
} catch (e) {
|
|
24
|
-
console.warn("Failed to initialize template storage service:", e);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function d(e) {
|
|
28
|
-
return {
|
|
29
|
-
metadata: e.metadata,
|
|
30
|
-
stepsData: e.stepsData || [],
|
|
31
|
-
// Default to empty array if no steps
|
|
32
|
-
preview: {
|
|
33
|
-
componentCount: e.preview?.componentCount || 0,
|
|
34
|
-
sectionCount: e.preview?.sectionCount || 0
|
|
35
|
-
},
|
|
36
|
-
governance: e.governance || {
|
|
37
|
-
approved: !1,
|
|
38
|
-
complianceTags: [],
|
|
39
|
-
deprecated: !1
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
const f = /* @__PURE__ */ new Map(), l = {
|
|
44
|
-
"generic-contact-information": async () => {
|
|
45
|
-
const e = await fetch(
|
|
46
|
-
"/src/packages/form-wizard/admin/templates/generic/contact-information.json"
|
|
47
|
-
);
|
|
48
|
-
if (!e.ok)
|
|
49
|
-
throw new Error(
|
|
50
|
-
`Failed to fetch generic-contact-information template: ${e.status}`
|
|
51
|
-
);
|
|
52
|
-
return e.json();
|
|
53
|
-
},
|
|
54
|
-
"generic-consent-agreement": async () => {
|
|
55
|
-
const e = await fetch(
|
|
56
|
-
"/src/packages/form-wizard/admin/templates/generic/consent-agreement.json"
|
|
57
|
-
);
|
|
58
|
-
if (!e.ok)
|
|
59
|
-
throw new Error(
|
|
60
|
-
`Failed to fetch generic-consent-agreement template: ${e.status}`
|
|
61
|
-
);
|
|
62
|
-
return e.json();
|
|
63
|
-
},
|
|
64
|
-
"generic-feedback-form": async () => {
|
|
65
|
-
const e = await fetch(
|
|
66
|
-
"/src/packages/form-wizard/admin/templates/generic/feedback-form.json"
|
|
67
|
-
);
|
|
68
|
-
if (!e.ok)
|
|
69
|
-
throw new Error(
|
|
70
|
-
`Failed to fetch generic-feedback-form template: ${e.status}`
|
|
71
|
-
);
|
|
72
|
-
return e.json();
|
|
73
|
-
},
|
|
74
|
-
"generic-incident-registration": async () => {
|
|
75
|
-
const e = await fetch(
|
|
76
|
-
"/src/packages/form-wizard/admin/templates/generic/incident-registration.json"
|
|
77
|
-
);
|
|
78
|
-
if (!e.ok)
|
|
79
|
-
throw new Error(
|
|
80
|
-
`Failed to fetch generic-incident-registration template: ${e.status}`
|
|
81
|
-
);
|
|
82
|
-
return e.json();
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
async function b(e) {
|
|
86
|
-
if (f.has(e))
|
|
87
|
-
return f.get(e);
|
|
88
|
-
try {
|
|
89
|
-
let a;
|
|
90
|
-
if (v(e)) {
|
|
91
|
-
const i = l[e];
|
|
92
|
-
if (!i) {
|
|
93
|
-
const s = Object.keys(l);
|
|
94
|
-
throw new Error(
|
|
95
|
-
`Generic template '${e}' not found. Available generic templates: ${s.join(", ")}`
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
const r = await i();
|
|
99
|
-
a = d(
|
|
100
|
-
r
|
|
101
|
-
);
|
|
102
|
-
} else if (h(e)) {
|
|
103
|
-
await y();
|
|
104
|
-
const i = await g();
|
|
105
|
-
if (!i)
|
|
106
|
-
throw new Error(
|
|
107
|
-
`Team template '${e}' could not be loaded: template storage service is not available`
|
|
108
|
-
);
|
|
109
|
-
const r = await i.loadTemplate(
|
|
110
|
-
e,
|
|
111
|
-
"team"
|
|
112
|
-
);
|
|
113
|
-
if (!r.success)
|
|
114
|
-
throw new Error(
|
|
115
|
-
`Team template '${e}' not found: ${"error" in r && r.error?.message || "Unknown error"}`
|
|
116
|
-
);
|
|
117
|
-
a = d(r.data);
|
|
118
|
-
} else {
|
|
119
|
-
const i = l[e];
|
|
120
|
-
if (i) {
|
|
121
|
-
const r = await i();
|
|
122
|
-
a = d(
|
|
123
|
-
r
|
|
124
|
-
);
|
|
125
|
-
} else {
|
|
126
|
-
const r = Object.keys(l);
|
|
127
|
-
throw new Error(
|
|
128
|
-
`Template '${e}' not found. Available generic templates: ${r.join(", ")}`
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (!a.metadata || !Array.isArray(a.stepsData))
|
|
133
|
-
throw new Error(
|
|
134
|
-
`Invalid template structure for template: ${e}. Templates must have metadata and stepsData array.`
|
|
135
|
-
);
|
|
136
|
-
return f.set(e, a), a;
|
|
137
|
-
} catch (a) {
|
|
138
|
-
throw new Error(
|
|
139
|
-
`Failed to load template '${e}': ${a instanceof Error ? a.message : "Unknown error"}`
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
async function E(e, a, i) {
|
|
144
|
-
const r = await b(e.templateId);
|
|
145
|
-
let s;
|
|
146
|
-
if (r.stepsData && Array.isArray(r.stepsData) && r.stepsData.length > 0)
|
|
147
|
-
i !== void 0 && i >= 0 && i < r.stepsData.length ? s = r.stepsData[i] : (s = r.stepsData[0], console.warn(
|
|
148
|
-
`Invalid stepIndex ${i} for template, using first step`
|
|
149
|
-
));
|
|
150
|
-
else
|
|
151
|
-
throw new Error(`Template ${e.templateId} has no steps data`);
|
|
152
|
-
const u = s.sections?.map((w) => ({
|
|
153
|
-
...w,
|
|
154
|
-
components: w.components.map((t) => {
|
|
155
|
-
const m = ((c) => `comp-${e.id}-${t.id || c}`)(t.id), o = {
|
|
156
|
-
id: m,
|
|
157
|
-
type: t.type,
|
|
158
|
-
properties: {
|
|
159
|
-
// Use properties from component.properties if it exists, otherwise fallback to root level
|
|
160
|
-
label: t.properties?.label || t.label || "",
|
|
161
|
-
placeholder: t.properties?.placeholder || t.placeholder || "",
|
|
162
|
-
description: t.properties?.description || t.description || "",
|
|
163
|
-
required: t.properties?.required || t.required || !1,
|
|
164
|
-
disabled: t.properties?.disabled || t.disabled || !1,
|
|
165
|
-
readOnly: t.properties?.readOnly || t.readOnly || !1,
|
|
166
|
-
invalid: t.properties?.invalid || !1,
|
|
167
|
-
// Add type-specific properties
|
|
168
|
-
type: t.properties?.type || t.type,
|
|
169
|
-
// Copy all other properties from component.properties if it exists
|
|
170
|
-
...t.properties && Object.keys(t.properties).reduce(
|
|
171
|
-
(c, p) => ([
|
|
172
|
-
"label",
|
|
173
|
-
"placeholder",
|
|
174
|
-
"description",
|
|
175
|
-
"required",
|
|
176
|
-
"disabled",
|
|
177
|
-
"readOnly",
|
|
178
|
-
"invalid",
|
|
179
|
-
"type"
|
|
180
|
-
].includes(p) || (c[p] = t.properties[p]), c),
|
|
181
|
-
{}
|
|
182
|
-
)
|
|
183
|
-
},
|
|
184
|
-
// Copy validation if it exists
|
|
185
|
-
...t.validation && { validation: t.validation }
|
|
186
|
-
}, n = e.componentOverrides?.[m];
|
|
187
|
-
return n ? {
|
|
188
|
-
...o,
|
|
189
|
-
...n,
|
|
190
|
-
// Merge properties deeply to allow partial property updates
|
|
191
|
-
properties: {
|
|
192
|
-
...o.properties,
|
|
193
|
-
...n.properties
|
|
194
|
-
},
|
|
195
|
-
// Merge validation deeply if both exist
|
|
196
|
-
...o.validation && n.validation && {
|
|
197
|
-
validation: {
|
|
198
|
-
...o.validation,
|
|
199
|
-
...n.validation
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
} : o;
|
|
203
|
-
})
|
|
204
|
-
}));
|
|
205
|
-
return {
|
|
206
|
-
id: e.id,
|
|
207
|
-
// Use the step ID from the form config
|
|
208
|
-
title: e.title || s.title,
|
|
209
|
-
displayTitle: s.displayTitle,
|
|
210
|
-
showStepNumber: e.showStepNumber !== void 0 ? e.showStepNumber : s.showStepNumber,
|
|
211
|
-
sections: u,
|
|
212
|
-
navigation: {
|
|
213
|
-
// Use default navigation, then template navigation if available, then step override
|
|
214
|
-
...a,
|
|
215
|
-
...s.navigation,
|
|
216
|
-
// Cast since navigation might not exist in Omit type
|
|
217
|
-
...e.navigation
|
|
218
|
-
},
|
|
219
|
-
// Copy actions if they exist
|
|
220
|
-
...s.actions && {
|
|
221
|
-
actions: s.actions
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
export {
|
|
226
|
-
b as loadTemplate,
|
|
227
|
-
E as resolveTemplateStep
|
|
228
|
-
};
|