@overdoser/react-toolkit 0.6.0 → 0.8.0
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/AGENTS.md +6 -0
- package/CHANGELOG.md +82 -0
- package/components/ActionButton/ActionButton.d.ts +105 -0
- package/components/ActionButton/ActionButton.js +211 -0
- package/components/ActionButton/ActionButton.module.scss.js +47 -0
- package/components/ActionButton/CopyButton.d.ts +31 -0
- package/components/ActionButton/CopyButton.js +66 -0
- package/components/ActionButton/index.d.ts +4 -0
- package/components/Alert/Alert.js +82 -0
- package/components/Alert/Alert.module.scss.js +25 -0
- package/components/Avatar/Avatar.js +57 -0
- package/components/Avatar/Avatar.module.scss.js +43 -0
- package/components/Badge/Badge.js +38 -0
- package/components/Badge/Badge.module.scss.js +31 -0
- package/components/Breadcrumbs/Breadcrumbs.js +49 -0
- package/components/Breadcrumbs/Breadcrumbs.module.scss.js +17 -0
- package/components/Button/Button.js +57 -0
- package/components/Button/Button.module.scss.js +47 -0
- package/components/Chart/AreaChart.js +244 -0
- package/components/Chart/Axis.js +45 -0
- package/components/Chart/BarChart.js +353 -0
- package/components/Chart/Chart.module.scss.js +61 -0
- package/components/Chart/ChartContainer.js +41 -0
- package/components/Chart/ChartLegend.js +31 -0
- package/components/Chart/ChartTooltip.js +42 -0
- package/components/Chart/LineChart.js +236 -0
- package/components/Chart/PieChart.js +248 -0
- package/components/Chart/RadarChart.js +221 -0
- package/components/Chart/Sparkline.js +69 -0
- package/components/Chart/TradingChart.js +732 -0
- package/components/Chart/scales.js +39 -0
- package/components/Chart/trading/indicators.js +68 -0
- package/components/Chart/trading/period.js +71 -0
- package/components/Chart/useChartDimensions.js +23 -0
- package/components/Divider/Divider.js +36 -0
- package/components/Divider/Divider.module.scss.js +31 -0
- package/components/Draggable/Draggable.js +155 -0
- package/components/Draggable/Draggable.module.scss.js +17 -0
- package/components/Drawer/Drawer.js +126 -0
- package/components/Drawer/Drawer.module.scss.js +117 -0
- package/components/Dropdown/Dropdown.js +142 -0
- package/components/Dropdown/Dropdown.module.scss.js +35 -0
- package/components/Dropdown/DropdownItem.js +31 -0
- package/components/Dropzone/Dropzone.js +107 -0
- package/components/Dropzone/Dropzone.module.scss.js +21 -0
- package/components/Form/Form.js +36 -0
- package/components/Form/Form.module.scss.js +29 -0
- package/components/Form/FormField.js +76 -0
- package/components/Form/FormRow.js +9 -0
- package/components/Form/formFieldDefaults.js +5 -0
- package/components/Link/Link.js +59 -0
- package/components/Link/Link.module.scss.js +16 -0
- package/components/List/List.js +46 -0
- package/components/List/List.module.scss.js +21 -0
- package/components/Modal/Modal.js +109 -0
- package/components/Modal/Modal.module.scss.js +31 -0
- package/components/Pagination/Pagination.js +84 -0
- package/components/Pagination/Pagination.module.scss.js +23 -0
- package/components/Pagination/paginationRange.js +24 -0
- package/components/Popover/Popover.js +138 -0
- package/components/Popover/Popover.module.scss.js +21 -0
- package/components/Skeleton/Skeleton.js +50 -0
- package/components/Skeleton/Skeleton.module.scss.js +25 -0
- package/components/Spinner/Spinner.js +25 -0
- package/components/Spinner/Spinner.module.scss.js +20 -0
- package/components/Table/Table.d.ts +61 -6
- package/components/Table/Table.js +284 -0
- package/components/Table/Table.module.scss.js +59 -0
- package/components/Table/useTableSort.d.ts +7 -5
- package/components/Table/useTableSort.js +44 -0
- package/components/Tabs/Tabs.js +163 -0
- package/components/Tabs/Tabs.module.scss.js +53 -0
- package/components/Timer/Timer.js +159 -0
- package/components/Timer/Timer.module.scss.js +55 -0
- package/components/Toast/Toast.js +133 -0
- package/components/Toast/Toast.module.scss.js +62 -0
- package/components/Toast/toastStore.js +62 -0
- package/components/ToggleIconButton/ToggleIconButton.d.ts +62 -0
- package/components/ToggleIconButton/ToggleIconButton.js +58 -0
- package/components/ToggleIconButton/ToggleIconButton.module.scss.js +27 -0
- package/components/ToggleIconButton/index.d.ts +2 -0
- package/components/Tooltip/Tooltip.js +86 -0
- package/components/Tooltip/Tooltip.module.scss.js +30 -0
- package/components/Typography/Typography.js +37 -0
- package/components/Typography/Typography.module.scss.js +53 -0
- package/components/inputs/Checkbox/Checkbox.js +50 -0
- package/components/inputs/Checkbox/Checkbox.module.scss.js +15 -0
- package/components/inputs/Checkbox/CheckboxGroup.js +111 -0
- package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +31 -0
- package/components/inputs/DatePicker/DatePicker.js +229 -0
- package/components/inputs/DatePicker/DatePicker.module.scss.js +45 -0
- package/components/inputs/DatePicker/dateUtils.js +41 -0
- package/components/inputs/Input/Input.js +50 -0
- package/components/inputs/Input/Input.module.scss.js +25 -0
- package/components/inputs/NumberInput/NumberInput.js +134 -0
- package/components/inputs/NumberInput/NumberInput.module.scss.js +25 -0
- package/components/inputs/Radio/Radio.js +68 -0
- package/components/inputs/Radio/Radio.module.scss.js +13 -0
- package/components/inputs/Select/Select.js +520 -0
- package/components/inputs/Select/Select.module.scss.js +69 -0
- package/components/inputs/Slider/Slider.js +128 -0
- package/components/inputs/Slider/Slider.module.scss.js +15 -0
- package/components/inputs/Textarea/Textarea.js +58 -0
- package/components/inputs/Textarea/Textarea.module.scss.js +25 -0
- package/hooks/useClickOutside.js +15 -0
- package/hooks/useFocusTrap.js +39 -0
- package/hooks/useKeyboard.js +19 -0
- package/hooks/usePortalPosition.js +20 -0
- package/index.css +1 -1
- package/index.d.ts +4 -0
- package/index.js +119 -6575
- package/index.layered.css +1 -1
- package/llms.txt +123 -5
- package/manifest.json +230 -2
- package/package.json +3 -2
- package/recipes/comparison-table.tsx +123 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { jsx as l, jsxs as H } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as R, useRef as g, useId as T, useMemo as j, useEffect as P, createContext as E, useContext as u } from "react";
|
|
3
|
+
import { createPortal as K } from "react-dom";
|
|
4
|
+
import s from "clsx";
|
|
5
|
+
import { useFocusTrap as W } from "../../hooks/useFocusTrap.js";
|
|
6
|
+
import { useKeyboard as $ } from "../../hooks/useKeyboard.js";
|
|
7
|
+
import r from "./Modal.module.scss.js";
|
|
8
|
+
const n = E({ classes: {}, titleId: "" }), p = ({ children: e, className: t, style: a, onClose: o }) => {
|
|
9
|
+
const { classes: i, titleId: d } = u(n);
|
|
10
|
+
return /* @__PURE__ */ H(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
id: d,
|
|
14
|
+
className: s(r.header, o && r.headerWithClose, i.header, t),
|
|
15
|
+
style: a,
|
|
16
|
+
children: [
|
|
17
|
+
e,
|
|
18
|
+
o && /* @__PURE__ */ l(
|
|
19
|
+
"button",
|
|
20
|
+
{
|
|
21
|
+
type: "button",
|
|
22
|
+
className: s(r.closeButton, i.closeButton),
|
|
23
|
+
onClick: o,
|
|
24
|
+
"aria-label": "Close",
|
|
25
|
+
children: "×"
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
p.displayName = "Modal.Header";
|
|
33
|
+
const v = ({ children: e, className: t, style: a }) => {
|
|
34
|
+
const { classes: o } = u(n);
|
|
35
|
+
return /* @__PURE__ */ l("div", { className: s(r.body, o.body, t), style: a, children: e });
|
|
36
|
+
};
|
|
37
|
+
v.displayName = "Modal.Body";
|
|
38
|
+
const h = ({ children: e, className: t, style: a }) => {
|
|
39
|
+
const { classes: o } = u(n);
|
|
40
|
+
return /* @__PURE__ */ l("div", { className: s(r.footer, o.footer, t), style: a, children: e });
|
|
41
|
+
};
|
|
42
|
+
h.displayName = "Modal.Footer";
|
|
43
|
+
const m = R(
|
|
44
|
+
({
|
|
45
|
+
open: e,
|
|
46
|
+
onClose: t,
|
|
47
|
+
closeOnBackdrop: a = !0,
|
|
48
|
+
closeOnEscape: o = !0,
|
|
49
|
+
size: i = "md",
|
|
50
|
+
classes: d,
|
|
51
|
+
className: N,
|
|
52
|
+
style: k,
|
|
53
|
+
children: x,
|
|
54
|
+
"aria-label": f,
|
|
55
|
+
"aria-labelledby": C
|
|
56
|
+
}, M) => {
|
|
57
|
+
const B = g(null), y = M ?? B, w = T(), b = C ?? `${w}-title`;
|
|
58
|
+
W(y, e);
|
|
59
|
+
const I = j(
|
|
60
|
+
() => ({
|
|
61
|
+
Escape: () => {
|
|
62
|
+
o && t();
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
[o, t]
|
|
66
|
+
);
|
|
67
|
+
$(I, e), P(() => {
|
|
68
|
+
if (!e) return;
|
|
69
|
+
const c = document.body.style.overflow;
|
|
70
|
+
return document.body.style.overflow = "hidden", () => {
|
|
71
|
+
document.body.style.overflow = c;
|
|
72
|
+
};
|
|
73
|
+
}, [e]);
|
|
74
|
+
const F = (c) => {
|
|
75
|
+
a && c.target === c.currentTarget && t();
|
|
76
|
+
};
|
|
77
|
+
return e ? K(
|
|
78
|
+
/* @__PURE__ */ l(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
className: s(r.backdrop, d?.backdrop),
|
|
82
|
+
onClick: F,
|
|
83
|
+
role: "presentation",
|
|
84
|
+
children: /* @__PURE__ */ l(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
ref: y,
|
|
88
|
+
className: s(r.modal, r[i], d?.modal, N),
|
|
89
|
+
style: k,
|
|
90
|
+
role: "dialog",
|
|
91
|
+
"aria-modal": "true",
|
|
92
|
+
"aria-label": f,
|
|
93
|
+
"aria-labelledby": f ? void 0 : b,
|
|
94
|
+
children: /* @__PURE__ */ l(n.Provider, { value: { classes: d ?? {}, titleId: b }, children: x })
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
document.body
|
|
100
|
+
) : null;
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
m.displayName = "Modal";
|
|
104
|
+
m.Header = p;
|
|
105
|
+
m.Body = v;
|
|
106
|
+
m.Footer = h;
|
|
107
|
+
export {
|
|
108
|
+
m as Modal
|
|
109
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const o = "crk-backdrop-jYpTA", c = "crk-backdropIn-x5Z-A", r = "crk-modal-yNG-7", e = "crk-modalIn-xFUwm", s = "crk-sm--xyY9", t = "crk-md-ETTfh", d = "crk-lg-5DBb7", n = "crk-fullscreen-b4jQ-", l = "crk-header-NS30G", a = "crk-headerWithClose-4davm", k = "crk-closeButton-JX-aq", m = "crk-body-3zIj9", b = "crk-footer-Oyz-R", h = {
|
|
2
|
+
backdrop: o,
|
|
3
|
+
backdropIn: c,
|
|
4
|
+
modal: r,
|
|
5
|
+
modalIn: e,
|
|
6
|
+
sm: s,
|
|
7
|
+
md: t,
|
|
8
|
+
lg: d,
|
|
9
|
+
fullscreen: n,
|
|
10
|
+
header: l,
|
|
11
|
+
headerWithClose: a,
|
|
12
|
+
closeButton: k,
|
|
13
|
+
body: m,
|
|
14
|
+
footer: b
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
o as backdrop,
|
|
18
|
+
c as backdropIn,
|
|
19
|
+
m as body,
|
|
20
|
+
k as closeButton,
|
|
21
|
+
h as default,
|
|
22
|
+
b as footer,
|
|
23
|
+
n as fullscreen,
|
|
24
|
+
l as header,
|
|
25
|
+
a as headerWithClose,
|
|
26
|
+
d as lg,
|
|
27
|
+
t as md,
|
|
28
|
+
r as modal,
|
|
29
|
+
e as modalIn,
|
|
30
|
+
s as sm
|
|
31
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as t, jsxs as d, Fragment as x } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as T, useState as W } from "react";
|
|
3
|
+
import l from "clsx";
|
|
4
|
+
import r from "./Pagination.module.scss.js";
|
|
5
|
+
import { paginationRange as q } from "./paginationRange.js";
|
|
6
|
+
const w = ({ dir: c }) => /* @__PURE__ */ t("svg", { viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: {
|
|
7
|
+
left: /* @__PURE__ */ t("path", { d: "M7 2L3 6l4 4" }),
|
|
8
|
+
right: /* @__PURE__ */ t("path", { d: "M5 2l4 4-4 4" }),
|
|
9
|
+
first: /* @__PURE__ */ d(x, { children: [
|
|
10
|
+
/* @__PURE__ */ t("path", { d: "M8 2L4 6l4 4" }),
|
|
11
|
+
/* @__PURE__ */ t("path", { d: "M4 2v8" })
|
|
12
|
+
] }),
|
|
13
|
+
last: /* @__PURE__ */ d(x, { children: [
|
|
14
|
+
/* @__PURE__ */ t("path", { d: "M4 2l4 4-4 4" }),
|
|
15
|
+
/* @__PURE__ */ t("path", { d: "M8 2v8" })
|
|
16
|
+
] })
|
|
17
|
+
}[c] }), z = T(
|
|
18
|
+
({
|
|
19
|
+
count: c,
|
|
20
|
+
total: p,
|
|
21
|
+
pageSize: b = 10,
|
|
22
|
+
page: h,
|
|
23
|
+
defaultPage: k = 1,
|
|
24
|
+
onChange: C,
|
|
25
|
+
boundaryCount: G = 1,
|
|
26
|
+
siblingCount: N = 2,
|
|
27
|
+
showPrevNext: m = !0,
|
|
28
|
+
showFirstLast: f = !1,
|
|
29
|
+
size: y = "md",
|
|
30
|
+
disabled: u = !1,
|
|
31
|
+
label: j = "Pagination",
|
|
32
|
+
classes: e,
|
|
33
|
+
className: L,
|
|
34
|
+
...P
|
|
35
|
+
}, R) => {
|
|
36
|
+
const i = c ?? (p != null ? Math.max(1, Math.ceil(p / b)) : 1), g = h !== void 0, [$, B] = W(k), n = Math.min(Math.max(g ? h : $, 1), i), v = (o) => {
|
|
37
|
+
const a = Math.min(Math.max(o, 1), i);
|
|
38
|
+
a !== n && (g || B(a), C?.(a));
|
|
39
|
+
}, I = q(n, i, G, N), s = (o, a, M, S) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
|
|
40
|
+
"button",
|
|
41
|
+
{
|
|
42
|
+
type: "button",
|
|
43
|
+
className: l(r.item, r.control, e?.item, e?.control),
|
|
44
|
+
onClick: () => v(M),
|
|
45
|
+
disabled: u || n === M || (a === "left" || a === "first" ? n === 1 : n === i),
|
|
46
|
+
"aria-label": S,
|
|
47
|
+
children: /* @__PURE__ */ t(w, { dir: a })
|
|
48
|
+
}
|
|
49
|
+
) }, o);
|
|
50
|
+
return /* @__PURE__ */ t(
|
|
51
|
+
"nav",
|
|
52
|
+
{
|
|
53
|
+
ref: R,
|
|
54
|
+
"aria-label": j,
|
|
55
|
+
className: l(r.root, r[y], e?.root, L),
|
|
56
|
+
...P,
|
|
57
|
+
children: /* @__PURE__ */ d("ul", { className: l(r.list, e?.list), children: [
|
|
58
|
+
f && s("first", "first", 1, "Go to first page"),
|
|
59
|
+
m && s("prev", "left", n - 1, "Go to previous page"),
|
|
60
|
+
I.map(
|
|
61
|
+
(o, a) => o === "ellipsis" ? /* @__PURE__ */ t("li", { "aria-hidden": "true", className: l(r.ellipsis, e?.ellipsis), children: "…" }, `e${a}`) : /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
|
|
62
|
+
"button",
|
|
63
|
+
{
|
|
64
|
+
type: "button",
|
|
65
|
+
className: l(r.item, o === n && r.active, e?.item, o === n && e?.active),
|
|
66
|
+
onClick: () => v(o),
|
|
67
|
+
disabled: u,
|
|
68
|
+
"aria-current": o === n ? "page" : void 0,
|
|
69
|
+
"aria-label": `Go to page ${o}`,
|
|
70
|
+
children: o
|
|
71
|
+
}
|
|
72
|
+
) }, o)
|
|
73
|
+
),
|
|
74
|
+
m && s("next", "right", n + 1, "Go to next page"),
|
|
75
|
+
f && s("last", "last", i, "Go to last page")
|
|
76
|
+
] })
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
z.displayName = "Pagination";
|
|
82
|
+
export {
|
|
83
|
+
z as Pagination
|
|
84
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const t = "crk-root-IuiQ5", s = "crk-sm-tfMLg", c = "crk-md-MdjxU", o = "crk-lg-6-p8a", l = "crk-list-UN-OF", i = "crk-item-ZOauk", r = "crk-active-gs4QO", n = "crk-control-HnlrC", e = "crk-ellipsis-iAsGN", k = {
|
|
2
|
+
root: t,
|
|
3
|
+
sm: s,
|
|
4
|
+
md: c,
|
|
5
|
+
lg: o,
|
|
6
|
+
list: l,
|
|
7
|
+
item: i,
|
|
8
|
+
active: r,
|
|
9
|
+
control: n,
|
|
10
|
+
ellipsis: e
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
r as active,
|
|
14
|
+
n as control,
|
|
15
|
+
k as default,
|
|
16
|
+
e as ellipsis,
|
|
17
|
+
i as item,
|
|
18
|
+
o as lg,
|
|
19
|
+
l as list,
|
|
20
|
+
c as md,
|
|
21
|
+
t as root,
|
|
22
|
+
s as sm
|
|
23
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function l(i, s) {
|
|
2
|
+
const e = Math.max(s - i + 1, 0);
|
|
3
|
+
return Array.from({ length: e }, (h, m) => i + m);
|
|
4
|
+
}
|
|
5
|
+
function x(i, s, e = 1, h = 2) {
|
|
6
|
+
if (s <= 0) return [];
|
|
7
|
+
const m = l(1, Math.min(e, s)), M = l(Math.max(s - e + 1, e + 1), s), a = Math.max(
|
|
8
|
+
Math.min(i - h, s - e - h * 2 - 1),
|
|
9
|
+
e + 2
|
|
10
|
+
), g = Math.min(
|
|
11
|
+
Math.max(i + h, e + h * 2 + 2),
|
|
12
|
+
M.length > 0 ? M[0] - 2 : s - 1
|
|
13
|
+
);
|
|
14
|
+
return [
|
|
15
|
+
...m,
|
|
16
|
+
...a > e + 2 ? ["ellipsis"] : e + 1 < s - e ? [e + 1] : [],
|
|
17
|
+
...l(a, g),
|
|
18
|
+
...g < s - e - 1 ? ["ellipsis"] : s - e > e ? [s - e] : [],
|
|
19
|
+
...M
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
x as paginationRange
|
|
24
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx as S, jsxs as G } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as J, useState as E, useRef as B, useId as Q, useCallback as O, useLayoutEffect as U, useEffect as Z, isValidElement as _, cloneElement as ee } from "react";
|
|
3
|
+
import y from "clsx";
|
|
4
|
+
import R from "./Popover.module.scss.js";
|
|
5
|
+
import { useClickOutside as te } from "../../hooks/useClickOutside.js";
|
|
6
|
+
import { useKeyboard as oe } from "../../hooks/useKeyboard.js";
|
|
7
|
+
function re(...a) {
|
|
8
|
+
return (h) => {
|
|
9
|
+
for (const f of a)
|
|
10
|
+
f && (typeof f == "function" ? f(h) : f.current = h);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const ne = J(
|
|
14
|
+
({
|
|
15
|
+
trigger: a,
|
|
16
|
+
asChild: h = !1,
|
|
17
|
+
content: f,
|
|
18
|
+
position: n = "bottom",
|
|
19
|
+
autoPosition: m = !0,
|
|
20
|
+
open: j,
|
|
21
|
+
onOpenChange: z,
|
|
22
|
+
classes: g,
|
|
23
|
+
className: K,
|
|
24
|
+
style: P
|
|
25
|
+
}, T) => {
|
|
26
|
+
const [V, W] = E(!1), [A, M] = E(n), [D, X] = E(0), [F, Y] = E(0), $ = B(null), u = B(null), v = B(null), k = Q(), C = j !== void 0, o = C ? j : V, w = O(
|
|
27
|
+
(t) => {
|
|
28
|
+
C || W(t), z?.(t);
|
|
29
|
+
},
|
|
30
|
+
[C, z]
|
|
31
|
+
), q = O(() => {
|
|
32
|
+
w(!1), v.current?.focus();
|
|
33
|
+
}, [w]), H = O(() => {
|
|
34
|
+
w(!o);
|
|
35
|
+
}, [o, w]);
|
|
36
|
+
te($, q, o), oe(
|
|
37
|
+
{
|
|
38
|
+
Escape: () => q()
|
|
39
|
+
},
|
|
40
|
+
o
|
|
41
|
+
), U(() => {
|
|
42
|
+
if (!o || !m) {
|
|
43
|
+
M(n), X(0), Y(0);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (typeof window > "u") return;
|
|
47
|
+
const t = () => {
|
|
48
|
+
const b = v.current, x = u.current;
|
|
49
|
+
if (!b || !x) return;
|
|
50
|
+
const s = b.getBoundingClientRect(), i = x.getBoundingClientRect(), N = window.innerWidth, I = window.innerHeight, r = 8;
|
|
51
|
+
let c = n;
|
|
52
|
+
if (n === "bottom" || n === "top") {
|
|
53
|
+
const e = s.bottom + r + i.height <= I, p = s.top - r - i.height >= 0;
|
|
54
|
+
n === "bottom" && !e && p ? c = "top" : n === "top" && !p && e && (c = "bottom");
|
|
55
|
+
} else {
|
|
56
|
+
const e = s.right + r + i.width <= N, p = s.left - r - i.width >= 0;
|
|
57
|
+
n === "right" && !e && p ? c = "left" : n === "left" && !p && e && (c = "right");
|
|
58
|
+
}
|
|
59
|
+
let l = 0, d = 0;
|
|
60
|
+
if (c === "bottom" || c === "top") {
|
|
61
|
+
const e = s.left + s.width / 2 - i.width / 2;
|
|
62
|
+
e < r ? l = r - e : e + i.width > N - r && (l = N - r - (e + i.width));
|
|
63
|
+
} else {
|
|
64
|
+
const e = s.top + s.height / 2 - i.height / 2;
|
|
65
|
+
e < r ? d = r - e : e + i.height > I - r && (d = I - r - (e + i.height));
|
|
66
|
+
}
|
|
67
|
+
l = Math.round(l), d = Math.round(d), M((e) => e === c ? e : c), X((e) => e === l ? e : l), Y((e) => e === d ? e : d);
|
|
68
|
+
};
|
|
69
|
+
return t(), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t), () => {
|
|
70
|
+
window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", t);
|
|
71
|
+
};
|
|
72
|
+
}, [o, m, n]), Z(() => {
|
|
73
|
+
if (o && u.current) {
|
|
74
|
+
const t = u.current.querySelector(
|
|
75
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
76
|
+
);
|
|
77
|
+
t ? t.focus() : u.current.focus();
|
|
78
|
+
}
|
|
79
|
+
}, [o]);
|
|
80
|
+
let L;
|
|
81
|
+
if (h && _(a)) {
|
|
82
|
+
const t = a, b = t.ref;
|
|
83
|
+
L = ee(t, {
|
|
84
|
+
ref: re(v, b),
|
|
85
|
+
onClick: (x) => {
|
|
86
|
+
t.props.onClick?.(x), H();
|
|
87
|
+
},
|
|
88
|
+
className: y(t.props.className, g?.trigger),
|
|
89
|
+
"aria-expanded": o,
|
|
90
|
+
"aria-haspopup": "dialog",
|
|
91
|
+
"aria-controls": o ? k : void 0
|
|
92
|
+
});
|
|
93
|
+
} else
|
|
94
|
+
L = /* @__PURE__ */ S(
|
|
95
|
+
"button",
|
|
96
|
+
{
|
|
97
|
+
ref: v,
|
|
98
|
+
type: "button",
|
|
99
|
+
className: y(R.trigger, g?.trigger),
|
|
100
|
+
onClick: H,
|
|
101
|
+
"aria-expanded": o,
|
|
102
|
+
"aria-haspopup": "dialog",
|
|
103
|
+
"aria-controls": o ? k : void 0,
|
|
104
|
+
children: a
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
return /* @__PURE__ */ S(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
ref: T,
|
|
111
|
+
className: y(R.root, g?.root, K),
|
|
112
|
+
style: P,
|
|
113
|
+
children: /* @__PURE__ */ G("div", { ref: $, children: [
|
|
114
|
+
L,
|
|
115
|
+
o && /* @__PURE__ */ S(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
ref: u,
|
|
119
|
+
id: k,
|
|
120
|
+
role: "dialog",
|
|
121
|
+
tabIndex: -1,
|
|
122
|
+
className: y(R.popover, R[m ? A : n], g?.popover),
|
|
123
|
+
style: m ? {
|
|
124
|
+
"--crk-popover-shift-x": `${D}px`,
|
|
125
|
+
"--crk-popover-shift-y": `${F}px`
|
|
126
|
+
} : void 0,
|
|
127
|
+
children: f
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
] })
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
ne.displayName = "Popover";
|
|
136
|
+
export {
|
|
137
|
+
ne as Popover
|
|
138
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const o = "crk-root-8H-L9", t = "crk-trigger-Zn1nQ", r = "crk-popover-rvS3X", e = "crk-popoverFade-hj41M", c = "crk-bottom-lawQw", p = "crk-top-rqvC6", s = "crk-left-J6exv", n = "crk-right-3y20l", g = {
|
|
2
|
+
root: o,
|
|
3
|
+
trigger: t,
|
|
4
|
+
popover: r,
|
|
5
|
+
popoverFade: e,
|
|
6
|
+
bottom: c,
|
|
7
|
+
top: p,
|
|
8
|
+
left: s,
|
|
9
|
+
right: n
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
c as bottom,
|
|
13
|
+
g as default,
|
|
14
|
+
s as left,
|
|
15
|
+
r as popover,
|
|
16
|
+
e as popoverFade,
|
|
17
|
+
n as right,
|
|
18
|
+
o as root,
|
|
19
|
+
p as top,
|
|
20
|
+
t as trigger
|
|
21
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as y } from "react";
|
|
3
|
+
import a from "clsx";
|
|
4
|
+
import t from "./Skeleton.module.scss.js";
|
|
5
|
+
const o = (e) => typeof e == "number" ? `${e}px` : e, w = y(
|
|
6
|
+
({ variant: e = "text", width: m, height: s, animation: l = "pulse", lines: r = 1, classes: i, className: p, style: d, ...f }, c) => {
|
|
7
|
+
const h = l === "wave" ? t.wave : l === "none" ? void 0 : t.pulse;
|
|
8
|
+
if (e === "text" && r > 1)
|
|
9
|
+
return /* @__PURE__ */ n(
|
|
10
|
+
"div",
|
|
11
|
+
{
|
|
12
|
+
ref: c,
|
|
13
|
+
"aria-hidden": "true",
|
|
14
|
+
className: a(t.stack, i?.root, p),
|
|
15
|
+
style: d,
|
|
16
|
+
...f,
|
|
17
|
+
children: Array.from({ length: r }).map((k, u) => /* @__PURE__ */ n(
|
|
18
|
+
"span",
|
|
19
|
+
{
|
|
20
|
+
className: a(t.line, t.text, h, i?.line),
|
|
21
|
+
style: {
|
|
22
|
+
width: u === r - 1 ? "60%" : o(m) ?? "100%",
|
|
23
|
+
height: o(s)
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
u
|
|
27
|
+
))
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
const x = {
|
|
31
|
+
width: o(m),
|
|
32
|
+
height: o(s),
|
|
33
|
+
...d
|
|
34
|
+
};
|
|
35
|
+
return /* @__PURE__ */ n(
|
|
36
|
+
"div",
|
|
37
|
+
{
|
|
38
|
+
ref: c,
|
|
39
|
+
"aria-hidden": "true",
|
|
40
|
+
className: a(t.line, t[e], h, i?.root, p),
|
|
41
|
+
style: x,
|
|
42
|
+
...f
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
w.displayName = "Skeleton";
|
|
48
|
+
export {
|
|
49
|
+
w as Skeleton
|
|
50
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const e = "crk-line-8roAA", c = "crk-stack-8QHed", t = "crk-text-4oj9n", k = "crk-circle-o-WgD", r = "crk-rect-8lO4C", s = "crk-pulse-dX0ir", l = "crk-crk-skeleton-pulse-ZXPJJ", n = "crk-wave-S82D6", o = "crk-crk-skeleton-wave-rDp6Z", a = {
|
|
2
|
+
line: e,
|
|
3
|
+
stack: c,
|
|
4
|
+
text: t,
|
|
5
|
+
circle: k,
|
|
6
|
+
rect: r,
|
|
7
|
+
pulse: s,
|
|
8
|
+
"crk-skeleton-pulse": "crk-crk-skeleton-pulse-ZXPJJ",
|
|
9
|
+
crkSkeletonPulse: l,
|
|
10
|
+
wave: n,
|
|
11
|
+
"crk-skeleton-wave": "crk-crk-skeleton-wave-rDp6Z",
|
|
12
|
+
crkSkeletonWave: o
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
k as circle,
|
|
16
|
+
l as crkSkeletonPulse,
|
|
17
|
+
o as crkSkeletonWave,
|
|
18
|
+
a as default,
|
|
19
|
+
e as line,
|
|
20
|
+
s as pulse,
|
|
21
|
+
r as rect,
|
|
22
|
+
c as stack,
|
|
23
|
+
t as text,
|
|
24
|
+
n as wave
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsxs as c, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as d } from "react";
|
|
3
|
+
import a from "clsx";
|
|
4
|
+
import r from "./Spinner.module.scss.js";
|
|
5
|
+
const f = d(
|
|
6
|
+
({ size: t = "md", color: i, label: o = "Loading", classes: e, className: m, style: l, ...s }, p) => /* @__PURE__ */ c(
|
|
7
|
+
"span",
|
|
8
|
+
{
|
|
9
|
+
ref: p,
|
|
10
|
+
role: "status",
|
|
11
|
+
"aria-live": "polite",
|
|
12
|
+
className: a(r.root, r[t], e?.root, m),
|
|
13
|
+
style: i ? { ...l, color: i } : l,
|
|
14
|
+
...s,
|
|
15
|
+
children: [
|
|
16
|
+
/* @__PURE__ */ n("span", { className: a(r.circle, e?.circle), "aria-hidden": "true" }),
|
|
17
|
+
o ? /* @__PURE__ */ n("span", { className: a(r.label, e?.label), children: o }) : null
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
f.displayName = "Spinner";
|
|
23
|
+
export {
|
|
24
|
+
f as Spinner
|
|
25
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const r = "crk-root-wia8E", c = "crk-circle-8olrz", t = "crk-crk-spinner-rotate-vrMQr", o = "crk-sm-q2vog", e = "crk-md-kcEfs", n = "crk-lg-8yfDn", s = "crk-label-ahktK", k = {
|
|
2
|
+
root: r,
|
|
3
|
+
circle: c,
|
|
4
|
+
"crk-spinner-rotate": "crk-crk-spinner-rotate-vrMQr",
|
|
5
|
+
crkSpinnerRotate: t,
|
|
6
|
+
sm: o,
|
|
7
|
+
md: e,
|
|
8
|
+
lg: n,
|
|
9
|
+
label: s
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
c as circle,
|
|
13
|
+
t as crkSpinnerRotate,
|
|
14
|
+
k as default,
|
|
15
|
+
s as label,
|
|
16
|
+
n as lg,
|
|
17
|
+
e as md,
|
|
18
|
+
r as root,
|
|
19
|
+
o as sm
|
|
20
|
+
};
|
|
@@ -3,16 +3,47 @@ import { SortConfig } from './useTableSort';
|
|
|
3
3
|
export interface ColumnDef<T> {
|
|
4
4
|
/** Object key on each row to read the cell value from. */
|
|
5
5
|
key: keyof T & string;
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Header content (string or any ReactNode). Interactive elements (e.g. a
|
|
8
|
+
* remove button) are allowed; inside a `sortable` column they must call
|
|
9
|
+
* `e.stopPropagation()` in their click handler so the click doesn't sort.
|
|
10
|
+
*/
|
|
7
11
|
header: ReactNode;
|
|
8
12
|
/** Enable click-to-sort on the header. */
|
|
9
13
|
sortable?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Direction the sort cycle starts with when this column is first clicked:
|
|
16
|
+
* `none → defaultSortDirection → opposite → none`. Use `'desc'` for
|
|
17
|
+
* columns where "highest first" is the natural question (scores, amounts).
|
|
18
|
+
* @default 'asc'
|
|
19
|
+
*/
|
|
20
|
+
defaultSortDirection?: 'asc' | 'desc';
|
|
10
21
|
/** Custom cell renderer; defaults to rendering `row[key]`. */
|
|
11
22
|
render?: (value: T[keyof T], row: T, index: number) => ReactNode;
|
|
12
23
|
/** Column width (CSS value). */
|
|
13
24
|
width?: string | number;
|
|
14
25
|
/** Text alignment for cells in this column. */
|
|
15
26
|
align?: 'left' | 'center' | 'right';
|
|
27
|
+
/**
|
|
28
|
+
* Pin this column to the left edge while the table scrolls horizontally.
|
|
29
|
+
* Only meaningful with the `scrollable` (or `dragScroll`) table prop, and
|
|
30
|
+
* intended for the first column — multiple sticky columns all pin to
|
|
31
|
+
* `left: 0` and would overlap.
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
sticky?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Per-cell class name for this column. Pass a string to apply the same
|
|
37
|
+
* class to every cell, or a function `(value, row, index) => className` to
|
|
38
|
+
* compute it from the cell value (e.g. bucket shading). Returned
|
|
39
|
+
* `undefined` adds nothing.
|
|
40
|
+
*/
|
|
41
|
+
cellClassName?: string | ((value: T[keyof T], row: T, index: number) => string | undefined);
|
|
42
|
+
/**
|
|
43
|
+
* Per-cell inline style for this column. Same value-or-callback shape as
|
|
44
|
+
* `cellClassName`; merged over the column's `align`.
|
|
45
|
+
*/
|
|
46
|
+
cellStyle?: React.CSSProperties | ((value: T[keyof T], row: T, index: number) => React.CSSProperties | undefined);
|
|
16
47
|
}
|
|
17
48
|
export interface PaginationConfig {
|
|
18
49
|
/** Current page (1-based) */
|
|
@@ -49,8 +80,25 @@ export interface TableProps<T extends Record<string, unknown>> {
|
|
|
49
80
|
* server is expected to handle both.
|
|
50
81
|
*/
|
|
51
82
|
onSort?: (config: SortConfig[]) => void;
|
|
52
|
-
/** Enable multi-column sort via Ctrl/Cmd-click on a sortable header. @default true */
|
|
83
|
+
/** Enable multi-column sort via Ctrl/Cmd/Shift-click on a sortable header. @default true */
|
|
53
84
|
multiSort?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Wrap the table in a horizontal scroll container (`overflow-x: auto`).
|
|
87
|
+
* Enable when columns can outgrow the available width; required for
|
|
88
|
+
* `sticky` columns to have any effect.
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
scrollable?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Let users scroll the table horizontally by dragging anywhere on it with
|
|
94
|
+
* the middle or right mouse button. Implies `scrollable`. The left button
|
|
95
|
+
* keeps its native behavior (text selection, clicks); touch pans natively
|
|
96
|
+
* via the scroll container. After a right-button drag the context menu is
|
|
97
|
+
* suppressed — a direct right click (no drag within 200ms) opens it
|
|
98
|
+
* normally.
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
dragScroll?: boolean;
|
|
54
102
|
/** Alternate row backgrounds. @default false */
|
|
55
103
|
striped?: boolean;
|
|
56
104
|
/** Highlight rows on hover. @default false */
|
|
@@ -81,17 +129,24 @@ export interface TableProps<T extends Record<string, unknown>> {
|
|
|
81
129
|
classes?: Partial<TableClasses>;
|
|
82
130
|
}
|
|
83
131
|
/**
|
|
84
|
-
* Generic data table with sortable columns, multi-sort (Ctrl/Cmd-click),
|
|
85
|
-
* client- or server-side pagination.
|
|
132
|
+
* Generic data table with sortable columns, multi-sort (Ctrl/Cmd/Shift-click),
|
|
133
|
+
* and client- or server-side pagination.
|
|
86
134
|
*
|
|
87
|
-
* Sort cycle on header click: `none → asc → desc → none
|
|
135
|
+
* Sort cycle on header click: `none → asc → desc → none` (start with `desc`
|
|
136
|
+
* via `defaultSortDirection: 'desc'` on the column).
|
|
88
137
|
*
|
|
89
138
|
* **Client-side mode** (default): omit `onSort`. Table sorts and paginates internally.
|
|
90
139
|
*
|
|
91
140
|
* **Controlled mode**: pass `sortConfig` + `onSort`. Your server returns the
|
|
92
141
|
* page already sorted and sliced; pass `pagination.totalRows` so the
|
|
93
142
|
* paginator can compute page count.
|
|
143
|
+
*
|
|
144
|
+
* **Wide tables**: `scrollable` makes the wrapper scroll horizontally,
|
|
145
|
+
* `dragScroll` adds middle/right-mouse-button drag panning, and
|
|
146
|
+
* `sticky: true` on the first column pins it to the left edge. Per-cell
|
|
147
|
+
* styling (e.g. value-bucket shading) via `cellClassName`/`cellStyle` on
|
|
148
|
+
* the column.
|
|
94
149
|
*/
|
|
95
|
-
declare function TableInner<T extends Record<string, unknown>>({ data, columns, sortConfig: controlledSortConfig, onSort, multiSort, striped, hoverable, compact, className, style, rowKey, rowClassName, rowStyle, emptyMessage, pagination, classes, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
150
|
+
declare function TableInner<T extends Record<string, unknown>>({ data, columns, sortConfig: controlledSortConfig, onSort, multiSort, scrollable, dragScroll, striped, hoverable, compact, className, style, rowKey, rowClassName, rowStyle, emptyMessage, pagination, classes, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
96
151
|
export declare const Table: typeof TableInner;
|
|
97
152
|
export {};
|