@xenosystem/elements-react 0.0.10 → 0.0.11

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.
Files changed (65) hide show
  1. package/dist/containers/Avatar.d.ts +8 -1
  2. package/dist/containers/Avatar.js +3 -3
  3. package/dist/containers/BulkActionBar.d.ts +20 -0
  4. package/dist/containers/BulkActionBar.js +8 -0
  5. package/dist/containers/DataTable.d.ts +50 -6
  6. package/dist/containers/DataTable.js +185 -11
  7. package/dist/containers/Table.d.ts +2 -2
  8. package/dist/containers/Table.js +4 -3
  9. package/dist/content/Kbd.d.ts +16 -0
  10. package/dist/content/Kbd.js +8 -0
  11. package/dist/index.d.ts +12 -1
  12. package/dist/index.js +12 -1
  13. package/dist/nav/Breadcrumb.d.ts +22 -0
  14. package/dist/nav/Breadcrumb.js +10 -0
  15. package/dist/overlays/CommandPalette.d.ts +43 -0
  16. package/dist/overlays/CommandPalette.js +96 -0
  17. package/dist/overlays/Popover.d.ts +27 -12
  18. package/dist/overlays/Popover.js +101 -7
  19. package/dist/overlays/ShortcutsSheet.d.ts +21 -0
  20. package/dist/overlays/ShortcutsSheet.js +7 -0
  21. package/dist/overlays/Tooltip.d.ts +21 -10
  22. package/dist/overlays/Tooltip.js +93 -9
  23. package/dist/shortcuts.d.ts +45 -0
  24. package/dist/shortcuts.js +164 -0
  25. package/dist/status/Banner.d.ts +23 -0
  26. package/dist/status/Banner.js +8 -0
  27. package/dist/status/Toast.d.ts +28 -0
  28. package/dist/status/Toast.js +11 -0
  29. package/dist/uiTree.d.ts +53 -0
  30. package/dist/uiTree.js +197 -0
  31. package/dist/useDialog.d.ts +3 -1
  32. package/dist/useDialog.js +37 -1
  33. package/dist/useMenu.js +31 -1
  34. package/dist/useToastQueue.d.ts +29 -0
  35. package/dist/useToastQueue.js +73 -0
  36. package/package.json +9 -3
  37. package/src/chrome-separated.css +133 -72
  38. package/src/chrome-unified.css +48 -16
  39. package/src/containers/Badges.css +52 -28
  40. package/src/containers/avatar.css +7 -2
  41. package/src/containers/bulk-action-bar.css +45 -0
  42. package/src/containers/card.css +14 -13
  43. package/src/containers/chip.css +1 -1
  44. package/src/containers/panel.css +16 -53
  45. package/src/containers/table.css +107 -1
  46. package/src/content/kbd.css +33 -0
  47. package/src/content/model-picker.css +2 -1
  48. package/src/controls.css +25 -11
  49. package/src/fonts.css +8 -2
  50. package/src/forced-colors.css +41 -0
  51. package/src/layout-platform.css +473 -0
  52. package/src/mcp-app-platform.css +1019 -0
  53. package/src/nav/breadcrumb.css +84 -0
  54. package/src/overlays/command-palette.css +157 -0
  55. package/src/overlays/menu.css +25 -16
  56. package/src/overlays/modal.css +9 -27
  57. package/src/overlays/onboarding.css +1305 -0
  58. package/src/overlays/segmented-control.css +6 -3
  59. package/src/overlays/shortcuts-sheet.css +55 -0
  60. package/src/overlays/tooltip.css +22 -4
  61. package/src/size.css +40 -0
  62. package/src/status/banner.css +83 -0
  63. package/src/status/toast.css +95 -0
  64. package/src/xeno-elements.css +63 -44
  65. package/src/xeno-theme.css +75 -31
@@ -18,8 +18,15 @@ export interface AvatarProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'chil
18
18
  readonly icon?: ElementDeclaration;
19
19
  /** Accessible label / image alt. Falls back to `name`, then a generic label. */
20
20
  readonly alt?: string;
21
+ /**
22
+ * How many letters the initials fallback draws: 2 (default) or 1. An {@link AvatarStack} draws 1,
23
+ * because overlapping tiles hide the left of every tile but the first, and a two-letter monogram
24
+ * then reads as half a letter ("MK" showed as "|U"). The owner's design references draw one letter
25
+ * in every stack. The accessible label is the full name either way.
26
+ */
27
+ readonly initials?: 1 | 2;
21
28
  }
22
- export declare function Avatar({ size, src, name, icon, alt, className, style, ...rest }: AvatarProps): ReactElement;
29
+ export declare function Avatar({ size, src, name, icon, alt, initials, className, style, ...rest }: AvatarProps): ReactElement;
23
30
  /** One entry in an {@link AvatarStack} — the same content priority as {@link Avatar}. */
24
31
  export interface AvatarStackItem {
25
32
  readonly src?: string;
@@ -14,16 +14,16 @@ const initialsOf = (name) => {
14
14
  const last = parts[parts.length - 1] ?? '';
15
15
  return (first.charAt(0) + last.charAt(0)).toUpperCase();
16
16
  };
17
- export function Avatar({ size = 24, src, name, icon, alt, className, style, ...rest }) {
17
+ export function Avatar({ size = 24, src, name, icon, alt, initials = 2, className, style, ...rest }) {
18
18
  const variant = src !== undefined ? 'image' : icon !== undefined ? 'icon' : name !== undefined ? 'initials' : 'empty';
19
19
  const label = alt ?? name ?? 'Avatar';
20
20
  const rootStyle = { ['--xeno-avatar-size']: `${size}px`, ...style };
21
- const content = src !== undefined ? (_jsx("img", { className: "xeno-avatar-img", src: src, alt: "", draggable: false })) : icon !== undefined ? (_jsx(XenoElement, { decl: icon, size: Math.round(size * 0.58) })) : name !== undefined ? (_jsx("span", { className: "xeno-avatar-initials", "aria-hidden": "true", children: initialsOf(name) })) : null;
21
+ const content = src !== undefined ? (_jsx("img", { className: "xeno-avatar-img", src: src, alt: "", draggable: false })) : icon !== undefined ? (_jsx(XenoElement, { decl: icon, size: Math.round(size * 0.58) })) : name !== undefined ? (_jsx("span", { className: "xeno-avatar-initials", "aria-hidden": "true", children: initials === 1 ? initialsOf(name).charAt(0) : initialsOf(name) })) : null;
22
22
  return (_jsx("span", { className: cx('xeno-avatar', className), "data-variant": variant, role: "img", "aria-label": label, style: rootStyle, ...rest, children: content }));
23
23
  }
24
24
  export function AvatarStack({ items, max = 4, size = 24, className, style, ...rest }) {
25
25
  const visible = items.slice(0, max);
26
26
  const overflow = items.length - visible.length;
27
27
  const rootStyle = { ['--xeno-avatar-size']: `${size}px`, ...style };
28
- return (_jsxs("div", { className: cx('xeno-avatar-stack', className), role: "group", style: rootStyle, ...rest, children: [visible.map((item, i) => (_jsx(Avatar, { size: size, style: { zIndex: visible.length - i }, ...(item.src !== undefined ? { src: item.src } : {}), ...(item.name !== undefined ? { name: item.name } : {}), ...(item.icon !== undefined ? { icon: item.icon } : {}) }, i))), overflow > 0 ? (_jsx("span", { className: "xeno-avatar xeno-avatar-more", "data-variant": "more", role: "img", "aria-label": `${overflow} more`, style: { ['--xeno-avatar-size']: `${size}px`, zIndex: 0 }, children: _jsxs("span", { className: "xeno-avatar-initials", "aria-hidden": "true", children: ["+", overflow] }) })) : null] }));
28
+ return (_jsxs("div", { className: cx('xeno-avatar-stack', className), role: "group", style: rootStyle, ...rest, children: [visible.map((item, i) => (_jsx(Avatar, { size: size, initials: 1, style: { zIndex: visible.length - i }, ...(item.src !== undefined ? { src: item.src } : {}), ...(item.name !== undefined ? { name: item.name } : {}), ...(item.icon !== undefined ? { icon: item.icon } : {}) }, i))), overflow > 0 ? (_jsx("span", { className: "xeno-avatar xeno-avatar-more", "data-variant": "more", role: "img", "aria-label": `${overflow} more`, style: { ['--xeno-avatar-size']: `${size}px`, zIndex: 0 }, children: _jsxs("span", { className: "xeno-avatar-initials", "aria-hidden": "true", children: ["+", overflow] }) })) : null] }));
29
29
  }
@@ -0,0 +1,20 @@
1
+ import type { HTMLAttributes, ReactElement, ReactNode } from 'react';
2
+ /**
3
+ * `<BulkActionBar>` — contextual selection strip shown above tables/lists when one or more rows
4
+ * are selected (Corpus Tenets bulk bar in `--xeno-info-soft`, Desktop Files bulk bar).
5
+ */
6
+ export interface BulkActionBarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
7
+ /** Number of selected items. Renders nothing when `<= 0` unless `alwaysShow` is true. */
8
+ readonly count: number;
9
+ /** Singular/plural noun, or custom summary node. Default `'selected'`. */
10
+ readonly label?: ReactNode;
11
+ /** Primary/secondary action buttons for the selection. */
12
+ readonly children?: ReactNode;
13
+ /** Called when the clear button is pressed. */
14
+ readonly onClear?: () => void;
15
+ /** Clear button label. Default `'Clear selection'`. */
16
+ readonly clearLabel?: string;
17
+ /** Keep mounted even when `count === 0`. */
18
+ readonly alwaysShow?: boolean;
19
+ }
20
+ export declare function BulkActionBar({ count, label, children, onClear, clearLabel, alwaysShow, className, ...rest }: BulkActionBarProps): ReactElement | null;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button } from '../controls/Button.js';
3
+ import { cx } from '../controls/util.js';
4
+ export function BulkActionBar({ count, label = 'selected', children, onClear, clearLabel = 'Clear selection', alwaysShow = false, className, ...rest }) {
5
+ if (count <= 0 && !alwaysShow)
6
+ return null;
7
+ return (_jsxs("div", { className: cx('xeno-bulk-bar', className), role: "region", "aria-label": "Bulk selection actions", "aria-live": "polite", ...rest, children: [_jsxs("span", { className: "xeno-bulk-bar-count", children: [_jsx("span", { className: "xeno-bulk-bar-num", children: count }), " ", label] }), _jsx("div", { className: "xeno-bulk-bar-actions", children: children }), onClear ? (_jsx(Button, { size: "xs", variant: "ghost", className: "xeno-bulk-bar-clear", onClick: onClear, children: clearLabel })) : null] }));
8
+ }
@@ -1,12 +1,22 @@
1
1
  import type { ReactElement, ReactNode, TableHTMLAttributes } from 'react';
2
2
  import { type ColumnAlign } from './Table.js';
3
3
  /**
4
- * `<DataTable>` — the column/row convenience over the {@link Table} primitives. Purely presentational:
5
- * you hand it `columns` (a header, an optional `render`, an optional `align`) and `rows`; it draws the
6
- * locked dense table for you. A column with no `render` reads `row[column.key]` verbatim. Row identity
7
- * comes from `getRowKey` (falls back to the index). When `rows` is empty and `empty` is supplied, a
8
- * single muted, column-spanning cell is drawn instead of an empty body.
4
+ * `<DataTable>` — production data table over {@link Table} primitives.
5
+ *
6
+ * Supports:
7
+ * - **Column sorting** (`col.sortable`, controlled `sort`/`onSortChange` or uncontrolled, `aria-sort`).
8
+ * - **Multi-row selection** (`selectable`, `selectedKeys`, `onSelectionChange`, header select-all / mixed).
9
+ * - **Sticky headers** (`stickyHeader`).
10
+ * - **Single delegated keyboard handler** on `<TBody>` (`ArrowDown`/`ArrowUp`/`Home`/`End`/`Enter`/`Space`),
11
+ * avoiding per-row listener closures at scale (GitHub Engineering 2026).
12
+ * - **Selective virtualization** (`virtualizeAbove`, default 2,500 rows): preserves native browser
13
+ * `Ctrl+F` on everyday tables while capping DOM nodes on 10,000+ row tables.
9
14
  */
15
+ export type DataTableSortDirection = 'asc' | 'desc';
16
+ export interface DataTableSort {
17
+ readonly key: string;
18
+ readonly direction: DataTableSortDirection;
19
+ }
10
20
  export interface DataTableColumn<T> {
11
21
  /** Stable column id; also the property read from the row when `render` is absent. */
12
22
  readonly key: string;
@@ -16,6 +26,16 @@ export interface DataTableColumn<T> {
16
26
  readonly render?: (row: T, rowIndex: number) => ReactNode;
17
27
  /** Cell text alignment for both the header and the column's body cells. */
18
28
  readonly align?: ColumnAlign;
29
+ /** Enable interactive sorting on this column. */
30
+ readonly sortable?: boolean;
31
+ /** Custom comparable value extractor for sorting (defaults to `row[key]`). */
32
+ readonly sortValue?: (row: T) => string | number;
33
+ /** Optional explicit width (e.g. `84px`, `120px`). */
34
+ readonly width?: string;
35
+ /** Minimum pixel width when `resizable` is enabled. Default `64`. */
36
+ readonly minWidth?: number;
37
+ /** Disable resizing for this individual column when table `resizable` is true. */
38
+ readonly resizable?: boolean;
19
39
  }
20
40
  export interface DataTableProps<T> extends Omit<TableHTMLAttributes<HTMLTableElement>, 'children'> {
21
41
  readonly columns: readonly DataTableColumn<T>[];
@@ -24,5 +44,29 @@ export interface DataTableProps<T> extends Omit<TableHTMLAttributes<HTMLTableEle
24
44
  readonly getRowKey?: (row: T, index: number) => string | number;
25
45
  /** Shown (column-spanning, muted) when `rows` is empty. */
26
46
  readonly empty?: ReactNode;
47
+ /** Controlled sort state. Omit for internal uncontrolled sorting when columns are `sortable`. */
48
+ readonly sort?: DataTableSort | null;
49
+ /** Called when a sortable header is clicked. */
50
+ readonly onSortChange?: (next: DataTableSort | null) => void;
51
+ /** Show a leading selection checkbox column (with select-all header). */
52
+ readonly selectable?: boolean;
53
+ /** Controlled selected row keys. */
54
+ readonly selectedKeys?: ReadonlySet<string | number>;
55
+ /** Called when selection changes. */
56
+ readonly onSelectionChange?: (next: Set<string | number>) => void;
57
+ /** Called when a row is activated via click or Enter. */
58
+ readonly onRowActivate?: (row: T, key: string | number) => void;
59
+ /** Keep header row pinned during vertical scroll. */
60
+ readonly stickyHeader?: boolean;
61
+ /** Allow interactive column width resizing via header drag handles or keyboard arrows. */
62
+ readonly resizable?: boolean;
63
+ /** Called when a column is resized to a new pixel width. */
64
+ readonly onColumnResize?: (columnKey: string, widthPx: number) => void;
65
+ /** Enable windowed row virtualization when `rows.length >= virtualizeAbove`. Default `2500`. */
66
+ readonly virtualizeAbove?: number;
67
+ /** Scroll viewport height in px when virtualizing. Default `420`. */
68
+ readonly viewportHeight?: number;
69
+ /** Estimated row height in px for virtualization geometry. Default `36`. */
70
+ readonly rowHeight?: number;
27
71
  }
28
- export declare function DataTable<T>({ columns, rows, getRowKey, empty, ...rest }: DataTableProps<T>): ReactElement;
72
+ export declare function DataTable<T>({ columns, rows, getRowKey, empty, sort: controlledSort, onSortChange, selectable, selectedKeys: controlledSelected, onSelectionChange, onRowActivate, stickyHeader, resizable, onColumnResize, virtualizeAbove, viewportHeight, rowHeight, className, ...rest }: DataTableProps<T>): ReactElement;
@@ -1,13 +1,187 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useCallback, useMemo, useRef, useState } from 'react';
3
+ import ChevronUp from '@xenosystem/elements/elements/chevron-up';
4
+ import ChevronDown from '@xenosystem/elements/elements/chevron-down';
5
+ import ChevronsUpDown from '@xenosystem/elements/elements/chevrons-up-down';
6
+ import { XenoElement } from '../XenoElement.js';
7
+ import { Checkbox } from '../forms/Checkbox.js';
2
8
  import { Table, THead, TBody, Tr, Th, Td } from './Table.js';
3
- export function DataTable({ columns, rows, getRowKey, empty, ...rest }) {
4
- return (_jsxs(Table, { ...rest, children: [_jsx(THead, { children: _jsx(Tr, { children: columns.map((col) => (_jsx(Th, { ...(col.align !== undefined ? { align: col.align } : {}), children: col.header }, col.key))) }) }), _jsx(TBody, { children: rows.length === 0 && empty !== undefined ? (_jsx(Tr, { children: _jsx(Td, { className: "xeno-table-empty", colSpan: columns.length, children: empty }) })) : (rows.map((row, rowIndex) => {
5
- const key = getRowKey ? getRowKey(row, rowIndex) : rowIndex;
6
- return (_jsx(Tr, { children: columns.map((col) => {
7
- const content = col.render
8
- ? col.render(row, rowIndex)
9
- : row[col.key];
10
- return (_jsx(Td, { ...(col.align !== undefined ? { align: col.align } : {}), children: content }, col.key));
11
- }) }, key));
12
- })) })] }));
9
+ const OVERSCAN = 8;
10
+ function compareValues(a, b) {
11
+ if (a === b)
12
+ return 0;
13
+ if (a == null)
14
+ return 1;
15
+ if (b == null)
16
+ return -1;
17
+ if (typeof a === 'number' && typeof b === 'number')
18
+ return a - b;
19
+ return String(a).localeCompare(String(b), undefined, { numeric: true, sensitivity: 'base' });
20
+ }
21
+ export function DataTable({ columns, rows, getRowKey, empty, sort: controlledSort, onSortChange, selectable = false, selectedKeys: controlledSelected, onSelectionChange, onRowActivate, stickyHeader = false, resizable = false, onColumnResize, virtualizeAbove = 2500, viewportHeight = 420, rowHeight = 36, className, ...rest }) {
22
+ const [internalSort, setInternalSort] = useState(null);
23
+ const [internalSelected, setInternalSelected] = useState(() => new Set());
24
+ const [colWidths, setColWidths] = useState({});
25
+ const [scrollTop, setScrollTop] = useState(0);
26
+ const tbodyRef = useRef(null);
27
+ const commitColumnWidth = useCallback((colKey, nextPx, minWidth = 64) => {
28
+ const clamped = Math.max(minWidth, Math.round(nextPx));
29
+ setColWidths((prev) => ({ ...prev, [colKey]: clamped }));
30
+ onColumnResize?.(colKey, clamped);
31
+ }, [onColumnResize]);
32
+ const startColumnResize = useCallback((e, col) => {
33
+ e.preventDefault();
34
+ e.stopPropagation();
35
+ const th = e.currentTarget.closest('th');
36
+ const startX = e.clientX;
37
+ const startWidth = colWidths[col.key] ?? th?.getBoundingClientRect().width ?? 120;
38
+ const minW = col.minWidth ?? 64;
39
+ const onMove = (ev) => {
40
+ commitColumnWidth(col.key, startWidth + (ev.clientX - startX), minW);
41
+ };
42
+ const onUp = () => {
43
+ window.removeEventListener('pointermove', onMove);
44
+ window.removeEventListener('pointerup', onUp);
45
+ };
46
+ window.addEventListener('pointermove', onMove);
47
+ window.addEventListener('pointerup', onUp);
48
+ }, [colWidths, commitColumnWidth]);
49
+ const activeSort = controlledSort !== undefined ? controlledSort : internalSort;
50
+ const selected = controlledSelected !== undefined ? controlledSelected : internalSelected;
51
+ const updateSort = useCallback((colKey) => {
52
+ const next = !activeSort || activeSort.key !== colKey
53
+ ? { key: colKey, direction: 'asc' }
54
+ : activeSort.direction === 'asc'
55
+ ? { key: colKey, direction: 'desc' }
56
+ : null;
57
+ if (controlledSort === undefined)
58
+ setInternalSort(next);
59
+ onSortChange?.(next);
60
+ }, [activeSort, controlledSort, onSortChange]);
61
+ const updateSelection = useCallback((next) => {
62
+ if (controlledSelected === undefined)
63
+ setInternalSelected(next);
64
+ onSelectionChange?.(next);
65
+ }, [controlledSelected, onSelectionChange]);
66
+ const sortedEntries = useMemo(() => {
67
+ const entries = rows.map((row, index) => ({
68
+ row,
69
+ index,
70
+ key: getRowKey ? getRowKey(row, index) : index,
71
+ }));
72
+ if (!activeSort)
73
+ return entries;
74
+ const col = columns.find((c) => c.key === activeSort.key);
75
+ if (!col)
76
+ return entries;
77
+ const dir = activeSort.direction === 'asc' ? 1 : -1;
78
+ return [...entries].sort((a, b) => {
79
+ const av = col.sortValue ? col.sortValue(a.row) : a.row[col.key];
80
+ const bv = col.sortValue ? col.sortValue(b.row) : b.row[col.key];
81
+ return compareValues(av, bv) * dir;
82
+ });
83
+ }, [rows, getRowKey, activeSort, columns]);
84
+ const allSelected = sortedEntries.length > 0 && sortedEntries.every((e) => selected.has(e.key));
85
+ const someSelected = !allSelected && sortedEntries.some((e) => selected.has(e.key));
86
+ const toggleAll = useCallback(() => {
87
+ if (allSelected) {
88
+ updateSelection(new Set());
89
+ }
90
+ else {
91
+ updateSelection(new Set(sortedEntries.map((e) => e.key)));
92
+ }
93
+ }, [allSelected, sortedEntries, updateSelection]);
94
+ const toggleKey = useCallback((key) => {
95
+ const next = new Set(selected);
96
+ if (next.has(key))
97
+ next.delete(key);
98
+ else
99
+ next.add(key);
100
+ updateSelection(next);
101
+ }, [selected, updateSelection]);
102
+ const isVirtualized = sortedEntries.length >= virtualizeAbove;
103
+ const startIndex = isVirtualized ? Math.max(0, Math.floor(scrollTop / rowHeight) - OVERSCAN) : 0;
104
+ const visibleCount = isVirtualized ? Math.ceil(viewportHeight / rowHeight) + OVERSCAN * 2 : sortedEntries.length;
105
+ const endIndex = isVirtualized ? Math.min(sortedEntries.length, startIndex + visibleCount) : sortedEntries.length;
106
+ const slice = isVirtualized ? sortedEntries.slice(startIndex, endIndex) : sortedEntries;
107
+ const topPad = isVirtualized ? startIndex * rowHeight : 0;
108
+ const bottomPad = isVirtualized ? Math.max(0, (sortedEntries.length - endIndex) * rowHeight) : 0;
109
+ const totalColSpan = columns.length + (selectable ? 1 : 0);
110
+ // Single delegated keyboard handler on <TBody> — zero per-row listener closures.
111
+ const onBodyKeyDown = useCallback((e) => {
112
+ const tr = e.target.closest('tr[data-row-idx]');
113
+ if (!tr || !tbodyRef.current)
114
+ return;
115
+ const rowEls = Array.from(tbodyRef.current.querySelectorAll('tr[data-row-idx]'));
116
+ const pos = rowEls.indexOf(tr);
117
+ if (pos < 0)
118
+ return;
119
+ if (e.key === 'ArrowDown') {
120
+ e.preventDefault();
121
+ rowEls[Math.min(rowEls.length - 1, pos + 1)]?.focus();
122
+ }
123
+ else if (e.key === 'ArrowUp') {
124
+ e.preventDefault();
125
+ rowEls[Math.max(0, pos - 1)]?.focus();
126
+ }
127
+ else if (e.key === 'Home') {
128
+ e.preventDefault();
129
+ rowEls[0]?.focus();
130
+ }
131
+ else if (e.key === 'End') {
132
+ e.preventDefault();
133
+ rowEls[rowEls.length - 1]?.focus();
134
+ }
135
+ else if (e.key === 'Enter' || (e.key === ' ' && selectable && e.target === tr)) {
136
+ e.preventDefault();
137
+ const idx = Number(tr.dataset.rowIdx);
138
+ const entry = sortedEntries[idx];
139
+ if (!entry)
140
+ return;
141
+ if (e.key === ' ' && selectable)
142
+ toggleKey(entry.key);
143
+ else
144
+ onRowActivate?.(entry.row, entry.key);
145
+ }
146
+ }, [sortedEntries, selectable, toggleKey, onRowActivate]);
147
+ const tableEl = (_jsxs(Table, { className: className, "data-sticky-header": stickyHeader || isVirtualized ? 'true' : undefined, "data-virtualized": isVirtualized ? 'true' : undefined, ...rest, children: [_jsx(THead, { children: _jsxs(Tr, { children: [selectable ? (_jsx(Th, { className: "xeno-th-select", style: { width: '36px' }, children: _jsx(Checkbox, { checked: allSelected ? true : someSelected ? 'mixed' : false, onCheckedChange: toggleAll, "aria-label": "Select all rows" }) })) : null, columns.map((col) => {
148
+ const isSorted = activeSort?.key === col.key;
149
+ const ariaSort = col.sortable
150
+ ? isSorted
151
+ ? activeSort.direction === 'asc'
152
+ ? 'ascending'
153
+ : 'descending'
154
+ : 'none'
155
+ : undefined;
156
+ const resolvedWidth = colWidths[col.key] !== undefined ? `${colWidths[col.key]}px` : col.width;
157
+ const canResize = resizable && col.resizable !== false;
158
+ return (_jsxs(Th, { "aria-sort": ariaSort, className: canResize ? 'xeno-th-resizable' : undefined, style: resolvedWidth ? { width: resolvedWidth } : undefined, ...(col.align !== undefined ? { align: col.align } : {}), children: [col.sortable ? (_jsxs("button", { type: "button", className: "xeno-th-sort", onClick: () => updateSort(col.key), children: [_jsx("span", { children: col.header }), _jsx("span", { className: "xeno-th-sort-mark", "aria-hidden": "true", children: _jsx(XenoElement, { decl: isSorted
159
+ ? activeSort.direction === 'asc'
160
+ ? ChevronUp
161
+ : ChevronDown
162
+ : ChevronsUpDown, size: 12 }) })] })) : (col.header), canResize ? (_jsx("span", { role: "separator", "aria-orientation": "vertical", "aria-label": `Resize ${String(col.key)} column`, tabIndex: 0, className: "xeno-th-resizer", onPointerDown: (e) => startColumnResize(e, col), onKeyDown: (e) => {
163
+ const cur = colWidths[col.key] ?? (parseInt(col.width ?? '120', 10) || 120);
164
+ if (e.key === 'ArrowRight') {
165
+ e.preventDefault();
166
+ commitColumnWidth(col.key, cur + 16, col.minWidth ?? 64);
167
+ }
168
+ else if (e.key === 'ArrowLeft') {
169
+ e.preventDefault();
170
+ commitColumnWidth(col.key, cur - 16, col.minWidth ?? 64);
171
+ }
172
+ } })) : null] }, col.key));
173
+ })] }) }), _jsx(TBody, { ref: tbodyRef, onKeyDown: onBodyKeyDown, children: sortedEntries.length === 0 && empty !== undefined ? (_jsx(Tr, { children: _jsx(Td, { className: "xeno-table-empty", colSpan: totalColSpan, children: empty }) })) : (_jsxs(_Fragment, { children: [topPad > 0 ? (_jsx("tr", { "aria-hidden": "true", className: "xeno-tr-spacer", children: _jsx("td", { colSpan: totalColSpan, style: { height: topPad, padding: 0, border: 0 } }) })) : null, slice.map((entry, localIdx) => {
174
+ const absIdx = startIndex + localIdx;
175
+ const isSelected = selected.has(entry.key);
176
+ return (_jsxs(Tr, { selected: isSelected, "data-row-idx": absIdx, tabIndex: selectable || onRowActivate ? 0 : undefined, style: isVirtualized ? { height: rowHeight } : undefined, onClick: onRowActivate ? () => onRowActivate(entry.row, entry.key) : undefined, children: [selectable ? (_jsx(Td, { className: "xeno-td-select", onClick: (e) => e.stopPropagation(), children: _jsx(Checkbox, { checked: isSelected, onCheckedChange: () => toggleKey(entry.key), "aria-label": `Select row ${String(entry.key)}` }) })) : null, columns.map((col) => {
177
+ const content = col.render
178
+ ? col.render(entry.row, entry.index)
179
+ : entry.row[col.key];
180
+ return (_jsx(Td, { ...(col.align !== undefined ? { align: col.align } : {}), children: content }, col.key));
181
+ })] }, entry.key));
182
+ }), bottomPad > 0 ? (_jsx("tr", { "aria-hidden": "true", className: "xeno-tr-spacer", children: _jsx("td", { colSpan: totalColSpan, style: { height: bottomPad, padding: 0, border: 0 } }) })) : null] })) })] }));
183
+ if (!isVirtualized) {
184
+ return _jsx("div", { className: "xeno-table-scroll", children: tableEl });
185
+ }
186
+ return (_jsx("div", { className: "xeno-table-viewport", style: { maxHeight: viewportHeight, overflow: 'auto' }, onScroll: (e) => setScrollTop(e.currentTarget.scrollTop), children: tableEl }));
13
187
  }
@@ -1,4 +1,4 @@
1
- import type { HTMLAttributes, ReactElement, ReactNode, TableHTMLAttributes, TdHTMLAttributes, ThHTMLAttributes } from 'react';
1
+ import { type HTMLAttributes, type ReactElement, type ReactNode, type TableHTMLAttributes, type TdHTMLAttributes, type ThHTMLAttributes } from 'react';
2
2
  /**
3
3
  * Dense table PRIMITIVES — the thin, purely-presentational wrappers over the native table elements
4
4
  * (`table`/`thead`/`tbody`/`tr`/`th`/`td`). They carry only the `xeno-*` classes so the locked table
@@ -20,7 +20,7 @@ export declare function THead({ className, children, ...rest }: THeadProps): Rea
20
20
  export interface TBodyProps extends HTMLAttributes<HTMLTableSectionElement> {
21
21
  readonly children?: ReactNode;
22
22
  }
23
- export declare function TBody({ className, children, ...rest }: TBodyProps): ReactElement;
23
+ export declare const TBody: import("react").ForwardRefExoticComponent<TBodyProps & import("react").RefAttributes<HTMLTableSectionElement>>;
24
24
  export interface TrProps extends HTMLAttributes<HTMLTableRowElement> {
25
25
  /** Presentational selection state — rides the `selection` axis. Omit for a plain row. */
26
26
  readonly selected?: boolean;
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, } from 'react';
2
3
  import { cx } from '../controls/util.js';
3
4
  export function Table({ className, children, ...rest }) {
4
5
  return (_jsx("table", { className: cx('xeno-table', className), ...rest, children: children }));
@@ -6,9 +7,9 @@ export function Table({ className, children, ...rest }) {
6
7
  export function THead({ className, children, ...rest }) {
7
8
  return (_jsx("thead", { className: cx('xeno-thead', className), ...rest, children: children }));
8
9
  }
9
- export function TBody({ className, children, ...rest }) {
10
- return (_jsx("tbody", { className: cx('xeno-tbody', className), ...rest, children: children }));
11
- }
10
+ export const TBody = forwardRef(function TBody({ className, children, ...rest }, ref) {
11
+ return (_jsx("tbody", { ref: ref, className: cx('xeno-tbody', className), ...rest, children: children }));
12
+ });
12
13
  export function Tr({ selected, className, children, ...rest }) {
13
14
  return (_jsx("tr", { className: cx('xeno-tr', className), "data-selection": selected === undefined ? undefined : selected ? 'on' : 'off', "aria-selected": selected, ...rest, children: children }));
14
15
  }
@@ -0,0 +1,16 @@
1
+ import type { HTMLAttributes, ReactElement, ReactNode } from 'react';
2
+ /**
3
+ * `<Kbd>` — a keyboard shortcut hint (`⌘K`, `Esc`, `⇧⌘P`), measured from all five references
4
+ * (header palette trigger, command palette rows, shortcuts sheet, composer send hint).
5
+ *
6
+ * Pass `keys` for a multi-key chord (`['⌘', 'K']`), or `children` for a single cap.
7
+ */
8
+ export interface KbdProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
9
+ /** Ordered key caps in a chord, rendered as individual `<kbd>` elements inside a `<span class="xeno-kbd-group">`. */
10
+ readonly keys?: readonly string[];
11
+ /** Single key label when `keys` is not provided. */
12
+ readonly children?: ReactNode;
13
+ /** Visual size: `sm` (18px, inline/header) or `md` (20px, shortcuts sheet). Default `sm`. */
14
+ readonly size?: 'sm' | 'md';
15
+ }
16
+ export declare function Kbd({ keys, children, size, className, ...rest }: KbdProps): ReactElement;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx } from '../controls/util.js';
3
+ export function Kbd({ keys, children, size = 'sm', className, ...rest }) {
4
+ if (keys && keys.length > 0) {
5
+ return (_jsx("span", { className: cx('xeno-kbd-group', className), "data-size": size, ...rest, children: keys.map((key, index) => (_jsx("kbd", { className: "xeno-kbd", "data-size": size, children: key }, `${key}-${index}`))) }));
6
+ }
7
+ return (_jsx("kbd", { className: cx('xeno-kbd', className), "data-size": size, ...rest, children: children }));
8
+ }
package/dist/index.d.ts CHANGED
@@ -43,7 +43,8 @@ export { Avatar, type AvatarProps } from './containers/Avatar.js';
43
43
  export { AvatarStack, type AvatarStackProps, type AvatarStackItem } from './containers/Avatar.js';
44
44
  export { ListRow, type ListRowProps } from './containers/ListRow.js';
45
45
  export { Table, type TableProps, THead, type THeadProps, TBody, type TBodyProps, Tr, type TrProps, Th, type ThProps, Td, type TdProps, type ColumnAlign, } from './containers/Table.js';
46
- export { DataTable, type DataTableProps, type DataTableColumn } from './containers/DataTable.js';
46
+ export { DataTable, type DataTableProps, type DataTableColumn, type DataTableSort, type DataTableSortDirection, } from './containers/DataTable.js';
47
+ export { BulkActionBar, type BulkActionBarProps } from './containers/BulkActionBar.js';
47
48
  export { Popover, type PopoverProps } from './overlays/Popover.js';
48
49
  export { Menu, type MenuProps } from './overlays/Menu.js';
49
50
  export { MenuItem, type MenuItemProps, type MenuItemVariant } from './overlays/MenuItem.js';
@@ -56,6 +57,8 @@ export { PickerField, type PickerFieldProps } from './overlays/PickerField.js';
56
57
  export { Reveal, type RevealProps } from './overlays/Reveal.js';
57
58
  export { DatePicker, type DatePickerProps, TimePicker, type TimePickerProps } from './overlays/DateTimePicker.js';
58
59
  export type { DateParts, MonthParts, TimeValue, Meridiem } from './overlays/DateTimePicker.js';
60
+ export { CommandPalette, type CommandPaletteProps, type CommandPaletteItem, } from './overlays/CommandPalette.js';
61
+ export { ShortcutsSheet, type ShortcutsSheetProps, type ShortcutSection, type ShortcutEntry, } from './overlays/ShortcutsSheet.js';
59
62
  export { Checkbox, type CheckboxProps, type CheckboxState } from './forms/Checkbox.js';
60
63
  export { RadioGroup, type RadioGroupProps, RadioRow, type RadioRowProps, type RadioOption } from './forms/RadioGroup.js';
61
64
  export { CodeBlock, type CodeBlockProps, type CodeBlockOutput, type CodeBlockOutputStatus, } from './content/CodeBlock.js';
@@ -63,13 +66,21 @@ export { SourceCard, type SourceCardProps } from './content/SourceCard.js';
63
66
  export { SourcesDisclosure, type SourcesDisclosureProps, type SourceRef } from './content/SourcesDisclosure.js';
64
67
  export { ModelPicker, type ModelPickerProps, type ModelOption, type ModelPickerLayout } from './content/ModelPicker.js';
65
68
  export { InlineCode, type InlineCodeProps } from './content/InlineCode.js';
69
+ export { Kbd, type KbdProps } from './content/Kbd.js';
66
70
  export { Callout, type CalloutProps, type CalloutTone } from './content/Callout.js';
67
71
  export { Collapsible, type CollapsibleProps } from './content/Collapsible.js';
68
72
  export { Caret, type CaretProps } from './content/Caret.js';
69
73
  export { Sidebar, type SidebarProps, type SidebarItem, type SidebarSection } from './nav/Sidebar.js';
74
+ export { Breadcrumb, type BreadcrumbProps, type BreadcrumbItem } from './nav/Breadcrumb.js';
70
75
  export { ResizablePanel, type ResizablePanelProps, type ResizablePanelSide } from './layout/ResizablePanel.js';
71
76
  export { ThinkingCube, type ThinkingCubeProps, type ThinkingCubeState } from './status/ThinkingCube.js';
72
77
  export { Spinner, type SpinnerProps } from './status/Spinner.js';
73
78
  export { ProgressBar, type ProgressBarProps } from './status/ProgressBar.js';
74
79
  export { StepTimeline, type StepTimelineProps, type Step, type StepStatus } from './status/StepTimeline.js';
75
80
  export { StatusIndicator, type StatusIndicatorProps, type StatusIndicatorTone } from './status/StatusIndicator.js';
81
+ export { Banner, type BannerProps, type BannerTone } from './status/Banner.js';
82
+ export { Toast, ToastStack, type ToastProps, type ToastStackProps, type ToastTone } from './status/Toast.js';
83
+ export { computeTooltipPosition, type TooltipPosition } from './overlays/Tooltip.js';
84
+ export { useShortcutRegistry, formatShortcutKeys, detectShortcutCollisions, toShortcutSections, toCommandItems, type ShortcutBinding, type ShortcutCollision, type UseShortcutRegistryResult, } from './shortcuts.js';
85
+ export { useToastQueue, type QueuedToast, type PushToastInput, type UseToastQueueResult, } from './useToastQueue.js';
86
+ export { snapshotXenoUiTree, installXenoUiTree, type XenoUiRect, type XenoUiNode, type XenoUiTreeSnapshot, type XenoUiBridge, } from './uiTree.js';
package/dist/index.js CHANGED
@@ -44,7 +44,8 @@ export { Avatar } from './containers/Avatar.js';
44
44
  export { AvatarStack } from './containers/Avatar.js';
45
45
  export { ListRow } from './containers/ListRow.js';
46
46
  export { Table, THead, TBody, Tr, Th, Td, } from './containers/Table.js';
47
- export { DataTable } from './containers/DataTable.js';
47
+ export { DataTable, } from './containers/DataTable.js';
48
+ export { BulkActionBar } from './containers/BulkActionBar.js';
48
49
  // ── Overlays ────────────────────────────────────────────────────────────────────────────────────
49
50
  export { Popover } from './overlays/Popover.js';
50
51
  export { Menu } from './overlays/Menu.js';
@@ -57,6 +58,8 @@ export { Tooltip } from './overlays/Tooltip.js';
57
58
  export { PickerField } from './overlays/PickerField.js';
58
59
  export { Reveal } from './overlays/Reveal.js';
59
60
  export { DatePicker, TimePicker } from './overlays/DateTimePicker.js';
61
+ export { CommandPalette, } from './overlays/CommandPalette.js';
62
+ export { ShortcutsSheet, } from './overlays/ShortcutsSheet.js';
60
63
  // ── Forms ───────────────────────────────────────────────────────────────────────────────────────
61
64
  export { Checkbox } from './forms/Checkbox.js';
62
65
  export { RadioGroup, RadioRow } from './forms/RadioGroup.js';
@@ -66,11 +69,13 @@ export { SourceCard } from './content/SourceCard.js';
66
69
  export { SourcesDisclosure } from './content/SourcesDisclosure.js';
67
70
  export { ModelPicker } from './content/ModelPicker.js';
68
71
  export { InlineCode } from './content/InlineCode.js';
72
+ export { Kbd } from './content/Kbd.js';
69
73
  export { Callout } from './content/Callout.js';
70
74
  export { Collapsible } from './content/Collapsible.js';
71
75
  export { Caret } from './content/Caret.js';
72
76
  // ── Nav ─────────────────────────────────────────────────────────────────────────────────────────
73
77
  export { Sidebar } from './nav/Sidebar.js';
78
+ export { Breadcrumb } from './nav/Breadcrumb.js';
74
79
  // ── Layout ──────────────────────────────────────────────────────────────────────────────────────
75
80
  export { ResizablePanel } from './layout/ResizablePanel.js';
76
81
  // ── Status ──────────────────────────────────────────────────────────────────────────────────────
@@ -79,3 +84,9 @@ export { Spinner } from './status/Spinner.js';
79
84
  export { ProgressBar } from './status/ProgressBar.js';
80
85
  export { StepTimeline } from './status/StepTimeline.js';
81
86
  export { StatusIndicator } from './status/StatusIndicator.js';
87
+ export { Banner } from './status/Banner.js';
88
+ export { Toast, ToastStack } from './status/Toast.js';
89
+ export { computeTooltipPosition } from './overlays/Tooltip.js';
90
+ export { useShortcutRegistry, formatShortcutKeys, detectShortcutCollisions, toShortcutSections, toCommandItems, } from './shortcuts.js';
91
+ export { useToastQueue, } from './useToastQueue.js';
92
+ export { snapshotXenoUiTree, installXenoUiTree, } from './uiTree.js';
@@ -0,0 +1,22 @@
1
+ import type { HTMLAttributes, ReactElement, ReactNode } from 'react';
2
+ /**
3
+ * `<Breadcrumb>` — header scope trail measured from Corpus (`Corpus / xeno-corporation ORG`) and
4
+ * Creator (`All networks / KNOW Media / Documentary`).
5
+ *
6
+ * Each item can be interactive (`onClick` / `href`) or static (`current` marks `aria-current="page"`),
7
+ * and may carry a compact mono `tag` (e.g. `ORG`, channel count).
8
+ */
9
+ export interface BreadcrumbItem {
10
+ readonly id: string;
11
+ readonly label: ReactNode;
12
+ readonly tag?: ReactNode;
13
+ readonly href?: string;
14
+ readonly onClick?: () => void;
15
+ readonly current?: boolean;
16
+ }
17
+ export interface BreadcrumbProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
18
+ readonly items: readonly BreadcrumbItem[];
19
+ /** Separator character between items. Default `'/'`. */
20
+ readonly separator?: ReactNode;
21
+ }
22
+ export declare function Breadcrumb({ items, separator, className, 'aria-label': ariaLabel, ...rest }: BreadcrumbProps): ReactElement;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from '../controls/util.js';
3
+ export function Breadcrumb({ items, separator = '/', className, 'aria-label': ariaLabel = 'Breadcrumb', ...rest }) {
4
+ return (_jsx("nav", { className: cx('xeno-breadcrumb', className), "aria-label": ariaLabel, ...rest, children: _jsx("ol", { className: "xeno-breadcrumb-list", children: items.map((item, idx) => {
5
+ const isLast = idx === items.length - 1;
6
+ const isCurrent = item.current ?? isLast;
7
+ const inner = (_jsxs(_Fragment, { children: [_jsx("span", { className: "xeno-breadcrumb-label", children: item.label }), item.tag !== undefined ? _jsx("span", { className: "xeno-breadcrumb-tag", children: item.tag }) : null] }));
8
+ return (_jsxs("li", { className: "xeno-breadcrumb-item", children: [idx > 0 ? (_jsx("span", { className: "xeno-breadcrumb-sep", "aria-hidden": "true", children: separator })) : null, item.href ? (_jsx("a", { href: item.href, className: "xeno-breadcrumb-link", "aria-current": isCurrent ? 'page' : undefined, onClick: item.onClick, children: inner })) : item.onClick ? (_jsx("button", { type: "button", className: "xeno-breadcrumb-btn", "aria-current": isCurrent ? 'page' : undefined, onClick: item.onClick, children: inner })) : (_jsx("span", { className: "xeno-breadcrumb-text", "aria-current": isCurrent ? 'page' : undefined, children: inner }))] }, item.id));
9
+ }) }) }));
10
+ }
@@ -0,0 +1,43 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ /**
3
+ * `<CommandPalette>` — the ⌘K command, navigation, and search overlay shared across Corpus,
4
+ * Creator, Workshop, and Desktop Shell (560px wide, 8px radius, `--xeno-pop` depth, grouped
5
+ * rows, ↑/↓/Enter/Esc keyboard navigation, and optional footer hints).
6
+ */
7
+ export interface CommandPaletteItem {
8
+ readonly id: string;
9
+ readonly label: string;
10
+ readonly group?: string;
11
+ readonly description?: string;
12
+ readonly keywords?: readonly string[];
13
+ readonly shortcut?: readonly string[];
14
+ readonly badge?: ReactNode;
15
+ readonly disabled?: boolean;
16
+ readonly onSelect?: () => void;
17
+ }
18
+ export interface CommandPaletteProps {
19
+ /** Whether the palette is mounted and visible. */
20
+ readonly open: boolean;
21
+ /** Called on Esc, scrim click, or after selection (unless `closeOnSelect={false}`). */
22
+ readonly onClose: () => void;
23
+ /** Available items, optionally grouped via `item.group`. */
24
+ readonly items: readonly CommandPaletteItem[];
25
+ /** Controlled query value (optional; falls back to internal state). */
26
+ readonly query?: string;
27
+ /** Called when the search input changes. */
28
+ readonly onQueryChange?: (query: string) => void;
29
+ /** Called whenever an item is chosen. */
30
+ readonly onSelect?: (item: CommandPaletteItem) => void;
31
+ /** Input placeholder. */
32
+ readonly placeholder?: string;
33
+ /** Text shown when no items match the query. */
34
+ readonly emptyMessage?: ReactNode;
35
+ /** Accessible label for the dialog. */
36
+ readonly label?: string;
37
+ /** Close automatically on item select. Default `true`. */
38
+ readonly closeOnSelect?: boolean;
39
+ /** Optional custom footer content. */
40
+ readonly footer?: ReactNode;
41
+ readonly className?: string;
42
+ }
43
+ export declare function CommandPalette({ open, onClose, items, query: controlledQuery, onQueryChange, onSelect, placeholder, emptyMessage, label, closeOnSelect, footer, className, }: CommandPaletteProps): ReactElement | null;