enefit-design-system 0.9.2-ds.2 → 0.9.2-ds.4
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/dist/DsForm/fields.js +149 -136
- package/dist/DsForm/utils.js +28 -21
- package/dist/DsStepper/DsStepper.js +42 -41
- package/package.json +1 -1
package/dist/DsForm/fields.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as
|
|
2
|
+
import { jsx as l, jsxs as x, Fragment as k } from "react/jsx-runtime";
|
|
3
|
+
import { useState as C, useRef as w } from "react";
|
|
4
4
|
/* empty css */
|
|
5
5
|
/* empty css */
|
|
6
6
|
/* empty css */
|
|
@@ -98,34 +98,34 @@ import "../Card/CardBody.js";
|
|
|
98
98
|
import "../Card/CardFooter.js";
|
|
99
99
|
import "../FileUpload/FileUpload.js";
|
|
100
100
|
import "../FormFields/FormFields.js";
|
|
101
|
-
import { useRevealContext as
|
|
101
|
+
import { useRevealContext as d } from "./RevealContext.js";
|
|
102
102
|
function v(e, n) {
|
|
103
103
|
const {
|
|
104
|
-
required:
|
|
105
|
-
read_only:
|
|
104
|
+
required: o,
|
|
105
|
+
read_only: r,
|
|
106
106
|
default_value: i,
|
|
107
107
|
default_selected_value: a,
|
|
108
|
-
validation_pattern:
|
|
108
|
+
validation_pattern: s,
|
|
109
109
|
__component: p,
|
|
110
110
|
type: m,
|
|
111
|
-
layout:
|
|
111
|
+
layout: t,
|
|
112
112
|
values: u,
|
|
113
113
|
items: b,
|
|
114
114
|
reveal: c,
|
|
115
|
-
select_name:
|
|
116
|
-
selectItems:
|
|
115
|
+
select_name: h,
|
|
116
|
+
selectItems: g,
|
|
117
117
|
selectDefaultSelectedKey: ae,
|
|
118
118
|
selectPlaceholder: ie,
|
|
119
119
|
choice_type: ue,
|
|
120
120
|
heading: se,
|
|
121
|
-
body:
|
|
122
|
-
severity:
|
|
121
|
+
body: me,
|
|
122
|
+
severity: le,
|
|
123
123
|
link_title: pe,
|
|
124
124
|
link_url: ce,
|
|
125
125
|
accept: ve,
|
|
126
|
-
rows:
|
|
127
|
-
suffix:
|
|
128
|
-
infoHint:
|
|
126
|
+
rows: he,
|
|
127
|
+
suffix: ge,
|
|
128
|
+
infoHint: de,
|
|
129
129
|
title: Ce,
|
|
130
130
|
size: R,
|
|
131
131
|
variant: fe,
|
|
@@ -138,81 +138,81 @@ function v(e, n) {
|
|
|
138
138
|
// if/when a renderer needs to honour a per-field override.
|
|
139
139
|
labelSuffix: be,
|
|
140
140
|
...D
|
|
141
|
-
} = e, { value: F, errorMessage: Ve, ...
|
|
142
|
-
...
|
|
143
|
-
required:
|
|
144
|
-
readOnly:
|
|
141
|
+
} = e, { value: F, errorMessage: Ve, ...T } = D, V = {
|
|
142
|
+
...T,
|
|
143
|
+
required: o,
|
|
144
|
+
readOnly: r,
|
|
145
145
|
size: R ?? n
|
|
146
146
|
};
|
|
147
147
|
return F !== void 0 ? V.value = F : i !== void 0 && (V.defaultValue = i), V;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
const { controllableNames: n } =
|
|
149
|
+
function f(e) {
|
|
150
|
+
const { controllableNames: n } = d();
|
|
151
151
|
return !!e.name && n.has(e.name);
|
|
152
152
|
}
|
|
153
|
-
function
|
|
154
|
-
const n =
|
|
155
|
-
n && e.name ?
|
|
153
|
+
function _(e) {
|
|
154
|
+
const n = f(e), { revealCache: o, onRevealCache: r } = d(), i = w(
|
|
155
|
+
n && e.name ? o[e.name] : void 0
|
|
156
156
|
);
|
|
157
157
|
if (!n || !e.name) return {};
|
|
158
158
|
const a = e.name;
|
|
159
159
|
return {
|
|
160
160
|
defaultValue: i.current,
|
|
161
|
-
onChange: (
|
|
161
|
+
onChange: (s) => r(a, s)
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
164
|
function M({ field: e }) {
|
|
165
|
-
const n = v(e),
|
|
166
|
-
if (!(!a || !a.trim()) &&
|
|
165
|
+
const n = v(e), o = _(e), r = e.validation_pattern ? new RegExp(e.validation_pattern) : void 0, i = (a) => {
|
|
166
|
+
if (!(!a || !a.trim()) && r && !r.test(a.trim()))
|
|
167
167
|
return " ";
|
|
168
168
|
};
|
|
169
|
-
return /* @__PURE__ */
|
|
169
|
+
return /* @__PURE__ */ l(
|
|
170
170
|
y,
|
|
171
171
|
{
|
|
172
172
|
...n,
|
|
173
|
-
defaultValue:
|
|
174
|
-
onChange:
|
|
173
|
+
defaultValue: o.defaultValue ?? n.defaultValue,
|
|
174
|
+
onChange: o.onChange ? (a) => o.onChange?.(a) : void 0,
|
|
175
175
|
validate: i
|
|
176
176
|
}
|
|
177
177
|
);
|
|
178
178
|
}
|
|
179
179
|
function O({ field: e }) {
|
|
180
|
-
const n = v(e),
|
|
181
|
-
return /* @__PURE__ */
|
|
180
|
+
const n = v(e), o = _(e);
|
|
181
|
+
return /* @__PURE__ */ l(
|
|
182
182
|
y,
|
|
183
183
|
{
|
|
184
184
|
type: "email",
|
|
185
185
|
autoComplete: "email",
|
|
186
186
|
...n,
|
|
187
|
-
defaultValue:
|
|
188
|
-
onChange:
|
|
187
|
+
defaultValue: o.defaultValue ?? n.defaultValue,
|
|
188
|
+
onChange: o.onChange ? (r) => o.onChange?.(r) : void 0
|
|
189
189
|
}
|
|
190
190
|
);
|
|
191
191
|
}
|
|
192
192
|
function U({ field: e }) {
|
|
193
|
-
const n = v(e),
|
|
194
|
-
return /* @__PURE__ */
|
|
193
|
+
const n = v(e), o = _(e);
|
|
194
|
+
return /* @__PURE__ */ l(
|
|
195
195
|
K,
|
|
196
196
|
{
|
|
197
197
|
...n,
|
|
198
198
|
rows: e.rows,
|
|
199
|
-
defaultValue:
|
|
200
|
-
onChange:
|
|
199
|
+
defaultValue: o.defaultValue ?? n.defaultValue,
|
|
200
|
+
onChange: o.onChange ? (r) => o.onChange?.(r) : void 0
|
|
201
201
|
}
|
|
202
202
|
);
|
|
203
203
|
}
|
|
204
204
|
function $({ field: e, context: n }) {
|
|
205
|
-
const
|
|
205
|
+
const o = v(e), r = _(e), i = e.validation_pattern ? new RegExp(e.validation_pattern) : /^[\d\s\-+()]+$/, a = (p) => {
|
|
206
206
|
if (p && !i.test(p))
|
|
207
207
|
return " ";
|
|
208
|
-
},
|
|
209
|
-
return /* @__PURE__ */
|
|
208
|
+
}, s = n?.phoneCountries;
|
|
209
|
+
return /* @__PURE__ */ l(
|
|
210
210
|
z,
|
|
211
211
|
{
|
|
212
|
-
...
|
|
213
|
-
defaultValue:
|
|
214
|
-
onChange:
|
|
215
|
-
countries: e.selectItems ??
|
|
212
|
+
...o,
|
|
213
|
+
defaultValue: r.defaultValue ?? o.defaultValue,
|
|
214
|
+
onChange: r.onChange ? (p) => r.onChange?.(p) : void 0,
|
|
215
|
+
countries: e.selectItems ?? s,
|
|
216
216
|
defaultCountry: e.selectDefaultSelectedKey,
|
|
217
217
|
countriesName: e.select_name,
|
|
218
218
|
validate: a
|
|
@@ -220,158 +220,171 @@ function $({ field: e, context: n }) {
|
|
|
220
220
|
);
|
|
221
221
|
}
|
|
222
222
|
function B({ field: e }) {
|
|
223
|
-
const n = v(e),
|
|
224
|
-
if (!(!a || !a.trim()) && !
|
|
223
|
+
const n = v(e), o = _(e), r = e.validation_pattern ? new RegExp(e.validation_pattern) : /^\d{6,20}$/, i = (a) => {
|
|
224
|
+
if (!(!a || !a.trim()) && !r.test(a.trim()))
|
|
225
225
|
return " ";
|
|
226
226
|
};
|
|
227
|
-
return /* @__PURE__ */
|
|
227
|
+
return /* @__PURE__ */ l(
|
|
228
228
|
y,
|
|
229
229
|
{
|
|
230
230
|
...n,
|
|
231
|
-
defaultValue:
|
|
232
|
-
onChange:
|
|
231
|
+
defaultValue: o.defaultValue ?? n.defaultValue,
|
|
232
|
+
onChange: o.onChange ? (a) => o.onChange?.(a) : void 0,
|
|
233
233
|
validate: i
|
|
234
234
|
}
|
|
235
235
|
);
|
|
236
236
|
}
|
|
237
237
|
function J({ field: e }) {
|
|
238
|
-
const n = v(e), { triggerValues:
|
|
238
|
+
const n = v(e), { triggerValues: o, revealCache: r, onTriggerChange: i, onRevealCache: a } = d(), s = f(e), [p] = C(() => {
|
|
239
239
|
if (!e.name) return e.default_selected_value;
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
if (
|
|
243
|
-
const u =
|
|
240
|
+
const t = o[e.name];
|
|
241
|
+
if (t !== void 0) return t;
|
|
242
|
+
if (s) {
|
|
243
|
+
const u = r[e.name];
|
|
244
244
|
if (u !== void 0) return u;
|
|
245
245
|
}
|
|
246
246
|
return e.default_selected_value;
|
|
247
|
-
}), m = (e.values ?? []).map((
|
|
248
|
-
value:
|
|
249
|
-
label:
|
|
247
|
+
}), m = (e.values ?? []).map((t) => ({
|
|
248
|
+
value: t.value,
|
|
249
|
+
label: t.title
|
|
250
250
|
}));
|
|
251
|
-
return /* @__PURE__ */
|
|
251
|
+
return /* @__PURE__ */ l(
|
|
252
252
|
j,
|
|
253
253
|
{
|
|
254
254
|
...n,
|
|
255
255
|
defaultValue: p,
|
|
256
256
|
items: m,
|
|
257
257
|
placeholder: e.placeholder,
|
|
258
|
-
onChange: (
|
|
259
|
-
e.name && (i(e.name,
|
|
258
|
+
onChange: (t) => {
|
|
259
|
+
e.name && (i(e.name, t), s && a(e.name, t));
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
);
|
|
263
263
|
}
|
|
264
264
|
function Q({ field: e }) {
|
|
265
|
-
const n = v(e), { triggerValues:
|
|
265
|
+
const n = v(e), { triggerValues: o, revealCache: r, onTriggerChange: i, onRevealCache: a } = d(), s = !!e.reveal, p = f(e), [m] = C(() => {
|
|
266
266
|
if (!e.name) return !!e.default_value;
|
|
267
|
-
if (
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
267
|
+
if (s) {
|
|
268
|
+
const t = o[e.name];
|
|
269
|
+
if (t !== void 0) return t;
|
|
270
270
|
}
|
|
271
271
|
if (p) {
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
272
|
+
const t = r[e.name];
|
|
273
|
+
if (t !== void 0) return t;
|
|
274
274
|
}
|
|
275
275
|
return !!e.default_value;
|
|
276
276
|
});
|
|
277
|
-
return /* @__PURE__ */
|
|
277
|
+
return /* @__PURE__ */ l(
|
|
278
278
|
S,
|
|
279
279
|
{
|
|
280
280
|
...n,
|
|
281
281
|
label: e.label,
|
|
282
282
|
defaultChecked: m,
|
|
283
|
-
onChange: (
|
|
284
|
-
e.name && (
|
|
283
|
+
onChange: (t) => {
|
|
284
|
+
e.name && (s && i(e.name, t), p && a(e.name, t));
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
);
|
|
288
288
|
}
|
|
289
289
|
function W({ field: e }) {
|
|
290
|
-
const n = v(e), { triggerValues:
|
|
290
|
+
const n = v(e), { triggerValues: o, revealCache: r, onTriggerChange: i, onRevealCache: a } = d(), s = f(e), [p] = C(() => {
|
|
291
291
|
if (!e.name)
|
|
292
292
|
return e.default_value ? [e.default_value] : void 0;
|
|
293
|
-
const
|
|
294
|
-
if (
|
|
295
|
-
if (
|
|
296
|
-
const u =
|
|
293
|
+
const t = o[e.name];
|
|
294
|
+
if (t !== void 0) return t;
|
|
295
|
+
if (s) {
|
|
296
|
+
const u = r[e.name];
|
|
297
297
|
if (u !== void 0) return u;
|
|
298
298
|
}
|
|
299
299
|
return e.default_value ? [e.default_value] : void 0;
|
|
300
|
-
}), m = (e.items ?? []).map((
|
|
301
|
-
value:
|
|
302
|
-
label:
|
|
303
|
-
description:
|
|
300
|
+
}), m = (e.items ?? []).map((t) => ({
|
|
301
|
+
value: t.value ?? t.label,
|
|
302
|
+
label: t.label,
|
|
303
|
+
description: t.description
|
|
304
304
|
}));
|
|
305
|
-
return /* @__PURE__ */
|
|
305
|
+
return /* @__PURE__ */ l(
|
|
306
306
|
L,
|
|
307
307
|
{
|
|
308
308
|
...n,
|
|
309
309
|
defaultValue: p,
|
|
310
310
|
items: m,
|
|
311
|
-
onChange: (
|
|
312
|
-
e.name && (i(e.name,
|
|
311
|
+
onChange: (t) => {
|
|
312
|
+
e.name && (i(e.name, t), s && a(e.name, t));
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
);
|
|
316
316
|
}
|
|
317
317
|
function X({ field: e }) {
|
|
318
|
-
const n = v(e), { triggerValues:
|
|
318
|
+
const n = v(e), { triggerValues: o, revealCache: r, onTriggerChange: i, onRevealCache: a } = d(), s = f(e), [p] = C(() => {
|
|
319
319
|
if (!e.name) return e.default_value;
|
|
320
|
-
const
|
|
321
|
-
if (
|
|
322
|
-
if (
|
|
323
|
-
const u =
|
|
320
|
+
const t = o[e.name];
|
|
321
|
+
if (t !== void 0) return t;
|
|
322
|
+
if (s) {
|
|
323
|
+
const u = r[e.name];
|
|
324
324
|
if (u !== void 0) return u;
|
|
325
325
|
}
|
|
326
326
|
return e.default_value;
|
|
327
|
-
}), m = (e.items ?? []).map((
|
|
328
|
-
value:
|
|
329
|
-
label:
|
|
330
|
-
description:
|
|
327
|
+
}), m = (e.items ?? []).map((t) => ({
|
|
328
|
+
value: t.value ?? "",
|
|
329
|
+
label: t.label,
|
|
330
|
+
description: t.description
|
|
331
331
|
}));
|
|
332
|
-
return /* @__PURE__ */
|
|
332
|
+
return /* @__PURE__ */ l(
|
|
333
333
|
P,
|
|
334
334
|
{
|
|
335
335
|
...n,
|
|
336
336
|
name: e.name ?? "",
|
|
337
337
|
defaultValue: p,
|
|
338
338
|
items: m,
|
|
339
|
-
onChange: (
|
|
340
|
-
e.name && (i(e.name,
|
|
339
|
+
onChange: (t) => {
|
|
340
|
+
e.name && (i(e.name, t), s && a(e.name, t));
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
);
|
|
344
344
|
}
|
|
345
345
|
function Y({ field: e }) {
|
|
346
|
-
const n = v(e), r = (e
|
|
346
|
+
const n = v(e), { triggerValues: o, revealCache: r, onTriggerChange: i, onRevealCache: a } = d(), s = f(e), [p] = C(() => {
|
|
347
|
+
if (!e.name)
|
|
348
|
+
return e.default_value ? [e.default_value] : void 0;
|
|
349
|
+
const t = o[e.name];
|
|
350
|
+
if (t !== void 0) return t;
|
|
351
|
+
if (s) {
|
|
352
|
+
const u = r[e.name];
|
|
353
|
+
if (u !== void 0) return u;
|
|
354
|
+
}
|
|
355
|
+
return e.default_value ? [e.default_value] : void 0;
|
|
356
|
+
}), m = (e.items ?? []).map((t) => ({
|
|
347
357
|
value: t.value ?? "",
|
|
348
358
|
label: t.label,
|
|
349
359
|
description: t.description
|
|
350
360
|
}));
|
|
351
|
-
return /* @__PURE__ */
|
|
361
|
+
return /* @__PURE__ */ l(
|
|
352
362
|
G,
|
|
353
363
|
{
|
|
354
364
|
...n,
|
|
355
365
|
name: e.name ?? "",
|
|
356
|
-
defaultValue:
|
|
366
|
+
defaultValue: p,
|
|
357
367
|
layout: e.layout === "one_column" ? "column" : "row",
|
|
358
|
-
items:
|
|
368
|
+
items: m,
|
|
369
|
+
onChange: (t) => {
|
|
370
|
+
e.name && (i(e.name, t), s && a(e.name, t));
|
|
371
|
+
}
|
|
359
372
|
}
|
|
360
373
|
);
|
|
361
374
|
}
|
|
362
375
|
function Z({ field: e }) {
|
|
363
|
-
const n = v(e),
|
|
364
|
-
return /* @__PURE__ */
|
|
376
|
+
const n = v(e), o = _(e);
|
|
377
|
+
return /* @__PURE__ */ l(
|
|
365
378
|
E,
|
|
366
379
|
{
|
|
367
380
|
...n,
|
|
368
|
-
defaultValue:
|
|
369
|
-
onChange:
|
|
381
|
+
defaultValue: o.defaultValue ?? n.defaultValue,
|
|
382
|
+
onChange: o.onChange ? (r) => o.onChange?.(r) : void 0
|
|
370
383
|
}
|
|
371
384
|
);
|
|
372
385
|
}
|
|
373
386
|
function ee({ field: e }) {
|
|
374
|
-
return e.name ? /* @__PURE__ */
|
|
387
|
+
return e.name ? /* @__PURE__ */ l(
|
|
375
388
|
"input",
|
|
376
389
|
{
|
|
377
390
|
type: "hidden",
|
|
@@ -381,51 +394,51 @@ function ee({ field: e }) {
|
|
|
381
394
|
) : null;
|
|
382
395
|
}
|
|
383
396
|
function te({ field: e, context: n }) {
|
|
384
|
-
const [
|
|
397
|
+
const [o, r] = C([]), i = o.filter((m) => m.status === "done" && m.url).map((m) => m.url).join(`
|
|
385
398
|
|
|
386
|
-
`), a = n,
|
|
387
|
-
const
|
|
388
|
-
for (const u of
|
|
399
|
+
`), a = n, s = async (m) => {
|
|
400
|
+
const t = Array.from(m);
|
|
401
|
+
for (const u of t) {
|
|
389
402
|
const b = a?.onFileValidate?.(u);
|
|
390
403
|
if (b) {
|
|
391
|
-
|
|
404
|
+
r((c) => [
|
|
392
405
|
...c,
|
|
393
406
|
{ file: u, status: "error", error: b }
|
|
394
407
|
]);
|
|
395
408
|
continue;
|
|
396
409
|
}
|
|
397
|
-
if (
|
|
398
|
-
|
|
410
|
+
if (r((c) => [...c, { file: u, status: "uploading" }]), !a?.onFileUpload) {
|
|
411
|
+
r(
|
|
399
412
|
(c) => c.map(
|
|
400
|
-
(
|
|
413
|
+
(h) => h.file === u ? { ...h, status: "done" } : h
|
|
401
414
|
)
|
|
402
415
|
);
|
|
403
416
|
continue;
|
|
404
417
|
}
|
|
405
418
|
try {
|
|
406
419
|
const c = await a.onFileUpload(u);
|
|
407
|
-
|
|
408
|
-
(
|
|
409
|
-
(
|
|
420
|
+
r(
|
|
421
|
+
(h) => h.map(
|
|
422
|
+
(g) => g.file === u ? { ...g, status: "done", url: c } : g
|
|
410
423
|
)
|
|
411
424
|
);
|
|
412
425
|
} catch (c) {
|
|
413
|
-
|
|
414
|
-
(
|
|
415
|
-
(
|
|
416
|
-
...
|
|
426
|
+
r(
|
|
427
|
+
(h) => h.map(
|
|
428
|
+
(g) => g.file === u ? {
|
|
429
|
+
...g,
|
|
417
430
|
status: "error",
|
|
418
431
|
error: c instanceof Error ? c.message : String(c)
|
|
419
|
-
} :
|
|
432
|
+
} : g
|
|
420
433
|
)
|
|
421
434
|
);
|
|
422
435
|
}
|
|
423
436
|
}
|
|
424
437
|
}, p = (m) => {
|
|
425
|
-
|
|
438
|
+
r((t) => t.filter((u) => u.file !== m));
|
|
426
439
|
};
|
|
427
|
-
return /* @__PURE__ */ x(
|
|
428
|
-
/* @__PURE__ */
|
|
440
|
+
return /* @__PURE__ */ x(k, { children: [
|
|
441
|
+
/* @__PURE__ */ l(
|
|
429
442
|
N,
|
|
430
443
|
{
|
|
431
444
|
label: e.label,
|
|
@@ -435,31 +448,31 @@ function te({ field: e, context: n }) {
|
|
|
435
448
|
required: e.required,
|
|
436
449
|
readOnly: e.read_only,
|
|
437
450
|
size: e.size,
|
|
438
|
-
onAddFiles:
|
|
451
|
+
onAddFiles: s,
|
|
439
452
|
onRemoveFile: p
|
|
440
453
|
}
|
|
441
454
|
),
|
|
442
|
-
e.name ? /* @__PURE__ */
|
|
455
|
+
e.name ? /* @__PURE__ */ l("input", { type: "hidden", name: e.name, value: i }) : null
|
|
443
456
|
] });
|
|
444
457
|
}
|
|
445
458
|
function oe({ field: e, context: n }) {
|
|
446
|
-
const
|
|
447
|
-
return /* @__PURE__ */
|
|
459
|
+
const o = v(e), r = n;
|
|
460
|
+
return /* @__PURE__ */ l(
|
|
448
461
|
I,
|
|
449
462
|
{
|
|
450
|
-
...
|
|
463
|
+
...o,
|
|
451
464
|
placeholder: e.placeholder,
|
|
452
|
-
onSearch:
|
|
453
|
-
loadingLabel: e.loadingLabel ??
|
|
454
|
-
emptyLabel: e.emptyLabel ??
|
|
455
|
-
errorLabel: e.errorLabel ??
|
|
465
|
+
onSearch: r?.onAddressSearch,
|
|
466
|
+
loadingLabel: e.loadingLabel ?? r?.loadingLabel,
|
|
467
|
+
emptyLabel: e.emptyLabel ?? r?.emptyLabel,
|
|
468
|
+
errorLabel: e.errorLabel ?? r?.errorLabel,
|
|
456
469
|
allowsCustomValue: !0
|
|
457
470
|
}
|
|
458
471
|
);
|
|
459
472
|
}
|
|
460
473
|
function re({ field: e }) {
|
|
461
474
|
return /* @__PURE__ */ x("div", { className: "ds-form__heading", children: [
|
|
462
|
-
e.heading ? /* @__PURE__ */
|
|
475
|
+
e.heading ? /* @__PURE__ */ l(
|
|
463
476
|
A,
|
|
464
477
|
{
|
|
465
478
|
variant: e.variant ?? "h5",
|
|
@@ -467,21 +480,21 @@ function re({ field: e }) {
|
|
|
467
480
|
children: e.heading
|
|
468
481
|
}
|
|
469
482
|
) : null,
|
|
470
|
-
e.body ? /* @__PURE__ */
|
|
483
|
+
e.body ? /* @__PURE__ */ l(q, { as: "div", children: e.body }) : null
|
|
471
484
|
] });
|
|
472
485
|
}
|
|
473
486
|
function ne({
|
|
474
487
|
field: e,
|
|
475
488
|
linkComponent: n
|
|
476
489
|
}) {
|
|
477
|
-
const
|
|
478
|
-
return /* @__PURE__ */
|
|
490
|
+
const o = e.severity === "notify" ? "info" : e.severity, r = e.link_title && e.link_url ? n ? n(e.link_url, e.link_title) : /* @__PURE__ */ l("a", { href: e.link_url, children: e.link_title }) : void 0;
|
|
491
|
+
return /* @__PURE__ */ l(
|
|
479
492
|
H,
|
|
480
493
|
{
|
|
481
|
-
variant:
|
|
494
|
+
variant: o,
|
|
482
495
|
title: e.title,
|
|
483
496
|
description: e.description,
|
|
484
|
-
children:
|
|
497
|
+
children: r
|
|
485
498
|
}
|
|
486
499
|
);
|
|
487
500
|
}
|
package/dist/DsForm/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function c(t) {
|
|
2
2
|
return t ? t.trim().split(/[\s,;]+/).filter(Boolean) : [];
|
|
3
3
|
}
|
|
4
4
|
function l(t) {
|
|
@@ -6,42 +6,49 @@ function l(t) {
|
|
|
6
6
|
if (!Array.isArray(t)) return a;
|
|
7
7
|
for (const e of t)
|
|
8
8
|
e.items?.forEach((r) => {
|
|
9
|
-
|
|
9
|
+
c(r.reveal).forEach((n) => a.add(n));
|
|
10
10
|
}), e.values?.forEach((r) => {
|
|
11
|
-
|
|
12
|
-
}), e.type === "checkbox" &&
|
|
11
|
+
c(r.reveal).forEach((n) => a.add(n));
|
|
12
|
+
}), e.type === "checkbox" && c(e.reveal).forEach((r) => a.add(r));
|
|
13
13
|
return a;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function p(t, a) {
|
|
16
16
|
if (!Array.isArray(t)) return /* @__PURE__ */ new Set();
|
|
17
17
|
const e = t.filter((r) => r.name).flatMap((r) => {
|
|
18
18
|
const n = a[r.name];
|
|
19
19
|
if (r.type === "radio-group") {
|
|
20
|
-
const
|
|
21
|
-
return s
|
|
20
|
+
const s = r.items?.find((u) => u.value === n);
|
|
21
|
+
return c(s?.reveal);
|
|
22
22
|
}
|
|
23
23
|
if (r.type === "select") {
|
|
24
|
-
const
|
|
25
|
-
return s
|
|
24
|
+
const s = r.values?.find((u) => u.value === n);
|
|
25
|
+
return c(s?.reveal);
|
|
26
26
|
}
|
|
27
27
|
if (r.type === "checkbox-group") {
|
|
28
|
-
const
|
|
28
|
+
const s = Array.isArray(n) ? n : [];
|
|
29
29
|
return (r.items ?? []).filter((u) => {
|
|
30
|
-
const
|
|
31
|
-
return
|
|
32
|
-
}).flatMap((u) =>
|
|
30
|
+
const o = u.value ?? u.label;
|
|
31
|
+
return o && s.includes(o);
|
|
32
|
+
}).flatMap((u) => c(u.reveal));
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
if (r.type === "choice-group") {
|
|
35
|
+
const s = Array.isArray(n) ? n : [];
|
|
36
|
+
return (r.items ?? []).filter((u) => {
|
|
37
|
+
const o = u.value ?? u.label;
|
|
38
|
+
return o && s.includes(o);
|
|
39
|
+
}).flatMap((u) => c(u.reveal));
|
|
40
|
+
}
|
|
41
|
+
return r.type === "checkbox" && n ? c(r.reveal) : [];
|
|
35
42
|
});
|
|
36
43
|
return new Set(e);
|
|
37
44
|
}
|
|
38
|
-
function
|
|
45
|
+
function i(t, a, e) {
|
|
39
46
|
return !t.name || !a.has(t.name) ? !0 : e.has(t.name);
|
|
40
47
|
}
|
|
41
48
|
function v(t) {
|
|
42
|
-
return Array.isArray(t) ? t.filter((a) => a.name).reduce((a, e) => (e.type === "radio-group" && e.default_value !== void 0 ? a[e.name] = e.default_value : e.type === "select" && e.default_selected_value !== void 0 ? a[e.name] = e.default_selected_value : e.type === "checkbox" && e.default_value !== void 0 ? a[e.name] = !!e.default_value : e.type === "checkbox-group" && e.default_value !== void 0 && (a[e.name] = [e.default_value]), a), {}) : {};
|
|
49
|
+
return Array.isArray(t) ? t.filter((a) => a.name).reduce((a, e) => (e.type === "radio-group" && e.default_value !== void 0 ? a[e.name] = e.default_value : e.type === "select" && e.default_selected_value !== void 0 ? a[e.name] = e.default_selected_value : e.type === "checkbox" && e.default_value !== void 0 ? a[e.name] = !!e.default_value : e.type === "checkbox-group" && e.default_value !== void 0 ? a[e.name] = [e.default_value] : e.type === "choice-group" && e.default_value !== void 0 && (a[e.name] = [e.default_value]), a), {}) : {};
|
|
43
50
|
}
|
|
44
|
-
function
|
|
51
|
+
function y(t) {
|
|
45
52
|
if (!t || !Array.isArray(t))
|
|
46
53
|
return { steps: null, fields: t || [] };
|
|
47
54
|
if (!t.some((n) => n.type === "step"))
|
|
@@ -58,9 +65,9 @@ function f(t) {
|
|
|
58
65
|
}
|
|
59
66
|
export {
|
|
60
67
|
l as collectControllableNames,
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
p as getRevealedNames,
|
|
69
|
+
y as groupFields,
|
|
63
70
|
v as initialTriggerValues,
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
i as isFieldVisible,
|
|
72
|
+
c as parseRevealNames
|
|
66
73
|
};
|
|
@@ -1,89 +1,90 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as n, jsx as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
2
|
+
import { jsxs as n, jsx as t, Fragment as D } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as F, useRef as T, useEffect as $ } from "react";
|
|
4
|
+
import q from "../output/icons/IconCheckXs.js";
|
|
5
|
+
import C from "../output/icons/IconCheckSm.js";
|
|
6
|
+
import { cn as b } from "../utils/dsClass.js";
|
|
6
7
|
/* empty css */
|
|
7
|
-
function
|
|
8
|
-
return r <
|
|
8
|
+
function E(r, s) {
|
|
9
|
+
return r < s ? "completed" : r === s ? "active" : "upcoming";
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
11
|
+
function H(r, s, i) {
|
|
12
|
+
return s ? !!(r === "completed" && i) : !1;
|
|
12
13
|
}
|
|
13
|
-
const K =
|
|
14
|
+
const K = F(
|
|
14
15
|
function({
|
|
15
|
-
items:
|
|
16
|
+
items: s,
|
|
16
17
|
value: i,
|
|
17
18
|
onChange: p,
|
|
18
|
-
allowPrevStepSelect:
|
|
19
|
+
allowPrevStepSelect: v = !1,
|
|
19
20
|
focusOnActiveChange: d = !1,
|
|
20
21
|
size: u = "default",
|
|
21
|
-
ariaLabels:
|
|
22
|
+
ariaLabels: m,
|
|
22
23
|
className: N,
|
|
23
|
-
...
|
|
24
|
-
},
|
|
25
|
-
const I =
|
|
26
|
-
|
|
24
|
+
...k
|
|
25
|
+
}, x) {
|
|
26
|
+
const I = m?.nav ?? "Steps", S = m?.completed ?? "completed", o = Math.max(0, s.findIndex((e) => e.value === i)), g = u === "small" ? "small" : "default", f = T(null);
|
|
27
|
+
$(() => {
|
|
27
28
|
if (!d) return;
|
|
28
|
-
const e =
|
|
29
|
+
const e = f.current;
|
|
29
30
|
if (!e) return;
|
|
30
31
|
(e.querySelector(
|
|
31
32
|
"button, [tabindex]"
|
|
32
33
|
) ?? e).focus();
|
|
33
34
|
}, [o, d]);
|
|
34
|
-
const l =
|
|
35
|
+
const l = s[o];
|
|
35
36
|
return /* @__PURE__ */ n(
|
|
36
37
|
"nav",
|
|
37
38
|
{
|
|
38
|
-
ref:
|
|
39
|
+
ref: x,
|
|
39
40
|
"aria-label": I,
|
|
40
|
-
className:
|
|
41
|
+
className: b(
|
|
41
42
|
"ds-stepper",
|
|
42
43
|
u === "small" && "ds-stepper--small",
|
|
43
44
|
N
|
|
44
45
|
),
|
|
45
|
-
...
|
|
46
|
+
...k,
|
|
46
47
|
children: [
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
const a =
|
|
48
|
+
/* @__PURE__ */ t("ol", { className: "ds-stepper__list", children: s.map((e, c) => {
|
|
49
|
+
const a = E(c, o), w = e.disabled ?? !1, y = s.slice(c + 1).every((j) => j.disabled), h = H(
|
|
49
50
|
a,
|
|
50
51
|
p,
|
|
51
|
-
|
|
52
|
-
),
|
|
53
|
-
/* @__PURE__ */
|
|
52
|
+
v
|
|
53
|
+
), L = a === "completed" ? g === "small" ? /* @__PURE__ */ t(q, { "aria-hidden": !0, width: 16, height: 16 }) : /* @__PURE__ */ t(C, { "aria-hidden": !0, width: 24, height: 24 }) : c + 1, _ = /* @__PURE__ */ n(D, { children: [
|
|
54
|
+
/* @__PURE__ */ t(
|
|
54
55
|
"span",
|
|
55
56
|
{
|
|
56
57
|
className: "ds-stepper__indicator",
|
|
57
58
|
"aria-hidden": "true",
|
|
58
|
-
children:
|
|
59
|
+
children: L
|
|
59
60
|
}
|
|
60
61
|
),
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
e.description != null && e.description !== "" ? /* @__PURE__ */
|
|
63
|
-
] }),
|
|
62
|
+
/* @__PURE__ */ t("span", { className: "ds-stepper__title", children: e.label }),
|
|
63
|
+
e.description != null && e.description !== "" ? /* @__PURE__ */ t("span", { className: "ds-stepper__description", children: e.description }) : null
|
|
64
|
+
] }), R = a === "completed" ? `${e.label}, ${S}` : e.label;
|
|
64
65
|
return /* @__PURE__ */ n(
|
|
65
66
|
"li",
|
|
66
67
|
{
|
|
67
|
-
ref: a === "active" ?
|
|
68
|
-
className:
|
|
68
|
+
ref: a === "active" ? f : void 0,
|
|
69
|
+
className: b(
|
|
69
70
|
"ds-stepper__item",
|
|
70
|
-
|
|
71
|
+
w && "ds-stepper__item--hidden"
|
|
71
72
|
),
|
|
72
73
|
"data-state": a,
|
|
73
74
|
"aria-current": a === "active" ? "step" : void 0,
|
|
74
|
-
"aria-label":
|
|
75
|
-
tabIndex: a === "active" && d && !
|
|
75
|
+
"aria-label": R,
|
|
76
|
+
tabIndex: a === "active" && d && !h ? -1 : void 0,
|
|
76
77
|
children: [
|
|
77
|
-
|
|
78
|
+
h ? /* @__PURE__ */ t(
|
|
78
79
|
"button",
|
|
79
80
|
{
|
|
80
81
|
type: "button",
|
|
81
82
|
className: "ds-stepper__button",
|
|
82
83
|
onClick: () => p?.(e.value),
|
|
83
|
-
children:
|
|
84
|
+
children: _
|
|
84
85
|
}
|
|
85
|
-
) :
|
|
86
|
-
|
|
86
|
+
) : _,
|
|
87
|
+
y ? null : /* @__PURE__ */ t(
|
|
87
88
|
"span",
|
|
88
89
|
{
|
|
89
90
|
className: "ds-stepper__separator",
|
|
@@ -97,8 +98,8 @@ const K = T(
|
|
|
97
98
|
);
|
|
98
99
|
}) }),
|
|
99
100
|
l ? /* @__PURE__ */ n("div", { className: "ds-stepper__active-step", "aria-hidden": "true", children: [
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
l.description != null && l.description !== "" ? /* @__PURE__ */
|
|
101
|
+
/* @__PURE__ */ t("p", { className: "ds-stepper__active-title", children: l.label }),
|
|
102
|
+
l.description != null && l.description !== "" ? /* @__PURE__ */ t("p", { className: "ds-stepper__active-description", children: l.description }) : null
|
|
102
103
|
] }) : null
|
|
103
104
|
]
|
|
104
105
|
}
|