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/Pill/Pill.d.ts +1 -0
- package/Pill/Pill.js +23 -21
- package/ScrollContainer/ScrollContainer.d.ts +7 -0
- package/ScrollContainer/ScrollContainer.js +410 -403
- package/Table/Table.d.ts +2 -1
- package/Table/Table.js +5616 -5605
- package/Tabs/Tabs.js +95 -81
- package/assets/style.css +1 -1
- package/assets/tailwind.css +2 -2
- package/package.json +1 -1
- package/theme.d.ts +2 -0
- package/theme.js +2 -0
package/Tabs/Tabs.js
CHANGED
|
@@ -1,121 +1,135 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useId as
|
|
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
|
|
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,
|
|
10
|
+
}, x = (e, c) => {
|
|
10
11
|
if (typeof window > "u") return null;
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
const l =
|
|
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
|
-
},
|
|
16
|
+
}, E = (e, c) => {
|
|
16
17
|
if (typeof window > "u") return;
|
|
17
|
-
const
|
|
18
|
-
|
|
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}?${
|
|
22
|
+
`${window.location.pathname}?${n}${window.location.hash}`
|
|
22
23
|
);
|
|
23
|
-
},
|
|
24
|
+
}, z = ({
|
|
24
25
|
tabs: e,
|
|
25
|
-
defaultIndex:
|
|
26
|
-
activeIndex:
|
|
26
|
+
defaultIndex: c = 0,
|
|
27
|
+
activeIndex: n,
|
|
27
28
|
onChange: l,
|
|
28
|
-
persistKey:
|
|
29
|
+
persistKey: u,
|
|
29
30
|
tabHeaderAlignment: j = "left",
|
|
30
|
-
headerFontSize:
|
|
31
|
+
headerFontSize: p,
|
|
31
32
|
headerClassName: $,
|
|
32
33
|
headerStyle: I
|
|
33
34
|
}) => {
|
|
34
|
-
const s =
|
|
35
|
-
() => (o ? x(o, e) : null) ??
|
|
36
|
-
),
|
|
37
|
-
if (
|
|
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
|
|
41
|
-
|
|
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
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
...
|
|
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
|
-
},
|
|
51
|
-
var m;
|
|
51
|
+
}, L = (t) => {
|
|
52
52
|
if (t.key !== "ArrowRight" && t.key !== "ArrowLeft") return;
|
|
53
53
|
t.preventDefault();
|
|
54
|
-
const
|
|
55
|
-
|
|
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__ */
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
|
|
59
|
+
return /* @__PURE__ */ v("div", { className: "jcTabs flex w-full flex-col", children: [
|
|
60
|
+
/* @__PURE__ */ b(
|
|
61
|
+
A,
|
|
60
62
|
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
children:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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__ */
|
|
119
|
+
/* @__PURE__ */ b(
|
|
106
120
|
"div",
|
|
107
121
|
{
|
|
108
122
|
role: "tabpanel",
|
|
109
|
-
id: `${s}-panel-${
|
|
110
|
-
"aria-labelledby": `${s}-tab-${
|
|
123
|
+
id: `${s}-panel-${d}`,
|
|
124
|
+
"aria-labelledby": `${s}-tab-${d}`,
|
|
111
125
|
tabIndex: 0,
|
|
112
126
|
className: "jcTabPanel pt-6",
|
|
113
|
-
children: e[
|
|
127
|
+
children: e[d].content
|
|
114
128
|
}
|
|
115
129
|
)
|
|
116
130
|
] });
|
|
117
131
|
};
|
|
118
132
|
export {
|
|
119
|
-
|
|
120
|
-
|
|
133
|
+
z as Tabs,
|
|
134
|
+
z as default
|
|
121
135
|
};
|