@overdoser/react-toolkit 0.18.0 → 0.19.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.
Files changed (156) hide show
  1. package/AGENTS.md +51 -7
  2. package/CHANGELOG.md +129 -0
  3. package/components/Accordion/Accordion.d.ts +94 -0
  4. package/components/Accordion/Accordion.js +180 -0
  5. package/components/Accordion/Accordion.module.scss.js +36 -0
  6. package/components/Accordion/index.d.ts +2 -0
  7. package/components/Alert/Alert.d.ts +29 -1
  8. package/components/Alert/Alert.js +44 -30
  9. package/components/Alert/Alert.module.scss.js +24 -16
  10. package/components/Alert/index.d.ts +1 -1
  11. package/components/Card/Card.d.ts +86 -0
  12. package/components/Card/Card.js +132 -0
  13. package/components/Card/Card.module.scss.js +60 -0
  14. package/components/Card/index.d.ts +2 -0
  15. package/components/Chip/Chip.d.ts +86 -0
  16. package/components/Chip/Chip.js +141 -0
  17. package/components/Chip/Chip.module.scss.js +59 -0
  18. package/components/Chip/index.d.ts +2 -0
  19. package/components/CodeBlock/CodeBlock.d.ts +78 -0
  20. package/components/CodeBlock/CodeBlock.js +120 -0
  21. package/components/CodeBlock/CodeBlock.module.scss.js +43 -0
  22. package/components/CodeBlock/index.d.ts +2 -0
  23. package/components/CommandPalette/CommandPalette.d.ts +141 -0
  24. package/components/CommandPalette/CommandPalette.js +397 -0
  25. package/components/CommandPalette/CommandPalette.module.scss.js +49 -0
  26. package/components/CommandPalette/index.d.ts +2 -0
  27. package/components/ConfirmDialog/ConfirmDialog.d.ts +119 -0
  28. package/components/ConfirmDialog/ConfirmDialog.js +201 -0
  29. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +21 -0
  30. package/components/ConfirmDialog/index.d.ts +2 -0
  31. package/components/Drawer/Drawer.d.ts +1 -0
  32. package/components/Drawer/Drawer.js +35 -36
  33. package/components/Drawer/Drawer.module.scss.js +20 -18
  34. package/components/Dropdown/Dropdown.d.ts +47 -7
  35. package/components/Dropdown/Dropdown.js +174 -81
  36. package/components/Dropdown/Dropdown.module.scss.js +40 -22
  37. package/components/Dropdown/DropdownItem.d.ts +31 -2
  38. package/components/Dropdown/DropdownItem.js +54 -27
  39. package/components/Dropdown/DropdownLabel.d.ts +11 -0
  40. package/components/Dropdown/DropdownLabel.js +11 -0
  41. package/components/Dropdown/DropdownSeparator.d.ts +12 -0
  42. package/components/Dropdown/DropdownSeparator.js +11 -0
  43. package/components/Dropdown/dropdownContext.d.ts +6 -0
  44. package/components/Dropdown/dropdownContext.js +5 -0
  45. package/components/Dropdown/index.d.ts +8 -2
  46. package/components/Dropdown/useContextMenu.d.ts +32 -0
  47. package/components/Dropdown/useContextMenu.js +18 -0
  48. package/components/EmptyState/EmptyState.d.ts +53 -0
  49. package/components/EmptyState/EmptyState.js +55 -0
  50. package/components/EmptyState/EmptyState.module.scss.js +25 -0
  51. package/components/EmptyState/index.d.ts +2 -0
  52. package/components/Form/FormField.js +25 -24
  53. package/components/ImageViewer/ImageViewer.d.ts +105 -0
  54. package/components/ImageViewer/ImageViewer.js +201 -0
  55. package/components/ImageViewer/ImageViewer.module.scss.js +47 -0
  56. package/components/ImageViewer/index.d.ts +4 -0
  57. package/components/ImageViewer/useZoomPan.d.ts +94 -0
  58. package/components/ImageViewer/useZoomPan.js +141 -0
  59. package/components/Kbd/Kbd.d.ts +26 -0
  60. package/components/Kbd/Kbd.js +22 -0
  61. package/components/Kbd/Kbd.module.scss.js +17 -0
  62. package/components/Kbd/index.d.ts +2 -0
  63. package/components/KeyValueList/KeyValueList.d.ts +84 -0
  64. package/components/KeyValueList/KeyValueList.js +127 -0
  65. package/components/KeyValueList/KeyValueList.module.scss.js +43 -0
  66. package/components/KeyValueList/index.d.ts +2 -0
  67. package/components/Modal/Modal.d.ts +1 -0
  68. package/components/Modal/Modal.js +40 -41
  69. package/components/Modal/Modal.module.scss.js +18 -16
  70. package/components/PageHeader/PageHeader.d.ts +61 -0
  71. package/components/PageHeader/PageHeader.js +73 -0
  72. package/components/PageHeader/PageHeader.module.scss.js +43 -0
  73. package/components/PageHeader/index.d.ts +2 -0
  74. package/components/ProgressBar/ProgressBar.d.ts +74 -0
  75. package/components/ProgressBar/ProgressBar.js +90 -0
  76. package/components/ProgressBar/ProgressBar.module.scss.js +51 -0
  77. package/components/ProgressBar/index.d.ts +2 -0
  78. package/components/RelativeTime/RelativeTime.d.ts +45 -0
  79. package/components/RelativeTime/RelativeTime.js +43 -0
  80. package/components/RelativeTime/RelativeTime.module.scss.js +7 -0
  81. package/components/RelativeTime/index.d.ts +2 -0
  82. package/components/SegmentedControl/SegmentedControl.d.ts +84 -0
  83. package/components/SegmentedControl/SegmentedControl.js +131 -0
  84. package/components/SegmentedControl/SegmentedControl.module.scss.js +39 -0
  85. package/components/SegmentedControl/index.d.ts +2 -0
  86. package/components/SplitPane/SplitPane.d.ts +61 -0
  87. package/components/SplitPane/SplitPane.js +171 -0
  88. package/components/SplitPane/SplitPane.module.scss.js +25 -0
  89. package/components/SplitPane/index.d.ts +2 -0
  90. package/components/StatCard/StatCard.d.ts +105 -0
  91. package/components/StatCard/StatCard.js +127 -0
  92. package/components/StatCard/StatCard.module.scss.js +72 -0
  93. package/components/StatCard/index.d.ts +2 -0
  94. package/components/StatusDot/StatusDot.d.ts +33 -0
  95. package/components/StatusDot/StatusDot.js +39 -0
  96. package/components/StatusDot/StatusDot.module.scss.js +32 -0
  97. package/components/StatusDot/index.d.ts +2 -0
  98. package/components/Table/Table.d.ts +100 -2
  99. package/components/Table/Table.js +371 -210
  100. package/components/Table/Table.module.scss.js +68 -46
  101. package/components/Table/index.d.ts +1 -1
  102. package/components/ThemeToggle/ThemeToggle.d.ts +38 -0
  103. package/components/ThemeToggle/ThemeToggle.js +97 -0
  104. package/components/ThemeToggle/ThemeToggle.module.scss.js +23 -0
  105. package/components/ThemeToggle/index.d.ts +2 -0
  106. package/components/inputs/Checkbox/Checkbox.d.ts +2 -0
  107. package/components/inputs/Checkbox/Checkbox.js +29 -28
  108. package/components/inputs/Checkbox/Checkbox.module.scss.js +8 -6
  109. package/components/inputs/Input/Input.d.ts +33 -1
  110. package/components/inputs/Input/Input.js +94 -35
  111. package/components/inputs/Input/Input.module.scss.js +14 -12
  112. package/components/inputs/Radio/Radio.d.ts +5 -4
  113. package/components/inputs/Radio/Radio.js +55 -50
  114. package/components/inputs/Radio/Radio.module.scss.js +12 -10
  115. package/components/inputs/SearchInput/SearchInput.d.ts +57 -0
  116. package/components/inputs/SearchInput/SearchInput.js +116 -0
  117. package/components/inputs/SearchInput/SearchInput.module.scss.js +13 -0
  118. package/components/inputs/SearchInput/index.d.ts +2 -0
  119. package/components/inputs/Select/Select.d.ts +52 -0
  120. package/components/inputs/Select/Select.js +494 -385
  121. package/components/inputs/Select/Select.module.scss.js +34 -30
  122. package/components/inputs/Switch/Switch.d.ts +15 -0
  123. package/components/inputs/Switch/Switch.js +8 -0
  124. package/components/inputs/Switch/index.d.ts +2 -0
  125. package/hooks/useDebouncedValue.d.ts +15 -0
  126. package/hooks/useDebouncedValue.js +15 -0
  127. package/hooks/useElementSize.d.ts +20 -0
  128. package/hooks/useElementSize.js +23 -0
  129. package/hooks/useKeyboard.d.ts +49 -5
  130. package/hooks/useKeyboard.js +66 -16
  131. package/hooks/useMediaQuery.d.ts +14 -0
  132. package/hooks/useMediaQuery.js +16 -0
  133. package/hooks/useNow.d.ts +14 -0
  134. package/hooks/useNow.js +35 -0
  135. package/hooks/usePersistedState.d.ts +30 -0
  136. package/hooks/usePersistedState.js +96 -0
  137. package/hooks/useResizable.d.ts +66 -0
  138. package/hooks/useResizable.js +105 -0
  139. package/hooks/useTheme.d.ts +33 -0
  140. package/hooks/useTheme.js +27 -0
  141. package/index.css +1 -1
  142. package/index.d.ts +58 -4
  143. package/index.js +208 -132
  144. package/index.layered.css +1 -1
  145. package/llms.txt +619 -25
  146. package/manifest.json +1739 -91
  147. package/package.json +1 -1
  148. package/recipes/confirm-modal.tsx +65 -53
  149. package/recipes/floating-copy-button.tsx +32 -28
  150. package/utils/formatBytes.d.ts +21 -0
  151. package/utils/formatBytes.js +14 -0
  152. package/utils/index.d.ts +6 -0
  153. package/utils/themeScript.d.ts +17 -0
  154. package/utils/themeScript.js +9 -0
  155. package/utils/timeAgo.d.ts +33 -0
  156. 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,2 @@
1
+ export { StatCard, StatGrid } from './StatCard';
2
+ export type { StatCardProps, StatCardClasses, StatCardDelta, StatCardTrend, StatCardTrendColor, StatCardVariant, StatGridProps, StatGridClasses, StatGridColumns, } from './StatCard';
@@ -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
+ };
@@ -0,0 +1,2 @@
1
+ export { StatusDot } from './StatusDot';
2
+ export type { StatusDotProps, StatusDotClasses, StatusDotStatus } from './StatusDot';
@@ -1,5 +1,14 @@
1
- import { ReactNode } from 'react';
1
+ import { MouseEvent, ReactNode } from 'react';
2
2
  import { SortConfig } from './useTableSort';
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
+ }
3
12
  export interface ColumnDef<T> {
4
13
  /** Object key on each row to read the cell value from. */
5
14
  key: keyof T & string;
@@ -66,6 +75,24 @@ export interface TableClasses {
66
75
  emptyCell: string;
67
76
  paginator: string;
68
77
  pageButton: string;
78
+ /** Rows that react to `onRowClick`. */
79
+ rowClickable: string;
80
+ /** Rows whose key is in the selection. */
81
+ rowSelected: string;
82
+ /** The leading checkbox cell of each row (`selectable`). */
83
+ selectCell: string;
84
+ /** The select-all header cell (`selectable`). */
85
+ selectHeaderCell: string;
86
+ /** Bar above the table shown while rows are selected. */
87
+ bulkBar: string;
88
+ /** "N selected" text in the bulk bar. */
89
+ bulkLabel: string;
90
+ /** "Clear" button in the bulk bar. */
91
+ bulkClear: string;
92
+ /** Slot holding `bulkActions` in the bulk bar. */
93
+ bulkActions: string;
94
+ /** Skeleton rows rendered while `loading` with no data. */
95
+ loadingRow: string;
69
96
  }
70
97
  export interface TableProps<T extends Record<string, unknown>> {
71
98
  /** Row data. */
@@ -125,6 +152,57 @@ export interface TableProps<T extends Record<string, unknown>> {
125
152
  emptyMessage?: ReactNode;
126
153
  /** When provided, renders a paginator below the table. */
127
154
  pagination?: PaginationConfig;
155
+ /**
156
+ * Show a loading overlay over the rows (they stay mounted and keep their
157
+ * height, so the page doesn't jump on refetch). With no `data` yet, renders
158
+ * `loadingRows` skeleton rows instead of `emptyMessage`. Sets `aria-busy`.
159
+ * @default false
160
+ */
161
+ loading?: boolean;
162
+ /** Skeleton rows rendered while `loading` and `data` is empty. @default 3 */
163
+ loadingRows?: number;
164
+ /**
165
+ * Makes rows clickable: pointer cursor, hover highlight, `tabIndex=0` and
166
+ * Enter / Space activation. Clicks that originate from an interactive
167
+ * element inside the row (button, link, input, checkbox…) are ignored, so
168
+ * per-row action buttons keep working.
169
+ */
170
+ onRowClick?: (row: T, index: number, event: MouseEvent<HTMLTableRowElement>) => void;
171
+ /**
172
+ * Adds a leading checkbox column with a select-all header. Selection keys
173
+ * come from `rowKey` (set it — without it the row index is used, which
174
+ * breaks across pages and sorts). Shift-click selects a range.
175
+ * @default false
176
+ */
177
+ selectable?: boolean;
178
+ /** Controlled selection (row keys). Pair with `onSelectionChange`. */
179
+ selectedKeys?: TableRowKey[];
180
+ /** Initial selection for the uncontrolled case. @default [] */
181
+ defaultSelectedKeys?: TableRowKey[];
182
+ /** Fires with the next selection and the matching rows from `data`. */
183
+ onSelectionChange?: (keys: TableRowKey[], rows: T[]) => void;
184
+ /** Return `false` to disable the checkbox for a row. */
185
+ isRowSelectable?: (row: T) => boolean;
186
+ /**
187
+ * Rendered in a bar above the table while something is selected, next to
188
+ * the "N selected" label and a "Clear" button. A function receives
189
+ * `{ selectedKeys, selectedRows, clear }`.
190
+ */
191
+ bulkActions?: ReactNode | ((ctx: TableBulkActionsContext<T>) => ReactNode);
192
+ /** Text for the bulk bar. @default (n) => `${n} selected` */
193
+ selectionLabel?: (count: number) => ReactNode;
194
+ /**
195
+ * Hide columns by key without filtering `columns` (so sort config and
196
+ * widths stay stable): `{ email: false }` hides the `email` column; keys
197
+ * that are missing or `true` stay visible. Build the picker yourself
198
+ * (`CheckboxGroup`, or `DropdownItem checked`).
199
+ */
200
+ columnVisibility?: Record<string, boolean>;
201
+ /**
202
+ * `'fixed'` sets `table-layout: fixed` so live-updating cell content never
203
+ * reflows column widths (give columns a `width`). @default 'auto'
204
+ */
205
+ layout?: 'auto' | 'fixed';
128
206
  /** Override class names on internal elements. */
129
207
  classes?: Partial<TableClasses>;
130
208
  }
@@ -146,7 +224,27 @@ export interface TableProps<T extends Record<string, unknown>> {
146
224
  * `sticky: true` on the first column pins it to the left edge. Per-cell
147
225
  * styling (e.g. value-bucket shading) via `cellClassName`/`cellStyle` on
148
226
  * the column.
227
+ *
228
+ * **Loading**: `loading` overlays the rows without changing their height
229
+ * (skeleton rows when there is no data yet). **Clickable rows**:
230
+ * `onRowClick`. **Selection**: `selectable` + `rowKey` (+ `selectedKeys` /
231
+ * `onSelectionChange` to control it) with a select-all header, shift-range
232
+ * and a `bulkActions` bar. **Column visibility**: `columnVisibility` map.
233
+ * `layout="fixed"` stops live cell updates from reflowing column widths.
234
+ *
235
+ * @example
236
+ * <Table
237
+ * data={users}
238
+ * columns={columns}
239
+ * rowKey="id"
240
+ * loading={isFetching}
241
+ * onRowClick={(user) => navigate(`/users/${user.id}`)}
242
+ * selectable
243
+ * bulkActions={({ selectedRows, clear }) => (
244
+ * <Button size="sm" variant="danger" onClick={() => { archive(selectedRows); clear(); }}>Archive</Button>
245
+ * )}
246
+ * />
149
247
  */
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;
248
+ 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, loading, loadingRows, onRowClick, selectable, selectedKeys: controlledSelectedKeys, defaultSelectedKeys, onSelectionChange, isRowSelectable, bulkActions, selectionLabel, columnVisibility, layout, classes, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
151
249
  export declare const Table: typeof TableInner;
152
250
  export {};