@emporix/component-library 1.5.3 → 1.6.0

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/index.es.js DELETED
@@ -1,796 +0,0 @@
1
- import { jsxs as I, jsx as u } from "react/jsx-runtime";
2
- import F, { useState as T, useRef as X, useMemo as me, useEffect as se, useId as he } from "react";
3
- const $e = "_primaryButton_gvcke_1", Le = "_primaryButtonDisabled_gvcke_33", Ae = "_spinner_gvcke_41", _e = {
4
- primaryButton: $e,
5
- primaryButtonDisabled: Le,
6
- spinner: Ae
7
- };
8
- var Ce = {
9
- color: void 0,
10
- size: void 0,
11
- className: void 0,
12
- style: void 0,
13
- attr: void 0
14
- }, ge = F.createContext && /* @__PURE__ */ F.createContext(Ce), qe = ["attr", "size", "title"];
15
- function Fe(e, t) {
16
- if (e == null) return {};
17
- var n, o, s = We(e, t);
18
- if (Object.getOwnPropertySymbols) {
19
- var a = Object.getOwnPropertySymbols(e);
20
- for (o = 0; o < a.length; o++) n = a[o], t.indexOf(n) === -1 && {}.propertyIsEnumerable.call(e, n) && (s[n] = e[n]);
21
- }
22
- return s;
23
- }
24
- function We(e, t) {
25
- if (e == null) return {};
26
- var n = {};
27
- for (var o in e) if ({}.hasOwnProperty.call(e, o)) {
28
- if (t.indexOf(o) !== -1) continue;
29
- n[o] = e[o];
30
- }
31
- return n;
32
- }
33
- function ue() {
34
- return ue = Object.assign ? Object.assign.bind() : function(e) {
35
- for (var t = 1; t < arguments.length; t++) {
36
- var n = arguments[t];
37
- for (var o in n) ({}).hasOwnProperty.call(n, o) && (e[o] = n[o]);
38
- }
39
- return e;
40
- }, ue.apply(null, arguments);
41
- }
42
- function be(e, t) {
43
- var n = Object.keys(e);
44
- if (Object.getOwnPropertySymbols) {
45
- var o = Object.getOwnPropertySymbols(e);
46
- t && (o = o.filter(function(s) {
47
- return Object.getOwnPropertyDescriptor(e, s).enumerable;
48
- })), n.push.apply(n, o);
49
- }
50
- return n;
51
- }
52
- function de(e) {
53
- for (var t = 1; t < arguments.length; t++) {
54
- var n = arguments[t] != null ? arguments[t] : {};
55
- t % 2 ? be(Object(n), !0).forEach(function(o) {
56
- Ee(e, o, n[o]);
57
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : be(Object(n)).forEach(function(o) {
58
- Object.defineProperty(e, o, Object.getOwnPropertyDescriptor(n, o));
59
- });
60
- }
61
- return e;
62
- }
63
- function Ee(e, t, n) {
64
- return (t = Re(t)) in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e;
65
- }
66
- function Re(e) {
67
- var t = Ve(e, "string");
68
- return typeof t == "symbol" ? t : t + "";
69
- }
70
- function Ve(e, t) {
71
- if (typeof e != "object" || !e) return e;
72
- var n = e[Symbol.toPrimitive];
73
- if (n !== void 0) {
74
- var o = n.call(e, t);
75
- if (typeof o != "object") return o;
76
- throw new TypeError("@@toPrimitive must return a primitive value.");
77
- }
78
- return (t === "string" ? String : Number)(e);
79
- }
80
- function Ne(e) {
81
- return e && e.map((t, n) => /* @__PURE__ */ F.createElement(t.tag, de({
82
- key: n
83
- }, t.attr), Ne(t.child)));
84
- }
85
- function ie(e) {
86
- return (t) => /* @__PURE__ */ F.createElement(He, ue({
87
- attr: de({}, e.attr)
88
- }, t), Ne(e.child));
89
- }
90
- function He(e) {
91
- var t = (n) => {
92
- var {
93
- attr: o,
94
- size: s,
95
- title: a
96
- } = e, i = Fe(e, qe), b = s || n.size || "1em", l;
97
- return n.className && (l = n.className), e.className && (l = (l ? l + " " : "") + e.className), /* @__PURE__ */ F.createElement("svg", ue({
98
- stroke: "currentColor",
99
- fill: "currentColor",
100
- strokeWidth: "0"
101
- }, n.attr, o, i, {
102
- className: l,
103
- style: de(de({
104
- color: e.color || n.color
105
- }, n.style), e.style),
106
- height: b,
107
- width: b,
108
- xmlns: "http://www.w3.org/2000/svg"
109
- }), a && /* @__PURE__ */ F.createElement("title", null, a), e.children);
110
- };
111
- return ge !== void 0 ? /* @__PURE__ */ F.createElement(ge.Consumer, null, (n) => t(n)) : t(Ce);
112
- }
113
- function Ke(e) {
114
- return ie({ attr: { viewBox: "0 0 24 24", fill: "none" }, child: [{ tag: "path", attr: { opacity: "0.2", fillRule: "evenodd", clipRule: "evenodd", d: "M12 19C15.866 19 19 15.866 19 12C19 8.13401 15.866 5 12 5C8.13401 5 5 8.13401 5 12C5 15.866 8.13401 19 12 19ZM12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z", fill: "currentColor" }, child: [] }, { tag: "path", attr: { d: "M2 12C2 6.47715 6.47715 2 12 2V5C8.13401 5 5 8.13401 5 12H2Z", fill: "currentColor" }, child: [] }] })(e);
115
- }
116
- const nn = ({
117
- children: e,
118
- disabled: t = !1,
119
- loading: n = !1,
120
- onClick: o,
121
- className: s = "",
122
- "data-testid": a,
123
- ...i
124
- }) => {
125
- const b = [
126
- _e.primaryButton,
127
- t ? _e.primaryButtonDisabled : "",
128
- s
129
- ].filter(Boolean).join(" ");
130
- return /* @__PURE__ */ I(
131
- "button",
132
- {
133
- type: "button",
134
- className: b,
135
- disabled: t || n,
136
- onClick: o,
137
- "data-testid": a,
138
- ...i,
139
- children: [
140
- n && /* @__PURE__ */ u(Ke, { className: _e.spinner, size: 12 }),
141
- e
142
- ]
143
- }
144
- );
145
- }, Me = "_secondaryButton_15dkw_1", Ze = "_secondaryButtonDisabled_15dkw_32", Be = {
146
- secondaryButton: Me,
147
- secondaryButtonDisabled: Ze
148
- }, rn = ({
149
- children: e,
150
- disabled: t = !1,
151
- onClick: n,
152
- className: o = "",
153
- "data-testid": s,
154
- ...a
155
- }) => {
156
- const i = [
157
- Be.secondaryButton,
158
- t ? Be.secondaryButtonDisabled : "",
159
- o
160
- ].filter(Boolean).join(" ");
161
- return /* @__PURE__ */ u(
162
- "button",
163
- {
164
- type: "button",
165
- className: i,
166
- disabled: t,
167
- onClick: n,
168
- "data-testid": s,
169
- ...a,
170
- children: e
171
- }
172
- );
173
- }, Qe = "_tabsContainer_m3c4e_1", Ge = "_tabsHeader_m3c4e_7", Ue = "_tabItem_m3c4e_13", Je = "_tabContent_m3c4e_29", Xe = "_tabLabel_m3c4e_51", Ye = "_tabLine_m3c4e_61", Te = "_active_m3c4e_68", et = "_inactive_m3c4e_76", tt = "_tabPanels_m3c4e_84", q = {
174
- tabsContainer: Qe,
175
- tabsHeader: Ge,
176
- tabItem: Ue,
177
- tabContent: Je,
178
- tabLabel: Xe,
179
- tabLine: Ye,
180
- active: Te,
181
- inactive: et,
182
- tabPanels: tt
183
- }, on = ({
184
- tabs: e,
185
- activeTabId: t,
186
- onTabChange: n,
187
- className: o = "",
188
- "data-testid": s,
189
- ...a
190
- }) => {
191
- var b;
192
- const i = [q.tabsContainer, o].filter(Boolean).join(" ");
193
- return /* @__PURE__ */ I("div", { className: i, "data-testid": s, ...a, children: [
194
- /* @__PURE__ */ u("div", { className: q.tabsHeader, children: e.map((l) => {
195
- const p = l.id === t, N = [
196
- q.tabItem,
197
- p ? q.active : q.inactive
198
- ].filter(Boolean).join(" ");
199
- return /* @__PURE__ */ I(
200
- "button",
201
- {
202
- type: "button",
203
- className: N,
204
- onClick: () => n(l.id),
205
- "data-testid": `${s}-tab-${l.id}`,
206
- children: [
207
- /* @__PURE__ */ u("div", { className: q.tabContent, children: /* @__PURE__ */ u("span", { className: q.tabLabel, children: l.label }) }),
208
- /* @__PURE__ */ u("div", { className: q.tabLine })
209
- ]
210
- },
211
- l.id
212
- );
213
- }) }),
214
- /* @__PURE__ */ u("div", { className: q.tabPanels, children: (b = e.find((l) => l.id === t)) == null ? void 0 : b.content })
215
- ] });
216
- };
217
- function nt(e) {
218
- return ie({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "circle", attr: { cx: "11", cy: "11", r: "8" }, child: [] }, { tag: "line", attr: { x1: "21", y1: "21", x2: "16.65", y2: "16.65" }, child: [] }] })(e);
219
- }
220
- function rt(e) {
221
- return ie({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "circle", attr: { cx: "12", cy: "12", r: "10" }, child: [] }, { tag: "line", attr: { x1: "12", y1: "16", x2: "12", y2: "12" }, child: [] }, { tag: "line", attr: { x1: "12", y1: "8", x2: "12.01", y2: "8" }, child: [] }] })(e);
222
- }
223
- function ot(e) {
224
- return ie({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "polyline", attr: { points: "9 18 15 12 9 6" }, child: [] }] })(e);
225
- }
226
- function xe(e) {
227
- return ie({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "polyline", attr: { points: "6 9 12 15 18 9" }, child: [] }] })(e);
228
- }
229
- const st = "_dropdown_yz8m1_1", it = "_label_yz8m1_9", lt = "_required_yz8m1_18", at = "_trigger_yz8m1_23", ct = "_triggerDisabled_yz8m1_47", ut = "_triggerInput_yz8m1_56", dt = "_value_yz8m1_74", ft = "_placeholder_yz8m1_81", pt = "_chevron_yz8m1_85", _t = "_open_yz8m1_92", yt = "_panel_yz8m1_116", mt = "_panelClosing_yz8m1_133", ht = "_filterWrapper_yz8m1_137", vt = "_filterInput_yz8m1_144", gt = "_filterIcon_yz8m1_163", bt = "_list_yz8m1_174", Bt = "_option_yz8m1_183", kt = "_optionSelected_yz8m1_195", wt = "_optionHighlighted_yz8m1_199", Ct = "_optionDisabled_yz8m1_203", Nt = "_empty_yz8m1_212", xt = "_disabled_yz8m1_219", v = {
230
- dropdown: st,
231
- label: it,
232
- required: lt,
233
- trigger: at,
234
- triggerDisabled: ct,
235
- triggerInput: ut,
236
- value: dt,
237
- placeholder: ft,
238
- chevron: pt,
239
- open: _t,
240
- panel: yt,
241
- panelClosing: mt,
242
- filterWrapper: ht,
243
- filterInput: vt,
244
- filterIcon: gt,
245
- list: bt,
246
- option: Bt,
247
- optionSelected: kt,
248
- optionHighlighted: wt,
249
- optionDisabled: Ct,
250
- empty: Nt,
251
- disabled: xt
252
- }, K = (e, t) => {
253
- const o = e[t];
254
- return o != null ? String(o) : "";
255
- }, Y = (e, t) => e[t], z = (e, t) => t == null ? !1 : !!e[t], sn = ({
256
- value: e,
257
- onChange: t,
258
- onEditEnd: n,
259
- options: o,
260
- optionLabel: s = "label",
261
- optionValue: a = "value",
262
- optionDisabled: i,
263
- placeholder: b = "Select",
264
- filter: l = !1,
265
- editable: p = !1,
266
- disabled: N = !1,
267
- required: P = !1,
268
- label: S,
269
- inputId: L,
270
- className: H = "",
271
- panelClassName: h = "",
272
- valueTemplate: y,
273
- itemTemplate: k,
274
- "data-testid": g
275
- }) => {
276
- const x = o.find(
277
- (r) => Y(r, a) === e
278
- ), C = x ? K(x, s) : "", [c, A] = T(!1), [O, le] = T(!1), [ee, ae] = T(""), [Q, w] = T(C), [_, d] = T(0), D = X(null), W = X(null), E = X(null), G = X(null), U = X(null), te = X(!1), j = me(
279
- () => l && !p ? o.filter(
280
- (r) => K(r, s).toLowerCase().includes(ee.toLowerCase())
281
- ) : o,
282
- [l, p, o, s, ee]
283
- );
284
- se(() => {
285
- p && w(C);
286
- }, [p, e, C]), se(() => {
287
- c && l && !p && (ae(""), d(0), setTimeout(() => {
288
- var r;
289
- return (r = E.current) == null ? void 0 : r.focus();
290
- }, 0));
291
- }, [c, l, p]), se(() => {
292
- if (!c) return;
293
- const r = j.findIndex(
294
- (B) => Y(B, a) === e
295
- ), f = j.findIndex(
296
- (B) => !z(B, i)
297
- ), m = r >= 0 && !z(j[r], i);
298
- d(m ? r : f >= 0 ? f : 0);
299
- }, [c, e, j, a, i]), se(() => {
300
- const r = U.current;
301
- r != null && r.scrollIntoView && typeof r.scrollIntoView == "function" && r.scrollIntoView({ block: "nearest" });
302
- }, [_]);
303
- const ne = () => {
304
- te.current = !0, le(!0);
305
- }, fe = (r) => {
306
- var f;
307
- (te.current || (f = r.animationName) != null && f.includes("menuOut")) && (te.current = !1, A(!1), le(!1), p && w(C));
308
- };
309
- se(() => {
310
- if (!c && !O) return;
311
- const r = (f) => {
312
- D.current && !D.current.contains(f.target) && (p && w(C), ne());
313
- };
314
- return document.addEventListener("mousedown", r), () => document.removeEventListener("mousedown", r);
315
- }, [c, O, p, C]);
316
- const re = () => {
317
- N || A((r) => !r);
318
- }, oe = (r, f) => {
319
- if (z(r, i)) return;
320
- const m = Y(r, a);
321
- p && w(K(r, s)), t == null || t({
322
- value: m ?? null,
323
- originalEvent: f
324
- }), ne();
325
- }, ve = (r) => {
326
- if (!c) {
327
- if (r.key === "Enter" && p && Q.trim()) {
328
- r.preventDefault();
329
- const f = Q.trim(), m = f.toLowerCase(), B = o.find((J) => {
330
- const V = K(J, s).toLowerCase();
331
- return V === m || V.startsWith(m);
332
- }), R = B && !z(B, i) ? Y(B, a) : null;
333
- B && !z(B, i) && (w(K(B, s)), t == null || t({
334
- value: R,
335
- originalEvent: r
336
- })), n == null || n({
337
- value: f,
338
- selectedValue: R,
339
- originalEvent: r
340
- });
341
- return;
342
- }
343
- (r.key === "Enter" || r.key === " " || r.key === "ArrowDown") && (r.preventDefault(), A(!0));
344
- return;
345
- }
346
- if (r.key === "Escape") {
347
- r.preventDefault(), ne();
348
- return;
349
- }
350
- if (r.key === "ArrowDown") {
351
- r.preventDefault(), d((f) => {
352
- for (let m = f + 1; m < j.length; m++)
353
- if (!z(j[m], i))
354
- return m;
355
- return f;
356
- });
357
- return;
358
- }
359
- if (r.key === "ArrowUp") {
360
- r.preventDefault(), d((f) => {
361
- for (let m = f - 1; m >= 0; m--)
362
- if (!z(j[m], i))
363
- return m;
364
- return f;
365
- });
366
- return;
367
- }
368
- if (r.key === "Enter") {
369
- if (r.preventDefault(), p) {
370
- const f = Q.trim();
371
- if (f) {
372
- const m = f.toLowerCase(), B = o.find((J) => {
373
- const V = K(J, s).toLowerCase();
374
- return V === m || V.startsWith(m);
375
- }), R = B && !z(B, i) ? Y(B, a) : null;
376
- B && !z(B, i) && oe(B, r), n == null || n({
377
- value: f,
378
- selectedValue: R,
379
- originalEvent: r
380
- });
381
- } else
382
- n == null || n({ value: "", selectedValue: null, originalEvent: r });
383
- } else if (j[_]) {
384
- const f = j[_];
385
- z(f, i) || oe(f, r);
386
- }
387
- }
388
- }, Oe = [
389
- v.dropdown,
390
- N ? v.disabled : "",
391
- c ? v.open : "",
392
- H
393
- ].filter(Boolean).join(" "), De = [
394
- v.trigger,
395
- N ? v.triggerDisabled : ""
396
- ].filter(Boolean).join(" "), Ie = [
397
- v.panel,
398
- O ? v.panelClosing : "",
399
- h
400
- ].filter(Boolean).join(" "), Se = he(), ce = L ?? `dropdown-${Se.replace(/[^a-zA-Z0-9_-]/g, "")}`, pe = `${ce}-panel`;
401
- return /* @__PURE__ */ I("div", { className: Oe, ref: D, "data-testid": g, children: [
402
- S != null && /* @__PURE__ */ I("label", { htmlFor: ce, className: v.label, children: [
403
- S,
404
- P && /* @__PURE__ */ u("span", { className: v.required, children: "*" })
405
- ] }),
406
- /* @__PURE__ */ I(
407
- "div",
408
- {
409
- id: p ? void 0 : ce,
410
- role: "combobox",
411
- "aria-expanded": c || O,
412
- "aria-haspopup": "listbox",
413
- "aria-controls": c || O ? pe : void 0,
414
- "aria-disabled": N,
415
- "aria-label": typeof S == "string" ? S : void 0,
416
- tabIndex: p || N ? -1 : 0,
417
- className: De,
418
- onClick: p ? void 0 : re,
419
- onKeyDown: p ? void 0 : ve,
420
- "data-testid": g && !p ? `${g}-trigger` : void 0,
421
- children: [
422
- p ? /* @__PURE__ */ u(
423
- "input",
424
- {
425
- ref: G,
426
- id: ce,
427
- type: "text",
428
- className: v.triggerInput,
429
- value: Q,
430
- onChange: (r) => {
431
- w(r.target.value), !c && !O && A(!0), d(0);
432
- },
433
- onFocus: () => {
434
- !N && !c && !O && A(!0);
435
- },
436
- onKeyDown: ve,
437
- placeholder: b,
438
- disabled: N,
439
- "aria-autocomplete": "list",
440
- "aria-controls": c || O ? pe : void 0,
441
- "aria-expanded": c || O,
442
- "data-testid": g ? `${g}-trigger` : void 0
443
- }
444
- ) : /* @__PURE__ */ u("span", { className: v.value, children: y ? y(x ?? null) : C || /* @__PURE__ */ u("span", { className: v.placeholder, children: b }) }),
445
- /* @__PURE__ */ u(
446
- xe,
447
- {
448
- className: v.chevron,
449
- "aria-hidden": !0,
450
- onClick: p ? re : void 0
451
- }
452
- )
453
- ]
454
- }
455
- ),
456
- (c || O) && /* @__PURE__ */ I(
457
- "div",
458
- {
459
- ref: W,
460
- id: pe,
461
- className: Ie,
462
- role: "presentation",
463
- onAnimationEnd: fe,
464
- "data-testid": g ? `${g}-panel` : void 0,
465
- children: [
466
- l && !p && /* @__PURE__ */ I("div", { className: v.filterWrapper, children: [
467
- /* @__PURE__ */ u(
468
- "input",
469
- {
470
- ref: E,
471
- type: "text",
472
- className: v.filterInput,
473
- value: ee,
474
- onChange: (r) => {
475
- ae(r.target.value), d(0);
476
- },
477
- onKeyDown: (r) => {
478
- r.key === "Escape" && A(!1), r.stopPropagation();
479
- },
480
- placeholder: "Search...",
481
- "aria-label": "Filter options",
482
- title: "Filter options",
483
- "data-testid": g ? `${g}-filter` : void 0
484
- }
485
- ),
486
- /* @__PURE__ */ u(nt, { className: v.filterIcon, "aria-hidden": !0 })
487
- ] }),
488
- /* @__PURE__ */ u("ul", { className: v.list, role: "listbox", "aria-label": "Options", children: j.length === 0 ? /* @__PURE__ */ u("li", { className: v.empty, children: "No results" }) : j.map((r, f) => {
489
- const m = Y(r, a), B = K(r, s), R = z(r, i), J = e === m, V = f === _, ze = m != null ? String(m) : `option-${f}`;
490
- return /* @__PURE__ */ u(
491
- "li",
492
- {
493
- ref: V ? U : void 0,
494
- role: "option",
495
- "aria-selected": J,
496
- "aria-disabled": R,
497
- className: [
498
- v.option,
499
- J ? v.optionSelected : "",
500
- V ? v.optionHighlighted : "",
501
- R ? v.optionDisabled : ""
502
- ].filter(Boolean).join(" "),
503
- onMouseEnter: () => !R && d(f),
504
- onClick: (Pe) => oe(r, Pe),
505
- "data-testid": g ? `${g}-option-${f}` : void 0,
506
- children: k ? k(r) : B
507
- },
508
- ze
509
- );
510
- }) })
511
- ]
512
- }
513
- )
514
- ] });
515
- }, jt = "_inputText_1crp5_1", Ot = "_label_1crp5_9", Dt = "_required_1crp5_20", It = "_tooltipIcon_1crp5_25", St = "_input_1crp5_1", zt = "_inputTextarea_1crp5_72", Pt = "_inputTextDisabled_1crp5_79", M = {
516
- inputText: jt,
517
- label: Ot,
518
- required: Dt,
519
- tooltipIcon: It,
520
- input: St,
521
- inputTextarea: zt,
522
- inputTextDisabled: Pt
523
- }, ln = ({
524
- label: e,
525
- tooltip: t,
526
- required: n = !1,
527
- inputId: o,
528
- textarea: s = !1,
529
- rows: a,
530
- className: i = "",
531
- "data-testid": b,
532
- disabled: l = !1,
533
- ...p
534
- }) => {
535
- const { type: N = "text", ...P } = p, S = he(), L = o || `input-text-${S.replace(/[^a-zA-Z0-9_-]/g, "")}`, H = [
536
- M.inputText,
537
- l ? M.inputTextDisabled : "",
538
- i
539
- ].filter(Boolean).join(" "), h = P["aria-invalid"];
540
- let y;
541
- h === void 0 ? y = void 0 : h === !0 ? y = "true" : h === !1 ? y = "false" : y = h;
542
- const k = n ? { "aria-required": "true" } : { "aria-required": "false" }, g = y === void 0 ? {} : { "aria-invalid": y }, x = [M.input, s ? M.inputTextarea : ""].filter(Boolean).join(" "), C = {
543
- id: L,
544
- className: x,
545
- disabled: l,
546
- ...k,
547
- ...g,
548
- "data-testid": b ? `${b}-input` : void 0
549
- };
550
- return /* @__PURE__ */ I("div", { className: H, "data-testid": b, children: [
551
- e != null && /* @__PURE__ */ I("label", { htmlFor: L, className: M.label, children: [
552
- e,
553
- n && /* @__PURE__ */ u("span", { className: M.required, children: "*" }),
554
- t != null && /* @__PURE__ */ u(
555
- "span",
556
- {
557
- className: M.tooltipIcon,
558
- title: t,
559
- "aria-label": t,
560
- children: /* @__PURE__ */ u(rt, { "aria-hidden": !0 })
561
- }
562
- )
563
- ] }),
564
- s ? /* @__PURE__ */ u(
565
- "textarea",
566
- {
567
- ...P,
568
- ...C,
569
- rows: a ?? 3
570
- }
571
- ) : /* @__PURE__ */ u("input", { ...P, ...C, type: N })
572
- ] });
573
- }, $t = "_accordion_l1hoq_1", Lt = "_tab_l1hoq_6", At = "_headerButton_l1hoq_11", qt = "_headerContent_l1hoq_39", Ft = "_icon_l1hoq_45", Wt = "_panel_l1hoq_53", Et = "_panelCollapsed_l1hoq_58", Rt = "_panelOpen_l1hoq_64", Vt = "_panelContent_l1hoq_70", Ht = "_noBorderLast_l1hoq_74", $ = {
574
- accordion: $t,
575
- tab: Lt,
576
- headerButton: At,
577
- headerContent: qt,
578
- icon: Ft,
579
- panel: Wt,
580
- panelCollapsed: Et,
581
- panelOpen: Rt,
582
- panelContent: Vt,
583
- noBorderLast: Ht
584
- }, je = (e) => null;
585
- je.displayName = "AccordionTab";
586
- const Kt = (e, t) => e == null ? [] : Array.isArray(e) ? t ? e : e.slice(0, 1) : [e], Mt = (e) => e.replace(/[^a-zA-Z0-9_-]/g, ""), Zt = ({
587
- activeIndex: e,
588
- multiple: t = !1,
589
- expandIcon: n,
590
- collapseIcon: o,
591
- onTabChange: s,
592
- onTabOpen: a,
593
- onTabClose: i,
594
- className: b = "",
595
- transitionOptions: l,
596
- pt: p,
597
- ptOptions: N,
598
- unstyled: P,
599
- children: S,
600
- ...L
601
- }) => {
602
- const H = he(), h = Mt(H), y = me(() => F.Children.toArray(S).filter(
603
- (_) => F.isValidElement(_) && _.type === je
604
- ), [S]), k = e !== void 0, g = me(() => Kt(e, t), [e, t]), [x, C] = T([]), c = k ? g : x, A = typeof l == "object" && l != null && typeof l.timeout == "number" ? l.timeout : void 0, O = /* @__PURE__ */ u(ot, { "aria-hidden": !0 }), le = /* @__PURE__ */ u(xe, { "aria-hidden": !0 }), ee = n ?? O, ae = o ?? le, Q = (w, _) => {
605
- const d = c.includes(w);
606
- if (t) {
607
- const E = d ? c.filter((G) => G !== w) : [...c, w];
608
- k || C(E), s == null || s({ index: E, originalEvent: _ }), d ? i == null || i({ index: w, originalEvent: _ }) : a == null || a({ index: w, originalEvent: _ });
609
- return;
610
- }
611
- const D = c.length ? c[0] : null, W = d ? [] : [w];
612
- if (k || C(W), s == null || s({ index: W, originalEvent: _ }), d) {
613
- i == null || i({ index: w, originalEvent: _ });
614
- return;
615
- }
616
- D != null && (i == null || i({ index: D, originalEvent: _ })), a == null || a({ index: w, originalEvent: _ });
617
- };
618
- return /* @__PURE__ */ u(
619
- "div",
620
- {
621
- className: [$.accordion, b].filter(Boolean).join(" "),
622
- ...L,
623
- children: y.map((w, _) => {
624
- var re;
625
- const d = w.props, D = c.includes(_), W = !!d.disabled, E = `${h}-header-${_}`, G = `${h}-content-${_}`, U = d.headerTemplate != null ? typeof d.headerTemplate == "function" ? d.headerTemplate({
626
- index: _,
627
- selected: D,
628
- disabled: W,
629
- count: y.length,
630
- first: _ === 0,
631
- last: _ === y.length - 1
632
- }) : d.headerTemplate : d.header, te = D ? ae : ee, j = [
633
- $.headerButton,
634
- d.headerClassName ?? ""
635
- ].filter(Boolean).join(" "), ne = [
636
- $.tab,
637
- d.className ?? "",
638
- _ === y.length - 1 ? $.noBorderLast : ""
639
- ].filter(Boolean).join(" "), fe = typeof U == "string" ? U : void 0;
640
- return /* @__PURE__ */ I(
641
- "div",
642
- {
643
- className: ne,
644
- style: d.style,
645
- children: [
646
- /* @__PURE__ */ I(
647
- "button",
648
- {
649
- id: E,
650
- type: "button",
651
- disabled: W,
652
- className: j,
653
- style: d.headerStyle,
654
- "aria-controls": G,
655
- "aria-expanded": D,
656
- "aria-disabled": W,
657
- tabIndex: d.tabIndex,
658
- onClick: (oe) => Q(_, oe),
659
- ...d.headerProps,
660
- "aria-label": ((re = d.headerProps) == null ? void 0 : re["aria-label"]) ?? fe,
661
- children: [
662
- /* @__PURE__ */ u("span", { className: $.headerContent, children: U }),
663
- /* @__PURE__ */ u("span", { className: $.icon, "aria-hidden": !0, children: te })
664
- ]
665
- }
666
- ),
667
- /* @__PURE__ */ u(
668
- "div",
669
- {
670
- id: G,
671
- role: "region",
672
- "aria-labelledby": E,
673
- "aria-hidden": !D,
674
- className: [
675
- $.panel,
676
- D ? $.panelOpen : $.panelCollapsed
677
- ].join(" "),
678
- style: {
679
- transitionDuration: A ? `${A}ms` : void 0
680
- },
681
- children: /* @__PURE__ */ u(
682
- "div",
683
- {
684
- className: [
685
- $.panelContent,
686
- d.contentClassName ?? ""
687
- ].filter(Boolean).join(" "),
688
- style: d.contentStyle,
689
- children: d.children
690
- }
691
- )
692
- }
693
- )
694
- ]
695
- },
696
- _
697
- );
698
- })
699
- }
700
- );
701
- };
702
- Zt.displayName = "Accordion";
703
- const Qt = "_selectButton_1u3fo_1", Gt = "_selectButtonDisabled_1u3fo_9", Ut = "_selectButtonInvalid_1u3fo_14", Jt = "_button_1u3fo_14", Xt = "_buttonFirst_1u3fo_47", Yt = "_buttonLast_1u3fo_51", Tt = "_buttonSelected_1u3fo_59", Z = {
704
- selectButton: Qt,
705
- selectButtonDisabled: Gt,
706
- selectButtonInvalid: Ut,
707
- button: Jt,
708
- buttonFirst: Xt,
709
- buttonLast: Yt,
710
- buttonSelected: Tt
711
- }, ke = (e, t) => {
712
- const o = e[t];
713
- return o != null ? String(o) : "";
714
- }, ye = (e, t) => e[t], we = (e, t) => t == null ? !1 : !!e[t], an = ({
715
- value: e,
716
- onChange: t,
717
- options: n,
718
- optionLabel: o = "label",
719
- optionValue: s = "value",
720
- optionDisabled: a,
721
- multiple: i = !1,
722
- itemTemplate: b,
723
- disabled: l = !1,
724
- invalid: p = !1,
725
- className: N = "",
726
- "data-testid": P
727
- }) => {
728
- const S = (h) => {
729
- const y = ye(h, s);
730
- return i && Array.isArray(e) ? e.includes(y) : e === y;
731
- }, L = (h, y) => {
732
- if (l || we(h, a)) return;
733
- const k = ye(h, s);
734
- if (k === void 0) return;
735
- let g;
736
- if (i) {
737
- const x = Array.isArray(e) ? e : [];
738
- g = x.includes(k) ? x.filter((c) => c !== k) : [...x, k];
739
- } else
740
- g = e === k ? null : k;
741
- t == null || t({
742
- value: g,
743
- originalEvent: y
744
- });
745
- }, H = [
746
- Z.selectButton,
747
- l ? Z.selectButtonDisabled : "",
748
- p ? Z.selectButtonInvalid : "",
749
- N
750
- ].filter(Boolean).join(" ");
751
- return /* @__PURE__ */ u(
752
- "div",
753
- {
754
- className: H,
755
- role: "group",
756
- "aria-disabled": l,
757
- "data-testid": P,
758
- children: n.map((h, y) => {
759
- const k = ye(h, s), g = k != null ? String(k) : `option-${y}`, x = we(h, a), C = S(h);
760
- return /* @__PURE__ */ u(
761
- "button",
762
- {
763
- type: "button",
764
- "aria-pressed": C,
765
- "aria-disabled": x || l,
766
- "aria-label": ke(h, o),
767
- disabled: l || x,
768
- className: [
769
- Z.button,
770
- C ? Z.buttonSelected : "",
771
- y === 0 ? Z.buttonFirst : "",
772
- y === n.length - 1 ? Z.buttonLast : ""
773
- ].filter(Boolean).join(" "),
774
- onClick: (c) => L(h, c),
775
- onKeyDown: (c) => {
776
- (c.key === " " || c.key === "Enter") && (c.preventDefault(), L(h, c));
777
- },
778
- "data-testid": P ? `${P}-option-${y}` : void 0,
779
- children: b ? b(h) : ke(h, o)
780
- },
781
- g
782
- );
783
- })
784
- }
785
- );
786
- };
787
- export {
788
- Zt as Accordion,
789
- je as AccordionTab,
790
- sn as Dropdown,
791
- ln as InputText,
792
- nn as PrimaryButton,
793
- rn as SecondaryButton,
794
- an as SelectButton,
795
- on as Tabs
796
- };