quirk-ui 0.0.108 → 0.0.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,101 +1,113 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { TabsContext as
|
|
4
|
-
import '../../assets/index33.css';const
|
|
5
|
-
tabs:
|
|
1
|
+
import { jsx as m, jsxs as T } from "react/jsx-runtime";
|
|
2
|
+
import x, { useState as A, useId as L, useRef as _, useMemo as d, useLayoutEffect as I } from "react";
|
|
3
|
+
import { TabsContext as R, useTabsContext as p } from "./Context.js";
|
|
4
|
+
import '../../assets/index33.css';const h = "_tabs_1wmov_1", C = "_tabsList_1wmov_7", N = "_left_1wmov_13", W = "_center_1wmov_17", k = "_right_1wmov_21", F = "_tabsTrigger_1wmov_25", M = "_active_1wmov_40", j = "_tabsPanelWrapper_1wmov_45", q = "_tabsPanel_1wmov_45", o = {
|
|
5
|
+
tabs: h,
|
|
6
6
|
tabsList: C,
|
|
7
7
|
left: N,
|
|
8
8
|
center: W,
|
|
9
9
|
right: k,
|
|
10
|
-
tabsTrigger:
|
|
10
|
+
tabsTrigger: F,
|
|
11
11
|
active: M,
|
|
12
12
|
tabsPanelWrapper: j,
|
|
13
|
-
tabsPanel:
|
|
14
|
-
},
|
|
15
|
-
left:
|
|
16
|
-
center:
|
|
17
|
-
right:
|
|
13
|
+
tabsPanel: q
|
|
14
|
+
}, D = {
|
|
15
|
+
left: o.left,
|
|
16
|
+
center: o.center,
|
|
17
|
+
right: o.right
|
|
18
18
|
};
|
|
19
19
|
function v({
|
|
20
|
-
children:
|
|
20
|
+
children: c,
|
|
21
21
|
defaultIndex: t = 0,
|
|
22
22
|
align: s = "left"
|
|
23
23
|
}) {
|
|
24
|
-
const [a,
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const [a, f] = A(t), n = L(), r = [], i = [], b = _(null), l = _([]), w = () => {
|
|
25
|
+
const e = b.current, u = l.current[a];
|
|
26
|
+
if (e && u) {
|
|
27
|
+
const $ = u.offsetHeight;
|
|
28
|
+
e.style.height = `${$}px`;
|
|
29
|
+
}
|
|
30
|
+
}, y = d(
|
|
31
|
+
() => ({
|
|
32
|
+
activeIndex: a,
|
|
33
|
+
setActiveIndex: f,
|
|
34
|
+
idPrefix: n,
|
|
35
|
+
align: s,
|
|
36
|
+
panelRefs: l,
|
|
37
|
+
setWrapperHeight: w
|
|
38
|
+
}),
|
|
39
|
+
[a, n, s]
|
|
27
40
|
);
|
|
28
|
-
return
|
|
29
|
-
var
|
|
30
|
-
(e == null ? void 0 : e.type) ===
|
|
31
|
-
}),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (e && g) {
|
|
35
|
-
const $ = g.offsetHeight;
|
|
36
|
-
e.offsetHeight, e.style.height = `${$}px`;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
return () => cancelAnimationFrame(_);
|
|
40
|
-
}, [a]), /* @__PURE__ */ f(h.Provider, { value: y, children: /* @__PURE__ */ T("div", { className: n.tabs, children: [
|
|
41
|
-
b,
|
|
42
|
-
/* @__PURE__ */ f("div", { ref: l, className: n.tabsPanelWrapper, children: u })
|
|
41
|
+
return x.Children.forEach(c, (e) => {
|
|
42
|
+
var u;
|
|
43
|
+
(e == null ? void 0 : e.type) === g ? r.push(e) : ((e == null ? void 0 : e.type) === P || ((u = e == null ? void 0 : e.type) == null ? void 0 : u.name) === "Panel") && i.push(e);
|
|
44
|
+
}), /* @__PURE__ */ m(R.Provider, { value: y, children: /* @__PURE__ */ T("div", { className: o.tabs, children: [
|
|
45
|
+
r,
|
|
46
|
+
/* @__PURE__ */ m("div", { ref: b, className: o.tabsPanelWrapper, children: i })
|
|
43
47
|
] }) });
|
|
44
48
|
}
|
|
45
|
-
function
|
|
49
|
+
function g({ children: c }) {
|
|
46
50
|
const { align: t } = p();
|
|
47
|
-
return /* @__PURE__ */
|
|
51
|
+
return /* @__PURE__ */ m(
|
|
48
52
|
"div",
|
|
49
53
|
{
|
|
50
|
-
className: `${
|
|
54
|
+
className: `${o.tabsList} ${D[t]}`,
|
|
51
55
|
role: "tablist",
|
|
52
56
|
"aria-label": "Tabs",
|
|
53
|
-
children:
|
|
57
|
+
children: c
|
|
54
58
|
}
|
|
55
59
|
);
|
|
56
60
|
}
|
|
57
|
-
function
|
|
58
|
-
const { activeIndex: s, setActiveIndex: a, idPrefix:
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
return /* @__PURE__ */
|
|
61
|
+
function E({ children: c, index: t }) {
|
|
62
|
+
const { activeIndex: s, setActiveIndex: a, idPrefix: f } = p(), n = _(null), r = (b) => {
|
|
63
|
+
b.key === "ArrowRight" ? a((l) => l + 1) : b.key === "ArrowLeft" && a((l) => Math.max(0, l - 1));
|
|
64
|
+
}, i = s === t;
|
|
65
|
+
return /* @__PURE__ */ m(
|
|
62
66
|
"button",
|
|
63
67
|
{
|
|
64
|
-
className: `${
|
|
68
|
+
className: `${o.tabsTrigger} ${i ? o.active : ""}`,
|
|
65
69
|
role: "tab",
|
|
66
|
-
ref:
|
|
67
|
-
id: `${
|
|
70
|
+
ref: n,
|
|
71
|
+
id: `${f}-tab-${t}`,
|
|
68
72
|
"aria-selected": s === t,
|
|
69
73
|
tabIndex: s === t ? 0 : -1,
|
|
70
74
|
onClick: () => a(t),
|
|
71
|
-
onKeyDown:
|
|
72
|
-
children:
|
|
75
|
+
onKeyDown: r,
|
|
76
|
+
children: c
|
|
73
77
|
}
|
|
74
78
|
);
|
|
75
79
|
}
|
|
76
|
-
function
|
|
77
|
-
const { activeIndex: s, idPrefix: a, panelRefs:
|
|
78
|
-
return
|
|
80
|
+
function P({ children: c, index: t }) {
|
|
81
|
+
const { activeIndex: s, idPrefix: a, panelRefs: f, setWrapperHeight: n } = p(), r = t === s;
|
|
82
|
+
return I(() => {
|
|
83
|
+
if (r) return;
|
|
84
|
+
const i = requestAnimationFrame(() => {
|
|
85
|
+
requestAnimationFrame(() => {
|
|
86
|
+
n == null || n();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
return () => cancelAnimationFrame(i);
|
|
90
|
+
}, [s, n]), r ? /* @__PURE__ */ m(
|
|
79
91
|
"div",
|
|
80
92
|
{
|
|
81
|
-
ref: (
|
|
82
|
-
|
|
93
|
+
ref: (i) => {
|
|
94
|
+
f.current[t] = i;
|
|
83
95
|
},
|
|
84
|
-
className:
|
|
96
|
+
className: o.tabsPanel,
|
|
85
97
|
role: "tabpanel",
|
|
86
98
|
id: `${a}-panel-${t}`,
|
|
87
99
|
"aria-labelledby": `${a}-tab-${t}`,
|
|
88
|
-
"aria-hidden":
|
|
89
|
-
hidden:
|
|
90
|
-
children:
|
|
100
|
+
"aria-hidden": !r,
|
|
101
|
+
hidden: !r,
|
|
102
|
+
children: c
|
|
91
103
|
}
|
|
92
|
-
);
|
|
104
|
+
) : null;
|
|
93
105
|
}
|
|
94
|
-
v.List =
|
|
95
|
-
v.Trigger =
|
|
96
|
-
v.Panel =
|
|
106
|
+
v.List = g;
|
|
107
|
+
v.Trigger = E;
|
|
108
|
+
v.Panel = P;
|
|
97
109
|
export {
|
|
98
110
|
v as Tabs,
|
|
99
|
-
|
|
111
|
+
D as alignClassMap,
|
|
100
112
|
v as default
|
|
101
113
|
};
|
|
@@ -6,6 +6,7 @@ export type TabsContextType = {
|
|
|
6
6
|
idPrefix: string;
|
|
7
7
|
align: Align;
|
|
8
8
|
panelRefs: React.RefObject<(HTMLDivElement | null)[]>;
|
|
9
|
+
setWrapperHeight?: () => void;
|
|
9
10
|
};
|
|
10
11
|
export declare const TabsContext: React.Context<TabsContextType | null>;
|
|
11
12
|
export declare function useTabsContext(): TabsContextType;
|