@digiform/wizard 0.2.9 → 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,155 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as s, jsxs as t } from "react/jsx-runtime";
|
|
3
|
+
import { AlertTriangle as d, RefreshCw as h } from "lucide-react";
|
|
4
|
+
import { Component as u } from "react";
|
|
5
|
+
import { Button as i } from "../../components/button/button.js";
|
|
6
|
+
import { Card as m, CardHeader as g, CardTitle as f, CardDescription as E, CardContent as v } from "../../components/card/card.js";
|
|
7
|
+
const x = ({
|
|
8
|
+
error: a,
|
|
9
|
+
resetError: r,
|
|
10
|
+
level: e,
|
|
11
|
+
context: o,
|
|
12
|
+
errorId: n
|
|
13
|
+
}) => {
|
|
14
|
+
const c = () => {
|
|
15
|
+
switch (e) {
|
|
16
|
+
case "app":
|
|
17
|
+
return "Application Error";
|
|
18
|
+
case "feature":
|
|
19
|
+
return "Feature Unavailable";
|
|
20
|
+
case "component":
|
|
21
|
+
return "Component Error";
|
|
22
|
+
default:
|
|
23
|
+
return "Something went wrong";
|
|
24
|
+
}
|
|
25
|
+
}, l = () => {
|
|
26
|
+
switch (e) {
|
|
27
|
+
case "app":
|
|
28
|
+
return "The application has encountered an unexpected error. Please try refreshing the page or contact support if the problem persists.";
|
|
29
|
+
case "feature":
|
|
30
|
+
return `The ${o || "feature"} is temporarily unavailable due to an error. You can try reloading this section or continue using other parts of the application.`;
|
|
31
|
+
case "component":
|
|
32
|
+
return `A component ${o ? `in ${o} ` : ""}has encountered an error. This shouldn't affect the rest of the application.`;
|
|
33
|
+
default:
|
|
34
|
+
return "An unexpected error occurred. Please try again.";
|
|
35
|
+
}
|
|
36
|
+
}, p = e === "app" || process.env.NODE_ENV === "development";
|
|
37
|
+
return /* @__PURE__ */ t(m, { className: "w-full max-w-2xl mx-auto my-8 border-destructive/50", children: [
|
|
38
|
+
/* @__PURE__ */ t(g, { children: [
|
|
39
|
+
/* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
|
|
40
|
+
/* @__PURE__ */ s(d, { className: "h-5 w-5 text-destructive" }),
|
|
41
|
+
/* @__PURE__ */ s(f, { className: "text-destructive", children: c() })
|
|
42
|
+
] }),
|
|
43
|
+
/* @__PURE__ */ s(E, { children: l() })
|
|
44
|
+
] }),
|
|
45
|
+
/* @__PURE__ */ t(v, { className: "space-y-4", children: [
|
|
46
|
+
/* @__PURE__ */ t("div", { className: "flex gap-2", children: [
|
|
47
|
+
/* @__PURE__ */ t(i, { onClick: r, variant: "outline", size: "sm", children: [
|
|
48
|
+
/* @__PURE__ */ s(h, { className: "h-4 w-4 mr-2" }),
|
|
49
|
+
"Try Again"
|
|
50
|
+
] }),
|
|
51
|
+
e === "app" && /* @__PURE__ */ s(
|
|
52
|
+
i,
|
|
53
|
+
{
|
|
54
|
+
onClick: () => window.location.reload(),
|
|
55
|
+
variant: "default",
|
|
56
|
+
size: "sm",
|
|
57
|
+
children: "Reload Page"
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
] }),
|
|
61
|
+
p && /* @__PURE__ */ t("details", { className: "mt-4", children: [
|
|
62
|
+
/* @__PURE__ */ t("summary", { className: "cursor-pointer text-sm font-medium text-muted-foreground hover:text-foreground", children: [
|
|
63
|
+
"Technical Details (Error ID: ",
|
|
64
|
+
n,
|
|
65
|
+
")"
|
|
66
|
+
] }),
|
|
67
|
+
/* @__PURE__ */ s("div", { className: "mt-2 p-3 bg-muted rounded-md", children: /* @__PURE__ */ t("div", { className: "text-sm space-y-2", children: [
|
|
68
|
+
/* @__PURE__ */ t("div", { children: [
|
|
69
|
+
/* @__PURE__ */ s("strong", { children: "Error:" }),
|
|
70
|
+
" ",
|
|
71
|
+
a.message
|
|
72
|
+
] }),
|
|
73
|
+
/* @__PURE__ */ t("div", { children: [
|
|
74
|
+
/* @__PURE__ */ s("strong", { children: "Stack:" }),
|
|
75
|
+
/* @__PURE__ */ s("pre", { className: "text-xs mt-1 whitespace-pre-wrap break-all", children: a.stack })
|
|
76
|
+
] })
|
|
77
|
+
] }) })
|
|
78
|
+
] })
|
|
79
|
+
] })
|
|
80
|
+
] });
|
|
81
|
+
};
|
|
82
|
+
class k extends u {
|
|
83
|
+
constructor(r) {
|
|
84
|
+
super(r), this.state = {
|
|
85
|
+
hasError: !1,
|
|
86
|
+
error: null,
|
|
87
|
+
errorInfo: null,
|
|
88
|
+
errorId: null
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
static getDerivedStateFromError(r) {
|
|
92
|
+
const e = `err_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
93
|
+
return {
|
|
94
|
+
hasError: !0,
|
|
95
|
+
error: r,
|
|
96
|
+
errorId: e
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
componentDidCatch(r, e) {
|
|
100
|
+
const o = this.state.errorId || `err_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
101
|
+
this.setState({
|
|
102
|
+
errorInfo: e,
|
|
103
|
+
errorId: o
|
|
104
|
+
}), process.env.NODE_ENV === "development" && (console.group(
|
|
105
|
+
`🚨 Error Boundary Caught Error (${this.props.level || "unknown"} level)`
|
|
106
|
+
), console.error("Error:", r), console.error("Error Info:", e), console.error("Context:", this.props.context), console.error("Error ID:", o), console.groupEnd()), this.props.onError && this.props.onError(r, e, o), process.env.NODE_ENV === "production" && this.logErrorToService(r, e, o);
|
|
107
|
+
}
|
|
108
|
+
logErrorToService = (r, e, o) => {
|
|
109
|
+
try {
|
|
110
|
+
const n = {
|
|
111
|
+
errorId: o,
|
|
112
|
+
message: r.message,
|
|
113
|
+
stack: r.stack,
|
|
114
|
+
componentStack: e.componentStack,
|
|
115
|
+
level: this.props.level,
|
|
116
|
+
context: this.props.context,
|
|
117
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
118
|
+
userAgent: navigator.userAgent,
|
|
119
|
+
url: window.location.href
|
|
120
|
+
};
|
|
121
|
+
console.error("Error logged to service:", n);
|
|
122
|
+
} catch (n) {
|
|
123
|
+
console.error("Failed to log error to service:", n);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
resetError = () => {
|
|
127
|
+
this.setState({
|
|
128
|
+
hasError: !1,
|
|
129
|
+
error: null,
|
|
130
|
+
errorInfo: null,
|
|
131
|
+
errorId: null
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
render() {
|
|
135
|
+
if (this.state.hasError && this.state.error && this.state.errorId && this.state.errorInfo) {
|
|
136
|
+
const r = this.props.fallbackComponent || x;
|
|
137
|
+
return /* @__PURE__ */ s(
|
|
138
|
+
r,
|
|
139
|
+
{
|
|
140
|
+
error: this.state.error,
|
|
141
|
+
errorInfo: this.state.errorInfo,
|
|
142
|
+
resetError: this.resetError,
|
|
143
|
+
level: this.props.level || "component",
|
|
144
|
+
context: this.props.context,
|
|
145
|
+
errorId: this.state.errorId
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
return this.props.children;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
export {
|
|
153
|
+
k as BaseErrorBoundary,
|
|
154
|
+
k as default
|
|
155
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r, jsxs as e } from "react/jsx-runtime";
|
|
3
|
+
import { AlertCircle as d, RefreshCw as v, X as x } from "lucide-react";
|
|
4
|
+
import { useState as f } from "react";
|
|
5
|
+
import { Alert as h, AlertDescription as p } from "../../components/alert/alert.js";
|
|
6
|
+
import { Button as o } from "../../components/button/button.js";
|
|
7
|
+
import { BaseErrorBoundary as g } from "./BaseErrorBoundary.js";
|
|
8
|
+
const N = ({
|
|
9
|
+
error: i,
|
|
10
|
+
resetError: t,
|
|
11
|
+
errorId: a,
|
|
12
|
+
context: n = "Component"
|
|
13
|
+
}) => {
|
|
14
|
+
const [c, s] = f(!1);
|
|
15
|
+
return c ? /* @__PURE__ */ e(h, { className: "border-destructive/50 bg-destructive/5", children: [
|
|
16
|
+
/* @__PURE__ */ r(d, { className: "h-4 w-4 text-destructive" }),
|
|
17
|
+
/* @__PURE__ */ e(p, { className: "flex items-center justify-between", children: [
|
|
18
|
+
/* @__PURE__ */ e("span", { className: "text-sm", children: [
|
|
19
|
+
n,
|
|
20
|
+
" temporarily unavailable"
|
|
21
|
+
] }),
|
|
22
|
+
/* @__PURE__ */ e("div", { className: "flex gap-1", children: [
|
|
23
|
+
/* @__PURE__ */ r(
|
|
24
|
+
o,
|
|
25
|
+
{
|
|
26
|
+
onClick: t,
|
|
27
|
+
size: "sm",
|
|
28
|
+
variant: "ghost",
|
|
29
|
+
className: "h-6 px-2 text-xs",
|
|
30
|
+
children: "Retry"
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
/* @__PURE__ */ r(
|
|
34
|
+
o,
|
|
35
|
+
{
|
|
36
|
+
onClick: () => s(!1),
|
|
37
|
+
size: "sm",
|
|
38
|
+
variant: "ghost",
|
|
39
|
+
className: "h-6 px-2 text-xs",
|
|
40
|
+
children: "Show"
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
] })
|
|
44
|
+
] })
|
|
45
|
+
] }) : /* @__PURE__ */ e(h, { className: "border-destructive/50 bg-destructive/5", children: [
|
|
46
|
+
/* @__PURE__ */ r(d, { className: "h-4 w-4 text-destructive" }),
|
|
47
|
+
/* @__PURE__ */ e(p, { children: [
|
|
48
|
+
/* @__PURE__ */ e("div", { className: "flex items-start justify-between", children: [
|
|
49
|
+
/* @__PURE__ */ e("div", { className: "flex-1", children: [
|
|
50
|
+
/* @__PURE__ */ e("div", { className: "font-medium text-destructive mb-1", children: [
|
|
51
|
+
n,
|
|
52
|
+
" Error"
|
|
53
|
+
] }),
|
|
54
|
+
/* @__PURE__ */ r("div", { className: "text-sm text-muted-foreground mb-2", children: "This component encountered an error and couldn't render properly. The rest of the application should work normally." }),
|
|
55
|
+
/* @__PURE__ */ e("div", { className: "flex gap-2", children: [
|
|
56
|
+
/* @__PURE__ */ e(o, { onClick: t, size: "sm", variant: "outline", children: [
|
|
57
|
+
/* @__PURE__ */ r(v, { className: "h-3 w-3 mr-1" }),
|
|
58
|
+
"Retry"
|
|
59
|
+
] }),
|
|
60
|
+
/* @__PURE__ */ r(
|
|
61
|
+
o,
|
|
62
|
+
{
|
|
63
|
+
onClick: () => s(!0),
|
|
64
|
+
size: "sm",
|
|
65
|
+
variant: "ghost",
|
|
66
|
+
className: "text-xs",
|
|
67
|
+
children: "Hide"
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
] })
|
|
71
|
+
] }),
|
|
72
|
+
/* @__PURE__ */ r(
|
|
73
|
+
o,
|
|
74
|
+
{
|
|
75
|
+
onClick: () => s(!0),
|
|
76
|
+
size: "sm",
|
|
77
|
+
variant: "ghost",
|
|
78
|
+
className: "h-6 w-6 p-0 shrink-0",
|
|
79
|
+
children: /* @__PURE__ */ r(x, { className: "h-3 w-3" })
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
] }),
|
|
83
|
+
process.env.NODE_ENV === "development" && /* @__PURE__ */ e("details", { className: "mt-3 text-xs", children: [
|
|
84
|
+
/* @__PURE__ */ e("summary", { className: "cursor-pointer text-muted-foreground hover:text-foreground", children: [
|
|
85
|
+
"Debug Info (ID: ",
|
|
86
|
+
a,
|
|
87
|
+
")"
|
|
88
|
+
] }),
|
|
89
|
+
/* @__PURE__ */ e("div", { className: "mt-1 p-2 bg-muted rounded text-xs", children: [
|
|
90
|
+
/* @__PURE__ */ e("div", { children: [
|
|
91
|
+
/* @__PURE__ */ r("strong", { children: "Component:" }),
|
|
92
|
+
" ",
|
|
93
|
+
n
|
|
94
|
+
] }),
|
|
95
|
+
/* @__PURE__ */ e("div", { children: [
|
|
96
|
+
/* @__PURE__ */ r("strong", { children: "Error:" }),
|
|
97
|
+
" ",
|
|
98
|
+
i.message
|
|
99
|
+
] }),
|
|
100
|
+
/* @__PURE__ */ e("div", { className: "mt-1", children: [
|
|
101
|
+
/* @__PURE__ */ r("strong", { children: "Stack:" }),
|
|
102
|
+
/* @__PURE__ */ r("pre", { className: "whitespace-pre-wrap break-all text-xs mt-1 max-h-20 overflow-y-auto", children: i.stack })
|
|
103
|
+
] })
|
|
104
|
+
] })
|
|
105
|
+
] })
|
|
106
|
+
] })
|
|
107
|
+
] });
|
|
108
|
+
}, z = ({
|
|
109
|
+
children: i,
|
|
110
|
+
componentName: t = "Component",
|
|
111
|
+
fallback: a,
|
|
112
|
+
onError: n
|
|
113
|
+
}) => /* @__PURE__ */ r(
|
|
114
|
+
g,
|
|
115
|
+
{
|
|
116
|
+
level: "component",
|
|
117
|
+
context: t,
|
|
118
|
+
fallbackComponent: a || N,
|
|
119
|
+
onError: (s, m, l) => {
|
|
120
|
+
if (console.warn(`⚠️ Component error in ${t}:`, {
|
|
121
|
+
error: s.message,
|
|
122
|
+
errorId: l,
|
|
123
|
+
componentName: t
|
|
124
|
+
}), process.env.NODE_ENV === "development" && console.error("Component error details:", {
|
|
125
|
+
error: s,
|
|
126
|
+
errorInfo: m,
|
|
127
|
+
errorId: l,
|
|
128
|
+
componentName: t
|
|
129
|
+
}), n && n(s, m, l), process.env.NODE_ENV === "production")
|
|
130
|
+
try {
|
|
131
|
+
console.log("Would send component error to monitoring service:", {
|
|
132
|
+
level: "warning",
|
|
133
|
+
// Lower priority than feature/app errors
|
|
134
|
+
message: s.message,
|
|
135
|
+
extra: {
|
|
136
|
+
errorId: l,
|
|
137
|
+
componentName: t,
|
|
138
|
+
context: "Component"
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
} catch (u) {
|
|
142
|
+
console.warn(
|
|
143
|
+
"Failed to send component error to monitoring service:",
|
|
144
|
+
u
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
children: i
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
export {
|
|
152
|
+
z as default
|
|
153
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r, jsxs as e } from "react/jsx-runtime";
|
|
3
|
+
import { FileX as m, RefreshCw as h, ArrowLeft as u } from "lucide-react";
|
|
4
|
+
import { Button as d } from "../../components/button/button.js";
|
|
5
|
+
import { Card as f, CardHeader as p, CardTitle as x, CardDescription as g, CardContent as N } from "../../components/card/card.js";
|
|
6
|
+
import { BaseErrorBoundary as v } from "./BaseErrorBoundary.js";
|
|
7
|
+
const w = ({
|
|
8
|
+
error: n,
|
|
9
|
+
resetError: a,
|
|
10
|
+
errorId: o,
|
|
11
|
+
context: i = "Form"
|
|
12
|
+
}) => /* @__PURE__ */ r("div", { className: "flex items-center justify-center min-h-[50vh] p-4", children: /* @__PURE__ */ e(f, { className: "w-full max-w-lg border-destructive/50", children: [
|
|
13
|
+
/* @__PURE__ */ e(p, { className: "text-center", children: [
|
|
14
|
+
/* @__PURE__ */ r("div", { className: "flex justify-center mb-2", children: /* @__PURE__ */ r(m, { className: "h-8 w-8 text-destructive" }) }),
|
|
15
|
+
/* @__PURE__ */ e(x, { className: "text-destructive", children: [
|
|
16
|
+
i,
|
|
17
|
+
" Unavailable"
|
|
18
|
+
] }),
|
|
19
|
+
/* @__PURE__ */ r(g, { children: "The form wizard encountered an error and cannot be displayed. This might be due to invalid configuration or a temporary issue." })
|
|
20
|
+
] }),
|
|
21
|
+
/* @__PURE__ */ e(N, { className: "space-y-4", children: [
|
|
22
|
+
/* @__PURE__ */ r("div", { className: "text-center space-y-2", children: /* @__PURE__ */ r("p", { className: "text-sm text-muted-foreground", children: "Your progress has been preserved. Please try reloading the form." }) }),
|
|
23
|
+
/* @__PURE__ */ e("div", { className: "flex flex-col sm:flex-row gap-2", children: [
|
|
24
|
+
/* @__PURE__ */ e(d, { onClick: a, className: "flex-1", children: [
|
|
25
|
+
/* @__PURE__ */ r(h, { className: "h-4 w-4 mr-2" }),
|
|
26
|
+
"Reload Form"
|
|
27
|
+
] }),
|
|
28
|
+
/* @__PURE__ */ e(d, { onClick: () => {
|
|
29
|
+
window.history.length > 1 ? window.history.back() : window.location.href = "/";
|
|
30
|
+
}, variant: "outline", className: "flex-1", children: [
|
|
31
|
+
/* @__PURE__ */ r(u, { className: "h-4 w-4 mr-2" }),
|
|
32
|
+
"Go Back"
|
|
33
|
+
] })
|
|
34
|
+
] }),
|
|
35
|
+
process.env.NODE_ENV === "development" && /* @__PURE__ */ e("details", { className: "mt-4", children: [
|
|
36
|
+
/* @__PURE__ */ e("summary", { className: "cursor-pointer text-xs text-muted-foreground hover:text-foreground", children: [
|
|
37
|
+
"Technical Details (ID: ",
|
|
38
|
+
o,
|
|
39
|
+
")"
|
|
40
|
+
] }),
|
|
41
|
+
/* @__PURE__ */ e("div", { className: "mt-2 p-2 bg-muted rounded text-xs", children: [
|
|
42
|
+
/* @__PURE__ */ e("div", { children: [
|
|
43
|
+
/* @__PURE__ */ r("strong", { children: "Error:" }),
|
|
44
|
+
" ",
|
|
45
|
+
n.message
|
|
46
|
+
] }),
|
|
47
|
+
/* @__PURE__ */ e("div", { className: "mt-1", children: [
|
|
48
|
+
/* @__PURE__ */ r("strong", { children: "Component Stack:" }),
|
|
49
|
+
/* @__PURE__ */ r("pre", { className: "whitespace-pre-wrap break-all text-xs mt-1", children: n.stack })
|
|
50
|
+
] })
|
|
51
|
+
] })
|
|
52
|
+
] }),
|
|
53
|
+
/* @__PURE__ */ r("div", { className: "text-center", children: /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: [
|
|
54
|
+
"Error ID: ",
|
|
55
|
+
o
|
|
56
|
+
] }) })
|
|
57
|
+
] })
|
|
58
|
+
] }) }), C = ({
|
|
59
|
+
children: n,
|
|
60
|
+
formId: a,
|
|
61
|
+
onError: o
|
|
62
|
+
}) => /* @__PURE__ */ r(
|
|
63
|
+
v,
|
|
64
|
+
{
|
|
65
|
+
level: "feature",
|
|
66
|
+
context: "Form Wizard",
|
|
67
|
+
fallbackComponent: w,
|
|
68
|
+
onError: (c, l, s) => {
|
|
69
|
+
console.error("🚨 Form Wizard error:", {
|
|
70
|
+
error: c,
|
|
71
|
+
errorInfo: l,
|
|
72
|
+
errorId: s,
|
|
73
|
+
formId: a,
|
|
74
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
75
|
+
url: window.location.href
|
|
76
|
+
});
|
|
77
|
+
try {
|
|
78
|
+
const t = localStorage.getItem(`form-data-${a}`);
|
|
79
|
+
t && (localStorage.setItem(`form-data-backup-${s}`, t), console.log("Form data backed up with error ID:", s));
|
|
80
|
+
} catch (t) {
|
|
81
|
+
console.warn("Failed to backup form data:", t);
|
|
82
|
+
}
|
|
83
|
+
if (o && o(c, l, s), process.env.NODE_ENV === "production")
|
|
84
|
+
try {
|
|
85
|
+
console.log("Would send form error to monitoring service:", {
|
|
86
|
+
level: "error",
|
|
87
|
+
message: c.message,
|
|
88
|
+
extra: {
|
|
89
|
+
errorId: s,
|
|
90
|
+
formId: a,
|
|
91
|
+
componentStack: l.componentStack,
|
|
92
|
+
context: "FormWizard"
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
} catch (t) {
|
|
96
|
+
console.error(
|
|
97
|
+
"Failed to send form error to monitoring service:",
|
|
98
|
+
t
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
children: n
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
export {
|
|
106
|
+
C as default
|
|
107
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var l = /* @__PURE__ */ ((o) => (o[o.DEBUG = 0] = "DEBUG", o[o.INFO = 1] = "INFO", o[o.WARN = 2] = "WARN", o[o.ERROR = 3] = "ERROR", o))(l || {});
|
|
3
|
+
class f {
|
|
4
|
+
level = 1;
|
|
5
|
+
isDevelopment = process.env.NODE_ENV === "development";
|
|
6
|
+
/**
|
|
7
|
+
* Sets the minimum log level for this logger instance
|
|
8
|
+
* @param level - The minimum log level to display
|
|
9
|
+
*/
|
|
10
|
+
setLevel(e) {
|
|
11
|
+
this.level = e;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Determines if a log entry should be processed based on current log level
|
|
15
|
+
* @param level - The log level to check
|
|
16
|
+
* @returns true if the log should be processed
|
|
17
|
+
*/
|
|
18
|
+
shouldLog(e) {
|
|
19
|
+
return e >= this.level;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Formats a log entry into a human-readable string
|
|
23
|
+
* @param entry - The log entry to format
|
|
24
|
+
* @returns Formatted log message string
|
|
25
|
+
*/
|
|
26
|
+
formatMessage(e) {
|
|
27
|
+
const { timestamp: t, level: r, message: a, context: n, error: s } = e, c = l[r];
|
|
28
|
+
let i = `[${t}] ${c}: ${a}`;
|
|
29
|
+
return n && Object.keys(n).length > 0 && (i += ` | Context: ${JSON.stringify(n)}`), s && (i += ` | Error: ${s.message}`, this.isDevelopment && s.stack && (i += `
|
|
30
|
+
Stack: ${s.stack}`)), i;
|
|
31
|
+
}
|
|
32
|
+
log(e, t, r, a) {
|
|
33
|
+
if (!this.shouldLog(e)) return;
|
|
34
|
+
const n = {
|
|
35
|
+
level: e,
|
|
36
|
+
message: t,
|
|
37
|
+
context: r,
|
|
38
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
39
|
+
error: a
|
|
40
|
+
}, s = this.formatMessage(n);
|
|
41
|
+
if (this.isDevelopment)
|
|
42
|
+
switch (e) {
|
|
43
|
+
case 0:
|
|
44
|
+
console.debug(s);
|
|
45
|
+
break;
|
|
46
|
+
case 1:
|
|
47
|
+
console.info(s);
|
|
48
|
+
break;
|
|
49
|
+
case 2:
|
|
50
|
+
console.warn(s);
|
|
51
|
+
break;
|
|
52
|
+
case 3:
|
|
53
|
+
console.error(s);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
else
|
|
57
|
+
e >= 3 && console.error(s);
|
|
58
|
+
}
|
|
59
|
+
debug(e, t) {
|
|
60
|
+
this.log(0, e, t);
|
|
61
|
+
}
|
|
62
|
+
info(e, t) {
|
|
63
|
+
this.log(1, e, t);
|
|
64
|
+
}
|
|
65
|
+
warn(e, t, r) {
|
|
66
|
+
this.log(2, e, t, r);
|
|
67
|
+
}
|
|
68
|
+
error(e, t, r) {
|
|
69
|
+
this.log(3, e, t, r);
|
|
70
|
+
}
|
|
71
|
+
// Utility methods for common logging scenarios
|
|
72
|
+
componentError(e, t, r) {
|
|
73
|
+
this.error(
|
|
74
|
+
`Component error in ${e}`,
|
|
75
|
+
{ component: e, action: t },
|
|
76
|
+
r
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
validationError(e, t, r) {
|
|
80
|
+
this.error(
|
|
81
|
+
`Validation failed for field: ${e}`,
|
|
82
|
+
{
|
|
83
|
+
component: "ValidationEngine",
|
|
84
|
+
field: e,
|
|
85
|
+
value: typeof t == "object" ? JSON.stringify(t) : String(t)
|
|
86
|
+
},
|
|
87
|
+
r
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
performanceWarning(e, t, r = 1e3) {
|
|
91
|
+
t > r && this.warn(`Performance warning: ${e} took ${t}ms`, {
|
|
92
|
+
operation: e,
|
|
93
|
+
duration: t,
|
|
94
|
+
threshold: r
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const m = new f();
|
|
99
|
+
process.env.NODE_ENV === "development" && (m.setLevel(
|
|
100
|
+
0
|
|
101
|
+
/* DEBUG */
|
|
102
|
+
), console.log("🔧 Logger initialized in development mode with DEBUG level"));
|
|
103
|
+
export {
|
|
104
|
+
l as LogLevel,
|
|
105
|
+
m as logger
|
|
106
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
3
|
+
import { useState as u, useMemo as m, createContext as c, useContext as g } from "react";
|
|
4
|
+
let o = null;
|
|
5
|
+
const n = () => (o || (o = c(
|
|
6
|
+
void 0
|
|
7
|
+
)), o), l = () => {
|
|
8
|
+
const e = n(), t = g(e);
|
|
9
|
+
if (!t)
|
|
10
|
+
throw new Error("useFormEditing must be used within a FormEditingProvider");
|
|
11
|
+
return t;
|
|
12
|
+
}, C = ({
|
|
13
|
+
children: e
|
|
14
|
+
}) => {
|
|
15
|
+
const [t, i] = u(!1), r = m(() => ({ isEditing: t, setEditing: i }), [t]), s = n();
|
|
16
|
+
return /* @__PURE__ */ d(s.Provider, { value: r, children: e });
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
C as FormEditingProvider,
|
|
20
|
+
l as useFormEditing
|
|
21
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { QueryClient as e } from "@tanstack/react-query";
|
|
3
|
+
const r = () => new e({
|
|
4
|
+
defaultOptions: {
|
|
5
|
+
queries: {
|
|
6
|
+
// Default cache time: 5 minutes
|
|
7
|
+
gcTime: 300 * 1e3,
|
|
8
|
+
// Default stale time: 30 seconds
|
|
9
|
+
staleTime: 30 * 1e3,
|
|
10
|
+
// Retry failed requests 2 times with exponential backoff
|
|
11
|
+
retry: 2,
|
|
12
|
+
// Don't refetch on window focus by default for form wizards
|
|
13
|
+
refetchOnWindowFocus: !1,
|
|
14
|
+
// Don't refetch on reconnect for form data consistency
|
|
15
|
+
refetchOnReconnect: !1
|
|
16
|
+
},
|
|
17
|
+
mutations: {
|
|
18
|
+
// Retry failed mutations once
|
|
19
|
+
retry: 1
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}), n = r();
|
|
23
|
+
export {
|
|
24
|
+
r as createFormWizardQueryClient,
|
|
25
|
+
n as formWizardQueryClient
|
|
26
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function t(e) {
|
|
3
|
+
return typeof e == "object" && e !== null && "templateId" in e;
|
|
4
|
+
}
|
|
5
|
+
function l(e) {
|
|
6
|
+
return e && typeof e.template == "object" && typeof e.template.typeId == "string";
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
l as isTemplateDialogConfig,
|
|
10
|
+
t as isTemplateStep
|
|
11
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const n = (e) => ![
|
|
3
|
+
"button",
|
|
4
|
+
"submit",
|
|
5
|
+
"reset",
|
|
6
|
+
"heading",
|
|
7
|
+
"paragraph",
|
|
8
|
+
"alert"
|
|
9
|
+
].includes(e), t = {
|
|
10
|
+
text: "",
|
|
11
|
+
date: "",
|
|
12
|
+
time: "",
|
|
13
|
+
"datetime-local": "",
|
|
14
|
+
tel: "",
|
|
15
|
+
email: "",
|
|
16
|
+
password: "",
|
|
17
|
+
textarea: "",
|
|
18
|
+
number: void 0,
|
|
19
|
+
range: 0,
|
|
20
|
+
radioGroup: "",
|
|
21
|
+
radio: "",
|
|
22
|
+
dropdown: [],
|
|
23
|
+
select: "",
|
|
24
|
+
checkbox: !1,
|
|
25
|
+
file: null,
|
|
26
|
+
hidden: "",
|
|
27
|
+
button: null,
|
|
28
|
+
submit: null,
|
|
29
|
+
reset: null,
|
|
30
|
+
heading: null,
|
|
31
|
+
paragraph: null,
|
|
32
|
+
alert: null,
|
|
33
|
+
"code-input": ""
|
|
34
|
+
}, r = (e) => t[e] ?? "";
|
|
35
|
+
export {
|
|
36
|
+
r as getDefaultValue,
|
|
37
|
+
n as isFormField
|
|
38
|
+
};
|