@purpurds/tabs 6.0.0 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tabs.es.js CHANGED
@@ -1,11 +1,11 @@
1
- import { jsx as T, jsxs as ee } from "react/jsx-runtime";
2
- import * as ve from "react";
3
- import E, { createContext as ne, useMemo as H, createElement as g, useContext as ge, useCallback as L, forwardRef as w, Children as P, isValidElement as z, cloneElement as se, Fragment as Le, useLayoutEffect as Ue, useEffect as N, useRef as R, useState as F, useReducer as Ve } from "react";
4
- import { flushSync as Be } from "react-dom";
1
+ import { jsx as m, Fragment as Be, jsxs as X } from "react/jsx-runtime";
2
+ import * as a from "react";
3
+ import P, { forwardRef as pe, isValidElement as je, useState as U, Children as B, useRef as ae, useEffect as j } from "react";
4
+ import "react-dom";
5
5
  function Ge(e) {
6
6
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
7
7
  }
8
- var he = { exports: {} };
8
+ var me = { exports: {} };
9
9
  /*!
10
10
  Copyright (c) 2018 Jed Watson.
11
11
  Licensed under the MIT License (MIT), see
@@ -15,9 +15,9 @@ var he = { exports: {} };
15
15
  (function() {
16
16
  var t = {}.hasOwnProperty;
17
17
  function n() {
18
- for (var r = "", c = 0; c < arguments.length; c++) {
19
- var a = arguments[c];
20
- a && (r = s(r, o.call(this, a)));
18
+ for (var r = "", i = 0; i < arguments.length; i++) {
19
+ var c = arguments[i];
20
+ c && (r = s(r, o.call(this, c)));
21
21
  }
22
22
  return r;
23
23
  }
@@ -30,19 +30,19 @@ var he = { exports: {} };
30
30
  return n.apply(this, r);
31
31
  if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
32
32
  return r.toString();
33
- var c = "";
34
- for (var a in r)
35
- t.call(r, a) && r[a] && (c = s(c, this && this[a] || a));
36
- return c;
33
+ var i = "";
34
+ for (var c in r)
35
+ t.call(r, c) && r[c] && (i = s(i, this && this[c] || c));
36
+ return i;
37
37
  }
38
- function s(r, c) {
39
- return c ? r ? r + " " + c : r + c : r;
38
+ function s(r, i) {
39
+ return i ? r ? r + " " + i : r + i : r;
40
40
  }
41
41
  e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
42
42
  })();
43
- })(he);
44
- var je = he.exports;
45
- const ke = /* @__PURE__ */ Ge(je), Ke = {
43
+ })(me);
44
+ var We = me.exports;
45
+ const ke = /* @__PURE__ */ Ge(We), Ke = {
46
46
  "purpur-icon": "_purpur-icon_8u1lq_1",
47
47
  "purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
48
48
  "purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
@@ -50,268 +50,216 @@ const ke = /* @__PURE__ */ Ge(je), Ke = {
50
50
  "purpur-icon--md": "_purpur-icon--md_8u1lq_16",
51
51
  "purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
52
52
  "purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
53
- }, ze = ke.bind(Ke), $e = "purpur-icon", We = "md", Ye = (e) => e.filter((t) => Object.keys(t).length >= 1).map((t) => `${t.name}="${t.value}"`).join(" "), Ze = ({ content: e = "", title: t } = {}) => {
53
+ }, ze = ke.bind(Ke), ue = "purpur-icon", Ye = "md", Ze = (e) => e.filter((t) => Object.keys(t).length >= 1).map((t) => `${t.name}="${t.value}"`).join(" "), Xe = ({ content: e = "", title: t } = {}) => {
54
54
  const n = [
55
55
  { name: "xmlns", value: "http://www.w3.org/2000/svg" },
56
56
  { name: "fill", value: "currentColor" },
57
57
  { name: "viewBox", value: "0 0 24 24" },
58
58
  t ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
59
59
  ], o = t ? `<title>${t}</title>` : "";
60
- return `<svg ${Ye(n)}>${o}${e}</svg>`;
61
- }, He = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), xe = ({
60
+ return `<svg ${Ze(n)}>${o}${e}</svg>`;
61
+ }, Je = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), _e = ({
62
62
  ["data-testid"]: e,
63
63
  svg: t,
64
64
  allyTitle: n,
65
65
  className: o,
66
- size: s = We,
66
+ size: s = Ye,
67
67
  ...r
68
68
  }) => {
69
- const c = Ze({
70
- content: He(t.svg),
69
+ const i = Xe({
70
+ content: Je(t.svg),
71
71
  title: n
72
- }), a = ze(o, $e, `${$e}--${s}`);
73
- return /* @__PURE__ */ T(
72
+ }), c = ze(o, ue, `${ue}--${s}`);
73
+ return /* @__PURE__ */ m(
74
74
  "span",
75
75
  {
76
76
  "aria-label": n,
77
- className: a,
77
+ className: c,
78
78
  "data-testid": e,
79
- dangerouslySetInnerHTML: { __html: c },
79
+ dangerouslySetInnerHTML: { __html: i },
80
80
  ...r
81
81
  }
82
82
  );
83
83
  };
84
- xe.displayName = "Icon";
85
- const Xe = {
84
+ _e.displayName = "Icon";
85
+ const Qe = {
86
86
  name: "chevron-left",
87
87
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M16.175 3.905a.9.9 0 0 1-.08 1.27L8.36 12l7.736 6.825a.9.9 0 0 1-1.191 1.35l-8.5-7.5a.9.9 0 0 1 0-1.35l8.5-7.5a.9.9 0 0 1 1.27.08Z" clip-rule="evenodd"/></svg>',
88
88
  keywords: ["chevron-left"],
89
89
  category: "utility"
90
- }, Je = {
90
+ }, He = {
91
91
  name: "chevron-right",
92
92
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M7.809 3.924a.9.9 0 0 0 .115 1.267L16.094 12l-8.17 6.809a.9.9 0 0 0 1.152 1.382l9-7.5a.9.9 0 0 0 0-1.382l-9-7.5a.9.9 0 0 0-1.267.115Z" clip-rule="evenodd"/></svg>',
93
93
  keywords: ["chevron-right"],
94
94
  category: "utility"
95
95
  };
96
- function C() {
97
- return C = Object.assign ? Object.assign.bind() : function(e) {
98
- for (var t = 1; t < arguments.length; t++) {
99
- var n = arguments[t];
100
- for (var o in n) ({}).hasOwnProperty.call(n, o) && (e[o] = n[o]);
101
- }
102
- return e;
103
- }, C.apply(null, arguments);
104
- }
105
- function O(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
96
+ function x(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
106
97
  return function(s) {
107
- if (e == null || e(s), n === !1 || !s.defaultPrevented) return t == null ? void 0 : t(s);
98
+ if (e == null || e(s), n === !1 || !s.defaultPrevented)
99
+ return t == null ? void 0 : t(s);
108
100
  };
109
101
  }
110
- function ae(e, t = []) {
102
+ function te(e, t = []) {
111
103
  let n = [];
112
- function o(r, c) {
113
- const a = /* @__PURE__ */ ne(c), u = n.length;
114
- n = [
115
- ...n,
116
- c
117
- ];
118
- function i(l) {
119
- const { scope: m, children: _, ...f } = l, h = (m == null ? void 0 : m[e][u]) || a, $ = H(
120
- () => f,
121
- Object.values(f)
122
- );
123
- return /* @__PURE__ */ g(h.Provider, {
124
- value: $
125
- }, _);
126
- }
127
- function p(l, m) {
128
- const _ = (m == null ? void 0 : m[e][u]) || a, f = ge(_);
104
+ function o(r, i) {
105
+ const c = a.createContext(i), u = n.length;
106
+ n = [...n, i];
107
+ const l = (d) => {
108
+ var _;
109
+ const { scope: b, children: h, ...f } = d, y = ((_ = b == null ? void 0 : b[e]) == null ? void 0 : _[u]) || c, v = a.useMemo(() => f, Object.values(f));
110
+ return /* @__PURE__ */ m(y.Provider, { value: v, children: h });
111
+ };
112
+ l.displayName = r + "Provider";
113
+ function g(d, b) {
114
+ var y;
115
+ const h = ((y = b == null ? void 0 : b[e]) == null ? void 0 : y[u]) || c, f = a.useContext(h);
129
116
  if (f) return f;
130
- if (c !== void 0) return c;
131
- throw new Error(`\`${l}\` must be used within \`${r}\``);
117
+ if (i !== void 0) return i;
118
+ throw new Error(`\`${d}\` must be used within \`${r}\``);
132
119
  }
133
- return i.displayName = r + "Provider", [
134
- i,
135
- p
136
- ];
120
+ return [l, g];
137
121
  }
138
122
  const s = () => {
139
- const r = n.map((c) => /* @__PURE__ */ ne(c));
140
- return function(a) {
141
- const u = (a == null ? void 0 : a[e]) || r;
142
- return H(
143
- () => ({
144
- [`__scope${e}`]: {
145
- ...a,
146
- [e]: u
147
- }
148
- }),
149
- [
150
- a,
151
- u
152
- ]
123
+ const r = n.map((i) => a.createContext(i));
124
+ return function(c) {
125
+ const u = (c == null ? void 0 : c[e]) || r;
126
+ return a.useMemo(
127
+ () => ({ [`__scope${e}`]: { ...c, [e]: u } }),
128
+ [c, u]
153
129
  );
154
130
  };
155
131
  };
156
- return s.scopeName = e, [
157
- o,
158
- Qe(s, ...t)
159
- ];
132
+ return s.scopeName = e, [o, et(s, ...t)];
160
133
  }
161
- function Qe(...e) {
134
+ function et(...e) {
162
135
  const t = e[0];
163
136
  if (e.length === 1) return t;
164
137
  const n = () => {
165
- const o = e.map(
166
- (s) => ({
167
- useScope: s(),
168
- scopeName: s.scopeName
169
- })
170
- );
138
+ const o = e.map((s) => ({
139
+ useScope: s(),
140
+ scopeName: s.scopeName
141
+ }));
171
142
  return function(r) {
172
- const c = o.reduce((a, { useScope: u, scopeName: i }) => {
173
- const l = u(r)[`__scope${i}`];
174
- return {
175
- ...a,
176
- ...l
177
- };
143
+ const i = o.reduce((c, { useScope: u, scopeName: l }) => {
144
+ const d = u(r)[`__scope${l}`];
145
+ return { ...c, ...d };
178
146
  }, {});
179
- return H(
180
- () => ({
181
- [`__scope${t.scopeName}`]: c
182
- }),
183
- [
184
- c
185
- ]
186
- );
147
+ return a.useMemo(() => ({ [`__scope${t.scopeName}`]: i }), [i]);
187
148
  };
188
149
  };
189
150
  return n.scopeName = t.scopeName, n;
190
151
  }
191
- function et(e, t) {
192
- typeof e == "function" ? e(t) : e != null && (e.current = t);
152
+ function le(e, t) {
153
+ if (typeof e == "function")
154
+ return e(t);
155
+ e != null && (e.current = t);
193
156
  }
194
- function Ie(...e) {
195
- return (t) => e.forEach(
196
- (n) => et(n, t)
197
- );
157
+ function ge(...e) {
158
+ return (t) => {
159
+ let n = !1;
160
+ const o = e.map((s) => {
161
+ const r = le(s, t);
162
+ return !n && typeof r == "function" && (n = !0), r;
163
+ });
164
+ if (n)
165
+ return () => {
166
+ for (let s = 0; s < o.length; s++) {
167
+ const r = o[s];
168
+ typeof r == "function" ? r() : le(e[s], null);
169
+ }
170
+ };
171
+ };
198
172
  }
199
- function X(...e) {
200
- return L(Ie(...e), e);
173
+ function W(...e) {
174
+ return a.useCallback(ge(...e), e);
201
175
  }
202
- const J = /* @__PURE__ */ w((e, t) => {
203
- const { children: n, ...o } = e, s = P.toArray(n), r = s.find(nt);
176
+ var k = a.forwardRef((e, t) => {
177
+ const { children: n, ...o } = e, s = a.Children.toArray(n), r = s.find(nt);
204
178
  if (r) {
205
- const c = r.props.children, a = s.map((u) => u === r ? P.count(c) > 1 ? P.only(null) : /* @__PURE__ */ z(c) ? c.props.children : null : u);
206
- return /* @__PURE__ */ g(re, C({}, o, {
207
- ref: t
208
- }), /* @__PURE__ */ z(c) ? /* @__PURE__ */ se(c, void 0, a) : null);
179
+ const i = r.props.children, c = s.map((u) => u === r ? a.Children.count(i) > 1 ? a.Children.only(null) : a.isValidElement(i) ? i.props.children : null : u);
180
+ return /* @__PURE__ */ m(Q, { ...o, ref: t, children: a.isValidElement(i) ? a.cloneElement(i, void 0, c) : null });
209
181
  }
210
- return /* @__PURE__ */ g(re, C({}, o, {
211
- ref: t
212
- }), n);
182
+ return /* @__PURE__ */ m(Q, { ...o, ref: t, children: n });
213
183
  });
214
- J.displayName = "Slot";
215
- const re = /* @__PURE__ */ w((e, t) => {
184
+ k.displayName = "Slot";
185
+ var Q = a.forwardRef((e, t) => {
216
186
  const { children: n, ...o } = e;
217
- return /* @__PURE__ */ z(n) ? /* @__PURE__ */ se(n, {
218
- ...rt(o, n.props),
219
- ref: t ? Ie(t, n.ref) : n.ref
220
- }) : P.count(n) > 1 ? P.only(null) : null;
187
+ if (a.isValidElement(n)) {
188
+ const s = ot(n), r = rt(o, n.props);
189
+ return n.type !== a.Fragment && (r.ref = t ? ge(t, s) : s), a.cloneElement(n, r);
190
+ }
191
+ return a.Children.count(n) > 1 ? a.Children.only(null) : null;
221
192
  });
222
- re.displayName = "SlotClone";
223
- const tt = ({ children: e }) => /* @__PURE__ */ g(Le, null, e);
193
+ Q.displayName = "SlotClone";
194
+ var tt = ({ children: e }) => /* @__PURE__ */ m(Be, { children: e });
224
195
  function nt(e) {
225
- return /* @__PURE__ */ z(e) && e.type === tt;
196
+ return a.isValidElement(e) && e.type === tt;
226
197
  }
227
198
  function rt(e, t) {
228
- const n = {
229
- ...t
230
- };
199
+ const n = { ...t };
231
200
  for (const o in t) {
232
201
  const s = e[o], r = t[o];
233
- /^on[A-Z]/.test(o) ? s && r ? n[o] = (...a) => {
234
- r(...a), s(...a);
235
- } : s && (n[o] = s) : o === "style" ? n[o] = {
236
- ...s,
237
- ...r
238
- } : o === "className" && (n[o] = [
239
- s,
240
- r
241
- ].filter(Boolean).join(" "));
202
+ /^on[A-Z]/.test(o) ? s && r ? n[o] = (...c) => {
203
+ r(...c), s(...c);
204
+ } : s && (n[o] = s) : o === "style" ? n[o] = { ...s, ...r } : o === "className" && (n[o] = [s, r].filter(Boolean).join(" "));
242
205
  }
243
- return {
244
- ...e,
245
- ...n
246
- };
206
+ return { ...e, ...n };
247
207
  }
248
208
  function ot(e) {
249
- const t = e + "CollectionProvider", [n, o] = ae(t), [s, r] = n(t, {
250
- collectionRef: {
251
- current: null
252
- },
253
- itemMap: /* @__PURE__ */ new Map()
254
- }), c = (_) => {
255
- const { scope: f, children: h } = _, $ = E.useRef(null), b = E.useRef(/* @__PURE__ */ new Map()).current;
256
- return /* @__PURE__ */ E.createElement(s, {
257
- scope: f,
258
- itemMap: b,
259
- collectionRef: $
260
- }, h);
261
- }, a = e + "CollectionSlot", u = /* @__PURE__ */ E.forwardRef((_, f) => {
262
- const { scope: h, children: $ } = _, b = r(a, h), v = X(f, b.collectionRef);
263
- return /* @__PURE__ */ E.createElement(J, {
264
- ref: v
265
- }, $);
266
- }), i = e + "CollectionItemSlot", p = "data-radix-collection-item", l = /* @__PURE__ */ E.forwardRef((_, f) => {
267
- const { scope: h, children: $, ...b } = _, v = E.useRef(null), U = X(f, v), y = r(i, h);
268
- return E.useEffect(() => (y.itemMap.set(v, {
269
- ref: v,
270
- ...b
271
- }), () => void y.itemMap.delete(v))), /* @__PURE__ */ E.createElement(J, {
272
- [p]: "",
273
- ref: U
274
- }, $);
275
- });
276
- function m(_) {
277
- const f = r(e + "CollectionConsumer", _);
278
- return E.useCallback(() => {
279
- const $ = f.collectionRef.current;
280
- if (!$) return [];
281
- const b = Array.from($.querySelectorAll(`[${p}]`));
209
+ var o, s;
210
+ let t = (o = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning;
211
+ return n ? e.ref : (t = (s = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : s.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
212
+ }
213
+ function st(e) {
214
+ const t = e + "CollectionProvider", [n, o] = te(t), [s, r] = n(
215
+ t,
216
+ { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
217
+ ), i = (h) => {
218
+ const { scope: f, children: y } = h, v = P.useRef(null), _ = P.useRef(/* @__PURE__ */ new Map()).current;
219
+ return /* @__PURE__ */ m(s, { scope: f, itemMap: _, collectionRef: v, children: y });
220
+ };
221
+ i.displayName = t;
222
+ const c = e + "CollectionSlot", u = P.forwardRef(
223
+ (h, f) => {
224
+ const { scope: y, children: v } = h, _ = r(c, y), w = W(f, _.collectionRef);
225
+ return /* @__PURE__ */ m(k, { ref: w, children: v });
226
+ }
227
+ );
228
+ u.displayName = c;
229
+ const l = e + "CollectionItemSlot", g = "data-radix-collection-item", d = P.forwardRef(
230
+ (h, f) => {
231
+ const { scope: y, children: v, ..._ } = h, w = P.useRef(null), E = W(f, w), N = r(l, y);
232
+ return P.useEffect(() => (N.itemMap.set(w, { ref: w, ..._ }), () => void N.itemMap.delete(w))), /* @__PURE__ */ m(k, { [g]: "", ref: E, children: v });
233
+ }
234
+ );
235
+ d.displayName = l;
236
+ function b(h) {
237
+ const f = r(e + "CollectionConsumer", h);
238
+ return P.useCallback(() => {
239
+ const v = f.collectionRef.current;
240
+ if (!v) return [];
241
+ const _ = Array.from(v.querySelectorAll(`[${g}]`));
282
242
  return Array.from(f.itemMap.values()).sort(
283
- (y, j) => b.indexOf(y.ref.current) - b.indexOf(j.ref.current)
243
+ (N, A) => _.indexOf(N.ref.current) - _.indexOf(A.ref.current)
284
244
  );
285
- }, [
286
- f.collectionRef,
287
- f.itemMap
288
- ]);
245
+ }, [f.collectionRef, f.itemMap]);
289
246
  }
290
247
  return [
291
- {
292
- Provider: c,
293
- Slot: u,
294
- ItemSlot: l
295
- },
296
- m,
248
+ { Provider: i, Slot: u, ItemSlot: d },
249
+ b,
297
250
  o
298
251
  ];
299
252
  }
300
- const oe = globalThis != null && globalThis.document ? Ue : () => {
301
- }, ct = ve.useId || (() => {
302
- });
303
- let st = 0;
304
- function Ce(e) {
305
- const [t, n] = ve.useState(ct());
306
- return oe(() => {
307
- e || n(
308
- (o) => o ?? String(st++)
309
- );
310
- }, [
311
- e
312
- ]), e || (t ? `radix-${t}` : "");
253
+ var H = globalThis != null && globalThis.document ? a.useLayoutEffect : () => {
254
+ }, it = a.useId || (() => {
255
+ }), ct = 0;
256
+ function be(e) {
257
+ const [t, n] = a.useState(it());
258
+ return H(() => {
259
+ e || n((o) => o ?? String(ct++));
260
+ }, [e]), e || (t ? `radix-${t}` : "");
313
261
  }
314
- const at = [
262
+ var at = [
315
263
  "a",
316
264
  "button",
317
265
  "div",
@@ -328,212 +276,190 @@ const at = [
328
276
  "span",
329
277
  "svg",
330
278
  "ul"
331
- ], G = at.reduce((e, t) => {
332
- const n = /* @__PURE__ */ w((o, s) => {
333
- const { asChild: r, ...c } = o, a = r ? J : t;
334
- return N(() => {
335
- window[Symbol.for("radix-ui")] = !0;
336
- }, []), /* @__PURE__ */ g(a, C({}, c, {
337
- ref: s
338
- }));
279
+ ], D = at.reduce((e, t) => {
280
+ const n = a.forwardRef((o, s) => {
281
+ const { asChild: r, ...i } = o, c = r ? k : t;
282
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ m(c, { ...i, ref: s });
339
283
  });
340
- return n.displayName = `Primitive.${t}`, {
341
- ...e,
342
- [t]: n
343
- };
284
+ return n.displayName = `Primitive.${t}`, { ...e, [t]: n };
344
285
  }, {});
345
- function ie(e) {
346
- const t = R(e);
347
- return N(() => {
286
+ function ne(e) {
287
+ const t = a.useRef(e);
288
+ return a.useEffect(() => {
348
289
  t.current = e;
349
- }), H(
350
- () => (...n) => {
351
- var o;
352
- return (o = t.current) === null || o === void 0 ? void 0 : o.call(t, ...n);
290
+ }), a.useMemo(() => (...n) => {
291
+ var o;
292
+ return (o = t.current) == null ? void 0 : o.call(t, ...n);
293
+ }, []);
294
+ }
295
+ function ve({
296
+ prop: e,
297
+ defaultProp: t,
298
+ onChange: n = () => {
299
+ }
300
+ }) {
301
+ const [o, s] = ut({ defaultProp: t, onChange: n }), r = e !== void 0, i = r ? e : o, c = ne(n), u = a.useCallback(
302
+ (l) => {
303
+ if (r) {
304
+ const d = typeof l == "function" ? l(e) : l;
305
+ d !== e && c(d);
306
+ } else
307
+ s(l);
353
308
  },
354
- []
309
+ [r, e, s, c]
355
310
  );
311
+ return [i, u];
356
312
  }
357
- function ye({ prop: e, defaultProp: t, onChange: n = () => {
358
- } }) {
359
- const [o, s] = it({
360
- defaultProp: t,
361
- onChange: n
362
- }), r = e !== void 0, c = r ? e : o, a = ie(n), u = L((i) => {
363
- if (r) {
364
- const l = typeof i == "function" ? i(e) : i;
365
- l !== e && a(l);
366
- } else s(i);
367
- }, [
368
- r,
369
- e,
370
- s,
371
- a
372
- ]);
373
- return [
374
- c,
375
- u
376
- ];
377
- }
378
- function it({ defaultProp: e, onChange: t }) {
379
- const n = F(e), [o] = n, s = R(o), r = ie(t);
380
- return N(() => {
313
+ function ut({
314
+ defaultProp: e,
315
+ onChange: t
316
+ }) {
317
+ const n = a.useState(e), [o] = n, s = a.useRef(o), r = ne(t);
318
+ return a.useEffect(() => {
381
319
  s.current !== o && (r(o), s.current = o);
382
- }, [
383
- o,
384
- s,
385
- r
386
- ]), n;
320
+ }, [o, s, r]), n;
387
321
  }
388
- const ut = /* @__PURE__ */ ne(void 0);
389
- function Se(e) {
390
- const t = ge(ut);
322
+ var lt = a.createContext(void 0);
323
+ function he(e) {
324
+ const t = a.useContext(lt);
391
325
  return e || t || "ltr";
392
326
  }
393
- const te = "rovingFocusGroup.onEntryFocus", dt = {
394
- bubbles: !1,
395
- cancelable: !0
396
- }, ue = "RovingFocusGroup", [ce, we, lt] = ot(ue), [ft, Te] = ae(ue, [
397
- lt
398
- ]), [pt, bt] = ft(ue), $t = /* @__PURE__ */ w((e, t) => /* @__PURE__ */ g(ce.Provider, {
399
- scope: e.__scopeRovingFocusGroup
400
- }, /* @__PURE__ */ g(ce.Slot, {
401
- scope: e.__scopeRovingFocusGroup
402
- }, /* @__PURE__ */ g(mt, C({}, e, {
403
- ref: t
404
- }))))), mt = /* @__PURE__ */ w((e, t) => {
405
- const { __scopeRovingFocusGroup: n, orientation: o, loop: s = !1, dir: r, currentTabStopId: c, defaultCurrentTabStopId: a, onCurrentTabStopIdChange: u, onEntryFocus: i, ...p } = e, l = R(null), m = X(t, l), _ = Se(r), [f = null, h] = ye({
406
- prop: c,
407
- defaultProp: a,
408
- onChange: u
409
- }), [$, b] = F(!1), v = ie(i), U = we(n), y = R(!1), [j, V] = F(0);
410
- return N(() => {
411
- const x = l.current;
412
- if (x)
413
- return x.addEventListener(te, v), () => x.removeEventListener(te, v);
414
- }, [
415
- v
416
- ]), /* @__PURE__ */ g(pt, {
417
- scope: n,
327
+ var J = "rovingFocusGroup.onEntryFocus", dt = { bubbles: !1, cancelable: !0 }, K = "RovingFocusGroup", [ee, ye, ft] = st(K), [pt, Ce] = te(
328
+ K,
329
+ [ft]
330
+ ), [mt, _t] = pt(K), we = a.forwardRef(
331
+ (e, t) => /* @__PURE__ */ m(ee.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ m(ee.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ m(gt, { ...e, ref: t }) }) })
332
+ );
333
+ we.displayName = K;
334
+ var gt = a.forwardRef((e, t) => {
335
+ const {
336
+ __scopeRovingFocusGroup: n,
418
337
  orientation: o,
419
- dir: _,
420
- loop: s,
421
- currentTabStopId: f,
422
- onItemFocus: L(
423
- (x) => h(x),
424
- [
425
- h
426
- ]
427
- ),
428
- onItemShiftTab: L(
429
- () => b(!0),
430
- []
431
- ),
432
- onFocusableItemAdd: L(
433
- () => V(
434
- (x) => x + 1
338
+ loop: s = !1,
339
+ dir: r,
340
+ currentTabStopId: i,
341
+ defaultCurrentTabStopId: c,
342
+ onCurrentTabStopIdChange: u,
343
+ onEntryFocus: l,
344
+ preventScrollOnEntryFocus: g = !1,
345
+ ...d
346
+ } = e, b = a.useRef(null), h = W(t, b), f = he(r), [y = null, v] = ve({
347
+ prop: i,
348
+ defaultProp: c,
349
+ onChange: u
350
+ }), [_, w] = a.useState(!1), E = ne(l), N = ye(n), A = a.useRef(!1), [L, q] = a.useState(0);
351
+ return a.useEffect(() => {
352
+ const I = b.current;
353
+ if (I)
354
+ return I.addEventListener(J, E), () => I.removeEventListener(J, E);
355
+ }, [E]), /* @__PURE__ */ m(
356
+ mt,
357
+ {
358
+ scope: n,
359
+ orientation: o,
360
+ dir: f,
361
+ loop: s,
362
+ currentTabStopId: y,
363
+ onItemFocus: a.useCallback(
364
+ (I) => v(I),
365
+ [v]
435
366
  ),
436
- []
437
- ),
438
- onFocusableItemRemove: L(
439
- () => V(
440
- (x) => x - 1
367
+ onItemShiftTab: a.useCallback(() => w(!0), []),
368
+ onFocusableItemAdd: a.useCallback(
369
+ () => q((I) => I + 1),
370
+ []
441
371
  ),
442
- []
443
- )
444
- }, /* @__PURE__ */ g(G.div, C({
445
- tabIndex: $ || j === 0 ? -1 : 0,
446
- "data-orientation": o
447
- }, p, {
448
- ref: m,
449
- style: {
450
- outline: "none",
451
- ...e.style
452
- },
453
- onMouseDown: O(e.onMouseDown, () => {
454
- y.current = !0;
455
- }),
456
- onFocus: O(e.onFocus, (x) => {
457
- const W = !y.current;
458
- if (x.target === x.currentTarget && W && !$) {
459
- const k = new CustomEvent(te, dt);
460
- if (x.currentTarget.dispatchEvent(k), !k.defaultPrevented) {
461
- const D = U().filter(
462
- (d) => d.focusable
463
- ), K = D.find(
464
- (d) => d.active
465
- ), Q = D.find(
466
- (d) => d.id === f
467
- ), Y = [
468
- K,
469
- Q,
470
- ...D
471
- ].filter(Boolean).map(
472
- (d) => d.ref.current
473
- );
474
- Ne(Y);
475
- }
476
- }
477
- y.current = !1;
478
- }),
479
- onBlur: O(
480
- e.onBlur,
481
- () => b(!1)
482
- )
483
- })));
484
- }), _t = "RovingFocusGroupItem", vt = /* @__PURE__ */ w((e, t) => {
485
- const { __scopeRovingFocusGroup: n, focusable: o = !0, active: s = !1, tabStopId: r, ...c } = e, a = Ce(), u = r || a, i = bt(_t, n), p = i.currentTabStopId === u, l = we(n), { onFocusableItemAdd: m, onFocusableItemRemove: _ } = i;
486
- return N(() => {
487
- if (o)
488
- return m(), () => _();
489
- }, [
490
- o,
491
- m,
492
- _
493
- ]), /* @__PURE__ */ g(ce.ItemSlot, {
494
- scope: n,
495
- id: u,
496
- focusable: o,
497
- active: s
498
- }, /* @__PURE__ */ g(G.span, C({
499
- tabIndex: p ? 0 : -1,
500
- "data-orientation": i.orientation
501
- }, c, {
502
- ref: t,
503
- onMouseDown: O(e.onMouseDown, (f) => {
504
- o ? i.onItemFocus(u) : f.preventDefault();
505
- }),
506
- onFocus: O(
507
- e.onFocus,
508
- () => i.onItemFocus(u)
509
- ),
510
- onKeyDown: O(e.onKeyDown, (f) => {
511
- if (f.key === "Tab" && f.shiftKey) {
512
- i.onItemShiftTab();
513
- return;
514
- }
515
- if (f.target !== f.currentTarget) return;
516
- const h = xt(f, i.orientation, i.dir);
517
- if (h !== void 0) {
518
- f.preventDefault();
519
- let b = l().filter(
520
- (v) => v.focusable
521
- ).map(
522
- (v) => v.ref.current
523
- );
524
- if (h === "last") b.reverse();
525
- else if (h === "prev" || h === "next") {
526
- h === "prev" && b.reverse();
527
- const v = b.indexOf(f.currentTarget);
528
- b = i.loop ? It(b, v + 1) : b.slice(v + 1);
372
+ onFocusableItemRemove: a.useCallback(
373
+ () => q((I) => I - 1),
374
+ []
375
+ ),
376
+ children: /* @__PURE__ */ m(
377
+ D.div,
378
+ {
379
+ tabIndex: _ || L === 0 ? -1 : 0,
380
+ "data-orientation": o,
381
+ ...d,
382
+ ref: h,
383
+ style: { outline: "none", ...e.style },
384
+ onMouseDown: x(e.onMouseDown, () => {
385
+ A.current = !0;
386
+ }),
387
+ onFocus: x(e.onFocus, (I) => {
388
+ const V = !A.current;
389
+ if (I.target === I.currentTarget && V && !_) {
390
+ const F = new CustomEvent(J, dt);
391
+ if (I.currentTarget.dispatchEvent(F), !F.defaultPrevented) {
392
+ const M = N().filter((C) => C.focusable), z = M.find((C) => C.active), Y = M.find((C) => C.id === y), p = [z, Y, ...M].filter(
393
+ Boolean
394
+ ).map((C) => C.ref.current);
395
+ Ne(p, g);
396
+ }
397
+ }
398
+ A.current = !1;
399
+ }),
400
+ onBlur: x(e.onBlur, () => w(!1))
529
401
  }
530
- setTimeout(
531
- () => Ne(b)
532
- );
402
+ )
403
+ }
404
+ );
405
+ }), Ie = "RovingFocusGroupItem", Se = a.forwardRef(
406
+ (e, t) => {
407
+ const {
408
+ __scopeRovingFocusGroup: n,
409
+ focusable: o = !0,
410
+ active: s = !1,
411
+ tabStopId: r,
412
+ ...i
413
+ } = e, c = be(), u = r || c, l = _t(Ie, n), g = l.currentTabStopId === u, d = ye(n), { onFocusableItemAdd: b, onFocusableItemRemove: h } = l;
414
+ return a.useEffect(() => {
415
+ if (o)
416
+ return b(), () => h();
417
+ }, [o, b, h]), /* @__PURE__ */ m(
418
+ ee.ItemSlot,
419
+ {
420
+ scope: n,
421
+ id: u,
422
+ focusable: o,
423
+ active: s,
424
+ children: /* @__PURE__ */ m(
425
+ D.span,
426
+ {
427
+ tabIndex: g ? 0 : -1,
428
+ "data-orientation": l.orientation,
429
+ ...i,
430
+ ref: t,
431
+ onMouseDown: x(e.onMouseDown, (f) => {
432
+ o ? l.onItemFocus(u) : f.preventDefault();
433
+ }),
434
+ onFocus: x(e.onFocus, () => l.onItemFocus(u)),
435
+ onKeyDown: x(e.onKeyDown, (f) => {
436
+ if (f.key === "Tab" && f.shiftKey) {
437
+ l.onItemShiftTab();
438
+ return;
439
+ }
440
+ if (f.target !== f.currentTarget) return;
441
+ const y = ht(f, l.orientation, l.dir);
442
+ if (y !== void 0) {
443
+ if (f.metaKey || f.ctrlKey || f.altKey || f.shiftKey) return;
444
+ f.preventDefault();
445
+ let _ = d().filter((w) => w.focusable).map((w) => w.ref.current);
446
+ if (y === "last") _.reverse();
447
+ else if (y === "prev" || y === "next") {
448
+ y === "prev" && _.reverse();
449
+ const w = _.indexOf(f.currentTarget);
450
+ _ = l.loop ? yt(_, w + 1) : _.slice(w + 1);
451
+ }
452
+ setTimeout(() => Ne(_));
453
+ }
454
+ })
455
+ }
456
+ )
533
457
  }
534
- })
535
- })));
536
- }), gt = {
458
+ );
459
+ }
460
+ );
461
+ Se.displayName = Ie;
462
+ var bt = {
537
463
  ArrowLeft: "prev",
538
464
  ArrowUp: "prev",
539
465
  ArrowRight: "next",
@@ -543,48 +469,33 @@ const te = "rovingFocusGroup.onEntryFocus", dt = {
543
469
  PageDown: "last",
544
470
  End: "last"
545
471
  };
546
- function ht(e, t) {
472
+ function vt(e, t) {
547
473
  return t !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
548
474
  }
549
- function xt(e, t, n) {
550
- const o = ht(e.key, n);
551
- if (!(t === "vertical" && [
552
- "ArrowLeft",
553
- "ArrowRight"
554
- ].includes(o)) && !(t === "horizontal" && [
555
- "ArrowUp",
556
- "ArrowDown"
557
- ].includes(o)))
558
- return gt[o];
475
+ function ht(e, t, n) {
476
+ const o = vt(e.key, n);
477
+ if (!(t === "vertical" && ["ArrowLeft", "ArrowRight"].includes(o)) && !(t === "horizontal" && ["ArrowUp", "ArrowDown"].includes(o)))
478
+ return bt[o];
559
479
  }
560
- function Ne(e) {
561
- const t = document.activeElement;
562
- for (const n of e)
563
- if (n === t || (n.focus(), document.activeElement !== t)) return;
480
+ function Ne(e, t = !1) {
481
+ const n = document.activeElement;
482
+ for (const o of e)
483
+ if (o === n || (o.focus({ preventScroll: t }), document.activeElement !== n)) return;
564
484
  }
565
- function It(e, t) {
566
- return e.map(
567
- (n, o) => e[(t + o) % e.length]
568
- );
485
+ function yt(e, t) {
486
+ return e.map((n, o) => e[(t + o) % e.length]);
569
487
  }
570
- const Ct = $t, yt = vt;
571
- function St(e, t) {
572
- return Ve((n, o) => {
573
- const s = t[n][o];
574
- return s ?? n;
575
- }, e);
488
+ var Ct = we, wt = Se;
489
+ function It(e, t) {
490
+ return a.useReducer((n, o) => t[n][o] ?? n, e);
576
491
  }
577
- const Ae = (e) => {
578
- const { present: t, children: n } = e, o = wt(t), s = typeof n == "function" ? n({
579
- present: o.isPresent
580
- }) : P.only(n), r = X(o.ref, s.ref);
581
- return typeof n == "function" || o.isPresent ? /* @__PURE__ */ se(s, {
582
- ref: r
583
- }) : null;
492
+ var Re = (e) => {
493
+ const { present: t, children: n } = e, o = St(t), s = typeof n == "function" ? n({ present: o.isPresent }) : a.Children.only(n), r = W(o.ref, Nt(s));
494
+ return typeof n == "function" || o.isPresent ? a.cloneElement(s, { ref: r }) : null;
584
495
  };
585
- Ae.displayName = "Presence";
586
- function wt(e) {
587
- const [t, n] = F(), o = R({}), s = R(e), r = R("none"), c = e ? "mounted" : "unmounted", [a, u] = St(c, {
496
+ Re.displayName = "Presence";
497
+ function St(e) {
498
+ const [t, n] = a.useState(), o = a.useRef({}), s = a.useRef(e), r = a.useRef("none"), i = e ? "mounted" : "unmounted", [c, u] = It(i, {
588
499
  mounted: {
589
500
  UNMOUNT: "unmounted",
590
501
  ANIMATION_OUT: "unmountSuspended"
@@ -597,159 +508,195 @@ function wt(e) {
597
508
  MOUNT: "mounted"
598
509
  }
599
510
  });
600
- return N(() => {
601
- const i = Z(o.current);
602
- r.current = a === "mounted" ? i : "none";
603
- }, [
604
- a
605
- ]), oe(() => {
606
- const i = o.current, p = s.current;
607
- if (p !== e) {
608
- const m = r.current, _ = Z(i);
609
- e ? u("MOUNT") : _ === "none" || (i == null ? void 0 : i.display) === "none" ? u("UNMOUNT") : u(p && m !== _ ? "ANIMATION_OUT" : "UNMOUNT"), s.current = e;
511
+ return a.useEffect(() => {
512
+ const l = G(o.current);
513
+ r.current = c === "mounted" ? l : "none";
514
+ }, [c]), H(() => {
515
+ const l = o.current, g = s.current;
516
+ if (g !== e) {
517
+ const b = r.current, h = G(l);
518
+ e ? u("MOUNT") : h === "none" || (l == null ? void 0 : l.display) === "none" ? u("UNMOUNT") : u(g && b !== h ? "ANIMATION_OUT" : "UNMOUNT"), s.current = e;
610
519
  }
611
- }, [
612
- e,
613
- u
614
- ]), oe(() => {
520
+ }, [e, u]), H(() => {
615
521
  if (t) {
616
- const i = (l) => {
617
- const _ = Z(o.current).includes(l.animationName);
618
- l.target === t && _ && Be(
619
- () => u("ANIMATION_END")
620
- );
621
- }, p = (l) => {
622
- l.target === t && (r.current = Z(o.current));
522
+ let l;
523
+ const g = t.ownerDocument.defaultView ?? window, d = (h) => {
524
+ const y = G(o.current).includes(h.animationName);
525
+ if (h.target === t && y && (u("ANIMATION_END"), !s.current)) {
526
+ const v = t.style.animationFillMode;
527
+ t.style.animationFillMode = "forwards", l = g.setTimeout(() => {
528
+ t.style.animationFillMode === "forwards" && (t.style.animationFillMode = v);
529
+ });
530
+ }
531
+ }, b = (h) => {
532
+ h.target === t && (r.current = G(o.current));
623
533
  };
624
- return t.addEventListener("animationstart", p), t.addEventListener("animationcancel", i), t.addEventListener("animationend", i), () => {
625
- t.removeEventListener("animationstart", p), t.removeEventListener("animationcancel", i), t.removeEventListener("animationend", i);
534
+ return t.addEventListener("animationstart", b), t.addEventListener("animationcancel", d), t.addEventListener("animationend", d), () => {
535
+ g.clearTimeout(l), t.removeEventListener("animationstart", b), t.removeEventListener("animationcancel", d), t.removeEventListener("animationend", d);
626
536
  };
627
537
  } else
628
538
  u("ANIMATION_END");
629
- }, [
630
- t,
631
- u
632
- ]), {
633
- isPresent: [
634
- "mounted",
635
- "unmountSuspended"
636
- ].includes(a),
637
- ref: L((i) => {
638
- i && (o.current = getComputedStyle(i)), n(i);
539
+ }, [t, u]), {
540
+ isPresent: ["mounted", "unmountSuspended"].includes(c),
541
+ ref: a.useCallback((l) => {
542
+ l && (o.current = getComputedStyle(l)), n(l);
639
543
  }, [])
640
544
  };
641
545
  }
642
- function Z(e) {
546
+ function G(e) {
643
547
  return (e == null ? void 0 : e.animationName) || "none";
644
548
  }
645
- const Ee = "Tabs", [Tt, nn] = ae(Ee, [
646
- Te
647
- ]), Pe = Te(), [Nt, de] = Tt(Ee), At = /* @__PURE__ */ w((e, t) => {
648
- const { __scopeTabs: n, value: o, onValueChange: s, defaultValue: r, orientation: c = "horizontal", dir: a, activationMode: u = "automatic", ...i } = e, p = Se(a), [l, m] = ye({
649
- prop: o,
650
- onChange: s,
651
- defaultProp: r
652
- });
653
- return /* @__PURE__ */ g(Nt, {
654
- scope: n,
655
- baseId: Ce(),
656
- value: l,
657
- onValueChange: m,
658
- orientation: c,
659
- dir: p,
660
- activationMode: u
661
- }, /* @__PURE__ */ g(G.div, C({
662
- dir: p,
663
- "data-orientation": c
664
- }, i, {
665
- ref: t
666
- })));
667
- }), Et = "TabsList", Pt = /* @__PURE__ */ w((e, t) => {
668
- const { __scopeTabs: n, loop: o = !0, ...s } = e, r = de(Et, n), c = Pe(n);
669
- return /* @__PURE__ */ g(Ct, C({
670
- asChild: !0
671
- }, c, {
672
- orientation: r.orientation,
673
- dir: r.dir,
674
- loop: o
675
- }), /* @__PURE__ */ g(G.div, C({
676
- role: "tablist",
677
- "aria-orientation": r.orientation
678
- }, s, {
679
- ref: t
680
- })));
681
- }), Rt = "TabsTrigger", Mt = /* @__PURE__ */ w((e, t) => {
682
- const { __scopeTabs: n, value: o, disabled: s = !1, ...r } = e, c = de(Rt, n), a = Pe(n), u = Re(c.baseId, o), i = Me(c.baseId, o), p = o === c.value;
683
- return /* @__PURE__ */ g(yt, C({
684
- asChild: !0
685
- }, a, {
686
- focusable: !s,
687
- active: p
688
- }), /* @__PURE__ */ g(G.button, C({
689
- type: "button",
690
- role: "tab",
691
- "aria-selected": p,
692
- "aria-controls": i,
693
- "data-state": p ? "active" : "inactive",
694
- "data-disabled": s ? "" : void 0,
695
- disabled: s,
696
- id: u
697
- }, r, {
698
- ref: t,
699
- onMouseDown: O(e.onMouseDown, (l) => {
700
- !s && l.button === 0 && l.ctrlKey === !1 ? c.onValueChange(o) : l.preventDefault();
701
- }),
702
- onKeyDown: O(e.onKeyDown, (l) => {
703
- [
704
- " ",
705
- "Enter"
706
- ].includes(l.key) && c.onValueChange(o);
707
- }),
708
- onFocus: O(e.onFocus, () => {
709
- const l = c.activationMode !== "manual";
710
- !p && !s && l && c.onValueChange(o);
711
- })
712
- })));
713
- }), Ot = "TabsContent", Ft = /* @__PURE__ */ w((e, t) => {
714
- const { __scopeTabs: n, value: o, forceMount: s, children: r, ...c } = e, a = de(Ot, n), u = Re(a.baseId, o), i = Me(a.baseId, o), p = o === a.value, l = R(p);
715
- return N(() => {
716
- const m = requestAnimationFrame(
717
- () => l.current = !1
549
+ function Nt(e) {
550
+ var o, s;
551
+ let t = (o = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning;
552
+ return n ? e.ref : (t = (s = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : s.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
553
+ }
554
+ var re = "Tabs", [Rt, Yt] = te(re, [
555
+ Ce
556
+ ]), Te = Ce(), [Tt, oe] = Rt(re), xe = a.forwardRef(
557
+ (e, t) => {
558
+ const {
559
+ __scopeTabs: n,
560
+ value: o,
561
+ onValueChange: s,
562
+ defaultValue: r,
563
+ orientation: i = "horizontal",
564
+ dir: c,
565
+ activationMode: u = "automatic",
566
+ ...l
567
+ } = e, g = he(c), [d, b] = ve({
568
+ prop: o,
569
+ onChange: s,
570
+ defaultProp: r
571
+ });
572
+ return /* @__PURE__ */ m(
573
+ Tt,
574
+ {
575
+ scope: n,
576
+ baseId: be(),
577
+ value: d,
578
+ onValueChange: b,
579
+ orientation: i,
580
+ dir: g,
581
+ activationMode: u,
582
+ children: /* @__PURE__ */ m(
583
+ D.div,
584
+ {
585
+ dir: g,
586
+ "data-orientation": i,
587
+ ...l,
588
+ ref: t
589
+ }
590
+ )
591
+ }
718
592
  );
719
- return () => cancelAnimationFrame(m);
720
- }, []), /* @__PURE__ */ g(
721
- Ae,
722
- {
723
- present: s || p
724
- },
725
- ({ present: m }) => /* @__PURE__ */ g(G.div, C({
726
- "data-state": p ? "active" : "inactive",
727
- "data-orientation": a.orientation,
728
- role: "tabpanel",
729
- "aria-labelledby": u,
730
- hidden: !m,
731
- id: i,
732
- tabIndex: 0
733
- }, c, {
734
- ref: t,
735
- style: {
736
- ...e.style,
737
- animationDuration: l.current ? "0s" : void 0
593
+ }
594
+ );
595
+ xe.displayName = re;
596
+ var Ee = "TabsList", Ae = a.forwardRef(
597
+ (e, t) => {
598
+ const { __scopeTabs: n, loop: o = !0, ...s } = e, r = oe(Ee, n), i = Te(n);
599
+ return /* @__PURE__ */ m(
600
+ Ct,
601
+ {
602
+ asChild: !0,
603
+ ...i,
604
+ orientation: r.orientation,
605
+ dir: r.dir,
606
+ loop: o,
607
+ children: /* @__PURE__ */ m(
608
+ D.div,
609
+ {
610
+ role: "tablist",
611
+ "aria-orientation": r.orientation,
612
+ ...s,
613
+ ref: t
614
+ }
615
+ )
738
616
  }
739
- }), m && r)
740
- );
741
- });
742
- function Re(e, t) {
617
+ );
618
+ }
619
+ );
620
+ Ae.displayName = Ee;
621
+ var Me = "TabsTrigger", Pe = a.forwardRef(
622
+ (e, t) => {
623
+ const { __scopeTabs: n, value: o, disabled: s = !1, ...r } = e, i = oe(Me, n), c = Te(n), u = $e(i.baseId, o), l = De(i.baseId, o), g = o === i.value;
624
+ return /* @__PURE__ */ m(
625
+ wt,
626
+ {
627
+ asChild: !0,
628
+ ...c,
629
+ focusable: !s,
630
+ active: g,
631
+ children: /* @__PURE__ */ m(
632
+ D.button,
633
+ {
634
+ type: "button",
635
+ role: "tab",
636
+ "aria-selected": g,
637
+ "aria-controls": l,
638
+ "data-state": g ? "active" : "inactive",
639
+ "data-disabled": s ? "" : void 0,
640
+ disabled: s,
641
+ id: u,
642
+ ...r,
643
+ ref: t,
644
+ onMouseDown: x(e.onMouseDown, (d) => {
645
+ !s && d.button === 0 && d.ctrlKey === !1 ? i.onValueChange(o) : d.preventDefault();
646
+ }),
647
+ onKeyDown: x(e.onKeyDown, (d) => {
648
+ [" ", "Enter"].includes(d.key) && i.onValueChange(o);
649
+ }),
650
+ onFocus: x(e.onFocus, () => {
651
+ const d = i.activationMode !== "manual";
652
+ !g && !s && d && i.onValueChange(o);
653
+ })
654
+ }
655
+ )
656
+ }
657
+ );
658
+ }
659
+ );
660
+ Pe.displayName = Me;
661
+ var Oe = "TabsContent", Fe = a.forwardRef(
662
+ (e, t) => {
663
+ const { __scopeTabs: n, value: o, forceMount: s, children: r, ...i } = e, c = oe(Oe, n), u = $e(c.baseId, o), l = De(c.baseId, o), g = o === c.value, d = a.useRef(g);
664
+ return a.useEffect(() => {
665
+ const b = requestAnimationFrame(() => d.current = !1);
666
+ return () => cancelAnimationFrame(b);
667
+ }, []), /* @__PURE__ */ m(Re, { present: s || g, children: ({ present: b }) => /* @__PURE__ */ m(
668
+ D.div,
669
+ {
670
+ "data-state": g ? "active" : "inactive",
671
+ "data-orientation": c.orientation,
672
+ role: "tabpanel",
673
+ "aria-labelledby": u,
674
+ hidden: !b,
675
+ id: l,
676
+ tabIndex: 0,
677
+ ...i,
678
+ ref: t,
679
+ style: {
680
+ ...e.style,
681
+ animationDuration: d.current ? "0s" : void 0
682
+ },
683
+ children: b && r
684
+ }
685
+ ) });
686
+ }
687
+ );
688
+ Fe.displayName = Oe;
689
+ function $e(e, t) {
743
690
  return `${e}-trigger-${t}`;
744
691
  }
745
- function Me(e, t) {
692
+ function De(e, t) {
746
693
  return `${e}-content-${t}`;
747
694
  }
748
- const Dt = At, qt = Pt, Lt = Mt, Ut = Ft;
749
- function Vt(e) {
695
+ var xt = xe, Et = Ae, At = Pe, Mt = Fe;
696
+ function Pt(e) {
750
697
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
751
698
  }
752
- var Oe = { exports: {} };
699
+ var Le = { exports: {} };
753
700
  /*!
754
701
  Copyright (c) 2018 Jed Watson.
755
702
  Licensed under the MIT License (MIT), see
@@ -759,9 +706,9 @@ var Oe = { exports: {} };
759
706
  (function() {
760
707
  var t = {}.hasOwnProperty;
761
708
  function n() {
762
- for (var r = "", c = 0; c < arguments.length; c++) {
763
- var a = arguments[c];
764
- a && (r = s(r, o.call(this, a)));
709
+ for (var r = "", i = 0; i < arguments.length; i++) {
710
+ var c = arguments[i];
711
+ c && (r = s(r, o.call(this, c)));
765
712
  }
766
713
  return r;
767
714
  }
@@ -774,22 +721,22 @@ var Oe = { exports: {} };
774
721
  return n.apply(this, r);
775
722
  if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
776
723
  return r.toString();
777
- var c = "";
778
- for (var a in r)
779
- t.call(r, a) && r[a] && (c = s(c, this && this[a] || a));
780
- return c;
724
+ var i = "";
725
+ for (var c in r)
726
+ t.call(r, c) && r[c] && (i = s(i, this && this[c] || c));
727
+ return i;
781
728
  }
782
- function s(r, c) {
783
- return c ? r ? r + " " + c : r + c : r;
729
+ function s(r, i) {
730
+ return i ? r ? r + " " + i : r + i : r;
784
731
  }
785
732
  e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
786
733
  })();
787
- })(Oe);
788
- var Bt = Oe.exports;
789
- const le = /* @__PURE__ */ Vt(Bt), Gt = {
734
+ })(Le);
735
+ var Ot = Le.exports;
736
+ const se = /* @__PURE__ */ Pt(Ot), Ft = {
790
737
  "purpur-tab-content": "_purpur-tab-content_1ugbi_1",
791
738
  "purpur-tab-content--force-mount": "_purpur-tab-content--force-mount_1ugbi_15"
792
- }, jt = le.bind(Gt), me = "purpur-tab-content", kt = w(
739
+ }, $t = se.bind(Ft), de = "purpur-tab-content", Dt = pe(
793
740
  ({
794
741
  children: e,
795
742
  tabId: t,
@@ -797,14 +744,14 @@ const le = /* @__PURE__ */ Vt(Bt), Gt = {
797
744
  className: o,
798
745
  disableForceMount: s,
799
746
  ...r
800
- }, c) => /* @__PURE__ */ T(
801
- Ut,
747
+ }, i) => /* @__PURE__ */ m(
748
+ Mt,
802
749
  {
803
- ref: c,
804
- className: jt([
805
- me,
750
+ ref: i,
751
+ className: $t([
752
+ de,
806
753
  o,
807
- { [`${me}--force-mount`]: !s }
754
+ { [`${de}--force-mount`]: !s }
808
755
  ]),
809
756
  "data-testid": n,
810
757
  value: t,
@@ -813,13 +760,13 @@ const le = /* @__PURE__ */ Vt(Bt), Gt = {
813
760
  children: e
814
761
  }
815
762
  )
816
- ), Kt = (e) => !!e && z(e) && !!e.props.name && !!e.props.tabId, zt = {
763
+ ), Lt = (e) => !!e && je(e) && !!e.props.name && !!e.props.tabId, qt = {
817
764
  "purpur-tab-header": "_purpur-tab-header_18g3c_1",
818
765
  "purpur-tab-header--contained": "_purpur-tab-header--contained_18g3c_33",
819
766
  "purpur-tab-header--contained-negative": "_purpur-tab-header--contained-negative_18g3c_33",
820
767
  "purpur-tab-header--line": "_purpur-tab-header--line_18g3c_36",
821
768
  "purpur-tab-header--line-negative": "_purpur-tab-header--line-negative_18g3c_48"
822
- }, Wt = le.bind(zt), _e = "purpur-tab-header", Yt = w(
769
+ }, Vt = se.bind(qt), fe = "purpur-tab-header", Ut = pe(
823
770
  ({
824
771
  index: e,
825
772
  tabId: t,
@@ -827,21 +774,21 @@ const le = /* @__PURE__ */ Vt(Bt), Gt = {
827
774
  negative: o,
828
775
  onFocus: s,
829
776
  "data-testid": r,
830
- children: c
831
- }, a) => /* @__PURE__ */ T(
832
- Lt,
777
+ children: i
778
+ }, c) => /* @__PURE__ */ m(
779
+ At,
833
780
  {
834
781
  id: `${t}-trigger`,
835
- className: Wt([_e, `${_e}--${n}${o ? "-negative" : ""}`]),
782
+ className: Vt([fe, `${fe}--${n}${o ? "-negative" : ""}`]),
836
783
  value: t,
837
784
  "data-testid": r,
838
785
  "data-index": e,
839
- ref: a,
786
+ ref: c,
840
787
  onFocus: s,
841
- children: c
788
+ children: i
842
789
  }
843
790
  )
844
- ), Zt = {
791
+ ), Bt = {
845
792
  "purpur-tabs__wrapper": "_purpur-tabs__wrapper_1dpqy_1",
846
793
  "purpur-tabs__scroll-button": "_purpur-tabs__scroll-button_1dpqy_9",
847
794
  "purpur-tabs__scroll-button--left": "_purpur-tabs__scroll-button--left_1dpqy_63",
@@ -856,158 +803,158 @@ const le = /* @__PURE__ */ Vt(Bt), Gt = {
856
803
  "purpur-tabs--contained-negative": "_purpur-tabs--contained-negative_1dpqy_103",
857
804
  "purpur-tabs__content-container": "_purpur-tabs__content-container_1dpqy_106",
858
805
  "purpur-tabs--fullWidth": "_purpur-tabs--fullWidth_1dpqy_115"
859
- }, rn = ["line", "contained"], Ht = (e) => new CustomEvent("tabChangeDetail", { detail: { value: e } }), q = le.bind(Zt), S = "purpur-tabs", Xt = (e, t) => {
806
+ }, Zt = ["line", "contained"], jt = (e) => new CustomEvent("tabChangeDetail", { detail: { value: e } }), O = se.bind(Bt), S = "purpur-tabs", Gt = (e, t) => {
860
807
  var u;
861
808
  if (typeof (e == null ? void 0 : e.getBoundingClientRect) != "function" || typeof (t == null ? void 0 : t.scroll) != "function")
862
809
  return;
863
- const n = e.getBoundingClientRect(), o = t.getBoundingClientRect(), s = t.clientWidth, r = parseInt((u = getComputedStyle(t).borderLeftWidth) == null ? void 0 : u.split("px")[0], 10), c = o.left + (isNaN(r) ? 0 : r);
864
- let a;
865
- n.right > o.right && (a = n.left + t.scrollLeft, a = a + n.width - s + s * 0.1, a = a - c), n.left < o.left && (a = n.left + t.scrollLeft, a = a - s * 0.1, a = a - c), a !== void 0 && t.scroll({ left: a, behavior: "smooth" });
866
- }, Jt = ({
810
+ const n = e.getBoundingClientRect(), o = t.getBoundingClientRect(), s = t.clientWidth, r = parseInt((u = getComputedStyle(t).borderLeftWidth) == null ? void 0 : u.split("px")[0], 10), i = o.left + (isNaN(r) ? 0 : r);
811
+ let c;
812
+ n.right > o.right && (c = n.left + t.scrollLeft, c = c + n.width - s + s * 0.1, c = c - i), n.left < o.left && (c = n.left + t.scrollLeft, c = c - s * 0.1, c = c - i), c !== void 0 && t.scroll({ left: c, behavior: "smooth" });
813
+ }, Wt = ({
867
814
  children: e,
868
815
  variant: t = "line",
869
816
  negative: n = !1,
870
817
  fullWidth: o = !1,
871
818
  onChange: s,
872
819
  className: r,
873
- defaultValue: c,
874
- "data-testid": a,
820
+ defaultValue: i,
821
+ "data-testid": c,
875
822
  value: u,
876
- ...i
823
+ ...l
877
824
  }) => {
878
- const [p, l] = F({}), [m, _] = F(0), [f, h] = F(0), $ = P.toArray(e).filter(Kt), b = R(), v = R(new Array($.length)), U = 200, y = t === "line", j = q([
825
+ const [g, d] = U({}), [b, h] = U(0), [f, y] = U(0), v = B.toArray(e).filter(Lt), _ = ae(), w = ae(new Array(v.length)), E = 200, N = t === "line", A = O([
879
826
  S,
880
827
  `${S}--${t}${n ? "-negative" : ""}`,
881
828
  { [`${S}--fullWidth`]: o },
882
829
  r
883
- ]), V = P.map($, ({ props: { tabId: d } }) => d), x = () => {
884
- const d = V.findIndex((I) => I === c);
885
- return d >= 0 ? d : 0;
830
+ ]), L = B.map(v, ({ props: { tabId: p } }) => p), q = () => {
831
+ const p = L.findIndex((C) => C === i);
832
+ return p >= 0 ? p : 0;
886
833
  };
887
- N(() => {
888
- u && k($.findIndex((d) => d.props.tabId === u));
889
- }, [$, u]);
890
- const [W, k] = F(x);
891
- if (new Set(V).size !== V.length)
834
+ j(() => {
835
+ u && V(v.findIndex((p) => p.props.tabId === u));
836
+ }, [v, u]);
837
+ const [I, V] = U(q);
838
+ if (new Set(L).size !== L.length)
892
839
  throw new Error("tabId must be unique");
893
- const D = (d, I) => I || a ? `${I || a}-${d}` : void 0, K = () => {
894
- if (!y)
840
+ const F = (p, C) => C || c ? `${C || c}-${p}` : void 0, M = () => {
841
+ if (!N)
895
842
  return;
896
- const d = v.current[W];
897
- _((d == null ? void 0 : d.offsetLeft) || 0), h((d == null ? void 0 : d.getBoundingClientRect().width) || 0);
898
- }, Q = (d) => {
899
- y && !u && k($.findIndex((I) => I.props.tabId === d)), s == null || s(Ht(d));
900
- }, fe = (d) => {
901
- if (b != null && b.current) {
902
- const { scrollLeft: I } = b.current, B = d === "left" ? -200 : U;
903
- b.current.scroll({ left: I + B, behavior: "smooth" });
843
+ const p = w.current[I];
844
+ h((p == null ? void 0 : p.offsetLeft) || 0), y((p == null ? void 0 : p.getBoundingClientRect().width) || 0);
845
+ }, z = (p) => {
846
+ N && !u && V(v.findIndex((C) => C.props.tabId === p)), s == null || s(jt(p));
847
+ }, Y = (p) => {
848
+ if (_ != null && _.current) {
849
+ const { scrollLeft: C } = _.current, $ = p === "left" ? -200 : E;
850
+ _.current.scroll({ left: C + $, behavior: "smooth" });
904
851
  }
905
- }, Y = ({ side: d }) => /* @__PURE__ */ T(
852
+ }, Z = ({ side: p }) => /* @__PURE__ */ m(
906
853
  "button",
907
854
  {
908
- className: q(`${S}__scroll-button`, `${S}__scroll-button--${d}`),
909
- onClick: () => fe(d),
855
+ className: O(`${S}__scroll-button`, `${S}__scroll-button--${p}`),
856
+ onClick: () => Y(p),
910
857
  type: "button",
911
858
  "aria-hidden": "true",
912
859
  tabIndex: -1,
913
- "data-testid": D("scroll-button"),
914
- children: /* @__PURE__ */ T(xe, { svg: d === "left" ? Xe : Je, size: "md" })
860
+ "data-testid": F("scroll-button"),
861
+ children: /* @__PURE__ */ m(_e, { svg: p === "left" ? Qe : He, size: "md" })
915
862
  }
916
863
  );
917
- return N(() => (window.addEventListener("resize", K), () => {
918
- window.removeEventListener("resize", K);
919
- }), []), N(() => {
920
- K();
921
- }, [W, o, $.length, t]), N(() => {
922
- const d = (M) => {
923
- if (M.every((A) => A.isIntersecting) && M.length === $.length) {
924
- l({});
864
+ return j(() => (window.addEventListener("resize", M), () => {
865
+ window.removeEventListener("resize", M);
866
+ }), []), j(() => {
867
+ M();
868
+ }, [I, o, v.length, t]), j(() => {
869
+ const p = (T) => {
870
+ if (T.every((R) => R.isIntersecting) && T.length === v.length) {
871
+ d({});
925
872
  return;
926
873
  }
927
- M.forEach((A) => {
928
- const be = Number(A.target.getAttribute("data-index")), Fe = be === 0, De = be === $.length - 1;
929
- l((qe) => ({
930
- ...qe,
931
- ...Fe && {
932
- [`${S}__wrapper--scroll-end`]: !A.isIntersecting
874
+ T.forEach((R) => {
875
+ const ce = Number(R.target.getAttribute("data-index")), qe = ce === 0, Ve = ce === v.length - 1;
876
+ d((Ue) => ({
877
+ ...Ue,
878
+ ...qe && {
879
+ [`${S}__wrapper--scroll-end`]: !R.isIntersecting
933
880
  },
934
- ...De && {
935
- [`${S}__wrapper--scroll-start`]: !A.isIntersecting
881
+ ...Ve && {
882
+ [`${S}__wrapper--scroll-start`]: !R.isIntersecting
936
883
  }
937
884
  }));
938
885
  });
939
- }, I = new IntersectionObserver(d, {
886
+ }, C = new IntersectionObserver(p, {
940
887
  threshold: [0.99],
941
- root: b.current
942
- }), B = v.current;
943
- return B.forEach((M) => I.observe(M)), () => {
944
- B.forEach((M) => I.unobserve(M));
888
+ root: _.current
889
+ }), $ = w.current;
890
+ return $.forEach((T) => C.observe(T)), () => {
891
+ $.forEach((T) => C.unobserve(T));
945
892
  };
946
- }, [$.length]), /* @__PURE__ */ T(
947
- Dt,
893
+ }, [v.length]), /* @__PURE__ */ m(
894
+ xt,
948
895
  {
949
- defaultValue: c ?? $[0].props.tabId,
950
- onValueChange: Q,
951
- "data-testid": a,
952
- className: j,
896
+ defaultValue: i ?? v[0].props.tabId,
897
+ onValueChange: z,
898
+ "data-testid": c,
899
+ className: A,
953
900
  value: u,
954
- ...i,
955
- children: /* @__PURE__ */ ee("div", { className: q(`${S}__container`), children: [
956
- /* @__PURE__ */ ee("div", { className: q([`${S}__wrapper`, p]), children: [
957
- /* @__PURE__ */ ee(
958
- qt,
901
+ ...l,
902
+ children: /* @__PURE__ */ X("div", { className: O(`${S}__container`), children: [
903
+ /* @__PURE__ */ X("div", { className: O([`${S}__wrapper`, g]), children: [
904
+ /* @__PURE__ */ X(
905
+ Et,
959
906
  {
960
- ref: (d) => {
961
- b.current = d;
907
+ ref: (p) => {
908
+ _.current = p;
962
909
  },
963
- className: q(`${S}__list`),
910
+ className: O(`${S}__list`),
964
911
  children: [
965
- P.map($, (d, I) => {
966
- const { name: B, tabId: M, "data-testid": pe } = d.props;
967
- return /* @__PURE__ */ T(
968
- Yt,
912
+ B.map(v, (p, C) => {
913
+ const { name: $, tabId: T, "data-testid": ie } = p.props;
914
+ return /* @__PURE__ */ m(
915
+ Ut,
969
916
  {
970
- "data-testid": D("header", pe),
971
- index: I,
972
- tabId: M,
973
- ref: (A) => {
974
- A && (v.current[I] = A);
917
+ "data-testid": F("header", ie),
918
+ index: C,
919
+ tabId: T,
920
+ ref: (R) => {
921
+ R && (w.current[C] = R);
975
922
  },
976
- onFocus: (A) => {
977
- Xt(A.target, b.current);
923
+ onFocus: (R) => {
924
+ Gt(R.target, _.current);
978
925
  },
979
926
  variant: t,
980
927
  negative: n,
981
- children: B
928
+ children: $
982
929
  }
983
930
  );
984
931
  }),
985
- y && /* @__PURE__ */ T(
932
+ N && /* @__PURE__ */ m(
986
933
  "div",
987
934
  {
988
- className: q(`${S}__selected-border`),
935
+ className: O(`${S}__selected-border`),
989
936
  style: {
990
937
  width: f,
991
- transform: `translateX(${m}px)`
938
+ transform: `translateX(${b}px)`
992
939
  },
993
- "data-testid": D("selected-border")
940
+ "data-testid": F("selected-border")
994
941
  }
995
942
  )
996
943
  ]
997
944
  }
998
945
  ),
999
- /* @__PURE__ */ T(Y, { side: "left" }),
1000
- /* @__PURE__ */ T(Y, { side: "right" })
946
+ /* @__PURE__ */ m(Z, { side: "left" }),
947
+ /* @__PURE__ */ m(Z, { side: "right" })
1001
948
  ] }),
1002
- /* @__PURE__ */ T("div", { className: q(`${S}__content-container`), children: P.map($, (d) => d) })
949
+ /* @__PURE__ */ m("div", { className: O(`${S}__content-container`), children: B.map(v, (p) => p) })
1003
950
  ] })
1004
951
  }
1005
952
  );
1006
953
  };
1007
- Jt.Content = kt;
954
+ Wt.Content = Dt;
1008
955
  export {
1009
- Jt as Tabs,
1010
- Ht as createTabChangeDetailEvent,
1011
- rn as tabsVariants
956
+ Wt as Tabs,
957
+ jt as createTabChangeDetailEvent,
958
+ Zt as tabsVariants
1012
959
  };
1013
960
  //# sourceMappingURL=tabs.es.js.map