@digiform/wizard 0.2.10 → 0.2.11
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 +35 -30
- package/styles.css +1 -1
- 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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ComponentTriggerEngine as r } from "../componentTriggerEngine.js";
|
|
3
|
+
const s = {
|
|
4
|
+
hasSaveTriggersResults: /* @__PURE__ */ new Map(),
|
|
5
|
+
hasSaveContextActionsResults: /* @__PURE__ */ new Map()
|
|
6
|
+
}, i = 500, l = ({ context: e }) => e.canNavigate, v = ({ context: e }) => e.pendingNavigation?.type === "next", d = ({ context: e }) => e.pendingNavigation?.type === "previous", h = ({ context: e }) => e.pendingNavigation?.type === "step", f = ({ context: e }) => {
|
|
7
|
+
const t = `${e.config.id}-${e.currentStepIndex}-${Object.keys(e.data).length}`, n = s.hasSaveTriggersResults.get(t);
|
|
8
|
+
if (n && Date.now() - n.timestamp < i)
|
|
9
|
+
return n.result;
|
|
10
|
+
const a = r.createExecutionPlan(
|
|
11
|
+
e.config,
|
|
12
|
+
"save",
|
|
13
|
+
e.currentStepIndex,
|
|
14
|
+
e
|
|
15
|
+
).totalActions > 0;
|
|
16
|
+
if (s.hasSaveTriggersResults.set(t, {
|
|
17
|
+
result: a,
|
|
18
|
+
timestamp: Date.now()
|
|
19
|
+
}), s.hasSaveTriggersResults.size > 50) {
|
|
20
|
+
const c = Date.now();
|
|
21
|
+
for (const [g, u] of s.hasSaveTriggersResults)
|
|
22
|
+
c - u.timestamp > i * 4 && s.hasSaveTriggersResults.delete(g);
|
|
23
|
+
}
|
|
24
|
+
return a;
|
|
25
|
+
}, S = ({ context: e }) => {
|
|
26
|
+
if (!e.pendingNavigation) return !0;
|
|
27
|
+
const t = e.config.steps[e.currentStepIndex];
|
|
28
|
+
if (!t || !("actions" in t) || !t.actions?.length)
|
|
29
|
+
return !0;
|
|
30
|
+
for (const n of t.actions)
|
|
31
|
+
if (n.type === "executeOnStepFinish")
|
|
32
|
+
return n.config?.navigationBehavior !== "block";
|
|
33
|
+
return !0;
|
|
34
|
+
}, N = ({ context: e }) => {
|
|
35
|
+
if (!e.pendingNavigation || e.pendingNavigation.type !== "next")
|
|
36
|
+
return !1;
|
|
37
|
+
const t = `save-context-${e.config.id}-${e.currentStepIndex}-${Object.keys(e.data).length}`, n = s.hasSaveContextActionsResults.get(t);
|
|
38
|
+
if (n && Date.now() - n.timestamp < i)
|
|
39
|
+
return n.result;
|
|
40
|
+
const a = r.createExecutionPlan(
|
|
41
|
+
e.config,
|
|
42
|
+
"save",
|
|
43
|
+
e.currentStepIndex,
|
|
44
|
+
e
|
|
45
|
+
).totalActions > 0;
|
|
46
|
+
return s.hasSaveContextActionsResults.set(t, {
|
|
47
|
+
result: a,
|
|
48
|
+
timestamp: Date.now()
|
|
49
|
+
}), a;
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
l as canNavigate,
|
|
53
|
+
N as hasSaveContextActions,
|
|
54
|
+
f as hasSaveTriggersForNext,
|
|
55
|
+
v as isPendingNextNavigation,
|
|
56
|
+
d as isPendingPreviousNavigation,
|
|
57
|
+
h as isPendingStepNavigation,
|
|
58
|
+
S as shouldProceedWithNormalNavigation
|
|
59
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ComponentTriggerEngine as i } from "../componentTriggerEngine.js";
|
|
3
|
+
const a = ({
|
|
4
|
+
context: e
|
|
5
|
+
}) => e.saveState.savingSection ? i.createExecutionPlan(
|
|
6
|
+
e.config,
|
|
7
|
+
"save",
|
|
8
|
+
e.currentStepIndex,
|
|
9
|
+
e
|
|
10
|
+
).totalActions > 0 && Object.keys(e.saveState.validationErrors).length === 0 : !1, o = ({
|
|
11
|
+
context: e
|
|
12
|
+
}) => {
|
|
13
|
+
const n = e.config.steps[e.currentStepIndex];
|
|
14
|
+
return !n || !("sections" in n) ? !1 : n.sections?.find(
|
|
15
|
+
(t) => t.id === e.saveState.savingSection
|
|
16
|
+
)?.mode === "editable";
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
a as canExecuteSaveActions,
|
|
20
|
+
o as isSectionEditable
|
|
21
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ComponentTriggerEngine as e } from "../componentTriggerEngine.js";
|
|
3
|
+
const g = ({ context: i }) => !i.pendingNavigation || i.pendingNavigation.type !== "next" || !(Object.keys(i.dirtyFields).length > 0) || !(Object.keys(i.componentOriginalValues).length > 0) ? !1 : e.findDirtyComponentsForNavigation(
|
|
4
|
+
i.config,
|
|
5
|
+
i.currentStepIndex,
|
|
6
|
+
i,
|
|
7
|
+
"step"
|
|
8
|
+
).length > 0;
|
|
9
|
+
export {
|
|
10
|
+
g as hasDirtyComponentsWithTriggers
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ComponentTriggerEngine as e } from "../componentTriggerEngine.js";
|
|
3
|
+
function t(n, o) {
|
|
4
|
+
return e.findComponentTriggers(n, o);
|
|
5
|
+
}
|
|
6
|
+
function r(n, o) {
|
|
7
|
+
return e.findComponentActions(n, o);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
r as findComponentActions,
|
|
11
|
+
t as findComponentTriggers
|
|
12
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const u = {};
|
|
3
|
+
typeof process < "u" && process.env.NODE_ENV;
|
|
4
|
+
typeof import.meta < "u" && typeof u < "u" || typeof process < "u" && process.env.NODE_ENV;
|
|
5
|
+
const l = {
|
|
6
|
+
/**
|
|
7
|
+
* Efficient object comparison for React optimization
|
|
8
|
+
*/
|
|
9
|
+
shallowEqual(e, t) {
|
|
10
|
+
const n = Object.keys(e), r = Object.keys(t);
|
|
11
|
+
if (n.length !== r.length)
|
|
12
|
+
return !1;
|
|
13
|
+
for (const s of n)
|
|
14
|
+
if (e[s] !== t[s])
|
|
15
|
+
return !1;
|
|
16
|
+
return !0;
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* Deep object comparison with depth limit for performance
|
|
20
|
+
*/
|
|
21
|
+
deepEqual(e, t, n = 3) {
|
|
22
|
+
if (n <= 0) return e === t;
|
|
23
|
+
if (e === t) return !0;
|
|
24
|
+
if (e == null || t == null || typeof e != typeof t) return !1;
|
|
25
|
+
if (typeof e == "object") {
|
|
26
|
+
const r = Object.keys(e), s = Object.keys(t);
|
|
27
|
+
if (r.length !== s.length) return !1;
|
|
28
|
+
for (const f of r)
|
|
29
|
+
if (!this.deepEqual(e[f], t[f], n - 1))
|
|
30
|
+
return !1;
|
|
31
|
+
return !0;
|
|
32
|
+
}
|
|
33
|
+
return !1;
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Optimized object merging
|
|
37
|
+
*/
|
|
38
|
+
fastMerge(e, t) {
|
|
39
|
+
let n = !1;
|
|
40
|
+
for (const r in t)
|
|
41
|
+
if (e[r] !== t[r]) {
|
|
42
|
+
n = !0;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
return n ? Object.assign({}, e, t) : e;
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Create optimized cache key
|
|
49
|
+
*/
|
|
50
|
+
createCacheKey(...e) {
|
|
51
|
+
return e.filter((t) => t != null).join("|");
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
l as memoryUtils
|
|
56
|
+
};
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMachine as me } from "@xstate/react";
|
|
3
|
+
import fe, { useContext as Ee, useMemo as f, useCallback as o, createContext as Ce } from "react";
|
|
4
|
+
import { ComponentTriggerEngine as V } from "./componentTriggerEngine.js";
|
|
5
|
+
import { formMachine as he } from "./formMachine.js";
|
|
6
|
+
import { ValidationEngine as Fe } from "../../validation-system/validation/ValidationEngine.js";
|
|
7
|
+
const ve = ({
|
|
8
|
+
config: i,
|
|
9
|
+
initialData: g = {},
|
|
10
|
+
onSubmit: p
|
|
11
|
+
}) => {
|
|
12
|
+
const d = f(() => new Fe({
|
|
13
|
+
messageStyle: i.validationMessageStyle || "withLabel",
|
|
14
|
+
debounceMs: 300
|
|
15
|
+
}), [i.validationMessageStyle]), [m, n] = me(he, {
|
|
16
|
+
input: {
|
|
17
|
+
config: i,
|
|
18
|
+
currentStepId: i.steps[0]?.id || "",
|
|
19
|
+
currentStepIndex: 0,
|
|
20
|
+
data: g,
|
|
21
|
+
errors: {},
|
|
22
|
+
dirtyFields: {},
|
|
23
|
+
touchedFields: {},
|
|
24
|
+
isValid: !0,
|
|
25
|
+
isSubmitting: !1
|
|
26
|
+
}
|
|
27
|
+
// Reduced inspection logging for performance
|
|
28
|
+
}), { context: s } = m, v = s.currentStepId, E = s.currentStepIndex, u = s.data, M = s.errors, h = s.isValid, O = s.isSubmitting, I = s.dirtyFields, R = s.touchedFields, N = f(
|
|
29
|
+
() => i.steps[E],
|
|
30
|
+
[i.steps, E]
|
|
31
|
+
), D = f(() => i.steps, [i.steps]), L = E === 0, P = E === i.steps.length - 1, F = o(
|
|
32
|
+
(e) => {
|
|
33
|
+
for (const t of i.steps) {
|
|
34
|
+
const r = "sections" in t ? t.sections : [];
|
|
35
|
+
for (const c of r || []) {
|
|
36
|
+
const a = c.components?.find(
|
|
37
|
+
(l) => l.id === e
|
|
38
|
+
);
|
|
39
|
+
if (a)
|
|
40
|
+
return a;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
},
|
|
45
|
+
[i.steps]
|
|
46
|
+
), S = o(
|
|
47
|
+
(e, t) => {
|
|
48
|
+
n({
|
|
49
|
+
type: "SET_FIELD_STATE",
|
|
50
|
+
componentId: e,
|
|
51
|
+
state: { error: t }
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
[n]
|
|
55
|
+
), C = o(
|
|
56
|
+
(e) => {
|
|
57
|
+
n({
|
|
58
|
+
type: "SET_FIELD_STATE",
|
|
59
|
+
componentId: e,
|
|
60
|
+
state: { error: null }
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
[n]
|
|
64
|
+
), x = o(
|
|
65
|
+
(e, t) => {
|
|
66
|
+
n({ type: "SET_DATA", key: e, value: t });
|
|
67
|
+
},
|
|
68
|
+
[n]
|
|
69
|
+
), T = o(
|
|
70
|
+
(e) => {
|
|
71
|
+
const t = F(e);
|
|
72
|
+
if (!t) return !0;
|
|
73
|
+
const r = d.validateField(
|
|
74
|
+
t,
|
|
75
|
+
u[e]
|
|
76
|
+
);
|
|
77
|
+
if (!r.isValid) {
|
|
78
|
+
const c = r.errors?.[0] || "Validation error";
|
|
79
|
+
return S(e, c), !1;
|
|
80
|
+
}
|
|
81
|
+
return C(e), !0;
|
|
82
|
+
},
|
|
83
|
+
[u, F, S, C, d]
|
|
84
|
+
), w = o(
|
|
85
|
+
(e) => {
|
|
86
|
+
let t = !0;
|
|
87
|
+
for (const r of i.steps) {
|
|
88
|
+
const a = ("sections" in r ? r.sections : [])?.find(
|
|
89
|
+
(l) => l.id === e
|
|
90
|
+
);
|
|
91
|
+
if (a) {
|
|
92
|
+
for (const l of a.components || [])
|
|
93
|
+
T(l.id) || (t = !1);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return t;
|
|
98
|
+
},
|
|
99
|
+
[i.steps, T]
|
|
100
|
+
), b = o(
|
|
101
|
+
async (e) => {
|
|
102
|
+
const t = i.steps.find((a) => a.id === e);
|
|
103
|
+
if (!t || !("sections" in t)) return !0;
|
|
104
|
+
const r = await d.validateStep(t, u);
|
|
105
|
+
for (const [a, l] of Object.entries(
|
|
106
|
+
r.fieldErrors
|
|
107
|
+
))
|
|
108
|
+
l.length > 0 && S(a, l[0]);
|
|
109
|
+
const c = t.sections?.flatMap(
|
|
110
|
+
(a) => a.components || []
|
|
111
|
+
) || [];
|
|
112
|
+
for (const a of c)
|
|
113
|
+
r.fieldErrors[a.id] || C(a.id);
|
|
114
|
+
return r.isValid;
|
|
115
|
+
},
|
|
116
|
+
[i.steps, d, u, S, C]
|
|
117
|
+
), G = o(async () => {
|
|
118
|
+
const e = await d.validateForm(i, u);
|
|
119
|
+
for (const [t, r] of Object.entries(
|
|
120
|
+
e.fieldErrors
|
|
121
|
+
))
|
|
122
|
+
r.length > 0 && S(t, r[0]);
|
|
123
|
+
return e.isValid;
|
|
124
|
+
}, [i, d, u, S]), W = o(() => {
|
|
125
|
+
n({ type: "NEXT" });
|
|
126
|
+
}, [n]), U = o(() => {
|
|
127
|
+
n({ type: "PREVIOUS" });
|
|
128
|
+
}, [n]), k = o(
|
|
129
|
+
(e) => {
|
|
130
|
+
n({ type: "GO_TO_STEP", stepId: e });
|
|
131
|
+
},
|
|
132
|
+
[n]
|
|
133
|
+
), $ = o(async () => {
|
|
134
|
+
if (n({ type: "SUBMIT" }), h && p)
|
|
135
|
+
try {
|
|
136
|
+
await p(u), n({ type: "SUBMIT_SUCCESS" });
|
|
137
|
+
} catch (e) {
|
|
138
|
+
n({
|
|
139
|
+
type: "SUBMIT_ERROR",
|
|
140
|
+
error: e instanceof Error ? e : new Error("Unknown error occurred")
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}, [n, h, p, u]), j = o(() => {
|
|
144
|
+
n({ type: "RESET" });
|
|
145
|
+
}, [n]), B = o(
|
|
146
|
+
(e, t) => {
|
|
147
|
+
n({ type: "START_SECTION_EDIT", sectionId: e, componentIds: t });
|
|
148
|
+
},
|
|
149
|
+
[n]
|
|
150
|
+
), z = o(
|
|
151
|
+
(e) => {
|
|
152
|
+
n({ type: "CANCEL_SECTION_EDIT", sectionId: e });
|
|
153
|
+
},
|
|
154
|
+
[n]
|
|
155
|
+
), H = o(
|
|
156
|
+
(e, t, r) => {
|
|
157
|
+
n({ type: "FIELD_CHANGED", fieldId: e, oldValue: t, newValue: r });
|
|
158
|
+
},
|
|
159
|
+
[n]
|
|
160
|
+
), K = o(
|
|
161
|
+
(e) => e ? s.fieldChangeState[e] || {
|
|
162
|
+
originalValue: void 0,
|
|
163
|
+
currentValue: void 0,
|
|
164
|
+
hasChanged: !1,
|
|
165
|
+
validationWarnings: []
|
|
166
|
+
} : s.fieldChangeState,
|
|
167
|
+
[s.fieldChangeState]
|
|
168
|
+
), X = o(
|
|
169
|
+
(e) => {
|
|
170
|
+
n({ type: "CLEAR_FIELD_CHANGES", fieldId: e });
|
|
171
|
+
},
|
|
172
|
+
[n]
|
|
173
|
+
), q = o(
|
|
174
|
+
(e, t) => {
|
|
175
|
+
n({ type: "TRIGGER_FIELD_WARNING", fieldId: e, warning: t });
|
|
176
|
+
},
|
|
177
|
+
[n]
|
|
178
|
+
), J = o(
|
|
179
|
+
(e, t) => {
|
|
180
|
+
n({ type: "DISMISS_FIELD_WARNING", fieldId: e, warningId: t });
|
|
181
|
+
},
|
|
182
|
+
[n]
|
|
183
|
+
), Q = o(
|
|
184
|
+
(e) => s.fieldChangeState[e]?.validationWarnings || [],
|
|
185
|
+
[s.fieldChangeState]
|
|
186
|
+
), Y = o(
|
|
187
|
+
async (e, t) => (n({ type: "START_FIELD_VERIFICATION", fieldId: e, config: t }), new Promise((r) => {
|
|
188
|
+
setTimeout(() => {
|
|
189
|
+
const c = {
|
|
190
|
+
status: "success",
|
|
191
|
+
timestamp: Date.now(),
|
|
192
|
+
result: { verified: !0 }
|
|
193
|
+
};
|
|
194
|
+
n({
|
|
195
|
+
type: "FIELD_VERIFICATION_COMPLETE",
|
|
196
|
+
fieldId: e,
|
|
197
|
+
result: c,
|
|
198
|
+
success: !0
|
|
199
|
+
}), r(c);
|
|
200
|
+
}, 1e3);
|
|
201
|
+
})),
|
|
202
|
+
[n]
|
|
203
|
+
), Z = o(
|
|
204
|
+
(e) => s.fieldValidationState.verificationResults[e] || null,
|
|
205
|
+
[s.fieldValidationState.verificationResults]
|
|
206
|
+
), ee = f(() => s.fieldValidationState.activeWarnings.length > 0, [s.fieldValidationState.activeWarnings]), te = f(() => s.fieldValidationState.pendingVerifications.length > 0, [s.fieldValidationState.pendingVerifications]), ne = f(() => Object.keys(s.fieldChangeState).length > 0, [s.fieldChangeState]), se = o(
|
|
207
|
+
(e, t, r) => {
|
|
208
|
+
console.log(
|
|
209
|
+
`🚀 [useFormMachine] evaluateComponentTriggers called for ${e}:`,
|
|
210
|
+
{
|
|
211
|
+
eventType: t,
|
|
212
|
+
value: r,
|
|
213
|
+
componentId: e,
|
|
214
|
+
sendFunction: !!n,
|
|
215
|
+
currentState: m.value
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
const c = {
|
|
219
|
+
type: "EVALUATE_COMPONENT_TRIGGERS",
|
|
220
|
+
componentId: e,
|
|
221
|
+
eventType: t,
|
|
222
|
+
value: r
|
|
223
|
+
};
|
|
224
|
+
console.log("🚀 [useFormMachine] About to send event:", c), n(c), console.log(
|
|
225
|
+
`🚀 [useFormMachine] EVALUATE_COMPONENT_TRIGGERS event sent for ${e}`
|
|
226
|
+
);
|
|
227
|
+
},
|
|
228
|
+
[n, m.value]
|
|
229
|
+
), re = o(
|
|
230
|
+
(e, t, r = "initialized") => {
|
|
231
|
+
n({
|
|
232
|
+
type: "SET_COMPONENT_ORIGINAL_VALUE",
|
|
233
|
+
componentId: e,
|
|
234
|
+
value: t,
|
|
235
|
+
source: r
|
|
236
|
+
});
|
|
237
|
+
},
|
|
238
|
+
[n]
|
|
239
|
+
), oe = o(
|
|
240
|
+
(e, t) => {
|
|
241
|
+
n({
|
|
242
|
+
type: "MARK_COMPONENT_AS_POPULATED",
|
|
243
|
+
componentId: e,
|
|
244
|
+
value: t
|
|
245
|
+
});
|
|
246
|
+
},
|
|
247
|
+
[n]
|
|
248
|
+
), ie = o(
|
|
249
|
+
(e) => s.componentOriginalValues[e]?.value,
|
|
250
|
+
[s.componentOriginalValues]
|
|
251
|
+
), ae = o(
|
|
252
|
+
(e, t) => {
|
|
253
|
+
const r = s.componentOriginalValues[e];
|
|
254
|
+
return !r || !r.isPopulated ? !1 : r.value !== t;
|
|
255
|
+
},
|
|
256
|
+
[s.componentOriginalValues]
|
|
257
|
+
), ce = o(
|
|
258
|
+
(e) => s.componentAlerts[e] || [],
|
|
259
|
+
[s.componentAlerts]
|
|
260
|
+
), le = o(
|
|
261
|
+
(e, t) => {
|
|
262
|
+
n({
|
|
263
|
+
type: "DISMISS_COMPONENT_ALERT",
|
|
264
|
+
componentId: e,
|
|
265
|
+
alertId: t
|
|
266
|
+
});
|
|
267
|
+
},
|
|
268
|
+
[n]
|
|
269
|
+
), de = o(
|
|
270
|
+
(e, t) => {
|
|
271
|
+
try {
|
|
272
|
+
const r = e.getFieldValue(t);
|
|
273
|
+
console.log(
|
|
274
|
+
`🔄 [useFormMachine] Resetting dirty state for field ${t}:`,
|
|
275
|
+
{ currentValue: r }
|
|
276
|
+
), e.resetField(t), r != null && r !== "" && e.setFieldValue(t, r, {
|
|
277
|
+
dontUpdateMeta: !0
|
|
278
|
+
// This prevents marking as dirty/touched
|
|
279
|
+
}), console.log(
|
|
280
|
+
`✅ [useFormMachine] Field ${t} dirty state reset complete`
|
|
281
|
+
);
|
|
282
|
+
} catch (r) {
|
|
283
|
+
console.error(
|
|
284
|
+
`❌ [useFormMachine] Error resetting dirty state for field ${t}:`,
|
|
285
|
+
r
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
[]
|
|
290
|
+
), ue = o(
|
|
291
|
+
(e) => V.hasComponentTriggers(i, e),
|
|
292
|
+
[i]
|
|
293
|
+
), pe = o(
|
|
294
|
+
(e) => V.hasComponentActions(i, e),
|
|
295
|
+
[i]
|
|
296
|
+
), Se = o(
|
|
297
|
+
(e) => {
|
|
298
|
+
const t = V.findComponentTriggers(
|
|
299
|
+
i,
|
|
300
|
+
e
|
|
301
|
+
), r = Object.entries(s.componentTriggerState).filter(([l]) => l.startsWith(`${e}-`)).reduce(
|
|
302
|
+
(l, [y, ge]) => (l[y] = ge, l),
|
|
303
|
+
{}
|
|
304
|
+
), c = s.activeComponentActions[e] || [], a = s.componentAlerts[e] || [];
|
|
305
|
+
return {
|
|
306
|
+
triggers: t,
|
|
307
|
+
triggerStates: r,
|
|
308
|
+
activeActions: c,
|
|
309
|
+
alerts: a
|
|
310
|
+
};
|
|
311
|
+
},
|
|
312
|
+
[
|
|
313
|
+
i,
|
|
314
|
+
s.componentTriggerState,
|
|
315
|
+
s.activeComponentActions,
|
|
316
|
+
s.componentAlerts
|
|
317
|
+
]
|
|
318
|
+
);
|
|
319
|
+
return {
|
|
320
|
+
// XState primitives - for direct machine access
|
|
321
|
+
state: m,
|
|
322
|
+
send: n,
|
|
323
|
+
// Computed state values
|
|
324
|
+
currentStep: N,
|
|
325
|
+
currentStepId: v,
|
|
326
|
+
currentStepIndex: E,
|
|
327
|
+
data: u,
|
|
328
|
+
errors: M,
|
|
329
|
+
isValid: h,
|
|
330
|
+
isSubmitting: O,
|
|
331
|
+
dirtyFields: I,
|
|
332
|
+
touchedFields: R,
|
|
333
|
+
isFirstStep: L,
|
|
334
|
+
isLastStep: P,
|
|
335
|
+
steps: D,
|
|
336
|
+
config: s.config,
|
|
337
|
+
// Shared validation engine
|
|
338
|
+
validationEngine: d,
|
|
339
|
+
// Helper functions
|
|
340
|
+
findComponentById: F,
|
|
341
|
+
setFieldError: S,
|
|
342
|
+
clearFieldError: C,
|
|
343
|
+
// Actions
|
|
344
|
+
setData: x,
|
|
345
|
+
validateField: T,
|
|
346
|
+
validateSection: w,
|
|
347
|
+
validateStep: b,
|
|
348
|
+
validateForm: G,
|
|
349
|
+
nextStep: W,
|
|
350
|
+
previousStep: U,
|
|
351
|
+
goToStep: k,
|
|
352
|
+
submitForm: $,
|
|
353
|
+
resetForm: j,
|
|
354
|
+
startSectionEdit: B,
|
|
355
|
+
cancelSectionEdit: z,
|
|
356
|
+
// Field change validation helpers
|
|
357
|
+
trackFieldChange: H,
|
|
358
|
+
getFieldChanges: K,
|
|
359
|
+
clearFieldChanges: X,
|
|
360
|
+
showFieldWarning: q,
|
|
361
|
+
dismissFieldWarning: J,
|
|
362
|
+
getFieldWarnings: Q,
|
|
363
|
+
startFieldVerification: Y,
|
|
364
|
+
getVerificationStatus: Z,
|
|
365
|
+
// Computed validation state
|
|
366
|
+
hasActiveWarnings: ee,
|
|
367
|
+
hasPendingVerifications: te,
|
|
368
|
+
hasFieldChanges: ne,
|
|
369
|
+
fieldChangeState: s.fieldChangeState,
|
|
370
|
+
fieldValidationState: s.fieldValidationState,
|
|
371
|
+
// Component trigger-action system
|
|
372
|
+
evaluateComponentTriggers: se,
|
|
373
|
+
setComponentOriginalValue: re,
|
|
374
|
+
markComponentAsPopulated: oe,
|
|
375
|
+
getComponentOriginalValue: ie,
|
|
376
|
+
isComponentDirty: ae,
|
|
377
|
+
getComponentAlerts: ce,
|
|
378
|
+
dismissComponentAlert: le,
|
|
379
|
+
resetFieldDirtyState: de,
|
|
380
|
+
hasComponentTriggers: ue,
|
|
381
|
+
hasComponentActions: pe,
|
|
382
|
+
getComponentTriggerState: Se,
|
|
383
|
+
componentTriggerState: s.componentTriggerState,
|
|
384
|
+
activeComponentActions: s.activeComponentActions,
|
|
385
|
+
componentAlerts: s.componentAlerts,
|
|
386
|
+
componentOriginalValues: s.componentOriginalValues
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
let A = null;
|
|
390
|
+
const _ = () => (A || (A = Ce(null)), A), Me = {
|
|
391
|
+
Provider: ({
|
|
392
|
+
children: i,
|
|
393
|
+
value: g
|
|
394
|
+
}) => {
|
|
395
|
+
const p = _();
|
|
396
|
+
return fe.createElement(p.Provider, { value: g }, i);
|
|
397
|
+
}
|
|
398
|
+
}, Oe = () => {
|
|
399
|
+
const i = _(), g = Ee(i);
|
|
400
|
+
if (!g)
|
|
401
|
+
throw new Error(
|
|
402
|
+
"useFormMachine must be used within a FormWizard component"
|
|
403
|
+
);
|
|
404
|
+
const { state: p, send: d, ...m } = g;
|
|
405
|
+
return [p, d, m];
|
|
406
|
+
};
|
|
407
|
+
export {
|
|
408
|
+
Me as FormMachineContext,
|
|
409
|
+
Oe as default,
|
|
410
|
+
Oe as useFormMachine,
|
|
411
|
+
ve as useFormMachineProvider
|
|
412
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as s, jsxs as r } from "react/jsx-runtime";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { Badge as c } from "../../../../../../ui/src/components/badge/badge.js";
|
|
5
|
+
import { Card as o, CardContent as l } from "../../../../../../ui/src/components/card/card.js";
|
|
6
|
+
import { clsx as d } from "clsx";
|
|
7
|
+
import { Loader2 as m } from "lucide-react";
|
|
8
|
+
import { memo as p } from "react";
|
|
9
|
+
import e from "./ActionLoadingIndicator.module.css.js";
|
|
10
|
+
const g = p(
|
|
11
|
+
({ activeActions: a, className: n }) => {
|
|
12
|
+
const t = Object.values(a).filter(
|
|
13
|
+
(i) => i.status === "executing"
|
|
14
|
+
);
|
|
15
|
+
return t.length === 0 ? null : /* @__PURE__ */ s(o, { className: d(e.card, n), children: /* @__PURE__ */ r(l, { className: e.cardContent, children: [
|
|
16
|
+
/* @__PURE__ */ r("div", { className: e.contentRow, children: [
|
|
17
|
+
/* @__PURE__ */ s(m, { className: e.spinner }),
|
|
18
|
+
/* @__PURE__ */ r("div", { className: e.textContent, children: [
|
|
19
|
+
/* @__PURE__ */ s("div", { className: e.title, children: "Executing Actions..." }),
|
|
20
|
+
/* @__PURE__ */ s("div", { className: e.subtitle, children: t.length === 1 ? "1 action in progress" : `${t.length} actions in progress` })
|
|
21
|
+
] }),
|
|
22
|
+
/* @__PURE__ */ s("div", { className: e.badgeList, children: t.map((i) => /* @__PURE__ */ s(
|
|
23
|
+
c,
|
|
24
|
+
{
|
|
25
|
+
variant: "secondary",
|
|
26
|
+
className: e.badgeText,
|
|
27
|
+
children: i.actionId.split("-")[0]
|
|
28
|
+
},
|
|
29
|
+
i.actionId
|
|
30
|
+
)) })
|
|
31
|
+
] }),
|
|
32
|
+
/* @__PURE__ */ s("div", { className: e.progressSection, children: /* @__PURE__ */ s("div", { className: e.progressTrack, children: /* @__PURE__ */ s(
|
|
33
|
+
"div",
|
|
34
|
+
{
|
|
35
|
+
className: e.progressBar,
|
|
36
|
+
style: { width: "60%" }
|
|
37
|
+
}
|
|
38
|
+
) }) })
|
|
39
|
+
] }) });
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
g.displayName = "ActionLoadingIndicator";
|
|
43
|
+
export {
|
|
44
|
+
g as ActionLoadingIndicator,
|
|
45
|
+
g as default
|
|
46
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const t = "fb-card_jvOrv", e = "fb-cardContent_Cnf5t", s = "fb-contentRow_-lops", n = "fb-spinner_SkwMR", o = "fb-textContent_t3X2X", r = "fb-title_-fTQX", c = "fb-subtitle_wyptE", b = "fb-badgeList_xtoNn", a = "fb-badgeText_TZRdG", g = "fb-progressSection_XcPgJ", i = "fb-progressTrack_BUoRx", f = "fb-progressBar_5MELx", p = {
|
|
3
|
+
card: t,
|
|
4
|
+
cardContent: e,
|
|
5
|
+
contentRow: s,
|
|
6
|
+
spinner: n,
|
|
7
|
+
textContent: o,
|
|
8
|
+
title: r,
|
|
9
|
+
subtitle: c,
|
|
10
|
+
badgeList: b,
|
|
11
|
+
badgeText: a,
|
|
12
|
+
progressSection: g,
|
|
13
|
+
progressTrack: i,
|
|
14
|
+
progressBar: f
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
b as badgeList,
|
|
18
|
+
a as badgeText,
|
|
19
|
+
t as card,
|
|
20
|
+
e as cardContent,
|
|
21
|
+
s as contentRow,
|
|
22
|
+
p as default,
|
|
23
|
+
f as progressBar,
|
|
24
|
+
g as progressSection,
|
|
25
|
+
i as progressTrack,
|
|
26
|
+
n as spinner,
|
|
27
|
+
c as subtitle,
|
|
28
|
+
o as textContent,
|
|
29
|
+
r as title
|
|
30
|
+
};
|