@toolbox-web/grid 2.11.0 → 2.12.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 (37) hide show
  1. package/index.js +1 -1
  2. package/index.js.map +1 -1
  3. package/lib/core/grid.d.ts +1 -1
  4. package/lib/core/internal/empty.d.ts +66 -0
  5. package/lib/core/styles/index.d.ts +3 -2
  6. package/lib/core/types.d.ts +85 -0
  7. package/lib/plugins/clipboard/index.js.map +1 -1
  8. package/lib/plugins/column-virtualization/index.js.map +1 -1
  9. package/lib/plugins/context-menu/index.js.map +1 -1
  10. package/lib/plugins/editing/index.js.map +1 -1
  11. package/lib/plugins/export/index.js.map +1 -1
  12. package/lib/plugins/filtering/index.js.map +1 -1
  13. package/lib/plugins/grouping-columns/index.js.map +1 -1
  14. package/lib/plugins/grouping-rows/index.js.map +1 -1
  15. package/lib/plugins/master-detail/index.js.map +1 -1
  16. package/lib/plugins/multi-sort/index.js.map +1 -1
  17. package/lib/plugins/pinned-columns/index.js.map +1 -1
  18. package/lib/plugins/pinned-rows/index.js.map +1 -1
  19. package/lib/plugins/pivot/index.js.map +1 -1
  20. package/lib/plugins/print/index.js.map +1 -1
  21. package/lib/plugins/reorder-columns/index.js.map +1 -1
  22. package/lib/plugins/reorder-rows/index.js.map +1 -1
  23. package/lib/plugins/responsive/index.js.map +1 -1
  24. package/lib/plugins/row-drag-drop/index.js.map +1 -1
  25. package/lib/plugins/selection/index.js.map +1 -1
  26. package/lib/plugins/server-side/index.js.map +1 -1
  27. package/lib/plugins/sticky-rows/index.js.map +1 -1
  28. package/lib/plugins/tooltip/index.js.map +1 -1
  29. package/lib/plugins/tree/index.js.map +1 -1
  30. package/lib/plugins/undo-redo/index.js.map +1 -1
  31. package/lib/plugins/visibility/index.js.map +1 -1
  32. package/package.json +1 -1
  33. package/public.d.ts +1 -1
  34. package/umd/grid.all.umd.js +1 -1
  35. package/umd/grid.all.umd.js.map +1 -1
  36. package/umd/grid.umd.js +1 -1
  37. package/umd/grid.umd.js.map +1 -1
@@ -566,7 +566,7 @@ export declare class DataGridElement<T = any> extends HTMLElement implements Int
566
566
  /** @internal Run grid setup (DOM rebuild). */
567
567
  _setup(): void;
568
568
  /** @internal Apply animation configuration to host element. */
569
- _applyAnimationConfig(config: GridConfig<T>): void;
569
+ _applyAnimationConfig(gridConfig: GridConfig<T>): void;
570
570
  /**
571
571
  * Find the header row element.
572
572
  * Used by plugins that need to access header cells for styling or measurement.
@@ -0,0 +1,66 @@
1
+ import { EmptyContext, EmptyOverlay, EmptyRenderer, GridConfig } from '../types';
2
+ /** Default messages used when no `emptyRenderer` is configured. */
3
+ export declare const DEFAULT_EMPTY_MESSAGE = "No data to display";
4
+ export declare const DEFAULT_FILTERED_OUT_MESSAGE = "No matching rows";
5
+ /**
6
+ * Default empty-state renderer.
7
+ * Produces a non-interactive `<div>` carrying a translatable message.
8
+ */
9
+ export declare function defaultEmptyRenderer(ctx: EmptyContext): HTMLElement;
10
+ /**
11
+ * Create the rendered content for the empty overlay.
12
+ * If a custom renderer is provided, use it; otherwise fall back to the default
13
+ * message. Strings returned by user renderers are sanitized through
14
+ * `sanitizeHTML()` before being assigned to `innerHTML` — mirroring the cell
15
+ * render path — so consumers can safely embed values from API responses
16
+ * (e.g. `Failed to load deals: ${error.message}`) without opening an XSS sink.
17
+ */
18
+ export declare function createEmptyContent(ctx: EmptyContext, renderer?: EmptyRenderer): HTMLElement;
19
+ /**
20
+ * Create the empty-state overlay element.
21
+ * Always carries `role="status"` + `aria-live="polite"` so screen readers
22
+ * announce the state on transition; the `data-overlay-target` attribute is
23
+ * informational only. CSS positions absolutely against the closest positioned
24
+ * ancestor — `.tbw-grid-root` is positioned by `base.css`, and `.rows-container`
25
+ * is given `position: relative` for `target='rows'` for the same reason.
26
+ */
27
+ export declare function createEmptyOverlay(ctx: EmptyContext, renderer?: EmptyRenderer, target?: EmptyOverlay): HTMLElement;
28
+ /**
29
+ * Mount the overlay into the chosen target element.
30
+ * Caller resolves the actual element (`.rows-container` for `'rows'`, the
31
+ * `.tbw-grid-root` for `'grid'`).
32
+ */
33
+ export declare function showEmptyOverlay(target: Element, overlayEl: HTMLElement): void;
34
+ /** Detach the overlay from the DOM. */
35
+ export declare function hideEmptyOverlay(overlayEl: HTMLElement | undefined): void;
36
+ /**
37
+ * Decide whether the empty overlay should be visible.
38
+ * The overlay is shown only when:
39
+ * - the grid is not currently in a loading state (loading takes precedence);
40
+ * - the rendered row count is zero (after all plugin processing);
41
+ * - the renderer has not been explicitly disabled by setting it to `null`.
42
+ */
43
+ export declare function shouldShowEmpty(loading: boolean, renderedRowCount: number, renderer: GridConfig['emptyRenderer'] | undefined): boolean;
44
+ /**
45
+ * Per-grid mutable state cached between overlay updates so the hot path
46
+ * (`_schedulerAfterRender` fires on every render phase, including
47
+ * VIRTUALIZATION during scroll) can skip the recreate when nothing observable
48
+ * has changed. Without this guard we'd churn DOM and could leak
49
+ * framework-adapter portals returned from user renderers.
50
+ */
51
+ export interface EmptyOverlayState {
52
+ el?: HTMLElement;
53
+ renderer?: GridConfig['emptyRenderer'];
54
+ target?: EmptyOverlay;
55
+ sourceRowCount?: number;
56
+ filteredOut?: boolean;
57
+ }
58
+ /**
59
+ * Compute, mount, or tear down the empty-state overlay in a single call.
60
+ * Encapsulates show/hide decision, change detection, mount-point resolution,
61
+ * and the `filteredOut` derivation so the grid host can stay a one-liner.
62
+ *
63
+ * The `state` object is mutated in place — callers store a single reference
64
+ * and pass it back on every tick.
65
+ */
66
+ export declare function updateEmptyOverlay(gridRoot: Element | null, loading: boolean, renderedRowCount: number, sourceRowCount: number, renderer: GridConfig['emptyRenderer'] | undefined, target: EmptyOverlay, state: EmptyOverlayState): void;
@@ -24,7 +24,8 @@
24
24
  * 6. Shell (toolbar, layout)
25
25
  * 7. Tool Panel (side panels, accordion)
26
26
  * 8. Loading (spinners, overlays)
27
- * 9. Animations (keyframes, transitions)
28
- * 10. Media Queries (accessibility, responsive)
27
+ * 9. Empty state (no-rows overlay)
28
+ * 10. Animations (keyframes, transitions)
29
+ * 11. Media Queries (accessibility, responsive)
29
30
  */
30
31
  export declare const gridStyles: string;
@@ -2652,7 +2652,92 @@ export interface GridConfig<TRow = any> {
2652
2652
  * ```
2653
2653
  */
2654
2654
  loadingRenderer?: LoadingRenderer;
2655
+ /**
2656
+ * Custom renderer shown when the grid has no rows to display
2657
+ * (`loading === false` AND the rendered row count is `0`, after all plugin
2658
+ * processing such as filtering / grouping / server-side).
2659
+ *
2660
+ * - When **omitted**, a built-in message is rendered ("No data to display"
2661
+ * or "No matching rows" when source rows existed but were filtered out).
2662
+ * - When set to a function, the function receives an {@link EmptyContext}
2663
+ * and returns an `HTMLElement` or HTML string.
2664
+ * - When **explicitly `null`**, the empty overlay is suppressed entirely.
2665
+ *
2666
+ * The empty overlay is mutually exclusive with the loading overlay; if
2667
+ * `loading === true`, the loading overlay always wins.
2668
+ *
2669
+ * @example
2670
+ * ```typescript
2671
+ * // Show a backend error message via a closure over the consumer's state.
2672
+ * gridConfig.emptyRenderer = () =>
2673
+ * error
2674
+ * ? `Failed to load deals: ${error.message}`
2675
+ * : 'No deals to display';
2676
+ * ```
2677
+ *
2678
+ * @see {@link EmptyOverlay} to control where the overlay is mounted.
2679
+ * @since 2.12.0
2680
+ */
2681
+ emptyRenderer?: EmptyRenderer | null;
2682
+ /**
2683
+ * Where the empty-state overlay is mounted.
2684
+ *
2685
+ * - `'rows'` (default) — overlays the `.rows-container`. Headers stay
2686
+ * visible so users can clear filters or see the column schema.
2687
+ * - `'grid'` — overlays the `.tbw-grid-root`. Hides headers and any
2688
+ * shell/toolbar content too.
2689
+ *
2690
+ * @defaultValue `'rows'`
2691
+ * @since 2.12.0
2692
+ */
2693
+ emptyOverlay?: EmptyOverlay;
2694
+ }
2695
+ /**
2696
+ * Where the empty-state overlay is mounted.
2697
+ *
2698
+ * @see {@link GridConfig.emptyOverlay}
2699
+ * @since 2.12.0
2700
+ */
2701
+ export type EmptyOverlay = 'rows' | 'grid';
2702
+ /**
2703
+ * Context passed to a custom {@link EmptyRenderer}.
2704
+ *
2705
+ * @since 2.12.0
2706
+ */
2707
+ export interface EmptyContext {
2708
+ /**
2709
+ * Number of rows in the source data before any plugin processing
2710
+ * (sort / filter / group / server-side). Equivalent to
2711
+ * `grid.sourceRows.length`.
2712
+ */
2713
+ sourceRowCount: number;
2714
+ /**
2715
+ * `true` when the source had rows but all of them were filtered out
2716
+ * (i.e. `sourceRowCount > 0` while the rendered row count is `0`).
2717
+ * The default renderer uses this flag to switch between
2718
+ * "No data to display" and "No matching rows".
2719
+ */
2720
+ filteredOut: boolean;
2655
2721
  }
2722
+ /**
2723
+ * Custom renderer for the empty state overlay.
2724
+ *
2725
+ * @param context - {@link EmptyContext} describing why the grid is empty.
2726
+ * @returns An `HTMLElement` or an HTML string.
2727
+ *
2728
+ * @example
2729
+ * ```typescript
2730
+ * const renderer: EmptyRenderer = (ctx) => {
2731
+ * const div = document.createElement('div');
2732
+ * div.textContent = ctx.filteredOut ? 'No matches' : 'No data';
2733
+ * return div;
2734
+ * };
2735
+ * ```
2736
+ *
2737
+ * @see {@link GridConfig.emptyRenderer}
2738
+ * @since 2.12.0
2739
+ */
2740
+ export type EmptyRenderer = (context: EmptyContext) => HTMLElement | string;
2656
2741
  /**
2657
2742
  * Sort state passed to custom sort handlers.
2658
2743
  * Represents the current sorting configuration for a column.