@gaulatti/bleecker 0.1.45 → 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.
- package/README.md +4 -0
- package/dist/components/access-panel.d.ts +90 -0
- package/dist/components/access-panel.js +336 -0
- package/dist/components/arm-take.d.ts +17 -0
- package/dist/components/arm-take.js +93 -0
- package/dist/components/button.d.ts +1 -1
- package/dist/components/drawer.d.ts +20 -3
- package/dist/components/drawer.js +14 -2
- package/dist/components/key-cap.d.ts +7 -0
- package/dist/components/key-cap.js +10 -0
- package/dist/components/meter.d.ts +19 -0
- package/dist/components/meter.js +11 -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/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/package.json +1 -1
|
@@ -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;
|
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
|
}
|
|
@@ -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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './core/index';
|
|
2
2
|
export * from './tokens/index';
|
|
3
|
+
export * from './components/access-panel';
|
|
3
4
|
export * from './components/brand-lockup';
|
|
4
5
|
export * from './components/bauhaus-background';
|
|
5
6
|
export * from './components/activity-item';
|
|
@@ -56,6 +57,7 @@ export * from './components/eyebrow';
|
|
|
56
57
|
export * from './components/hover-card';
|
|
57
58
|
export * from './components/input';
|
|
58
59
|
export * from './components/kbd';
|
|
60
|
+
export * from './components/key-cap';
|
|
59
61
|
export * from './components/label';
|
|
60
62
|
export * from './components/menubar';
|
|
61
63
|
export * from './components/navigation-menu';
|
|
@@ -94,7 +96,13 @@ export * from './components/file-input';
|
|
|
94
96
|
export * from './components/section-header';
|
|
95
97
|
export * from './assets/logo';
|
|
96
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';
|
|
97
104
|
export * from './components/status-badge';
|
|
105
|
+
export * from './components/state-pill';
|
|
98
106
|
export * from './components/table';
|
|
99
107
|
export { DataTable as TanStackDataTable } from './components/data-table';
|
|
100
108
|
export * from './components/tabs';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './core/index.js';
|
|
2
2
|
export * from './tokens/index.js';
|
|
3
|
+
export * from './components/access-panel.js';
|
|
3
4
|
export * from './components/brand-lockup.js';
|
|
4
5
|
export * from './components/bauhaus-background.js';
|
|
5
6
|
export * from './components/activity-item.js';
|
|
@@ -56,6 +57,7 @@ export * from './components/eyebrow.js';
|
|
|
56
57
|
export * from './components/hover-card.js';
|
|
57
58
|
export * from './components/input.js';
|
|
58
59
|
export * from './components/kbd.js';
|
|
60
|
+
export * from './components/key-cap.js';
|
|
59
61
|
export * from './components/label.js';
|
|
60
62
|
export * from './components/menubar.js';
|
|
61
63
|
export * from './components/navigation-menu.js';
|
|
@@ -94,7 +96,13 @@ export * from './components/file-input.js';
|
|
|
94
96
|
export * from './components/section-header.js';
|
|
95
97
|
export * from './assets/logo.js';
|
|
96
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';
|
|
97
104
|
export * from './components/status-badge.js';
|
|
105
|
+
export * from './components/state-pill.js';
|
|
98
106
|
export * from './components/table.js';
|
|
99
107
|
export { DataTable as TanStackDataTable } from './components/data-table.js';
|
|
100
108
|
export * from './components/tabs.js';
|