quirk-ui 0.0.110 → 0.0.112

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