quirk-ui 0.0.105 → 0.0.107
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/components/Tabs/index.js +47 -47
- package/package.json +1 -1
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
import { jsx as b, jsxs as
|
|
2
|
-
import T, { useState as L, useId as x, useRef as
|
|
3
|
-
import { TabsContext as
|
|
4
|
-
import '../../assets/index33.css';const
|
|
5
|
-
tabs:
|
|
6
|
-
tabsList:
|
|
7
|
-
left:
|
|
1
|
+
import { jsx as b, jsxs as y } from "react/jsx-runtime";
|
|
2
|
+
import T, { useState as L, useId as x, useRef as p, useMemo as I, useEffect as d } from "react";
|
|
3
|
+
import { TabsContext as h, useTabsContext as v } from "./Context.js";
|
|
4
|
+
import '../../assets/index33.css';const R = "_tabs_1wmov_1", A = "_tabsList_1wmov_7", C = "_left_1wmov_13", N = "_center_1wmov_17", W = "_right_1wmov_21", k = "_tabsTrigger_1wmov_25", H = "_active_1wmov_40", M = "_tabsPanelWrapper_1wmov_45", j = "_tabsPanel_1wmov_45", n = {
|
|
5
|
+
tabs: R,
|
|
6
|
+
tabsList: A,
|
|
7
|
+
left: C,
|
|
8
8
|
center: N,
|
|
9
9
|
right: W,
|
|
10
10
|
tabsTrigger: k,
|
|
11
|
-
active:
|
|
12
|
-
tabsPanelWrapper:
|
|
13
|
-
tabsPanel:
|
|
14
|
-
},
|
|
11
|
+
active: H,
|
|
12
|
+
tabsPanelWrapper: M,
|
|
13
|
+
tabsPanel: j
|
|
14
|
+
}, D = {
|
|
15
15
|
left: n.left,
|
|
16
16
|
center: n.center,
|
|
17
17
|
right: n.right
|
|
18
18
|
};
|
|
19
|
-
function
|
|
19
|
+
function g({
|
|
20
20
|
children: r,
|
|
21
|
-
defaultIndex:
|
|
21
|
+
defaultIndex: t = 0,
|
|
22
22
|
align: a = "left"
|
|
23
23
|
}) {
|
|
24
|
-
const [s, c] = L(
|
|
24
|
+
const [s, c] = L(t), o = x(), _ = [], u = [], l = p(null), i = p([]), w = I(
|
|
25
25
|
() => ({ activeIndex: s, setActiveIndex: c, idPrefix: o, align: a, panelRefs: i }),
|
|
26
26
|
[s, o, a]
|
|
27
27
|
);
|
|
28
|
-
return T.Children.forEach(r, (
|
|
28
|
+
return T.Children.forEach(r, (e) => {
|
|
29
29
|
var f;
|
|
30
|
-
(
|
|
30
|
+
(e == null ? void 0 : e.type) === m ? _.push(e) : ((e == null ? void 0 : e.type) === P || ((f = e == null ? void 0 : e.type) == null ? void 0 : f.name) === "Panel") && u.push(e);
|
|
31
31
|
}), d(() => {
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
|
|
32
|
+
const e = l.current, f = i.current[s];
|
|
33
|
+
if (e && f) {
|
|
34
|
+
const $ = f.offsetHeight;
|
|
35
|
+
e.offsetHeight, e.style.height = `${$}px`;
|
|
36
36
|
}
|
|
37
|
-
}, [s]), /* @__PURE__ */ b(
|
|
38
|
-
|
|
37
|
+
}, [s]), /* @__PURE__ */ b(h.Provider, { value: w, children: /* @__PURE__ */ y("div", { className: n.tabs, children: [
|
|
38
|
+
_,
|
|
39
39
|
/* @__PURE__ */ b("div", { ref: l, className: n.tabsPanelWrapper, children: u })
|
|
40
40
|
] }) });
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
const { align:
|
|
42
|
+
function m({ children: r }) {
|
|
43
|
+
const { align: t } = v();
|
|
44
44
|
return /* @__PURE__ */ b(
|
|
45
45
|
"div",
|
|
46
46
|
{
|
|
47
|
-
className: `${n.tabsList} ${
|
|
47
|
+
className: `${n.tabsList} ${D[t]}`,
|
|
48
48
|
role: "tablist",
|
|
49
49
|
"aria-label": "Tabs",
|
|
50
50
|
children: r
|
|
51
51
|
}
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
const { activeIndex: a, setActiveIndex: s, idPrefix: c } =
|
|
54
|
+
function E({ children: r, index: t }) {
|
|
55
|
+
const { activeIndex: a, setActiveIndex: s, idPrefix: c } = v(), o = p(null), _ = (l) => {
|
|
56
56
|
l.key === "ArrowRight" ? s((i) => i + 1) : l.key === "ArrowLeft" && s((i) => Math.max(0, i - 1));
|
|
57
|
-
}, u = a ===
|
|
57
|
+
}, u = a === t;
|
|
58
58
|
return /* @__PURE__ */ b(
|
|
59
59
|
"button",
|
|
60
60
|
{
|
|
61
61
|
className: `${n.tabsTrigger} ${u ? n.active : ""}`,
|
|
62
62
|
role: "tab",
|
|
63
63
|
ref: o,
|
|
64
|
-
id: `${c}-tab-${
|
|
65
|
-
"aria-selected": a ===
|
|
66
|
-
tabIndex: a ===
|
|
67
|
-
onClick: () => s(
|
|
68
|
-
onKeyDown:
|
|
64
|
+
id: `${c}-tab-${t}`,
|
|
65
|
+
"aria-selected": a === t,
|
|
66
|
+
tabIndex: a === t ? 0 : -1,
|
|
67
|
+
onClick: () => s(t),
|
|
68
|
+
onKeyDown: _,
|
|
69
69
|
children: r
|
|
70
70
|
}
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
const { activeIndex: a, idPrefix: s, panelRefs: c } =
|
|
75
|
-
return
|
|
73
|
+
function P({ children: r, index: t }) {
|
|
74
|
+
const { activeIndex: a, idPrefix: s, panelRefs: c } = v();
|
|
75
|
+
return t !== a ? null : /* @__PURE__ */ b(
|
|
76
76
|
"div",
|
|
77
77
|
{
|
|
78
78
|
ref: (o) => {
|
|
79
|
-
c.current[
|
|
79
|
+
c.current[t] = o;
|
|
80
80
|
},
|
|
81
81
|
className: n.tabsPanel,
|
|
82
82
|
role: "tabpanel",
|
|
83
|
-
id: `${s}-panel-${
|
|
84
|
-
"aria-labelledby": `${s}-tab-${
|
|
85
|
-
"aria-hidden": a !==
|
|
86
|
-
hidden: a !==
|
|
83
|
+
id: `${s}-panel-${t}`,
|
|
84
|
+
"aria-labelledby": `${s}-tab-${t}`,
|
|
85
|
+
"aria-hidden": a !== t,
|
|
86
|
+
hidden: a !== t,
|
|
87
87
|
children: r
|
|
88
88
|
}
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
g.List = m;
|
|
92
|
+
g.Trigger = E;
|
|
93
|
+
g.Panel = P;
|
|
94
94
|
export {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
g as Tabs,
|
|
96
|
+
D as alignClassMap,
|
|
97
|
+
g as default
|
|
98
98
|
};
|