@gaulatti/bleecker 0.1.46 → 0.1.47

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.
@@ -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
- export interface DrawerProps {
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
- export declare function Drawer({ children, className, description, isOpen, onClose, title }: DrawerProps): React.ReactPortal | null;
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({ children, className, description, isOpen, onClose, title }) {
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,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,19 @@
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
+ /** The live peak, in the same scale as `value`. */
9
+ peak?: number | null;
10
+ unit?: string;
11
+ value: number | null;
12
+ /** From here to `max` the scale is the warning zone, and a hold inside it turns red. */
13
+ warnFrom?: number;
14
+ }
15
+ /**
16
+ * A reading and its scale: a level between `min` and `max` with an optional live peak, a held peak
17
+ * and a warning zone. It does not animate; the page feeds it new values.
18
+ */
19
+ export declare function Meter({ className, hold, label, max, min, peak, unit, value, warnFrom }: MeterProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
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, 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
+ 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}` : ''}`, className: cn('relative h-1.5 overflow-hidden rounded-full bg-sand/30 dark:bg-sand/25', className), children: [warnFrom !== undefined ? _jsx("span", { "data-meter": 'warn', className: 'absolute inset-y-0 right-0 bg-terracotta/35', style: { left: `${at(warnFrom)}%` } }) : null, value !== null ? _jsx("span", { "data-meter": 'fill', className: 'absolute inset-y-0 left-0 bg-sea dark:bg-accent-blue', style: { width: `${at(value)}%` } }) : null, peak !== undefined && peak !== null ? _jsx("span", { "data-meter": 'peak', className: 'absolute inset-y-0 w-0.5 bg-text-primary/80', style: { left: `calc(${at(peak)}% - 1px)` } }) : null, hold !== undefined && hold !== null ? (_jsx("span", { "data-meter": 'hold', className: cn('absolute inset-y-0 w-0.5', warnFrom !== undefined && hold >= warnFrom ? 'bg-terracotta' : 'bg-accent-text dark:bg-accent-yellow'), style: { left: `calc(${at(hold)}% - 1px)` } })) : null] }));
11
+ }
@@ -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;
@@ -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
- return (_jsxs(TableRow, { "data-selected": isSelected, children: [selectable && (_jsx(TableCell, { children: _jsx(Checkbox, { checked: isSelected, onChange: (e) => toggleRow(key, e.target.checked), "aria-label": `Select row ${key}` }) })), columns.map((col) => (_jsx(TableCell, { className: cn(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));
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
  }
@@ -0,0 +1,29 @@
1
+ export interface TransportCue {
2
+ /** Where the cue sits, in seconds. */
3
+ at: number;
4
+ label: string;
5
+ }
6
+ export interface TransportProps {
7
+ className?: string;
8
+ /** Marks on the timeline, such as a song's cue in and cue out. */
9
+ cues?: TransportCue[];
10
+ disabled?: boolean;
11
+ /** Seconds, or null when the length is unknown (the timeline is then hidden). */
12
+ duration: number | null;
13
+ onNext?: () => void;
14
+ onPrev?: () => void;
15
+ /** Called with the new position in seconds. Without it the timeline is read only. */
16
+ onSeek?: (seconds: number) => void;
17
+ onToggle: () => void;
18
+ playing: boolean;
19
+ /** Seconds. */
20
+ position: number;
21
+ subtitle?: string;
22
+ title: string;
23
+ }
24
+ /**
25
+ * One shared transport for a list of audio: previous, play or pause, next, what is loaded, a
26
+ * timeline with cue marks, and the time. It is presentational: the page owns the audio element.
27
+ * Space toggles on the timeline, and the arrow keys seek by five seconds.
28
+ */
29
+ export declare function Transport({ className, cues, disabled, duration, onNext, onPrev, onSeek, onToggle, playing, position, subtitle, title }: TransportProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,59 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pause, Play, SkipBack, SkipForward } from 'lucide-react';
3
+ import React from 'react';
4
+ import { cn } from '../utils/cn.js';
5
+ const SEEK_STEP_SECONDS = 5;
6
+ function formatClock(seconds) {
7
+ if (seconds === null || !Number.isFinite(seconds))
8
+ return '—';
9
+ const whole = Math.max(0, Math.floor(seconds));
10
+ return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, '0')}`;
11
+ }
12
+ /**
13
+ * One shared transport for a list of audio: previous, play or pause, next, what is loaded, a
14
+ * timeline with cue marks, and the time. It is presentational: the page owns the audio element.
15
+ * Space toggles on the timeline, and the arrow keys seek by five seconds.
16
+ */
17
+ export function Transport({ className, cues = [], disabled = false, duration, onNext, onPrev, onSeek, onToggle, playing, position, subtitle, title }) {
18
+ const timeline = React.useRef(null);
19
+ const length = duration !== null && duration > 0 ? duration : null;
20
+ const clamped = length === null ? Math.max(0, position) : Math.min(Math.max(0, position), length);
21
+ const percent = (seconds, total) => Math.max(0, Math.min(100, (seconds / total) * 100));
22
+ const seekTo = (seconds) => {
23
+ if (!onSeek || length === null)
24
+ return;
25
+ onSeek(Math.max(0, Math.min(length, seconds)));
26
+ };
27
+ const onKeyDown = (event) => {
28
+ if (disabled)
29
+ return;
30
+ if (event.key === ' ') {
31
+ event.preventDefault();
32
+ onToggle();
33
+ }
34
+ else if (event.key === 'ArrowRight') {
35
+ event.preventDefault();
36
+ seekTo(clamped + SEEK_STEP_SECONDS);
37
+ }
38
+ else if (event.key === 'ArrowLeft') {
39
+ event.preventDefault();
40
+ seekTo(clamped - SEEK_STEP_SECONDS);
41
+ }
42
+ else if (event.key === 'Home') {
43
+ event.preventDefault();
44
+ seekTo(0);
45
+ }
46
+ else if (event.key === 'End' && length !== null) {
47
+ event.preventDefault();
48
+ seekTo(length);
49
+ }
50
+ };
51
+ const buttonClass = 'inline-flex h-8 w-8 items-center justify-center rounded-full text-text-secondary hover:bg-sand/20 hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-sea disabled:pointer-events-none disabled:opacity-40 dark:focus-visible:ring-accent-blue';
52
+ return (_jsxs("div", { role: 'group', "aria-label": 'Transport', className: cn('flex items-center gap-4 rounded-[var(--radius-card)] border border-sand/30 bg-light-sand/50 px-4 py-2.5 dark:border-white/10 dark:bg-white/[0.04]', className), children: [_jsxs("div", { className: 'flex items-center gap-1', children: [_jsx("button", { type: 'button', "aria-label": 'Previous', className: buttonClass, disabled: disabled || !onPrev, onClick: onPrev, children: _jsx(SkipBack, { size: 14, "aria-hidden": 'true' }) }), _jsx("button", { type: 'button', "aria-label": playing ? 'Pause' : 'Play', className: 'inline-flex h-9 w-9 items-center justify-center rounded-full bg-sea text-white hover:bg-deep-sea focus:outline-none focus-visible:ring-2 focus-visible:ring-sea focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-40 dark:bg-accent-blue dark:hover:bg-accent-blue/80 dark:focus-visible:ring-accent-blue', disabled: disabled, onClick: onToggle, children: playing ? _jsx(Pause, { size: 16, "aria-hidden": 'true' }) : _jsx(Play, { size: 16, "aria-hidden": 'true' }) }), _jsx("button", { type: 'button', "aria-label": 'Next', className: buttonClass, disabled: disabled || !onNext, onClick: onNext, children: _jsx(SkipForward, { size: 14, "aria-hidden": 'true' }) })] }), _jsxs("div", { className: 'min-w-0 basis-40', children: [_jsx("p", { className: 'truncate text-sm font-semibold text-text-primary', children: title }), subtitle ? _jsx("p", { className: 'truncate text-[11px] text-text-secondary', children: subtitle }) : null] }), length !== null ? (_jsxs("div", { ref: timeline, role: 'slider', tabIndex: disabled ? -1 : 0, "aria-label": 'Position', "aria-valuemin": 0, "aria-valuemax": Math.round(length), "aria-valuenow": Math.round(clamped), "aria-valuetext": `${formatClock(clamped)} of ${formatClock(length)}`, "aria-disabled": disabled || !onSeek, onKeyDown: onKeyDown, onClick: (event) => {
53
+ if (!onSeek || disabled || !timeline.current)
54
+ return;
55
+ const box = timeline.current.getBoundingClientRect();
56
+ if (box.width > 0)
57
+ seekTo(((event.clientX - box.left) / box.width) * length);
58
+ }, className: 'relative h-4 min-w-24 flex-1 cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-sea dark:focus-visible:ring-accent-blue', children: [_jsx("span", { className: 'absolute inset-x-0 top-1/2 h-[3px] -translate-y-1/2 rounded-full bg-sand/50 dark:bg-sand/40' }), _jsx("span", { "data-transport": 'done', className: 'absolute left-0 top-1/2 h-[3px] -translate-y-1/2 rounded-full bg-sea dark:bg-accent-blue', style: { width: `${percent(clamped, length)}%` } }), cues.map((cue) => (_jsx("span", { "data-transport": 'cue', title: cue.label, className: 'absolute top-0 h-full w-0.5 bg-accent-text dark:bg-accent-yellow', style: { left: `${percent(cue.at, length)}%` } }, `${cue.label}-${cue.at}`)))] })) : (_jsx("div", { className: 'flex-1' })), _jsxs("p", { className: 'shrink-0 font-mono text-xs tabular-nums text-text-secondary', children: [_jsx("b", { className: 'text-text-primary', children: formatClock(clamped) }), " / ", formatClock(length)] })] }));
59
+ }
package/dist/index.d.ts CHANGED
@@ -57,6 +57,7 @@ export * from './components/eyebrow';
57
57
  export * from './components/hover-card';
58
58
  export * from './components/input';
59
59
  export * from './components/kbd';
60
+ export * from './components/key-cap';
60
61
  export * from './components/label';
61
62
  export * from './components/menubar';
62
63
  export * from './components/navigation-menu';
@@ -95,7 +96,13 @@ export * from './components/file-input';
95
96
  export * from './components/section-header';
96
97
  export * from './assets/logo';
97
98
  export * from './components/panel';
99
+ export * from './components/arm-take';
100
+ export * from './components/meter';
101
+ export * from './components/on-air-strip';
102
+ export * from './components/segmented-filter';
103
+ export * from './components/transport';
98
104
  export * from './components/status-badge';
105
+ export * from './components/state-pill';
99
106
  export * from './components/table';
100
107
  export { DataTable as TanStackDataTable } from './components/data-table';
101
108
  export * from './components/tabs';
package/dist/index.js CHANGED
@@ -57,6 +57,7 @@ export * from './components/eyebrow.js';
57
57
  export * from './components/hover-card.js';
58
58
  export * from './components/input.js';
59
59
  export * from './components/kbd.js';
60
+ export * from './components/key-cap.js';
60
61
  export * from './components/label.js';
61
62
  export * from './components/menubar.js';
62
63
  export * from './components/navigation-menu.js';
@@ -95,7 +96,13 @@ export * from './components/file-input.js';
95
96
  export * from './components/section-header.js';
96
97
  export * from './assets/logo.js';
97
98
  export * from './components/panel.js';
99
+ export * from './components/arm-take.js';
100
+ export * from './components/meter.js';
101
+ export * from './components/on-air-strip.js';
102
+ export * from './components/segmented-filter.js';
103
+ export * from './components/transport.js';
98
104
  export * from './components/status-badge.js';
105
+ export * from './components/state-pill.js';
99
106
  export * from './components/table.js';
100
107
  export { DataTable as TanStackDataTable } from './components/data-table.js';
101
108
  export * from './components/tabs.js';