jcicl 1.2.3 → 1.2.5

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/Tabs/Tabs.js CHANGED
@@ -1,121 +1,135 @@
1
- import { jsxs as h, jsx as v } from "react/jsx-runtime";
2
- import { useId as E, useState as S, useRef as T, useEffect as k } from "react";
1
+ import { jsxs as v, jsx as b } from "react/jsx-runtime";
2
+ import { useId as P, useState as R, useRef as T, useEffect as D } from "react";
3
+ import A from "../ScrollContainer/ScrollContainer.js";
3
4
  import { cn as y } from "../cn.js";
4
- const A = {
5
+ const N = {
5
6
  left: "justify-start",
6
7
  center: "justify-between",
7
8
  // spread headers across the full width
8
9
  right: "justify-end"
9
- }, x = (e, i) => {
10
+ }, x = (e, c) => {
10
11
  if (typeof window > "u") return null;
11
- const r = new URLSearchParams(window.location.search).get(e);
12
- if (r == null) return null;
13
- const l = i.findIndex((d) => d.label === r);
12
+ const n = new URLSearchParams(window.location.search).get(e);
13
+ if (n == null) return null;
14
+ const l = c.findIndex((u) => u.label === n);
14
15
  return l >= 0 ? l : null;
15
- }, N = (e, i) => {
16
+ }, E = (e, c) => {
16
17
  if (typeof window > "u") return;
17
- const r = new URLSearchParams(window.location.search);
18
- r.set(e, i), window.history.replaceState(
18
+ const n = new URLSearchParams(window.location.search);
19
+ n.set(e, c), window.history.replaceState(
19
20
  window.history.state,
20
21
  "",
21
- `${window.location.pathname}?${r}${window.location.hash}`
22
+ `${window.location.pathname}?${n}${window.location.hash}`
22
23
  );
23
- }, M = ({
24
+ }, z = ({
24
25
  tabs: e,
25
- defaultIndex: i = 0,
26
- activeIndex: r,
26
+ defaultIndex: c = 0,
27
+ activeIndex: n,
27
28
  onChange: l,
28
- persistKey: d,
29
+ persistKey: u,
29
30
  tabHeaderAlignment: j = "left",
30
- headerFontSize: f,
31
+ headerFontSize: p,
31
32
  headerClassName: $,
32
33
  headerStyle: I
33
34
  }) => {
34
- const s = E(), u = r !== void 0, o = !u && d, [g, b] = S(
35
- () => (o ? x(o, e) : null) ?? i
36
- ), L = u ? r : g, p = T(e);
37
- if (p.current = e, k(() => {
35
+ const s = P(), f = n !== void 0, o = !f && u, [g, w] = R(
36
+ () => (o ? x(o, e) : null) ?? c
37
+ ), S = f ? n : g, m = T(e);
38
+ if (m.current = e, D(() => {
38
39
  if (!o) return;
39
40
  const t = () => {
40
- const n = x(o, p.current);
41
- n != null && b(n);
41
+ const r = x(o, m.current);
42
+ r != null && w(r);
42
43
  };
43
44
  return window.addEventListener("popstate", t), () => window.removeEventListener("popstate", t);
44
45
  }, [o]), e.length === 0) return null;
45
- const c = Math.min(Math.max(L, 0), e.length - 1), w = (t) => {
46
- u || b(t), o && N(o, e[t].label), l == null || l(t);
47
- }, P = {
48
- ...f != null ? { fontSize: f } : {},
46
+ const d = Math.min(Math.max(S, 0), e.length - 1), h = (t) => {
47
+ f || w(t), o && E(o, e[t].label), l == null || l(t);
48
+ }, k = {
49
+ ...p != null ? { fontSize: p } : {},
49
50
  ...I
50
- }, R = (t) => {
51
- var m;
51
+ }, L = (t) => {
52
52
  if (t.key !== "ArrowRight" && t.key !== "ArrowLeft") return;
53
53
  t.preventDefault();
54
- const n = t.key === "ArrowRight" ? 1 : -1, a = (c + n + e.length) % e.length;
55
- w(a), (m = document.getElementById(`${s}-tab-${a}`)) == null || m.focus();
54
+ const r = t.key === "ArrowRight" ? 1 : -1, a = (d + r + e.length) % e.length;
55
+ h(a);
56
+ const i = document.getElementById(`${s}-tab-${a}`);
57
+ i == null || i.focus({ preventScroll: !0 }), i == null || i.scrollIntoView({ block: "nearest", inline: "nearest" });
56
58
  };
57
- return /* @__PURE__ */ h("div", { className: "jcTabs flex w-full flex-col", children: [
58
- /* @__PURE__ */ v(
59
- "div",
59
+ return /* @__PURE__ */ v("div", { className: "jcTabs flex w-full flex-col", children: [
60
+ /* @__PURE__ */ b(
61
+ A,
60
62
  {
61
- role: "tablist",
62
- className: y(
63
- "jcTabList flex flex-wrap gap-1 border-b-2 border-jc-gray-2",
64
- A[j]
65
- ),
66
- children: e.map((t, n) => {
67
- const a = n === c;
68
- return /* @__PURE__ */ h(
69
- "button",
70
- {
71
- id: `${s}-tab-${n}`,
72
- type: "button",
73
- role: "tab",
74
- "aria-selected": a,
75
- "aria-controls": `${s}-panel-${n}`,
76
- tabIndex: a ? 0 : -1,
77
- "data-active": a,
78
- onClick: () => w(n),
79
- onKeyDown: R,
80
- style: P,
81
- className: y(
82
- // The lib's CSS omits Tailwind preflight, so reset the native button
83
- // border explicitly (none on top/sides) and keep only the bottom indicator.
84
- "jcTab -mb-0.5 inline-flex cursor-pointer appearance-none items-center gap-2 bg-transparent px-5 py-3",
85
- "border-solid border-t-0 border-x-0 border-b-[3px] border-b-[color:transparent]",
86
- "text-[27px] font-normal text-jc-black transition-[color,border-color] duration-200",
87
- // Active indicator + focus ring track the app's selected theme color
88
- // (--jc-theme-color, injected by DefaultTemplate); jc-gold (#fab62d) is the
89
- // fallback outside a themed app. Keep these strings literal — Tailwind only
90
- // scans complete class strings, so the color can't be interpolated.
91
- "data-[active=true]:font-semibold data-[active=true]:border-b-[color:var(--jc-theme-color,#fab62d)]",
92
- "focus-visible:rounded-[4px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--jc-theme-color,#fab62d)]",
93
- $
94
- ),
95
- children: [
96
- t.icon,
97
- t.label
98
- ]
99
- },
100
- n
101
- );
102
- })
63
+ direction: "horizontal",
64
+ height: "auto",
65
+ autoHide: "leave",
66
+ autoHideDelay: 0,
67
+ fadeDurationMs: 270,
68
+ children: /* @__PURE__ */ b(
69
+ "div",
70
+ {
71
+ role: "tablist",
72
+ className: y(
73
+ "jcTabList flex w-max min-w-full gap-1 border-b-2 border-jc-gray-2",
74
+ N[j]
75
+ ),
76
+ children: e.map((t, r) => {
77
+ const a = r === d;
78
+ return /* @__PURE__ */ v(
79
+ "button",
80
+ {
81
+ id: `${s}-tab-${r}`,
82
+ type: "button",
83
+ role: "tab",
84
+ "aria-selected": a,
85
+ "aria-controls": `${s}-panel-${r}`,
86
+ tabIndex: a ? 0 : -1,
87
+ "data-active": a,
88
+ onClick: () => h(r),
89
+ onKeyDown: L,
90
+ style: k,
91
+ className: y(
92
+ // The lib's CSS omits Tailwind preflight, so reset the native button
93
+ // border explicitly (none on top/sides) and keep only the bottom indicator.
94
+ "jcTab -mb-0.5 inline-flex shrink-0 cursor-pointer appearance-none items-center gap-2 whitespace-nowrap bg-transparent px-5 py-3",
95
+ "border-solid border-t-0 border-x-0 border-b-[3px] border-b-[color:transparent]",
96
+ "text-[27px] font-normal text-jc-black transition-[color,border-color] duration-200",
97
+ // Active indicator + focus ring track the app's selected theme color
98
+ // (--jc-theme-color, injected by DefaultTemplate); jc-gold (#fab62d) is the
99
+ // fallback outside a themed app. Keep these strings literal — Tailwind only
100
+ // scans complete class strings, so the color can't be interpolated.
101
+ "data-[active=true]:font-semibold data-[active=true]:border-b-[color:var(--jc-theme-color,#fab62d)]",
102
+ // Inset the focus ring (negative offset) so the horizontal ScrollContainer
103
+ // (which clips overflow-y) can't cut it off at the top/bottom or scroll edges.
104
+ "focus-visible:rounded-[4px] focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[color:var(--jc-theme-color,#fab62d)]",
105
+ $
106
+ ),
107
+ children: [
108
+ t.icon,
109
+ t.label
110
+ ]
111
+ },
112
+ r
113
+ );
114
+ })
115
+ }
116
+ )
103
117
  }
104
118
  ),
105
- /* @__PURE__ */ v(
119
+ /* @__PURE__ */ b(
106
120
  "div",
107
121
  {
108
122
  role: "tabpanel",
109
- id: `${s}-panel-${c}`,
110
- "aria-labelledby": `${s}-tab-${c}`,
123
+ id: `${s}-panel-${d}`,
124
+ "aria-labelledby": `${s}-tab-${d}`,
111
125
  tabIndex: 0,
112
126
  className: "jcTabPanel pt-6",
113
- children: e[c].content
127
+ children: e[d].content
114
128
  }
115
129
  )
116
130
  ] });
117
131
  };
118
132
  export {
119
- M as Tabs,
120
- M as default
133
+ z as Tabs,
134
+ z as default
121
135
  };