simple-table-core 3.8.5 → 3.8.7

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 (50) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/src/core/SimpleTableVanilla.d.ts +19 -0
  3. package/dist/cjs/src/core/api/TableAPIImpl.d.ts +2 -0
  4. package/dist/cjs/src/core/rendering/RenderOrchestrator.d.ts +3 -0
  5. package/dist/cjs/src/core/rendering/SectionRenderer.d.ts +8 -0
  6. package/dist/cjs/src/core/rendering/TableRenderer.d.ts +3 -0
  7. package/dist/cjs/src/managers/AnimationCoordinator.d.ts +44 -0
  8. package/dist/cjs/src/types/SimpleTableConfig.d.ts +10 -0
  9. package/dist/cjs/src/types/TableAPI.d.ts +6 -1
  10. package/dist/cjs/src/types/Theme.d.ts +1 -1
  11. package/dist/cjs/src/utils/bodyCell/eventTracking.d.ts +1 -1
  12. package/dist/cjs/src/utils/bodyCell/types.d.ts +8 -0
  13. package/dist/cjs/src/utils/charts/createBarChart.d.ts +5 -0
  14. package/dist/cjs/src/utils/charts/createLineAreaChart.d.ts +8 -0
  15. package/dist/cjs/src/utils/headerWidthUtils.d.ts +6 -0
  16. package/dist/cjs/stories/examples/music/MusicExample.d.ts +1 -1
  17. package/dist/cjs/stories/tests/32-ThemesTests.stories.d.ts +1 -17
  18. package/dist/cjs/stories/tests/46-AutoSizeColumnsTests.stories.d.ts +53 -0
  19. package/dist/cjs/styles.css +1 -1
  20. package/dist/index.es.js +1 -1
  21. package/dist/src/core/SimpleTableVanilla.d.ts +19 -0
  22. package/dist/src/core/api/TableAPIImpl.d.ts +2 -0
  23. package/dist/src/core/rendering/RenderOrchestrator.d.ts +3 -0
  24. package/dist/src/core/rendering/SectionRenderer.d.ts +8 -0
  25. package/dist/src/core/rendering/TableRenderer.d.ts +3 -0
  26. package/dist/src/managers/AnimationCoordinator.d.ts +44 -0
  27. package/dist/src/types/SimpleTableConfig.d.ts +10 -0
  28. package/dist/src/types/TableAPI.d.ts +6 -1
  29. package/dist/src/types/Theme.d.ts +1 -1
  30. package/dist/src/utils/bodyCell/eventTracking.d.ts +1 -1
  31. package/dist/src/utils/bodyCell/types.d.ts +8 -0
  32. package/dist/src/utils/charts/createBarChart.d.ts +5 -0
  33. package/dist/src/utils/charts/createLineAreaChart.d.ts +8 -0
  34. package/dist/src/utils/headerWidthUtils.d.ts +6 -0
  35. package/dist/stories/examples/music/MusicExample.d.ts +1 -1
  36. package/dist/stories/tests/32-ThemesTests.stories.d.ts +1 -17
  37. package/dist/stories/tests/46-AutoSizeColumnsTests.stories.d.ts +53 -0
  38. package/dist/styles.css +1 -1
  39. package/package.json +1 -1
  40. package/src/styles/all-themes.css +0 -4
  41. package/src/styles/base.css +47 -70
  42. package/src/styles/themes/dark.css +7 -5
  43. package/src/styles/themes/light.css +4 -2
  44. package/src/styles/themes/modern-dark.css +7 -146
  45. package/src/styles/themes/modern-light.css +11 -138
  46. package/src/styles/themes/neutral.css +6 -4
  47. package/src/styles/themes/theme-custom.css +6 -253
  48. package/src/styles/themes/frost.css +0 -116
  49. package/src/styles/themes/sky.css +0 -115
  50. package/src/styles/themes/violet.css +0 -116
@@ -13,6 +13,17 @@ export declare class SimpleTableVanilla {
13
13
  private hoveredHeaderRef;
14
14
  private localRows;
15
15
  private headers;
16
+ /**
17
+ * Pristine deep-cloned snapshot of the column definitions as configured
18
+ * (constructor / update with `defaultHeaders`). `this.headers` shares object
19
+ * references with `config.defaultHeaders` at mount, and the column editor
20
+ * mutates header objects in place (e.g. `header.hide = true`) — so
21
+ * `config.defaultHeaders` drifts with runtime state and cannot serve as the
22
+ * reset target. `resetColumns()` restores from this snapshot instead, giving
23
+ * a well-defined default: every column visible except those explicitly
24
+ * configured with `hide: true` in the definitions.
25
+ */
26
+ private pristineDefaultHeaders;
16
27
  private essentialAccessors;
17
28
  /** Accessors of leaf columns that should size to content (width:"auto" or autoSizeColumns). */
18
29
  private autoSizeAccessors;
@@ -188,6 +199,14 @@ export declare class SimpleTableVanilla {
188
199
  * No-op when animations are disabled (which already includes the
189
200
  * prefers-reduced-motion check via {@link AnimationCoordinator.isEnabled}).
190
201
  */
202
+ /**
203
+ * Walk the CURRENT (pre-change) header tree and collect every accessor that
204
+ * is renderable as a header cell given the current collapsed/hidden state —
205
+ * group headers plus the leaf columns visible under them (honoring
206
+ * `showWhen` and the collapsed set). Used by {@link beginAccordionAnimation}
207
+ * to seed the animation coordinator's re-entry guard.
208
+ */
209
+ private collectAccordionRenderableAccessors;
191
210
  private beginAccordionAnimation;
192
211
  private initializeManagers;
193
212
  mount(): void;
@@ -14,6 +14,8 @@ export interface TableAPIContext {
14
14
  localRows: Row[];
15
15
  effectiveHeaders: HeaderObject[];
16
16
  headers: HeaderObject[];
17
+ /** Pristine snapshot of the configured column definitions (see SimpleTableVanilla.pristineDefaultHeaders). */
18
+ getPristineDefaultHeaders: () => HeaderObject[];
17
19
  essentialAccessors: Set<string>;
18
20
  customTheme: CustomTheme;
19
21
  currentPage: number;
@@ -44,6 +44,8 @@ export interface RenderContext {
44
44
  getCollapsedHeaders?: () => Set<Accessor>;
45
45
  getExpandedRows: () => Map<string, number>;
46
46
  getHeaders: () => HeaderObject[];
47
+ /** Pristine snapshot of the configured column definitions — the reset target for the column editor's reset button. */
48
+ getPristineDefaultHeaders: () => HeaderObject[];
47
49
  getRowStateMap: () => Map<string | number, RowState>;
48
50
  headerRegistry: Map<string, any>;
49
51
  headers: HeaderObject[];
@@ -125,6 +127,7 @@ export declare class RenderOrchestrator {
125
127
  getLastProcessedResult(): ProcessRowsResult | null;
126
128
  /** See {@link TableRenderer.getCurrentBodyLayouts}. */
127
129
  getCurrentBodyLayouts(): Map<HTMLElement, Map<string, CellPosition>>;
130
+ setOnRendererHostDiscard(cb: ((host: HTMLElement) => void) | undefined): void;
128
131
  invalidateCache(type?: "body" | "header" | "context" | "all"): void;
129
132
  computeEffectiveHeaders(headers: HeaderObject[], config: SimpleTableConfig, customTheme: CustomTheme, containerWidth?: number): HeaderObject[];
130
133
  /**
@@ -44,6 +44,13 @@ export interface BodySectionParams {
44
44
  export declare class SectionRenderer {
45
45
  private headerSections;
46
46
  private bodySections;
47
+ /**
48
+ * Callback fired before a body cell host element is permanently removed in
49
+ * the {@link invalidateCache} "all" path (which wipes every rendered cell).
50
+ * Threaded down from the table config so framework adapters can tear down
51
+ * renderer subtrees (React portals, etc.) before the nodes are discarded.
52
+ */
53
+ private onRendererHostDiscard?;
47
54
  private bodyCellsCache;
48
55
  private headerCellsCache;
49
56
  private contextCache;
@@ -64,6 +71,7 @@ export declare class SectionRenderer {
64
71
  private getCachedBodyCells;
65
72
  private getCachedHeaderCells;
66
73
  private getCachedContext;
74
+ setOnRendererHostDiscard(cb: ((host: HTMLElement) => void) | undefined): void;
67
75
  invalidateCache(type?: "body" | "header" | "context" | "all"): void;
68
76
  /**
69
77
  * Get the next colIndex after rendering a section
@@ -41,6 +41,8 @@ export interface TableRendererDeps {
41
41
  getCollapsedRows: () => Map<string, number>;
42
42
  getExpandedRows: () => Map<string, number>;
43
43
  getHeaders: () => HeaderObject[];
44
+ /** Pristine snapshot of the configured column definitions — the reset target for the column editor's reset button. */
45
+ getPristineDefaultHeaders: () => HeaderObject[];
44
46
  getRowStateMap: () => Map<string | number, any>;
45
47
  headerRegistry: Map<string, any>;
46
48
  headers: HeaderObject[];
@@ -99,6 +101,7 @@ export declare class TableRenderer {
99
101
  private pendingRenderCallback;
100
102
  constructor();
101
103
  private scheduleRender;
104
+ setOnRendererHostDiscard(cb: ((host: HTMLElement) => void) | undefined): void;
102
105
  invalidateCache(type?: "body" | "header" | "context" | "all"): void;
103
106
  /** See {@link SectionRenderer.getCurrentBodyLayouts}. */
104
107
  getCurrentBodyLayouts(): Map<HTMLElement, Map<string, CellPosition>>;
@@ -41,6 +41,21 @@ export declare class AnimationCoordinator {
41
41
  * rather than appearing in place. Cleared at the end of {@link play}.
42
42
  */
43
43
  private incomingOrigins;
44
+ /**
45
+ * Accessors that were already renderable (visible leaf/group columns) in the
46
+ * pre-change layout for an in-flight accordion-horizontal toggle. Set once
47
+ * per collapse/expand render and consumed by the renderers' grow-from-zero
48
+ * gate so a column that merely re-enters the virtualization band (because the
49
+ * collapsed group shrank the content width and clamped scrollLeft) is NOT
50
+ * mistaken for a freshly-expanded column and animated from width 0.
51
+ *
52
+ * Header cells have no full pre-change conceptual layout the way body cells do
53
+ * (see SectionRenderer.getCurrentBodyLayouts), so `hasSnapshotEntry` alone
54
+ * can't tell "newly visible" apart from "scrolled back into view". This set
55
+ * supplies the missing pre-change visibility signal. Cleared at the end of
56
+ * {@link play}.
57
+ */
58
+ private accordionPreVisibleAccessors;
44
59
  private inFlight;
45
60
  /** Outgoing cells the renderer handed off; keyed per container so play() finds them. */
46
61
  private retainedCells;
@@ -82,7 +97,21 @@ export declare class AnimationCoordinator {
82
97
  * transforms it left behind, so only the latest sort animates.
83
98
  */
84
99
  private scheduledFlip;
100
+ /**
101
+ * Invoked immediately BEFORE a retained/ghost element is permanently removed
102
+ * from the DOM (FLIP/shrink/cancel/destroy teardown). Lets framework adapters
103
+ * tear down renderer subtrees (React portals, etc.) mounted into the element
104
+ * before it's discarded. NOT called on reuse/reparent paths
105
+ * ({@link claimRetainedForReuse} success), so a reclaimed ghost keeps its
106
+ * content.
107
+ */
108
+ private onHostDiscard?;
85
109
  constructor(opts?: AnimationCoordinatorOptions);
110
+ /**
111
+ * Register the callback fired before a ghost/retained element is permanently
112
+ * removed (see {@link onHostDiscard}). Additive: passing `undefined` disables it.
113
+ */
114
+ setOnHostDiscard(cb: ((host: HTMLElement) => void) | undefined): void;
86
115
  setEnabled(enabled: boolean): void;
87
116
  setDuration(duration: number): void;
88
117
  setEasing(easing: string): void;
@@ -101,6 +130,21 @@ export declare class AnimationCoordinator {
101
130
  * the corresponding cells.
102
131
  */
103
132
  setIncomingOrigins(origins: Map<string, CellPosition> | null): void;
133
+ /**
134
+ * Register the set of accessors that were renderable in the pre-change layout
135
+ * of an accordion-horizontal toggle. Must be set after `captureSnapshot` and
136
+ * before the render that creates cells. Consumed and cleared by the next
137
+ * {@link play}. Pass `null` (e.g. for vertical/row accordions) to disable the
138
+ * re-entry guard so behavior is unchanged.
139
+ */
140
+ setAccordionPreVisibleAccessors(accessors: Set<string> | null): void;
141
+ /**
142
+ * True when `accessor` was already a renderable column before the current
143
+ * accordion-horizontal toggle. Renderers use this to skip the grow-from-zero
144
+ * animation for columns that only re-entered the virtualization band rather
145
+ * than genuinely becoming visible from an expand.
146
+ */
147
+ wasRenderableBeforeAccordion(accessor: string): boolean;
104
148
  /**
105
149
  * Read scroller layout metrics for `container`, caching the result for the
106
150
  * remainder of the current render cycle. Subsequent calls in the same
@@ -72,6 +72,16 @@ export interface SimpleTableConfig {
72
72
  onPageChange?: (page: number) => void | Promise<void>;
73
73
  onRowGroupExpand?: (props: OnRowGroupExpandProps) => void | Promise<void>;
74
74
  onRowSelectionChange?: (props: RowSelectionChangeProps) => void;
75
+ /**
76
+ * Called by the renderer immediately BEFORE it permanently discards a host
77
+ * element that may contain async-framework renderer output (e.g. React
78
+ * portals): innerHTML clears on cell rebuild/edit, plain cell removal, and
79
+ * the animation coordinator's ghost/FLIP/shrink teardown paths. Framework
80
+ * adapters use this to tear down the renderer subtree mounted into `host`
81
+ * (or any descendant) so it isn't orphaned. Reuse/reparent paths never fire
82
+ * it, so a reused node keeps its renderer content.
83
+ */
84
+ onRendererHostDiscard?: (host: HTMLElement) => void;
75
85
  onSortChange?: (sort: SortColumn | null) => void;
76
86
  quickFilter?: QuickFilterConfig;
77
87
  rowButtons?: RowButton[];
@@ -47,7 +47,12 @@ export type TableAPI = {
47
47
  applyColumnVisibility: (visibility: {
48
48
  [accessor: string]: boolean;
49
49
  }) => Promise<void>;
50
- /** Reset columns to default order and visibility (restores defaultHeaders state). */
50
+ /**
51
+ * Reset columns to the configured definitions: default order, widths, and
52
+ * visibility. All columns become visible again except those explicitly
53
+ * defined with `hide: true` in `defaultHeaders`, regardless of any runtime
54
+ * visibility changes made since mount.
55
+ */
51
56
  resetColumns: () => void;
52
57
  setQuickFilter: (text: string) => void;
53
58
  getSelectedCells: () => Set<string>;
@@ -1,2 +1,2 @@
1
- type Theme = "light" | "dark" | "sky" | "violet" | "neutral" | "custom" | "frost" | "modern-light" | "modern-dark";
1
+ type Theme = "light" | "dark" | "neutral" | "custom" | "modern-light" | "modern-dark";
2
2
  export default Theme;
@@ -1,3 +1,3 @@
1
1
  export declare const addTrackedEventListener: (element: HTMLElement, event: string, handler: EventListener, options?: AddEventListenerOptions) => void;
2
2
  export declare const getRenderedCells: (container: HTMLElement) => Map<string, HTMLElement>;
3
- export declare const cleanupBodyCellRendering: (container?: HTMLElement) => void;
3
+ export declare const cleanupBodyCellRendering: (container?: HTMLElement, onHostDiscard?: ((host: HTMLElement) => void) | undefined) => void;
@@ -104,6 +104,14 @@ export interface CellRenderContext {
104
104
  handleRowSelect?: (rowId: string, checked: boolean) => void;
105
105
  handleMouseDown: (cell: CellData) => void;
106
106
  handleMouseOver: (cell: CellData, clientX: number, clientY: number) => void;
107
+ /**
108
+ * Called immediately BEFORE the renderer permanently discards a host element
109
+ * (e.g. `innerHTML = ""` on cell rebuild/edit, or a plain `element.remove()`).
110
+ * Framework adapters use this to tear down any renderer subtree (React
111
+ * portal, etc.) mounted into `host` or one of its descendants. Reuse paths
112
+ * never call it, so a reused node keeps its content.
113
+ */
114
+ onRendererHostDiscard?: (host: HTMLElement) => void;
107
115
  cellRegistry?: Map<string, CellRegistryEntry>;
108
116
  setCollapsedRows: Dispatch<SetStateAction<Map<string, number>>>;
109
117
  setExpandedRows: Dispatch<SetStateAction<Map<string, number>>>;
@@ -8,6 +8,11 @@ export interface BarChartProps {
8
8
  min?: number;
9
9
  max?: number;
10
10
  }
11
+ /**
12
+ * Renders a sparkline bar chart in pixel space: the viewBox always matches the
13
+ * actual rendered size (tracked via ResizeObserver), and bar edges are snapped
14
+ * to whole pixels so bars and gaps stay uniform and crisp at any column width.
15
+ */
11
16
  export declare const createBarChart: (options: BarChartProps) => {
12
17
  element: SVGSVGElement;
13
18
  update: (newOptions: Partial<BarChartProps>) => void;
@@ -10,6 +10,14 @@ export interface LineAreaChartProps {
10
10
  min?: number;
11
11
  max?: number;
12
12
  }
13
+ /**
14
+ * Renders a sparkline line/area chart in pixel space: the viewBox always
15
+ * matches the actual rendered size (tracked via ResizeObserver), so the stroke
16
+ * keeps a uniform width instead of being smeared by non-uniform scaling. The
17
+ * line is inset by half the stroke width so peaks and valleys aren't clipped,
18
+ * and the area is filled with a vertical gradient that fades toward the
19
+ * baseline.
20
+ */
13
21
  export declare const createLineAreaChart: (options: LineAreaChartProps) => {
14
22
  element: SVGSVGElement;
15
23
  update: (newOptions: Partial<LineAreaChartProps>) => void;
@@ -95,4 +95,10 @@ export declare const calculateHeaderContentWidth: (accessor: Accessor, options?:
95
95
  theme?: any;
96
96
  /** Scope `.st-cell-content` font/padding sampling to this table instance */
97
97
  styleRoot?: ParentNode | null;
98
+ /**
99
+ * The table's resolved sort icon. Used to reserve space on sortable columns
100
+ * that are not currently sorted (the icon only exists on the active sort
101
+ * column), so sorting later does not push the label into ellipsis.
102
+ */
103
+ sortIcon?: string | HTMLElement | SVGSVGElement;
98
104
  }) => number;
@@ -3,7 +3,7 @@ export declare const musicExampleDefaults: {
3
3
  columnReordering: boolean;
4
4
  columnResizing: boolean;
5
5
  selectableCells: boolean;
6
- theme: "frost";
6
+ theme: "modern-light";
7
7
  customTheme: {
8
8
  rowHeight: number;
9
9
  headerHeight: number;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THEMES TESTS
3
- * Tests for SimpleTable theme prop (light, dark, sky, violet, etc.).
3
+ * Tests for SimpleTable theme prop (light, dark, neutral, modern-light, modern-dark).
4
4
  */
5
5
  import type { Meta } from "@storybook/html";
6
6
  declare const meta: Meta;
@@ -21,22 +21,6 @@ export declare const ThemeDark: {
21
21
  canvasElement: HTMLElement;
22
22
  }) => Promise<void>;
23
23
  };
24
- export declare const ThemeSky: {
25
- render: () => HTMLDivElement & {
26
- _table?: import("../../src/index").SimpleTableVanilla | undefined;
27
- };
28
- play: ({ canvasElement }: {
29
- canvasElement: HTMLElement;
30
- }) => Promise<void>;
31
- };
32
- export declare const ThemeViolet: {
33
- render: () => HTMLDivElement & {
34
- _table?: import("../../src/index").SimpleTableVanilla | undefined;
35
- };
36
- play: ({ canvasElement }: {
37
- canvasElement: HTMLElement;
38
- }) => Promise<void>;
39
- };
40
24
  export declare const ThemeModernLight: {
41
25
  render: () => HTMLDivElement & {
42
26
  _table?: import("../../src/index").SimpleTableVanilla | undefined;
@@ -84,6 +84,28 @@ export declare const AutoSizeMeasuresCustomRenderer: {
84
84
  canvasElement: HTMLElement;
85
85
  }) => Promise<void>;
86
86
  };
87
+ export declare const AutoSizeMeasuresCustomHeaderRenderer: {
88
+ parameters: {
89
+ tags: string[];
90
+ };
91
+ render: () => HTMLDivElement & {
92
+ _table?: SimpleTableVanilla | undefined;
93
+ };
94
+ play: ({ canvasElement }: {
95
+ canvasElement: HTMLElement;
96
+ }) => Promise<void>;
97
+ };
98
+ export declare const AutoSizeSortIconDoesNotTruncateLabel: {
99
+ parameters: {
100
+ tags: string[];
101
+ };
102
+ render: () => HTMLDivElement & {
103
+ _table?: SimpleTableVanilla | undefined;
104
+ };
105
+ play: ({ canvasElement }: {
106
+ canvasElement: HTMLElement;
107
+ }) => Promise<void>;
108
+ };
87
109
  export declare const AutoSizeMeasuresFormattedValue: {
88
110
  parameters: {
89
111
  tags: string[];
@@ -249,6 +271,37 @@ export declare const AutoSizeNoFlicker: {
249
271
  canvasElement: HTMLElement;
250
272
  }) => Promise<void>;
251
273
  };
274
+ export declare const AutoSizeAsyncRendererInternalTruncation: {
275
+ parameters: {
276
+ tags: string[];
277
+ };
278
+ render: () => HTMLDivElement & {
279
+ _table?: SimpleTableVanilla | undefined;
280
+ };
281
+ play: ({ canvasElement }: {
282
+ canvasElement: HTMLElement;
283
+ }) => Promise<void>;
284
+ };
285
+ export declare const AutoSizeConsistentAcrossContainerWidths: {
286
+ parameters: {
287
+ tags: string[];
288
+ };
289
+ render: () => HTMLDivElement;
290
+ play: ({ canvasElement }: {
291
+ canvasElement: HTMLElement;
292
+ }) => Promise<void>;
293
+ };
294
+ export declare const AutoSizeEmptyStateAsyncHeaderRenderer: {
295
+ parameters: {
296
+ tags: string[];
297
+ };
298
+ render: () => HTMLDivElement & {
299
+ _table?: SimpleTableVanilla | undefined;
300
+ };
301
+ play: ({ canvasElement }: {
302
+ canvasElement: HTMLElement;
303
+ }) => Promise<void>;
304
+ };
252
305
  export declare const SamplingAndOutlierHelpers: {
253
306
  parameters: {
254
307
  tags: string[];