@tensor_1/react 2.4.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;
@@ -414,7 +604,7 @@ interface PaginationProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange
414
604
  }
415
605
  declare function Pagination({ page, pageCount, onChange, className, ...props }: PaginationProps): react.JSX.Element;
416
606
 
417
- type PillTone = 'neutral' | 'success' | 'info' | 'warning' | 'danger' | 'critical' | 'muted';
607
+ type PillTone = 'neutral' | 'success' | 'info' | 'warning' | 'danger' | 'critical' | 'muted' | 'attention' | 'overdue' | 'sla-ok' | 'sla-at-risk' | 'sla-breached' | 'p1' | 'p2' | 'p3' | 'p4' | 'p5';
418
608
  type PillTreatment = 'filled' | 'outline';
419
609
  interface StatusPillProps extends HTMLAttributes<HTMLSpanElement> {
420
610
  tone?: PillTone;
@@ -435,6 +625,17 @@ interface ProgressProps extends HTMLAttributes<HTMLDivElement> {
435
625
  }
436
626
  declare function Progress({ value, max, indeterminate, className, ...props }: ProgressProps): react.JSX.Element;
437
627
 
628
+ /** Fill color tone for the meter bar. Defaults to `success` (green). */
629
+ type MeterTone = 'success' | 'warning' | 'danger' | 'attention' | 'overdue';
630
+ interface MeterProps extends HTMLAttributes<HTMLDivElement> {
631
+ /** Fill level 0–100. Clamped to this range. */
632
+ value?: number;
633
+ /** Threshold tone applied via `data-tone` on the fill element. `success` is the implicit default (no attribute). */
634
+ tone?: MeterTone;
635
+ }
636
+ /** Horizontal utilization / threshold bar backed by `.uix-meter`. */
637
+ declare function Meter({ value, tone, className, ...props }: MeterProps): react.JSX.Element;
638
+
438
639
  interface StatTrend {
439
640
  direction: 'up' | 'down';
440
641
  label: ReactNode;
@@ -548,17 +749,65 @@ interface CommentProps extends HTMLAttributes<HTMLDivElement> {
548
749
  /** A single comment over `.uix-comment` (avatar column + body). */
549
750
  declare function Comment({ avatar, author, meta, children, className, ...props }: CommentProps): react.JSX.Element;
550
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
+
551
794
  interface TimelineProps extends HTMLAttributes<HTMLDivElement> {
552
795
  children?: ReactNode;
553
796
  }
554
797
  /** Activity timeline container over `.uix-timeline`. */
555
798
  declare function Timeline({ children, className, ...props }: TimelineProps): react.JSX.Element;
556
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;
557
806
  meta?: ReactNode;
558
807
  children?: ReactNode;
559
808
  }
560
809
  /** A timeline entry over `.uix-timeline__item` (node + connecting line + body). */
561
- declare function TimelineItem({ meta, children, className, ...props }: TimelineItemProps): react.JSX.Element;
810
+ declare function TimelineItem({ node, meta, children, className, ...props }: TimelineItemProps): react.JSX.Element;
562
811
 
563
812
  interface ProseProps extends HTMLAttributes<HTMLDivElement> {
564
813
  children?: ReactNode;
@@ -617,6 +866,37 @@ interface CommandItemProps extends HTMLAttributes<HTMLDivElement> {
617
866
  /** A single command row over `.uix-cmdk__item`. */
618
867
  declare function CommandItem({ icon, shortcut, active, children, className, ...props }: CommandItemProps): react.JSX.Element;
619
868
 
869
+ interface InboxProps extends HTMLAttributes<HTMLDivElement> {
870
+ children?: ReactNode;
871
+ }
872
+ /** Two-pane inbox master-detail container backed by `.uix-inbox`. Place `<InboxList>` and `<InboxDetail>` as children. */
873
+ declare function Inbox({ children, className, ...props }: InboxProps): react.JSX.Element;
874
+ interface InboxListProps extends HTMLAttributes<HTMLDivElement> {
875
+ children?: ReactNode;
876
+ }
877
+ /** Left-pane item list. Place `<InboxItem>` children here. */
878
+ declare function InboxList({ children, className, ...props }: InboxListProps): react.JSX.Element;
879
+ interface InboxItemProps extends HTMLAttributes<HTMLDivElement> {
880
+ /** Primary subject / title line. */
881
+ subject?: ReactNode;
882
+ /** Secondary preview excerpt (truncated). */
883
+ preview?: ReactNode;
884
+ /** Leading slot — avatar, icon, or priority indicator. */
885
+ leading?: ReactNode;
886
+ /** When true sets `data-unread` → bolds the subject line. */
887
+ unread?: boolean;
888
+ /** When true sets `aria-selected` → renders the accent left-border stripe. */
889
+ selected?: boolean;
890
+ children?: ReactNode;
891
+ }
892
+ /** A single inbox row with subject, preview excerpt, optional leading slot, and unread/selected states. */
893
+ declare function InboxItem({ subject, preview, leading, unread, selected, children, className, ...props }: InboxItemProps): react.JSX.Element;
894
+ interface InboxDetailProps extends HTMLAttributes<HTMLDivElement> {
895
+ children?: ReactNode;
896
+ }
897
+ /** Right-pane detail area — renders the full content of the selected item. */
898
+ declare function InboxDetail({ children, className, ...props }: InboxDetailProps): react.JSX.Element;
899
+
620
900
  interface KanbanProps extends HTMLAttributes<HTMLDivElement> {
621
901
  children?: ReactNode;
622
902
  }
@@ -658,4 +938,4 @@ interface TreeProps extends Omit<HTMLAttributes<HTMLUListElement>, 'onSelect' |
658
938
  }
659
939
  declare function Tree({ nodes, expanded: controlledExpanded, defaultExpanded, selected, onToggle, onSelect, className, ...props }: TreeProps): react.JSX.Element;
660
940
 
661
- 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, 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, 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,27 +18,32 @@ 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';
33
+ export { Meter, MeterProps, MeterTone } from './components/Meter.js';
31
34
  export { Stat, StatProps, StatTrend } from './components/Stat.js';
32
35
  export { Tooltip, TooltipProps } from './components/Tooltip.js';
33
36
  export { EmptyState, EmptyStateProps, ErrorState, ErrorStateProps, LoadingState, LoadingStateProps, Skeleton, SkeletonProps } from './components/States.js';
34
37
  export { Label, LabelProps } from './components/Label.js';
35
38
  export { Avatar, AvatarGroup, AvatarGroupProps, AvatarProps, UserChip, UserChipProps } from './components/Avatar.js';
36
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';
37
42
  export { Timeline, TimelineItem, TimelineItemProps, TimelineProps } from './components/Timeline.js';
38
43
  export { Note, NoteProps, NoteTone, Prose, ProseProps } from './components/Prose.js';
39
44
  export { Popover, PopoverProps } from './components/Popover.js';
40
45
  export { CommandGroup, CommandGroupProps, CommandItem, CommandItemProps, CommandPalette, CommandPaletteProps } from './components/CommandPalette.js';
46
+ export { Inbox, InboxDetail, InboxDetailProps, InboxItem, InboxItemProps, InboxList, InboxListProps, InboxProps } from './components/Inbox.js';
41
47
  export { Kanban, KanbanCard, KanbanCardProps, KanbanColumn, KanbanColumnProps, KanbanProps } from './components/Kanban.js';
42
48
  export { Tree, TreeNodeData, TreeNodeProps, TreeProps } from './components/Tree.js';
43
49
  import 'react';
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,20 +25,39 @@ 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";
47
+ import { Meter } from "./components/Meter.js";
31
48
  import { Stat } from "./components/Stat.js";
32
49
  import { Tooltip } from "./components/Tooltip.js";
33
50
  import { EmptyState, ErrorState, Skeleton, LoadingState } from "./components/States.js";
34
51
  import { Label } from "./components/Label.js";
35
52
  import { Avatar, AvatarGroup, UserChip } from "./components/Avatar.js";
36
53
  import { Comments, Comment } from "./components/Comments.js";
54
+ import { Composer, ComposerBar } from "./components/Composer.js";
55
+ import { Segmented, SegmentedOption } from "./components/Segmented.js";
37
56
  import { Timeline, TimelineItem } from "./components/Timeline.js";
38
57
  import { Prose, Note } from "./components/Prose.js";
39
58
  import { Popover } from "./components/Popover.js";
40
59
  import { CommandPalette, CommandGroup, CommandItem } from "./components/CommandPalette.js";
60
+ import { Inbox, InboxList, InboxItem, InboxDetail } from "./components/Inbox.js";
41
61
  import { Kanban, KanbanColumn, KanbanCard } from "./components/Kanban.js";
42
62
  import { Tree } from "./components/Tree.js";
43
63
  export {
@@ -45,22 +65,33 @@ export {
45
65
  AppShell,
46
66
  Avatar,
47
67
  AvatarGroup,
68
+ BulkBar,
48
69
  Button,
49
70
  ButtonGroup,
50
71
  Card,
72
+ CellStrong,
73
+ CellSub,
51
74
  Checkbox,
52
75
  CommandGroup,
53
76
  CommandItem,
54
77
  CommandPalette,
55
78
  Comment,
56
79
  Comments,
80
+ Composer,
81
+ ComposerBar,
57
82
  DescriptionItem,
58
83
  DescriptionList,
59
84
  DetailLayout,
60
85
  Drawer,
61
86
  EmptyState,
62
87
  ErrorState,
88
+ ExpandToggle,
63
89
  Field,
90
+ Highlighted,
91
+ Inbox,
92
+ InboxDetail,
93
+ InboxItem,
94
+ InboxList,
64
95
  Input,
65
96
  InputGroup,
66
97
  Kanban,
@@ -70,6 +101,8 @@ export {
70
101
  List,
71
102
  ListItem,
72
103
  LoadingState,
104
+ Mark,
105
+ Meter,
73
106
  Modal,
74
107
  NavFavourites,
75
108
  NavGroup,
@@ -83,6 +116,10 @@ export {
83
116
  Prose,
84
117
  Radio,
85
118
  RadioGroup,
119
+ RowAction,
120
+ RowActions,
121
+ Segmented,
122
+ SegmentedOption,
86
123
  Select,
87
124
  Sidebar,
88
125
  SidebarSection,
@@ -109,5 +146,6 @@ export {
109
146
  Tree,
110
147
  UserChip,
111
148
  cx,
112
- useDialog
149
+ useDialog,
150
+ useTable
113
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 };