@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.
- package/AGENTS.md +51 -7
- package/CHANGELOG.md +129 -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 +100 -2
- package/components/Table/Table.js +371 -210
- package/components/Table/Table.module.scss.js +68 -46
- package/components/Table/index.d.ts +1 -1
- package/components/ThemeToggle/ThemeToggle.d.ts +38 -0
- package/components/ThemeToggle/ThemeToggle.js +97 -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 +96 -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 +27 -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 +619 -25
- package/manifest.json +1739 -91
- 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 +17 -0
- package/utils/themeScript.js +9 -0
- package/utils/timeAgo.d.ts +33 -0
- package/utils/timeAgo.js +37 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as x, useMemo as I } from "react";
|
|
3
|
+
import u from "clsx";
|
|
4
|
+
import d from "./RelativeTime.module.scss.js";
|
|
5
|
+
import { useNow as R } from "../../hooks/useNow.js";
|
|
6
|
+
import { toTimestamp as b, timeAgo as E, refreshIntervalFor as L } from "../../utils/timeAgo.js";
|
|
7
|
+
const O = { dateStyle: "medium", timeStyle: "short" }, U = x(
|
|
8
|
+
({
|
|
9
|
+
value: r,
|
|
10
|
+
format: p = "long",
|
|
11
|
+
numeric: v = "auto",
|
|
12
|
+
locale: i,
|
|
13
|
+
live: T = !0,
|
|
14
|
+
now: o,
|
|
15
|
+
maxAge: h,
|
|
16
|
+
absoluteFormat: w = O,
|
|
17
|
+
title: e = !0,
|
|
18
|
+
fallback: A = "—",
|
|
19
|
+
classes: m,
|
|
20
|
+
className: n,
|
|
21
|
+
...s
|
|
22
|
+
}, a) => {
|
|
23
|
+
const t = I(() => b(r), [r]), l = Number.isFinite(t), D = t - (o ?? Date.now()), S = L(D), g = R(S, T && o === void 0 && l), y = o ?? g;
|
|
24
|
+
if (!l)
|
|
25
|
+
return /* @__PURE__ */ f("time", { ref: a, className: u(d.root, m?.root, n), ...s, children: A });
|
|
26
|
+
const F = new Date(t).toISOString(), c = new Intl.DateTimeFormat(i, w).format(t), N = E(t, { now: y, locale: i, format: p, numeric: v, maxAge: h });
|
|
27
|
+
return /* @__PURE__ */ f(
|
|
28
|
+
"time",
|
|
29
|
+
{
|
|
30
|
+
ref: a,
|
|
31
|
+
dateTime: F,
|
|
32
|
+
title: e === !1 ? void 0 : e === !0 ? c : e,
|
|
33
|
+
className: u(d.root, m?.root, n),
|
|
34
|
+
...s,
|
|
35
|
+
children: N ?? c
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
U.displayName = "RelativeTime";
|
|
41
|
+
export {
|
|
42
|
+
U as RelativeTime
|
|
43
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { CSSProperties, ReactElement, ReactNode, Ref } from 'react';
|
|
2
|
+
export interface SegmentedControlOption<T extends string = string> {
|
|
3
|
+
/** Value sent through `onChange`. */
|
|
4
|
+
value: T;
|
|
5
|
+
/** Visible text. Omit for an icon-only segment (then give `aria-label` or a string `tooltip`). */
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
/** Leading icon (hidden from assistive tech). */
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
/** Non-interactive when true. */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/** Tooltip shown on hover/focus. A string also labels an icon-only segment. */
|
|
12
|
+
tooltip?: ReactNode;
|
|
13
|
+
/** Small muted counter rendered after the label (e.g. result counts). */
|
|
14
|
+
count?: number | string;
|
|
15
|
+
/** Render the segment as a link. When any option has `href`, the control is a navigation group (see component docs). */
|
|
16
|
+
href?: string;
|
|
17
|
+
/** Accessible name for an icon-only segment. */
|
|
18
|
+
'aria-label'?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SegmentedControlClasses {
|
|
21
|
+
root: string;
|
|
22
|
+
item: string;
|
|
23
|
+
itemSelected: string;
|
|
24
|
+
icon: string;
|
|
25
|
+
label: string;
|
|
26
|
+
count: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SegmentedControlProps<T extends string = string> {
|
|
29
|
+
/** Segments to render. */
|
|
30
|
+
options: SegmentedControlOption<T>[];
|
|
31
|
+
/** Controlled selected value. */
|
|
32
|
+
value?: T;
|
|
33
|
+
/** Initial value when uncontrolled. */
|
|
34
|
+
defaultValue?: T;
|
|
35
|
+
/** Fires with the newly selected value. */
|
|
36
|
+
onChange?: (value: T) => void;
|
|
37
|
+
/** Segment size. @default 'md' */
|
|
38
|
+
size?: 'sm' | 'md' | 'lg';
|
|
39
|
+
/** Corner style of the track and segments. @default 'rounded' */
|
|
40
|
+
shape?: 'pill' | 'rounded' | 'square';
|
|
41
|
+
/**
|
|
42
|
+
* `'filled'`: grey track with a raised white selected segment (iOS/macOS style).
|
|
43
|
+
* `'outlined'`: joined bordered buttons; the selected one gets a primary tint.
|
|
44
|
+
* @default 'filled'
|
|
45
|
+
*/
|
|
46
|
+
variant?: 'filled' | 'outlined';
|
|
47
|
+
/** Stretch to the container width with equal-width segments. @default false */
|
|
48
|
+
fullWidth?: boolean;
|
|
49
|
+
/** Disables every segment. @default false */
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
/** Override class names on internal elements. */
|
|
52
|
+
classes?: Partial<SegmentedControlClasses>;
|
|
53
|
+
className?: string;
|
|
54
|
+
style?: CSSProperties;
|
|
55
|
+
id?: string;
|
|
56
|
+
/** Accessible label. Use this OR `aria-labelledby`. */
|
|
57
|
+
'aria-label'?: string;
|
|
58
|
+
'aria-labelledby'?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Single-select button group — the "pill tabs without panels" pattern for
|
|
62
|
+
* view switchers, filters and modes. Items are `role="radio"` buttons with a
|
|
63
|
+
* roving tabindex: Arrow keys move selection and focus (wrapping, skipping
|
|
64
|
+
* disabled segments), Home/End jump.
|
|
65
|
+
*
|
|
66
|
+
* When any option has `href`, the control becomes a navigation group: the root
|
|
67
|
+
* is `role="group"`, items are anchors and the selected one carries
|
|
68
|
+
* `aria-current="page"`.
|
|
69
|
+
*
|
|
70
|
+
* For multi-select chips use `CheckboxGroup variant="chips"`.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* <SegmentedControl
|
|
74
|
+
* aria-label="View"
|
|
75
|
+
* options={[{ value: 'list', label: 'List' }, { value: 'grid', label: 'Grid' }]}
|
|
76
|
+
* value={view}
|
|
77
|
+
* onChange={setView}
|
|
78
|
+
* />
|
|
79
|
+
*/
|
|
80
|
+
export declare const SegmentedControl: (<T extends string = string>(props: SegmentedControlProps<T> & {
|
|
81
|
+
ref?: Ref<HTMLDivElement>;
|
|
82
|
+
}) => ReactElement) & {
|
|
83
|
+
displayName?: string;
|
|
84
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx as t, jsxs as q, Fragment as z } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as B, useState as G, useRef as J, useCallback as Q } from "react";
|
|
3
|
+
import c from "clsx";
|
|
4
|
+
import a from "./SegmentedControl.module.scss.js";
|
|
5
|
+
import { Tooltip as V } from "../Tooltip/Tooltip.js";
|
|
6
|
+
function X({
|
|
7
|
+
options: m,
|
|
8
|
+
value: y,
|
|
9
|
+
defaultValue: R,
|
|
10
|
+
onChange: w,
|
|
11
|
+
size: A = "md",
|
|
12
|
+
shape: K = "rounded",
|
|
13
|
+
variant: T = "filled",
|
|
14
|
+
fullWidth: j = !1,
|
|
15
|
+
disabled: d = !1,
|
|
16
|
+
classes: i,
|
|
17
|
+
className: O,
|
|
18
|
+
style: E,
|
|
19
|
+
id: F,
|
|
20
|
+
"aria-label": H,
|
|
21
|
+
"aria-labelledby": L
|
|
22
|
+
}, M) {
|
|
23
|
+
const b = y !== void 0, [U, W] = G(R), s = b ? y : U, h = J(/* @__PURE__ */ new Map()), D = m.some((e) => e.href !== void 0), g = Q(
|
|
24
|
+
(e) => {
|
|
25
|
+
b || W(e), e !== s && w?.(e);
|
|
26
|
+
},
|
|
27
|
+
[b, s, w]
|
|
28
|
+
), l = m.filter((e) => !(d || e.disabled)), u = (e) => {
|
|
29
|
+
e && (g(e.value), h.current.get(e.value)?.focus());
|
|
30
|
+
}, k = (e, o) => {
|
|
31
|
+
if (l.length === 0) return;
|
|
32
|
+
const n = l.findIndex((v) => v.value === o.value);
|
|
33
|
+
switch (e.key) {
|
|
34
|
+
case "ArrowRight":
|
|
35
|
+
case "ArrowDown":
|
|
36
|
+
e.preventDefault(), u(l[(n + 1 + l.length) % l.length]);
|
|
37
|
+
break;
|
|
38
|
+
case "ArrowLeft":
|
|
39
|
+
case "ArrowUp":
|
|
40
|
+
e.preventDefault(), u(l[(n - 1 + l.length) % l.length]);
|
|
41
|
+
break;
|
|
42
|
+
case "Home":
|
|
43
|
+
e.preventDefault(), u(l[0]);
|
|
44
|
+
break;
|
|
45
|
+
case "End":
|
|
46
|
+
e.preventDefault(), u(l[l.length - 1]);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}, N = l.find((e) => e.value === s)?.value ?? l[0]?.value;
|
|
50
|
+
return /* @__PURE__ */ t(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
ref: M,
|
|
54
|
+
id: F,
|
|
55
|
+
role: D ? "group" : "radiogroup",
|
|
56
|
+
"aria-label": H,
|
|
57
|
+
"aria-labelledby": L,
|
|
58
|
+
"aria-disabled": d || void 0,
|
|
59
|
+
className: c(
|
|
60
|
+
a.root,
|
|
61
|
+
a[A],
|
|
62
|
+
a[K],
|
|
63
|
+
a[T],
|
|
64
|
+
j && a.fullWidth,
|
|
65
|
+
d && a.disabled,
|
|
66
|
+
i?.root,
|
|
67
|
+
O
|
|
68
|
+
),
|
|
69
|
+
style: E,
|
|
70
|
+
children: m.map((e) => {
|
|
71
|
+
const o = e.value === s, n = d || !!e.disabled, v = e.icon !== void 0 && e.label === void 0, p = typeof e.tooltip == "string" ? e.tooltip : void 0, x = e["aria-label"] ?? (v ? p : void 0), C = /* @__PURE__ */ q(z, { children: [
|
|
72
|
+
e.icon !== void 0 && /* @__PURE__ */ t("span", { className: c(a.icon, i?.icon), "aria-hidden": "true", children: e.icon }),
|
|
73
|
+
e.label !== void 0 && /* @__PURE__ */ t("span", { className: c(a.label, i?.label), children: e.label }),
|
|
74
|
+
e.count !== void 0 && /* @__PURE__ */ t("span", { className: c(a.count, i?.count), children: e.count })
|
|
75
|
+
] }), S = c(
|
|
76
|
+
a.item,
|
|
77
|
+
o && a.itemSelected,
|
|
78
|
+
v && a.iconOnly,
|
|
79
|
+
i?.item,
|
|
80
|
+
o && i?.itemSelected
|
|
81
|
+
), I = (r) => {
|
|
82
|
+
r ? h.current.set(e.value, r) : h.current.delete(e.value);
|
|
83
|
+
};
|
|
84
|
+
let f;
|
|
85
|
+
return D ? f = /* @__PURE__ */ t(
|
|
86
|
+
"a",
|
|
87
|
+
{
|
|
88
|
+
ref: I,
|
|
89
|
+
href: n ? void 0 : e.href,
|
|
90
|
+
"aria-current": o ? "page" : void 0,
|
|
91
|
+
"aria-disabled": n || void 0,
|
|
92
|
+
"aria-label": x,
|
|
93
|
+
tabIndex: n ? -1 : e.value === N ? 0 : -1,
|
|
94
|
+
className: S,
|
|
95
|
+
onClick: (r) => {
|
|
96
|
+
if (n) {
|
|
97
|
+
r.preventDefault();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
g(e.value);
|
|
101
|
+
},
|
|
102
|
+
onKeyDown: (r) => k(r, e),
|
|
103
|
+
children: C
|
|
104
|
+
},
|
|
105
|
+
e.value
|
|
106
|
+
) : f = /* @__PURE__ */ t(
|
|
107
|
+
"button",
|
|
108
|
+
{
|
|
109
|
+
ref: I,
|
|
110
|
+
type: "button",
|
|
111
|
+
role: "radio",
|
|
112
|
+
"aria-checked": o,
|
|
113
|
+
"aria-label": x,
|
|
114
|
+
disabled: n,
|
|
115
|
+
tabIndex: e.value === N ? 0 : -1,
|
|
116
|
+
className: S,
|
|
117
|
+
onClick: () => g(e.value),
|
|
118
|
+
onKeyDown: (r) => k(r, e),
|
|
119
|
+
children: C
|
|
120
|
+
},
|
|
121
|
+
e.value
|
|
122
|
+
), e.tooltip !== void 0 && e.tooltip !== null && e.tooltip !== "" ? /* @__PURE__ */ t(V, { content: e.tooltip, children: f }, e.value) : f;
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
const Y = B(X);
|
|
128
|
+
Y.displayName = "SegmentedControl";
|
|
129
|
+
export {
|
|
130
|
+
Y as SegmentedControl
|
|
131
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const c = "crk-root-ito0X", t = "crk-sm-P03Ce", o = "crk-md-my5y5", l = "crk-lg-C6A9b", n = "crk-pill-yWMHd", e = "crk-rounded-KQgE9", d = "crk-square-gChT2", s = "crk-fullWidth-ahjYN", r = "crk-item-n8hr3", i = "crk-iconOnly-wyO0n", k = "crk-icon-RUgES", u = "crk-label-urUg5", m = "crk-count-qh4-d", a = "crk-filled-THBvo", g = "crk-itemSelected-c3IgH", y = "crk-outlined-xC8GL", b = "crk-disabled-BzP8D", f = {
|
|
2
|
+
root: c,
|
|
3
|
+
sm: t,
|
|
4
|
+
md: o,
|
|
5
|
+
lg: l,
|
|
6
|
+
pill: n,
|
|
7
|
+
rounded: e,
|
|
8
|
+
square: d,
|
|
9
|
+
fullWidth: s,
|
|
10
|
+
item: r,
|
|
11
|
+
iconOnly: i,
|
|
12
|
+
icon: k,
|
|
13
|
+
label: u,
|
|
14
|
+
count: m,
|
|
15
|
+
filled: a,
|
|
16
|
+
itemSelected: g,
|
|
17
|
+
outlined: y,
|
|
18
|
+
disabled: b
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
m as count,
|
|
22
|
+
f as default,
|
|
23
|
+
b as disabled,
|
|
24
|
+
a as filled,
|
|
25
|
+
s as fullWidth,
|
|
26
|
+
k as icon,
|
|
27
|
+
i as iconOnly,
|
|
28
|
+
r as item,
|
|
29
|
+
g as itemSelected,
|
|
30
|
+
u as label,
|
|
31
|
+
l as lg,
|
|
32
|
+
o as md,
|
|
33
|
+
y as outlined,
|
|
34
|
+
n as pill,
|
|
35
|
+
c as root,
|
|
36
|
+
e as rounded,
|
|
37
|
+
t as sm,
|
|
38
|
+
d as square
|
|
39
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
export type SplitPaneDirection = 'horizontal' | 'vertical';
|
|
3
|
+
export interface SplitPaneClasses {
|
|
4
|
+
root: string;
|
|
5
|
+
pane: string;
|
|
6
|
+
primary: string;
|
|
7
|
+
secondary: string;
|
|
8
|
+
handle: string;
|
|
9
|
+
handleActive: string;
|
|
10
|
+
collapsed: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SplitPaneProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
|
|
13
|
+
/** Exactly two panes. */
|
|
14
|
+
children: [ReactNode, ReactNode];
|
|
15
|
+
/** `'horizontal'` = side by side (resize width), `'vertical'` = stacked (resize height). @default 'horizontal' */
|
|
16
|
+
direction?: SplitPaneDirection;
|
|
17
|
+
/** Which pane `size` applies to; the other one flexes. @default 'first' */
|
|
18
|
+
primary?: 'first' | 'second';
|
|
19
|
+
/** Controlled primary size: px number, or a CSS percentage/px string (`'30%'`, `'320px'`). */
|
|
20
|
+
size?: number | string;
|
|
21
|
+
/** Initial primary size when uncontrolled. A percentage keeps its ratio when the container resizes. @default '50%' */
|
|
22
|
+
defaultSize?: number | string;
|
|
23
|
+
/** Fires with the primary size in px after every drag/key/reset. */
|
|
24
|
+
onSizeChange?: (px: number) => void;
|
|
25
|
+
/** Minimum primary size (px). @default 100 */
|
|
26
|
+
minSize?: number;
|
|
27
|
+
/** Maximum primary size (px). @default container size − `minSecondarySize` − handle */
|
|
28
|
+
maxSize?: number;
|
|
29
|
+
/** Minimum size the flexing pane keeps (px); defines the default `maxSize`. @default 100 */
|
|
30
|
+
minSecondarySize?: number;
|
|
31
|
+
/** Dragging below `minSize / 2` or double-clicking the handle collapses the primary pane to 0. @default false */
|
|
32
|
+
collapsible?: boolean;
|
|
33
|
+
/** Controlled collapsed state (`collapsible` only). */
|
|
34
|
+
collapsed?: boolean;
|
|
35
|
+
/** Initial collapsed state when uncontrolled. @default false */
|
|
36
|
+
defaultCollapsed?: boolean;
|
|
37
|
+
/** Fires when the user collapses/expands via the handle. */
|
|
38
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
39
|
+
/** Persist size (px) and collapsed state under this key (localStorage, via `usePersistedState`). */
|
|
40
|
+
persistKey?: string;
|
|
41
|
+
/** Handle hit area in px; the visible line is 1px and widens on hover/drag. @default 6 */
|
|
42
|
+
handleSize?: number;
|
|
43
|
+
/** Accessible label of the handle. @default 'Resize' */
|
|
44
|
+
handleLabel?: string;
|
|
45
|
+
/** Disable resizing (the handle stays as a static divider). @default false */
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
/** Override class names on internal elements. */
|
|
48
|
+
classes?: Partial<SplitPaneClasses>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Two panes with a draggable, keyboard-operable divider. The `primary` pane
|
|
52
|
+
* has the size; the other flexes. Supports px or % sizes, min/max clamps,
|
|
53
|
+
* collapsing, persistence, and horizontal or vertical stacking.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* <SplitPane defaultSize={280} minSize={200} persistKey="layout:sidebar" collapsible>
|
|
57
|
+
* <Sidebar />
|
|
58
|
+
* <Editor />
|
|
59
|
+
* </SplitPane>
|
|
60
|
+
*/
|
|
61
|
+
export declare const SplitPane: import('react').ForwardRefExoticComponent<Omit<SplitPaneProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -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,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>>;
|