@toolbox-web/grid 1.31.1 → 1.31.3

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 (60) hide show
  1. package/all.js +2 -2
  2. package/all.js.map +1 -1
  3. package/index.js +1 -1
  4. package/index.js.map +1 -1
  5. package/lib/core/internal/shell.d.ts +20 -0
  6. package/lib/core/internal/sorting.d.ts +4 -0
  7. package/lib/core/plugin/base-plugin.d.ts +12 -0
  8. package/lib/core/plugin/plugin-manager.d.ts +4 -1
  9. package/lib/core/plugin/types.d.ts +2 -0
  10. package/lib/core/types.d.ts +20 -1
  11. package/lib/plugins/clipboard/index.js.map +1 -1
  12. package/lib/plugins/column-virtualization/index.js.map +1 -1
  13. package/lib/plugins/context-menu/index.js.map +1 -1
  14. package/lib/plugins/editing/index.js +1 -1
  15. package/lib/plugins/editing/index.js.map +1 -1
  16. package/lib/plugins/export/index.js.map +1 -1
  17. package/lib/plugins/filtering/index.js.map +1 -1
  18. package/lib/plugins/grouping-columns/index.js.map +1 -1
  19. package/lib/plugins/grouping-rows/index.js +1 -1
  20. package/lib/plugins/grouping-rows/index.js.map +1 -1
  21. package/lib/plugins/master-detail/index.js.map +1 -1
  22. package/lib/plugins/multi-sort/index.js.map +1 -1
  23. package/lib/plugins/pinned-columns/index.js +1 -1
  24. package/lib/plugins/pinned-columns/index.js.map +1 -1
  25. package/lib/plugins/pinned-rows/index.js.map +1 -1
  26. package/lib/plugins/pivot/index.js +1 -1
  27. package/lib/plugins/pivot/index.js.map +1 -1
  28. package/lib/plugins/print/index.js.map +1 -1
  29. package/lib/plugins/reorder-columns/index.js.map +1 -1
  30. package/lib/plugins/reorder-rows/index.js.map +1 -1
  31. package/lib/plugins/responsive/index.js.map +1 -1
  32. package/lib/plugins/selection/index.js.map +1 -1
  33. package/lib/plugins/server-side/index.js +1 -1
  34. package/lib/plugins/server-side/index.js.map +1 -1
  35. package/lib/plugins/tooltip/index.js +1 -1
  36. package/lib/plugins/tooltip/index.js.map +1 -1
  37. package/lib/plugins/tree/index.js +1 -1
  38. package/lib/plugins/tree/index.js.map +1 -1
  39. package/lib/plugins/tree/types.d.ts +6 -0
  40. package/lib/plugins/undo-redo/index.js.map +1 -1
  41. package/lib/plugins/visibility/index.js.map +1 -1
  42. package/package.json +1 -1
  43. package/umd/grid.all.umd.js +1 -1
  44. package/umd/grid.all.umd.js.map +1 -1
  45. package/umd/grid.umd.js +1 -1
  46. package/umd/grid.umd.js.map +1 -1
  47. package/umd/plugins/editing.umd.js +1 -1
  48. package/umd/plugins/editing.umd.js.map +1 -1
  49. package/umd/plugins/grouping-rows.umd.js +1 -1
  50. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  51. package/umd/plugins/pinned-columns.umd.js +1 -1
  52. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  53. package/umd/plugins/pivot.umd.js +1 -1
  54. package/umd/plugins/pivot.umd.js.map +1 -1
  55. package/umd/plugins/server-side.umd.js +1 -1
  56. package/umd/plugins/server-side.umd.js.map +1 -1
  57. package/umd/plugins/tooltip.umd.js +1 -1
  58. package/umd/plugins/tooltip.umd.js.map +1 -1
  59. package/umd/plugins/tree.umd.js +1 -1
  60. package/umd/plugins/tree.umd.js.map +1 -1
@@ -285,3 +285,23 @@ export declare function buildGridDOMIntoElement(renderRoot: Element, shellConfig
285
285
  expand?: IconValue;
286
286
  collapse?: IconValue;
287
287
  }): boolean;
288
+ /**
289
+ * Surgically rebuild only the shell wrapper (header + tool panel) while
290
+ * preserving the existing `.tbw-grid-root` element and its `.tbw-grid-content`
291
+ * child with all descendants and event listeners intact.
292
+ *
293
+ * This avoids the full `replaceChildren()` nuke that `buildGridDOMIntoElement`
294
+ * performs, so event listeners bound to `.tbw-grid-root` or its grid content
295
+ * descendants (e.g. tooltip's delegated mouseover) remain intact.
296
+ *
297
+ * If no existing `.tbw-grid-root` is found (first render), falls back to
298
+ * `buildGridDOMIntoElement` for a full rebuild.
299
+ */
300
+ export declare function rebuildShellDOM(renderRoot: Element, shellConfig: ShellConfig | undefined, runtimeState: {
301
+ isPanelOpen: boolean;
302
+ expandedSections: Set<string>;
303
+ }, icons?: {
304
+ toolPanel?: IconValue;
305
+ expand?: IconValue;
306
+ collapse?: IconValue;
307
+ }): boolean;
@@ -74,5 +74,9 @@ export declare function reapplyCoreSort<T>(grid: InternalGrid<T>, rows: T[]): T[
74
74
  *
75
75
  * Uses custom sortHandler from gridConfig if provided, otherwise uses built-in sorting.
76
76
  * Supports both sync and async handlers (for server-side sorting).
77
+ *
78
+ * When row-model plugins are active (grouping, tree, pivot), delegates to the render
79
+ * scheduler so the full pipeline (reapplyCoreSort → processRows) runs on base rows.
80
+ * This prevents sorting from corrupting plugin-generated row structures.
77
81
  */
78
82
  export declare function applySort(grid: GridHost, col: ColumnConfig<any>, dir: 1 | -1): void;
@@ -275,6 +275,18 @@ export interface PluginManifest<TConfig = unknown> {
275
275
  * ```
276
276
  */
277
277
  events?: EventDefinition[];
278
+ /**
279
+ * Whether this plugin's `processRows` hook injects or removes rows
280
+ * (group headers, tree nodes, pivot aggregates, placeholders, etc.).
281
+ *
282
+ * When true, the core sorting module delegates to the render scheduler
283
+ * instead of sorting `_rows` in-place, because `_rows` may contain
284
+ * plugin-generated marker objects that would be corrupted by a direct sort.
285
+ *
286
+ * Plugins that only **filter** or **reorder** existing rows (e.g. Filtering,
287
+ * MultiSort) should leave this unset or set it to `false`.
288
+ */
289
+ modifiesRowStructure?: boolean;
278
290
  }
279
291
  /** Convert camelCase icon key to kebab-case data-icon attribute value. */
280
292
  export declare function toIconAttr(key: string): string;
@@ -24,7 +24,10 @@ export declare class PluginManager {
24
24
  /** Cached hook presence flags — invalidated on plugin attach/detach */
25
25
  private _hasAfterCellRender;
26
26
  private _hasAfterRowRender;
27
- private _hasProcessRows;
27
+ /** Whether any plugin has a processRows hook. */
28
+ _hasProcessRows: boolean;
29
+ /** Whether any plugin with `modifiesRowStructure` is attached. Exposed for the sorting module. */
30
+ _hasRowStructurePlugins: boolean;
28
31
  /**
29
32
  * Event listeners indexed by event type.
30
33
  * Maps event type → Map<plugin instance → callback>.
@@ -351,6 +351,8 @@ export interface GridElementRef {
351
351
  subscribe(plugin: unknown, eventType: string, callback: (detail: unknown) => void): void;
352
352
  unsubscribe(plugin: unknown, eventType: string): void;
353
353
  emitPluginEvent<T>(eventType: string, detail: T): void;
354
+ /** Whether any attached plugin injects/removes rows (group headers, tree nodes, etc.). */
355
+ _hasRowStructurePlugins: boolean;
354
356
  };
355
357
  /**
356
358
  * Query all plugins with a generic query and collect responses.
@@ -463,6 +463,10 @@ export interface InternalGrid<T = any> extends PublicGrid<T>, GridConfig<T> {
463
463
  __hasSpecialColumns?: boolean;
464
464
  /** Cached flag for whether any plugin has renderRow hooks. @internal */
465
465
  __hasRenderRowPlugins?: boolean;
466
+ /** @internal Access the plugin manager's cached state. */
467
+ _pluginManager?: {
468
+ _hasRowStructurePlugins: boolean;
469
+ };
466
470
  _gridTemplate: string;
467
471
  _virtualization: VirtualState;
468
472
  _focusRow: number;
@@ -1197,6 +1201,19 @@ export interface CellRenderContext<TRow = any, TValue = any> {
1197
1201
  field: keyof TRow & string;
1198
1202
  /** Column configuration reference. */
1199
1203
  column: ColumnConfig<TRow>;
1204
+ /**
1205
+ * The grid element that owns this cell.
1206
+ * Use to access public grid API (e.g., `getPluginByName()`) from custom renderers.
1207
+ *
1208
+ * @example
1209
+ * ```typescript
1210
+ * const renderer: ColumnViewRenderer<MyRow> = (ctx) => {
1211
+ * const tree = ctx.grid?.getPluginByName('tree');
1212
+ * // ...
1213
+ * };
1214
+ * ```
1215
+ */
1216
+ grid?: DataGridElement;
1200
1217
  /**
1201
1218
  * The cell DOM element being rendered into.
1202
1219
  * Framework adapters can use this to cache per-cell state (e.g., React roots).
@@ -1438,9 +1455,11 @@ export interface FrameworkAdapter {
1438
1455
  * Used by Angular's `GridTypeRegistry` and React's `GridTypeProvider`.
1439
1456
  *
1440
1457
  * @param type - The column type (e.g., 'date', 'currency', 'country')
1458
+ * @param gridEl - The owning `<tbw-grid>` element. Helps adapters resolve
1459
+ * the correct context provider in multi-grid scenarios.
1441
1460
  * @returns Type defaults for renderer/editor, or undefined if not registered
1442
1461
  */
1443
- getTypeDefault?<TRow = unknown>(type: string): TypeDefault<TRow> | undefined;
1462
+ getTypeDefault?<TRow = unknown>(type: string, gridEl?: HTMLElement): TypeDefault<TRow> | undefined;
1444
1463
  /**
1445
1464
  * Pre-process a grid config before the grid core applies it.
1446
1465
  * Framework adapters use this to convert framework-specific component references