@tensor_1/react 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,10 +1,145 @@
1
1
  import * as react from 'react';
2
- import { ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, CSSProperties, HTMLAttributes, AnchorHTMLAttributes, TableHTMLAttributes, TdHTMLAttributes, ThHTMLAttributes } from 'react';
2
+ import { ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, CSSProperties, HTMLAttributes, AnchorHTMLAttributes, TdHTMLAttributes, TableHTMLAttributes, ThHTMLAttributes } from 'react';
3
3
 
4
4
  declare function cx(...args: (string | false | null | undefined | 0)[]): string;
5
5
 
6
6
  declare function useDialog(open: boolean): React.RefObject<HTMLDialogElement>;
7
7
 
8
+ /**
9
+ * uix table engine — framework-agnostic, dependency-free logic for data grids.
10
+ *
11
+ * Pure functions only (no DOM, no React), so the same core drives the React
12
+ * wrappers, the vanilla styleguide, and any consumer. Everything here is
13
+ * deterministic and unit-tested (see table-engine.test.mjs). The React layer
14
+ * (useTable / Table subcomponents) composes these; products may also call them
15
+ * directly. Presentation stays in table.css via the --uix-* contract.
16
+ */
17
+ type SortDir = 'ascending' | 'descending';
18
+ interface SortKey {
19
+ /** row field to sort on */
20
+ field: string;
21
+ dir: SortDir;
22
+ }
23
+ type Primitive = string | number | boolean | null | undefined;
24
+ type Row = Record<string, unknown>;
25
+ /**
26
+ * Stable multi-column sort. `keys` are applied in priority order (first is
27
+ * primary). Returns a new array; the input is not mutated.
28
+ */
29
+ declare function multiSort<T extends Row>(rows: readonly T[], keys: readonly SortKey[]): T[];
30
+ /** Cycle a header's sort state: none → ascending → descending → none. */
31
+ declare function nextSortDir(current: SortDir | 'none' | undefined): SortDir | 'none';
32
+ /**
33
+ * Toggle a field within a multi-sort key list. Without shift, it replaces the
34
+ * list with just this field (cycling its direction); with shift, it adds/updates
35
+ * the field as a secondary key (removing it when it cycles back to none).
36
+ */
37
+ declare function toggleSort(keys: readonly SortKey[], field: string, additive?: boolean): SortKey[];
38
+ type FilterKind = 'enum' | 'text' | 'number' | 'date' | 'boolean';
39
+ type FilterOp = 'isAnyOf' | 'isNoneOf' | 'contains' | 'equals' | 'startsWith' | 'eq' | 'lt' | 'gt' | 'between' | 'is';
40
+ interface ColumnFilter {
41
+ field: string;
42
+ kind: FilterKind;
43
+ op: FilterOp;
44
+ /** value(s): a scalar, an array (enum / between), or [min,max] for between */
45
+ value: Primitive | Primitive[];
46
+ }
47
+ declare function matchFilter(row: Row, f: ColumnFilter): boolean;
48
+ /** Keep rows that satisfy EVERY active filter (AND across columns). */
49
+ declare function applyFilters<T extends Row>(rows: readonly T[], filters: readonly ColumnFilter[]): T[];
50
+ /** Rows where any of `fields` (default: all string/number values) contains `query`. */
51
+ declare function searchRows<T extends Row>(rows: readonly T[], query: string, fields?: readonly string[]): T[];
52
+ interface Segment {
53
+ text: string;
54
+ match: boolean;
55
+ }
56
+ /** Split `text` into matched / unmatched segments for <mark> rendering (case-insensitive). */
57
+ declare function highlightSegments(text: string, query: string): Segment[];
58
+ interface ViewState {
59
+ sort?: SortKey[];
60
+ filters?: ColumnFilter[];
61
+ columns?: string[];
62
+ density?: 'compact' | 'standard' | 'comfortable';
63
+ q?: string;
64
+ }
65
+ /** Serialize a view to a compact, linkable query string (no leading '?'). */
66
+ declare function serializeView(v: ViewState): string;
67
+ /** Parse a query string (with or without leading '?') back into a ViewState. */
68
+ declare function parseView(qs: string): ViewState;
69
+ interface VirtualWindow {
70
+ start: number;
71
+ end: number;
72
+ padTop: number;
73
+ padBottom: number;
74
+ total: number;
75
+ }
76
+ /**
77
+ * Compute the visible row window for a fixed row height. Renders only
78
+ * [start, end) plus `overscan` rows on each side; padTop/padBottom are spacer
79
+ * heights (px) so the scrollbar stays correct. Below `threshold` rows, callers
80
+ * should skip virtualization (render all) — see shouldVirtualize.
81
+ */
82
+ declare function virtualWindow(scrollTop: number, viewportH: number, rowH: number, count: number, overscan?: number): VirtualWindow;
83
+ declare function shouldVirtualize(count: number, threshold?: number): boolean;
84
+ /** Clamp a dragged column width to a sane minimum (and optional maximum). */
85
+ declare function clampWidth(width: number, min?: number, max?: number): number;
86
+ /** Move an item from index `from` to index `to`, returning a new array. */
87
+ declare function reorder<T>(arr: readonly T[], from: number, to: number): T[];
88
+ declare function toggleId(set: ReadonlySet<string>, id: string): Set<string>;
89
+ type SelectAllState = 'none' | 'some' | 'all';
90
+ declare function selectAllState(selected: ReadonlySet<string>, pageIds: readonly string[]): SelectAllState;
91
+ /** Toggle every id on the current page on/off based on the header checkbox. */
92
+ declare function togglePage(selected: ReadonlySet<string>, pageIds: readonly string[]): Set<string>;
93
+ /** Pinned rows (kept present regardless of filter/sort) hoisted above the rest. */
94
+ declare function mergePinned<T extends Row>(all: readonly T[], visible: readonly T[], pinnedIds: ReadonlySet<string>, idField?: string): T[];
95
+
96
+ interface UseTableOptions {
97
+ /** row field used as the stable id (selection / pinning). Default: 'id'. */
98
+ idField?: string;
99
+ initialSort?: SortKey[];
100
+ initialFilters?: ColumnFilter[];
101
+ initialQuery?: string;
102
+ /** restrict full-text search to these fields (default: all values). */
103
+ searchFields?: readonly string[];
104
+ /** ids kept present + hoisted regardless of filter/sort. */
105
+ initialPinned?: Iterable<string>;
106
+ }
107
+ interface UseTableResult<T> {
108
+ /** derived view: filter → search → sort, then pinned rows hoisted to the top. */
109
+ rows: T[];
110
+ sort: SortKey[];
111
+ filters: ColumnFilter[];
112
+ query: string;
113
+ selected: ReadonlySet<string>;
114
+ pinned: ReadonlySet<string>;
115
+ /** header select-all tri-state over the current derived rows. */
116
+ selectAll: SelectAllState;
117
+ /** cycle a column's sort; pass additive (⇧-click) to keep it as a secondary key. */
118
+ toggleSort: (field: string, additive?: boolean) => void;
119
+ setSort: (keys: SortKey[]) => void;
120
+ setFilters: (filters: ColumnFilter[]) => void;
121
+ setQuery: (query: string) => void;
122
+ isSelected: (id: string) => boolean;
123
+ toggleRow: (id: string) => void;
124
+ /** toggle every currently-visible row from the header checkbox. */
125
+ toggleAllRows: () => void;
126
+ clearSelection: () => void;
127
+ togglePin: (id: string) => void;
128
+ /** current state as a ViewState + its linkable query string. */
129
+ view: ViewState;
130
+ viewQueryString: string;
131
+ /** hydrate sort/filters/query from a saved-view query string. */
132
+ applyView: (queryString: string) => void;
133
+ }
134
+ /**
135
+ * Compose the framework-agnostic table-engine into React state: sorting, typed
136
+ * filtering, full-text search, page-scoped selection, pinning, and linkable saved
137
+ * views. Presentation stays in the `<Table>` primitives + table.css; this only owns
138
+ * the state and the derived row list. The vanilla styleguide (`guide/app.js`) runs
139
+ * the same engine functions, so both layers behave identically.
140
+ */
141
+ declare function useTable<T extends Row>(data: readonly T[], options?: UseTableOptions): UseTableResult<T>;
142
+
8
143
  interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
9
144
  variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger' | 'link';
10
145
  size?: 'sm' | 'md' | 'lg';
@@ -219,13 +354,27 @@ interface TabProps extends Omit<HTMLAttributes<HTMLButtonElement>, 'onChange'> {
219
354
  }
220
355
  declare function Tab({ value, children, disabled, className, onClick, ...props }: TabProps): react.JSX.Element;
221
356
 
357
+ type ShellNav = 'full' | 'rail' | 'hidden';
222
358
  interface AppShellProps extends HTMLAttributes<HTMLDivElement> {
359
+ /** Sidebar width tier: 'full' (default) → 'rail' (icon only) → 'hidden' (0). */
360
+ nav?: ShellNav;
361
+ /** Back-compat alias for nav="rail". Ignored when `nav` is set. */
223
362
  collapsed?: boolean;
363
+ /**
364
+ * Immersive focus mode: hides the sidebar AND the topbar so a wide, many-column
365
+ * table uses the whole frame. Provide `onExitFocus` to enable Esc-to-exit and
366
+ * the floating exit control.
367
+ */
368
+ focus?: boolean;
369
+ /** Called when the user presses Esc (or the exit control) while in focus mode. */
370
+ onExitFocus?: () => void;
371
+ /** Drop the content gutter so a genuinely wide table runs edge-to-edge. */
372
+ mainBleed?: boolean;
224
373
  sidebar?: ReactNode;
225
374
  topbar?: ReactNode;
226
375
  children?: ReactNode;
227
376
  }
228
- declare function AppShell({ collapsed, sidebar, topbar, children, className, ...props }: AppShellProps): react.JSX.Element;
377
+ declare function AppShell({ nav, collapsed, focus, onExitFocus, mainBleed, sidebar, topbar, children, className, ...props }: AppShellProps): react.JSX.Element;
229
378
 
230
379
  interface SidebarProps extends HTMLAttributes<HTMLElement> {
231
380
  collapsed?: boolean;
@@ -387,16 +536,20 @@ interface TableProps extends TableHTMLAttributes<HTMLTableElement> {
387
536
  density?: TableDensity;
388
537
  zebra?: boolean;
389
538
  pinnedCol?: boolean;
539
+ /** table-layout: fixed — required for reliable column widths + primary-column truncation */
540
+ fixed?: boolean;
390
541
  rowPeek?: boolean;
391
542
  v2?: boolean;
392
543
  }
393
- declare function Table({ density, zebra, pinnedCol, rowPeek, v2, className, children, ...props }: TableProps): react.JSX.Element;
544
+ declare function Table({ density, zebra, pinnedCol, fixed, rowPeek, v2, className, children, ...props }: TableProps): react.JSX.Element;
394
545
  interface ThProps extends ThHTMLAttributes<HTMLTableCellElement> {
395
546
  sortable?: boolean;
396
547
  sortDirection?: SortDirection;
548
+ /** 1-based ordinal shown when this column is a secondary key in a multi-sort */
549
+ sortOrder?: number;
397
550
  onSort?: () => void;
398
551
  }
399
- declare function Th({ sortable, sortDirection, onSort, className, children, onClick, ...props }: ThProps): react.JSX.Element;
552
+ declare function Th({ sortable, sortDirection, sortOrder, onSort, className, children, onClick, ...props }: ThProps): react.JSX.Element;
400
553
  interface TdProps extends TdHTMLAttributes<HTMLTableCellElement> {
401
554
  pinned?: boolean;
402
555
  }
@@ -406,6 +559,43 @@ interface TrProps extends HTMLAttributes<HTMLTableRowElement> {
406
559
  pinned?: boolean;
407
560
  }
408
561
  declare function Tr({ selected, pinned, className, children, ...props }: TrProps): react.JSX.Element;
562
+ interface BulkBarProps extends HTMLAttributes<HTMLDivElement> {
563
+ /** number of selected rows, rendered as "N selected" */
564
+ count?: number;
565
+ children?: ReactNode;
566
+ }
567
+ /** Contextual action bar shown above the table when ≥1 row is selected. */
568
+ declare function BulkBar({ count, children, className, ...props }: BulkBarProps): react.JSX.Element;
569
+ interface RowActionsProps extends TdHTMLAttributes<HTMLTableCellElement> {
570
+ children?: ReactNode;
571
+ }
572
+ /** Trailing cell that holds the row's hover actions (kebab, quick actions). */
573
+ declare function RowActions({ children, className, ...props }: RowActionsProps): react.JSX.Element;
574
+ interface RowActionProps extends ButtonHTMLAttributes<HTMLButtonElement> {
575
+ children?: ReactNode;
576
+ }
577
+ /** A single hover-revealed row action button (icon inside). */
578
+ declare function RowAction({ children, className, type, ...props }: RowActionProps): react.JSX.Element;
579
+ interface ExpandToggleProps extends ButtonHTMLAttributes<HTMLButtonElement> {
580
+ expanded?: boolean;
581
+ }
582
+ /** Chevron button that expands/collapses an inline detail row. */
583
+ declare function ExpandToggle({ expanded, className, type, ...props }: ExpandToggleProps): react.JSX.Element;
584
+ /** Emphasised primary cell text. */
585
+ declare function CellStrong({ children, className, ...props }: HTMLAttributes<HTMLSpanElement>): react.JSX.Element;
586
+ /** Secondary line under a primary cell value (muted, meta size). */
587
+ declare function CellSub({ children, className, ...props }: HTMLAttributes<HTMLSpanElement>): react.JSX.Element;
588
+ interface MarkProps extends HTMLAttributes<HTMLElement> {
589
+ children?: ReactNode;
590
+ }
591
+ /** A search-match highlight span. */
592
+ declare function Mark({ children, className, ...props }: MarkProps): react.JSX.Element;
593
+ interface HighlightedProps {
594
+ text: string;
595
+ query: string;
596
+ }
597
+ /** Render `text` with case-insensitive matches of `query` wrapped in <mark>. */
598
+ declare function Highlighted({ text, query }: HighlightedProps): react.JSX.Element;
409
599
 
410
600
  interface PaginationProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
411
601
  page: number;
@@ -559,17 +749,65 @@ interface CommentProps extends HTMLAttributes<HTMLDivElement> {
559
749
  /** A single comment over `.uix-comment` (avatar column + body). */
560
750
  declare function Comment({ avatar, author, meta, children, className, ...props }: CommentProps): react.JSX.Element;
561
751
 
752
+ interface ComposerProps extends HTMLAttributes<HTMLDivElement> {
753
+ children?: ReactNode;
754
+ }
755
+ /**
756
+ * Composer surface over `.uix-composer` — a single box that owns the
757
+ * `:focus-within` accent ring. Drop a borderless `<textarea>` and a
758
+ * `<ComposerBar>` inside; the descendant `textarea` picks up the composer's
759
+ * padding/typography automatically, so the input never reads as a second
760
+ * nested box.
761
+ */
762
+ declare function Composer({ children, className, ...props }: ComposerProps): react.JSX.Element;
763
+ interface ComposerBarProps extends HTMLAttributes<HTMLDivElement> {
764
+ children?: ReactNode;
765
+ }
766
+ /** Action footer for a `<Composer>` over `.uix-composer__bar` (top-bordered, right-aligned). */
767
+ declare function ComposerBar({ children, className, ...props }: ComposerBarProps): react.JSX.Element;
768
+
769
+ interface SegmentedProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
770
+ /** The currently-selected option value. */
771
+ value?: string;
772
+ /** Fires with the option's value when a different option is chosen. */
773
+ onChange?: (value: string) => void;
774
+ children?: ReactNode;
775
+ }
776
+ /**
777
+ * Segmented single-select over `.uix-segmented` — the compact 2–3 way toggle
778
+ * (density, audience, view mode …) that reads as one pill with a lifted active
779
+ * segment. Selection state is shared with `<SegmentedOption>` via context, so
780
+ * the caller only wires `value` + `onChange` once.
781
+ */
782
+ declare function Segmented({ value, onChange, children, className, ...props }: SegmentedProps): react.JSX.Element;
783
+ interface SegmentedOptionProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'onChange'> {
784
+ value: string;
785
+ children?: ReactNode;
786
+ }
787
+ /**
788
+ * One option in a `<Segmented>`. Active state is derived from the parent's
789
+ * `value`; the pressed segment lifts to the surface via
790
+ * `.uix-segmented__option[aria-pressed="true"]`.
791
+ */
792
+ declare function SegmentedOption({ value, children, className, onClick, ...props }: SegmentedOptionProps): react.JSX.Element;
793
+
562
794
  interface TimelineProps extends HTMLAttributes<HTMLDivElement> {
563
795
  children?: ReactNode;
564
796
  }
565
797
  /** Activity timeline container over `.uix-timeline`. */
566
798
  declare function Timeline({ children, className, ...props }: TimelineProps): react.JSX.Element;
567
799
  interface TimelineItemProps extends HTMLAttributes<HTMLDivElement> {
800
+ /**
801
+ * Custom rail node — an icon puck, an avatar, a tinted dot. Defaults to the
802
+ * accent `.uix-timeline__node` dot. Supply this to make a heterogeneous feed
803
+ * (comments + audit events) read on one rail with per-row node semantics.
804
+ */
805
+ node?: ReactNode;
568
806
  meta?: ReactNode;
569
807
  children?: ReactNode;
570
808
  }
571
809
  /** A timeline entry over `.uix-timeline__item` (node + connecting line + body). */
572
- declare function TimelineItem({ meta, children, className, ...props }: TimelineItemProps): react.JSX.Element;
810
+ declare function TimelineItem({ node, meta, children, className, ...props }: TimelineItemProps): react.JSX.Element;
573
811
 
574
812
  interface ProseProps extends HTMLAttributes<HTMLDivElement> {
575
813
  children?: ReactNode;
@@ -700,4 +938,4 @@ interface TreeProps extends Omit<HTMLAttributes<HTMLUListElement>, 'onSelect' |
700
938
  }
701
939
  declare function Tree({ nodes, expanded: controlledExpanded, defaultExpanded, selected, onToggle, onSelect, className, ...props }: TreeProps): react.JSX.Element;
702
940
 
703
- export { Alert, type AlertProps, type AlertTone, AppShell, type AppShellProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, Card, type CardProps, Checkbox, type CheckboxProps, CommandGroup, type CommandGroupProps, CommandItem, type CommandItemProps, CommandPalette, type CommandPaletteProps, Comment, type CommentProps, Comments, type CommentsProps, DescriptionItem, type DescriptionItemProps, DescriptionList, type DescriptionListItem, type DescriptionListProps, DetailLayout, type DetailLayoutProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, ErrorState, type ErrorStateProps, Field, type FieldProps, Inbox, InboxDetail, type InboxDetailProps, InboxItem, type InboxItemProps, InboxList, type InboxListProps, type InboxProps, Input, InputGroup, type InputGroupProps, type InputProps, Kanban, KanbanCard, type KanbanCardProps, KanbanColumn, type KanbanColumnProps, type KanbanProps, Label, type LabelProps, List, ListItem, type ListItemProps, type ListProps, LoadingState, type LoadingStateProps, Meter, type MeterProps, type MeterTone, Modal, type ModalProps, type NavFavouriteItem, NavFavourites, type NavFavouritesLabels, type NavFavouritesProps, NavGroup, type NavGroupProps, NavItem, type NavItemProps, Note, type NoteProps, type NoteTone, PageHeader, type PageHeaderProps, Pagination, type PaginationProps, Peek, type PeekProps, type PillTone, type PillTreatment, Popover, type PopoverProps, Progress, type ProgressProps, Prose, type ProseProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, Select, type SelectProps, Sidebar, type SidebarProps, SidebarSection, type SidebarSectionProps, Skeleton, type SkeletonProps, type SortDirection, Spinner, type SpinnerProps, StarButton, type StarButtonProps, Stat, type StatProps, type StatTrend, StatusPill, type StatusPillProps, SubNavItem, type SubNavItemProps, Switch, type SwitchProps, Tab, type TabProps, Table, type TableDensity, type TableProps, TableWrap, type TableWrapProps, Tabs, type TabsProps, Td, type TdProps, Textarea, type TextareaProps, Th, type ThProps, Timeline, TimelineItem, type TimelineItemProps, type TimelineProps, Toast, type ToastProps, type ToastTone, Toaster, type ToasterProps, Tooltip, type TooltipProps, Tr, type TrProps, Tree, type TreeNodeData, type TreeNodeProps, type TreeProps, UserChip, type UserChipProps, cx, useDialog };
941
+ export { Alert, type AlertProps, type AlertTone, AppShell, type AppShellProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, BulkBar, type BulkBarProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, Card, type CardProps, CellStrong, CellSub, Checkbox, type CheckboxProps, type ColumnFilter, CommandGroup, type CommandGroupProps, CommandItem, type CommandItemProps, CommandPalette, type CommandPaletteProps, Comment, type CommentProps, Comments, type CommentsProps, Composer, ComposerBar, type ComposerBarProps, type ComposerProps, DescriptionItem, type DescriptionItemProps, DescriptionList, type DescriptionListItem, type DescriptionListProps, DetailLayout, type DetailLayoutProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, ErrorState, type ErrorStateProps, ExpandToggle, type ExpandToggleProps, Field, type FieldProps, type FilterKind, type FilterOp, Highlighted, type HighlightedProps, Inbox, InboxDetail, type InboxDetailProps, InboxItem, type InboxItemProps, InboxList, type InboxListProps, type InboxProps, Input, InputGroup, type InputGroupProps, type InputProps, Kanban, KanbanCard, type KanbanCardProps, KanbanColumn, type KanbanColumnProps, type KanbanProps, Label, type LabelProps, List, ListItem, type ListItemProps, type ListProps, LoadingState, type LoadingStateProps, Mark, type MarkProps, Meter, type MeterProps, type MeterTone, Modal, type ModalProps, type NavFavouriteItem, NavFavourites, type NavFavouritesLabels, type NavFavouritesProps, NavGroup, type NavGroupProps, NavItem, type NavItemProps, Note, type NoteProps, type NoteTone, PageHeader, type PageHeaderProps, Pagination, type PaginationProps, Peek, type PeekProps, type PillTone, type PillTreatment, Popover, type PopoverProps, type Primitive, Progress, type ProgressProps, Prose, type ProseProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type Row, RowAction, type RowActionProps, RowActions, type RowActionsProps, type Segment, Segmented, SegmentedOption, type SegmentedOptionProps, type SegmentedProps, Select, type SelectAllState, type SelectProps, type ShellNav, Sidebar, type SidebarProps, SidebarSection, type SidebarSectionProps, Skeleton, type SkeletonProps, type SortDir, type SortDirection, type SortKey, Spinner, type SpinnerProps, StarButton, type StarButtonProps, Stat, type StatProps, type StatTrend, StatusPill, type StatusPillProps, SubNavItem, type SubNavItemProps, Switch, type SwitchProps, Tab, type TabProps, Table, type TableDensity, type TableProps, TableWrap, type TableWrapProps, Tabs, type TabsProps, Td, type TdProps, Textarea, type TextareaProps, Th, type ThProps, Timeline, TimelineItem, type TimelineItemProps, type TimelineProps, Toast, type ToastProps, type ToastTone, Toaster, type ToasterProps, Tooltip, type TooltipProps, Tr, type TrProps, Tree, type TreeNodeData, type TreeNodeProps, type TreeProps, type UseTableOptions, type UseTableResult, UserChip, type UserChipProps, type ViewState, type VirtualWindow, applyFilters, clampWidth, cx, highlightSegments, matchFilter, mergePinned, multiSort, nextSortDir, parseView, reorder, searchRows, selectAllState, serializeView, shouldVirtualize, toggleId, togglePage, toggleSort, useDialog, useTable, virtualWindow };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { cx } from './cx.js';
2
2
  export { useDialog } from './hooks/useDialog.js';
3
+ export { UseTableOptions, UseTableResult, useTable } from './hooks/useTable.js';
3
4
  export { Button, ButtonGroup, ButtonGroupProps, ButtonProps } from './components/Button.js';
4
5
  export { Input, InputGroup, InputGroupProps, InputProps } from './components/Input.js';
5
6
  export { Textarea, TextareaProps } from './components/Textarea.js';
@@ -17,14 +18,15 @@ export { DetailLayout, DetailLayoutProps } from './components/DetailLayout.js';
17
18
  export { List, ListItem, ListItemProps, ListProps } from './components/List.js';
18
19
  export { DescriptionItem, DescriptionItemProps, DescriptionList, DescriptionListItem, DescriptionListProps } from './components/DescriptionList.js';
19
20
  export { Tab, TabProps, Tabs, TabsProps } from './components/Tabs.js';
20
- export { AppShell, AppShellProps } from './components/AppShell.js';
21
+ export { AppShell, AppShellProps, ShellNav } from './components/AppShell.js';
21
22
  export { NavGroup, NavGroupProps, NavItem, NavItemProps, Sidebar, SidebarProps, SidebarSection, SidebarSectionProps, SubNavItem, SubNavItemProps } from './components/Sidebar.js';
22
23
  export { StarButton, StarButtonProps } from './components/StarButton.js';
23
24
  export { NavFavouriteItem, NavFavourites, NavFavouritesLabels, NavFavouritesProps } from './components/NavFavourites.js';
24
25
  export { Alert, AlertProps, AlertTone } from './components/Alert.js';
25
26
  export { Spinner, SpinnerProps } from './components/Spinner.js';
26
27
  export { Toast, ToastProps, ToastTone, Toaster, ToasterProps } from './components/Toast.js';
27
- export { SortDirection, Table, TableDensity, TableProps, TableWrap, TableWrapProps, Td, TdProps, Th, ThProps, Tr, TrProps } from './components/Table.js';
28
+ export { BulkBar, BulkBarProps, CellStrong, CellSub, ExpandToggle, ExpandToggleProps, Highlighted, HighlightedProps, Mark, MarkProps, RowAction, RowActionProps, RowActions, RowActionsProps, SortDirection, Table, TableDensity, TableProps, TableWrap, TableWrapProps, Td, TdProps, Th, ThProps, Tr, TrProps } from './components/Table.js';
29
+ export { ColumnFilter, FilterKind, FilterOp, Primitive, Row, Segment, SelectAllState, SortDir, SortKey, ViewState, VirtualWindow, applyFilters, clampWidth, highlightSegments, matchFilter, mergePinned, multiSort, nextSortDir, parseView, reorder, searchRows, selectAllState, serializeView, shouldVirtualize, toggleId, togglePage, toggleSort, virtualWindow } from './table-engine.js';
28
30
  export { Pagination, PaginationProps } from './components/Pagination.js';
29
31
  export { PillTone, PillTreatment, StatusPill, StatusPillProps } from './components/StatusPill.js';
30
32
  export { Progress, ProgressProps } from './components/Progress.js';
@@ -35,6 +37,8 @@ export { EmptyState, EmptyStateProps, ErrorState, ErrorStateProps, LoadingState,
35
37
  export { Label, LabelProps } from './components/Label.js';
36
38
  export { Avatar, AvatarGroup, AvatarGroupProps, AvatarProps, UserChip, UserChipProps } from './components/Avatar.js';
37
39
  export { Comment, CommentProps, Comments, CommentsProps } from './components/Comments.js';
40
+ export { Composer, ComposerBar, ComposerBarProps, ComposerProps } from './components/Composer.js';
41
+ export { Segmented, SegmentedOption, SegmentedOptionProps, SegmentedProps } from './components/Segmented.js';
38
42
  export { Timeline, TimelineItem, TimelineItemProps, TimelineProps } from './components/Timeline.js';
39
43
  export { Note, NoteProps, NoteTone, Prose, ProseProps } from './components/Prose.js';
40
44
  export { Popover, PopoverProps } from './components/Popover.js';
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { cx } from "./cx.js";
2
2
  import { useDialog } from "./hooks/useDialog.js";
3
+ import { useTable } from "./hooks/useTable.js";
3
4
  import { Button, ButtonGroup } from "./components/Button.js";
4
5
  import { Input, InputGroup } from "./components/Input.js";
5
6
  import { Textarea } from "./components/Textarea.js";
@@ -24,7 +25,22 @@ import { NavFavourites } from "./components/NavFavourites.js";
24
25
  import { Alert } from "./components/Alert.js";
25
26
  import { Spinner } from "./components/Spinner.js";
26
27
  import { Toast, Toaster } from "./components/Toast.js";
27
- import { TableWrap, Table, Th, Td, Tr } from "./components/Table.js";
28
+ import {
29
+ TableWrap,
30
+ Table,
31
+ Th,
32
+ Td,
33
+ Tr,
34
+ BulkBar,
35
+ RowActions,
36
+ RowAction,
37
+ ExpandToggle,
38
+ CellStrong,
39
+ CellSub,
40
+ Mark,
41
+ Highlighted
42
+ } from "./components/Table.js";
43
+ export * from "./table-engine.js";
28
44
  import { Pagination } from "./components/Pagination.js";
29
45
  import { StatusPill } from "./components/StatusPill.js";
30
46
  import { Progress } from "./components/Progress.js";
@@ -35,6 +51,8 @@ import { EmptyState, ErrorState, Skeleton, LoadingState } from "./components/Sta
35
51
  import { Label } from "./components/Label.js";
36
52
  import { Avatar, AvatarGroup, UserChip } from "./components/Avatar.js";
37
53
  import { Comments, Comment } from "./components/Comments.js";
54
+ import { Composer, ComposerBar } from "./components/Composer.js";
55
+ import { Segmented, SegmentedOption } from "./components/Segmented.js";
38
56
  import { Timeline, TimelineItem } from "./components/Timeline.js";
39
57
  import { Prose, Note } from "./components/Prose.js";
40
58
  import { Popover } from "./components/Popover.js";
@@ -47,22 +65,29 @@ export {
47
65
  AppShell,
48
66
  Avatar,
49
67
  AvatarGroup,
68
+ BulkBar,
50
69
  Button,
51
70
  ButtonGroup,
52
71
  Card,
72
+ CellStrong,
73
+ CellSub,
53
74
  Checkbox,
54
75
  CommandGroup,
55
76
  CommandItem,
56
77
  CommandPalette,
57
78
  Comment,
58
79
  Comments,
80
+ Composer,
81
+ ComposerBar,
59
82
  DescriptionItem,
60
83
  DescriptionList,
61
84
  DetailLayout,
62
85
  Drawer,
63
86
  EmptyState,
64
87
  ErrorState,
88
+ ExpandToggle,
65
89
  Field,
90
+ Highlighted,
66
91
  Inbox,
67
92
  InboxDetail,
68
93
  InboxItem,
@@ -76,6 +101,7 @@ export {
76
101
  List,
77
102
  ListItem,
78
103
  LoadingState,
104
+ Mark,
79
105
  Meter,
80
106
  Modal,
81
107
  NavFavourites,
@@ -90,6 +116,10 @@ export {
90
116
  Prose,
91
117
  Radio,
92
118
  RadioGroup,
119
+ RowAction,
120
+ RowActions,
121
+ Segmented,
122
+ SegmentedOption,
93
123
  Select,
94
124
  Sidebar,
95
125
  SidebarSection,
@@ -116,5 +146,6 @@ export {
116
146
  Tree,
117
147
  UserChip,
118
148
  cx,
119
- useDialog
149
+ useDialog,
150
+ useTable
120
151
  };
@@ -0,0 +1,89 @@
1
+ /**
2
+ * uix table engine — framework-agnostic, dependency-free logic for data grids.
3
+ *
4
+ * Pure functions only (no DOM, no React), so the same core drives the React
5
+ * wrappers, the vanilla styleguide, and any consumer. Everything here is
6
+ * deterministic and unit-tested (see table-engine.test.mjs). The React layer
7
+ * (useTable / Table subcomponents) composes these; products may also call them
8
+ * directly. Presentation stays in table.css via the --uix-* contract.
9
+ */
10
+ type SortDir = 'ascending' | 'descending';
11
+ interface SortKey {
12
+ /** row field to sort on */
13
+ field: string;
14
+ dir: SortDir;
15
+ }
16
+ type Primitive = string | number | boolean | null | undefined;
17
+ type Row = Record<string, unknown>;
18
+ /**
19
+ * Stable multi-column sort. `keys` are applied in priority order (first is
20
+ * primary). Returns a new array; the input is not mutated.
21
+ */
22
+ declare function multiSort<T extends Row>(rows: readonly T[], keys: readonly SortKey[]): T[];
23
+ /** Cycle a header's sort state: none → ascending → descending → none. */
24
+ declare function nextSortDir(current: SortDir | 'none' | undefined): SortDir | 'none';
25
+ /**
26
+ * Toggle a field within a multi-sort key list. Without shift, it replaces the
27
+ * list with just this field (cycling its direction); with shift, it adds/updates
28
+ * the field as a secondary key (removing it when it cycles back to none).
29
+ */
30
+ declare function toggleSort(keys: readonly SortKey[], field: string, additive?: boolean): SortKey[];
31
+ type FilterKind = 'enum' | 'text' | 'number' | 'date' | 'boolean';
32
+ type FilterOp = 'isAnyOf' | 'isNoneOf' | 'contains' | 'equals' | 'startsWith' | 'eq' | 'lt' | 'gt' | 'between' | 'is';
33
+ interface ColumnFilter {
34
+ field: string;
35
+ kind: FilterKind;
36
+ op: FilterOp;
37
+ /** value(s): a scalar, an array (enum / between), or [min,max] for between */
38
+ value: Primitive | Primitive[];
39
+ }
40
+ declare function matchFilter(row: Row, f: ColumnFilter): boolean;
41
+ /** Keep rows that satisfy EVERY active filter (AND across columns). */
42
+ declare function applyFilters<T extends Row>(rows: readonly T[], filters: readonly ColumnFilter[]): T[];
43
+ /** Rows where any of `fields` (default: all string/number values) contains `query`. */
44
+ declare function searchRows<T extends Row>(rows: readonly T[], query: string, fields?: readonly string[]): T[];
45
+ interface Segment {
46
+ text: string;
47
+ match: boolean;
48
+ }
49
+ /** Split `text` into matched / unmatched segments for <mark> rendering (case-insensitive). */
50
+ declare function highlightSegments(text: string, query: string): Segment[];
51
+ interface ViewState {
52
+ sort?: SortKey[];
53
+ filters?: ColumnFilter[];
54
+ columns?: string[];
55
+ density?: 'compact' | 'standard' | 'comfortable';
56
+ q?: string;
57
+ }
58
+ /** Serialize a view to a compact, linkable query string (no leading '?'). */
59
+ declare function serializeView(v: ViewState): string;
60
+ /** Parse a query string (with or without leading '?') back into a ViewState. */
61
+ declare function parseView(qs: string): ViewState;
62
+ interface VirtualWindow {
63
+ start: number;
64
+ end: number;
65
+ padTop: number;
66
+ padBottom: number;
67
+ total: number;
68
+ }
69
+ /**
70
+ * Compute the visible row window for a fixed row height. Renders only
71
+ * [start, end) plus `overscan` rows on each side; padTop/padBottom are spacer
72
+ * heights (px) so the scrollbar stays correct. Below `threshold` rows, callers
73
+ * should skip virtualization (render all) — see shouldVirtualize.
74
+ */
75
+ declare function virtualWindow(scrollTop: number, viewportH: number, rowH: number, count: number, overscan?: number): VirtualWindow;
76
+ declare function shouldVirtualize(count: number, threshold?: number): boolean;
77
+ /** Clamp a dragged column width to a sane minimum (and optional maximum). */
78
+ declare function clampWidth(width: number, min?: number, max?: number): number;
79
+ /** Move an item from index `from` to index `to`, returning a new array. */
80
+ declare function reorder<T>(arr: readonly T[], from: number, to: number): T[];
81
+ declare function toggleId(set: ReadonlySet<string>, id: string): Set<string>;
82
+ type SelectAllState = 'none' | 'some' | 'all';
83
+ declare function selectAllState(selected: ReadonlySet<string>, pageIds: readonly string[]): SelectAllState;
84
+ /** Toggle every id on the current page on/off based on the header checkbox. */
85
+ declare function togglePage(selected: ReadonlySet<string>, pageIds: readonly string[]): Set<string>;
86
+ /** Pinned rows (kept present regardless of filter/sort) hoisted above the rest. */
87
+ declare function mergePinned<T extends Row>(all: readonly T[], visible: readonly T[], pinnedIds: ReadonlySet<string>, idField?: string): T[];
88
+
89
+ export { type ColumnFilter, type FilterKind, type FilterOp, type Primitive, type Row, type Segment, type SelectAllState, type SortDir, type SortKey, type ViewState, type VirtualWindow, applyFilters, clampWidth, highlightSegments, matchFilter, mergePinned, multiSort, nextSortDir, parseView, reorder, searchRows, selectAllState, serializeView, shouldVirtualize, toggleId, togglePage, toggleSort, virtualWindow };