@gaulatti/bleecker 0.1.46 → 0.1.48
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/dist/components/arm-take.d.ts +17 -0
- package/dist/components/arm-take.js +93 -0
- package/dist/components/drawer.d.ts +20 -3
- package/dist/components/drawer.js +14 -2
- package/dist/components/fader.d.ts +35 -0
- package/dist/components/fader.js +125 -0
- package/dist/components/key-cap.d.ts +7 -0
- package/dist/components/key-cap.js +10 -0
- package/dist/components/meter.d.ts +21 -0
- package/dist/components/meter.js +15 -0
- package/dist/components/on-air-strip.d.ts +35 -0
- package/dist/components/on-air-strip.js +16 -0
- package/dist/components/segmented-filter.d.ts +19 -0
- package/dist/components/segmented-filter.js +13 -0
- package/dist/components/state-pill.d.ts +16 -0
- package/dist/components/state-pill.js +19 -0
- package/dist/components/table.d.ts +15 -1
- package/dist/components/table.js +21 -3
- package/dist/components/toggle-group.js +14 -2
- package/dist/components/transport.d.ts +29 -0
- package/dist/components/transport.js +59 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/styles.css +1 -1
- package/dist/tokens/source.d.ts +54 -0
- package/dist/tokens/source.js +45 -2
- package/package.json +3 -2
- package/src/styles/tokens.generated.css +36 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ArmTakeProps {
|
|
2
|
+
className?: string;
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
/** How long a hold takes to confirm. */
|
|
5
|
+
holdMs?: number;
|
|
6
|
+
label: string;
|
|
7
|
+
/** Called when the take is confirmed: a hold of `holdMs`, or a second press while armed. */
|
|
8
|
+
onTake: () => void;
|
|
9
|
+
/** How long an armed control waits for the second press before it disarms itself. */
|
|
10
|
+
armTimeoutMs?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A control that cannot fire by accident: hold it for `holdMs` (a fill shows the progress), or
|
|
14
|
+
* press it twice (the first press arms it, the second takes). A single click never takes. With
|
|
15
|
+
* reduced motion there is no fill and no hold, only the two presses. Esc disarms.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ArmTake({ armTimeoutMs, className, disabled, holdMs, label, onTake }: ArmTakeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { cn } from '../utils/cn.js';
|
|
4
|
+
function prefersReducedMotion() {
|
|
5
|
+
return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A control that cannot fire by accident: hold it for `holdMs` (a fill shows the progress), or
|
|
9
|
+
* press it twice (the first press arms it, the second takes). A single click never takes. With
|
|
10
|
+
* reduced motion there is no fill and no hold, only the two presses. Esc disarms.
|
|
11
|
+
*/
|
|
12
|
+
export function ArmTake({ armTimeoutMs = 5_000, className, disabled = false, holdMs = 800, label, onTake }) {
|
|
13
|
+
const [armed, setArmed] = React.useState(false);
|
|
14
|
+
const [progress, setProgress] = React.useState(0);
|
|
15
|
+
const frame = React.useRef(null);
|
|
16
|
+
const startedAt = React.useRef(null);
|
|
17
|
+
// The click that follows a completed hold must not arm the control again.
|
|
18
|
+
const heldConfirmed = React.useRef(false);
|
|
19
|
+
const armTimer = React.useRef(null);
|
|
20
|
+
const take = React.useRef(onTake);
|
|
21
|
+
take.current = onTake;
|
|
22
|
+
const clearTimer = React.useCallback(() => {
|
|
23
|
+
if (armTimer.current)
|
|
24
|
+
clearTimeout(armTimer.current);
|
|
25
|
+
armTimer.current = null;
|
|
26
|
+
}, []);
|
|
27
|
+
const disarm = React.useCallback(() => {
|
|
28
|
+
clearTimer();
|
|
29
|
+
setArmed(false);
|
|
30
|
+
}, [clearTimer]);
|
|
31
|
+
const stopHold = React.useCallback(() => {
|
|
32
|
+
if (frame.current !== null)
|
|
33
|
+
cancelAnimationFrame(frame.current);
|
|
34
|
+
frame.current = null;
|
|
35
|
+
startedAt.current = null;
|
|
36
|
+
setProgress(0);
|
|
37
|
+
}, []);
|
|
38
|
+
const confirm = React.useCallback(() => {
|
|
39
|
+
clearTimer();
|
|
40
|
+
setArmed(false);
|
|
41
|
+
take.current();
|
|
42
|
+
}, [clearTimer]);
|
|
43
|
+
const arm = React.useCallback(() => {
|
|
44
|
+
clearTimer();
|
|
45
|
+
setArmed(true);
|
|
46
|
+
armTimer.current = setTimeout(() => setArmed(false), armTimeoutMs);
|
|
47
|
+
}, [armTimeoutMs, clearTimer]);
|
|
48
|
+
React.useEffect(() => () => {
|
|
49
|
+
clearTimer();
|
|
50
|
+
if (frame.current !== null)
|
|
51
|
+
cancelAnimationFrame(frame.current);
|
|
52
|
+
}, [clearTimer]);
|
|
53
|
+
const tick = React.useCallback((now) => {
|
|
54
|
+
if (startedAt.current === null)
|
|
55
|
+
return;
|
|
56
|
+
const ratio = Math.min(1, (now - startedAt.current) / holdMs);
|
|
57
|
+
setProgress(ratio);
|
|
58
|
+
if (ratio >= 1) {
|
|
59
|
+
frame.current = null;
|
|
60
|
+
startedAt.current = null;
|
|
61
|
+
setProgress(0);
|
|
62
|
+
heldConfirmed.current = true;
|
|
63
|
+
confirm();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
frame.current = requestAnimationFrame(tick);
|
|
67
|
+
}, [confirm, holdMs]);
|
|
68
|
+
const onPointerDown = () => {
|
|
69
|
+
if (disabled || prefersReducedMotion() || startedAt.current !== null)
|
|
70
|
+
return;
|
|
71
|
+
startedAt.current = performance.now();
|
|
72
|
+
frame.current = requestAnimationFrame(tick);
|
|
73
|
+
};
|
|
74
|
+
const onClick = () => {
|
|
75
|
+
if (heldConfirmed.current) {
|
|
76
|
+
heldConfirmed.current = false;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (armed)
|
|
80
|
+
confirm();
|
|
81
|
+
else
|
|
82
|
+
arm();
|
|
83
|
+
};
|
|
84
|
+
return (_jsxs("button", { type: 'button', disabled: disabled, "aria-label": armed ? `${label}: armed, press again to take` : label, "data-armed": armed, onPointerDown: onPointerDown, onPointerUp: stopHold, onPointerLeave: stopHold, onPointerCancel: stopHold, onBlur: () => {
|
|
85
|
+
stopHold();
|
|
86
|
+
disarm();
|
|
87
|
+
}, onKeyDown: (event) => {
|
|
88
|
+
if (event.key === 'Escape' && armed) {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
disarm();
|
|
91
|
+
}
|
|
92
|
+
}, onClick: onClick, className: cn('relative inline-flex h-9 select-none items-center gap-2 overflow-hidden rounded-[var(--radius-button)] border px-4 text-xs font-bold uppercase tracking-wider focus:outline-none focus-visible:ring-2 focus-visible:ring-sea disabled:pointer-events-none disabled:opacity-50 dark:focus-visible:ring-accent-blue', armed ? 'border-accent-red bg-accent-red text-white' : 'border-accent-text text-accent-text dark:border-accent-yellow dark:text-accent-yellow', className), children: [_jsx("span", { "aria-hidden": 'true', "data-arm-fill": true, className: 'absolute inset-y-0 left-0 bg-accent-red/70', style: { width: `${progress * 100}%` } }), _jsx("span", { className: 'relative', children: armed ? 'Press again to take' : label }), _jsx("span", { role: 'status', className: 'sr-only', children: armed ? 'Armed. Press again within the time shown to take.' : '' })] }));
|
|
93
|
+
}
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
interface DrawerBaseProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
className?: string;
|
|
5
5
|
description?: string;
|
|
6
|
-
isOpen: boolean;
|
|
7
6
|
onClose: () => void;
|
|
8
7
|
snapPoints?: string[];
|
|
9
8
|
title?: string;
|
|
10
9
|
}
|
|
11
|
-
|
|
10
|
+
/** The bottom sheet (the default): a modal overlay that holds focus. */
|
|
11
|
+
export interface DrawerSheetProps extends DrawerBaseProps {
|
|
12
|
+
variant?: 'sheet';
|
|
13
|
+
isOpen: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `variant="detail"` (bleecker#549): a panel docked beside a list, with no
|
|
17
|
+
* overlay and no focus trap, so focus stays in the list. `open` (or `isOpen`)
|
|
18
|
+
* shows it; `width` defaults to 22rem.
|
|
19
|
+
*/
|
|
20
|
+
export interface DrawerDetailProps extends DrawerBaseProps {
|
|
21
|
+
variant: 'detail';
|
|
22
|
+
open?: boolean;
|
|
23
|
+
isOpen?: boolean;
|
|
24
|
+
width?: string;
|
|
25
|
+
}
|
|
26
|
+
export type DrawerProps = DrawerSheetProps | DrawerDetailProps;
|
|
27
|
+
export declare function Drawer(props: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export {};
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Minus } from 'lucide-react';
|
|
3
|
+
import { Minus, X } from 'lucide-react';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
import { cn } from '../utils/cn.js';
|
|
7
7
|
import { ModalLayerScope, useModalLayer, usePresence } from '../utils/hooks.js';
|
|
8
|
-
export function Drawer(
|
|
8
|
+
export function Drawer(props) {
|
|
9
|
+
if (props.variant === 'detail')
|
|
10
|
+
return _jsx(DetailDrawer, { ...props });
|
|
11
|
+
return _jsx(SheetDrawer, { ...props });
|
|
12
|
+
}
|
|
13
|
+
function DetailDrawer({ children, className, description, onClose, open, isOpen, title, width = '22rem' }) {
|
|
14
|
+
const titleId = React.useId();
|
|
15
|
+
const descriptionId = React.useId();
|
|
16
|
+
if (!(open ?? isOpen))
|
|
17
|
+
return null;
|
|
18
|
+
return (_jsxs("aside", { "data-bleecker-drawer": 'detail', "aria-label": title ? undefined : 'Details', "aria-labelledby": title ? titleId : undefined, "aria-describedby": description ? descriptionId : undefined, style: { width }, className: cn('flex h-full min-h-0 shrink-0 flex-col border-l border-sand/25 bg-white dark:border-white/10 dark:bg-deep-sea', className), children: [_jsxs("div", { className: 'flex items-start gap-3 border-b border-sand/20 px-5 py-4 dark:border-white/[0.07]', children: [_jsxs("div", { className: 'min-w-0 flex-1', children: [title ? _jsx("h2", { id: titleId, className: 'truncate text-base font-medium text-text-primary dark:text-text-primary', children: title }) : null, description ? _jsx("p", { id: descriptionId, className: 'font-secondary mt-1 text-sm text-text-secondary dark:text-text-secondary', children: description }) : null] }), _jsx("button", { type: 'button', onClick: onClose, "aria-label": 'Close details', className: '-mr-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-[var(--radius-button)] text-text-secondary transition-colors duration-[var(--motion-control)] ease-premium hover:bg-light-sand/60 hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sea/45 dark:hover:bg-white/[0.06]', children: _jsx(X, { size: 16, "aria-hidden": 'true' }) })] }), _jsx("div", { className: 'min-h-0 flex-1 overflow-y-auto px-5 py-4', children: children })] }));
|
|
19
|
+
}
|
|
20
|
+
function SheetDrawer({ children, className, description, isOpen, onClose, title }) {
|
|
9
21
|
const { present, visible } = usePresence(isOpen, 180);
|
|
10
22
|
const startYRef = React.useRef(null);
|
|
11
23
|
const panelRef = useModalLayer(isOpen, onClose);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type MeterProps } from './meter';
|
|
2
|
+
export type FaderUnit = 'db' | 'percent';
|
|
3
|
+
export interface FaderProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
/** The coarse step, for Shift with an arrow and for Page Up / Page Down. Defaults to ten steps. */
|
|
6
|
+
coarseStep?: number;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** What the fader sets, announced with its value ("Music: −6.0 dB"). */
|
|
9
|
+
label: string;
|
|
10
|
+
/** The track's length along its axis (a CSS length). Defaults to 12rem. */
|
|
11
|
+
length?: string;
|
|
12
|
+
max: number;
|
|
13
|
+
/** A level shown beside the fader on the same scale (`min` to `max`). */
|
|
14
|
+
meter?: Pick<MeterProps, 'hold' | 'peak' | 'value' | 'warnFrom'>;
|
|
15
|
+
min: number;
|
|
16
|
+
onValueChange: (value: number) => void;
|
|
17
|
+
orientation?: 'horizontal' | 'vertical';
|
|
18
|
+
/** The fine step, for an arrow key. Defaults to 0.5 dB or 1 %. */
|
|
19
|
+
step?: number;
|
|
20
|
+
/** The value the fader returns to on double-click or the 0 key; drawn as a mark on the track. */
|
|
21
|
+
unity?: number;
|
|
22
|
+
unit: FaderUnit;
|
|
23
|
+
value: number;
|
|
24
|
+
}
|
|
25
|
+
/** The value as read out and announced: "−6.0 dB", "+3.0 dB", "75 %". */
|
|
26
|
+
export declare function formatFaderValue(value: number, unit: FaderUnit): string;
|
|
27
|
+
/**
|
|
28
|
+
* A console fader: sets a level between `min` and `max` and states it. Vertical by default, with a
|
|
29
|
+
* unity mark, a readout in tabular numerals and an optional level meter on the same scale.
|
|
30
|
+
*
|
|
31
|
+
* Keyboard: arrows step by `step`, Shift with an arrow (or Page Up / Page Down) by `coarseStep`,
|
|
32
|
+
* Home and End go to the limits, and 0 returns to `unity`. A double-click also returns to unity.
|
|
33
|
+
* Mute and solo are separate controls.
|
|
34
|
+
*/
|
|
35
|
+
export declare function Fader({ className, coarseStep, disabled, label, length, max, meter, min, onValueChange, orientation, step, unity, unit, value }: FaderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { cn } from '../utils/cn.js';
|
|
4
|
+
import { Meter } from './meter.js';
|
|
5
|
+
const DECIMALS = { db: 1, percent: 0 };
|
|
6
|
+
/** The value as read out and announced: "−6.0 dB", "+3.0 dB", "75 %". */
|
|
7
|
+
export function formatFaderValue(value, unit) {
|
|
8
|
+
const fixed = Math.abs(value).toFixed(DECIMALS[unit]);
|
|
9
|
+
if (unit === 'percent')
|
|
10
|
+
return `${value < 0 ? '−' : ''}${fixed} %`;
|
|
11
|
+
const sign = Number(fixed) === 0 ? '' : value < 0 ? '−' : '+';
|
|
12
|
+
return `${sign}${fixed} dB`;
|
|
13
|
+
}
|
|
14
|
+
function clampToStep(value, min, max, step) {
|
|
15
|
+
const clamped = Math.min(max, Math.max(min, value));
|
|
16
|
+
if (!(step > 0))
|
|
17
|
+
return clamped;
|
|
18
|
+
const snapped = min + Math.round((clamped - min) / step) * step;
|
|
19
|
+
// Keep the decimals of the step (0.5 + 0.1 drift) and stay inside the range.
|
|
20
|
+
const digits = (String(step).split('.')[1] ?? '').length;
|
|
21
|
+
return Math.min(max, Math.max(min, Number(snapped.toFixed(digits))));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A console fader: sets a level between `min` and `max` and states it. Vertical by default, with a
|
|
25
|
+
* unity mark, a readout in tabular numerals and an optional level meter on the same scale.
|
|
26
|
+
*
|
|
27
|
+
* Keyboard: arrows step by `step`, Shift with an arrow (or Page Up / Page Down) by `coarseStep`,
|
|
28
|
+
* Home and End go to the limits, and 0 returns to `unity`. A double-click also returns to unity.
|
|
29
|
+
* Mute and solo are separate controls.
|
|
30
|
+
*/
|
|
31
|
+
export function Fader({ className, coarseStep, disabled = false, label, length = '12rem', max, meter, min, onValueChange, orientation = 'vertical', step, unity, unit, value }) {
|
|
32
|
+
const fine = step ?? (unit === 'db' ? 0.5 : 1);
|
|
33
|
+
const coarse = coarseStep ?? fine * 10;
|
|
34
|
+
const vertical = orientation === 'vertical';
|
|
35
|
+
const span = max - min;
|
|
36
|
+
const at = (reading) => (span > 0 ? Math.max(0, Math.min(100, ((reading - min) / span) * 100)) : 0);
|
|
37
|
+
const current = Math.min(max, Math.max(min, value));
|
|
38
|
+
const unityInRange = unity !== undefined && unity >= min && unity <= max;
|
|
39
|
+
const readout = formatFaderValue(current, unit);
|
|
40
|
+
const dragging = React.useRef(false);
|
|
41
|
+
const commit = (next) => {
|
|
42
|
+
const settled = clampToStep(next, min, max, fine);
|
|
43
|
+
if (settled !== current)
|
|
44
|
+
onValueChange(settled);
|
|
45
|
+
};
|
|
46
|
+
const valueAt = (track, clientX, clientY) => {
|
|
47
|
+
const box = track.getBoundingClientRect();
|
|
48
|
+
const fraction = vertical
|
|
49
|
+
? box.height > 0 ? (box.bottom - clientY) / box.height : 0
|
|
50
|
+
: box.width > 0 ? (clientX - box.left) / box.width : 0;
|
|
51
|
+
return min + Math.max(0, Math.min(1, fraction)) * span;
|
|
52
|
+
};
|
|
53
|
+
const onKeyDown = (event) => {
|
|
54
|
+
if (disabled)
|
|
55
|
+
return;
|
|
56
|
+
const amount = event.shiftKey ? coarse : fine;
|
|
57
|
+
// From a value between steps, the first press of any step key (fine or coarse) goes to the
|
|
58
|
+
// nearest fine step in that direction.
|
|
59
|
+
const onGrid = clampToStep(current, min, max, fine);
|
|
60
|
+
const up = (by) => (onGrid > current ? onGrid : onGrid + by);
|
|
61
|
+
const down = (by) => (onGrid < current ? onGrid : onGrid - by);
|
|
62
|
+
let next = null;
|
|
63
|
+
switch (event.key) {
|
|
64
|
+
case 'ArrowUp':
|
|
65
|
+
case 'ArrowRight':
|
|
66
|
+
next = up(amount);
|
|
67
|
+
break;
|
|
68
|
+
case 'ArrowDown':
|
|
69
|
+
case 'ArrowLeft':
|
|
70
|
+
next = down(amount);
|
|
71
|
+
break;
|
|
72
|
+
case 'PageUp':
|
|
73
|
+
next = up(coarse);
|
|
74
|
+
break;
|
|
75
|
+
case 'PageDown':
|
|
76
|
+
next = down(coarse);
|
|
77
|
+
break;
|
|
78
|
+
case 'Home':
|
|
79
|
+
next = min;
|
|
80
|
+
break;
|
|
81
|
+
case 'End':
|
|
82
|
+
next = max;
|
|
83
|
+
break;
|
|
84
|
+
case '0':
|
|
85
|
+
if (unityInRange)
|
|
86
|
+
next = unity;
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
if (next !== null)
|
|
93
|
+
commit(next);
|
|
94
|
+
};
|
|
95
|
+
const onPointerDown = (event) => {
|
|
96
|
+
if (disabled || event.button !== 0)
|
|
97
|
+
return;
|
|
98
|
+
event.currentTarget.focus();
|
|
99
|
+
dragging.current = true;
|
|
100
|
+
try {
|
|
101
|
+
// Keeps the drag when the pointer leaves the track; a pointer the browser
|
|
102
|
+
// does not know (a synthetic one) cannot be captured, and the drag still works on the track.
|
|
103
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// Not capturable: the drag follows the track only.
|
|
107
|
+
}
|
|
108
|
+
commit(valueAt(event.currentTarget, event.clientX, event.clientY));
|
|
109
|
+
};
|
|
110
|
+
const onPointerMove = (event) => {
|
|
111
|
+
if (disabled || !dragging.current)
|
|
112
|
+
return;
|
|
113
|
+
commit(valueAt(event.currentTarget, event.clientX, event.clientY));
|
|
114
|
+
};
|
|
115
|
+
const endDrag = () => {
|
|
116
|
+
dragging.current = false;
|
|
117
|
+
};
|
|
118
|
+
const position = at(current);
|
|
119
|
+
const cap = vertical ? { bottom: `calc(${position}% - 0.5rem)` } : { left: `calc(${position}% - 0.5rem)` };
|
|
120
|
+
const fill = vertical ? { height: `${position}%` } : { width: `${position}%` };
|
|
121
|
+
return (_jsxs("div", { "data-fader": orientation, className: cn('inline-flex gap-2 text-text-primary', vertical ? 'flex-col items-center' : 'flex-row items-center', disabled && 'opacity-50', className), children: [_jsx("span", { className: 'text-xs font-medium text-text-secondary dark:text-text-primary', children: label }), _jsxs("div", { className: cn('flex gap-2', vertical ? 'flex-row items-stretch' : 'flex-col'), style: vertical ? { height: length } : { width: length }, children: [_jsxs("div", { role: 'slider', tabIndex: disabled ? -1 : 0, "aria-label": label, "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": current, "aria-valuetext": readout, "aria-orientation": orientation, "aria-disabled": disabled || undefined, onKeyDown: onKeyDown, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: endDrag, onPointerCancel: endDrag, onLostPointerCapture: endDrag, style: vertical ? { height: length } : { width: length }, onDoubleClick: () => {
|
|
122
|
+
if (!disabled && unityInRange)
|
|
123
|
+
commit(unity);
|
|
124
|
+
}, className: cn('relative shrink-0 touch-none select-none rounded-[var(--radius-ui)] bg-text-primary/15', 'focus:outline-none focus-visible:ring-2 focus-visible:ring-sea focus-visible:ring-offset-2 dark:focus-visible:ring-accent-blue', vertical ? 'w-3' : 'h-3', disabled ? 'cursor-not-allowed' : vertical ? 'cursor-ns-resize' : 'cursor-ew-resize'), children: [_jsx("span", { "data-fader": 'fill', className: cn('absolute rounded-[inherit] bg-sea dark:bg-accent-blue', vertical ? 'inset-x-0 bottom-0' : 'inset-y-0 left-0'), style: fill }), unityInRange ? (_jsx("span", { "data-fader": 'unity', "aria-hidden": 'true', className: cn('absolute bg-text-primary/70', vertical ? '-inset-x-1 h-px' : '-inset-y-1 w-px'), style: vertical ? { bottom: `${at(unity)}%` } : { left: `${at(unity)}%` } })) : null, _jsx("span", { "data-fader": 'cap', "aria-hidden": 'true', className: cn('absolute rounded-sm border border-text-primary/40 bg-white shadow-sm transition-shadow duration-[var(--motion-control)] ease-premium dark:bg-dark-sand', vertical ? '-inset-x-1.5 h-4' : '-inset-y-1.5 w-4'), style: cap })] }), meter ? (_jsx(Meter, { label: `${label} level`, min: min, max: max, unit: unit === 'db' ? 'dB' : '%', orientation: orientation, value: meter.value, peak: meter.peak, hold: meter.hold, warnFrom: meter.warnFrom })) : null] }), _jsx("output", { "aria-hidden": 'true', className: 'font-mono text-xs tabular-nums text-text-secondary dark:text-text-primary', children: readout })] }));
|
|
125
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface KeyCapProps extends React.HTMLAttributes<HTMLElement> {
|
|
3
|
+
/** One cap per key, for a chord: `keys={['⌘', 'K']}`. */
|
|
4
|
+
keys?: string[];
|
|
5
|
+
}
|
|
6
|
+
/** A keyboard key as a cap with a heavier bottom edge. Kbd stays exported; KeyCap is the new styling. */
|
|
7
|
+
export declare function KeyCap({ className, children, keys, ...props }: KeyCapProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../utils/cn.js';
|
|
3
|
+
const capClasses = 'inline-flex h-5 min-w-5 items-center justify-center rounded-[5px] border border-b-2 border-sand/60 bg-white px-1.5 font-mono text-[11px] font-semibold text-text-secondary dark:border-white/20 dark:bg-deep-sea/60 dark:text-text-primary';
|
|
4
|
+
/** A keyboard key as a cap with a heavier bottom edge. Kbd stays exported; KeyCap is the new styling. */
|
|
5
|
+
export function KeyCap({ className, children, keys, ...props }) {
|
|
6
|
+
if (keys && keys.length > 0) {
|
|
7
|
+
return (_jsx("span", { className: 'inline-flex items-center gap-1', role: 'group', "aria-label": keys.join(' '), children: keys.map((key, index) => (_jsx("kbd", { ...props, className: cn(capClasses, className), children: key }, `${key}-${index}`))) }));
|
|
8
|
+
}
|
|
9
|
+
return (_jsx("kbd", { ...props, className: cn(capClasses, className), children: children }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface MeterProps {
|
|
2
|
+
className?: string;
|
|
3
|
+
/** The held maximum, in the same scale as `value`. */
|
|
4
|
+
hold?: number | null;
|
|
5
|
+
label: string;
|
|
6
|
+
max: number;
|
|
7
|
+
min: number;
|
|
8
|
+
/** Horizontal by default. Vertical fills from the bottom, for a meter beside a vertical fader. */
|
|
9
|
+
orientation?: 'horizontal' | 'vertical';
|
|
10
|
+
/** The live peak, in the same scale as `value`. */
|
|
11
|
+
peak?: number | null;
|
|
12
|
+
unit?: string;
|
|
13
|
+
value: number | null;
|
|
14
|
+
/** From here to `max` the scale is the warning zone, and a hold inside it turns red. */
|
|
15
|
+
warnFrom?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A reading and its scale: a level between `min` and `max` with an optional live peak, a held peak
|
|
19
|
+
* and a warning zone. It does not animate; the page feeds it new values.
|
|
20
|
+
*/
|
|
21
|
+
export declare function Meter({ className, hold, label, max, min, orientation, peak, unit, value, warnFrom }: MeterProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../utils/cn.js';
|
|
3
|
+
/**
|
|
4
|
+
* A reading and its scale: a level between `min` and `max` with an optional live peak, a held peak
|
|
5
|
+
* and a warning zone. It does not animate; the page feeds it new values.
|
|
6
|
+
*/
|
|
7
|
+
export function Meter({ className, hold, label, max, min, orientation = 'horizontal', peak, unit, value, warnFrom }) {
|
|
8
|
+
const span = max - min;
|
|
9
|
+
const at = (reading) => (span > 0 ? Math.max(0, Math.min(100, ((reading - min) / span) * 100)) : 0);
|
|
10
|
+
const vertical = orientation === 'vertical';
|
|
11
|
+
// Along the meter's axis: from the left, or from the bottom when vertical.
|
|
12
|
+
const from = (percent) => (vertical ? { bottom: `${percent}%` } : { left: `${percent}%` });
|
|
13
|
+
const mark = (percent) => (vertical ? { bottom: `calc(${percent}% - 1px)` } : { left: `calc(${percent}% - 1px)` });
|
|
14
|
+
return (_jsxs("div", { role: 'meter', "aria-label": label, "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": value ?? min, "aria-valuetext": value === null ? 'No level' : `${value.toFixed(1)}${unit ? ` ${unit}` : ''}`, "data-orientation": vertical ? 'vertical' : undefined, className: cn('relative overflow-hidden rounded-full bg-sand/30 dark:bg-sand/25', vertical ? 'h-full w-1.5' : 'h-1.5', className), children: [warnFrom !== undefined ? (_jsx("span", { "data-meter": 'warn', className: cn('absolute bg-terracotta/35', vertical ? 'inset-x-0 top-0' : 'inset-y-0 right-0'), style: from(at(warnFrom)) })) : null, value !== null ? (_jsx("span", { "data-meter": 'fill', className: cn('absolute bg-sea dark:bg-accent-blue', vertical ? 'inset-x-0 bottom-0' : 'inset-y-0 left-0'), style: vertical ? { height: `${at(value)}%` } : { width: `${at(value)}%` } })) : null, peak !== undefined && peak !== null ? (_jsx("span", { "data-meter": 'peak', className: cn('absolute bg-text-primary/80', vertical ? 'inset-x-0 h-0.5' : 'inset-y-0 w-0.5'), style: mark(at(peak)) })) : null, hold !== undefined && hold !== null ? (_jsx("span", { "data-meter": 'hold', className: cn('absolute', vertical ? 'inset-x-0 h-0.5' : 'inset-y-0 w-0.5', warnFrom !== undefined && hold >= warnFrom ? 'bg-terracotta' : 'bg-accent-text dark:bg-accent-yellow'), style: mark(at(hold)) })) : null] }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StatePillTone } from './state-pill';
|
|
3
|
+
export type OnAirState = 'live' | 'armed' | 'idle';
|
|
4
|
+
export interface OnAirStripPill {
|
|
5
|
+
label: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
tone: StatePillTone;
|
|
8
|
+
}
|
|
9
|
+
export interface OnAirStripProps {
|
|
10
|
+
className?: string;
|
|
11
|
+
/** A clock or any trailing readout, shown at the right. */
|
|
12
|
+
clock?: React.ReactNode;
|
|
13
|
+
/** What plays now: a title line and a detail line. */
|
|
14
|
+
now?: {
|
|
15
|
+
detail?: string;
|
|
16
|
+
title: string;
|
|
17
|
+
};
|
|
18
|
+
/** What plays next. */
|
|
19
|
+
next?: {
|
|
20
|
+
detail?: string;
|
|
21
|
+
title: string;
|
|
22
|
+
};
|
|
23
|
+
/** Health chips: stream, engine, monitor. */
|
|
24
|
+
pills?: OnAirStripPill[];
|
|
25
|
+
state: OnAirState;
|
|
26
|
+
/** What the state says when it differs from its default words (On air, Armed, Off air). */
|
|
27
|
+
stateLabel?: string;
|
|
28
|
+
/** Shown when nothing is on air. */
|
|
29
|
+
idleText?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A one-row strip for the top of a console: whether the program is on air, what plays and what is
|
|
33
|
+
* next, the health chips and a clock. Tones come from StatePill.
|
|
34
|
+
*/
|
|
35
|
+
export declare function OnAirStrip({ className, clock, idleText, next, now, pills, state, stateLabel }: OnAirStripProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../utils/cn.js';
|
|
3
|
+
import { StatePill } from './state-pill.js';
|
|
4
|
+
const STATE_TONES = {
|
|
5
|
+
live: { label: 'On air', tone: 'live' },
|
|
6
|
+
armed: { label: 'Armed', tone: 'arm' },
|
|
7
|
+
idle: { label: 'Off air', tone: 'idle' }
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A one-row strip for the top of a console: whether the program is on air, what plays and what is
|
|
11
|
+
* next, the health chips and a clock. Tones come from StatePill.
|
|
12
|
+
*/
|
|
13
|
+
export function OnAirStrip({ className, clock, idleText = 'Nothing on air', next, now, pills = [], state, stateLabel }) {
|
|
14
|
+
const base = STATE_TONES[state];
|
|
15
|
+
return (_jsxs("section", { "aria-label": 'On air', "data-state": state, className: cn('flex flex-wrap items-center gap-x-5 gap-y-2 rounded-[var(--radius-card)] bg-deep-sea px-4 py-2.5 text-white', className), children: [_jsx(StatePill, { tone: base.tone, label: stateLabel ?? base.label, pulse: state === 'live', className: 'border-white/30' }), _jsx("div", { className: 'min-w-0 flex-1 basis-56', children: now ? (_jsxs(_Fragment, { children: [_jsx("p", { className: 'truncate text-sm font-semibold', children: now.title }), now.detail ? _jsx("p", { className: 'truncate text-xs text-white/70', children: now.detail }) : null] })) : (_jsx("p", { className: 'text-sm text-white/70', children: idleText })) }), next ? (_jsxs("div", { className: 'min-w-0 basis-48 text-xs', children: [_jsx("p", { className: 'text-white/70', children: "Next" }), _jsxs("p", { className: 'truncate', children: [_jsx("span", { className: 'font-semibold', children: next.title }), next.detail ? _jsxs("span", { className: 'text-white/70', children: [" \u00B7 ", next.detail] }) : null] })] })) : null, pills.length > 0 ? (_jsx("div", { className: 'flex flex-wrap items-center gap-1.5', children: pills.map((pill) => (_jsx(StatePill, { tone: pill.tone, label: pill.label, title: pill.title }, pill.label))) })) : null, clock ? _jsx("div", { className: 'font-mono text-lg font-semibold tabular-nums', children: clock }) : null] }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface SegmentedFilterOption {
|
|
2
|
+
/** Shown after the label, in tabular numerals. */
|
|
3
|
+
count?: number;
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SegmentedFilterProps {
|
|
8
|
+
className?: string;
|
|
9
|
+
/** Names the group for assistive technology. */
|
|
10
|
+
label: string;
|
|
11
|
+
onChange: (value: string) => void;
|
|
12
|
+
options: SegmentedFilterOption[];
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* One choice of several, always one chosen: a segmented filter built on ToggleGroup. Pressing the
|
|
17
|
+
* chosen segment again keeps it chosen (a filter has no "none").
|
|
18
|
+
*/
|
|
19
|
+
export declare function SegmentedFilter({ className, label, onChange, options, value }: SegmentedFilterProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../utils/cn.js';
|
|
3
|
+
import { ToggleGroup, ToggleGroupItem } from './toggle-group.js';
|
|
4
|
+
/**
|
|
5
|
+
* One choice of several, always one chosen: a segmented filter built on ToggleGroup. Pressing the
|
|
6
|
+
* chosen segment again keeps it chosen (a filter has no "none").
|
|
7
|
+
*/
|
|
8
|
+
export function SegmentedFilter({ className, label, onChange, options, value }) {
|
|
9
|
+
return (_jsx("div", { role: 'group', "aria-label": label, className: cn('inline-flex', className), children: _jsx(ToggleGroup, { type: 'single', value: value, onValueChange: (next) => {
|
|
10
|
+
if (next)
|
|
11
|
+
onChange(next);
|
|
12
|
+
}, size: 'sm', children: options.map((option) => (_jsxs(ToggleGroupItem, { value: option.value, children: [option.label, option.count !== undefined ? _jsx("span", { className: 'font-mono text-[11px] tabular-nums text-text-secondary', children: option.count }) : null] }, option.value))) }) }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type StatePillTone = 'live' | 'ok' | 'warn' | 'bad' | 'arm' | 'info' | 'idle';
|
|
2
|
+
export interface StatePillProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
/** The state, in words. Colour alone never carries it. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Pulses the dot (a live state). Respects reduced motion. */
|
|
7
|
+
pulse?: boolean;
|
|
8
|
+
title?: string;
|
|
9
|
+
tone: StatePillTone;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A state as a dot and a label: the compact status of a row, a strip or a header. StatusBadge stays
|
|
13
|
+
* exported with its current variants; StatePill is its successor with the tones of the console's
|
|
14
|
+
* dense surfaces (on air, ready, measuring, failed, armed).
|
|
15
|
+
*/
|
|
16
|
+
export declare function StatePill({ className, label, pulse, title, tone }: StatePillProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../utils/cn.js';
|
|
3
|
+
const toneClasses = {
|
|
4
|
+
live: 'border-accent-red bg-accent-red text-white',
|
|
5
|
+
ok: 'border-emerald-600/30 bg-emerald-600/[0.08] text-emerald-700 dark:border-emerald-400/35 dark:bg-emerald-400/10 dark:text-emerald-300',
|
|
6
|
+
warn: 'border-desert/35 bg-desert/10 text-accent-text dark:border-desert/35 dark:bg-desert/10 dark:text-accent-text',
|
|
7
|
+
bad: 'border-terracotta/40 bg-terracotta/10 text-[color-mix(in_srgb,var(--color-terracotta),var(--color-text-primary)_35%)] dark:border-terracotta/40 dark:bg-terracotta/10 dark:text-terracotta',
|
|
8
|
+
arm: 'border-accent-text bg-transparent text-accent-text dark:border-accent-yellow dark:text-accent-yellow',
|
|
9
|
+
info: 'border-sea/30 bg-sea/10 text-sea dark:border-accent-blue/35 dark:bg-accent-blue/10 dark:text-accent-blue',
|
|
10
|
+
idle: 'border-sand/40 bg-transparent text-text-secondary dark:border-sand/40 dark:text-text-secondary'
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A state as a dot and a label: the compact status of a row, a strip or a header. StatusBadge stays
|
|
14
|
+
* exported with its current variants; StatePill is its successor with the tones of the console's
|
|
15
|
+
* dense surfaces (on air, ready, measuring, failed, armed).
|
|
16
|
+
*/
|
|
17
|
+
export function StatePill({ className, label, pulse = false, title, tone }) {
|
|
18
|
+
return (_jsxs("span", { "data-tone": tone, title: title, className: cn('inline-flex h-[22px] items-center gap-1.5 whitespace-nowrap rounded-full border px-2.5 text-[11px] font-semibold tracking-ui', toneClasses[tone], className), children: [_jsx("i", { "aria-hidden": 'true', className: cn('h-1.5 w-1.5 rounded-full bg-current', pulse && 'motion-safe:animate-pulse') }), label] }));
|
|
19
|
+
}
|
|
@@ -56,5 +56,19 @@ export interface DataTableProps<TData> {
|
|
|
56
56
|
selectable?: boolean;
|
|
57
57
|
selectedKeys?: Set<string>;
|
|
58
58
|
onSelectionChange?: (keys: Set<string>) => void;
|
|
59
|
+
/**
|
|
60
|
+
* `dense` (bleecker#549): 40px rows, tabular numerics and tighter cells. The
|
|
61
|
+
* default density keeps its 52px rows unchanged.
|
|
62
|
+
*/
|
|
63
|
+
density?: 'default' | 'dense';
|
|
64
|
+
/** The one row shown as selected with a tint (for a list beside a detail panel). */
|
|
65
|
+
selectedKey?: string;
|
|
66
|
+
/** Makes each row clickable (and focusable, with Enter or Space). */
|
|
67
|
+
onRowClick?: (row: TData, index: number) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Keeps the header visible while the rows scroll. Bound the height through
|
|
70
|
+
* `containerClassName` (for example `max-h-[60dvh]`); the container then scrolls.
|
|
71
|
+
*/
|
|
72
|
+
stickyHeader?: boolean;
|
|
59
73
|
}
|
|
60
|
-
export declare function DataTable<TData>({ caption, className, columns, containerClassName, data, emptyMessage, getRowKey, footer, sort: controlledSort, onSortChange, selectable, selectedKeys: controlledSelected, onSelectionChange }: DataTableProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
74
|
+
export declare function DataTable<TData>({ caption, className, columns, containerClassName, data, emptyMessage, getRowKey, footer, sort: controlledSort, onSortChange, selectable, selectedKeys: controlledSelected, onSelectionChange, density, selectedKey, onRowClick, stickyHeader }: DataTableProps<TData>): import("react/jsx-runtime").JSX.Element;
|
package/dist/components/table.js
CHANGED
|
@@ -63,7 +63,8 @@ function defaultCompare(key, a, b) {
|
|
|
63
63
|
return av - bv;
|
|
64
64
|
return String(av ?? '').localeCompare(String(bv ?? ''));
|
|
65
65
|
}
|
|
66
|
-
export function DataTable({ caption, className, columns, containerClassName, data, emptyMessage = 'No results.', getRowKey, footer, sort: controlledSort, onSortChange, selectable = false, selectedKeys: controlledSelected, onSelectionChange }) {
|
|
66
|
+
export function DataTable({ caption, className, columns, containerClassName, data, emptyMessage = 'No results.', getRowKey, footer, sort: controlledSort, onSortChange, selectable = false, selectedKeys: controlledSelected, onSelectionChange, density = 'default', selectedKey, onRowClick, stickyHeader = false }) {
|
|
67
|
+
const dense = density === 'dense';
|
|
67
68
|
const [internalSort, setInternalSort] = React.useState({ field: '', order: 'asc' });
|
|
68
69
|
const [internalSelected, setInternalSelected] = React.useState(new Set());
|
|
69
70
|
const sort = controlledSort ?? internalSort;
|
|
@@ -96,12 +97,29 @@ export function DataTable({ caption, className, columns, containerClassName, dat
|
|
|
96
97
|
checked ? next.add(key) : next.delete(key);
|
|
97
98
|
setSelectedKeys(next);
|
|
98
99
|
};
|
|
99
|
-
return (_jsx("div", { className: cn('overflow-hidden rounded-[var(--radius-card)] border border-sand/30 bg-white shadow-[var(--shadow-surface)] dark:border-white/10 dark:bg-deep-sea', containerClassName), children: _jsxs(Table, { className: className, children: [caption && _jsx(TableCaption, { children: caption }), _jsx(TableHeader, { children: _jsxs(TableRow, { children: [selectable && (_jsx(TableHead, { className: 'w-10', children: _jsx(Checkbox, { checked: allSelected, ref: (el) => {
|
|
100
|
+
return (_jsx("div", { className: cn('overflow-hidden rounded-[var(--radius-card)] border border-sand/30 bg-white shadow-[var(--shadow-surface)] dark:border-white/10 dark:bg-deep-sea', stickyHeader && 'overflow-auto', containerClassName), children: _jsxs(Table, { className: cn(dense && 'tabular-nums', className), containerClassName: stickyHeader ? 'overflow-visible' : undefined, children: [caption && _jsx(TableCaption, { children: caption }), _jsx(TableHeader, { className: cn(stickyHeader && 'sticky top-0 z-10 bg-white dark:bg-deep-sea [&_th]:bg-light-sand/40 dark:[&_th]:bg-white/[0.035]', dense && '[&_th]:h-9 [&_th]:px-3'), children: _jsxs(TableRow, { children: [selectable && (_jsx(TableHead, { className: 'w-10', children: _jsx(Checkbox, { checked: allSelected, ref: (el) => {
|
|
100
101
|
if (el)
|
|
101
102
|
el.indeterminate = someSelected;
|
|
102
103
|
}, onChange: (e) => toggleAll(e.target.checked), "aria-label": 'Select all' }) })), columns.map((col) => (_jsx(SortableTableHeader, { field: col.key, label: col.header, currentSort: sort, onSort: handleSort, sortable: col.sortable !== false, align: col.align === 'right' ? 'right' : 'left', className: col.headerClassName }, col.key)))] }) }), _jsx(TableBody, { children: sortedData.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: columns.length + (selectable ? 1 : 0), className: 'h-24 text-center text-text-secondary dark:text-text-secondary', children: emptyMessage }) })) : (sortedData.map((row, i) => {
|
|
103
104
|
const key = rowKeys[i];
|
|
105
|
+
// The checkbox is checkbox selection only; selectedKey only tints the
|
|
106
|
+
// row (bleecker#552), so it never checks a box toggleRow cannot clear.
|
|
104
107
|
const isSelected = selectedKeys.has(key);
|
|
105
|
-
|
|
108
|
+
const isTinted = isSelected || (selectedKey !== undefined && selectedKey === key);
|
|
109
|
+
const rowProps = onRowClick
|
|
110
|
+
? {
|
|
111
|
+
tabIndex: 0,
|
|
112
|
+
'aria-selected': selectedKey !== undefined ? selectedKey === key : undefined,
|
|
113
|
+
onClick: () => onRowClick(row, i),
|
|
114
|
+
onKeyDown: (event) => {
|
|
115
|
+
if (event.target !== event.currentTarget || (event.key !== 'Enter' && event.key !== ' '))
|
|
116
|
+
return;
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
onRowClick(row, i);
|
|
119
|
+
},
|
|
120
|
+
className: 'cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-sea/45'
|
|
121
|
+
}
|
|
122
|
+
: {};
|
|
123
|
+
return (_jsxs(TableRow, { "data-selected": isTinted, ...rowProps, className: cn(dense && 'h-10', rowProps.className), children: [selectable && (_jsx(TableCell, { className: cn(dense && 'px-3 py-0'), onClick: onRowClick ? (event) => event.stopPropagation() : undefined, children: _jsx(Checkbox, { checked: isSelected, onChange: (e) => toggleRow(key, e.target.checked), "aria-label": `Select row ${key}` }) })), columns.map((col) => (_jsx(TableCell, { className: cn(dense && 'px-3 py-0', col.align === 'right' && 'text-right', col.align === 'center' && 'text-center', col.className), children: col.cell ? col.cell(row, i) : String(row[col.key] ?? '') }, col.key)))] }, key));
|
|
106
124
|
})) }), footer && _jsx(TableFooter, { children: footer(sortedData) })] }) }));
|
|
107
125
|
}
|
|
@@ -23,11 +23,23 @@ export function ToggleGroup({ children, className, disabled, size, type, variant
|
|
|
23
23
|
onValueChange?.(arr.includes(itemValue) ? arr.filter((v) => v !== itemValue) : [...arr, itemValue]);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
return (_jsx(ToggleGroupContext.Provider, { value: { type, value: currentValue, onValueChange: handleChange, size, variant, disabled }, children: _jsx("div", { role: 'group',
|
|
26
|
+
return (_jsx(ToggleGroupContext.Provider, { value: { type, value: currentValue, onValueChange: handleChange, size, variant, disabled }, children: _jsx("div", { role: 'group', "data-variant": variant ?? 'default', className: cn(variant === 'outline'
|
|
27
|
+
? // A segmented control (gaulatti/bleecker#557): the group owns the one rounded outline, and
|
|
28
|
+
// each segment after the first draws the single divider on its left (see the item), so
|
|
29
|
+
// hover, focus and selection change nothing but colour and nothing shifts.
|
|
30
|
+
'inline-flex items-stretch overflow-hidden rounded-[9px] border border-sand/30 dark:border-sand/40'
|
|
31
|
+
: 'inline-flex items-center gap-0.5 rounded-[9px] border border-sand/20 bg-light-sand/65 p-1 dark:border-white/[0.07] dark:bg-white/[0.05]', className), children: children }) }));
|
|
27
32
|
}
|
|
28
33
|
export function ToggleGroupItem({ children, className, disabled, size, value, variant, ...props }) {
|
|
29
34
|
const ctx = useToggleGroup();
|
|
30
35
|
const pressed = ctx.type === 'single' ? ctx.value === value : ctx.value.includes(value);
|
|
31
36
|
const isDisabled = disabled ?? ctx.disabled;
|
|
32
|
-
return (_jsx(Toggle, { pressed: pressed, onPressedChange: () => ctx.onValueChange(value), disabled: isDisabled, size: size ?? ctx.size, variant: variant ?? ctx.variant, className: cn(
|
|
37
|
+
return (_jsx(Toggle, { pressed: pressed, onPressedChange: () => ctx.onValueChange(value), disabled: isDisabled, size: size ?? ctx.size, variant: variant ?? ctx.variant, className: cn((variant ?? ctx.variant) === 'outline'
|
|
38
|
+
? // Inside an outline group a segment is square and draws no outline of its own; each segment
|
|
39
|
+
// after the first draws the one divider on its left, in the group's colour in every state
|
|
40
|
+
// (a pressed segment's colour never reaches it). The group's overflow and radius round the
|
|
41
|
+
// first and last, and the focus ring is drawn inside so it isn't clipped. Tailwind's
|
|
42
|
+
// divide-x on the group can't do this: its selector has zero specificity, so border-0 wins.
|
|
43
|
+
'rounded-none border-0 not-first:border-l not-first:border-sand/30 dark:not-first:border-sand/40 focus-visible:ring-inset'
|
|
44
|
+
: 'rounded-lg', className), ...props, children: children }));
|
|
33
45
|
}
|