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