@overdoser/react-toolkit 0.17.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 (160) hide show
  1. package/AGENTS.md +51 -7
  2. package/CHANGELOG.md +149 -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/Loader/Loader.d.ts +104 -0
  68. package/components/Loader/Loader.js +186 -0
  69. package/components/Loader/Loader.module.scss.js +70 -0
  70. package/components/Loader/index.d.ts +2 -0
  71. package/components/Modal/Modal.d.ts +1 -0
  72. package/components/Modal/Modal.js +40 -41
  73. package/components/Modal/Modal.module.scss.js +18 -16
  74. package/components/PageHeader/PageHeader.d.ts +61 -0
  75. package/components/PageHeader/PageHeader.js +73 -0
  76. package/components/PageHeader/PageHeader.module.scss.js +43 -0
  77. package/components/PageHeader/index.d.ts +2 -0
  78. package/components/ProgressBar/ProgressBar.d.ts +74 -0
  79. package/components/ProgressBar/ProgressBar.js +90 -0
  80. package/components/ProgressBar/ProgressBar.module.scss.js +51 -0
  81. package/components/ProgressBar/index.d.ts +2 -0
  82. package/components/RelativeTime/RelativeTime.d.ts +45 -0
  83. package/components/RelativeTime/RelativeTime.js +43 -0
  84. package/components/RelativeTime/RelativeTime.module.scss.js +7 -0
  85. package/components/RelativeTime/index.d.ts +2 -0
  86. package/components/SegmentedControl/SegmentedControl.d.ts +84 -0
  87. package/components/SegmentedControl/SegmentedControl.js +131 -0
  88. package/components/SegmentedControl/SegmentedControl.module.scss.js +39 -0
  89. package/components/SegmentedControl/index.d.ts +2 -0
  90. package/components/SplitPane/SplitPane.d.ts +61 -0
  91. package/components/SplitPane/SplitPane.js +171 -0
  92. package/components/SplitPane/SplitPane.module.scss.js +25 -0
  93. package/components/SplitPane/index.d.ts +2 -0
  94. package/components/StatCard/StatCard.d.ts +105 -0
  95. package/components/StatCard/StatCard.js +127 -0
  96. package/components/StatCard/StatCard.module.scss.js +72 -0
  97. package/components/StatCard/index.d.ts +2 -0
  98. package/components/StatusDot/StatusDot.d.ts +33 -0
  99. package/components/StatusDot/StatusDot.js +39 -0
  100. package/components/StatusDot/StatusDot.module.scss.js +32 -0
  101. package/components/StatusDot/index.d.ts +2 -0
  102. package/components/Table/Table.d.ts +100 -2
  103. package/components/Table/Table.js +371 -210
  104. package/components/Table/Table.module.scss.js +68 -46
  105. package/components/Table/index.d.ts +1 -1
  106. package/components/ThemeToggle/ThemeToggle.d.ts +38 -0
  107. package/components/ThemeToggle/ThemeToggle.js +97 -0
  108. package/components/ThemeToggle/ThemeToggle.module.scss.js +23 -0
  109. package/components/ThemeToggle/index.d.ts +2 -0
  110. package/components/inputs/Checkbox/Checkbox.d.ts +2 -0
  111. package/components/inputs/Checkbox/Checkbox.js +29 -28
  112. package/components/inputs/Checkbox/Checkbox.module.scss.js +8 -6
  113. package/components/inputs/Input/Input.d.ts +33 -1
  114. package/components/inputs/Input/Input.js +94 -35
  115. package/components/inputs/Input/Input.module.scss.js +14 -12
  116. package/components/inputs/Radio/Radio.d.ts +5 -4
  117. package/components/inputs/Radio/Radio.js +55 -50
  118. package/components/inputs/Radio/Radio.module.scss.js +12 -10
  119. package/components/inputs/SearchInput/SearchInput.d.ts +57 -0
  120. package/components/inputs/SearchInput/SearchInput.js +116 -0
  121. package/components/inputs/SearchInput/SearchInput.module.scss.js +13 -0
  122. package/components/inputs/SearchInput/index.d.ts +2 -0
  123. package/components/inputs/Select/Select.d.ts +52 -0
  124. package/components/inputs/Select/Select.js +494 -385
  125. package/components/inputs/Select/Select.module.scss.js +34 -30
  126. package/components/inputs/Switch/Switch.d.ts +15 -0
  127. package/components/inputs/Switch/Switch.js +8 -0
  128. package/components/inputs/Switch/index.d.ts +2 -0
  129. package/hooks/useDebouncedValue.d.ts +15 -0
  130. package/hooks/useDebouncedValue.js +15 -0
  131. package/hooks/useElementSize.d.ts +20 -0
  132. package/hooks/useElementSize.js +23 -0
  133. package/hooks/useKeyboard.d.ts +49 -5
  134. package/hooks/useKeyboard.js +66 -16
  135. package/hooks/useMediaQuery.d.ts +14 -0
  136. package/hooks/useMediaQuery.js +16 -0
  137. package/hooks/useNow.d.ts +14 -0
  138. package/hooks/useNow.js +35 -0
  139. package/hooks/usePersistedState.d.ts +30 -0
  140. package/hooks/usePersistedState.js +96 -0
  141. package/hooks/useResizable.d.ts +66 -0
  142. package/hooks/useResizable.js +105 -0
  143. package/hooks/useTheme.d.ts +33 -0
  144. package/hooks/useTheme.js +27 -0
  145. package/index.css +1 -1
  146. package/index.d.ts +60 -4
  147. package/index.js +208 -130
  148. package/index.layered.css +1 -1
  149. package/llms.txt +659 -25
  150. package/manifest.json +1797 -76
  151. package/package.json +1 -1
  152. package/recipes/confirm-modal.tsx +65 -53
  153. package/recipes/floating-copy-button.tsx +32 -28
  154. package/utils/formatBytes.d.ts +21 -0
  155. package/utils/formatBytes.js +14 -0
  156. package/utils/index.d.ts +6 -0
  157. package/utils/themeScript.d.ts +17 -0
  158. package/utils/themeScript.js +9 -0
  159. package/utils/timeAgo.d.ts +33 -0
  160. package/utils/timeAgo.js +37 -0
@@ -0,0 +1,171 @@
1
+ import { jsx as O, jsxs as ft } from "react/jsx-runtime";
2
+ import { forwardRef as mt, useRef as T, useImperativeHandle as xt, useState as C, useLayoutEffect as U, useCallback as P, useMemo as vt, useEffect as ht } from "react";
3
+ import _ from "clsx";
4
+ import e from "./SplitPane.module.scss.js";
5
+ import { useResizable as yt } from "../../hooks/useResizable.js";
6
+ import { usePersistedState as Rt } from "../../hooks/usePersistedState.js";
7
+ function V(s, p) {
8
+ if (s === void 0) return { px: null, ratio: null };
9
+ if (typeof s == "number") return { px: s, ratio: null };
10
+ const c = s.trim();
11
+ if (c.endsWith("%")) {
12
+ const d = parseFloat(c) / 100;
13
+ return { px: p > 0 ? d * p : null, ratio: Number.isFinite(d) ? d : null };
14
+ }
15
+ const f = parseFloat(c);
16
+ return { px: Number.isFinite(f) ? f : null, ratio: null };
17
+ }
18
+ const wt = "__crk-splitpane-unpersisted__", zt = mt(
19
+ ({
20
+ children: s,
21
+ direction: p = "horizontal",
22
+ primary: c = "first",
23
+ size: f,
24
+ defaultSize: d = "50%",
25
+ onSizeChange: X,
26
+ minSize: m = 100,
27
+ maxSize: g,
28
+ minSecondarySize: A = 100,
29
+ collapsible: z = !1,
30
+ collapsed: k,
31
+ defaultCollapsed: Z = !1,
32
+ onCollapsedChange: D,
33
+ persistKey: l,
34
+ handleSize: F = 6,
35
+ handleLabel: S = "Resize",
36
+ disabled: x = !1,
37
+ classes: o,
38
+ className: K,
39
+ style: tt,
40
+ ...et
41
+ }, nt) => {
42
+ const I = T(null);
43
+ xt(nt, () => I.current);
44
+ const v = p === "horizontal", [i, rt] = C(0);
45
+ U(() => {
46
+ const t = I.current;
47
+ if (!t) return;
48
+ const u = () => {
49
+ const G = t.getBoundingClientRect(), J = v ? G.width : G.height;
50
+ rt((Q) => Q === J ? Q : J);
51
+ };
52
+ if (u(), typeof ResizeObserver > "u") return;
53
+ const q = new ResizeObserver(u);
54
+ return q.observe(t), () => q.disconnect();
55
+ }, [v]);
56
+ const [h, $] = Rt(l ?? wt, {}, { sync: !!l }), E = P(
57
+ (t) => {
58
+ l && $((u) => ({ ...u, ...t }));
59
+ },
60
+ [l, $]
61
+ ), y = vt(() => V(d, 0), [d]), [R, j] = C(
62
+ () => l && h.px !== void 0 ? null : y.ratio
63
+ ), [ot, B] = C(
64
+ () => l && h.px !== void 0 ? h.px : y.px ?? 0
65
+ );
66
+ U(() => {
67
+ R !== null && i > 0 && B(R * i);
68
+ }, [R, i]);
69
+ const n = f !== void 0 ? V(f, i) : null, H = n ? n.px ?? 0 : ot, [it, at] = C(
70
+ () => l && h.collapsed !== void 0 ? h.collapsed : Z
71
+ ), a = z && (k ?? it), N = P(
72
+ (t) => {
73
+ k === void 0 && at(t), D?.(t), E({ collapsed: t });
74
+ },
75
+ [k, D, E]
76
+ ), L = P(() => g !== void 0 ? g : i > 0 ? Math.max(m, i - A - F) : 1 / 0, [g, i, m, A, F]), b = i > 0 ? Math.min(Math.max(H, m), L()) : H, M = T(b), w = yt({
77
+ size: b,
78
+ defaultSize: y.px ?? (y.ratio !== null && i > 0 ? y.ratio * i : b),
79
+ min: m,
80
+ max: L,
81
+ axis: v ? "x" : "y",
82
+ invert: c === "second",
83
+ disabled: x,
84
+ onResizeStart: () => {
85
+ a && N(!1);
86
+ },
87
+ onResize: (t, u) => {
88
+ M.current = u, n || (j(null), B(t)), X?.(t);
89
+ },
90
+ onResizeEnd: (t) => {
91
+ if (z && M.current < m / 2) {
92
+ N(!0), M.current = t;
93
+ return;
94
+ }
95
+ E({ px: t });
96
+ }
97
+ }), st = P(() => {
98
+ x || (z ? N(!a) : w.reset());
99
+ }, [x, z, a, N, w]);
100
+ ht(() => {
101
+ n?.ratio !== null && n?.ratio !== void 0 && j(n.ratio);
102
+ }, [n?.ratio]);
103
+ const lt = a ? 0 : n && n.px === null && n.ratio !== null ? `${n.ratio * 100}%` : !n && R !== null && i === 0 ? `${R * 100}%` : b, W = { [v ? "width" : "height"]: lt, flex: "0 0 auto" }, ct = s[0], dt = s[1], r = c === "first", ut = /* @__PURE__ */ O(
104
+ "div",
105
+ {
106
+ className: _(
107
+ e.pane,
108
+ r ? e.primary : e.secondary,
109
+ r && a && e.collapsed,
110
+ o?.pane,
111
+ r ? o?.primary : o?.secondary,
112
+ r && a && o?.collapsed
113
+ ),
114
+ style: r ? W : void 0,
115
+ "data-pane": r ? "primary" : "secondary",
116
+ children: ct
117
+ }
118
+ ), pt = /* @__PURE__ */ O(
119
+ "div",
120
+ {
121
+ className: _(
122
+ e.pane,
123
+ r ? e.secondary : e.primary,
124
+ !r && a && e.collapsed,
125
+ o?.pane,
126
+ r ? o?.secondary : o?.primary,
127
+ !r && a && o?.collapsed
128
+ ),
129
+ style: r ? void 0 : W,
130
+ "data-pane": r ? "secondary" : "primary",
131
+ children: dt
132
+ }
133
+ ), { onDoubleClick: bt, ...Y } = w.handleProps;
134
+ return /* @__PURE__ */ ft(
135
+ "div",
136
+ {
137
+ ref: I,
138
+ className: _(e.root, v ? e.horizontal : e.vertical, o?.root, K),
139
+ style: { ...tt, "--crk-splitpane-handle-size": `${F}px` },
140
+ "data-direction": p,
141
+ ...et,
142
+ children: [
143
+ ut,
144
+ /* @__PURE__ */ O(
145
+ "div",
146
+ {
147
+ ...Y,
148
+ onDoubleClick: st,
149
+ "aria-label": S,
150
+ "aria-valuenow": a ? 0 : Y["aria-valuenow"],
151
+ tabIndex: x ? -1 : 0,
152
+ className: _(
153
+ e.handle,
154
+ w.isResizing && e.handleActive,
155
+ x && e.handleDisabled,
156
+ o?.handle,
157
+ w.isResizing && o?.handleActive
158
+ ),
159
+ "data-collapsed": a || void 0
160
+ }
161
+ ),
162
+ pt
163
+ ]
164
+ }
165
+ );
166
+ }
167
+ );
168
+ zt.displayName = "SplitPane";
169
+ export {
170
+ zt as SplitPane
171
+ };
@@ -0,0 +1,25 @@
1
+ const c = "crk-root-4-LwZ", a = "crk-horizontal-zy9XG", e = "crk-vertical-K4r-5", o = "crk-pane-2kL-G", r = "crk-primary-uXbxW", n = "crk-secondary-Fq-4C", t = "crk-collapsed-DBz98", l = "crk-handle-dFfxM", s = "crk-handleActive-jc42L", d = "crk-handleDisabled-CEtI-", i = {
2
+ root: c,
3
+ horizontal: a,
4
+ vertical: e,
5
+ pane: o,
6
+ primary: r,
7
+ secondary: n,
8
+ collapsed: t,
9
+ handle: l,
10
+ handleActive: s,
11
+ handleDisabled: d
12
+ };
13
+ export {
14
+ t as collapsed,
15
+ i as default,
16
+ l as handle,
17
+ s as handleActive,
18
+ d as handleDisabled,
19
+ a as horizontal,
20
+ o as pane,
21
+ r as primary,
22
+ c as root,
23
+ n as secondary,
24
+ e as vertical
25
+ };
@@ -0,0 +1,2 @@
1
+ export { SplitPane } from './SplitPane';
2
+ export type { SplitPaneProps, SplitPaneClasses, SplitPaneDirection } from './SplitPane';
@@ -0,0 +1,105 @@
1
+ import { ComponentPropsWithRef, ReactNode } from 'react';
2
+ export type StatCardVariant = 'outlined' | 'elevated' | 'filled';
3
+ export type StatCardTrend = 'up' | 'down' | 'flat';
4
+ export type StatCardTrendColor = 'auto' | 'positive-up' | 'positive-down' | 'none';
5
+ export interface StatCardDelta {
6
+ /** Pre-formatted delta text ("+12.5%", "−3 pts"). */
7
+ value: ReactNode;
8
+ /** Direction; drives the arrow and the colour. @default 'flat' */
9
+ trend?: StatCardTrend;
10
+ }
11
+ export interface StatCardClasses {
12
+ root: string;
13
+ header: string;
14
+ label: string;
15
+ icon: string;
16
+ value: string;
17
+ unit: string;
18
+ delta: string;
19
+ deltaLabel: string;
20
+ chart: string;
21
+ footer: string;
22
+ }
23
+ export interface StatCardProps extends Omit<ComponentPropsWithRef<'div'>, 'title'> {
24
+ /** Small muted caption above the value ("Revenue", "Active users"). */
25
+ label: ReactNode;
26
+ /** The headline figure. Format it yourself (`Intl.NumberFormat`, currency…). */
27
+ value: ReactNode;
28
+ /** Suffix rendered after the value in a smaller size ("ms", "%", "users"). */
29
+ unit?: ReactNode;
30
+ /**
31
+ * Change versus a previous period. A number renders `▲ 12.5%` / `▼ 3%`
32
+ * with the trend inferred from its sign (formatted by `deltaFormat`);
33
+ * an object carries pre-formatted text and an explicit `trend`.
34
+ */
35
+ delta?: number | StatCardDelta;
36
+ /** Formats a numeric `delta`. @default n => `${Math.abs(n)}%` with at most one decimal */
37
+ deltaFormat?: (delta: number) => ReactNode;
38
+ /**
39
+ * Which direction is good. `'auto'`/`'positive-up'`: up = success, down =
40
+ * danger. `'positive-down'` for latency, cost, errors. `'none'` keeps the
41
+ * delta neutral. @default 'auto'
42
+ */
43
+ trendColor?: StatCardTrendColor;
44
+ /** Muted text after the delta ("vs last week"). */
45
+ deltaLabel?: ReactNode;
46
+ /** Top-right slot (an icon). */
47
+ icon?: ReactNode;
48
+ /** Bottom slot — pass a `<Sparkline data={…} />`. */
49
+ chart?: ReactNode;
50
+ /** Footer text/links below the chart. */
51
+ footer?: ReactNode;
52
+ /** Render as an anchor to this URL (whole tile is the link). */
53
+ href?: string;
54
+ /** Replaces value and delta with skeleton bars. @default false */
55
+ loading?: boolean;
56
+ /** Surface style. @default 'outlined' */
57
+ variant?: StatCardVariant;
58
+ /** Value size: xl / 2xl / 3xl. @default 'md' */
59
+ size?: 'sm' | 'md' | 'lg';
60
+ /** 3px left stripe in this CSS colour (`'var(--crk-color-success)'` works). */
61
+ accent?: string;
62
+ /** Override class names on internal elements. */
63
+ classes?: Partial<StatCardClasses>;
64
+ }
65
+ /**
66
+ * KPI tile: caption, headline value, optional delta with trend colouring,
67
+ * icon, sparkline slot and footer. Lay several out with `StatGrid`.
68
+ *
69
+ * @example
70
+ * <StatGrid>
71
+ * <StatCard label="Revenue" value="€48.2k" delta={12.5} deltaLabel="vs last month" />
72
+ * <StatCard label="p95 latency" value={412} unit="ms" delta={-8} trendColor="positive-down" />
73
+ * <StatCard label="Signups" value={1_204} chart={<Sparkline data={series} />} />
74
+ * </StatGrid>
75
+ */
76
+ export declare const StatCard: import('react').ForwardRefExoticComponent<Omit<StatCardProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
77
+ export interface StatGridColumns {
78
+ /** Columns below 640px. @default 1 */
79
+ sm?: number;
80
+ /** Columns from 640px. @default 2 */
81
+ md?: number;
82
+ /** Columns from 1024px. @default 4 */
83
+ lg?: number;
84
+ }
85
+ export interface StatGridClasses {
86
+ root: string;
87
+ }
88
+ export interface StatGridProps extends ComponentPropsWithRef<'div'> {
89
+ /**
90
+ * Column count — a number for every width, or per breakpoint
91
+ * (`sm` < 640px ≤ `md` < 1024px ≤ `lg`). @default { sm: 1, md: 2, lg: 4 }
92
+ */
93
+ columns?: number | StatGridColumns;
94
+ /** Gap between tiles. @default 'md' */
95
+ gap?: 'sm' | 'md' | 'lg';
96
+ /** Override class names on internal elements. */
97
+ classes?: Partial<StatGridClasses>;
98
+ }
99
+ /**
100
+ * Responsive grid for `StatCard` tiles (1 / 2 / 4 columns by default).
101
+ *
102
+ * @example
103
+ * <StatGrid columns={{ sm: 1, md: 3, lg: 3 }} gap="lg">…</StatGrid>
104
+ */
105
+ export declare const StatGrid: import('react').ForwardRefExoticComponent<Omit<StatGridProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
@@ -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';