simple-table-core 4.1.6 → 4.1.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 (84) hide show
  1. package/README.md +15 -7
  2. package/dist/cjs/index.js +1 -1
  3. package/dist/cjs/styles.css +1 -1
  4. package/dist/consts/general-consts.d.ts +0 -4
  5. package/dist/core/SimpleTableVanilla.d.ts +19 -275
  6. package/dist/core/api/TableAPIContext.d.ts +74 -0
  7. package/dist/core/api/TableAPIImpl.d.ts +2 -74
  8. package/dist/core/api/buildTableAPIContext.d.ts +61 -0
  9. package/dist/core/dev/UnvirtualizedRowsWarning.d.ts +20 -0
  10. package/dist/core/initialization/createDataManagers.d.ts +37 -0
  11. package/dist/core/initialization/wireMountManagers.d.ts +43 -0
  12. package/dist/core/pipeline/syncPivotPipeline.d.ts +41 -0
  13. package/dist/core/rendering/RenderContext.d.ts +125 -0
  14. package/dist/core/rendering/RenderOrchestrator.d.ts +8 -119
  15. package/dist/core/rendering/SectionRenderer.d.ts +21 -15
  16. package/dist/core/rendering/TableRenderer.d.ts +6 -98
  17. package/dist/core/rendering/TableRendererDeps.d.ts +98 -0
  18. package/dist/core/rendering/buildRenderContext.d.ts +94 -0
  19. package/dist/core/rendering/cellRenderContexts.d.ts +11 -0
  20. package/dist/core/rendering/renderBodySections.d.ts +14 -0
  21. package/dist/core/rendering/renderHeaderSections.d.ts +13 -0
  22. package/dist/core/rendering/sectionCaches.d.ts +24 -0
  23. package/dist/core/rendering/sectionExtraRows.d.ts +19 -0
  24. package/dist/core/rendering/sectionLayout.d.ts +42 -0
  25. package/dist/core/vanilla/VanillaLiveHost.d.ts +103 -0
  26. package/dist/core/vanilla/applyTableUpdate.d.ts +10 -0
  27. package/dist/core/vanilla/createVanillaRenderContext.d.ts +4 -0
  28. package/dist/core/vanilla/destroyTableResources.d.ts +26 -0
  29. package/dist/core/vanilla/syncRowSelectionManager.d.ts +13 -0
  30. package/dist/core/vanilla/tableContainers.d.ts +5 -0
  31. package/dist/core/vanilla/toTableAPIContextHost.d.ts +3 -0
  32. package/dist/hooks/contentHeight.d.ts +3 -1
  33. package/dist/hooks/scrollbarWidth.d.ts +0 -43
  34. package/dist/hooks/useAggregatedRows.d.ts +0 -2
  35. package/dist/index.es.js +1 -1
  36. package/dist/managers/AccordionController.d.ts +39 -0
  37. package/dist/managers/AnimationCoordinator.d.ts +15 -1
  38. package/dist/managers/AutoSizeManager.d.ts +64 -0
  39. package/dist/managers/CellSlideAnimator.d.ts +54 -0
  40. package/dist/managers/DragHandlerManager.d.ts +4 -26
  41. package/dist/managers/ExternalScrollController.d.ts +68 -0
  42. package/dist/managers/ScrollRenderCoalescer.d.ts +32 -0
  43. package/dist/managers/SelectionManager/mouseUtils.d.ts +3 -3
  44. package/dist/styles.css +1 -1
  45. package/dist/utils/accordionAnimation.d.ts +0 -5
  46. package/dist/utils/bodyCell/editing.d.ts +1 -1
  47. package/dist/utils/bodyCell/editors/booleanDropdown.d.ts +1 -1
  48. package/dist/utils/bodyCell/editors/datePicker.d.ts +1 -1
  49. package/dist/utils/bodyCell/editors/enumDropdown.d.ts +1 -1
  50. package/dist/utils/bodyCell/selection.d.ts +0 -1
  51. package/dist/utils/bodyCell/styling.d.ts +2 -0
  52. package/dist/utils/cellScrollUtils.d.ts +1 -1
  53. package/dist/utils/cellUtils.d.ts +0 -4
  54. package/dist/utils/collapseUtils.d.ts +0 -10
  55. package/dist/utils/externalScroll.d.ts +0 -10
  56. package/dist/utils/formatters.d.ts +0 -2
  57. package/dist/utils/headerCell/eventTracking.d.ts +2 -2
  58. package/dist/utils/headerCell/styling.d.ts +0 -1
  59. package/dist/utils/headerWidthUtils.d.ts +2 -2
  60. package/dist/utils/infiniteScrollUtils.d.ts +0 -1
  61. package/dist/utils/parkAndStagger.d.ts +44 -0
  62. package/dist/utils/resizeUtils/domUpdates.d.ts +1 -1
  63. package/dist/utils/resizeUtils/maxWidth.d.ts +2 -1
  64. package/dist/utils/rowSelectionUtils.d.ts +0 -4
  65. package/dist/utils/rowSeparatorRenderer.d.ts +0 -1
  66. package/dist/utils/rowUtils.d.ts +1 -27
  67. package/dist/utils/setAbsoluteCellPosition.d.ts +31 -0
  68. package/dist/utils/stateRowRenderer.d.ts +0 -1
  69. package/dist/utils/tableDomScope.d.ts +20 -0
  70. package/package.json +4 -3
  71. package/src/styles/base.css +40 -147
  72. package/dist/managers/ColumnManager.d.ts +0 -42
  73. package/dist/managers/RowManager.d.ts +0 -56
  74. package/dist/managers/TableManager.d.ts +0 -72
  75. package/dist/types/BoundingBox.d.ts +0 -11
  76. package/dist/types/DragHandlerProps.d.ts +0 -14
  77. package/dist/types/OnSortProps.d.ts +0 -3
  78. package/dist/types/SharedTableProps.d.ts +0 -24
  79. package/dist/types/TableBodyProps.d.ts +0 -20
  80. package/dist/types/TableHeaderProps.d.ts +0 -17
  81. package/dist/types/TableHeaderSectionProps.d.ts +0 -19
  82. package/dist/types/TableRowProps.d.ts +0 -29
  83. package/dist/utils/columnIndicesUtils.d.ts +0 -15
  84. package/dist/utils/columnVirtualizationUtils.d.ts +0 -128
@@ -16,38 +16,13 @@ export declare class SimpleTableVanilla<TData extends RowData = Row> {
16
16
  private localRows;
17
17
  private headers;
18
18
  /**
19
- * Pristine deep-cloned snapshot of the column definitions as configured
20
- * (constructor / update with `columns`). `this.headers` shares object
21
- * references with `config.columns` at mount, and the column editor
22
- * mutates header objects in place (e.g. `header.hide = true`) — so
23
- * `config.columns` drifts with runtime state and cannot serve as the
24
- * reset target. `resetColumns()` restores from this snapshot instead, giving
25
- * a well-defined default: every column visible except those explicitly
26
- * configured with `hide: true` in the definitions.
19
+ * Last ingested column definitions. `resetColumns()` restores from this
20
+ * snapshot. Runtime hide, width, and pin live on `this.headers`.
27
21
  */
28
22
  private pristineDefaultHeaders;
29
23
  private essentialAccessors;
30
- /** Accessors of leaf columns that should size to content (width:"auto" or autoSizeColumns). */
31
- private autoSizeAccessors;
32
- /** Accessors awaiting a content-fit measurement on the next render. */
33
- private pendingAutoSize;
34
- /**
35
- * Natural (unexpanded) pixel width per leaf column, overriding the declared
36
- * width: the measured content width for `width: "auto"` columns and the
37
- * width the user explicitly set via drag-resize / double-click auto-fit.
38
- * With autoExpandColumns these feed the shrink floors used during column
39
- * resize — neighbors give up surplus (expanded) space but are never
40
- * squeezed below their natural width; past that point the section
41
- * overflows into horizontal scroll.
42
- */
43
- private naturalWidths;
44
- /** Guard against re-entrancy while the auto-size pass re-renders. */
45
- private isAutoSizing;
46
24
  private currentPage;
47
- private scrollTop;
48
- private scrollDirection;
49
25
  private isResizing;
50
- private isScrolling;
51
26
  /** True when this render is scroll-driven so body can use position-only updates for existing cells. */
52
27
  private _positionOnlyBody;
53
28
  private firstRenderDone;
@@ -71,6 +46,11 @@ export declare class SimpleTableVanilla<TData extends RowData = Row> {
71
46
  private headerRegistry;
72
47
  private rowIndexMap;
73
48
  private animationCoordinator;
49
+ private accordionController;
50
+ private autoSizeManager;
51
+ private externalScrollController;
52
+ private scrollCoalescer;
53
+ private unvirtualizedRowsWarning;
74
54
  /**
75
55
  * When true, the sort subscriber skips `captureAnimationSnapshot` so
76
56
  * live-update-driven reorder/visibility changes don't FLIP-animate.
@@ -94,281 +74,45 @@ export declare class SimpleTableVanilla<TData extends RowData = Row> {
94
74
  private expandedDepthsManager;
95
75
  private ariaAnnouncementManager;
96
76
  private mounted;
97
- private scrollRafId;
98
- private scrollEndTimeoutId;
99
- private lastScrollTop;
100
77
  private isUpdating;
101
- /** Set once the dev-only "too many unvirtualized rows" warning has fired, so it never repeats. */
102
- private hasWarnedUnvirtualizedRows;
103
- /** Pending deferred check for the unvirtualized-rows warning (lets external-scroll seeding settle first). */
104
- private unvirtualizedRowsCheckTimeoutId;
105
- /** Currently resolved external scroll parent (HTMLElement or window). Null when external scroll mode is inactive. */
106
- private resolvedScrollParent;
107
- /** Bound scroll handler attached to the external scroll parent. */
108
- private externalScrollListener;
109
- /** Bound resize handler attached to window when scrollParent is "window". */
110
- private externalWindowResizeListener;
111
- /** ResizeObserver watching the external scroll parent element. */
112
- private externalParentResizeObserver;
113
- /** Cached visible viewport height of the table inside the external parent. Fed into virtualization. */
114
- private externalViewportHeight;
115
- /**
116
- * rAF handle for retrying resolution of a configured-but-not-yet-resolvable
117
- * `scrollParent` (e.g. a getter pointing at a ref attached on a later commit
118
- * than this table's mount). Null when no retry is pending.
119
- */
120
- private externalScrollRetryRaf;
121
- /** Number of resolution retries attempted; bounded so we don't spin forever. */
122
- private externalScrollRetryCount;
123
- private static readonly EXTERNAL_SCROLL_MAX_RETRIES;
124
- /** True iff the body-container scroll listener is currently attached. */
125
- private bodyScrollListenerAttached;
126
78
  /** Bound mouseleave handler on the body container. */
127
79
  private bodyContainerMouseLeaveListener;
128
- /** Bound scroll handler attached to the body container (internal scroll mode). */
129
- private bodyContainerScrollListener;
130
- /**
131
- * When external scroll mode is active we briefly take control of the scroll
132
- * parent's `overscroll-behavior-y` to neutralize the browser's rubber-band /
133
- * scroll-chaining at the boundaries. Without this, pulling past the top or
134
- * bottom of the scroll parent visually translates the entire scroll content
135
- * layer (including the CSS-sticky header), causing the header to "disappear"
136
- * during overscroll bounces even though its layout position is unchanged.
137
- * We record the previous inline value so {@link detachExternalScrollWiring}
138
- * can restore it cleanly.
139
- */
140
- private overscrollBehaviorTarget;
141
- private overscrollBehaviorPrev;
142
- /**
143
- * Active accordion axis for the next render. Set by row/column collapse-
144
- * expand mutators (see {@link beginAccordionAnimation}) and consumed by the
145
- * cell renderers via the render context. Cleared in {@link render} after
146
- * each render so subsequent non-accordion renders (sort, scroll, etc.)
147
- * don't re-trigger the size transitions.
148
- */
149
- private pendingAccordionAxis;
150
- /** Pending timeout id used to remove the accordion CSS class. */
151
- private accordionCleanupTimerId;
152
- /**
153
- * Visible-leaf-headers key as of the last render that committed to the DOM.
154
- * Used by `setHeaders` to detect hide/show/pin/unpin and trigger the
155
- * accordion-horizontal animation. Comparing against `this.headers` directly
156
- * doesn't work because the column editor mutates header objects in place
157
- * (e.g. `header.hide = true`) BEFORE invoking setHeaders, so by the time
158
- * setHeaders runs, the prev and next trees already point to the same
159
- * mutated header instances.
160
- */
161
- private lastRenderedVisibilityKey;
80
+ private liveHost;
162
81
  constructor(container: HTMLElement, config: SimpleTableConfigInput<TData>);
82
+ /** Copy caller columns into `config.columns` and `pristineDefaultHeaders`. */
83
+ private ingestColumnSnapshot;
163
84
  private applyAnimationsConfig;
164
85
  private rebuildRowIndexMap;
165
- private getBodyContainers;
166
- private getHeaderContainers;
167
- /**
168
- * All cell-bearing containers — body sections AND header sections — that the
169
- * animation coordinator needs to inspect. Headers participate in FLIP for
170
- * column reorder so their cells slide to their new slot rather than
171
- * teleporting.
172
- */
173
86
  private getAnimatableContainers;
174
87
  /**
175
- * Capture pre-change cell positions for the FLIP animation, including
176
- * conceptual positions for cells outside the virtualization viewport so
177
- * incoming cells can animate from off-screen on column reorder/sort. The
178
- * `play` step that runs at the end of the next render consumes this
179
- * snapshot to inverse-transform cells from their old visual positions and
180
- * tween them to their new ones.
181
- *
182
- * Called on every layout-affecting state change — including the chain of
183
- * mid-drag `setHeaders` calls that fire on each `dragover` swap — so that
184
- * displaced columns slide smoothly out of the dragged column's way rather
185
- * than snapping into place.
88
+ * Shared header write path for the render context and TableAPI. Accordion-
89
+ * horizontal when the visible or pinned set changed; column-drag uses the
90
+ * dedicated reorder animator; otherwise snapshot for FLIP.
186
91
  */
187
- /**
188
- * Build a key summarizing the leaf columns that will paint (accessor +
189
- * pinned section). Hidden leaves and excluded subtrees drop out; nested
190
- * children are flattened so a parent collapse/expand counts as a
191
- * visibility change at the leaf level too.
192
- */
193
- private buildVisibilityKey;
194
- /**
195
- * True when the visible-leaf-set (or its pinned-section assignment) for
196
- * `nextHeaders` differs from the last render that committed to the DOM.
197
- *
198
- * We deliberately compare against {@link lastRenderedVisibilityKey} rather
199
- * than `this.headers`: the column editor mutates header objects in place
200
- * before invoking setHeaders (e.g. `header.hide = true`, then
201
- * `setHeaders(deepClone(headers))`), and `this.headers` shares those
202
- * mutated references — so a prev-vs-next compare always reads the same
203
- * state and reports no change. Comparing to the last-rendered key sees
204
- * the user's actually-painted state and correctly detects hide/show and
205
- * pin/unpin changes.
206
- */
207
- private didColumnVisibilityChange;
208
- private captureAnimationSnapshot;
209
- /**
210
- * Push the visible vertical viewport into the animation coordinator when
211
- * external/page scroll is active (or clear it otherwise). Keeps the FLIP
212
- * distance-scaling viewport-relative so cells don't slide the full
213
- * conceptual distance when the table grows to its natural height.
214
- */
215
- private updateAnimationVerticalScroll;
216
- /**
217
- * Open the accordion animation window for the next render: capture a FLIP
218
- * snapshot, mark the active axis so cell renderers initialize incoming
219
- * cells at zero size, and add the CSS class that enables the size
220
- * transitions on `.st-cell` / `.st-header-cell`.
221
- *
222
- * The CSS class is removed after `duration + ACCORDION_CLEANUP_BUFFER_MS`
223
- * so non-accordion renders don't keep transitioning size on subsequent
224
- * inline-style writes.
225
- *
226
- * No-op when animations are disabled (which already includes the
227
- * prefers-reduced-motion check via {@link AnimationCoordinator.isEnabled}).
228
- */
229
- /**
230
- * Walk the CURRENT (pre-change) header tree and collect every accessor that
231
- * is renderable as a header cell given the current collapsed/hidden state —
232
- * group headers plus the leaf columns visible under them (honoring
233
- * `showWhen` and the collapsed set). Used by {@link beginAccordionAnimation}
234
- * to seed the animation coordinator's re-entry guard.
235
- */
236
- private collectAccordionRenderableAccessors;
237
- private beginAccordionAnimation;
92
+ private applyHeaders;
238
93
  private initializeManagers;
239
94
  mount(): void;
240
95
  private setupManagers;
241
96
  private setupEventListeners;
242
- /**
243
- * Reconciles which element owns the vertical scroll listener based on the
244
- * current `scrollParent` config. Called on mount and whenever `update()`
245
- * could have changed the relevant inputs (`scrollParent` / `height` /
246
- * `maxHeight`). Idempotent — safe to call repeatedly.
247
- */
248
- private syncExternalScrollWiring;
249
- /**
250
- * Retry resolving a configured `scrollParent` on the next animation frame.
251
- * Used when the parent (typically a getter pointing at a ref) was not yet
252
- * resolvable when external wiring last ran. Bounded by
253
- * {@link SimpleTableVanilla.EXTERNAL_SCROLL_MAX_RETRIES} so a permanently
254
- * unresolvable parent doesn't spin forever.
255
- */
256
- private scheduleExternalScrollParentRetry;
257
- private ensureBodyScrollListenerAttached;
258
- private ensureBodyScrollListenerDetached;
259
- private attachExternalScrollWiring;
260
- private detachExternalScrollWiring;
261
- /**
262
- * Set `overscroll-behavior-y: none` on the resolved scroll parent (or
263
- * `document.documentElement` for `scrollParent: "window"`). This neutralizes
264
- * the browser's elastic rubber-band at the scroll boundaries, which would
265
- * otherwise translate the entire scroll content layer (including our
266
- * `position: sticky` header) during overscroll bounces — making the header
267
- * visually disappear off the top of the parent. `contain` only stops scroll
268
- * chaining; we need `none` to actually disable the elastic bounce on the
269
- * scroll container itself. Previous inline value is captured so we can
270
- * restore it on detach.
271
- */
272
- private applyOverscrollContainment;
273
- private restoreOverscrollBehavior;
274
- /**
275
- * Read the resolved scroll parent's computed `padding-top` and publish it
276
- * as `--st-external-scroll-padding-top` on the table root. The sticky
277
- * header CSS uses `top: calc(-1 * var(...))` so the header pins flush to
278
- * the parent's outer top edge instead of the padding edge, eliminating the
279
- * visible gap that CSS sticky would otherwise produce when the consumer
280
- * gives the scroll parent any top padding. Re-run on layout changes via
281
- * ResizeObserver / window resize.
282
- */
283
- private recomputeExternalScrollPaddingTop;
284
- /**
285
- * Recompute the visible portion of the table inside the external scroll
286
- * parent and push it into the DimensionManager so virtualization math
287
- * picks it up. Cheap; called on scroll, on parent/window resize, and on
288
- * every re-render where the resolved parent may have moved.
289
- */
290
- private recomputeExternalViewportHeight;
291
- private handleExternalResize;
292
- private handleExternalScroll;
97
+ private handleExternalScrollMetrics;
293
98
  private handleScroll;
99
+ private getTableRoot;
100
+ private bindTableRoot;
294
101
  private clearHoveredRows;
295
102
  private updateAriaLiveRegion;
296
- /**
297
- * Pivot emits a flat matrix — disable consumer rowGrouping while active so
298
- * expand/collapse hierarchy does not wrap pivoted rows.
299
- */
300
103
  private getEffectiveRowGrouping;
301
- /**
302
- * Recompute pivot from filtered source rows and feed sort/selection managers.
303
- * When pivot is inactive, sort sees the filtered source rows directly.
304
- */
305
104
  private syncPivotPipeline;
306
105
  private getRenderContext;
106
+ private applyPivot;
307
107
  private getRenderState;
308
- /** A leaf column that should size to content (declared with width:"auto"). */
309
- private isAutoSizeLeaf;
310
- private computeAutoSizeAccessors;
311
- private getAutoSizeStyleRoot;
312
- /**
313
- * Rows that content-fit ("auto") measurement should sample. With client-side
314
- * pagination only the current page is rendered, so fit columns to the page's
315
- * rows rather than the entire dataset — otherwise off-page values inflate
316
- * every auto column's width.
317
- */
318
- private getAutoSizeRows;
319
- /**
320
- * Shrink floors for auto-expand column resize, keyed by accessor. Each
321
- * visible leaf's floor is its natural width — a user-set / content-measured
322
- * override when present, else the pixel width declared in the column
323
- * definitions — raised to at least its `minWidth` (or the global minimum).
324
- * Flexible declarations (fr / % / unmeasured "auto") have no pixel natural,
325
- * so they floor at `minWidth` alone.
326
- */
327
- private getShrinkFloors;
328
- /** Record user-set / measured widths as the columns' new natural widths. */
329
- private recordNaturalWidths;
330
- /** Immutably write measured pixel widths into the leaf headers. */
331
- private applyMeasuredWidths;
332
- /**
333
- * Measure and apply content-fit widths for any pending "auto" columns, then
334
- * re-render once at the final widths. Called at the end of render(); the
335
- * measurement reads the just-rendered (provisional-width) DOM and the
336
- * corrective render happens in the same synchronous task, so there is no
337
- * visible width snap.
338
- *
339
- * With autoExpandColumns, the measured width becomes the column's natural
340
- * width: the expand-only auto-scale pass in the corrective render stretches
341
- * columns to fill surplus container space, or leaves them at natural width
342
- * (horizontal scroll) when they don't fit.
343
- */
344
108
  private maybeAutoSizeColumns;
345
- /**
346
- * Re-run the content-fit measurement for all auto-size columns. Useful for
347
- * host frameworks (e.g. React) whose custom renderers mount asynchronously:
348
- * calling this from a layout effect (pre-paint) re-measures once the real
349
- * renderer DOM is present, so the column fits accurately without flicker.
350
- */
351
109
  refitAutoSizeColumns(): void;
352
110
  private render;
353
- /**
354
- * Dev-only safeguard. Schedules a one-shot, deferred check that warns when the
355
- * table is about to render a very large number of rows with no virtualization
356
- * active (no `height` / `maxHeight` and no bounded `scrollParent`). The check
357
- * is deferred so external-scroll viewport seeding (which can momentarily leave
358
- * `contentHeight` undefined on the first paint) has time to settle and we
359
- * don't cry wolf for a correctly-configured table. Compiled out of production
360
- * via the NODE_ENV guard. Never throws.
361
- */
362
- private maybeScheduleUnvirtualizedRowsWarning;
363
- private evaluateUnvirtualizedRowsWarning;
364
111
  update(config: Partial<SimpleTableConfigInput<TData>>): void;
365
112
  /** @deprecated Use {@link update} — same behavior. */
366
113
  updateConfig(config: Partial<SimpleTableConfigInput<TData>>): void;
367
- /**
368
- * Create, update, or destroy the RowSelectionManager when enableRowSelection
369
- * (and related props) change at runtime.
370
- */
371
114
  private syncRowSelectionManager;
372
115
  destroy(): void;
373
116
  getAPI(): TableAPI<TData>;
117
+ private getLiveHost;
374
118
  }
@@ -0,0 +1,74 @@
1
+ import { SimpleTableConfig } from "../../types/SimpleTableConfig";
2
+ import ColumnDef, { Accessor } from "../../types/ColumnDef";
3
+ import Row from "../../types/Row";
4
+ import { CustomTheme } from "../../types/CustomTheme";
5
+ import RowState from "../../types/RowState";
6
+ import { SelectionManager } from "../../managers/SelectionManager";
7
+ import { RowSelectionManager } from "../../managers/RowSelectionManager";
8
+ import { SortManager } from "../../managers/SortManager";
9
+ import { FilterManager } from "../../managers/FilterManager";
10
+ import { FlattenRowsResult } from "../../utils/rowFlattening";
11
+ import { ProcessRowsResult } from "../../utils/rowProcessing";
12
+ import type { PivotConfig } from "../../types/PivotTypes";
13
+ export interface TableAPIContext {
14
+ config: SimpleTableConfig;
15
+ localRows: Row[];
16
+ effectiveHeaders: ColumnDef[];
17
+ headers: ColumnDef[];
18
+ /** Last ingested column definitions (see SimpleTableVanilla.pristineDefaultHeaders). */
19
+ getPristineDefaultHeaders: () => ColumnDef[];
20
+ essentialAccessors: Set<string>;
21
+ customTheme: CustomTheme;
22
+ currentPage: number;
23
+ /** Returns current page from live state (use this in API getCurrentPage so it stays correct after setPage). */
24
+ getCurrentPage: () => number;
25
+ expandedRows: Map<string, number>;
26
+ collapsedRows: Map<string, number>;
27
+ expandedDepths: Set<number>;
28
+ clearExpandedRows: () => void;
29
+ clearCollapsedRows: () => void;
30
+ rowStateMap: Map<string | number, RowState>;
31
+ headerRegistry: Map<string, any>;
32
+ cellRegistry?: Map<string, {
33
+ updateContent: (value: any) => void;
34
+ }>;
35
+ /**
36
+ * Whether a cell (by its `getCellId` key) is currently mid-FLIP-animation.
37
+ * Live `updateData` content writes are skipped for animating cells so a
38
+ * data tick doesn't re-render / mutate a cell that is sliding to a new
39
+ * position (which causes visible jank). The underlying row data is still
40
+ * updated; only the in-place DOM refresh is deferred to the next tick or
41
+ * re-render once the animation settles.
42
+ */
43
+ isCellAnimating?: (cellId: string) => boolean;
44
+ /** True while any FLIP cell transition is in flight (blocks live re-sort/re-filter). */
45
+ hasAnimatingCells?: () => boolean;
46
+ columnEditorOpen: boolean;
47
+ expandedDepthsManager: any;
48
+ selectionManager: SelectionManager | null;
49
+ rowSelectionManager: RowSelectionManager | null;
50
+ sortManager: SortManager | null;
51
+ filterManager: FilterManager | null;
52
+ getCachedFlattenResult?: () => FlattenRowsResult | null;
53
+ getCachedProcessedResult?: () => ProcessRowsResult | null;
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;
66
+ setHeaders: (headers: ColumnDef[]) => void;
67
+ setCurrentPage: (page: number) => void;
68
+ setColumnEditorOpen: (open: boolean) => void;
69
+ getEffectiveRowGrouping: () => Accessor[] | undefined;
70
+ setPivot: (config: PivotConfig | null) => void;
71
+ getPivot: () => PivotConfig | null;
72
+ getPivotHeaders: () => ColumnDef[];
73
+ getPivotedRows: () => Row[];
74
+ }
@@ -1,78 +1,6 @@
1
1
  import { TableAPI } from "../../types/TableAPI";
2
- import { SimpleTableConfig } from "../../types/SimpleTableConfig";
3
- import ColumnDef, { Accessor } from "../../types/ColumnDef";
4
- import Row from "../../types/Row";
5
- import { CustomTheme } from "../../types/CustomTheme";
6
- import RowState from "../../types/RowState";
7
- import { SelectionManager } from "../../managers/SelectionManager";
8
- import { RowSelectionManager } from "../../managers/RowSelectionManager";
9
- import { SortManager } from "../../managers/SortManager";
10
- import { FilterManager } from "../../managers/FilterManager";
11
- import { FlattenRowsResult } from "../../utils/rowFlattening";
12
- import { ProcessRowsResult } from "../../utils/rowProcessing";
13
- import type { PivotConfig } from "../../types/PivotTypes";
14
- export interface TableAPIContext {
15
- config: SimpleTableConfig;
16
- localRows: Row[];
17
- effectiveHeaders: ColumnDef[];
18
- headers: ColumnDef[];
19
- /** Pristine snapshot of the configured column definitions (see SimpleTableVanilla.pristineDefaultHeaders). */
20
- getPristineDefaultHeaders: () => ColumnDef[];
21
- essentialAccessors: Set<string>;
22
- customTheme: CustomTheme;
23
- currentPage: number;
24
- /** Returns current page from live state (use this in API getCurrentPage so it stays correct after setPage). */
25
- getCurrentPage: () => number;
26
- expandedRows: Map<string, number>;
27
- collapsedRows: Map<string, number>;
28
- expandedDepths: Set<number>;
29
- clearExpandedRows: () => void;
30
- clearCollapsedRows: () => void;
31
- rowStateMap: Map<string | number, RowState>;
32
- headerRegistry: Map<string, any>;
33
- cellRegistry?: Map<string, {
34
- updateContent: (value: any) => void;
35
- }>;
36
- /**
37
- * Whether a cell (by its `getCellId` key) is currently mid-FLIP-animation.
38
- * Live `updateData` content writes are skipped for animating cells so a
39
- * data tick doesn't re-render / mutate a cell that is sliding to a new
40
- * position (which causes visible jank). The underlying row data is still
41
- * updated; only the in-place DOM refresh is deferred to the next tick or
42
- * re-render once the animation settles.
43
- */
44
- isCellAnimating?: (cellId: string) => boolean;
45
- /** True while any FLIP cell transition is in flight (blocks live re-sort/re-filter). */
46
- hasAnimatingCells?: () => boolean;
47
- columnEditorOpen: boolean;
48
- expandedDepthsManager: any;
49
- selectionManager: SelectionManager | null;
50
- rowSelectionManager: RowSelectionManager | null;
51
- sortManager: SortManager | null;
52
- filterManager: FilterManager | null;
53
- getCachedFlattenResult?: () => FlattenRowsResult | null;
54
- getCachedProcessedResult?: () => ProcessRowsResult | null;
55
- onRender: () => void;
56
- /**
57
- * Bust the flatten / body row caches so the next render re-runs quick filter
58
- * (and related processing) against in-place mutated row values.
59
- */
60
- invalidateRowsCache?: () => void;
61
- /**
62
- * Run `fn` without capturing a FLIP snapshot when sort/filter subscribers
63
- * fire. Used for live-update-driven reorder/visibility changes so high-
64
- * frequency ticks don't spam sort animations.
65
- */
66
- runWithoutAnimationSnapshot?: (fn: () => void) => void;
67
- setHeaders: (headers: ColumnDef[]) => void;
68
- setCurrentPage: (page: number) => void;
69
- setColumnEditorOpen: (open: boolean) => void;
70
- getEffectiveRowGrouping: () => Accessor[] | undefined;
71
- setPivot: (config: PivotConfig | null) => void;
72
- getPivot: () => PivotConfig | null;
73
- getPivotHeaders: () => ColumnDef[];
74
- getPivotedRows: () => Row[];
75
- }
2
+ import type { TableAPIContext } from "./TableAPIContext";
3
+ export type { TableAPIContext } from "./TableAPIContext";
76
4
  export declare class TableAPIImpl {
77
5
  static createAPI(context: TableAPIContext): TableAPI;
78
6
  }
@@ -0,0 +1,61 @@
1
+ import type { SimpleTableConfig } from "../../types/SimpleTableConfig";
2
+ import type ColumnDef from "../../types/ColumnDef";
3
+ import type { Accessor } from "../../types/ColumnDef";
4
+ import type Row from "../../types/Row";
5
+ import type { CustomTheme } from "../../types/CustomTheme";
6
+ import type RowState from "../../types/RowState";
7
+ import type { SelectionManager } from "../../managers/SelectionManager";
8
+ import type { RowSelectionManager } from "../../managers/RowSelectionManager";
9
+ import type { SortManager } from "../../managers/SortManager";
10
+ import type { FilterManager } from "../../managers/FilterManager";
11
+ import type { FlattenRowsResult } from "../../utils/rowFlattening";
12
+ import type { ProcessRowsResult } from "../../utils/rowProcessing";
13
+ import type { PivotConfig } from "../../types/PivotTypes";
14
+ import type { TableAPIContext } from "./TableAPIContext";
15
+ /**
16
+ * Live table instance surface used to build a cached {@link TableAPIContext}.
17
+ * Getters read current instance state rather than a snapshot captured at
18
+ * `getAPI()` time.
19
+ */
20
+ export interface TableAPIContextHost {
21
+ getConfig(): SimpleTableConfig;
22
+ getLocalRows(): Row[];
23
+ getHeaders(): ColumnDef[];
24
+ applyHeaders(headers: ColumnDef[]): void;
25
+ getPristineDefaultHeaders(): ColumnDef[];
26
+ getEssentialAccessors(): Set<string>;
27
+ getCustomTheme(): CustomTheme;
28
+ getCurrentPage(): number;
29
+ setCurrentPage(page: number): void;
30
+ getExpandedRows(): Map<string, number>;
31
+ getCollapsedRows(): Map<string, number>;
32
+ getExpandedDepths(): Set<number>;
33
+ clearExpandedRows(): void;
34
+ clearCollapsedRows(): void;
35
+ getRowStateMap(): Map<string | number, RowState>;
36
+ getHeaderRegistry(): Map<string, any>;
37
+ getCellRegistry(): Map<string, {
38
+ updateContent: (value: any) => void;
39
+ }>;
40
+ isCellAnimating(cellId: string): boolean;
41
+ hasAnimatingCells(): boolean;
42
+ getColumnEditorOpen(): boolean;
43
+ setColumnEditorOpen(open: boolean): void;
44
+ getExpandedDepthsManager(): any;
45
+ getSelectionManager(): SelectionManager | null;
46
+ getRowSelectionManager(): RowSelectionManager | null;
47
+ getSortManager(): SortManager | null;
48
+ getFilterManager(): FilterManager | null;
49
+ getCachedFlattenResult(): FlattenRowsResult | null;
50
+ getCachedProcessedResult(): ProcessRowsResult | null;
51
+ getEffectiveRowGrouping(): Accessor[] | undefined;
52
+ setPivot(config: PivotConfig | null): void;
53
+ getPivot(): PivotConfig | null;
54
+ getPivotHeaders(): ColumnDef[];
55
+ getPivotedRows(): Row[];
56
+ onRender(): void;
57
+ invalidateRowsCache(): void;
58
+ runWithoutAnimationSnapshot(fn: () => void): void;
59
+ computeEffectiveHeaders(): ColumnDef[];
60
+ }
61
+ export declare const buildTableAPIContext: (host: TableAPIContextHost) => TableAPIContext;
@@ -0,0 +1,20 @@
1
+ export interface UnvirtualizedRowsWarningHost {
2
+ isMounted(): boolean;
3
+ isVirtualizationDisabled(): boolean;
4
+ getContentHeight(): number | undefined;
5
+ getRenderedRowCount(): number;
6
+ hasScrollParent(): boolean;
7
+ }
8
+ /**
9
+ * Warns once in development when a large row set is painted with no viewport
10
+ * (`height`, `maxHeight`, or a bounded `scrollParent`).
11
+ */
12
+ export declare class UnvirtualizedRowsWarning {
13
+ private hasWarned;
14
+ private timeoutId;
15
+ private host;
16
+ constructor(host: UnvirtualizedRowsWarningHost);
17
+ schedule(): void;
18
+ destroy(): void;
19
+ private evaluate;
20
+ }
@@ -0,0 +1,37 @@
1
+ import type { SimpleTableConfig } from "../../types/SimpleTableConfig";
2
+ import type { CustomTheme } from "../../types/CustomTheme";
3
+ import type ColumnDef from "../../types/ColumnDef";
4
+ import type { Accessor } from "../../types/ColumnDef";
5
+ import type Row from "../../types/Row";
6
+ import type { PivotManager } from "../../managers/PivotManager";
7
+ import { SortManager } from "../../managers/SortManager";
8
+ import { FilterManager } from "../../managers/FilterManager";
9
+ import { SelectionManager } from "../../managers/SelectionManager";
10
+ import ExpandedDepthsManager from "../../hooks/expandedDepths";
11
+ import AriaAnnouncementManager from "../../hooks/ariaAnnouncements";
12
+ export interface DataManagersHost {
13
+ getConfig(): SimpleTableConfig;
14
+ getHeaders(): ColumnDef[];
15
+ getPristineDefaultHeaders(): ColumnDef[];
16
+ getLocalRows(): Row[];
17
+ getCustomTheme(): CustomTheme;
18
+ getCollapsedHeaders(): Set<Accessor>;
19
+ getCellRegistry(): Map<string, any>;
20
+ getTableRoot(): HTMLElement;
21
+ getEffectiveRowGrouping(): Accessor[] | undefined;
22
+ getPivotManager(): PivotManager | null;
23
+ onAnnouncement(message: string): void;
24
+ onExpandedDepths(depths: Set<number>): void;
25
+ onSortNotify(): void;
26
+ onFilterNotify(filteredRows: Row[]): void;
27
+ onSelectionDragEnd(): void;
28
+ }
29
+ export interface DataManagers {
30
+ ariaAnnouncementManager: AriaAnnouncementManager;
31
+ expandedDepthsManager: ExpandedDepthsManager;
32
+ sortManager: SortManager;
33
+ filterManager: FilterManager;
34
+ selectionManager: SelectionManager;
35
+ }
36
+ /** Constructs sort, filter, selection, expand-depth, and aria managers. */
37
+ export declare const createDataManagers: (host: DataManagersHost) => DataManagers;
@@ -0,0 +1,43 @@
1
+ import type { SimpleTableConfig } from "../../types/SimpleTableConfig";
2
+ import type { CustomTheme } from "../../types/CustomTheme";
3
+ import type ColumnDef from "../../types/ColumnDef";
4
+ import type { Accessor } from "../../types/ColumnDef";
5
+ import type { DOMRefs } from "../dom/DOMManager";
6
+ import { DimensionManager } from "../../managers/DimensionManager";
7
+ import { ScrollManager } from "../../managers/ScrollManager";
8
+ import { SectionScrollController } from "../../managers/SectionScrollController";
9
+ import { AutoScaleManager } from "../../managers/AutoScaleManager";
10
+ import { SelectionManager } from "../../managers/SelectionManager";
11
+ import WindowResizeManager from "../../hooks/windowResize";
12
+ import HandleOutsideClickManager from "../../hooks/handleOutsideClick";
13
+ import ScrollbarVisibilityManager from "../../hooks/scrollbarVisibility";
14
+ import type { RenderOrchestrator } from "../rendering/RenderOrchestrator";
15
+ export interface MountManagersHost {
16
+ getConfig(): SimpleTableConfig;
17
+ getCustomTheme(): CustomTheme;
18
+ getHeaders(): ColumnDef[];
19
+ getCollapsedHeaders(): Set<Accessor>;
20
+ getLocalRowCount(): number;
21
+ getIsResizing(): boolean;
22
+ getSelectionManager(): SelectionManager | null;
23
+ getRenderOrchestrator(): RenderOrchestrator;
24
+ onRender(source: string): void;
25
+ onFirstDimensionPaint(): void;
26
+ onScrollbarVisibilityChange(isScrollable: boolean, scrollbarWidth: number): void;
27
+ onScrollbarWidthChange(scrollbarWidth: number): void;
28
+ }
29
+ export interface MountManagers {
30
+ dimensionManager: DimensionManager;
31
+ scrollManager: ScrollManager;
32
+ sectionScrollController: SectionScrollController;
33
+ autoScaleManager: AutoScaleManager | null;
34
+ scrollbarVisibilityManager: ScrollbarVisibilityManager | null;
35
+ windowResizeManager: WindowResizeManager;
36
+ handleOutsideClickManager: HandleOutsideClickManager | null;
37
+ scrollbarWidth: number;
38
+ }
39
+ /**
40
+ * Constructs managers that need the mounted DOM (dimensions, scroll sync,
41
+ * auto-expand, scrollbar, outside-click).
42
+ */
43
+ export declare const wireMountManagers: (host: MountManagersHost, refs: DOMRefs) => MountManagers | null;