@overdoser/react-toolkit 0.18.0 → 0.20.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 +51 -7
- package/CHANGELOG.md +162 -0
- package/components/Accordion/Accordion.d.ts +94 -0
- package/components/Accordion/Accordion.js +180 -0
- package/components/Accordion/Accordion.module.scss.js +36 -0
- package/components/Accordion/index.d.ts +2 -0
- package/components/Alert/Alert.d.ts +29 -1
- package/components/Alert/Alert.js +44 -30
- package/components/Alert/Alert.module.scss.js +24 -16
- package/components/Alert/index.d.ts +1 -1
- package/components/Card/Card.d.ts +86 -0
- package/components/Card/Card.js +132 -0
- package/components/Card/Card.module.scss.js +60 -0
- package/components/Card/index.d.ts +2 -0
- package/components/Chip/Chip.d.ts +86 -0
- package/components/Chip/Chip.js +141 -0
- package/components/Chip/Chip.module.scss.js +59 -0
- package/components/Chip/index.d.ts +2 -0
- package/components/CodeBlock/CodeBlock.d.ts +78 -0
- package/components/CodeBlock/CodeBlock.js +120 -0
- package/components/CodeBlock/CodeBlock.module.scss.js +43 -0
- package/components/CodeBlock/index.d.ts +2 -0
- package/components/CommandPalette/CommandPalette.d.ts +141 -0
- package/components/CommandPalette/CommandPalette.js +397 -0
- package/components/CommandPalette/CommandPalette.module.scss.js +49 -0
- package/components/CommandPalette/index.d.ts +2 -0
- package/components/ConfirmDialog/ConfirmDialog.d.ts +119 -0
- package/components/ConfirmDialog/ConfirmDialog.js +201 -0
- package/components/ConfirmDialog/ConfirmDialog.module.scss.js +21 -0
- package/components/ConfirmDialog/index.d.ts +2 -0
- package/components/Drawer/Drawer.d.ts +1 -0
- package/components/Drawer/Drawer.js +35 -36
- package/components/Drawer/Drawer.module.scss.js +20 -18
- package/components/Dropdown/Dropdown.d.ts +47 -7
- package/components/Dropdown/Dropdown.js +174 -81
- package/components/Dropdown/Dropdown.module.scss.js +40 -22
- package/components/Dropdown/DropdownItem.d.ts +31 -2
- package/components/Dropdown/DropdownItem.js +54 -27
- package/components/Dropdown/DropdownLabel.d.ts +11 -0
- package/components/Dropdown/DropdownLabel.js +11 -0
- package/components/Dropdown/DropdownSeparator.d.ts +12 -0
- package/components/Dropdown/DropdownSeparator.js +11 -0
- package/components/Dropdown/dropdownContext.d.ts +6 -0
- package/components/Dropdown/dropdownContext.js +5 -0
- package/components/Dropdown/index.d.ts +8 -2
- package/components/Dropdown/useContextMenu.d.ts +32 -0
- package/components/Dropdown/useContextMenu.js +18 -0
- package/components/EmptyState/EmptyState.d.ts +53 -0
- package/components/EmptyState/EmptyState.js +55 -0
- package/components/EmptyState/EmptyState.module.scss.js +25 -0
- package/components/EmptyState/index.d.ts +2 -0
- package/components/Form/FormField.js +25 -24
- package/components/ImageViewer/ImageViewer.d.ts +105 -0
- package/components/ImageViewer/ImageViewer.js +201 -0
- package/components/ImageViewer/ImageViewer.module.scss.js +47 -0
- package/components/ImageViewer/index.d.ts +4 -0
- package/components/ImageViewer/useZoomPan.d.ts +94 -0
- package/components/ImageViewer/useZoomPan.js +141 -0
- package/components/Kbd/Kbd.d.ts +26 -0
- package/components/Kbd/Kbd.js +22 -0
- package/components/Kbd/Kbd.module.scss.js +17 -0
- package/components/Kbd/index.d.ts +2 -0
- package/components/KeyValueList/KeyValueList.d.ts +84 -0
- package/components/KeyValueList/KeyValueList.js +127 -0
- package/components/KeyValueList/KeyValueList.module.scss.js +43 -0
- package/components/KeyValueList/index.d.ts +2 -0
- package/components/Modal/Modal.d.ts +1 -0
- package/components/Modal/Modal.js +40 -41
- package/components/Modal/Modal.module.scss.js +18 -16
- package/components/PageHeader/PageHeader.d.ts +61 -0
- package/components/PageHeader/PageHeader.js +73 -0
- package/components/PageHeader/PageHeader.module.scss.js +43 -0
- package/components/PageHeader/index.d.ts +2 -0
- package/components/ProgressBar/ProgressBar.d.ts +74 -0
- package/components/ProgressBar/ProgressBar.js +90 -0
- package/components/ProgressBar/ProgressBar.module.scss.js +51 -0
- package/components/ProgressBar/index.d.ts +2 -0
- package/components/RelativeTime/RelativeTime.d.ts +45 -0
- package/components/RelativeTime/RelativeTime.js +43 -0
- package/components/RelativeTime/RelativeTime.module.scss.js +7 -0
- package/components/RelativeTime/index.d.ts +2 -0
- package/components/SegmentedControl/SegmentedControl.d.ts +84 -0
- package/components/SegmentedControl/SegmentedControl.js +131 -0
- package/components/SegmentedControl/SegmentedControl.module.scss.js +39 -0
- package/components/SegmentedControl/index.d.ts +2 -0
- package/components/SplitPane/SplitPane.d.ts +61 -0
- package/components/SplitPane/SplitPane.js +171 -0
- package/components/SplitPane/SplitPane.module.scss.js +25 -0
- package/components/SplitPane/index.d.ts +2 -0
- package/components/StatCard/StatCard.d.ts +105 -0
- package/components/StatCard/StatCard.js +127 -0
- package/components/StatCard/StatCard.module.scss.js +72 -0
- package/components/StatCard/index.d.ts +2 -0
- package/components/StatusDot/StatusDot.d.ts +33 -0
- package/components/StatusDot/StatusDot.js +39 -0
- package/components/StatusDot/StatusDot.module.scss.js +32 -0
- package/components/StatusDot/index.d.ts +2 -0
- package/components/Table/Table.d.ts +140 -17
- package/components/Table/Table.js +382 -210
- package/components/Table/Table.module.scss.js +68 -46
- package/components/Table/index.d.ts +1 -1
- package/components/Table/useTableSort.d.ts +1 -1
- package/components/ThemeToggle/ThemeToggle.d.ts +40 -0
- package/components/ThemeToggle/ThemeToggle.js +98 -0
- package/components/ThemeToggle/ThemeToggle.module.scss.js +23 -0
- package/components/ThemeToggle/index.d.ts +2 -0
- package/components/inputs/Checkbox/Checkbox.d.ts +2 -0
- package/components/inputs/Checkbox/Checkbox.js +29 -28
- package/components/inputs/Checkbox/Checkbox.module.scss.js +8 -6
- package/components/inputs/Input/Input.d.ts +33 -1
- package/components/inputs/Input/Input.js +94 -35
- package/components/inputs/Input/Input.module.scss.js +14 -12
- package/components/inputs/Radio/Radio.d.ts +5 -4
- package/components/inputs/Radio/Radio.js +55 -50
- package/components/inputs/Radio/Radio.module.scss.js +12 -10
- package/components/inputs/SearchInput/SearchInput.d.ts +57 -0
- package/components/inputs/SearchInput/SearchInput.js +116 -0
- package/components/inputs/SearchInput/SearchInput.module.scss.js +13 -0
- package/components/inputs/SearchInput/index.d.ts +2 -0
- package/components/inputs/Select/Select.d.ts +52 -0
- package/components/inputs/Select/Select.js +494 -385
- package/components/inputs/Select/Select.module.scss.js +34 -30
- package/components/inputs/Switch/Switch.d.ts +15 -0
- package/components/inputs/Switch/Switch.js +8 -0
- package/components/inputs/Switch/index.d.ts +2 -0
- package/hooks/useDebouncedValue.d.ts +15 -0
- package/hooks/useDebouncedValue.js +15 -0
- package/hooks/useElementSize.d.ts +20 -0
- package/hooks/useElementSize.js +23 -0
- package/hooks/useKeyboard.d.ts +49 -5
- package/hooks/useKeyboard.js +66 -16
- package/hooks/useMediaQuery.d.ts +14 -0
- package/hooks/useMediaQuery.js +16 -0
- package/hooks/useNow.d.ts +14 -0
- package/hooks/useNow.js +35 -0
- package/hooks/usePersistedState.d.ts +30 -0
- package/hooks/usePersistedState.js +99 -0
- package/hooks/useResizable.d.ts +66 -0
- package/hooks/useResizable.js +105 -0
- package/hooks/useTheme.d.ts +33 -0
- package/hooks/useTheme.js +25 -0
- package/index.css +1 -1
- package/index.d.ts +58 -4
- package/index.js +208 -132
- package/index.layered.css +1 -1
- package/llms.txt +620 -26
- package/manifest.json +1795 -99
- package/package.json +1 -1
- package/recipes/confirm-modal.tsx +65 -53
- package/recipes/floating-copy-button.tsx +32 -28
- package/utils/formatBytes.d.ts +21 -0
- package/utils/formatBytes.js +14 -0
- package/utils/index.d.ts +6 -0
- package/utils/themeScript.d.ts +19 -0
- package/utils/themeScript.js +9 -0
- package/utils/timeAgo.d.ts +33 -0
- package/utils/timeAgo.js +37 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { jsxs as o, Fragment as x, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as j } from "react";
|
|
3
|
+
import n from "clsx";
|
|
4
|
+
import e from "./StatCard.module.scss.js";
|
|
5
|
+
import { Skeleton as $ } from "../Skeleton/Skeleton.js";
|
|
6
|
+
const M = (t) => `${new Intl.NumberFormat(void 0, { maximumFractionDigits: 1 }).format(Math.abs(t))}%`;
|
|
7
|
+
function O(t, i) {
|
|
8
|
+
return t == null ? null : typeof t == "number" ? Number.isFinite(t) ? { text: i(t), trend: t > 0 ? "up" : t < 0 ? "down" : "flat" } : null : { text: t.value, trend: t.trend ?? "flat" };
|
|
9
|
+
}
|
|
10
|
+
function P(t, i) {
|
|
11
|
+
return i === "none" || t === "flat" ? "neutral" : t === "up" === (i !== "positive-down") ? "positive" : "negative";
|
|
12
|
+
}
|
|
13
|
+
const q = j(
|
|
14
|
+
({
|
|
15
|
+
label: t,
|
|
16
|
+
value: i,
|
|
17
|
+
unit: l,
|
|
18
|
+
delta: N,
|
|
19
|
+
deltaFormat: g = M,
|
|
20
|
+
trendColor: y = "auto",
|
|
21
|
+
deltaLabel: c,
|
|
22
|
+
icon: h,
|
|
23
|
+
chart: s,
|
|
24
|
+
footer: p,
|
|
25
|
+
href: f,
|
|
26
|
+
loading: u = !1,
|
|
27
|
+
variant: R = "outlined",
|
|
28
|
+
size: T = "md",
|
|
29
|
+
accent: b,
|
|
30
|
+
classes: a,
|
|
31
|
+
className: z,
|
|
32
|
+
style: B,
|
|
33
|
+
onClick: w,
|
|
34
|
+
onKeyDown: S,
|
|
35
|
+
...k
|
|
36
|
+
}, D) => {
|
|
37
|
+
const d = u ? null : O(N, g), C = d ? P(d.trend, y) : "neutral", v = !f && !!w, E = !!f || v, K = (m) => {
|
|
38
|
+
S?.(m), !(!v || m.defaultPrevented) && (m.key === "Enter" || m.key === " ") && (m.preventDefault(), m.currentTarget.click());
|
|
39
|
+
}, F = n(
|
|
40
|
+
e.root,
|
|
41
|
+
e[R],
|
|
42
|
+
e[`size-${T}`],
|
|
43
|
+
E && e.interactive,
|
|
44
|
+
b && e.accented,
|
|
45
|
+
u && e.loading,
|
|
46
|
+
a?.root,
|
|
47
|
+
z
|
|
48
|
+
), G = { ...b ? { "--crk-stat-accent": b } : null, ...B }, I = /* @__PURE__ */ o(x, { children: [
|
|
49
|
+
/* @__PURE__ */ o("div", { className: n(e.header, a?.header), children: [
|
|
50
|
+
/* @__PURE__ */ r("span", { className: n(e.label, a?.label), children: t }),
|
|
51
|
+
h && /* @__PURE__ */ r("span", { className: n(e.icon, a?.icon), "aria-hidden": "true", children: h })
|
|
52
|
+
] }),
|
|
53
|
+
u ? /* @__PURE__ */ o("div", { className: e.skeletons, "aria-hidden": "true", children: [
|
|
54
|
+
/* @__PURE__ */ r($, { variant: "text", width: "55%", height: "1.6em" }),
|
|
55
|
+
/* @__PURE__ */ r($, { variant: "text", width: "35%", height: "0.9em" })
|
|
56
|
+
] }) : /* @__PURE__ */ o(x, { children: [
|
|
57
|
+
/* @__PURE__ */ o("div", { className: n(e.value, a?.value), children: [
|
|
58
|
+
i,
|
|
59
|
+
l != null && /* @__PURE__ */ r("span", { className: n(e.unit, a?.unit), children: l })
|
|
60
|
+
] }),
|
|
61
|
+
(d || c) && /* @__PURE__ */ o("div", { className: e.deltaRow, children: [
|
|
62
|
+
d && /* @__PURE__ */ o("span", { className: n(e.delta, e[`tone-${C}`], a?.delta), children: [
|
|
63
|
+
d.trend !== "flat" && /* @__PURE__ */ o(x, { children: [
|
|
64
|
+
/* @__PURE__ */ r("span", { "aria-hidden": "true", className: e.arrow, children: d.trend === "up" ? "▲" : "▼" }),
|
|
65
|
+
/* @__PURE__ */ r("span", { className: e.srOnly, children: d.trend })
|
|
66
|
+
] }),
|
|
67
|
+
d.text
|
|
68
|
+
] }),
|
|
69
|
+
c && /* @__PURE__ */ r("span", { className: n(e.deltaLabel, a?.deltaLabel), children: c })
|
|
70
|
+
] })
|
|
71
|
+
] }),
|
|
72
|
+
s && /* @__PURE__ */ r("div", { className: n(e.chart, a?.chart), children: s }),
|
|
73
|
+
p && /* @__PURE__ */ r("div", { className: n(e.footer, a?.footer), children: p })
|
|
74
|
+
] });
|
|
75
|
+
return f ? /* @__PURE__ */ r(
|
|
76
|
+
"a",
|
|
77
|
+
{
|
|
78
|
+
ref: D,
|
|
79
|
+
href: f,
|
|
80
|
+
className: F,
|
|
81
|
+
style: G,
|
|
82
|
+
"aria-busy": u || void 0,
|
|
83
|
+
...k,
|
|
84
|
+
children: I
|
|
85
|
+
}
|
|
86
|
+
) : /* @__PURE__ */ r(
|
|
87
|
+
"div",
|
|
88
|
+
{
|
|
89
|
+
ref: D,
|
|
90
|
+
className: F,
|
|
91
|
+
style: G,
|
|
92
|
+
role: v ? "button" : void 0,
|
|
93
|
+
tabIndex: v ? 0 : void 0,
|
|
94
|
+
onClick: w,
|
|
95
|
+
onKeyDown: v || S ? K : void 0,
|
|
96
|
+
"aria-busy": u || void 0,
|
|
97
|
+
...k,
|
|
98
|
+
children: I
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
q.displayName = "StatCard";
|
|
104
|
+
const A = j(
|
|
105
|
+
({ columns: t = { sm: 1, md: 2, lg: 4 }, gap: i = "md", classes: l, className: N, style: g, children: y, ...c }, h) => {
|
|
106
|
+
const s = typeof t == "number" ? { sm: t, md: t, lg: t } : { sm: t.sm ?? 1, md: t.md ?? 2, lg: t.lg ?? 4 }, p = {
|
|
107
|
+
"--crk-stat-grid-columns-sm": String(s.sm),
|
|
108
|
+
"--crk-stat-grid-columns-md": String(s.md),
|
|
109
|
+
"--crk-stat-grid-columns-lg": String(s.lg)
|
|
110
|
+
};
|
|
111
|
+
return /* @__PURE__ */ r(
|
|
112
|
+
"div",
|
|
113
|
+
{
|
|
114
|
+
ref: h,
|
|
115
|
+
className: n(e.grid, e[`gap-${i}`], l?.root, N),
|
|
116
|
+
style: { ...p, ...g },
|
|
117
|
+
...c,
|
|
118
|
+
children: y
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
A.displayName = "StatGrid";
|
|
124
|
+
export {
|
|
125
|
+
q as StatCard,
|
|
126
|
+
A as StatGrid
|
|
127
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const e = "crk-root-zKEt2", t = "crk-outlined-XHAHG", c = "crk-elevated-VHDgT", o = "crk-filled-w9awn", n = "crk-size-sm-dy5Z-", r = "crk-size-md-Q1vXC", s = "crk-size-lg-RHsB3", a = "crk-interactive-w53Nd", i = "crk-accented-aEY4-", l = "crk-header-ZLeFH", k = "crk-label-E4Rgi", d = "crk-icon-XvPJv", g = "crk-value-0r3GP", v = "crk-unit-00NPF", p = "crk-deltaRow-AaiEx", m = "crk-delta-xCWjx", u = "crk-arrow-OdpoI", z = "crk-tone-positive-H-7co", h = "crk-tone-negative-kbhSv", y = "crk-tone-neutral-SAt38", b = "crk-deltaLabel-CzgUN", w = "crk-chart-GYQ0q", N = "crk-footer-K76y3", S = "crk-skeletons-uy-lT", H = "crk-srOnly-KSjm6", L = "crk-grid-bPuJo", f = "crk-gap-sm-60yMv", M = "crk-gap-md-peh45", P = "crk-gap-lg-7gGgN", R = {
|
|
2
|
+
root: e,
|
|
3
|
+
outlined: t,
|
|
4
|
+
elevated: c,
|
|
5
|
+
filled: o,
|
|
6
|
+
"size-sm": "crk-size-sm-dy5Z-",
|
|
7
|
+
sizeSm: n,
|
|
8
|
+
"size-md": "crk-size-md-Q1vXC",
|
|
9
|
+
sizeMd: r,
|
|
10
|
+
"size-lg": "crk-size-lg-RHsB3",
|
|
11
|
+
sizeLg: s,
|
|
12
|
+
interactive: a,
|
|
13
|
+
accented: i,
|
|
14
|
+
header: l,
|
|
15
|
+
label: k,
|
|
16
|
+
icon: d,
|
|
17
|
+
value: g,
|
|
18
|
+
unit: v,
|
|
19
|
+
deltaRow: p,
|
|
20
|
+
delta: m,
|
|
21
|
+
arrow: u,
|
|
22
|
+
"tone-positive": "crk-tone-positive-H-7co",
|
|
23
|
+
tonePositive: z,
|
|
24
|
+
"tone-negative": "crk-tone-negative-kbhSv",
|
|
25
|
+
toneNegative: h,
|
|
26
|
+
"tone-neutral": "crk-tone-neutral-SAt38",
|
|
27
|
+
toneNeutral: y,
|
|
28
|
+
deltaLabel: b,
|
|
29
|
+
chart: w,
|
|
30
|
+
footer: N,
|
|
31
|
+
skeletons: S,
|
|
32
|
+
srOnly: H,
|
|
33
|
+
grid: L,
|
|
34
|
+
"gap-sm": "crk-gap-sm-60yMv",
|
|
35
|
+
gapSm: f,
|
|
36
|
+
"gap-md": "crk-gap-md-peh45",
|
|
37
|
+
gapMd: M,
|
|
38
|
+
"gap-lg": "crk-gap-lg-7gGgN",
|
|
39
|
+
gapLg: P
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
i as accented,
|
|
43
|
+
u as arrow,
|
|
44
|
+
w as chart,
|
|
45
|
+
R as default,
|
|
46
|
+
m as delta,
|
|
47
|
+
b as deltaLabel,
|
|
48
|
+
p as deltaRow,
|
|
49
|
+
c as elevated,
|
|
50
|
+
o as filled,
|
|
51
|
+
N as footer,
|
|
52
|
+
P as gapLg,
|
|
53
|
+
M as gapMd,
|
|
54
|
+
f as gapSm,
|
|
55
|
+
L as grid,
|
|
56
|
+
l as header,
|
|
57
|
+
d as icon,
|
|
58
|
+
a as interactive,
|
|
59
|
+
k as label,
|
|
60
|
+
t as outlined,
|
|
61
|
+
e as root,
|
|
62
|
+
s as sizeLg,
|
|
63
|
+
r as sizeMd,
|
|
64
|
+
n as sizeSm,
|
|
65
|
+
S as skeletons,
|
|
66
|
+
H as srOnly,
|
|
67
|
+
h as toneNegative,
|
|
68
|
+
y as toneNeutral,
|
|
69
|
+
z as tonePositive,
|
|
70
|
+
v as unit,
|
|
71
|
+
g as value
|
|
72
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
export interface StatusDotClasses {
|
|
3
|
+
root: string;
|
|
4
|
+
dot: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
export type StatusDotStatus = 'success' | 'warning' | 'danger' | 'info' | 'neutral';
|
|
8
|
+
export interface StatusDotProps extends Omit<ComponentPropsWithRef<'span'>, 'color'> {
|
|
9
|
+
/** Colour intent of the dot. @default 'neutral' */
|
|
10
|
+
status?: StatusDotStatus;
|
|
11
|
+
/** Soft expanding ring animation (live / in-progress). Disabled under `prefers-reduced-motion`. @default false */
|
|
12
|
+
pulse?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Text rendered after the dot. Without a label the dot alone carries no
|
|
15
|
+
* accessible name — pass `aria-label` (which also sets `role="img"`).
|
|
16
|
+
*/
|
|
17
|
+
label?: ReactNode;
|
|
18
|
+
/** Dot diameter: 0.5 / 0.625 / 0.75rem. @default 'md' */
|
|
19
|
+
size?: 'sm' | 'md' | 'lg';
|
|
20
|
+
/** Any CSS colour; overrides the `status` colour (via `--crk-status-dot-color`). */
|
|
21
|
+
color?: string;
|
|
22
|
+
/** Override class names on internal elements. */
|
|
23
|
+
classes?: Partial<StatusDotClasses>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Coloured status indicator dot with an optional label — online/offline,
|
|
27
|
+
* healthy/degraded, saving/saved.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* <StatusDot status="success" label="Online" />
|
|
31
|
+
* <StatusDot status="warning" pulse aria-label="Saving" />
|
|
32
|
+
*/
|
|
33
|
+
export declare const StatusDot: import('react').ForwardRefExoticComponent<Omit<StatusDotProps, "ref"> & import('react').RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsxs as x, jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as N } from "react";
|
|
3
|
+
import a from "clsx";
|
|
4
|
+
import t from "./StatusDot.module.scss.js";
|
|
5
|
+
const h = N(
|
|
6
|
+
({
|
|
7
|
+
status: d = "neutral",
|
|
8
|
+
pulse: i = !1,
|
|
9
|
+
label: r,
|
|
10
|
+
size: n = "md",
|
|
11
|
+
color: e,
|
|
12
|
+
classes: o,
|
|
13
|
+
className: p,
|
|
14
|
+
style: s,
|
|
15
|
+
"aria-label": l,
|
|
16
|
+
...f
|
|
17
|
+
}, u) => {
|
|
18
|
+
const c = e ? { ...s, "--crk-status-dot-color": e } : s;
|
|
19
|
+
return /* @__PURE__ */ x(
|
|
20
|
+
"span",
|
|
21
|
+
{
|
|
22
|
+
ref: u,
|
|
23
|
+
role: l ? "img" : void 0,
|
|
24
|
+
"aria-label": l,
|
|
25
|
+
className: a(t.root, t[d], t[n], o?.root, p),
|
|
26
|
+
style: c,
|
|
27
|
+
...f,
|
|
28
|
+
children: [
|
|
29
|
+
/* @__PURE__ */ m("span", { className: a(t.dot, i && t.pulse, o?.dot), "aria-hidden": "true" }),
|
|
30
|
+
r != null && r !== !1 && /* @__PURE__ */ m("span", { className: a(t.label, o?.label), children: r })
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
h.displayName = "StatusDot";
|
|
37
|
+
export {
|
|
38
|
+
h as StatusDot
|
|
39
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const s = "crk-root-mk5vg", t = "crk-sm-HElbl", c = "crk-md--UpcY", o = "crk-lg-Kx26L", r = "crk-success-ZX2Kp", n = "crk-warning-DTrhj", e = "crk-danger-Zlvpq", l = "crk-info-sq8X2", k = "crk-neutral-AoR5Q", u = "crk-dot-fG4xA", a = "crk-pulse-pfCL2", d = "crk-crk-status-dot-pulse-Me6AH", p = "crk-label-ViWke", g = {
|
|
2
|
+
root: s,
|
|
3
|
+
sm: t,
|
|
4
|
+
md: c,
|
|
5
|
+
lg: o,
|
|
6
|
+
success: r,
|
|
7
|
+
warning: n,
|
|
8
|
+
danger: e,
|
|
9
|
+
info: l,
|
|
10
|
+
neutral: k,
|
|
11
|
+
dot: u,
|
|
12
|
+
pulse: a,
|
|
13
|
+
"crk-status-dot-pulse": "crk-crk-status-dot-pulse-Me6AH",
|
|
14
|
+
crkStatusDotPulse: d,
|
|
15
|
+
label: p
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
d as crkStatusDotPulse,
|
|
19
|
+
e as danger,
|
|
20
|
+
g as default,
|
|
21
|
+
u as dot,
|
|
22
|
+
l as info,
|
|
23
|
+
p as label,
|
|
24
|
+
o as lg,
|
|
25
|
+
c as md,
|
|
26
|
+
k as neutral,
|
|
27
|
+
a as pulse,
|
|
28
|
+
s as root,
|
|
29
|
+
t as sm,
|
|
30
|
+
r as success,
|
|
31
|
+
n as warning
|
|
32
|
+
};
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import { SortConfig } from './useTableSort';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export type TableRowKey = string | number;
|
|
4
|
+
export interface TableBulkActionsContext<T> {
|
|
5
|
+
/** Keys of the selected rows (from `rowKey`). */
|
|
6
|
+
selectedKeys: TableRowKey[];
|
|
7
|
+
/** The selected rows that are present in `data`. */
|
|
8
|
+
selectedRows: T[];
|
|
9
|
+
/** Clear the selection. */
|
|
10
|
+
clear: () => void;
|
|
11
|
+
}
|
|
12
|
+
interface ColumnCommon {
|
|
6
13
|
/**
|
|
7
14
|
* Header content (string or any ReactNode). Interactive elements (e.g. a
|
|
8
15
|
* remove button) are allowed; inside a `sortable` column they must call
|
|
9
16
|
* `e.stopPropagation()` in their click handler so the click doesn't sort.
|
|
10
17
|
*/
|
|
11
18
|
header: ReactNode;
|
|
12
|
-
/** Enable click-to-sort on the header. */
|
|
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';
|
|
21
|
-
/** Custom cell renderer; defaults to rendering `row[key]`. */
|
|
22
|
-
render?: (value: T[keyof T], row: T, index: number) => ReactNode;
|
|
23
19
|
/** Column width (CSS value). */
|
|
24
20
|
width?: string | number;
|
|
25
21
|
/** Text alignment for cells in this column. */
|
|
@@ -32,6 +28,23 @@ export interface ColumnDef<T> {
|
|
|
32
28
|
* @default false
|
|
33
29
|
*/
|
|
34
30
|
sticky?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** A column backed by a row field: `key` names the field, `render` is optional. */
|
|
33
|
+
export interface DataColumnDef<T> extends ColumnCommon {
|
|
34
|
+
/** Object key on each row to read the cell value from. */
|
|
35
|
+
key: keyof T & string;
|
|
36
|
+
id?: never;
|
|
37
|
+
/** Enable click-to-sort on the header. */
|
|
38
|
+
sortable?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Direction the sort cycle starts with when this column is first clicked:
|
|
41
|
+
* `none → defaultSortDirection → opposite → none`. Use `'desc'` for
|
|
42
|
+
* columns where "highest first" is the natural question (scores, amounts).
|
|
43
|
+
* @default 'asc'
|
|
44
|
+
*/
|
|
45
|
+
defaultSortDirection?: 'asc' | 'desc';
|
|
46
|
+
/** Custom cell renderer; defaults to rendering `row[key]`. */
|
|
47
|
+
render?: (value: T[keyof T], row: T, index: number) => ReactNode;
|
|
35
48
|
/**
|
|
36
49
|
* Per-cell class name for this column. Pass a string to apply the same
|
|
37
50
|
* class to every cell, or a function `(value, row, index) => className` to
|
|
@@ -45,6 +58,27 @@ export interface ColumnDef<T> {
|
|
|
45
58
|
*/
|
|
46
59
|
cellStyle?: React.CSSProperties | ((value: T[keyof T], row: T, index: number) => React.CSSProperties | undefined);
|
|
47
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* A column with no backing field (`'actions'`, `'select'`): `id` identifies it
|
|
63
|
+
* and `render` is required and receives the row. Not sortable.
|
|
64
|
+
*/
|
|
65
|
+
export interface DisplayColumnDef<T> extends ColumnCommon {
|
|
66
|
+
/** Unique id for the column (React key, `columnVisibility` key). */
|
|
67
|
+
id: string;
|
|
68
|
+
key?: never;
|
|
69
|
+
/** Renders the cell from the row. */
|
|
70
|
+
render: (row: T, index: number) => ReactNode;
|
|
71
|
+
/** Per-cell class name: a string, or `(row, index) => className`. */
|
|
72
|
+
cellClassName?: string | ((row: T, index: number) => string | undefined);
|
|
73
|
+
/** Per-cell inline style: an object, or `(row, index) => style`. */
|
|
74
|
+
cellStyle?: React.CSSProperties | ((row: T, index: number) => React.CSSProperties | undefined);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A table column: either a {@link DataColumnDef} (`key` names a row field) or
|
|
78
|
+
* a {@link DisplayColumnDef} (`id` + a required `render(row)`). A misspelled
|
|
79
|
+
* `key` is a type error; a display column's callbacks never receive a value.
|
|
80
|
+
*/
|
|
81
|
+
export type ColumnDef<T> = DataColumnDef<T> | DisplayColumnDef<T>;
|
|
48
82
|
export interface PaginationConfig {
|
|
49
83
|
/** Current page (1-based) */
|
|
50
84
|
page: number;
|
|
@@ -66,8 +100,26 @@ export interface TableClasses {
|
|
|
66
100
|
emptyCell: string;
|
|
67
101
|
paginator: string;
|
|
68
102
|
pageButton: string;
|
|
103
|
+
/** Rows that react to `onRowClick`. */
|
|
104
|
+
rowClickable: string;
|
|
105
|
+
/** Rows whose key is in the selection. */
|
|
106
|
+
rowSelected: string;
|
|
107
|
+
/** The leading checkbox cell of each row (`selectable`). */
|
|
108
|
+
selectCell: string;
|
|
109
|
+
/** The select-all header cell (`selectable`). */
|
|
110
|
+
selectHeaderCell: string;
|
|
111
|
+
/** Bar above the table shown while rows are selected. */
|
|
112
|
+
bulkBar: string;
|
|
113
|
+
/** "N selected" text in the bulk bar. */
|
|
114
|
+
bulkLabel: string;
|
|
115
|
+
/** "Clear" button in the bulk bar. */
|
|
116
|
+
bulkClear: string;
|
|
117
|
+
/** Slot holding `bulkActions` in the bulk bar. */
|
|
118
|
+
bulkActions: string;
|
|
119
|
+
/** Skeleton rows rendered while `loading` with no data. */
|
|
120
|
+
loadingRow: string;
|
|
69
121
|
}
|
|
70
|
-
export interface TableProps<T extends
|
|
122
|
+
export interface TableProps<T extends object> {
|
|
71
123
|
/** Row data. */
|
|
72
124
|
data: T[];
|
|
73
125
|
/** Column definitions. */
|
|
@@ -125,6 +177,57 @@ export interface TableProps<T extends Record<string, unknown>> {
|
|
|
125
177
|
emptyMessage?: ReactNode;
|
|
126
178
|
/** When provided, renders a paginator below the table. */
|
|
127
179
|
pagination?: PaginationConfig;
|
|
180
|
+
/**
|
|
181
|
+
* Show a loading overlay over the rows (they stay mounted and keep their
|
|
182
|
+
* height, so the page doesn't jump on refetch). With no `data` yet, renders
|
|
183
|
+
* `loadingRows` skeleton rows instead of `emptyMessage`. Sets `aria-busy`.
|
|
184
|
+
* @default false
|
|
185
|
+
*/
|
|
186
|
+
loading?: boolean;
|
|
187
|
+
/** Skeleton rows rendered while `loading` and `data` is empty. @default 3 */
|
|
188
|
+
loadingRows?: number;
|
|
189
|
+
/**
|
|
190
|
+
* Makes rows clickable: pointer cursor, hover highlight, `tabIndex=0` and
|
|
191
|
+
* Enter / Space activation. Clicks that originate from an interactive
|
|
192
|
+
* element inside the row (button, link, input, checkbox…) are ignored, so
|
|
193
|
+
* per-row action buttons keep working.
|
|
194
|
+
*/
|
|
195
|
+
onRowClick?: (row: T, index: number, event: MouseEvent<HTMLTableRowElement>) => void;
|
|
196
|
+
/**
|
|
197
|
+
* Adds a leading checkbox column with a select-all header. Selection keys
|
|
198
|
+
* come from `rowKey` (set it — without it the row index is used, which
|
|
199
|
+
* breaks across pages and sorts). Shift-click selects a range.
|
|
200
|
+
* @default false
|
|
201
|
+
*/
|
|
202
|
+
selectable?: boolean;
|
|
203
|
+
/** Controlled selection (row keys). Pair with `onSelectionChange`. */
|
|
204
|
+
selectedKeys?: TableRowKey[];
|
|
205
|
+
/** Initial selection for the uncontrolled case. @default [] */
|
|
206
|
+
defaultSelectedKeys?: TableRowKey[];
|
|
207
|
+
/** Fires with the next selection and the matching rows from `data`. */
|
|
208
|
+
onSelectionChange?: (keys: TableRowKey[], rows: T[]) => void;
|
|
209
|
+
/** Return `false` to disable the checkbox for a row. */
|
|
210
|
+
isRowSelectable?: (row: T) => boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Rendered in a bar above the table while something is selected, next to
|
|
213
|
+
* the "N selected" label and a "Clear" button. A function receives
|
|
214
|
+
* `{ selectedKeys, selectedRows, clear }`.
|
|
215
|
+
*/
|
|
216
|
+
bulkActions?: ReactNode | ((ctx: TableBulkActionsContext<T>) => ReactNode);
|
|
217
|
+
/** Text for the bulk bar. @default (n) => `${n} selected` */
|
|
218
|
+
selectionLabel?: (count: number) => ReactNode;
|
|
219
|
+
/**
|
|
220
|
+
* Hide columns by key without filtering `columns` (so sort config and
|
|
221
|
+
* widths stay stable): `{ email: false }` hides the `email` column; keys
|
|
222
|
+
* that are missing or `true` stay visible. Build the picker yourself
|
|
223
|
+
* (`CheckboxGroup`, or `DropdownItem checked`).
|
|
224
|
+
*/
|
|
225
|
+
columnVisibility?: Record<string, boolean>;
|
|
226
|
+
/**
|
|
227
|
+
* `'fixed'` sets `table-layout: fixed` so live-updating cell content never
|
|
228
|
+
* reflows column widths (give columns a `width`). @default 'auto'
|
|
229
|
+
*/
|
|
230
|
+
layout?: 'auto' | 'fixed';
|
|
128
231
|
/** Override class names on internal elements. */
|
|
129
232
|
classes?: Partial<TableClasses>;
|
|
130
233
|
}
|
|
@@ -146,7 +249,27 @@ export interface TableProps<T extends Record<string, unknown>> {
|
|
|
146
249
|
* `sticky: true` on the first column pins it to the left edge. Per-cell
|
|
147
250
|
* styling (e.g. value-bucket shading) via `cellClassName`/`cellStyle` on
|
|
148
251
|
* the column.
|
|
252
|
+
*
|
|
253
|
+
* **Loading**: `loading` overlays the rows without changing their height
|
|
254
|
+
* (skeleton rows when there is no data yet). **Clickable rows**:
|
|
255
|
+
* `onRowClick`. **Selection**: `selectable` + `rowKey` (+ `selectedKeys` /
|
|
256
|
+
* `onSelectionChange` to control it) with a select-all header, shift-range
|
|
257
|
+
* and a `bulkActions` bar. **Column visibility**: `columnVisibility` map.
|
|
258
|
+
* `layout="fixed"` stops live cell updates from reflowing column widths.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* <Table
|
|
262
|
+
* data={users}
|
|
263
|
+
* columns={columns}
|
|
264
|
+
* rowKey="id"
|
|
265
|
+
* loading={isFetching}
|
|
266
|
+
* onRowClick={(user) => navigate(`/users/${user.id}`)}
|
|
267
|
+
* selectable
|
|
268
|
+
* bulkActions={({ selectedRows, clear }) => (
|
|
269
|
+
* <Button size="sm" variant="danger" onClick={() => { archive(selectedRows); clear(); }}>Archive</Button>
|
|
270
|
+
* )}
|
|
271
|
+
* />
|
|
149
272
|
*/
|
|
150
|
-
declare function TableInner<T extends
|
|
273
|
+
declare function TableInner<T extends object>({ data, columns, sortConfig: controlledSortConfig, onSort, multiSort, scrollable, dragScroll, striped, hoverable, compact, className, style, rowKey, rowClassName, rowStyle, emptyMessage, pagination, loading, loadingRows, onRowClick, selectable, selectedKeys: controlledSelectedKeys, defaultSelectedKeys, onSelectionChange, isRowSelectable, bulkActions, selectionLabel, columnVisibility, layout, classes, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
151
274
|
export declare const Table: typeof TableInner;
|
|
152
275
|
export {};
|