quirk-ui 0.0.105 → 0.0.106

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