@digiform/wizard 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/src/types/guards.js +0 -12
- package/core/src/utils/apiBodyUtils.js +43 -75
- package/features/form-runtime/components/FormFooter.d.ts +5 -0
- package/features/form-runtime/hooks/useValidationEvents.d.ts +0 -1
- package/features/state-management/machines/formMachine.d.ts +3 -0
- package/features/state-management/machines/types.d.ts +4 -0
- package/features/state-management/machines/useFormMachine.d.ts +18 -0
- package/index.d.ts +2 -8
- package/index.js +2 -108
- package/package.json +1 -30
- package/styles.css +1 -1
- package/ui/src/lib/utils/templateUtils.js +11 -43
- package/wizard/src/features/api-integration/services/ApiCallService.js +65 -74
- package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.js +39 -43
- package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js +37 -41
- package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.js +44 -45
- package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +56 -78
- package/wizard/src/features/form-runtime/components/FormField.js +28 -28
- package/wizard/src/features/form-runtime/components/FormFooter.js +53 -184
- package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +152 -196
- package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +82 -91
- package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +24 -30
- package/wizard/src/features/form-runtime/config/configResolver.js +10 -14
- package/wizard/src/features/form-runtime/config/templateLoader.js +71 -108
- package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +45 -88
- package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +27 -41
- package/wizard/src/features/form-runtime/hooks/useFormFieldState.js +5 -5
- package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +22 -25
- package/wizard/src/features/form-runtime/utils/errorUtils.js +31 -42
- package/wizard/src/features/form-runtime/utils/formDirtyStateSync.js +26 -37
- package/wizard/src/features/form-runtime/utils/logger.js +12 -12
- package/wizard/src/features/form-runtime/utils/validationUX.js +14 -55
- package/wizard/src/features/state-management/machines/actions/navigationActions.js +13 -8
- package/wizard/src/features/state-management/machines/componentTriggerEngine.js +167 -432
- package/wizard/src/features/state-management/machines/formMachine.js +558 -677
- package/wizard/src/features/state-management/machines/useFormMachine.js +172 -190
- package/wizard/src/features/trigger-action-system/components/ActionManager.js +35 -86
- package/wizard/src/features/validation-system/validation/SchemaBuilder.js +28 -82
- package/wizard/src/features/validation-system/validation/ValidationCache.js +11 -27
- package/wizard/src/features/validation-system/validation/ValidationEngine.js +24 -29
- package/wizard/src/features/validation-system/validation/ValidationExecutor.js +26 -58
- package/FormWizard.d.ts +0 -10
- package/core/src/types/api.js +0 -12
- package/core/src/types/form-config.js +0 -60
- package/core/src/types/form-wizard-config-schema.js +0 -113
- package/core/src/types/validation.js +0 -61
- package/features/api-integration.d.ts +0 -2
- package/features/api-integration.js +0 -17
- package/features/dialog-system.d.ts +0 -2
- package/features/dialog-system.js +0 -9
- package/features/form-runtime/utils/formSaver.d.ts +0 -22
- package/features/form-runtime.d.ts +0 -2
- package/features/form-runtime.js +0 -63
- package/features/index.d.ts +0 -11
- package/features/state-management/components/ValidationBuilder/ValidationBuilder.d.ts +0 -9
- package/features/state-management/machines/__tests__/setup.d.ts +0 -0
- package/features/state-management/machines/__tests__/vitest.config.d.ts +0 -2
- package/features/state-management/machines/actions/validationActions.d.ts +0 -68
- package/features/state-management/machines/lazyLoading.d.ts +0 -34
- package/features/state-management/machines/validation/index.d.ts +0 -5
- package/features/state-management/machines/validation/validateField.d.ts +0 -2
- package/features/state-management/machines/validation/validateForm.d.ts +0 -2
- package/features/state-management/machines/validation/validateSection.d.ts +0 -2
- package/features/state-management/machines/validation/validateStep.d.ts +0 -2
- package/features/state-management/machines/validation/validationTypes.d.ts +0 -1
- package/features/state-management.d.ts +0 -2
- package/features/state-management.js +0 -21
- package/features/trigger-action-system/components/FieldWarning/FieldWarning.d.ts +0 -20
- package/features/trigger-action-system.d.ts +0 -2
- package/features/trigger-action-system.js +0 -12
- package/features/validation-system.d.ts +0 -2
- package/features/validation-system.js +0 -23
- package/styles/index.d.ts +0 -0
- package/ui/src/components/badge/badge.js +0 -20
- package/ui/src/components/badge/badge.module.css.js +0 -12
- package/wizard/src/features/api-integration/services/ActionExecutor.js +0 -339
- package/wizard/src/features/api-integration/services/ApiCallExecutor.js +0 -6
- package/wizard/src/features/api-integration/services/DialogExecutor.js +0 -6
- package/wizard/src/features/api-integration/services/GenericTriggerService.js +0 -284
- package/wizard/src/features/api-integration/services/NavigationExecutor.js +0 -6
- package/wizard/src/features/form-runtime/config/templateConfig.js +0 -156
- package/wizard/src/features/form-runtime/config/templateUtils.js +0 -14
- package/wizard/src/features/form-runtime/utils/validation.js +0 -100
- package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.js +0 -46
- package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.module.css.js +0 -30
- package/wizard/src/features/trigger-action-system/utils/GenericTriggerEngine.js +0 -376
- package/wizard/src/features/validation-system/components/ValidationDebugger.js +0 -69
- package/wizard/src/features/validation-system/validation/tanstackSchemaAdapter.js +0 -17
- package/wizard/src/features/validation-system/validation/validationService.js +0 -74
|
@@ -1,52 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
const r = {
|
|
2
|
+
const t = {
|
|
4
3
|
GENERIC: "generic-",
|
|
5
4
|
TEAM: "team-"
|
|
6
5
|
};
|
|
7
|
-
function
|
|
8
|
-
return e.startsWith(
|
|
9
|
-
}
|
|
10
|
-
function p(e) {
|
|
11
|
-
return i(e) === "generic";
|
|
6
|
+
function n(e) {
|
|
7
|
+
return e.startsWith(t.GENERIC) ? "generic" : e.startsWith(t.TEAM) ? "team" : null;
|
|
12
8
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
9
|
+
function r(e) {
|
|
10
|
+
return n(e) === "generic";
|
|
15
11
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
18
|
-
/**
|
|
19
|
-
* Lists all available generic templates
|
|
20
|
-
*/
|
|
21
|
-
getAvailableGenericTemplatesSync() {
|
|
22
|
-
return e.getAvailableGenericTemplates();
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* Gets metadata for a template without loading the full template
|
|
26
|
-
*/
|
|
27
|
-
async getTemplateInfo(a) {
|
|
28
|
-
return await e.getTemplateMetadata(a);
|
|
29
|
-
},
|
|
30
|
-
/**
|
|
31
|
-
* Validates that all template references in a configuration are valid
|
|
32
|
-
*/
|
|
33
|
-
async validateTemplateReferences(a) {
|
|
34
|
-
const n = [], s = await e.getAvailableTemplates();
|
|
35
|
-
for (const t of a.steps)
|
|
36
|
-
l(t) && (s.includes(t.templateId) || n.push(
|
|
37
|
-
`Template '${t.templateId}' referenced in step '${t.id}' does not exist`
|
|
38
|
-
));
|
|
39
|
-
return {
|
|
40
|
-
isValid: n.length === 0,
|
|
41
|
-
errors: n
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
};
|
|
12
|
+
function i(e) {
|
|
13
|
+
return n(e) === "team";
|
|
45
14
|
}
|
|
46
15
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
m as isTeamTemplate
|
|
16
|
+
t as TEMPLATE_PREFIXES,
|
|
17
|
+
n as getTemplateTypeFromId,
|
|
18
|
+
r as isGenericTemplate,
|
|
19
|
+
i as isTeamTemplate
|
|
52
20
|
};
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { compileApiRequestBody as h } from "../../../../../core/src/utils/apiBodyUtils.js";
|
|
3
3
|
import { ActionValidationError as c } from "../../validation-system/validation/ActionValidation.js";
|
|
4
4
|
import "@tanstack/react-query";
|
|
5
|
-
function y(
|
|
6
|
-
return
|
|
5
|
+
function y(n) {
|
|
6
|
+
return n !== null && typeof n == "object" && !Array.isArray(n);
|
|
7
7
|
}
|
|
8
|
-
function d(
|
|
9
|
-
return typeof
|
|
8
|
+
function d(n) {
|
|
9
|
+
return typeof n == "object" && n !== null && "message" in n && typeof n.message == "string";
|
|
10
10
|
}
|
|
11
11
|
class C {
|
|
12
12
|
options;
|
|
@@ -18,15 +18,15 @@ class C {
|
|
|
18
18
|
if (e.cacheKey)
|
|
19
19
|
return this.interpolateTemplate(e.cacheKey, r);
|
|
20
20
|
const t = this.interpolateTemplate(e.url, r), i = e.method;
|
|
21
|
-
let
|
|
21
|
+
let o = "";
|
|
22
22
|
if (i === "POST" || i === "PUT")
|
|
23
23
|
try {
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const a = h(e, r);
|
|
25
|
+
o = a ? `:${JSON.stringify(a)}` : "";
|
|
26
26
|
} catch {
|
|
27
|
-
|
|
27
|
+
o = "";
|
|
28
28
|
}
|
|
29
|
-
return `api-call:${i}:${t}${
|
|
29
|
+
return `api-call:${i}:${t}${o}`;
|
|
30
30
|
}
|
|
31
31
|
// Create query options for React Query
|
|
32
32
|
createQueryOptions(e, r) {
|
|
@@ -62,12 +62,12 @@ class C {
|
|
|
62
62
|
let t = this.interpolateTemplate(e.url, r);
|
|
63
63
|
const i = this.buildQueryParams(e, r);
|
|
64
64
|
if (i.size > 0) {
|
|
65
|
-
const
|
|
65
|
+
const s = new URL(t, window.location.origin);
|
|
66
66
|
i.forEach((p, m) => {
|
|
67
|
-
|
|
68
|
-
}), t =
|
|
67
|
+
s.searchParams.set(m, p);
|
|
68
|
+
}), t = s.toString();
|
|
69
69
|
}
|
|
70
|
-
const
|
|
70
|
+
const o = this.buildHeaders(e, r);
|
|
71
71
|
try {
|
|
72
72
|
new URL(t, window.location.origin);
|
|
73
73
|
} catch {
|
|
@@ -78,63 +78,63 @@ class C {
|
|
|
78
78
|
{ url: t, originalUrl: e.url }
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
|
-
const
|
|
81
|
+
const a = {
|
|
82
82
|
method: e.method,
|
|
83
|
-
headers:
|
|
83
|
+
headers: o
|
|
84
84
|
};
|
|
85
85
|
if (e.method === "POST" || e.method === "PUT")
|
|
86
86
|
try {
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
} catch (
|
|
87
|
+
const s = h(e, r);
|
|
88
|
+
s && (a.body = s, o["Content-Type"] = o["Content-Type"] || "application/json");
|
|
89
|
+
} catch (s) {
|
|
90
90
|
throw new c(
|
|
91
91
|
"api-call-error",
|
|
92
92
|
"apiCall",
|
|
93
|
-
`Failed to compile request body: ${
|
|
93
|
+
`Failed to compile request body: ${s.message}`,
|
|
94
94
|
{ config: e, formData: r }
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
|
-
const
|
|
98
|
-
() =>
|
|
97
|
+
const l = new AbortController(), u = setTimeout(
|
|
98
|
+
() => l.abort(),
|
|
99
99
|
e.timeout || 1e4
|
|
100
100
|
);
|
|
101
101
|
try {
|
|
102
|
-
const
|
|
103
|
-
...
|
|
104
|
-
signal:
|
|
102
|
+
const s = await fetch(t, {
|
|
103
|
+
...a,
|
|
104
|
+
signal: l.signal
|
|
105
105
|
});
|
|
106
|
-
if (clearTimeout(u), !
|
|
107
|
-
const p = await
|
|
106
|
+
if (clearTimeout(u), !s.ok) {
|
|
107
|
+
const p = await s.text().catch(() => "Unknown error");
|
|
108
108
|
throw new c(
|
|
109
109
|
"api-call-error",
|
|
110
110
|
"apiCall",
|
|
111
|
-
`API call failed: ${
|
|
111
|
+
`API call failed: ${s.status} ${s.statusText}`,
|
|
112
112
|
{
|
|
113
|
-
status:
|
|
114
|
-
statusText:
|
|
113
|
+
status: s.status,
|
|
114
|
+
statusText: s.statusText,
|
|
115
115
|
errorText: p,
|
|
116
116
|
url: t
|
|
117
117
|
}
|
|
118
118
|
);
|
|
119
119
|
}
|
|
120
120
|
try {
|
|
121
|
-
return await
|
|
121
|
+
return await s.json();
|
|
122
122
|
} catch {
|
|
123
|
-
return await
|
|
123
|
+
return await s.text();
|
|
124
124
|
}
|
|
125
|
-
} catch (
|
|
126
|
-
throw clearTimeout(u),
|
|
125
|
+
} catch (s) {
|
|
126
|
+
throw clearTimeout(u), s instanceof c ? s : s instanceof DOMException && s.name === "AbortError" ? new c(
|
|
127
127
|
"api-call-error",
|
|
128
128
|
"apiCall",
|
|
129
129
|
`API call timed out after ${e.timeout || 1e4}ms`,
|
|
130
130
|
{ url: t, timeout: e.timeout || 1e4 }
|
|
131
|
-
) : this.isCorsError(
|
|
131
|
+
) : this.isCorsError(s, t) ? new c(
|
|
132
132
|
"api-cors-error",
|
|
133
133
|
"apiCall",
|
|
134
134
|
"Unable to connect to the external service due to security restrictions. This typically happens when the target server doesn't allow cross-origin requests from this website.",
|
|
135
135
|
{
|
|
136
136
|
url: t,
|
|
137
|
-
originalError:
|
|
137
|
+
originalError: s.message,
|
|
138
138
|
errorType: "CORS",
|
|
139
139
|
userFriendlyMessage: "The external service is not accessible from this application due to security policies.",
|
|
140
140
|
suggestedActions: [
|
|
@@ -143,13 +143,13 @@ class C {
|
|
|
143
143
|
"Check if the API endpoint URL is correct"
|
|
144
144
|
]
|
|
145
145
|
}
|
|
146
|
-
) : this.isNetworkError(
|
|
146
|
+
) : this.isNetworkError(s) ? new c(
|
|
147
147
|
"api-network-error",
|
|
148
148
|
"apiCall",
|
|
149
149
|
"Failed to connect to the external service. Please check your internet connection or try again later.",
|
|
150
150
|
{
|
|
151
151
|
url: t,
|
|
152
|
-
originalError:
|
|
152
|
+
originalError: s.message,
|
|
153
153
|
errorType: "NETWORK",
|
|
154
154
|
userFriendlyMessage: "Unable to connect to the external service. This could be due to network issues or the service being unavailable.",
|
|
155
155
|
suggestedActions: [
|
|
@@ -161,10 +161,10 @@ class C {
|
|
|
161
161
|
) : new c(
|
|
162
162
|
"api-call-error",
|
|
163
163
|
"apiCall",
|
|
164
|
-
`Network error: ${
|
|
164
|
+
`Network error: ${s.message}`,
|
|
165
165
|
{
|
|
166
166
|
url: t,
|
|
167
|
-
originalError:
|
|
167
|
+
originalError: s.message,
|
|
168
168
|
userFriendlyMessage: "An unexpected error occurred while calling the external service."
|
|
169
169
|
}
|
|
170
170
|
);
|
|
@@ -174,7 +174,7 @@ class C {
|
|
|
174
174
|
* Detects if an error is likely a CORS error
|
|
175
175
|
*/
|
|
176
176
|
isCorsError(e, r) {
|
|
177
|
-
const t = d(e) ? e.message.toLowerCase() : "",
|
|
177
|
+
const t = d(e) ? e.message.toLowerCase() : "", o = [
|
|
178
178
|
"cors",
|
|
179
179
|
"cross-origin",
|
|
180
180
|
"access to fetch",
|
|
@@ -184,8 +184,8 @@ class C {
|
|
|
184
184
|
"cors error"
|
|
185
185
|
].some(
|
|
186
186
|
(u) => t.includes(u)
|
|
187
|
-
),
|
|
188
|
-
return
|
|
187
|
+
), a = r.startsWith("http") && !r.includes(window.location.hostname), l = e instanceof TypeError && t.includes("failed to fetch") && a;
|
|
188
|
+
return o || l;
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
191
|
* Detects if an error is a network-related error (but not CORS)
|
|
@@ -202,21 +202,12 @@ class C {
|
|
|
202
202
|
"unreachable",
|
|
203
203
|
"connection failed"
|
|
204
204
|
], i = e instanceof TypeError && r.includes("failed to fetch");
|
|
205
|
-
return t.some((
|
|
205
|
+
return t.some((o) => r.includes(o)) || i;
|
|
206
206
|
}
|
|
207
207
|
applyFlattenedResponseMappings(e, r, t) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
});
|
|
212
|
-
for (const [i, s] of Object.entries(r)) {
|
|
213
|
-
const n = this.getValueFromPath(e, i), a = this.extractFieldNameFromTemplate(s);
|
|
214
|
-
console.log("📝 Field mapping:", {
|
|
215
|
-
apiField: i,
|
|
216
|
-
formFieldTemplate: s,
|
|
217
|
-
actualFieldName: a,
|
|
218
|
-
rawValue: n
|
|
219
|
-
}), t(a, n);
|
|
208
|
+
for (const [i, o] of Object.entries(r)) {
|
|
209
|
+
const a = this.getValueFromPath(e, i), l = this.extractFieldNameFromTemplate(o);
|
|
210
|
+
t(l, a);
|
|
220
211
|
}
|
|
221
212
|
}
|
|
222
213
|
/**
|
|
@@ -262,44 +253,44 @@ class C {
|
|
|
262
253
|
// }
|
|
263
254
|
buildHeaders(e, r) {
|
|
264
255
|
const t = {}, i = e.headers || e.headersConfig || [];
|
|
265
|
-
for (const
|
|
266
|
-
if (
|
|
267
|
-
const
|
|
268
|
-
|
|
256
|
+
for (const o of i)
|
|
257
|
+
if (o.key.trim() && o.value.trim()) {
|
|
258
|
+
const a = this.interpolateTemplate(
|
|
259
|
+
o.value,
|
|
269
260
|
r
|
|
270
261
|
);
|
|
271
|
-
t[
|
|
262
|
+
t[o.key] = a;
|
|
272
263
|
}
|
|
273
264
|
return t;
|
|
274
265
|
}
|
|
275
266
|
buildQueryParams(e, r) {
|
|
276
267
|
const t = new URLSearchParams(), i = e.params || e.paramsConfig || [];
|
|
277
|
-
for (const
|
|
278
|
-
if (
|
|
279
|
-
const
|
|
280
|
-
|
|
268
|
+
for (const o of i)
|
|
269
|
+
if (o.key.trim() && o.value.trim()) {
|
|
270
|
+
const a = this.interpolateTemplate(
|
|
271
|
+
o.value,
|
|
281
272
|
r
|
|
282
273
|
);
|
|
283
|
-
t.set(
|
|
274
|
+
t.set(o.key, a);
|
|
284
275
|
}
|
|
285
276
|
return t;
|
|
286
277
|
}
|
|
287
278
|
interpolateTemplate(e, r) {
|
|
288
279
|
let t = e.replace(
|
|
289
280
|
/\$\{data\.([^}]+)\}/g,
|
|
290
|
-
(i,
|
|
291
|
-
const
|
|
292
|
-
return
|
|
281
|
+
(i, o) => {
|
|
282
|
+
const a = this.getValueFromPath(r, o);
|
|
283
|
+
return a != null ? String(a) : i;
|
|
293
284
|
}
|
|
294
285
|
);
|
|
295
|
-
return t = t.replace(/\$\{([^}]+)\}/g, (i,
|
|
286
|
+
return t = t.replace(/\$\{([^}]+)\}/g, (i, o) => {
|
|
296
287
|
if (i.includes("data.")) return i;
|
|
297
|
-
if (
|
|
298
|
-
const
|
|
299
|
-
return
|
|
288
|
+
if (o.includes(".")) {
|
|
289
|
+
const l = o.split("."), u = l[l.length - 1], s = r[u];
|
|
290
|
+
return s != null ? String(s) : i;
|
|
300
291
|
}
|
|
301
|
-
const
|
|
302
|
-
return
|
|
292
|
+
const a = this.getValueFromPath(r, o);
|
|
293
|
+
return a != null ? String(a) : i;
|
|
303
294
|
}), t;
|
|
304
295
|
}
|
|
305
296
|
}
|
|
@@ -1,54 +1,50 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as e, jsxs as
|
|
2
|
+
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
3
3
|
/* empty css */
|
|
4
4
|
import { Button as N } from "../../../../../../ui/src/components/button/button.js";
|
|
5
|
-
import { Dialog as
|
|
6
|
-
import { Sheet as
|
|
7
|
-
import { memo as
|
|
5
|
+
import { Dialog as f, DialogContent as g, DialogHeader as D, DialogTitle as S, DialogDescription as T } from "../../../../../../ui/src/components/dialog/dialog.js";
|
|
6
|
+
import { Sheet as I, SheetContent as _, SheetHeader as B, SheetTitle as H } from "../../../../../../ui/src/components/sheet/sheet.js";
|
|
7
|
+
import { memo as M, useState as x } from "react";
|
|
8
8
|
import { ConfirmationDialog as $ } from "../ConfirmationDialog/ConfirmationDialog.js";
|
|
9
9
|
import { EmailVerificationDialog as b } from "../EmailVerificationDialog/EmailVerificationDialog.js";
|
|
10
|
-
import
|
|
11
|
-
const w =
|
|
12
|
-
({ config:
|
|
10
|
+
import r from "./ActionDialog.module.css.js";
|
|
11
|
+
const w = M(
|
|
12
|
+
({ config: a, formData: n, onButtonClick: s, onClose: o, isOpen: i }) => {
|
|
13
13
|
const [c, h] = x(!1);
|
|
14
|
-
if (!
|
|
15
|
-
if (
|
|
16
|
-
config: t,
|
|
17
|
-
typeId: t.templateMetadata?.typeId,
|
|
18
|
-
title: t.title
|
|
19
|
-
}), t.templateMetadata?.typeId === "verify-dialog")
|
|
14
|
+
if (!a) return null;
|
|
15
|
+
if (a.templateMetadata?.typeId === "verify-dialog")
|
|
20
16
|
return /* @__PURE__ */ e(
|
|
21
17
|
b,
|
|
22
18
|
{
|
|
23
|
-
config:
|
|
19
|
+
config: a,
|
|
24
20
|
formData: n,
|
|
25
21
|
onButtonClick: s,
|
|
26
22
|
onClose: o,
|
|
27
23
|
isOpen: i
|
|
28
24
|
}
|
|
29
25
|
);
|
|
30
|
-
if (
|
|
26
|
+
if (a.templateMetadata?.typeId === "confirmation-dialog")
|
|
31
27
|
return /* @__PURE__ */ e(
|
|
32
28
|
$,
|
|
33
29
|
{
|
|
34
|
-
config:
|
|
30
|
+
config: a,
|
|
35
31
|
formData: n,
|
|
36
32
|
onButtonClick: s,
|
|
37
33
|
onClose: o,
|
|
38
34
|
isOpen: i
|
|
39
35
|
}
|
|
40
36
|
);
|
|
41
|
-
const y = async (
|
|
37
|
+
const y = async (t) => {
|
|
42
38
|
h(!0);
|
|
43
39
|
try {
|
|
44
|
-
s(
|
|
40
|
+
s(t.action);
|
|
45
41
|
} finally {
|
|
46
42
|
h(!1);
|
|
47
43
|
}
|
|
48
44
|
}, u = () => {
|
|
49
|
-
|
|
50
|
-
}, v = (
|
|
51
|
-
switch (
|
|
45
|
+
a.dismissible !== !1 && !c && o();
|
|
46
|
+
}, v = (t) => {
|
|
47
|
+
switch (t) {
|
|
52
48
|
case "primary":
|
|
53
49
|
return "default";
|
|
54
50
|
case "secondary":
|
|
@@ -58,53 +54,53 @@ const w = H(
|
|
|
58
54
|
default:
|
|
59
55
|
return "secondary";
|
|
60
56
|
}
|
|
61
|
-
}, d =
|
|
57
|
+
}, d = a.content.replace(
|
|
62
58
|
/\$\{data\.([^}]+)\}/g,
|
|
63
|
-
(
|
|
59
|
+
(t, C) => {
|
|
64
60
|
const p = n[C];
|
|
65
|
-
return p != null ? String(p) :
|
|
61
|
+
return p != null ? String(p) : t;
|
|
66
62
|
}
|
|
67
|
-
), m = () => /* @__PURE__ */ e("div", { className:
|
|
63
|
+
), m = () => /* @__PURE__ */ e("div", { className: r.buttonRow, children: a.buttons.map((t) => /* @__PURE__ */ e(
|
|
68
64
|
N,
|
|
69
65
|
{
|
|
70
|
-
variant: v(
|
|
71
|
-
onClick: () => y(
|
|
66
|
+
variant: v(t.variant),
|
|
67
|
+
onClick: () => y(t),
|
|
72
68
|
disabled: c,
|
|
73
|
-
className:
|
|
74
|
-
children:
|
|
69
|
+
className: r.minWidthButton,
|
|
70
|
+
children: t.label
|
|
75
71
|
},
|
|
76
|
-
`${
|
|
72
|
+
`${t.label}-${t.action}`
|
|
77
73
|
)) });
|
|
78
|
-
return
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
-
/* @__PURE__ */ e("h3", { className:
|
|
74
|
+
return a.type === "toast" ? i ? /* @__PURE__ */ e("div", { className: r.toastContainer, children: /* @__PURE__ */ l("div", { className: r.toastCard, children: [
|
|
75
|
+
/* @__PURE__ */ l("div", { children: [
|
|
76
|
+
/* @__PURE__ */ e("h3", { className: r.toastTitle, children: a.title }),
|
|
81
77
|
/* @__PURE__ */ e(
|
|
82
78
|
"div",
|
|
83
79
|
{
|
|
84
|
-
className:
|
|
80
|
+
className: r.toastContent,
|
|
85
81
|
dangerouslySetInnerHTML: { __html: d }
|
|
86
82
|
}
|
|
87
83
|
)
|
|
88
84
|
] }),
|
|
89
85
|
/* @__PURE__ */ e(m, {})
|
|
90
|
-
] }) }) : null :
|
|
91
|
-
/* @__PURE__ */ e(
|
|
92
|
-
/* @__PURE__ */
|
|
86
|
+
] }) }) : null : a.type === "sidebar" ? /* @__PURE__ */ e(I, { open: i, onOpenChange: (t) => !t && u(), children: /* @__PURE__ */ l(_, { className: r.sheetContent, children: [
|
|
87
|
+
/* @__PURE__ */ e(B, { children: /* @__PURE__ */ e(H, { children: a.title }) }),
|
|
88
|
+
/* @__PURE__ */ l("div", { className: r.sheetBody, children: [
|
|
93
89
|
/* @__PURE__ */ e(
|
|
94
90
|
"div",
|
|
95
91
|
{
|
|
96
|
-
className:
|
|
92
|
+
className: r.sheetText,
|
|
97
93
|
dangerouslySetInnerHTML: { __html: d }
|
|
98
94
|
}
|
|
99
95
|
),
|
|
100
96
|
/* @__PURE__ */ e(m, {})
|
|
101
97
|
] })
|
|
102
|
-
] }) }) : /* @__PURE__ */ e(
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */ e(
|
|
105
|
-
/* @__PURE__ */ e(
|
|
98
|
+
] }) }) : /* @__PURE__ */ e(f, { open: i, onOpenChange: (t) => !t && u(), children: /* @__PURE__ */ l(g, { className: r[`size-${a.size || "medium"}`], children: [
|
|
99
|
+
/* @__PURE__ */ l(D, { children: [
|
|
100
|
+
/* @__PURE__ */ e(S, { children: a.title }),
|
|
101
|
+
/* @__PURE__ */ e(T, { asChild: !0, children: /* @__PURE__ */ e("div", { dangerouslySetInnerHTML: { __html: d } }) })
|
|
106
102
|
] }),
|
|
107
|
-
/* @__PURE__ */ e("div", { className:
|
|
103
|
+
/* @__PURE__ */ e("div", { className: r.modalButtonRow, children: /* @__PURE__ */ e(m, {}) })
|
|
108
104
|
] }) });
|
|
109
105
|
}
|
|
110
106
|
);
|
package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js
CHANGED
|
@@ -1,64 +1,60 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as e, jsxs as t, Fragment as h } from "react/jsx-runtime";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import { Button as
|
|
5
|
-
import { Dialog as
|
|
6
|
-
import { HelpCircle as
|
|
4
|
+
import { Button as f } from "../../../../../../ui/src/components/button/button.js";
|
|
5
|
+
import { Dialog as u, DialogContent as g, DialogHeader as C, DialogTitle as l, DialogDescription as c } from "../../../../../../ui/src/components/dialog/dialog.js";
|
|
6
|
+
import { HelpCircle as s, Info as N, AlertTriangle as D } from "lucide-react";
|
|
7
7
|
import { memo as v } from "react";
|
|
8
|
-
import
|
|
9
|
-
const
|
|
8
|
+
import n from "./ConfirmationDialog.module.css.js";
|
|
9
|
+
const I = v(
|
|
10
10
|
({
|
|
11
11
|
config: i,
|
|
12
|
-
formData:
|
|
13
|
-
onButtonClick:
|
|
14
|
-
onClose:
|
|
15
|
-
isOpen:
|
|
12
|
+
formData: w,
|
|
13
|
+
onButtonClick: m,
|
|
14
|
+
onClose: y,
|
|
15
|
+
isOpen: d
|
|
16
16
|
}) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
console.log("🔥 ConfirmationDialog: Button clicked with action:", n), console.log("🔥 ConfirmationDialog: Action type:", n.type), console.log(
|
|
20
|
-
"🔥 ConfirmationDialog: Action details:",
|
|
21
|
-
JSON.stringify(n, null, 2)
|
|
22
|
-
), d(n), console.log("🔥 ConfirmationDialog: onButtonClick called");
|
|
17
|
+
const o = i.templateMetadata, p = (a) => {
|
|
18
|
+
m(a);
|
|
23
19
|
}, r = (() => {
|
|
24
|
-
if (!
|
|
25
|
-
switch (
|
|
20
|
+
if (!o?.showIcon) return null;
|
|
21
|
+
switch (o?.iconType) {
|
|
26
22
|
case "warning":
|
|
27
|
-
return /* @__PURE__ */
|
|
23
|
+
return /* @__PURE__ */ e(D, { className: n.iconWarning });
|
|
28
24
|
case "question":
|
|
29
|
-
return /* @__PURE__ */
|
|
25
|
+
return /* @__PURE__ */ e(s, { className: n.iconInfo });
|
|
30
26
|
case "info":
|
|
31
|
-
return /* @__PURE__ */
|
|
27
|
+
return /* @__PURE__ */ e(N, { className: n.iconInfo });
|
|
32
28
|
default:
|
|
33
|
-
return /* @__PURE__ */
|
|
29
|
+
return /* @__PURE__ */ e(s, { className: n.iconInfo });
|
|
34
30
|
}
|
|
35
31
|
})();
|
|
36
|
-
return /* @__PURE__ */
|
|
37
|
-
/* @__PURE__ */
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
/* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ e(u, { open: d, onOpenChange: () => !1, children: /* @__PURE__ */ t(g, { className: n.dialogContent, children: [
|
|
33
|
+
/* @__PURE__ */ e(C, { children: r ? /* @__PURE__ */ t("div", { className: n.iconRow, children: [
|
|
34
|
+
/* @__PURE__ */ e("div", { className: n.iconCircle, children: r }),
|
|
35
|
+
/* @__PURE__ */ t("div", { children: [
|
|
36
|
+
/* @__PURE__ */ e(l, { children: i.title }),
|
|
37
|
+
/* @__PURE__ */ e(c, { className: n.descriptionSpaced, children: i.content })
|
|
42
38
|
] })
|
|
43
|
-
] }) : /* @__PURE__ */
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
/* @__PURE__ */
|
|
39
|
+
] }) : /* @__PURE__ */ t(h, { children: [
|
|
40
|
+
/* @__PURE__ */ e(l, { children: i.title }),
|
|
41
|
+
/* @__PURE__ */ e(c, { children: i.content })
|
|
46
42
|
] }) }),
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
|
|
43
|
+
/* @__PURE__ */ e("div", { className: n.buttonRow, children: i.buttons.map((a) => /* @__PURE__ */ e(
|
|
44
|
+
f,
|
|
49
45
|
{
|
|
50
|
-
variant:
|
|
51
|
-
onClick: () =>
|
|
52
|
-
className:
|
|
53
|
-
children:
|
|
46
|
+
variant: a.variant === "danger" ? "destructive" : a.variant === "secondary" ? "outline" : "default",
|
|
47
|
+
onClick: () => p(a.action),
|
|
48
|
+
className: n.minWidthButton,
|
|
49
|
+
children: a.label
|
|
54
50
|
},
|
|
55
|
-
|
|
51
|
+
a.id
|
|
56
52
|
)) })
|
|
57
53
|
] }) });
|
|
58
54
|
}
|
|
59
55
|
);
|
|
60
|
-
|
|
56
|
+
I.displayName = "ConfirmationDialog";
|
|
61
57
|
export {
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
I as ConfirmationDialog,
|
|
59
|
+
I as default
|
|
64
60
|
};
|