simple-table-core 3.9.6 → 3.9.8

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 (57) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/src/core/SimpleTableVanilla.d.ts +8 -0
  3. package/dist/cjs/src/core/api/TableAPIImpl.d.ts +13 -0
  4. package/dist/cjs/src/hooks/handleOutsideClick.d.ts +1 -1
  5. package/dist/cjs/src/index.d.ts +2 -0
  6. package/dist/cjs/src/managers/AnimationCoordinator.d.ts +2 -0
  7. package/dist/cjs/src/managers/SelectionManager/types.d.ts +6 -1
  8. package/dist/cjs/src/managers/TableManager.d.ts +1 -0
  9. package/dist/cjs/src/types/SimpleTableConfig.d.ts +1 -0
  10. package/dist/cjs/src/types/SimpleTableProps.d.ts +1 -0
  11. package/dist/cjs/src/utils/headerCell/types.d.ts +1 -1
  12. package/dist/cjs/src/utils/propSyncEqual.d.ts +65 -0
  13. package/dist/cjs/src/utils/rowUtils.d.ts +7 -0
  14. package/dist/cjs/stories/docs/Examples.stories.d.ts +1 -0
  15. package/dist/cjs/stories/docs/storyArgs.d.ts +7 -0
  16. package/dist/cjs/stories/examples/AlignmentExample.d.ts +1 -0
  17. package/dist/cjs/stories/examples/CellHighlighting.d.ts +1 -0
  18. package/dist/cjs/stories/examples/Pagination.d.ts +1 -0
  19. package/dist/cjs/stories/examples/SelectableCells.d.ts +1 -0
  20. package/dist/cjs/stories/examples/Theming.d.ts +1 -0
  21. package/dist/cjs/stories/examples/crypto/CryptoExample.d.ts +14 -0
  22. package/dist/cjs/stories/examples/crypto/crypto-data.d.ts +30 -0
  23. package/dist/cjs/stories/examples/crypto/crypto-headers.d.ts +5 -0
  24. package/dist/cjs/stories/examples/pinned-columns/PinnedColumns.d.ts +1 -0
  25. package/dist/cjs/stories/tests/12-CellSelectionTests.stories.d.ts +1 -1
  26. package/dist/cjs/stories/tests/21-ColumnSelectionTests.stories.d.ts +1 -1
  27. package/dist/cjs/stories/tests/testUtils.d.ts +1 -1
  28. package/dist/cjs/stories/vanillaStoryConfig.d.ts +7 -0
  29. package/dist/index.es.js +1 -1
  30. package/dist/src/core/SimpleTableVanilla.d.ts +8 -0
  31. package/dist/src/core/api/TableAPIImpl.d.ts +13 -0
  32. package/dist/src/hooks/handleOutsideClick.d.ts +1 -1
  33. package/dist/src/index.d.ts +2 -0
  34. package/dist/src/managers/AnimationCoordinator.d.ts +2 -0
  35. package/dist/src/managers/SelectionManager/types.d.ts +6 -1
  36. package/dist/src/managers/TableManager.d.ts +1 -0
  37. package/dist/src/types/SimpleTableConfig.d.ts +1 -0
  38. package/dist/src/types/SimpleTableProps.d.ts +1 -0
  39. package/dist/src/utils/headerCell/types.d.ts +1 -1
  40. package/dist/src/utils/propSyncEqual.d.ts +65 -0
  41. package/dist/src/utils/rowUtils.d.ts +7 -0
  42. package/dist/stories/docs/Examples.stories.d.ts +1 -0
  43. package/dist/stories/docs/storyArgs.d.ts +7 -0
  44. package/dist/stories/examples/AlignmentExample.d.ts +1 -0
  45. package/dist/stories/examples/CellHighlighting.d.ts +1 -0
  46. package/dist/stories/examples/Pagination.d.ts +1 -0
  47. package/dist/stories/examples/SelectableCells.d.ts +1 -0
  48. package/dist/stories/examples/Theming.d.ts +1 -0
  49. package/dist/stories/examples/crypto/CryptoExample.d.ts +14 -0
  50. package/dist/stories/examples/crypto/crypto-data.d.ts +30 -0
  51. package/dist/stories/examples/crypto/crypto-headers.d.ts +5 -0
  52. package/dist/stories/examples/pinned-columns/PinnedColumns.d.ts +1 -0
  53. package/dist/stories/tests/12-CellSelectionTests.stories.d.ts +1 -1
  54. package/dist/stories/tests/21-ColumnSelectionTests.stories.d.ts +1 -1
  55. package/dist/stories/tests/testUtils.d.ts +1 -1
  56. package/dist/stories/vanillaStoryConfig.d.ts +7 -0
  57. package/package.json +1 -1
@@ -69,6 +69,14 @@ export declare class SimpleTableVanilla {
69
69
  private headerRegistry;
70
70
  private rowIndexMap;
71
71
  private animationCoordinator;
72
+ /**
73
+ * When true, the sort subscriber skips `captureAnimationSnapshot` so
74
+ * live-update-driven reorder/visibility changes don't FLIP-animate.
75
+ * User-initiated sorts leave this false and keep FLIP.
76
+ */
77
+ private suppressNextAnimationSnapshot;
78
+ /** Lazily created once — callers often invoke getAPI() every live tick. */
79
+ private cachedAPI;
72
80
  private autoScaleManager;
73
81
  private dimensionManager;
74
82
  private scrollManager;
@@ -41,6 +41,8 @@ export interface TableAPIContext {
41
41
  * re-render once the animation settles.
42
42
  */
43
43
  isCellAnimating?: (cellId: string) => boolean;
44
+ /** True while any FLIP cell transition is in flight (blocks live re-sort/re-filter). */
45
+ hasAnimatingCells?: () => boolean;
44
46
  columnEditorOpen: boolean;
45
47
  expandedDepthsManager: any;
46
48
  selectionManager: SelectionManager | null;
@@ -50,6 +52,17 @@ export interface TableAPIContext {
50
52
  getCachedFlattenResult?: () => FlattenRowsResult | null;
51
53
  getCachedProcessedResult?: () => ProcessRowsResult | null;
52
54
  onRender: () => void;
55
+ /**
56
+ * Bust the flatten / body row caches so the next render re-runs quick filter
57
+ * (and related processing) against in-place mutated row values.
58
+ */
59
+ invalidateRowsCache?: () => void;
60
+ /**
61
+ * Run `fn` without capturing a FLIP snapshot when sort/filter subscribers
62
+ * fire. Used for live-update-driven reorder/visibility changes so high-
63
+ * frequency ticks don't spam sort animations.
64
+ */
65
+ runWithoutAnimationSnapshot?: (fn: () => void) => void;
53
66
  setHeaders: (headers: HeaderObject[]) => void;
54
67
  setCurrentPage: (page: number) => void;
55
68
  setColumnEditorOpen: (open: boolean) => void;
@@ -1,7 +1,7 @@
1
1
  import HeaderObject from "../types/HeaderObject";
2
2
  import Cell from "../types/Cell";
3
3
  export interface HandleOutsideClickConfig {
4
- selectableCells: boolean;
4
+ selectableColumns: boolean;
5
5
  selectedCells: Set<string>;
6
6
  selectedColumns: Set<number>;
7
7
  setSelectedCells: (cells: Set<string>) => void;
@@ -49,4 +49,6 @@ import type { RowId } from "./types/RowId";
49
49
  import type { PinnedSectionsState } from "./types/PinnedSectionsState";
50
50
  export { SimpleTableVanilla };
51
51
  export { asRows } from "./utils/asRows";
52
+ export { headersStructurallyEqual, collectHeaderAccessors, rowsShallowUnchanged, shallowEqualRow, SHALLOW_ROW_COMPARE_MAX, } from "./utils/propSyncEqual";
53
+ export type { HeaderStructureLike, GetRowIdLike } from "./utils/propSyncEqual";
52
54
  export type { Accessor, AggregationConfig, AggregationType, AnimationsConfig, BoundingBox, Cell, CellChangeProps, CellClickProps, CellRenderer, CellRendererProps, CellValue, ChartOptions, ColumnEditorConfig, ColumnEditorCustomRenderer, ColumnEditorCustomRendererProps, ColumnEditorRowRenderer, ColumnEditorRowRendererComponents, ColumnEditorRowRendererProps, ColumnEditorSearchFunction, ColumnType, ColumnVisibilityState, Comparator, ComparatorProps, CustomTheme, CustomThemeProps, DragHandlerProps, EmptyStateRenderer, EmptyStateRendererProps, EnumOption, ErrorStateRenderer, ErrorStateRendererProps, ExportToCSVProps, ExportValueGetter, ExportValueProps, FilterCondition, FilterOperator, StringFilterOperator, NumberFilterOperator, BooleanFilterOperator, DateFilterOperator, EnumFilterOperator, FooterRendererProps, FooterPosition, GetRowId, GetRowIdParams, IconsConfig, LoadingStateRenderer, LoadingStateRendererProps, HeaderDropdown, HeaderDropdownProps, HeaderObject, HeaderRenderer, HeaderRendererProps, HeaderRendererComponents, OnRowGroupExpandProps, OnSortProps, QuickFilterConfig, QuickFilterGetter, QuickFilterGetterProps, QuickFilterMode, Row, RowButtonProps, RowId, RowSelectionChangeProps, RowSelectionMode, RowState, SetHeaderRenameProps, SharedTableProps, ShowWhen, SimpleTableConfig, SimpleTableProps, SortColumn, TableAPI, TableFilterState, TableHeaderProps, TableRowProps, Theme, PinnedSectionsState, UpdateDataProps, ValueFormatter, ValueFormatterProps, ValueGetter, ValueGetterProps, };
@@ -117,6 +117,8 @@ export declare class AnimationCoordinator {
117
117
  setEasing(easing: string): void;
118
118
  isEnabled(): boolean;
119
119
  isInFlight(cellId: string): boolean;
120
+ /** True while any FLIP / retained-cell transition is still running. */
121
+ hasInFlight(): boolean;
120
122
  getDuration(): number;
121
123
  getEasing(): string;
122
124
  /**
@@ -5,8 +5,13 @@ import type Cell from "../../types/Cell";
5
5
  import type { CustomTheme } from "../../types/CustomTheme";
6
6
  export declare const createSetString: ({ rowIndex, colIndex, rowId }: Cell) => string;
7
7
  export interface SelectionManagerConfig {
8
- /** When true, enables cell selection and column header selection. */
9
8
  selectableCells: boolean;
9
+ /**
10
+ * When true, column header click selects columns (`st-header-selected` on headers).
11
+ * Cell-in-column header tint (`st-header-has-highlighted-cell`) also applies when `selectableCells` is true
12
+ * even if this is false.
13
+ */
14
+ selectableColumns?: boolean;
10
15
  headers: HeaderObject[];
11
16
  tableRows: TableRowType[];
12
17
  onCellEdit?: (props: any) => void;
@@ -23,6 +23,7 @@ export interface TableManagerConfig {
23
23
  rowGrouping?: Accessor[];
24
24
  getRowId?: GetRowId;
25
25
  selectableCells?: boolean;
26
+ selectableColumns?: boolean;
26
27
  enableRowSelection?: boolean;
27
28
  copyHeadersToClipboard?: boolean;
28
29
  height?: string | number;
@@ -105,6 +105,7 @@ export interface SimpleTableConfig {
105
105
  rowsPerPage?: number;
106
106
  scrollParent?: HTMLElement | "window" | (() => HTMLElement | null);
107
107
  selectableCells?: boolean;
108
+ selectableColumns?: boolean;
108
109
  serverSidePagination?: boolean;
109
110
  shouldPaginate?: boolean;
110
111
  tableEmptyStateRenderer?: HTMLElement | string | null;
@@ -98,6 +98,7 @@ export interface SimpleTableProps {
98
98
  rowsPerPage?: number;
99
99
  scrollParent?: HTMLElement | "window" | (() => HTMLElement | null);
100
100
  selectableCells?: boolean;
101
+ selectableColumns?: boolean;
101
102
  serverSidePagination?: boolean;
102
103
  shouldPaginate?: boolean;
103
104
  tableEmptyStateRenderer?: HTMLElement | string | null;
@@ -74,7 +74,7 @@ export interface HeaderRenderContext {
74
74
  reverse: boolean;
75
75
  rows: Row[];
76
76
  selectColumns?: (columnIndices: number[]) => void;
77
- selectableCells?: boolean;
77
+ selectableColumns?: boolean;
78
78
  selectedColumns: Set<number>;
79
79
  selectedRowCount?: number; /** Used for context cache invalidation when row selection changes */
80
80
  setCollapsedHeaders: Dispatch<SetStateAction<Set<Accessor>>>;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Shared prop-sync helpers for framework adapters.
3
+ * Used to skip no-op `defaultHeaders` / `rows` updates when consumers rebuild
4
+ * column configs or shallow-clone rows every render.
5
+ */
6
+ /** Minimal header shape for structural comparison (renderers ignored). */
7
+ export type HeaderStructureLike = {
8
+ accessor: string | number | symbol;
9
+ width?: number | string;
10
+ minWidth?: number | string;
11
+ maxWidth?: number | string;
12
+ label?: string;
13
+ type?: string;
14
+ pinned?: string | boolean | null;
15
+ hide?: boolean;
16
+ isSortable?: boolean;
17
+ filterable?: boolean;
18
+ align?: string;
19
+ collapsible?: boolean;
20
+ collapseDefault?: boolean;
21
+ showWhen?: string;
22
+ isEditable?: boolean;
23
+ isEssential?: boolean;
24
+ disableReorder?: boolean;
25
+ expandable?: boolean;
26
+ excludeFromRender?: boolean;
27
+ autoSizeMode?: string;
28
+ tooltip?: string;
29
+ quickFilterable?: boolean;
30
+ filterOperators?: ReadonlyArray<string>;
31
+ children?: ReadonlyArray<HeaderStructureLike>;
32
+ };
33
+ /**
34
+ * True when two header trees describe the same columns (accessors, widths,
35
+ * flags, nesting). Ignores renderer identity.
36
+ */
37
+ export declare function headersStructurallyEqual(a: ReadonlyArray<HeaderStructureLike> | undefined, b: ReadonlyArray<HeaderStructureLike> | undefined): boolean;
38
+ /** Collect every accessor in a header tree (for renderer-cache pruning). */
39
+ export declare function collectHeaderAccessors(headers: ReadonlyArray<HeaderStructureLike>, into?: Set<string>): Set<string>;
40
+ /**
41
+ * Shallow equality of a single row object (own enumerable keys, `===` values).
42
+ * Identical references are equal. In-place mutation on a shared object is
43
+ * invisible — callers must pass new object identities when data changes.
44
+ */
45
+ export declare function shallowEqualRow(a: object, b: object): boolean;
46
+ export type GetRowIdLike = (params: {
47
+ row: unknown;
48
+ depth?: number;
49
+ index?: number;
50
+ rowPath?: (string | number)[];
51
+ rowIndexPath?: number[];
52
+ groupingKey?: string;
53
+ }) => string | number | undefined;
54
+ /**
55
+ * Above this length, skip per-field shallow compares when row object identity
56
+ * differs. Same-array-ref and same-row-object cases stay O(1) / O(n) pointer
57
+ * checks. Protects huge client datasets from O(n × fields) scans.
58
+ */
59
+ export declare const SHALLOW_ROW_COMPARE_MAX = 50000;
60
+ /**
61
+ * True when `next` is a no-op relative to `prev` for table sync:
62
+ * same length, matching `getRowId` sequence (when provided), and each row
63
+ * either the same object or shallow-equal (for modest list sizes).
64
+ */
65
+ export declare function rowsShallowUnchanged(prev: ReadonlyArray<object> | undefined, next: ReadonlyArray<object> | undefined, getRowId?: GetRowIdLike): boolean;
@@ -55,6 +55,13 @@ export declare const calculateNestedTableHeight: ({ calculatedHeight, customHeig
55
55
  * getNestedValue(row, "releaseDate[0]") returns row.releaseDate[0]
56
56
  */
57
57
  export declare const getNestedValue: (obj: Row, path: Accessor) => CellValue;
58
+ /**
59
+ * True when both arrays have the same length and the same row object references
60
+ * at each index. Used by FilterManager / SortManager so in-place live updates
61
+ * that recompute filter/sort only notify subscribers when membership or order
62
+ * actually changed (`.filter()` / `handleSort` always allocate new arrays).
63
+ */
64
+ export declare const rowsOrderEqual: (a: Row[], b: Row[]) => boolean;
58
65
  /**
59
66
  * Set a nested property value in an object using dot notation and array bracket notation
60
67
  * Examples:
@@ -7,6 +7,7 @@ declare const meta: Meta;
7
7
  export default meta;
8
8
  export declare const Billing: StoryObj;
9
9
  export declare const Clay: StoryObj;
10
+ export declare const Crypto: StoryObj;
10
11
  export declare const Finance: StoryObj;
11
12
  export declare const Infrastructure: StoryObj;
12
13
  export declare const Leads: StoryObj;
@@ -18,6 +18,7 @@ export declare const storyArgs: (exampleDefaults?: Partial<UniversalVanillaArgs>
18
18
  hideFooter?: boolean | undefined;
19
19
  rowsPerPage?: number | undefined;
20
20
  selectableCells?: boolean | undefined;
21
+ selectableColumns?: boolean | undefined;
21
22
  shouldPaginate?: boolean | undefined;
22
23
  theme?: import("../../src/types/Theme").default | undefined;
23
24
  useHoverRowBackground?: boolean | undefined;
@@ -110,6 +111,12 @@ export declare const storyArgs: (exampleDefaults?: Partial<UniversalVanillaArgs>
110
111
  };
111
112
  description: string;
112
113
  };
114
+ selectableColumns: {
115
+ control: {
116
+ type: "boolean";
117
+ };
118
+ description: string;
119
+ };
113
120
  shouldPaginate: {
114
121
  control: {
115
122
  type: "boolean";
@@ -3,6 +3,7 @@ export declare const alignmentExampleDefaults: {
3
3
  columnResizing: boolean;
4
4
  columnReordering: boolean;
5
5
  selectableCells: boolean;
6
+ selectableColumns: boolean;
6
7
  editColumns: boolean;
7
8
  height: string;
8
9
  };
@@ -2,5 +2,6 @@ import { type UniversalVanillaArgs } from "../vanillaStoryConfig";
2
2
  export declare const cellHighlightingExampleDefaults: {
3
3
  height: string;
4
4
  selectableCells: boolean;
5
+ selectableColumns: boolean;
5
6
  };
6
7
  export declare function renderCellHighlightingExample(args?: Partial<UniversalVanillaArgs>): HTMLElement;
@@ -5,6 +5,7 @@ export declare const paginationExampleDefaults: {
5
5
  columnReordering: boolean;
6
6
  columnResizing: boolean;
7
7
  selectableCells: boolean;
8
+ selectableColumns: boolean;
8
9
  theme: "modern-dark";
9
10
  height: string;
10
11
  };
@@ -2,6 +2,7 @@ import { type UniversalVanillaArgs } from "../vanillaStoryConfig";
2
2
  export declare const selectableCellsExampleDefaults: {
3
3
  rowGrouping: readonly ["stores"];
4
4
  selectableCells: boolean;
5
+ selectableColumns: boolean;
5
6
  columnResizing: boolean;
6
7
  columnReordering: boolean;
7
8
  height: string;
@@ -4,6 +4,7 @@ export declare const themingExampleDefaults: {
4
4
  columnReordering: boolean;
5
5
  editColumns: boolean;
6
6
  selectableCells: boolean;
7
+ selectableColumns: boolean;
7
8
  shouldPaginate: boolean;
8
9
  rowsPerPage: number;
9
10
  height: string;
@@ -0,0 +1,14 @@
1
+ import { type UniversalVanillaArgs } from "../../vanillaStoryConfig";
2
+ export declare const cryptoExampleDefaults: {
3
+ columnResizing: boolean;
4
+ columnReordering: boolean;
5
+ selectableCells: boolean;
6
+ editColumns: boolean;
7
+ cellUpdateFlash: boolean;
8
+ height: string;
9
+ customTheme: {
10
+ headerHeight: number;
11
+ rowHeight: number;
12
+ };
13
+ };
14
+ export declare function renderCryptoExample(args?: Partial<UniversalVanillaArgs>): HTMLElement;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Deterministic crypto market dataset – same generator as the marketing
3
+ * Crypto example (`apps/marketing/src/examples/crypto/useCryptoData.ts`).
4
+ */
5
+ import type { Row } from "../../../src/index";
6
+ export interface CryptoCoin extends Row {
7
+ id: string;
8
+ rank: number;
9
+ name: string;
10
+ symbol: string;
11
+ price: number;
12
+ change1h: number;
13
+ change24h: number;
14
+ change7d: number;
15
+ change30d: number;
16
+ marketCap: number;
17
+ volume24h: number;
18
+ circulatingSupply: number;
19
+ maxSupply: number | null;
20
+ supplyPercent: number;
21
+ ath: number;
22
+ athChangePercent: number;
23
+ category: string;
24
+ priceHistory: number[];
25
+ }
26
+ export declare function generateCryptoData(count?: number): CryptoCoin[];
27
+ export declare function formatCompact(value: number): string;
28
+ export declare function formatCompactUsd(value: number): string;
29
+ export declare function formatPrice(value: number): string;
30
+ export declare function formatSignedPercent(value: number, digits?: number): string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Crypto example headers – vanilla port of the marketing crypto-headers.
3
+ */
4
+ import type { HeaderObject } from "../../../src/index";
5
+ export declare function getCryptoHeaders(): HeaderObject[];
@@ -4,6 +4,7 @@ export declare const pinnedColumnsExampleDefaults: {
4
4
  rowGrouping: readonly ["stores"];
5
5
  columnReordering: boolean;
6
6
  selectableCells: boolean;
7
+ selectableColumns: boolean;
7
8
  editColumns: boolean;
8
9
  height: string;
9
10
  enableStickyParents: boolean;
@@ -74,7 +74,7 @@ export declare const OutsideClickClearsSelection: {
74
74
  }) => Promise<void>;
75
75
  };
76
76
  /**
77
- * Edge case: when selectableCells is true, clicking a column header should clear
77
+ * Edge case: when selectableColumns is true, clicking a column header should clear
78
78
  * any existing cell selection (and initial focused cell) so that column selection takes over.
79
79
  */
80
80
  export declare const ColumnHeaderClickClearsCellSelection: {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * COLUMN SELECTION TESTS
3
- * Tests for selectableCells (column selection mode) and onColumnSelect callback.
3
+ * Tests for selectableColumns and onColumnSelect callback.
4
4
  */
5
5
  import type { Meta } from "@storybook/html";
6
6
  declare const meta: Meta;
@@ -24,7 +24,7 @@ export declare const rowExists: (container: HTMLElement, rowIndex: string) => bo
24
24
  * This mimics the old .st-row structure for backward compatibility with tests
25
25
  */
26
26
  export declare const getVirtualRows: (container: HTMLElement) => HTMLElement[][];
27
- export declare const waitForTable: (timeout?: number) => Promise<void>;
27
+ export declare const waitForTable: (timeoutOrRoot?: number | ParentNode, maybeTimeout?: number) => Promise<void>;
28
28
  /** Poll until predicate returns true or timeout (reduces flake vs fixed setTimeout). */
29
29
  export declare function waitUntil(predicate: () => boolean, options?: {
30
30
  timeoutMs?: number;
@@ -18,6 +18,7 @@ export interface UniversalVanillaArgs {
18
18
  hideFooter?: boolean;
19
19
  rowsPerPage?: number;
20
20
  selectableCells?: boolean;
21
+ selectableColumns?: boolean;
21
22
  shouldPaginate?: boolean;
22
23
  theme?: Theme;
23
24
  useHoverRowBackground?: boolean;
@@ -111,6 +112,12 @@ export declare const vanillaArgTypes: {
111
112
  };
112
113
  description: string;
113
114
  };
115
+ selectableColumns: {
116
+ control: {
117
+ type: "boolean";
118
+ };
119
+ description: string;
120
+ };
114
121
  shouldPaginate: {
115
122
  control: {
116
123
  type: "boolean";