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