@spear-ai/spectral 1.4.22 → 1.4.24
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/TabsBase.d.ts +11 -2
- package/dist/Tabs/TabsBase.js +154 -103
- package/dist/Tabs.d.ts +12 -10
- package/dist/Tabs.js +46 -52
- package/dist/Tray.js +63 -4912
- package/dist/index-BvRlXSJj.js +4859 -0
- package/dist/styles/main.css +1 -1
- package/package.json +1 -1
package/dist/Tabs/TabsBase.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
2
|
export interface TabsContextValue {
|
|
3
|
-
onValueChange: (value: string) => void;
|
|
4
3
|
activationMode: 'automatic' | 'manual';
|
|
5
4
|
baseId: string;
|
|
6
5
|
dir: 'ltr' | 'rtl';
|
|
7
6
|
disabled: boolean;
|
|
7
|
+
onValueChange: (value: string) => void;
|
|
8
8
|
orientation: 'horizontal' | 'vertical';
|
|
9
|
+
rightSlot?: ReactNode | undefined;
|
|
9
10
|
value: string;
|
|
10
11
|
}
|
|
11
12
|
export declare const TabsContext: import('react').Context<TabsContextValue | null>;
|
|
@@ -18,11 +19,14 @@ export interface TabsBaseProps extends Omit<ComponentPropsWithoutRef<'div'>, 'di
|
|
|
18
19
|
dir?: 'ltr' | 'rtl';
|
|
19
20
|
disabled?: boolean;
|
|
20
21
|
orientation?: 'horizontal' | 'vertical';
|
|
22
|
+
rightSlot?: ReactNode | undefined;
|
|
21
23
|
value?: string;
|
|
22
24
|
}
|
|
23
25
|
export declare const TabsBase: import('react').ForwardRefExoticComponent<TabsBaseProps & import('react').RefAttributes<HTMLElement>>;
|
|
24
|
-
export interface TabsListProps extends ComponentPropsWithoutRef<'div'> {
|
|
26
|
+
export interface TabsListProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
27
|
+
children?: ReactNode;
|
|
25
28
|
loop?: boolean;
|
|
29
|
+
rightSlot?: ReactNode | undefined;
|
|
26
30
|
}
|
|
27
31
|
export declare const TabsList: import('react').ForwardRefExoticComponent<TabsListProps & import('react').RefAttributes<HTMLElement>>;
|
|
28
32
|
export interface TabsTriggerProps extends ComponentPropsWithoutRef<'button'> {
|
|
@@ -30,6 +34,11 @@ export interface TabsTriggerProps extends ComponentPropsWithoutRef<'button'> {
|
|
|
30
34
|
disabled?: boolean;
|
|
31
35
|
}
|
|
32
36
|
export declare const TabsTrigger: import('react').ForwardRefExoticComponent<TabsTriggerProps & import('react').RefAttributes<HTMLElement>>;
|
|
37
|
+
export interface TabsContentContainerProps {
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
export declare const TabsContentContainer: import('react').ForwardRefExoticComponent<TabsContentContainerProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
33
42
|
export interface TabsContentProps extends ComponentPropsWithoutRef<'div'> {
|
|
34
43
|
value: string;
|
|
35
44
|
forceMount?: boolean;
|
package/dist/Tabs/TabsBase.js
CHANGED
|
@@ -1,164 +1,215 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../styles/main.css";
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { generateId as
|
|
3
|
+
import { jsx as m, jsxs as E } from "react/jsx-runtime";
|
|
4
|
+
import { generateId as M, prefersReducedMotion as $, debounce as K, getIndicatorPosition as P, calculateIndicatorStyle as S } from "./tabsUtils.js";
|
|
5
5
|
import { cn as y } from "../utils/twUtils.js";
|
|
6
|
-
import { createContext as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
import { createContext as j, forwardRef as I, useState as N, useId as k, useCallback as T, useRef as O, useEffect as U, useContext as F } from "react";
|
|
7
|
+
import { j as q, m as R, A as B } from "../index-BvRlXSJj.js";
|
|
8
|
+
const _ = j(null), D = (x = "Tabs") => {
|
|
9
|
+
const l = F(_);
|
|
10
|
+
if (l === null)
|
|
11
|
+
throw new Error(`${x} components must be used within a Tabs.Root`);
|
|
12
|
+
return l;
|
|
13
|
+
}, X = I(function({ activationMode: l = "automatic", children: a, defaultValue: r, dir: d = "ltr", disabled: u = !1, onValueChange: f, orientation: o = "horizontal", rightSlot: v, value: t, ...b }, p) {
|
|
14
|
+
const [g, w] = N(r ?? ""), C = k() ?? M("tabs"), i = t !== void 0, e = i ? t : g, n = T(
|
|
15
|
+
(s) => {
|
|
16
|
+
u || (i || w(s), f?.(s));
|
|
16
17
|
},
|
|
17
|
-
[
|
|
18
|
-
),
|
|
19
|
-
|
|
18
|
+
[i, f, u]
|
|
19
|
+
), c = {
|
|
20
|
+
activationMode: l,
|
|
21
|
+
baseId: C,
|
|
22
|
+
dir: d,
|
|
23
|
+
disabled: u,
|
|
20
24
|
onValueChange: n,
|
|
21
25
|
orientation: o,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
disabled: l,
|
|
25
|
-
baseId: d
|
|
26
|
+
rightSlot: v,
|
|
27
|
+
value: e
|
|
26
28
|
};
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
}),
|
|
29
|
-
const { orientation:
|
|
30
|
-
left: 0,
|
|
31
|
-
top: 0,
|
|
32
|
-
width: 0,
|
|
29
|
+
return /* @__PURE__ */ m(_.Provider, { value: c, children: /* @__PURE__ */ m("div", { ref: p, "data-testid": "spectral-tabs", "data-orientation": o, "data-disabled": u ? "" : void 0, dir: d, ...b, children: a }) });
|
|
30
|
+
}), Y = I(function({ children: l, className: a, loop: r = !0, rightSlot: d, ...u }, f) {
|
|
31
|
+
const { orientation: o, disabled: v } = D("TabsList"), [t, b] = N(() => ({
|
|
33
32
|
height: 0,
|
|
33
|
+
isEnclosed: !1,
|
|
34
|
+
left: 0,
|
|
34
35
|
orientation: "horizontal",
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
top: 0,
|
|
37
|
+
width: 0
|
|
38
|
+
})), p = O(null), g = $(), w = T(
|
|
39
|
+
K(() => {
|
|
40
|
+
const i = S(p);
|
|
41
|
+
b(i);
|
|
40
42
|
}, 16),
|
|
41
43
|
// ~60fps
|
|
42
44
|
[]
|
|
43
45
|
);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
return
|
|
46
|
+
U(() => {
|
|
47
|
+
w();
|
|
48
|
+
const i = new ResizeObserver(w), e = new MutationObserver(w), n = p.current;
|
|
49
|
+
return n && (i.observe(n), e.observe(n, {
|
|
48
50
|
attributes: !0,
|
|
49
51
|
childList: !0,
|
|
50
52
|
subtree: !0
|
|
51
53
|
})), () => {
|
|
52
|
-
|
|
54
|
+
i.disconnect(), e.disconnect();
|
|
53
55
|
};
|
|
54
|
-
}, [
|
|
55
|
-
const
|
|
56
|
-
(
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
let
|
|
63
|
-
const { key:
|
|
64
|
-
|
|
56
|
+
}, [w]);
|
|
57
|
+
const C = T(
|
|
58
|
+
(i) => {
|
|
59
|
+
if (v) return;
|
|
60
|
+
const e = Array.from(p.current?.querySelectorAll("[role='tab']:not([disabled]):not([aria-disabled='true'])") ?? []);
|
|
61
|
+
if (e.length === 0) return;
|
|
62
|
+
const n = e.findIndex((L) => L === document.activeElement);
|
|
63
|
+
if (n === -1) return;
|
|
64
|
+
let c = null;
|
|
65
|
+
const { key: s, ctrlKey: h, metaKey: z } = i, A = h || z;
|
|
66
|
+
o === "horizontal" ? s === "ArrowLeft" || s === "ArrowUp" && A ? c = n > 0 ? n - 1 : r ? e.length - 1 : n : (s === "ArrowRight" || s === "ArrowDown" && A) && (c = n < e.length - 1 ? n + 1 : r ? 0 : n) : s === "ArrowUp" || s === "ArrowLeft" && A ? c = n > 0 ? n - 1 : r ? e.length - 1 : n : (s === "ArrowDown" || s === "ArrowRight" && A) && (c = n < e.length - 1 ? n + 1 : r ? 0 : n), s === "Home" ? c = 0 : s === "End" && (c = e.length - 1), c !== null && c !== n && (i.preventDefault(), i.stopPropagation(), e[c]?.focus());
|
|
65
67
|
},
|
|
66
|
-
[
|
|
68
|
+
[v, o, r]
|
|
67
69
|
);
|
|
68
|
-
return /* @__PURE__ */
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
|
|
70
|
+
return /* @__PURE__ */ E("div", { className: "relative", ref: p, children: [
|
|
71
|
+
/* @__PURE__ */ E(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
ref: f,
|
|
75
|
+
role: "tablist",
|
|
76
|
+
"data-testid": "spectral-tabs-list",
|
|
77
|
+
"aria-orientation": o,
|
|
78
|
+
"aria-disabled": v,
|
|
79
|
+
className: y("tabs-list flex", o === "horizontal" && "items-center justify-between", o === "vertical" && "flex-col", a),
|
|
80
|
+
onKeyDown: C,
|
|
81
|
+
...u,
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ m("div", { className: y("flex", o === "horizontal" && "items-center", o === "vertical" && "flex-col"), children: l }),
|
|
84
|
+
d && /* @__PURE__ */ m("div", { className: "flex items-center z-10", children: d })
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
/* @__PURE__ */ m(
|
|
71
89
|
"div",
|
|
72
90
|
{
|
|
73
91
|
className: y(
|
|
74
92
|
"absolute pointer-events-none select-none",
|
|
75
|
-
!
|
|
76
|
-
|
|
77
|
-
|
|
93
|
+
!g && "transition-all duration-300 ease-out",
|
|
94
|
+
t.orientation === "horizontal" && !t.isEnclosed && ["bottom-[1px] after:content-[''] after:absolute after:bottom-0 after:left-0 after:w-full", "after:border-b-[0.3rem] after:border-tabs-indicator after:rounded-t-[0.3rem] z-10"],
|
|
95
|
+
t.orientation === "vertical" && !t.isEnclosed && [
|
|
78
96
|
"right-[1px]",
|
|
79
|
-
!
|
|
97
|
+
!g && "transition-[top_300ms_ease,height_300ms_ease]",
|
|
80
98
|
"after:content-[''] after:absolute after:right-0 after:top-0 after:h-full after:w-1",
|
|
81
99
|
"after:border-r-[0.3rem] after:border-tabs-indicator after:rounded-l-[0.3rem] z-10"
|
|
82
100
|
],
|
|
83
|
-
|
|
84
|
-
|
|
101
|
+
t.orientation === "horizontal" && t.isEnclosed && ["bg-tabs-enclosed-indicator rounded-lg shadow-lg top-[10%] bottom-[10%] z-0", !g && "transition-[left_300ms_ease,width_300ms_ease]"],
|
|
102
|
+
t.orientation === "vertical" && t.isEnclosed && ["bg-tabs-enclosed-indicator rounded-lg shadow-lg left-1 right-1 z-0 max-h-10 w-auto"]
|
|
85
103
|
),
|
|
86
104
|
style: {
|
|
87
|
-
...
|
|
88
|
-
...
|
|
105
|
+
...P(t),
|
|
106
|
+
...t.isEnclosed && t.orientation === "vertical" ? { height: "40px" } : {}
|
|
89
107
|
},
|
|
90
108
|
"aria-hidden": "true"
|
|
91
109
|
}
|
|
92
110
|
)
|
|
93
111
|
] });
|
|
94
|
-
}),
|
|
95
|
-
const { value: v, onValueChange:
|
|
96
|
-
(
|
|
97
|
-
if (
|
|
98
|
-
|
|
112
|
+
}), Z = I(function({ className: l, value: a, onClick: r, onKeyDown: d, disabled: u = !1, ...f }, o) {
|
|
113
|
+
const { value: v, onValueChange: t, activationMode: b, disabled: p, baseId: g } = D("TabsTrigger"), w = `${g}-trigger-${a}`, C = `${g}-content-${a}`, i = v === a, e = p || u, n = T(
|
|
114
|
+
(h) => {
|
|
115
|
+
if (e) {
|
|
116
|
+
h.preventDefault();
|
|
99
117
|
return;
|
|
100
118
|
}
|
|
101
|
-
|
|
119
|
+
t(a), r?.(h);
|
|
102
120
|
},
|
|
103
|
-
[
|
|
104
|
-
),
|
|
105
|
-
(
|
|
106
|
-
if (
|
|
107
|
-
|
|
121
|
+
[a, t, r, e]
|
|
122
|
+
), c = T(
|
|
123
|
+
(h) => {
|
|
124
|
+
if (e) {
|
|
125
|
+
h.preventDefault();
|
|
108
126
|
return;
|
|
109
127
|
}
|
|
110
|
-
const { key:
|
|
111
|
-
(
|
|
128
|
+
const { key: z } = h;
|
|
129
|
+
(z === "Enter" || z === " ") && (h.preventDefault(), h.stopPropagation(), t(a)), d?.(h);
|
|
112
130
|
},
|
|
113
|
-
[
|
|
114
|
-
),
|
|
115
|
-
|
|
116
|
-
}, [
|
|
117
|
-
return /* @__PURE__ */
|
|
131
|
+
[a, t, d, e]
|
|
132
|
+
), s = T(() => {
|
|
133
|
+
e || b === "automatic" && t(a);
|
|
134
|
+
}, [b, t, a, e]);
|
|
135
|
+
return /* @__PURE__ */ m(
|
|
118
136
|
"button",
|
|
119
137
|
{
|
|
120
|
-
"aria-controls":
|
|
121
|
-
"aria-disabled":
|
|
122
|
-
"aria-selected":
|
|
123
|
-
className: y("tabs-trigger z-10 focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600",
|
|
124
|
-
"data-disabled":
|
|
125
|
-
"data-state":
|
|
138
|
+
"aria-controls": C,
|
|
139
|
+
"aria-disabled": e,
|
|
140
|
+
"aria-selected": i,
|
|
141
|
+
className: y("tabs-trigger z-10 focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600", l),
|
|
142
|
+
"data-disabled": e ? "" : void 0,
|
|
143
|
+
"data-state": i ? "active" : "inactive",
|
|
126
144
|
"data-testid": "spectral-tabs-trigger",
|
|
127
|
-
disabled:
|
|
128
|
-
id:
|
|
129
|
-
onClick:
|
|
130
|
-
onFocus:
|
|
131
|
-
onKeyDown:
|
|
145
|
+
disabled: e,
|
|
146
|
+
id: w,
|
|
147
|
+
onClick: n,
|
|
148
|
+
onFocus: s,
|
|
149
|
+
onKeyDown: c,
|
|
132
150
|
ref: o,
|
|
133
151
|
role: "tab",
|
|
134
|
-
tabIndex:
|
|
152
|
+
tabIndex: i ? 0 : -1,
|
|
135
153
|
type: "button",
|
|
136
154
|
...f
|
|
137
155
|
}
|
|
138
156
|
);
|
|
139
|
-
}),
|
|
140
|
-
const { value:
|
|
141
|
-
return
|
|
157
|
+
}), V = I(function({ children: l, className: a }, r) {
|
|
158
|
+
const { value: d } = D("TabsContentContainer"), [u, f] = q(), o = $();
|
|
159
|
+
return /* @__PURE__ */ m(
|
|
160
|
+
R.div,
|
|
161
|
+
{
|
|
162
|
+
ref: r,
|
|
163
|
+
className: y("overflow-hidden", a),
|
|
164
|
+
"data-testid": "spectral-tabs-content-container",
|
|
165
|
+
animate: {
|
|
166
|
+
height: f.height || "auto"
|
|
167
|
+
},
|
|
168
|
+
transition: o ? { duration: 0 } : {
|
|
169
|
+
duration: 0.3,
|
|
170
|
+
ease: [0.25, 1, 0.5, 1]
|
|
171
|
+
},
|
|
172
|
+
children: /* @__PURE__ */ m(B, { mode: "wait", initial: !1, children: /* @__PURE__ */ m(
|
|
173
|
+
R.div,
|
|
174
|
+
{
|
|
175
|
+
ref: u,
|
|
176
|
+
initial: o ? !1 : { opacity: 0, y: 8 },
|
|
177
|
+
animate: { opacity: 1, y: 0 },
|
|
178
|
+
exit: o ? void 0 : { opacity: 0, y: -8 },
|
|
179
|
+
transition: o ? { duration: 0 } : {
|
|
180
|
+
duration: 0.2,
|
|
181
|
+
ease: [0.25, 1, 0.5, 1]
|
|
182
|
+
},
|
|
183
|
+
children: l
|
|
184
|
+
},
|
|
185
|
+
d
|
|
186
|
+
) })
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
}), tt = I(function({ className: l, value: a, forceMount: r = !1, ...d }, u) {
|
|
190
|
+
const { value: f, baseId: o } = D("TabsContent"), v = `${o}-content-${a}`, t = `${o}-trigger-${a}`, b = f === a;
|
|
191
|
+
return !r && !b ? null : /* @__PURE__ */ m(
|
|
142
192
|
"div",
|
|
143
193
|
{
|
|
144
|
-
"aria-labelledby":
|
|
145
|
-
className: y("tabs-content focus:outline-none focus-visible:outline-none",
|
|
146
|
-
"data-state":
|
|
194
|
+
"aria-labelledby": t,
|
|
195
|
+
className: y("tabs-content focus:outline-none focus-visible:outline-none", l),
|
|
196
|
+
"data-state": b ? "active" : "inactive",
|
|
147
197
|
"data-testid": "spectral-tabs-content",
|
|
148
|
-
hidden: !
|
|
198
|
+
hidden: !b,
|
|
149
199
|
id: v,
|
|
150
|
-
ref:
|
|
200
|
+
ref: u,
|
|
151
201
|
role: "tabpanel",
|
|
152
202
|
tabIndex: 0,
|
|
153
|
-
...
|
|
203
|
+
...d
|
|
154
204
|
}
|
|
155
205
|
);
|
|
156
206
|
});
|
|
157
207
|
export {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
208
|
+
X as TabsBase,
|
|
209
|
+
tt as TabsContent,
|
|
210
|
+
V as TabsContentContainer,
|
|
211
|
+
_ as TabsContext,
|
|
212
|
+
Y as TabsList,
|
|
213
|
+
Z as TabsTrigger,
|
|
214
|
+
D as useTabsContext
|
|
164
215
|
};
|
package/dist/Tabs.d.ts
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import { TabsBase, TabsContent, TabsList, TabsTrigger, TabsBaseProps } from './TabsBase';
|
|
2
|
-
import {
|
|
1
|
+
import { TabsBase, TabsContent, TabsContentContainer, TabsList, TabsTrigger, TabsBaseProps } from './TabsBase';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
3
|
export interface TabValue {
|
|
4
|
-
key: string | undefined;
|
|
5
|
-
label: ReactNode;
|
|
6
4
|
children: ReactNode;
|
|
7
5
|
disabled?: boolean | undefined;
|
|
6
|
+
key: string | undefined;
|
|
7
|
+
label: ReactNode;
|
|
8
8
|
'aria-label'?: string | undefined;
|
|
9
9
|
'aria-describedby'?: string | undefined;
|
|
10
10
|
}
|
|
11
11
|
export interface TabsProps extends Omit<TabsBaseProps, 'children' | 'defaultValue' | 'onError' | 'disabled'> {
|
|
12
|
-
|
|
13
|
-
onError?: (error: Error) => void | ReactEventHandler<HTMLDivElement> | undefined;
|
|
12
|
+
activationMode?: 'automatic' | 'manual' | undefined;
|
|
14
13
|
ariaLabel?: string | undefined;
|
|
15
14
|
className?: string | undefined;
|
|
15
|
+
onBeforeChange?: (newValue: string, oldValue: string) => boolean | Promise<boolean> | undefined;
|
|
16
|
+
onError?: ((error: Error) => void) | undefined;
|
|
17
|
+
loading?: boolean | undefined;
|
|
16
18
|
openOnLoad?: string | undefined;
|
|
19
|
+
rightSlot?: ReactNode | undefined;
|
|
17
20
|
tabValues: TabValue[] | undefined;
|
|
18
21
|
variant?: 'enclosed' | 'default';
|
|
19
|
-
loading?: boolean | undefined;
|
|
20
22
|
}
|
|
21
|
-
export declare const Tabs: ({ ariaLabel, className,
|
|
22
|
-
export { TabsContent, TabsList, TabsBase as TabsRoot, TabsTrigger };
|
|
23
|
-
export type { TabsBaseProps, TabsContentProps, TabsListProps, TabsTriggerProps } from './TabsBase';
|
|
23
|
+
export declare const Tabs: ({ activationMode, ariaLabel, className, loading, onBeforeChange, onError, onValueChange, openOnLoad, orientation, rightSlot, tabValues, variant, ...props }: TabsProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export { TabsContent, TabsContentContainer, TabsList, TabsBase as TabsRoot, TabsTrigger };
|
|
25
|
+
export type { TabsBaseProps, TabsContentContainerProps, TabsContentProps, TabsListProps, TabsTriggerProps } from './TabsBase';
|
|
24
26
|
export type TabKeys<T extends TabValue[]> = T[number]['key'];
|
|
25
27
|
export type TabValueWithKey<TKey extends string> = TabValue & {
|
|
26
28
|
key: TKey;
|
package/dist/Tabs.js
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
1
|
import "./styles/main.css";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { TabsBase as
|
|
4
|
-
import { validateTabValues as
|
|
2
|
+
import { jsx as l, jsxs as p } from "react/jsx-runtime";
|
|
3
|
+
import { TabsBase as T, TabsList as z, TabsTrigger as k, TabsContentContainer as C, TabsContent as j } from "./Tabs/TabsBase.js";
|
|
4
|
+
import { validateTabValues as V, getTabKeys as E } from "./Tabs/tabsUtils.js";
|
|
5
5
|
import { cn as r } from "./utils/twUtils.js";
|
|
6
6
|
import "react";
|
|
7
|
-
const
|
|
8
|
-
/* @__PURE__ */
|
|
9
|
-
/* @__PURE__ */
|
|
10
|
-
/* @__PURE__ */
|
|
11
|
-
] }),
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
7
|
+
const K = ({ tabCount: d, orientation: s }) => /* @__PURE__ */ p("div", { className: "flex flex-col relative w-full", role: "status", children: [
|
|
8
|
+
/* @__PURE__ */ l("div", { className: r("inline-flex items-center justify-start w-full", s === "horizontal" && "border-b border-neutral-600", s === "vertical" && "flex-col items-stretch border-r border-neutral-600"), children: Array.from({ length: Math.min(d, 5) }, (h, n) => /* @__PURE__ */ l("div", { className: r("animate-pulse bg-neutral-600 rounded", s === "horizontal" ? "h-6 w-16 mx-2 my-2" : "h-6 w-full mx-2 my-1"), "aria-hidden": "true" }, n)) }),
|
|
9
|
+
/* @__PURE__ */ l("div", { className: "animate-pulse bg-neutral-600 h-32 w-full mt-4 rounded", "aria-hidden": "true" }),
|
|
10
|
+
/* @__PURE__ */ l("span", { className: "sr-only", children: "Loading tabs…" })
|
|
11
|
+
] }), R = ({ activationMode: d = "automatic", ariaLabel: s, className: h, loading: n = !1, onBeforeChange: v, onError: b, onValueChange: x, openOnLoad: i, orientation: t = "horizontal", rightSlot: y, tabValues: m = [], variant: a = "default", ...g }) => {
|
|
12
|
+
const c = m.filter((e) => e.key !== void 0);
|
|
13
|
+
if (!V(c)) {
|
|
14
14
|
const e = new Error("Invalid tabValues provided to Tabs component");
|
|
15
|
-
return
|
|
15
|
+
return b?.(e), /* @__PURE__ */ l("div", { className: "flex flex-col relative w-full p-4 text-center text-gray-500", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ l("p", { children: "No valid tabs provided" }) });
|
|
16
16
|
}
|
|
17
|
-
if (
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
-
const
|
|
20
|
-
let
|
|
21
|
-
if (i && !
|
|
17
|
+
if (n)
|
|
18
|
+
return /* @__PURE__ */ l(K, { tabCount: m.length || 3, orientation: t });
|
|
19
|
+
const u = E(c);
|
|
20
|
+
let o = i ?? u[0];
|
|
21
|
+
if (i && !u.includes(i) && (console.warn(`Tabs: openOnLoad value '${i}' is not a valid tab key`), o = u[0]), !o) {
|
|
22
22
|
const e = new Error("No valid default tab available");
|
|
23
|
-
return
|
|
23
|
+
return b?.(e), /* @__PURE__ */ l("div", { className: "flex flex-col relative w-full p-4 text-center text-text-secondary", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ l("p", { children: "Unable to render tabs" }) });
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
const
|
|
25
|
+
const w = async (e) => {
|
|
26
|
+
if (v && x) {
|
|
27
|
+
const N = o;
|
|
28
28
|
try {
|
|
29
|
-
if (await
|
|
30
|
-
} catch (
|
|
31
|
-
|
|
29
|
+
if (await v(e, N) === !1) return;
|
|
30
|
+
} catch (f) {
|
|
31
|
+
b?.(f instanceof Error ? f : new Error("Before change callback failed"));
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
x?.(e);
|
|
36
36
|
};
|
|
37
|
-
return /* @__PURE__ */
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
|
|
37
|
+
return /* @__PURE__ */ l("div", { className: "flex flex-col relative w-full", children: /* @__PURE__ */ p(T, { "aria-label": s, className: r("relative w-full data-[orientation=vertical]:flex", a, h), defaultValue: o, orientation: t, activationMode: d, onValueChange: w, ...g, children: [
|
|
38
|
+
/* @__PURE__ */ l(
|
|
39
|
+
z,
|
|
40
40
|
{
|
|
41
41
|
className: r(
|
|
42
|
-
"inline-flex items-center justify-
|
|
43
|
-
t === "horizontal" &&
|
|
44
|
-
t === "vertical" &&
|
|
45
|
-
t === "horizontal" &&
|
|
46
|
-
t === "vertical" &&
|
|
42
|
+
"inline-flex items-center justify-between w-full",
|
|
43
|
+
t === "horizontal" && a === "default" && ["border-b border-tabs-border"],
|
|
44
|
+
t === "vertical" && a === "default" && ["flex-col items-stretch border-r border-tabs-border h-auto m-0 py-1 w-auto relative"],
|
|
45
|
+
t === "horizontal" && a === "enclosed" && ["bg-tabs-group-bg border-0 rounded-lg p-1 relative"],
|
|
46
|
+
t === "vertical" && a === "enclosed" && ["bg-tabs-group-bg rounded-lg border-0 p-1 w-auto flex-col"]
|
|
47
47
|
),
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
rightSlot: y,
|
|
49
|
+
children: c.map((e) => /* @__PURE__ */ l(
|
|
50
|
+
k,
|
|
50
51
|
{
|
|
51
52
|
value: e.key,
|
|
52
53
|
disabled: e.disabled,
|
|
@@ -54,10 +55,10 @@ const V = ({ tabCount: d, orientation: s }) => /* @__PURE__ */ m("div", { classN
|
|
|
54
55
|
"aria-describedby": e["aria-describedby"],
|
|
55
56
|
className: r(
|
|
56
57
|
"relative whitespace-nowrap font-semibold transition-all duration-500 ease-in-out focus:outline-none focus-visible:outline-none",
|
|
57
|
-
t === "horizontal" &&
|
|
58
|
-
t === "vertical" &&
|
|
59
|
-
t === "horizontal" &&
|
|
60
|
-
t === "vertical" &&
|
|
58
|
+
t === "horizontal" && a === "default" && ["text-text-primary hover:text-accent py-2 px-4 hover:bg-tabs-bg--hover"],
|
|
59
|
+
t === "vertical" && a === "default" && ["text-text-primary flex items-center h-10 px-4 py-2 data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover"],
|
|
60
|
+
t === "horizontal" && a === "enclosed" && ["text-text-primary inline-flex items-center justify-center px-4 py-2 data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover z-[1]"],
|
|
61
|
+
t === "vertical" && a === "enclosed" && ["text-text-primary px-4 py-2 z-[1] data-[state=active]:text-accent hover:text-accent hover:bg-tabs-bg--hover"],
|
|
61
62
|
"disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:text-text-primary disabled:hover:bg-transparent"
|
|
62
63
|
),
|
|
63
64
|
children: e.label
|
|
@@ -66,21 +67,14 @@ const V = ({ tabCount: d, orientation: s }) => /* @__PURE__ */ m("div", { classN
|
|
|
66
67
|
))
|
|
67
68
|
}
|
|
68
69
|
),
|
|
69
|
-
|
|
70
|
-
k,
|
|
71
|
-
{
|
|
72
|
-
value: e.key,
|
|
73
|
-
className: r("focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent text-text-primary", t === "horizontal" && "py-6", t === "vertical" && "ps-8", "data-[state=active]:animate-fade-in-tabs"),
|
|
74
|
-
children: e.children
|
|
75
|
-
},
|
|
76
|
-
e.key
|
|
77
|
-
))
|
|
70
|
+
/* @__PURE__ */ l(C, { className: r(t === "vertical" && "flex-1"), children: c.map((e) => /* @__PURE__ */ l(j, { value: e.key, className: r("focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent text-text-primary", t === "horizontal" && "pb-4", t === "vertical" && "py-2 px-4"), children: e.children }, e.key)) })
|
|
78
71
|
] }) });
|
|
79
72
|
};
|
|
80
73
|
export {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
R as Tabs,
|
|
75
|
+
j as TabsContent,
|
|
76
|
+
C as TabsContentContainer,
|
|
77
|
+
z as TabsList,
|
|
78
|
+
T as TabsRoot,
|
|
79
|
+
k as TabsTrigger
|
|
86
80
|
};
|