@toolbox-web/grid 2.8.1 → 2.10.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.
Files changed (46) 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/dom-builder.d.ts +8 -0
  6. package/lib/core/plugin/index.d.ts +1 -0
  7. package/lib/core/plugin/types.d.ts +61 -0
  8. package/lib/core/types.d.ts +68 -2
  9. package/lib/plugins/clipboard/index.js.map +1 -1
  10. package/lib/plugins/column-virtualization/index.js.map +1 -1
  11. package/lib/plugins/context-menu/index.js.map +1 -1
  12. package/lib/plugins/editing/index.js.map +1 -1
  13. package/lib/plugins/export/index.js +1 -1
  14. package/lib/plugins/export/index.js.map +1 -1
  15. package/lib/plugins/export/types.d.ts +35 -5
  16. package/lib/plugins/filtering/index.js.map +1 -1
  17. package/lib/plugins/grouping-columns/index.js +1 -1
  18. package/lib/plugins/grouping-columns/index.js.map +1 -1
  19. package/lib/plugins/grouping-rows/index.js.map +1 -1
  20. package/lib/plugins/master-detail/index.js.map +1 -1
  21. package/lib/plugins/multi-sort/index.js.map +1 -1
  22. package/lib/plugins/pinned-columns/index.js.map +1 -1
  23. package/lib/plugins/pinned-rows/index.js.map +1 -1
  24. package/lib/plugins/pivot/index.js.map +1 -1
  25. package/lib/plugins/print/index.js.map +1 -1
  26. package/lib/plugins/reorder-columns/index.js.map +1 -1
  27. package/lib/plugins/reorder-rows/index.js.map +1 -1
  28. package/lib/plugins/responsive/index.js.map +1 -1
  29. package/lib/plugins/row-drag-drop/index.js.map +1 -1
  30. package/lib/plugins/selection/index.js.map +1 -1
  31. package/lib/plugins/server-side/index.js.map +1 -1
  32. package/lib/plugins/sticky-rows/index.js.map +1 -1
  33. package/lib/plugins/tooltip/index.js.map +1 -1
  34. package/lib/plugins/tree/index.js.map +1 -1
  35. package/lib/plugins/undo-redo/index.js.map +1 -1
  36. package/lib/plugins/visibility/index.js.map +1 -1
  37. package/package.json +1 -1
  38. package/public.d.ts +1 -1
  39. package/umd/grid.all.umd.js +1 -1
  40. package/umd/grid.all.umd.js.map +1 -1
  41. package/umd/grid.umd.js +1 -1
  42. package/umd/grid.umd.js.map +1 -1
  43. package/umd/plugins/export.umd.js +1 -1
  44. package/umd/plugins/export.umd.js.map +1 -1
  45. package/umd/plugins/grouping-columns.umd.js +1 -1
  46. package/umd/plugins/grouping-columns.umd.js.map +1 -1
@@ -42,6 +42,14 @@ export interface ShellHeaderOptions {
42
42
  hasPanels: boolean;
43
43
  isPanelOpen: boolean;
44
44
  toolPanelIcon?: string;
45
+ /**
46
+ * Whether to render the built-in tool panel toggle button and the
47
+ * adjacent separator. Independent of `hasPanels` so panels can remain
48
+ * registered (and openable via the public API) while the consumer
49
+ * supplies their own toggle button.
50
+ * @default true when hasPanels is true
51
+ */
52
+ showToggle?: boolean;
45
53
  /** Config toolbar contents with render function (pre-sorted by order) */
46
54
  configButtons: Array<{
47
55
  id: string;
@@ -6,6 +6,7 @@
6
6
  */
7
7
  export { BaseGridPlugin } from './base-plugin';
8
8
  export type { AfterCellRenderContext, AfterRowRenderContext, CellClickEvent, CellCoords, CellEditor, CellMouseEvent, CellRenderer, ContextMenuItem, ContextMenuParams, GridElement, HeaderClickEvent, HeaderRenderer, KeyboardModifiers, PluginCellRenderContext, PluginHeaderRenderContext, PluginQuery, RowClickEvent, ScrollEvent, } from './base-plugin';
9
+ export type { CollectHeaderRowsContext, HeaderRowCell, HeaderRowContribution } from './types';
9
10
  export { PluginManager } from './plugin-manager';
10
11
  export type { EventDefinition, HookName, PluginConfigRule, PluginDependency, PluginIncompatibility, PluginManifest, PluginPropertyDefinition, QueryDefinition, } from './base-plugin';
11
12
  export type { ColumnConfig } from '../types';
@@ -194,6 +194,67 @@ export interface PluginQuery<T = unknown> {
194
194
  /** Query-specific context/parameters */
195
195
  context: T;
196
196
  }
197
+ /**
198
+ * Context passed in {@link PluginQuery.context} for the `'collectHeaderRows'`
199
+ * query — used by consumers (e.g. the export plugin) to collect extra header
200
+ * rows that should sit **above** the leaf column-header row.
201
+ *
202
+ * Plugins that contribute header rows (e.g. `GroupingColumnsPlugin`) declare
203
+ * `{ type: 'collectHeaderRows' }` in their manifest and respond from
204
+ * `handleQuery` with a {@link HeaderRowContribution} — or an array of them
205
+ * for multi-row contributions (e.g. multi-level grouping). The consumer
206
+ * flattens array replies.
207
+ *
208
+ * The reply shape is intentionally generic — "here are some cells, each
209
+ * spanning N leaf columns" — so consumers don't need to know which plugin
210
+ * produced them. Responding plugins MUST align their contribution to the
211
+ * `columns` array on this context — `span` values are indices into it.
212
+ *
213
+ * @category Plugin Development
214
+ * @since 2.10.0
215
+ */
216
+ export interface CollectHeaderRowsContext {
217
+ /** Resolved leaf columns (in display order) the consumer is about to emit. */
218
+ columns: ColumnConfig[];
219
+ }
220
+ /**
221
+ * Single cell in a contributed header row. `span` is the number of leaf
222
+ * columns this cell covers (always `>= 1`). The sum of `span` across all
223
+ * cells in a row MUST equal `context.columns.length`.
224
+ *
225
+ * `label === ''` is treated as a blank/dropped cell — consumers may still
226
+ * emit it (to preserve span alignment) or skip the entire row if every
227
+ * cell is blank.
228
+ *
229
+ * @category Plugin Development
230
+ * @since 2.10.0
231
+ */
232
+ export interface HeaderRowCell {
233
+ /** Display label for this cell. Empty string = blank cell (span preserved). */
234
+ label: string;
235
+ /** Number of leaf columns covered. Always `>= 1`. */
236
+ span: number;
237
+ /** Optional plugin name (for debugging / `processHeaderRow` filtering). */
238
+ source?: string;
239
+ /** Optional opaque payload for consumers that need plugin-specific data. */
240
+ meta?: unknown;
241
+ }
242
+ /**
243
+ * A single header row contributed by a plugin. Sits **above** the leaf
244
+ * column-header row in the visual / export output.
245
+ *
246
+ * Each contribution represents **one row**. A plugin needing multiple rows
247
+ * (e.g. multi-level grouping) returns `HeaderRowContribution[]` from
248
+ * `handleQuery`; the consumer flattens. Within each row, `cells` MUST
249
+ * independently sum to `context.columns.length`.
250
+ *
251
+ * @category Plugin Development
252
+ * @since 2.10.0
253
+ */
254
+ export interface HeaderRowContribution {
255
+ /** Cells in this row, in left-to-right column order. */
256
+ cells: HeaderRowCell[];
257
+ }
197
258
  /**
198
259
  * Cell render context for plugin cell renderers.
199
260
  * Provides full context including position and editing state.
@@ -3261,7 +3261,8 @@ export declare const DEFAULT_GRID_ICONS: Required<GridIcons>;
3261
3261
  * },
3262
3262
  * toolPanel: {
3263
3263
  * position: 'right',
3264
- * defaultOpen: 'columns', // Open by default
3264
+ * initialState: 'open', // Sidebar open on load
3265
+ * defaultOpen: 'columns', // Auto-expand the "Columns" section
3265
3266
  * },
3266
3267
  * },
3267
3268
  * plugins: [new VisibilityPlugin()], // Adds "Columns" panel
@@ -3309,6 +3310,20 @@ export interface ShellHeaderConfig {
3309
3310
  title?: string;
3310
3311
  /** Custom toolbar content (rendered before tool panel toggle) */
3311
3312
  toolbarContents?: ToolbarContentDefinition[];
3313
+ /**
3314
+ * Whether the grid renders its built-in tool panel toggle button
3315
+ * (`button.tbw-toolbar-btn[data-panel-toggle]`) and the auto-inserted
3316
+ * `.tbw-toolbar-separator` between custom toolbar contents and the toggle.
3317
+ *
3318
+ * Set to `false` when you want to provide your own toggle button (e.g. a
3319
+ * design-system button styled to match your application). Wire your button
3320
+ * to call {@link Grid.toggleToolPanel} (or `toggleToolPanelSection(id)` for
3321
+ * a specific section). All tool panels remain functional; only the
3322
+ * built-in toggle button and adjacent separator are suppressed.
3323
+ *
3324
+ * @default true
3325
+ */
3326
+ toolPanelToggle?: boolean;
3312
3327
  /**
3313
3328
  * Light DOM header content elements (parsed from <tbw-grid-header> children).
3314
3329
  * @internal Set by ConfigManager during merge
@@ -3329,8 +3344,59 @@ export interface ToolPanelConfig {
3329
3344
  position?: 'left' | 'right';
3330
3345
  /** Default panel width in pixels (default: 280) */
3331
3346
  width?: number;
3332
- /** Panel ID to open by default on load */
3347
+ /**
3348
+ * Accordion section to auto-expand the first time the tool panel opens.
3349
+ *
3350
+ * @deprecated **Behavior change planned for v3.0.0** — see [issue #259](https://github.com/OysteinAmundsen/toolbox/issues/259).
3351
+ *
3352
+ * Today (v2.x, kept for backward compatibility): setting `defaultOpen` also
3353
+ * **opens the sidebar** on grid load. This conflates "which section is
3354
+ * pre-selected" with "is the sidebar open", and there is no way to
3355
+ * pre-select a section without also forcing the sidebar open.
3356
+ *
3357
+ * In v3.0.0 (#259): `defaultOpen` will only pre-select which accordion
3358
+ * section auto-expands the first time the sidebar opens, and will no
3359
+ * longer open the sidebar by itself. Migrate by combining `defaultOpen`
3360
+ * with `initialState: 'open'` (or `locked: true`) when you want both
3361
+ * effects.
3362
+ *
3363
+ * Callers that want forward-compatible behavior today: prefer
3364
+ * `initialState` / `locked` for sidebar open state, and use `defaultOpen`
3365
+ * purely for section selection.
3366
+ *
3367
+ * @since 0.1.1
3368
+ */
3333
3369
  defaultOpen?: string;
3370
+ /**
3371
+ * Initial open state of the tool panel sidebar on grid load.
3372
+ *
3373
+ * - `'closed'` (default) — sidebar starts collapsed; user opens it via the
3374
+ * built-in toggle button or `grid.openToolPanel()`.
3375
+ * - `'open'` — sidebar starts open; the section named by {@link defaultOpen}
3376
+ * (or the first registered panel) is expanded.
3377
+ *
3378
+ * Takes precedence over the legacy v2 behavior of {@link defaultOpen}: if
3379
+ * `initialState` is set explicitly, it wins.
3380
+ *
3381
+ * @default 'closed'
3382
+ * @since 2.9.0
3383
+ */
3384
+ initialState?: 'open' | 'closed';
3385
+ /**
3386
+ * When `true`, lock the tool panel sidebar in its open state.
3387
+ *
3388
+ * Effects:
3389
+ * - Implies `initialState: 'open'` — the sidebar is forced open on load.
3390
+ * - `grid.closeToolPanel()` / `grid.toggleToolPanel()` become no-ops while
3391
+ * locked (the panel cannot be closed by user or programmatic actions).
3392
+ * - Suppresses the built-in toolbar toggle button (same effect as
3393
+ * `shell.header.toolPanelToggle: false`) since toggling is disabled.
3394
+ * - Accordion sections inside the panel can still be expanded/collapsed.
3395
+ *
3396
+ * @default false
3397
+ * @since 2.9.0
3398
+ */
3399
+ locked?: boolean;
3334
3400
  /** Whether to persist open/closed state (requires Column State Events) */
3335
3401
  persistState?: boolean;
3336
3402
  /**