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