@purpurds/accordion 0.0.1

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.
@@ -0,0 +1,1044 @@
1
+ import { jsx as A, jsxs as X } from "react/jsx-runtime";
2
+ import * as be from "react";
3
+ import u, { createContext as ee, useMemo as U, createElement as y, useContext as $e, useCallback as G, forwardRef as S, Children as w, isValidElement as M, cloneElement as F, Fragment as Le, useRef as C, useEffect as D, useState as re, useLayoutEffect as je, useReducer as qe } from "react";
4
+ import { flushSync as Ve } from "react-dom";
5
+ function Ue(e) {
6
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
7
+ }
8
+ var _e = { exports: {} };
9
+ /*!
10
+ Copyright (c) 2018 Jed Watson.
11
+ Licensed under the MIT License (MIT), see
12
+ http://jedwatson.github.io/classnames
13
+ */
14
+ (function(e) {
15
+ (function() {
16
+ var r = {}.hasOwnProperty;
17
+ function n() {
18
+ for (var t = "", a = 0; a < arguments.length; a++) {
19
+ var i = arguments[a];
20
+ i && (t = c(t, o(i)));
21
+ }
22
+ return t;
23
+ }
24
+ function o(t) {
25
+ if (typeof t == "string" || typeof t == "number")
26
+ return t;
27
+ if (typeof t != "object")
28
+ return "";
29
+ if (Array.isArray(t))
30
+ return n.apply(null, t);
31
+ if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]"))
32
+ return t.toString();
33
+ var a = "";
34
+ for (var i in t)
35
+ r.call(t, i) && t[i] && (a = c(a, i));
36
+ return a;
37
+ }
38
+ function c(t, a) {
39
+ return a ? t ? t + " " + a : t + a : t;
40
+ }
41
+ e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
42
+ })();
43
+ })(_e);
44
+ var Be = _e.exports;
45
+ const He = /* @__PURE__ */ Ue(Be), j = {
46
+ "purpur-heading": "_purpur-heading_k9fhq_1",
47
+ "purpur-heading--hyphens": "_purpur-heading--hyphens_k9fhq_8",
48
+ "purpur-heading--negative": "_purpur-heading--negative_k9fhq_11",
49
+ "purpur-heading--subsection-100": "_purpur-heading--subsection-100_k9fhq_14",
50
+ "purpur-heading--title-100": "_purpur-heading--title-100_k9fhq_20",
51
+ "purpur-heading--title-200": "_purpur-heading--title-200_k9fhq_26",
52
+ "purpur-heading--title-300": "_purpur-heading--title-300_k9fhq_32",
53
+ "purpur-heading--title-400": "_purpur-heading--title-400_k9fhq_38",
54
+ "purpur-heading--title-500": "_purpur-heading--title-500_k9fhq_44",
55
+ "purpur-heading--title-600": "_purpur-heading--title-600_k9fhq_50",
56
+ "purpur-heading--title-700": "_purpur-heading--title-700_k9fhq_56",
57
+ "purpur-heading--display-25": "_purpur-heading--display-25_k9fhq_62",
58
+ "purpur-heading--display-50": "_purpur-heading--display-50_k9fhq_68",
59
+ "purpur-heading--display-100": "_purpur-heading--display-100_k9fhq_74",
60
+ "purpur-heading--display-200": "_purpur-heading--display-200_k9fhq_80"
61
+ }, Ge = {
62
+ TITLE100: "title-100",
63
+ TITLE200: "title-200",
64
+ TITLE300: "title-300",
65
+ TITLE400: "title-400",
66
+ TITLE500: "title-500",
67
+ TITLE600: "title-600",
68
+ TITLE700: "title-700",
69
+ SUBSECTION100: "subsection-100"
70
+ }, q = "purpur-heading", me = ({
71
+ ["data-testid"]: e,
72
+ children: r,
73
+ className: n = "",
74
+ enableHyphenation: o = !1,
75
+ negative: c = !1,
76
+ tag: t,
77
+ variant: a = Ge.TITLE100,
78
+ ...i
79
+ }) => {
80
+ const s = t, l = He([
81
+ n,
82
+ j[q],
83
+ j[`${q}--${a}`],
84
+ {
85
+ [j[`${q}--hyphens`]]: o,
86
+ [j[`${q}--negative`]]: c
87
+ }
88
+ ]);
89
+ return /* @__PURE__ */ A(s, { ...i, className: l, "data-testid": e, children: r });
90
+ };
91
+ function h() {
92
+ return h = Object.assign ? Object.assign.bind() : function(e) {
93
+ for (var r = 1; r < arguments.length; r++) {
94
+ var n = arguments[r];
95
+ for (var o in n)
96
+ Object.prototype.hasOwnProperty.call(n, o) && (e[o] = n[o]);
97
+ }
98
+ return e;
99
+ }, h.apply(this, arguments);
100
+ }
101
+ function oe(e, r = []) {
102
+ let n = [];
103
+ function o(t, a) {
104
+ const i = /* @__PURE__ */ ee(a), s = n.length;
105
+ n = [
106
+ ...n,
107
+ a
108
+ ];
109
+ function l(p) {
110
+ const { scope: _, children: f, ...b } = p, x = (_ == null ? void 0 : _[e][s]) || i, g = U(
111
+ () => b,
112
+ Object.values(b)
113
+ );
114
+ return /* @__PURE__ */ y(x.Provider, {
115
+ value: g
116
+ }, f);
117
+ }
118
+ function d(p, _) {
119
+ const f = (_ == null ? void 0 : _[e][s]) || i, b = $e(f);
120
+ if (b)
121
+ return b;
122
+ if (a !== void 0)
123
+ return a;
124
+ throw new Error(`\`${p}\` must be used within \`${t}\``);
125
+ }
126
+ return l.displayName = t + "Provider", [
127
+ l,
128
+ d
129
+ ];
130
+ }
131
+ const c = () => {
132
+ const t = n.map((a) => /* @__PURE__ */ ee(a));
133
+ return function(i) {
134
+ const s = (i == null ? void 0 : i[e]) || t;
135
+ return U(
136
+ () => ({
137
+ [`__scope${e}`]: {
138
+ ...i,
139
+ [e]: s
140
+ }
141
+ }),
142
+ [
143
+ i,
144
+ s
145
+ ]
146
+ );
147
+ };
148
+ };
149
+ return c.scopeName = e, [
150
+ o,
151
+ Fe(c, ...r)
152
+ ];
153
+ }
154
+ function Fe(...e) {
155
+ const r = e[0];
156
+ if (e.length === 1)
157
+ return r;
158
+ const n = () => {
159
+ const o = e.map(
160
+ (c) => ({
161
+ useScope: c(),
162
+ scopeName: c.scopeName
163
+ })
164
+ );
165
+ return function(t) {
166
+ const a = o.reduce((i, { useScope: s, scopeName: l }) => {
167
+ const p = s(t)[`__scope${l}`];
168
+ return {
169
+ ...i,
170
+ ...p
171
+ };
172
+ }, {});
173
+ return U(
174
+ () => ({
175
+ [`__scope${r.scopeName}`]: a
176
+ }),
177
+ [
178
+ a
179
+ ]
180
+ );
181
+ };
182
+ };
183
+ return n.scopeName = r.scopeName, n;
184
+ }
185
+ function ze(e, r) {
186
+ typeof e == "function" ? e(r) : e != null && (e.current = r);
187
+ }
188
+ function he(...e) {
189
+ return (r) => e.forEach(
190
+ (n) => ze(n, r)
191
+ );
192
+ }
193
+ function k(...e) {
194
+ return G(he(...e), e);
195
+ }
196
+ const B = /* @__PURE__ */ S((e, r) => {
197
+ const { children: n, ...o } = e, c = w.toArray(n), t = c.find(Ze);
198
+ if (t) {
199
+ const a = t.props.children, i = c.map((s) => s === t ? w.count(a) > 1 ? w.only(null) : /* @__PURE__ */ M(a) ? a.props.children : null : s);
200
+ return /* @__PURE__ */ y(te, h({}, o, {
201
+ ref: r
202
+ }), /* @__PURE__ */ M(a) ? /* @__PURE__ */ F(a, void 0, i) : null);
203
+ }
204
+ return /* @__PURE__ */ y(te, h({}, o, {
205
+ ref: r
206
+ }), n);
207
+ });
208
+ B.displayName = "Slot";
209
+ const te = /* @__PURE__ */ S((e, r) => {
210
+ const { children: n, ...o } = e;
211
+ return /* @__PURE__ */ M(n) ? /* @__PURE__ */ F(n, {
212
+ ...Ye(o, n.props),
213
+ ref: r ? he(r, n.ref) : n.ref
214
+ }) : w.count(n) > 1 ? w.only(null) : null;
215
+ });
216
+ te.displayName = "SlotClone";
217
+ const Ke = ({ children: e }) => /* @__PURE__ */ y(Le, null, e);
218
+ function Ze(e) {
219
+ return /* @__PURE__ */ M(e) && e.type === Ke;
220
+ }
221
+ function Ye(e, r) {
222
+ const n = {
223
+ ...r
224
+ };
225
+ for (const o in r) {
226
+ const c = e[o], t = r[o];
227
+ /^on[A-Z]/.test(o) ? c && t ? n[o] = (...i) => {
228
+ t(...i), c(...i);
229
+ } : c && (n[o] = c) : o === "style" ? n[o] = {
230
+ ...c,
231
+ ...t
232
+ } : o === "className" && (n[o] = [
233
+ c,
234
+ t
235
+ ].filter(Boolean).join(" "));
236
+ }
237
+ return {
238
+ ...e,
239
+ ...n
240
+ };
241
+ }
242
+ function Je(e) {
243
+ const r = e + "CollectionProvider", [n, o] = oe(r), [c, t] = n(r, {
244
+ collectionRef: {
245
+ current: null
246
+ },
247
+ itemMap: /* @__PURE__ */ new Map()
248
+ }), a = (f) => {
249
+ const { scope: b, children: x } = f, g = u.useRef(null), m = u.useRef(/* @__PURE__ */ new Map()).current;
250
+ return /* @__PURE__ */ u.createElement(c, {
251
+ scope: b,
252
+ itemMap: m,
253
+ collectionRef: g
254
+ }, x);
255
+ }, i = e + "CollectionSlot", s = /* @__PURE__ */ u.forwardRef((f, b) => {
256
+ const { scope: x, children: g } = f, m = t(i, x), $ = k(b, m.collectionRef);
257
+ return /* @__PURE__ */ u.createElement(B, {
258
+ ref: $
259
+ }, g);
260
+ }), l = e + "CollectionItemSlot", d = "data-radix-collection-item", p = /* @__PURE__ */ u.forwardRef((f, b) => {
261
+ const { scope: x, children: g, ...m } = f, $ = u.useRef(null), v = k(b, $), N = t(l, x);
262
+ return u.useEffect(() => (N.itemMap.set($, {
263
+ ref: $,
264
+ ...m
265
+ }), () => void N.itemMap.delete($))), /* @__PURE__ */ u.createElement(B, {
266
+ [d]: "",
267
+ ref: v
268
+ }, g);
269
+ });
270
+ function _(f) {
271
+ const b = t(e + "CollectionConsumer", f);
272
+ return u.useCallback(() => {
273
+ const g = b.collectionRef.current;
274
+ if (!g)
275
+ return [];
276
+ const m = Array.from(g.querySelectorAll(`[${d}]`));
277
+ return Array.from(b.itemMap.values()).sort(
278
+ (N, O) => m.indexOf(N.ref.current) - m.indexOf(O.ref.current)
279
+ );
280
+ }, [
281
+ b.collectionRef,
282
+ b.itemMap
283
+ ]);
284
+ }
285
+ return [
286
+ {
287
+ Provider: a,
288
+ Slot: s,
289
+ ItemSlot: p
290
+ },
291
+ _,
292
+ o
293
+ ];
294
+ }
295
+ function ge(e, r, { checkForDefaultPrevented: n = !0 } = {}) {
296
+ return function(c) {
297
+ if (e == null || e(c), n === !1 || !c.defaultPrevented)
298
+ return r == null ? void 0 : r(c);
299
+ };
300
+ }
301
+ function ve(e) {
302
+ const r = C(e);
303
+ return D(() => {
304
+ r.current = e;
305
+ }), U(
306
+ () => (...n) => {
307
+ var o;
308
+ return (o = r.current) === null || o === void 0 ? void 0 : o.call(r, ...n);
309
+ },
310
+ []
311
+ );
312
+ }
313
+ function ae({ prop: e, defaultProp: r, onChange: n = () => {
314
+ } }) {
315
+ const [o, c] = Qe({
316
+ defaultProp: r,
317
+ onChange: n
318
+ }), t = e !== void 0, a = t ? e : o, i = ve(n), s = G((l) => {
319
+ if (t) {
320
+ const p = typeof l == "function" ? l(e) : l;
321
+ p !== e && i(p);
322
+ } else
323
+ c(l);
324
+ }, [
325
+ t,
326
+ e,
327
+ c,
328
+ i
329
+ ]);
330
+ return [
331
+ a,
332
+ s
333
+ ];
334
+ }
335
+ function Qe({ defaultProp: e, onChange: r }) {
336
+ const n = re(e), [o] = n, c = C(o), t = ve(r);
337
+ return D(() => {
338
+ c.current !== o && (t(o), c.current = o);
339
+ }, [
340
+ o,
341
+ c,
342
+ t
343
+ ]), n;
344
+ }
345
+ const We = [
346
+ "a",
347
+ "button",
348
+ "div",
349
+ "form",
350
+ "h2",
351
+ "h3",
352
+ "img",
353
+ "input",
354
+ "label",
355
+ "li",
356
+ "nav",
357
+ "ol",
358
+ "p",
359
+ "span",
360
+ "svg",
361
+ "ul"
362
+ ], L = We.reduce((e, r) => {
363
+ const n = /* @__PURE__ */ S((o, c) => {
364
+ const { asChild: t, ...a } = o, i = t ? B : r;
365
+ return D(() => {
366
+ window[Symbol.for("radix-ui")] = !0;
367
+ }, []), /* @__PURE__ */ y(i, h({}, a, {
368
+ ref: c
369
+ }));
370
+ });
371
+ return n.displayName = `Primitive.${r}`, {
372
+ ...e,
373
+ [r]: n
374
+ };
375
+ }, {}), H = globalThis != null && globalThis.document ? je : () => {
376
+ };
377
+ function Xe(e, r) {
378
+ return qe((n, o) => {
379
+ const c = r[n][o];
380
+ return c ?? n;
381
+ }, e);
382
+ }
383
+ const xe = (e) => {
384
+ const { present: r, children: n } = e, o = et(r), c = typeof n == "function" ? n({
385
+ present: o.isPresent
386
+ }) : w.only(n), t = k(o.ref, c.ref);
387
+ return typeof n == "function" || o.isPresent ? /* @__PURE__ */ F(c, {
388
+ ref: t
389
+ }) : null;
390
+ };
391
+ xe.displayName = "Presence";
392
+ function et(e) {
393
+ const [r, n] = re(), o = C({}), c = C(e), t = C("none"), a = e ? "mounted" : "unmounted", [i, s] = Xe(a, {
394
+ mounted: {
395
+ UNMOUNT: "unmounted",
396
+ ANIMATION_OUT: "unmountSuspended"
397
+ },
398
+ unmountSuspended: {
399
+ MOUNT: "mounted",
400
+ ANIMATION_END: "unmounted"
401
+ },
402
+ unmounted: {
403
+ MOUNT: "mounted"
404
+ }
405
+ });
406
+ return D(() => {
407
+ const l = V(o.current);
408
+ t.current = i === "mounted" ? l : "none";
409
+ }, [
410
+ i
411
+ ]), H(() => {
412
+ const l = o.current, d = c.current;
413
+ if (d !== e) {
414
+ const _ = t.current, f = V(l);
415
+ e ? s("MOUNT") : f === "none" || (l == null ? void 0 : l.display) === "none" ? s("UNMOUNT") : s(d && _ !== f ? "ANIMATION_OUT" : "UNMOUNT"), c.current = e;
416
+ }
417
+ }, [
418
+ e,
419
+ s
420
+ ]), H(() => {
421
+ if (r) {
422
+ const l = (p) => {
423
+ const f = V(o.current).includes(p.animationName);
424
+ p.target === r && f && Ve(
425
+ () => s("ANIMATION_END")
426
+ );
427
+ }, d = (p) => {
428
+ p.target === r && (t.current = V(o.current));
429
+ };
430
+ return r.addEventListener("animationstart", d), r.addEventListener("animationcancel", l), r.addEventListener("animationend", l), () => {
431
+ r.removeEventListener("animationstart", d), r.removeEventListener("animationcancel", l), r.removeEventListener("animationend", l);
432
+ };
433
+ } else
434
+ s("ANIMATION_END");
435
+ }, [
436
+ r,
437
+ s
438
+ ]), {
439
+ isPresent: [
440
+ "mounted",
441
+ "unmountSuspended"
442
+ ].includes(i),
443
+ ref: G((l) => {
444
+ l && (o.current = getComputedStyle(l)), n(l);
445
+ }, [])
446
+ };
447
+ }
448
+ function V(e) {
449
+ return (e == null ? void 0 : e.animationName) || "none";
450
+ }
451
+ const tt = be.useId || (() => {
452
+ });
453
+ let nt = 0;
454
+ function Ae(e) {
455
+ const [r, n] = be.useState(tt());
456
+ return H(() => {
457
+ n(
458
+ (o) => o ?? String(nt++)
459
+ );
460
+ }, [
461
+ e
462
+ ]), r ? `radix-${r}` : "";
463
+ }
464
+ const ye = "Collapsible", [rt, Ce] = oe(ye), [ot, ce] = rt(ye), at = /* @__PURE__ */ S((e, r) => {
465
+ const { __scopeCollapsible: n, open: o, defaultOpen: c, disabled: t, onOpenChange: a, ...i } = e, [s = !1, l] = ae({
466
+ prop: o,
467
+ defaultProp: c,
468
+ onChange: a
469
+ });
470
+ return /* @__PURE__ */ y(ot, {
471
+ scope: n,
472
+ disabled: t,
473
+ contentId: Ae(),
474
+ open: s,
475
+ onOpenToggle: G(
476
+ () => l(
477
+ (d) => !d
478
+ ),
479
+ [
480
+ l
481
+ ]
482
+ )
483
+ }, /* @__PURE__ */ y(L.div, h({
484
+ "data-state": ie(s),
485
+ "data-disabled": t ? "" : void 0
486
+ }, i, {
487
+ ref: r
488
+ })));
489
+ }), ct = "CollapsibleTrigger", it = /* @__PURE__ */ S((e, r) => {
490
+ const { __scopeCollapsible: n, ...o } = e, c = ce(ct, n);
491
+ return /* @__PURE__ */ y(L.button, h({
492
+ type: "button",
493
+ "aria-controls": c.contentId,
494
+ "aria-expanded": c.open || !1,
495
+ "data-state": ie(c.open),
496
+ "data-disabled": c.disabled ? "" : void 0,
497
+ disabled: c.disabled
498
+ }, o, {
499
+ ref: r,
500
+ onClick: ge(e.onClick, c.onOpenToggle)
501
+ }));
502
+ }), Ne = "CollapsibleContent", st = /* @__PURE__ */ S((e, r) => {
503
+ const { forceMount: n, ...o } = e, c = ce(Ne, e.__scopeCollapsible);
504
+ return /* @__PURE__ */ y(
505
+ xe,
506
+ {
507
+ present: n || c.open
508
+ },
509
+ ({ present: t }) => /* @__PURE__ */ y(lt, h({}, o, {
510
+ ref: r,
511
+ present: t
512
+ }))
513
+ );
514
+ }), lt = /* @__PURE__ */ S((e, r) => {
515
+ const { __scopeCollapsible: n, present: o, children: c, ...t } = e, a = ce(Ne, n), [i, s] = re(o), l = C(null), d = k(r, l), p = C(0), _ = p.current, f = C(0), b = f.current, x = a.open || i, g = C(x), m = C();
516
+ return D(() => {
517
+ const $ = requestAnimationFrame(
518
+ () => g.current = !1
519
+ );
520
+ return () => cancelAnimationFrame($);
521
+ }, []), H(() => {
522
+ const $ = l.current;
523
+ if ($) {
524
+ m.current = m.current || {
525
+ transitionDuration: $.style.transitionDuration,
526
+ animationName: $.style.animationName
527
+ }, $.style.transitionDuration = "0s", $.style.animationName = "none";
528
+ const v = $.getBoundingClientRect();
529
+ p.current = v.height, f.current = v.width, g.current || ($.style.transitionDuration = m.current.transitionDuration, $.style.animationName = m.current.animationName), s(o);
530
+ }
531
+ }, [
532
+ a.open,
533
+ o
534
+ ]), /* @__PURE__ */ y(L.div, h({
535
+ "data-state": ie(a.open),
536
+ "data-disabled": a.disabled ? "" : void 0,
537
+ id: a.contentId,
538
+ hidden: !x
539
+ }, t, {
540
+ ref: d,
541
+ style: {
542
+ "--radix-collapsible-content-height": _ ? `${_}px` : void 0,
543
+ "--radix-collapsible-content-width": b ? `${b}px` : void 0,
544
+ ...e.style
545
+ }
546
+ }), x && c);
547
+ });
548
+ function ie(e) {
549
+ return e ? "open" : "closed";
550
+ }
551
+ const ut = at, pt = it, dt = st, ft = /* @__PURE__ */ ee(void 0);
552
+ function bt(e) {
553
+ const r = $e(ft);
554
+ return e || r || "ltr";
555
+ }
556
+ const I = "Accordion", $t = [
557
+ "Home",
558
+ "End",
559
+ "ArrowDown",
560
+ "ArrowUp",
561
+ "ArrowLeft",
562
+ "ArrowRight"
563
+ ], [se, _t, mt] = Je(I), [z, un] = oe(I, [
564
+ mt,
565
+ Ce
566
+ ]), le = Ce(), Ee = /* @__PURE__ */ u.forwardRef((e, r) => {
567
+ const { type: n, ...o } = e, c = o, t = o;
568
+ return /* @__PURE__ */ u.createElement(se.Provider, {
569
+ scope: e.__scopeAccordion
570
+ }, n === "multiple" ? /* @__PURE__ */ u.createElement(xt, h({}, t, {
571
+ ref: r
572
+ })) : /* @__PURE__ */ u.createElement(vt, h({}, c, {
573
+ ref: r
574
+ })));
575
+ });
576
+ Ee.propTypes = {
577
+ type(e) {
578
+ const r = e.value || e.defaultValue;
579
+ return e.type && ![
580
+ "single",
581
+ "multiple"
582
+ ].includes(e.type) ? new Error("Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`.") : e.type === "multiple" && typeof r == "string" ? new Error("Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`.") : e.type === "single" && Array.isArray(r) ? new Error("Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`.") : null;
583
+ }
584
+ };
585
+ const [Ie, ht] = z(I), [Pe, gt] = z(I, {
586
+ collapsible: !1
587
+ }), vt = /* @__PURE__ */ u.forwardRef((e, r) => {
588
+ const { value: n, defaultValue: o, onValueChange: c = () => {
589
+ }, collapsible: t = !1, ...a } = e, [i, s] = ae({
590
+ prop: n,
591
+ defaultProp: o,
592
+ onChange: c
593
+ });
594
+ return /* @__PURE__ */ u.createElement(Ie, {
595
+ scope: e.__scopeAccordion,
596
+ value: i ? [
597
+ i
598
+ ] : [],
599
+ onItemOpen: s,
600
+ onItemClose: u.useCallback(
601
+ () => t && s(""),
602
+ [
603
+ t,
604
+ s
605
+ ]
606
+ )
607
+ }, /* @__PURE__ */ u.createElement(Pe, {
608
+ scope: e.__scopeAccordion,
609
+ collapsible: t
610
+ }, /* @__PURE__ */ u.createElement(we, h({}, a, {
611
+ ref: r
612
+ }))));
613
+ }), xt = /* @__PURE__ */ u.forwardRef((e, r) => {
614
+ const { value: n, defaultValue: o, onValueChange: c = () => {
615
+ }, ...t } = e, [a = [], i] = ae({
616
+ prop: n,
617
+ defaultProp: o,
618
+ onChange: c
619
+ }), s = u.useCallback(
620
+ (d) => i(
621
+ (p = []) => [
622
+ ...p,
623
+ d
624
+ ]
625
+ ),
626
+ [
627
+ i
628
+ ]
629
+ ), l = u.useCallback(
630
+ (d) => i(
631
+ (p = []) => p.filter(
632
+ (_) => _ !== d
633
+ )
634
+ ),
635
+ [
636
+ i
637
+ ]
638
+ );
639
+ return /* @__PURE__ */ u.createElement(Ie, {
640
+ scope: e.__scopeAccordion,
641
+ value: a,
642
+ onItemOpen: s,
643
+ onItemClose: l
644
+ }, /* @__PURE__ */ u.createElement(Pe, {
645
+ scope: e.__scopeAccordion,
646
+ collapsible: !0
647
+ }, /* @__PURE__ */ u.createElement(we, h({}, t, {
648
+ ref: r
649
+ }))));
650
+ }), [At, K] = z(I), we = /* @__PURE__ */ u.forwardRef((e, r) => {
651
+ const { __scopeAccordion: n, disabled: o, dir: c, orientation: t = "vertical", ...a } = e, i = u.useRef(null), s = k(i, r), l = _t(n), p = bt(c) === "ltr", _ = ge(e.onKeyDown, (f) => {
652
+ var b;
653
+ if (!$t.includes(f.key))
654
+ return;
655
+ const x = f.target, g = l().filter((J) => {
656
+ var Q;
657
+ return !((Q = J.ref.current) !== null && Q !== void 0 && Q.disabled);
658
+ }), m = g.findIndex(
659
+ (J) => J.ref.current === x
660
+ ), $ = g.length;
661
+ if (m === -1)
662
+ return;
663
+ f.preventDefault();
664
+ let v = m;
665
+ const N = 0, O = $ - 1, Z = () => {
666
+ v = m + 1, v > O && (v = N);
667
+ }, Y = () => {
668
+ v = m - 1, v < N && (v = O);
669
+ };
670
+ switch (f.key) {
671
+ case "Home":
672
+ v = N;
673
+ break;
674
+ case "End":
675
+ v = O;
676
+ break;
677
+ case "ArrowRight":
678
+ t === "horizontal" && (p ? Z() : Y());
679
+ break;
680
+ case "ArrowDown":
681
+ t === "vertical" && Z();
682
+ break;
683
+ case "ArrowLeft":
684
+ t === "horizontal" && (p ? Y() : Z());
685
+ break;
686
+ case "ArrowUp":
687
+ t === "vertical" && Y();
688
+ break;
689
+ }
690
+ const De = v % $;
691
+ (b = g[De].ref.current) === null || b === void 0 || b.focus();
692
+ });
693
+ return /* @__PURE__ */ u.createElement(At, {
694
+ scope: n,
695
+ disabled: o,
696
+ direction: c,
697
+ orientation: t
698
+ }, /* @__PURE__ */ u.createElement(se.Slot, {
699
+ scope: n
700
+ }, /* @__PURE__ */ u.createElement(L.div, h({}, a, {
701
+ "data-orientation": t,
702
+ ref: s,
703
+ onKeyDown: o ? void 0 : _
704
+ }))));
705
+ }), ne = "AccordionItem", [yt, ue] = z(ne), Ct = /* @__PURE__ */ u.forwardRef((e, r) => {
706
+ const { __scopeAccordion: n, value: o, ...c } = e, t = K(ne, n), a = ht(ne, n), i = le(n), s = Ae(), l = o && a.value.includes(o) || !1, d = t.disabled || e.disabled;
707
+ return /* @__PURE__ */ u.createElement(yt, {
708
+ scope: n,
709
+ open: l,
710
+ disabled: d,
711
+ triggerId: s
712
+ }, /* @__PURE__ */ u.createElement(ut, h({
713
+ "data-orientation": t.orientation,
714
+ "data-state": Se(l)
715
+ }, i, c, {
716
+ ref: r,
717
+ disabled: d,
718
+ open: l,
719
+ onOpenChange: (p) => {
720
+ p ? a.onItemOpen(o) : a.onItemClose(o);
721
+ }
722
+ })));
723
+ }), Nt = "AccordionHeader", Et = /* @__PURE__ */ u.forwardRef((e, r) => {
724
+ const { __scopeAccordion: n, ...o } = e, c = K(I, n), t = ue(Nt, n);
725
+ return /* @__PURE__ */ u.createElement(L.h3, h({
726
+ "data-orientation": c.orientation,
727
+ "data-state": Se(t.open),
728
+ "data-disabled": t.disabled ? "" : void 0
729
+ }, o, {
730
+ ref: r
731
+ }));
732
+ }), pe = "AccordionTrigger", It = /* @__PURE__ */ u.forwardRef((e, r) => {
733
+ const { __scopeAccordion: n, ...o } = e, c = K(I, n), t = ue(pe, n), a = gt(pe, n), i = le(n);
734
+ return /* @__PURE__ */ u.createElement(se.ItemSlot, {
735
+ scope: n
736
+ }, /* @__PURE__ */ u.createElement(pt, h({
737
+ "aria-disabled": t.open && !a.collapsible || void 0,
738
+ "data-orientation": c.orientation,
739
+ id: t.triggerId
740
+ }, i, o, {
741
+ ref: r
742
+ })));
743
+ }), Pt = "AccordionContent", wt = /* @__PURE__ */ u.forwardRef((e, r) => {
744
+ const { __scopeAccordion: n, ...o } = e, c = K(I, n), t = ue(Pt, n), a = le(n);
745
+ return /* @__PURE__ */ u.createElement(dt, h({
746
+ role: "region",
747
+ "aria-labelledby": t.triggerId,
748
+ "data-orientation": c.orientation
749
+ }, a, o, {
750
+ ref: r,
751
+ style: {
752
+ "--radix-accordion-content-height": "var(--radix-collapsible-content-height)",
753
+ "--radix-accordion-content-width": "var(--radix-collapsible-content-width)",
754
+ ...e.style
755
+ }
756
+ }));
757
+ });
758
+ function Se(e) {
759
+ return e ? "open" : "closed";
760
+ }
761
+ const St = Ee, Ot = Ct, Rt = Et, Tt = It, Mt = wt;
762
+ function kt(e) {
763
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
764
+ }
765
+ var Oe = { exports: {} };
766
+ /*!
767
+ Copyright (c) 2018 Jed Watson.
768
+ Licensed under the MIT License (MIT), see
769
+ http://jedwatson.github.io/classnames
770
+ */
771
+ (function(e) {
772
+ (function() {
773
+ var r = {}.hasOwnProperty;
774
+ function n() {
775
+ for (var t = "", a = 0; a < arguments.length; a++) {
776
+ var i = arguments[a];
777
+ i && (t = c(t, o.call(this, i)));
778
+ }
779
+ return t;
780
+ }
781
+ function o(t) {
782
+ if (typeof t == "string" || typeof t == "number")
783
+ return this && this[t] || t;
784
+ if (typeof t != "object")
785
+ return "";
786
+ if (Array.isArray(t))
787
+ return n.apply(this, t);
788
+ if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]"))
789
+ return t.toString();
790
+ var a = "";
791
+ for (var i in t)
792
+ r.call(t, i) && t[i] && (a = c(a, this && this[i] || i));
793
+ return a;
794
+ }
795
+ function c(t, a) {
796
+ return a ? t ? t + " " + a : t + a : t;
797
+ }
798
+ e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
799
+ })();
800
+ })(Oe);
801
+ var Dt = Oe.exports;
802
+ const Re = /* @__PURE__ */ kt(Dt), Lt = {
803
+ "purpur-accordion__title": "_purpur-accordion__title_1ower_1",
804
+ "purpur-accordion--negative": "_purpur-accordion--negative_1ower_10"
805
+ };
806
+ function jt(e) {
807
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
808
+ }
809
+ var Te = { exports: {} };
810
+ /*!
811
+ Copyright (c) 2018 Jed Watson.
812
+ Licensed under the MIT License (MIT), see
813
+ http://jedwatson.github.io/classnames
814
+ */
815
+ (function(e) {
816
+ (function() {
817
+ var r = {}.hasOwnProperty;
818
+ function n() {
819
+ for (var t = "", a = 0; a < arguments.length; a++) {
820
+ var i = arguments[a];
821
+ i && (t = c(t, o.call(this, i)));
822
+ }
823
+ return t;
824
+ }
825
+ function o(t) {
826
+ if (typeof t == "string" || typeof t == "number")
827
+ return this && this[t] || t;
828
+ if (typeof t != "object")
829
+ return "";
830
+ if (Array.isArray(t))
831
+ return n.apply(this, t);
832
+ if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]"))
833
+ return t.toString();
834
+ var a = "";
835
+ for (var i in t)
836
+ r.call(t, i) && t[i] && (a = c(a, this && this[i] || i));
837
+ return a;
838
+ }
839
+ function c(t, a) {
840
+ return a ? t ? t + " " + a : t + a : t;
841
+ }
842
+ e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
843
+ })();
844
+ })(Te);
845
+ var qt = Te.exports;
846
+ const Vt = /* @__PURE__ */ jt(qt), Ut = {
847
+ "purpur-icon": "_purpur-icon_8u1lq_1",
848
+ "purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
849
+ "purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
850
+ "purpur-icon--sm": "_purpur-icon--sm_8u1lq_12",
851
+ "purpur-icon--md": "_purpur-icon--md_8u1lq_16",
852
+ "purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
853
+ "purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
854
+ }, Bt = {
855
+ name: "chevron-down",
856
+ svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M20.136 7.864a.9.9 0 0 0-1.272 0L12 14.727 5.136 7.864a.9.9 0 0 0-1.272 1.272l7.5 7.5a.9.9 0 0 0 1.272 0l7.5-7.5a.9.9 0 0 0 0-1.272Z" clip-rule="evenodd"/></svg>',
857
+ keywords: ["chevron-down"],
858
+ category: "utility"
859
+ }, Me = (e) => /* @__PURE__ */ A(
860
+ Zt,
861
+ {
862
+ ...e,
863
+ svg: Bt
864
+ }
865
+ );
866
+ Me.displayName = "IconChevronDown";
867
+ const Ht = Vt.bind(Ut), de = "purpur-icon", Gt = "md", Ft = (e) => e.filter((r) => Object.keys(r).length >= 1).map((r) => `${r.name}="${r.value}"`).join(" "), zt = ({ content: e = "", title: r } = {}) => {
868
+ const n = [
869
+ { name: "xmlns", value: "http://www.w3.org/2000/svg" },
870
+ { name: "fill", value: "currentColor" },
871
+ { name: "viewBox", value: "0 0 24 24" },
872
+ r ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
873
+ ], o = r ? `<title>${r}</title>` : "";
874
+ return `<svg ${Ft(n)}>${o}${e}</svg>`;
875
+ }, Kt = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), Zt = ({
876
+ ["data-testid"]: e,
877
+ svg: r,
878
+ allyTitle: n,
879
+ className: o = "",
880
+ size: c = Gt,
881
+ ...t
882
+ }) => {
883
+ const a = zt({
884
+ content: Kt(r.svg),
885
+ title: n
886
+ }), i = Ht(o, de, `${de}--${c}`);
887
+ return /* @__PURE__ */ A(
888
+ "span",
889
+ {
890
+ "aria-label": n,
891
+ className: i,
892
+ "data-testid": e,
893
+ dangerouslySetInnerHTML: { __html: a },
894
+ ...t
895
+ }
896
+ );
897
+ };
898
+ function Yt(e) {
899
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
900
+ }
901
+ var ke = { exports: {} };
902
+ /*!
903
+ Copyright (c) 2018 Jed Watson.
904
+ Licensed under the MIT License (MIT), see
905
+ http://jedwatson.github.io/classnames
906
+ */
907
+ (function(e) {
908
+ (function() {
909
+ var r = {}.hasOwnProperty;
910
+ function n() {
911
+ for (var t = "", a = 0; a < arguments.length; a++) {
912
+ var i = arguments[a];
913
+ i && (t = c(t, o(i)));
914
+ }
915
+ return t;
916
+ }
917
+ function o(t) {
918
+ if (typeof t == "string" || typeof t == "number")
919
+ return t;
920
+ if (typeof t != "object")
921
+ return "";
922
+ if (Array.isArray(t))
923
+ return n.apply(null, t);
924
+ if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]"))
925
+ return t.toString();
926
+ var a = "";
927
+ for (var i in t)
928
+ r.call(t, i) && t[i] && (a = c(a, i));
929
+ return a;
930
+ }
931
+ function c(t, a) {
932
+ return a ? t ? t + " " + a : t + a : t;
933
+ }
934
+ e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
935
+ })();
936
+ })(ke);
937
+ var Jt = ke.exports;
938
+ const Qt = /* @__PURE__ */ Yt(Jt), R = {
939
+ "purpur-paragraph": "_purpur-paragraph_1rh57_1",
940
+ "purpur-paragraph--disabled": "_purpur-paragraph--disabled_1rh57_7",
941
+ "purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_1rh57_10",
942
+ "purpur-paragraph--negative": "_purpur-paragraph--negative_1rh57_13",
943
+ "purpur-paragraph--paragraph-100": "_purpur-paragraph--paragraph-100_1rh57_16",
944
+ "purpur-paragraph--paragraph-100-medium": "_purpur-paragraph--paragraph-100-medium_1rh57_22",
945
+ "purpur-paragraph--paragraph-100-bold": "_purpur-paragraph--paragraph-100-bold_1rh57_29",
946
+ "purpur-paragraph--paragraph-200": "_purpur-paragraph--paragraph-200_1rh57_36",
947
+ "purpur-paragraph--preamble-100": "_purpur-paragraph--preamble-100_1rh57_42",
948
+ "purpur-paragraph--preamble-200": "_purpur-paragraph--preamble-200_1rh57_48",
949
+ "purpur-paragraph--additional-100": "_purpur-paragraph--additional-100_1rh57_54",
950
+ "purpur-paragraph--additional-100-medium": "_purpur-paragraph--additional-100-medium_1rh57_60",
951
+ "purpur-paragraph--overline-100": "_purpur-paragraph--overline-100_1rh57_67",
952
+ "purpur-paragraph--overline-200": "_purpur-paragraph--overline-200_1rh57_75"
953
+ }, Wt = {
954
+ PARAGRAPH100: "paragraph-100",
955
+ PARAGRAPH100MEDIUM: "paragraph-100-medium",
956
+ PARAGRAPH100BOLD: "paragraph-100-bold",
957
+ PARAGRAPH200: "paragraph-200",
958
+ PREAMBLE100: "preamble-100",
959
+ PREAMBLE200: "preamble-200",
960
+ ADDITIONAL100: "additional-100",
961
+ ADDITIONAL100MEDIUM: "additional-100-medium",
962
+ OVERLINE100: "overline-100",
963
+ OVERLINE200: "overline-200"
964
+ }, T = "purpur-paragraph", Xt = ({
965
+ ["data-testid"]: e,
966
+ children: r,
967
+ className: n = "",
968
+ disabled: o,
969
+ enableHyphenation: c = !1,
970
+ negative: t = !1,
971
+ variant: a = Wt.PARAGRAPH100,
972
+ ...i
973
+ }) => {
974
+ const s = Qt([
975
+ n,
976
+ R[T],
977
+ R[`${T}--${a}`],
978
+ {
979
+ [R[`${T}--hyphens`]]: c,
980
+ [R[`${T}--disabled`]]: o,
981
+ [R[`${T}--negative`]]: t
982
+ }
983
+ ]);
984
+ return /* @__PURE__ */ A("p", { ...i, className: s, "data-testid": e, children: r });
985
+ }, en = "_slideDown_8k8nf_1", tn = "_slideUp_8k8nf_1", nn = {
986
+ "purpur-accordion-item": "_purpur-accordion-item_8k8nf_1",
987
+ "purpur-accordion-item__header": "_purpur-accordion-item__header_8k8nf_8",
988
+ "purpur-accordion-item__trigger": "_purpur-accordion-item__trigger_8k8nf_11",
989
+ "purpur-accordion-item__content": "_purpur-accordion-item__content_8k8nf_35",
990
+ slideDown: en,
991
+ slideUp: tn,
992
+ "purpur-accordion-item__contentText": "_purpur-accordion-item__contentText_8k8nf_44",
993
+ "purpur-accordion-item__icon": "_purpur-accordion-item__icon_8k8nf_48",
994
+ "purpur-accordion-item__title": "_purpur-accordion-item__title_8k8nf_60",
995
+ "purpur-accordion-item--negative": "_purpur-accordion-item--negative_8k8nf_78"
996
+ }, P = Re.bind(nn), E = "purpur-accordion-item", rn = ({
997
+ children: e,
998
+ className: r,
999
+ title: n,
1000
+ negative: o,
1001
+ ...c
1002
+ }) => {
1003
+ const t = P([
1004
+ r,
1005
+ E,
1006
+ {
1007
+ [`${E}--negative`]: o
1008
+ }
1009
+ ]);
1010
+ return /* @__PURE__ */ X(Ot, { className: t, value: n, ...c, children: [
1011
+ /* @__PURE__ */ A(Rt, { className: P(`${E}__header`), asChild: !0, children: /* @__PURE__ */ X(Tt, { className: P(`${E}__trigger`, r), children: [
1012
+ /* @__PURE__ */ A(me, { tag: "h3", variant: "title-100", className: P(`${E}__title`), children: n }),
1013
+ /* @__PURE__ */ A(Me, { size: "md", className: P(`${E}__icon`), "aria-hidden": !0 })
1014
+ ] }) }),
1015
+ /* @__PURE__ */ A(Mt, { className: P(`${E}__content`, r), children: /* @__PURE__ */ A("div", { className: P(`${E}__contentText`), children: typeof e == "string" ? /* @__PURE__ */ A(Xt, { variant: "paragraph-200", children: e }) : e }) })
1016
+ ] });
1017
+ }, on = (e) => M(e) && (e == null ? void 0 : e.type) === rn, fe = Re.bind(Lt), W = "purpur-accordion", an = ({
1018
+ ["data-testid"]: e,
1019
+ children: r,
1020
+ className: n,
1021
+ negative: o = !1,
1022
+ title: c,
1023
+ titleVariant: t = "title-300"
1024
+ }) => {
1025
+ const a = fe([
1026
+ n,
1027
+ W,
1028
+ {
1029
+ [`${W}--negative`]: o
1030
+ }
1031
+ ]), i = () => w.map(r, (s) => {
1032
+ if (on(s))
1033
+ return F(s, { negative: o });
1034
+ });
1035
+ return /* @__PURE__ */ X(St, { className: a, type: "multiple", "data-testid": e, children: [
1036
+ c ? /* @__PURE__ */ A(me, { tag: "h2", variant: t, className: fe(`${W}__title`), children: c }) : null,
1037
+ i()
1038
+ ] });
1039
+ };
1040
+ an.displayName = "Accordion";
1041
+ export {
1042
+ an as Accordion
1043
+ };
1044
+ //# sourceMappingURL=accordion.es.js.map