@tensor_1/react 2.11.0 → 2.12.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
@@ -140,6 +140,30 @@ interface UseTableResult<T> {
140
140
  */
141
141
  declare function useTable<T extends Row>(data: readonly T[], options?: UseTableOptions): UseTableResult<T>;
142
142
 
143
+ interface UseVirtualRowsOptions {
144
+ /** Fixed rendered row height in pixels. */
145
+ rowHeight: number;
146
+ /** Rows rendered beyond each viewport edge. Default: 6. */
147
+ overscan?: number;
148
+ /** Render all rows at or below this count. Default: 100. */
149
+ threshold?: number;
150
+ }
151
+ interface UseVirtualRowsResult<T> {
152
+ /** Attach to the scrolling TableWrap. */
153
+ containerRef: RefObject<HTMLDivElement>;
154
+ rows: readonly T[];
155
+ startIndex: number;
156
+ padTop: number;
157
+ padBottom: number;
158
+ totalHeight: number;
159
+ virtualized: boolean;
160
+ }
161
+ /**
162
+ * Owns scroll/resize observation and exposes the small visible row window.
163
+ * Consumers render padTop/padBottom spacer rows inside their existing tbody.
164
+ */
165
+ declare function useVirtualRows<T>(rows: readonly T[], { rowHeight, overscan, threshold }: UseVirtualRowsOptions): UseVirtualRowsResult<T>;
166
+
143
167
  /**
144
168
  * uix overlay positioning — framework-agnostic, dependency-free anchored placement.
145
169
  *
@@ -605,7 +629,7 @@ declare function Toaster({ children, className, ...props }: ToasterProps): react
605
629
  interface TableWrapProps extends HTMLAttributes<HTMLDivElement> {
606
630
  children?: ReactNode;
607
631
  }
608
- declare function TableWrap({ children, className, ...props }: TableWrapProps): react.JSX.Element;
632
+ declare const TableWrap: react.ForwardRefExoticComponent<TableWrapProps & react.RefAttributes<HTMLDivElement>>;
609
633
  type TableDensity = 'compact' | 'standard' | 'comfortable';
610
634
  type SortDirection = 'ascending' | 'descending' | 'none';
611
635
  interface TableProps extends TableHTMLAttributes<HTMLTableElement> {
@@ -1270,4 +1294,4 @@ interface StatusRowProps extends HTMLAttributes<HTMLDivElement> {
1270
1294
  /** Status row — indicator + name + trailing meta (`.uix-status-row`). */
1271
1295
  declare function StatusRow({ indicator, name, meta, className, ...props }: StatusRowProps): react.JSX.Element;
1272
1296
 
1273
- export { Alert, type AlertProps, type AlertTone, type Align, 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, ContentList, ContentListItem, type ContentListItemProps, type ContentListProps, DescriptionItem, type DescriptionItemProps, DescriptionList, type DescriptionListItem, type DescriptionListProps, DetailLayout, type DetailLayoutProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, ErrorState, type ErrorStateProps, EventRow, type EventRowProps, ExpandToggle, type ExpandToggleProps, FeaturedRundown, FeaturedRundownItem, type FeaturedRundownItemProps, type FeaturedRundownProps, FeaturedStage, type FeaturedStageProps, Field, type FieldProps, type FilterKind, type FilterOp, type FlatNode, 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, NewsLead, type NewsLeadProps, Note, type NoteProps, type NoteTone, NoticeQueue, type NoticeQueueProps, PageHeader, type PageHeaderProps, PageIntro, type PageIntroProps, Pagination, type PaginationProps, Peek, type PeekProps, type PillTone, type PillTreatment, type Placement, Popover, type PopoverProps, type PositionOptions, type PositionResult, type Primitive, Progress, type ProgressProps, Prose, type ProseProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type Rect, ResourceGrid, type ResourceGridProps, type Row, RowAction, type RowActionProps, RowActions, type RowActionsProps, SectionHead, type SectionHeadProps, type Segment, Segmented, SegmentedOption, type SegmentedOptionProps, type SegmentedProps, Select, type SelectAllState, type SelectProps, type ShellNav, type Side, Sidebar, type SidebarProps, SidebarSection, type SidebarSectionProps, type Size, Skeleton, type SkeletonProps, type SortDir, type SortDirection, type SortKey, Spinner, type SpinnerProps, StarButton, type StarButtonProps, Stat, StatLine, type StatLineItem, type StatLineProps, type StatProps, type StatTrend, StatusPill, type StatusPillProps, StatusRow, type StatusRowProps, 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 TreeLike, type TreeNavAction, type TreeNodeData, type TreeNodeProps, type TreeProps, type UseAnchoredPositionOptions, type UseTableOptions, type UseTableResult, UserChip, type UserChipProps, type ViewState, type VirtualWindow, applyFilters, clampWidth, computePosition, cx, flattenTree, highlightSegments, matchFilter, mergePinned, multiSort, nextSortDir, parseView, reorder, searchRows, selectAllState, serializeView, shouldVirtualize, toggleId, togglePage, toggleSort, treeNav, useAnchoredPosition, useDialog, useTable, virtualWindow };
1297
+ export { Alert, type AlertProps, type AlertTone, type Align, 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, ContentList, ContentListItem, type ContentListItemProps, type ContentListProps, DescriptionItem, type DescriptionItemProps, DescriptionList, type DescriptionListItem, type DescriptionListProps, DetailLayout, type DetailLayoutProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, ErrorState, type ErrorStateProps, EventRow, type EventRowProps, ExpandToggle, type ExpandToggleProps, FeaturedRundown, FeaturedRundownItem, type FeaturedRundownItemProps, type FeaturedRundownProps, FeaturedStage, type FeaturedStageProps, Field, type FieldProps, type FilterKind, type FilterOp, type FlatNode, 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, NewsLead, type NewsLeadProps, Note, type NoteProps, type NoteTone, NoticeQueue, type NoticeQueueProps, PageHeader, type PageHeaderProps, PageIntro, type PageIntroProps, Pagination, type PaginationProps, Peek, type PeekProps, type PillTone, type PillTreatment, type Placement, Popover, type PopoverProps, type PositionOptions, type PositionResult, type Primitive, Progress, type ProgressProps, Prose, type ProseProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type Rect, ResourceGrid, type ResourceGridProps, type Row, RowAction, type RowActionProps, RowActions, type RowActionsProps, SectionHead, type SectionHeadProps, type Segment, Segmented, SegmentedOption, type SegmentedOptionProps, type SegmentedProps, Select, type SelectAllState, type SelectProps, type ShellNav, type Side, Sidebar, type SidebarProps, SidebarSection, type SidebarSectionProps, type Size, Skeleton, type SkeletonProps, type SortDir, type SortDirection, type SortKey, Spinner, type SpinnerProps, StarButton, type StarButtonProps, Stat, StatLine, type StatLineItem, type StatLineProps, type StatProps, type StatTrend, StatusPill, type StatusPillProps, StatusRow, type StatusRowProps, 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 TreeLike, type TreeNavAction, type TreeNodeData, type TreeNodeProps, type TreeProps, type UseAnchoredPositionOptions, type UseTableOptions, type UseTableResult, type UseVirtualRowsOptions, type UseVirtualRowsResult, UserChip, type UserChipProps, type ViewState, type VirtualWindow, applyFilters, clampWidth, computePosition, cx, flattenTree, highlightSegments, matchFilter, mergePinned, multiSort, nextSortDir, parseView, reorder, searchRows, selectAllState, serializeView, shouldVirtualize, toggleId, togglePage, toggleSort, treeNav, useAnchoredPosition, useDialog, useTable, useVirtualRows, virtualWindow };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { cx } from './cx.js';
2
2
  export { useDialog } from './hooks/useDialog.js';
3
3
  export { UseTableOptions, UseTableResult, useTable } from './hooks/useTable.js';
4
+ export { UseVirtualRowsOptions, UseVirtualRowsResult, useVirtualRows } from './hooks/useVirtualRows.js';
4
5
  export { UseAnchoredPositionOptions, useAnchoredPosition } from './hooks/useAnchoredPosition.js';
5
6
  export { Align, Placement, PositionOptions, PositionResult, Rect, Side, Size, computePosition } from './overlay-position.js';
6
7
  export { Button, ButtonGroup, ButtonGroupProps, ButtonProps } from './components/Button.js';
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { cx } from "./cx.js";
2
2
  import { useDialog } from "./hooks/useDialog.js";
3
3
  import { useTable } from "./hooks/useTable.js";
4
+ import { useVirtualRows } from "./hooks/useVirtualRows.js";
4
5
  import { useAnchoredPosition } from "./hooks/useAnchoredPosition.js";
5
6
  import { computePosition } from "./overlay-position.js";
6
7
  import { Button, ButtonGroup } from "./components/Button.js";
@@ -182,5 +183,6 @@ export {
182
183
  treeNav,
183
184
  useAnchoredPosition,
184
185
  useDialog,
185
- useTable
186
+ useTable,
187
+ useVirtualRows
186
188
  };
@@ -1,19 +1,20 @@
1
+ const stringCollator = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
1
2
  function compare(a, b) {
2
3
  if (a == null && b == null) return 0;
3
4
  if (a == null) return -1;
4
5
  if (b == null) return 1;
5
6
  if (typeof a === "number" && typeof b === "number") return a - b;
6
- return String(a).localeCompare(String(b), void 0, { numeric: true, sensitivity: "base" });
7
+ return stringCollator.compare(String(a), String(b));
7
8
  }
8
9
  function multiSort(rows, keys) {
9
10
  if (!keys.length) return rows.slice();
10
- return rows.map((row, i) => ({ row, i })).sort((x, y) => {
11
+ return rows.slice().sort((a, b) => {
11
12
  for (const k of keys) {
12
- const c = compare(x.row[k.field], y.row[k.field]);
13
+ const c = compare(a[k.field], b[k.field]);
13
14
  if (c !== 0) return k.dir === "ascending" ? c : -c;
14
15
  }
15
- return x.i - y.i;
16
- }).map((w) => w.row);
16
+ return 0;
17
+ });
17
18
  }
18
19
  function nextSortDir(current) {
19
20
  if (current === "ascending") return "descending";
@@ -213,7 +214,8 @@ function toggleId(set, id) {
213
214
  return next;
214
215
  }
215
216
  function selectAllState(selected, pageIds) {
216
- const on = pageIds.filter((id) => selected.has(id)).length;
217
+ let on = 0;
218
+ for (const id of pageIds) if (selected.has(id)) on += 1;
217
219
  if (on === 0) return "none";
218
220
  return on === pageIds.length ? "all" : "some";
219
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tensor_1/react",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "Thin React wrappers over the UIx v2 CSS component library.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -26,22 +26,36 @@
26
26
  "types": "./dist/chart.d.ts",
27
27
  "import": "./dist/chart.js",
28
28
  "require": "./dist/chart.cjs"
29
+ },
30
+ "./chart/preset": {
31
+ "types": "./dist/chart-preset.d.ts",
32
+ "import": "./dist/chart-preset.js",
33
+ "require": "./dist/chart-preset.cjs"
29
34
  }
30
35
  },
31
36
  "scripts": {
32
37
  "build": "tsup",
33
38
  "dev": "tsup --watch",
34
39
  "typecheck": "tsc --noEmit",
35
- "test": "node --test"
40
+ "test": "node --test",
41
+ "test:performance": "node scripts/table-performance.mjs",
42
+ "size": "node scripts/check-chart-preset-size.mjs"
36
43
  },
37
44
  "peerDependencies": {
45
+ "echarts": "^5.6.0",
38
46
  "react": "^18.0.0 || ^19.0.0",
39
47
  "react-dom": "^18.0.0 || ^19.0.0"
40
48
  },
49
+ "peerDependenciesMeta": {
50
+ "echarts": {
51
+ "optional": true
52
+ }
53
+ },
41
54
  "devDependencies": {
42
55
  "@types/react": "^18.0.0",
43
56
  "@types/react-dom": "^18.0.0",
44
57
  "echarts": "^5.6.0",
58
+ "esbuild": "^0.27.0",
45
59
  "tsup": "^8.0.0",
46
60
  "typescript": "^5.0.0"
47
61
  }