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