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.
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { jsx as s, jsxs as x, Fragment as T } from "react/jsx-runtime";
3
- import { useState as f, useRef as w } from "react";
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 g } from "./RevealContext.js";
101
+ import { useRevealContext as d } from "./RevealContext.js";
102
102
  function v(e, n) {
103
103
  const {
104
- required: r,
105
- read_only: t,
104
+ required: o,
105
+ read_only: r,
106
106
  default_value: i,
107
107
  default_selected_value: a,
108
- validation_pattern: l,
108
+ validation_pattern: s,
109
109
  __component: p,
110
110
  type: m,
111
- layout: o,
111
+ layout: t,
112
112
  values: u,
113
113
  items: b,
114
114
  reveal: c,
115
- select_name: d,
116
- selectItems: h,
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: le,
122
- severity: me,
121
+ body: me,
122
+ severity: le,
123
123
  link_title: pe,
124
124
  link_url: ce,
125
125
  accept: ve,
126
- rows: de,
127
- suffix: he,
128
- infoHint: ge,
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, ...k } = D, V = {
142
- ...k,
143
- required: r,
144
- readOnly: t,
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 _(e) {
150
- const { controllableNames: n } = g();
149
+ function f(e) {
150
+ const { controllableNames: n } = d();
151
151
  return !!e.name && n.has(e.name);
152
152
  }
153
- function C(e) {
154
- const n = _(e), { revealCache: r, onRevealCache: t } = g(), i = w(
155
- n && e.name ? r[e.name] : void 0
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: (l) => t(a, l)
161
+ onChange: (s) => r(a, s)
162
162
  };
163
163
  }
164
164
  function M({ field: e }) {
165
- const n = v(e), r = C(e), t = e.validation_pattern ? new RegExp(e.validation_pattern) : void 0, i = (a) => {
166
- if (!(!a || !a.trim()) && t && !t.test(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__ */ s(
169
+ return /* @__PURE__ */ l(
170
170
  y,
171
171
  {
172
172
  ...n,
173
- defaultValue: r.defaultValue ?? n.defaultValue,
174
- onChange: r.onChange ? (a) => r.onChange?.(a) : void 0,
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), r = C(e);
181
- return /* @__PURE__ */ s(
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: r.defaultValue ?? n.defaultValue,
188
- onChange: r.onChange ? (t) => r.onChange?.(t) : void 0
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), r = C(e);
194
- return /* @__PURE__ */ s(
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: r.defaultValue ?? n.defaultValue,
200
- onChange: r.onChange ? (t) => r.onChange?.(t) : void 0
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 r = v(e), t = C(e), i = e.validation_pattern ? new RegExp(e.validation_pattern) : /^[\d\s\-+()]+$/, a = (p) => {
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
- }, l = n?.phoneCountries;
209
- return /* @__PURE__ */ s(
208
+ }, s = n?.phoneCountries;
209
+ return /* @__PURE__ */ l(
210
210
  z,
211
211
  {
212
- ...r,
213
- defaultValue: t.defaultValue ?? r.defaultValue,
214
- onChange: t.onChange ? (p) => t.onChange?.(p) : void 0,
215
- countries: e.selectItems ?? l,
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), r = C(e), t = e.validation_pattern ? new RegExp(e.validation_pattern) : /^\d{6,20}$/, i = (a) => {
224
- if (!(!a || !a.trim()) && !t.test(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__ */ s(
227
+ return /* @__PURE__ */ l(
228
228
  y,
229
229
  {
230
230
  ...n,
231
- defaultValue: r.defaultValue ?? n.defaultValue,
232
- onChange: r.onChange ? (a) => r.onChange?.(a) : void 0,
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: r, revealCache: t, onTriggerChange: i, onRevealCache: a } = g(), l = _(e), [p] = f(() => {
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 o = r[e.name];
241
- if (o !== void 0) return o;
242
- if (l) {
243
- const u = t[e.name];
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((o) => ({
248
- value: o.value,
249
- label: o.title
247
+ }), m = (e.values ?? []).map((t) => ({
248
+ value: t.value,
249
+ label: t.title
250
250
  }));
251
- return /* @__PURE__ */ s(
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: (o) => {
259
- e.name && (i(e.name, o), l && a(e.name, o));
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: r, revealCache: t, onTriggerChange: i, onRevealCache: a } = g(), l = !!e.reveal, p = _(e), [m] = f(() => {
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 (l) {
268
- const o = r[e.name];
269
- if (o !== void 0) return o;
267
+ if (s) {
268
+ const t = o[e.name];
269
+ if (t !== void 0) return t;
270
270
  }
271
271
  if (p) {
272
- const o = t[e.name];
273
- if (o !== void 0) return o;
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__ */ s(
277
+ return /* @__PURE__ */ l(
278
278
  S,
279
279
  {
280
280
  ...n,
281
281
  label: e.label,
282
282
  defaultChecked: m,
283
- onChange: (o) => {
284
- e.name && (l && i(e.name, o), p && a(e.name, o));
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: r, revealCache: t, onTriggerChange: i, onRevealCache: a } = g(), l = _(e), [p] = f(() => {
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 o = r[e.name];
294
- if (o !== void 0) return o;
295
- if (l) {
296
- const u = t[e.name];
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((o) => ({
301
- value: o.value ?? o.label,
302
- label: o.label,
303
- description: o.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__ */ s(
305
+ return /* @__PURE__ */ l(
306
306
  L,
307
307
  {
308
308
  ...n,
309
309
  defaultValue: p,
310
310
  items: m,
311
- onChange: (o) => {
312
- e.name && (i(e.name, o), l && a(e.name, o));
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: r, revealCache: t, onTriggerChange: i, onRevealCache: a } = g(), l = _(e), [p] = f(() => {
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 o = r[e.name];
321
- if (o !== void 0) return o;
322
- if (l) {
323
- const u = t[e.name];
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((o) => ({
328
- value: o.value ?? "",
329
- label: o.label,
330
- description: o.description
327
+ }), m = (e.items ?? []).map((t) => ({
328
+ value: t.value ?? "",
329
+ label: t.label,
330
+ description: t.description
331
331
  }));
332
- return /* @__PURE__ */ s(
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: (o) => {
340
- e.name && (i(e.name, o), l && a(e.name, o));
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.items ?? []).map((t) => ({
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__ */ s(
361
+ return /* @__PURE__ */ l(
352
362
  G,
353
363
  {
354
364
  ...n,
355
365
  name: e.name ?? "",
356
- defaultValue: e.default_value ? [e.default_value] : void 0,
366
+ defaultValue: p,
357
367
  layout: e.layout === "one_column" ? "column" : "row",
358
- items: r
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), r = C(e);
364
- return /* @__PURE__ */ s(
376
+ const n = v(e), o = _(e);
377
+ return /* @__PURE__ */ l(
365
378
  E,
366
379
  {
367
380
  ...n,
368
- defaultValue: r.defaultValue ?? n.defaultValue,
369
- onChange: r.onChange ? (t) => r.onChange?.(t) : void 0
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__ */ s(
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 [r, t] = f([]), i = r.filter((m) => m.status === "done" && m.url).map((m) => m.url).join(`
397
+ const [o, r] = C([]), i = o.filter((m) => m.status === "done" && m.url).map((m) => m.url).join(`
385
398
 
386
- `), a = n, l = async (m) => {
387
- const o = Array.from(m);
388
- for (const u of o) {
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
- t((c) => [
404
+ r((c) => [
392
405
  ...c,
393
406
  { file: u, status: "error", error: b }
394
407
  ]);
395
408
  continue;
396
409
  }
397
- if (t((c) => [...c, { file: u, status: "uploading" }]), !a?.onFileUpload) {
398
- t(
410
+ if (r((c) => [...c, { file: u, status: "uploading" }]), !a?.onFileUpload) {
411
+ r(
399
412
  (c) => c.map(
400
- (d) => d.file === u ? { ...d, status: "done" } : d
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
- t(
408
- (d) => d.map(
409
- (h) => h.file === u ? { ...h, status: "done", url: c } : h
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
- t(
414
- (d) => d.map(
415
- (h) => h.file === u ? {
416
- ...h,
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
- } : h
432
+ } : g
420
433
  )
421
434
  );
422
435
  }
423
436
  }
424
437
  }, p = (m) => {
425
- t((o) => o.filter((u) => u.file !== m));
438
+ r((t) => t.filter((u) => u.file !== m));
426
439
  };
427
- return /* @__PURE__ */ x(T, { children: [
428
- /* @__PURE__ */ s(
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: l,
451
+ onAddFiles: s,
439
452
  onRemoveFile: p
440
453
  }
441
454
  ),
442
- e.name ? /* @__PURE__ */ s("input", { type: "hidden", name: e.name, value: i }) : null
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 r = v(e), t = n;
447
- return /* @__PURE__ */ s(
459
+ const o = v(e), r = n;
460
+ return /* @__PURE__ */ l(
448
461
  I,
449
462
  {
450
- ...r,
463
+ ...o,
451
464
  placeholder: e.placeholder,
452
- onSearch: t?.onAddressSearch,
453
- loadingLabel: e.loadingLabel ?? t?.loadingLabel,
454
- emptyLabel: e.emptyLabel ?? t?.emptyLabel,
455
- errorLabel: e.errorLabel ?? t?.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__ */ s(
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__ */ s(q, { as: "div", children: e.body }) : null
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 r = e.severity === "notify" ? "info" : e.severity, t = e.link_title && e.link_url ? n ? n(e.link_url, e.link_title) : /* @__PURE__ */ s("a", { href: e.link_url, children: e.link_title }) : void 0;
478
- return /* @__PURE__ */ s(
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: r,
494
+ variant: o,
482
495
  title: e.title,
483
496
  description: e.description,
484
- children: t
497
+ children: r
485
498
  }
486
499
  );
487
500
  }
@@ -1,4 +1,4 @@
1
- function s(t) {
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
- s(r.reveal).forEach((n) => a.add(n));
9
+ c(r.reveal).forEach((n) => a.add(n));
10
10
  }), e.values?.forEach((r) => {
11
- s(r.reveal).forEach((n) => a.add(n));
12
- }), e.type === "checkbox" && s(e.reveal).forEach((r) => a.add(r));
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 i(t, a) {
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 o = r.items?.find((u) => u.value === n);
21
- return s(o?.reveal);
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 o = r.values?.find((u) => u.value === n);
25
- return s(o?.reveal);
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 o = Array.isArray(n) ? n : [];
28
+ const s = Array.isArray(n) ? n : [];
29
29
  return (r.items ?? []).filter((u) => {
30
- const c = u.value ?? u.label;
31
- return c && o.includes(c);
32
- }).flatMap((u) => s(u.reveal));
30
+ const o = u.value ?? u.label;
31
+ return o && s.includes(o);
32
+ }).flatMap((u) => c(u.reveal));
33
33
  }
34
- return r.type === "checkbox" && n ? s(r.reveal) : [];
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 p(t, a, e) {
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 f(t) {
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
- i as getRevealedNames,
62
- f as groupFields,
68
+ p as getRevealedNames,
69
+ y as groupFields,
63
70
  v as initialTriggerValues,
64
- p as isFieldVisible,
65
- s as parseRevealNames
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 s, Fragment as F } from "react/jsx-runtime";
3
- import { forwardRef as T, useRef as $, useEffect as q } from "react";
4
- import { DsIcon as w } from "../DsIcon/DsIcon.js";
5
- import { cn as v } from "../utils/dsClass.js";
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 z(r, t) {
8
- return r < t ? "completed" : r === t ? "active" : "upcoming";
8
+ function E(r, s) {
9
+ return r < s ? "completed" : r === s ? "active" : "upcoming";
9
10
  }
10
- function E(r, t, i) {
11
- return t ? !!(r === "completed" && i) : !1;
11
+ function H(r, s, i) {
12
+ return s ? !!(r === "completed" && i) : !1;
12
13
  }
13
- const K = T(
14
+ const K = F(
14
15
  function({
15
- items: t,
16
+ items: s,
16
17
  value: i,
17
18
  onChange: p,
18
- allowPrevStepSelect: h = !1,
19
+ allowPrevStepSelect: v = !1,
19
20
  focusOnActiveChange: d = !1,
20
21
  size: u = "default",
21
- ariaLabels: f,
22
+ ariaLabels: m,
22
23
  className: N,
23
- ...x
24
- }, k) {
25
- const I = f?.nav ?? "Steps", S = f?.completed ?? "completed", o = Math.max(0, t.findIndex((e) => e.value === i)), y = u === "small" ? "small" : "default", m = $(null);
26
- q(() => {
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 = m.current;
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 = t[o];
35
+ const l = s[o];
35
36
  return /* @__PURE__ */ n(
36
37
  "nav",
37
38
  {
38
- ref: k,
39
+ ref: x,
39
40
  "aria-label": I,
40
- className: v(
41
+ className: b(
41
42
  "ds-stepper",
42
43
  u === "small" && "ds-stepper--small",
43
44
  N
44
45
  ),
45
- ...x,
46
+ ...k,
46
47
  children: [
47
- /* @__PURE__ */ s("ol", { className: "ds-stepper__list", children: t.map((e, c) => {
48
- const a = z(c, o), D = e.disabled ?? !1, L = t.slice(c + 1).every((j) => j.disabled), _ = E(
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
- h
52
- ), R = a === "completed" ? /* @__PURE__ */ s(w, { icon: "check", size: y, "aria-hidden": "true" }) : c + 1, b = /* @__PURE__ */ n(F, { children: [
53
- /* @__PURE__ */ s(
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: R
59
+ children: L
59
60
  }
60
61
  ),
61
- /* @__PURE__ */ s("span", { className: "ds-stepper__title", children: e.label }),
62
- e.description != null && e.description !== "" ? /* @__PURE__ */ s("span", { className: "ds-stepper__description", children: e.description }) : null
63
- ] }), g = a === "completed" ? `${e.label}, ${S}` : e.label;
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" ? m : void 0,
68
- className: v(
68
+ ref: a === "active" ? f : void 0,
69
+ className: b(
69
70
  "ds-stepper__item",
70
- D && "ds-stepper__item--hidden"
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": g,
75
- tabIndex: a === "active" && d && !_ ? -1 : void 0,
75
+ "aria-label": R,
76
+ tabIndex: a === "active" && d && !h ? -1 : void 0,
76
77
  children: [
77
- _ ? /* @__PURE__ */ s(
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: b
84
+ children: _
84
85
  }
85
- ) : b,
86
- L ? null : /* @__PURE__ */ s(
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__ */ s("p", { className: "ds-stepper__active-title", children: l.label }),
101
- l.description != null && l.description !== "" ? /* @__PURE__ */ s("p", { className: "ds-stepper__active-description", children: l.description }) : null
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "enefit-design-system",
3
- "version": "0.9.2-ds.2",
3
+ "version": "0.9.2-ds.4",
4
4
  "description": "Enefit design system",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",