@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.
- package/AGENTS.md +51 -7
- package/CHANGELOG.md +149 -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/Loader/Loader.d.ts +104 -0
- package/components/Loader/Loader.js +186 -0
- package/components/Loader/Loader.module.scss.js +70 -0
- package/components/Loader/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 +60 -4
- package/index.js +208 -130
- package/index.layered.css +1 -1
- package/llms.txt +659 -25
- package/manifest.json +1797 -76
- 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,74 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
export type ProgressBarVariant = 'primary' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
3
|
+
export interface ProgressBarThreshold {
|
|
4
|
+
/** Lower bound (inclusive) from which `variant` applies. */
|
|
5
|
+
value: number;
|
|
6
|
+
/** Fill colour used once the current value reaches `value`. */
|
|
7
|
+
variant: ProgressBarVariant;
|
|
8
|
+
}
|
|
9
|
+
export interface ProgressBarClasses {
|
|
10
|
+
root: string;
|
|
11
|
+
header: string;
|
|
12
|
+
label: string;
|
|
13
|
+
value: string;
|
|
14
|
+
track: string;
|
|
15
|
+
fill: string;
|
|
16
|
+
segment: string;
|
|
17
|
+
segmentFilled: string;
|
|
18
|
+
segmentCurrent: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ProgressBarProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
|
|
21
|
+
/**
|
|
22
|
+
* Current value, clamped to `[0, max]`. Omit it for an indeterminate bar
|
|
23
|
+
* (sliding shimmer; fades in place under `prefers-reduced-motion`).
|
|
24
|
+
*/
|
|
25
|
+
value?: number;
|
|
26
|
+
/** Upper bound of `value`. @default 100 */
|
|
27
|
+
max?: number;
|
|
28
|
+
/** Text shown above the bar, on the left. A string label also becomes the track's `aria-label`. */
|
|
29
|
+
label?: ReactNode;
|
|
30
|
+
/** Show the formatted value above the bar, on the right. Ignored when indeterminate. @default false */
|
|
31
|
+
showValue?: boolean;
|
|
32
|
+
/** Formats the text rendered by `showValue`. @default (v, max) => `${Math.round(v / max * 100)}%` */
|
|
33
|
+
formatValue?: (value: number, max: number) => ReactNode;
|
|
34
|
+
/** Track height. @default 'md' */
|
|
35
|
+
size?: 'sm' | 'md' | 'lg';
|
|
36
|
+
/** Fill colour. Overridden by a matching `thresholds` entry. @default 'primary' */
|
|
37
|
+
variant?: ProgressBarVariant;
|
|
38
|
+
/**
|
|
39
|
+
* Value-driven colour: the entry with the highest `value` that is `<=` the
|
|
40
|
+
* current value wins (`[{ value: 0, variant: 'danger' }, { value: 20, variant: 'warning' }, { value: 50, variant: 'success' }]`
|
|
41
|
+
* is a battery gauge). Below every threshold, `variant` applies.
|
|
42
|
+
*/
|
|
43
|
+
thresholds?: ProgressBarThreshold[];
|
|
44
|
+
/**
|
|
45
|
+
* When `> 1`, renders that many discrete blocks instead of a continuous
|
|
46
|
+
* fill; `Math.round(value / max * segments)` of them are filled from the
|
|
47
|
+
* left. Ignored when indeterminate.
|
|
48
|
+
*/
|
|
49
|
+
segments?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Segmented mode only. Marks the segment right after the last filled one
|
|
52
|
+
* as the *current* step with a mid shade, giving three states: done /
|
|
53
|
+
* current / remaining (`value` = steps completed). @default false
|
|
54
|
+
*/
|
|
55
|
+
showCurrent?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Corner style. `'square'` removes every radius — the flat stepper strip
|
|
58
|
+
* at the top of a survey/wizard page. @default 'rounded'
|
|
59
|
+
*/
|
|
60
|
+
shape?: 'rounded' | 'square';
|
|
61
|
+
/** Override class names on internal elements. */
|
|
62
|
+
classes?: Partial<ProgressBarClasses>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Determinate / indeterminate progress bar with optional label, value text,
|
|
66
|
+
* value-driven colour thresholds and a segmented (stepper) mode.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* <ProgressBar label="Uploading" value={42} showValue />
|
|
70
|
+
* <ProgressBar value={level} thresholds={[{ value: 0, variant: 'danger' }, { value: 20, variant: 'warning' }, { value: 50, variant: 'success' }]} />
|
|
71
|
+
* <ProgressBar value={2} max={5} segments={5} size="lg" />
|
|
72
|
+
* <ProgressBar value={2} max={4} segments={4} showCurrent shape="square" aria-label="Step 3 of 4" />
|
|
73
|
+
*/
|
|
74
|
+
export declare const ProgressBar: import('react').ForwardRefExoticComponent<Omit<ProgressBarProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsxs as M, jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as R, useMemo as V } from "react";
|
|
3
|
+
import n from "clsx";
|
|
4
|
+
import e from "./ProgressBar.module.scss.js";
|
|
5
|
+
const _ = (o, s) => `${Math.round(o / s * 100)}%`, z = R(
|
|
6
|
+
({
|
|
7
|
+
value: o,
|
|
8
|
+
max: s = 100,
|
|
9
|
+
label: l,
|
|
10
|
+
showValue: h = !1,
|
|
11
|
+
formatValue: k = _,
|
|
12
|
+
size: w = "md",
|
|
13
|
+
variant: v = "primary",
|
|
14
|
+
thresholds: g,
|
|
15
|
+
segments: i,
|
|
16
|
+
showCurrent: F = !1,
|
|
17
|
+
shape: j = "rounded",
|
|
18
|
+
classes: r,
|
|
19
|
+
className: q,
|
|
20
|
+
style: B,
|
|
21
|
+
"aria-label": C,
|
|
22
|
+
"aria-labelledby": P,
|
|
23
|
+
...S
|
|
24
|
+
}, $) => {
|
|
25
|
+
const c = s > 0 ? s : 100, a = o === void 0 || Number.isNaN(o), d = a ? 0 : Math.min(c, Math.max(0, o)), N = d / c, A = V(() => {
|
|
26
|
+
if (a || !g?.length) return v;
|
|
27
|
+
const x = [...g].sort((p, L) => p.value - L.value);
|
|
28
|
+
let t = v;
|
|
29
|
+
for (const p of x)
|
|
30
|
+
p.value <= d && (t = p.variant);
|
|
31
|
+
return t;
|
|
32
|
+
}, [a, g, v, d]), u = !a && typeof i == "number" && i > 1, f = u ? Math.round(N * i) : 0, y = u && F && f < i ? f : -1, b = l != null && l !== !1, H = b || h && !a;
|
|
33
|
+
return /* @__PURE__ */ M(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
ref: $,
|
|
37
|
+
className: n(e.root, e[w], e[A], j === "square" && e.square, r?.root, q),
|
|
38
|
+
style: B,
|
|
39
|
+
...S,
|
|
40
|
+
children: [
|
|
41
|
+
H && /* @__PURE__ */ M("div", { className: n(e.header, r?.header), children: [
|
|
42
|
+
b && /* @__PURE__ */ m("span", { className: n(e.label, r?.label), children: l }),
|
|
43
|
+
h && !a && /* @__PURE__ */ m("span", { className: n(e.value, r?.value), children: k(d, c) })
|
|
44
|
+
] }),
|
|
45
|
+
/* @__PURE__ */ m(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
role: "progressbar",
|
|
49
|
+
"aria-valuemin": 0,
|
|
50
|
+
"aria-valuemax": c,
|
|
51
|
+
"aria-valuenow": a ? void 0 : d,
|
|
52
|
+
"aria-label": C ?? (typeof l == "string" ? l : void 0),
|
|
53
|
+
"aria-labelledby": P,
|
|
54
|
+
className: n(
|
|
55
|
+
e.track,
|
|
56
|
+
a && e.indeterminate,
|
|
57
|
+
u && e.segmented,
|
|
58
|
+
r?.track
|
|
59
|
+
),
|
|
60
|
+
children: u ? Array.from({ length: i }, (x, t) => /* @__PURE__ */ m(
|
|
61
|
+
"span",
|
|
62
|
+
{
|
|
63
|
+
className: n(
|
|
64
|
+
e.segment,
|
|
65
|
+
t < f && e.segmentFilled,
|
|
66
|
+
t === y && e.segmentCurrent,
|
|
67
|
+
r?.segment,
|
|
68
|
+
t < f && r?.segmentFilled,
|
|
69
|
+
t === y && r?.segmentCurrent
|
|
70
|
+
)
|
|
71
|
+
},
|
|
72
|
+
t
|
|
73
|
+
)) : /* @__PURE__ */ m(
|
|
74
|
+
"span",
|
|
75
|
+
{
|
|
76
|
+
className: n(e.fill, r?.fill),
|
|
77
|
+
style: a ? void 0 : { width: `${N * 100}%` }
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
z.displayName = "ProgressBar";
|
|
88
|
+
export {
|
|
89
|
+
z as ProgressBar
|
|
90
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const r = "crk-root-OIfFA", e = "crk-sm-lcp3n", s = "crk-md-6WStK", c = "crk-lg-i8EIC", t = "crk-primary-d7Piz", n = "crk-success-cvbui", o = "crk-warning-T5lWo", l = "crk-danger-43KPI", k = "crk-neutral-8XqGp", a = "crk-header-z7QvW", g = "crk-label-hsH4C", d = "crk-value-lGO18", i = "crk-track-vjybM", m = "crk-fill-MAyGB", u = "crk-indeterminate-D4x08", p = "crk-crk-progress-slide-lJXeI", f = "crk-segmented-4U5CV", P = "crk-segment-kL8tr", v = "crk-segmentFilled-iSzPI", y = "crk-segmentCurrent-H443l", C = "crk-square-6Soi4", F = "crk-crk-progress-fade-748w-", I = {
|
|
2
|
+
root: r,
|
|
3
|
+
sm: e,
|
|
4
|
+
md: s,
|
|
5
|
+
lg: c,
|
|
6
|
+
primary: t,
|
|
7
|
+
success: n,
|
|
8
|
+
warning: o,
|
|
9
|
+
danger: l,
|
|
10
|
+
neutral: k,
|
|
11
|
+
header: a,
|
|
12
|
+
label: g,
|
|
13
|
+
value: d,
|
|
14
|
+
track: i,
|
|
15
|
+
fill: m,
|
|
16
|
+
indeterminate: u,
|
|
17
|
+
"crk-progress-slide": "crk-crk-progress-slide-lJXeI",
|
|
18
|
+
crkProgressSlide: p,
|
|
19
|
+
segmented: f,
|
|
20
|
+
segment: P,
|
|
21
|
+
segmentFilled: v,
|
|
22
|
+
segmentCurrent: y,
|
|
23
|
+
square: C,
|
|
24
|
+
"crk-progress-fade": "crk-crk-progress-fade-748w-",
|
|
25
|
+
crkProgressFade: F
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
F as crkProgressFade,
|
|
29
|
+
p as crkProgressSlide,
|
|
30
|
+
l as danger,
|
|
31
|
+
I as default,
|
|
32
|
+
m as fill,
|
|
33
|
+
a as header,
|
|
34
|
+
u as indeterminate,
|
|
35
|
+
g as label,
|
|
36
|
+
c as lg,
|
|
37
|
+
s as md,
|
|
38
|
+
k as neutral,
|
|
39
|
+
t as primary,
|
|
40
|
+
r as root,
|
|
41
|
+
P as segment,
|
|
42
|
+
y as segmentCurrent,
|
|
43
|
+
v as segmentFilled,
|
|
44
|
+
f as segmented,
|
|
45
|
+
e as sm,
|
|
46
|
+
C as square,
|
|
47
|
+
n as success,
|
|
48
|
+
i as track,
|
|
49
|
+
d as value,
|
|
50
|
+
o as warning
|
|
51
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
export interface RelativeTimeClasses {
|
|
3
|
+
root: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RelativeTimeProps extends Omit<ComponentPropsWithRef<'time'>, 'children' | 'title'> {
|
|
6
|
+
/** The instant to describe: `Date`, epoch ms, or an ISO string. */
|
|
7
|
+
value: Date | number | string;
|
|
8
|
+
/** `Intl.RelativeTimeFormat` style: "3 minutes ago" / "3 min. ago" / "3m ago". @default 'long' */
|
|
9
|
+
format?: 'long' | 'short' | 'narrow';
|
|
10
|
+
/** `'auto'` says "yesterday" / "now"; `'always'` says "1 day ago". @default 'auto' */
|
|
11
|
+
numeric?: 'always' | 'auto';
|
|
12
|
+
/** BCP 47 locale; `undefined` = runtime default. */
|
|
13
|
+
locale?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Keep the label fresh. Ticks every second under a minute, every 30 s under
|
|
16
|
+
* an hour, then every minute. Subscribers share one timer per period.
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
live?: boolean;
|
|
20
|
+
/** Fixed reference instant (ms) instead of the live clock — for tests and snapshots. */
|
|
21
|
+
now?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Past this many ms the relative label is replaced by an absolute date
|
|
24
|
+
* (`absoluteFormat`), e.g. `7 * 24 * 3600 * 1000` for "after a week show the date".
|
|
25
|
+
*/
|
|
26
|
+
maxAge?: number;
|
|
27
|
+
/** `Intl.DateTimeFormat` options for the absolute fallback and the `title` tooltip. @default { dateStyle: 'medium', timeStyle: 'short' } */
|
|
28
|
+
absoluteFormat?: Intl.DateTimeFormatOptions;
|
|
29
|
+
/** Tooltip with the absolute time (plain `title`, no underline). `false` disables it. @default true */
|
|
30
|
+
title?: boolean | string;
|
|
31
|
+
/** Rendered instead of the text for an unparsable `value`. @default '—' */
|
|
32
|
+
fallback?: ReactNode;
|
|
33
|
+
/** Override class names on internal elements. */
|
|
34
|
+
classes?: Partial<RelativeTimeClasses>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* "3 minutes ago" / "in 2 hours" as a live-updating `<time>` element with the
|
|
38
|
+
* absolute time in `dateTime` and as a tooltip. Uses `Intl.RelativeTimeFormat`,
|
|
39
|
+
* so no locale tables ship with the toolkit.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* <RelativeTime value={comment.createdAt} />
|
|
43
|
+
* <RelativeTime value={deploy.finishedAt} format="short" maxAge={7 * 86_400_000} />
|
|
44
|
+
*/
|
|
45
|
+
export declare const RelativeTime: import('react').ForwardRefExoticComponent<Omit<RelativeTimeProps, "ref"> & import('react').RefAttributes<HTMLTimeElement>>;
|
|
@@ -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>>;
|