@toolbox-web/grid 0.2.8 → 0.3.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.
- package/README.md +13 -13
- package/all.d.ts +25 -5659
- package/all.d.ts.map +1 -0
- package/all.js +524 -450
- package/all.js.map +1 -1
- package/index.d.ts +8 -2678
- package/index.d.ts.map +1 -0
- package/index.js +3929 -25
- package/index.js.map +1 -1
- package/lib/core/constants.d.ts +114 -0
- package/lib/core/constants.d.ts.map +1 -0
- package/lib/core/grid.d.ts +337 -0
- package/lib/core/grid.d.ts.map +1 -0
- package/lib/core/internal/aggregators.d.ts +67 -0
- package/lib/core/internal/aggregators.d.ts.map +1 -0
- package/lib/core/internal/column-state.d.ts +124 -0
- package/lib/core/internal/column-state.d.ts.map +1 -0
- package/lib/core/internal/columns.d.ts +107 -0
- package/lib/core/internal/columns.d.ts.map +1 -0
- package/lib/core/internal/dom-builder.d.ts +115 -0
- package/lib/core/internal/dom-builder.d.ts.map +1 -0
- package/lib/core/internal/editing.d.ts +76 -0
- package/lib/core/internal/editing.d.ts.map +1 -0
- package/lib/core/internal/editors.d.ts +8 -0
- package/lib/core/internal/editors.d.ts.map +1 -0
- package/lib/core/internal/event-delegation.d.ts +11 -0
- package/lib/core/internal/event-delegation.d.ts.map +1 -0
- package/lib/core/internal/grid-internals.d.ts +83 -0
- package/lib/core/internal/grid-internals.d.ts.map +1 -0
- package/lib/core/internal/header.d.ts +7 -0
- package/lib/core/internal/header.d.ts.map +1 -0
- package/lib/core/internal/idle-scheduler.d.ts +65 -0
- package/lib/core/internal/idle-scheduler.d.ts.map +1 -0
- package/lib/core/internal/inference.d.ts +12 -0
- package/lib/core/internal/inference.d.ts.map +1 -0
- package/lib/core/internal/keyboard.d.ts +18 -0
- package/lib/core/internal/keyboard.d.ts.map +1 -0
- package/lib/core/internal/resize.d.ts +3 -0
- package/lib/core/internal/resize.d.ts.map +1 -0
- package/lib/core/internal/rows.d.ts +35 -0
- package/lib/core/internal/rows.d.ts.map +1 -0
- package/lib/core/internal/sanitize.d.ts +13 -0
- package/lib/core/internal/sanitize.d.ts.map +1 -0
- package/lib/core/internal/shell.d.ts +228 -0
- package/lib/core/internal/shell.d.ts.map +1 -0
- package/lib/core/internal/sorting.d.ts +24 -0
- package/lib/core/internal/sorting.d.ts.map +1 -0
- package/lib/core/internal/touch-scroll.d.ts +54 -0
- package/lib/core/internal/touch-scroll.d.ts.map +1 -0
- package/lib/core/internal/utils.d.ts +38 -0
- package/lib/core/internal/utils.d.ts.map +1 -0
- package/lib/core/internal/virtualization.d.ts +66 -0
- package/lib/core/internal/virtualization.d.ts.map +1 -0
- package/lib/core/plugin/base-plugin.d.ts +616 -0
- package/lib/core/plugin/base-plugin.d.ts.map +1 -0
- package/lib/core/plugin/index.d.ts +11 -0
- package/lib/core/plugin/index.d.ts.map +1 -0
- package/lib/core/plugin/plugin-manager.d.ts +183 -0
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -0
- package/lib/core/plugin/types.d.ts +196 -0
- package/lib/core/plugin/types.d.ts.map +1 -0
- package/lib/core/types.d.ts +841 -0
- package/lib/core/types.d.ts.map +1 -0
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +46 -0
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -0
- package/lib/plugins/clipboard/copy.d.ts +47 -0
- package/lib/plugins/clipboard/copy.d.ts.map +1 -0
- package/lib/plugins/clipboard/index.d.ts +7 -0
- package/lib/plugins/clipboard/index.d.ts.map +1 -0
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/paste.d.ts +25 -0
- package/lib/plugins/clipboard/paste.d.ts.map +1 -0
- package/lib/plugins/clipboard/types.d.ts +40 -0
- package/lib/plugins/clipboard/types.d.ts.map +1 -0
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +54 -0
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -0
- package/lib/plugins/column-virtualization/column-virtualization.d.ts +53 -0
- package/lib/plugins/column-virtualization/column-virtualization.d.ts.map +1 -0
- package/lib/plugins/column-virtualization/index.d.ts +7 -0
- package/lib/plugins/column-virtualization/index.d.ts.map +1 -0
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/column-virtualization/types.d.ts +41 -0
- package/lib/plugins/column-virtualization/types.d.ts.map +1 -0
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +52 -0
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -0
- package/lib/plugins/context-menu/index.d.ts +7 -0
- package/lib/plugins/context-menu/index.d.ts.map +1 -0
- package/lib/plugins/context-menu/index.js +24 -24
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/context-menu/menu.d.ts +38 -0
- package/lib/plugins/context-menu/menu.d.ts.map +1 -0
- package/lib/plugins/context-menu/types.d.ts +77 -0
- package/lib/plugins/context-menu/types.d.ts.map +1 -0
- package/lib/plugins/export/ExportPlugin.d.ts +53 -0
- package/lib/plugins/export/ExportPlugin.d.ts.map +1 -0
- package/lib/plugins/export/csv.d.ts +31 -0
- package/lib/plugins/export/csv.d.ts.map +1 -0
- package/lib/plugins/export/excel.d.ts +12 -0
- package/lib/plugins/export/excel.d.ts.map +1 -0
- package/lib/plugins/export/index.d.ts +7 -0
- package/lib/plugins/export/index.d.ts.map +1 -0
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/export/types.d.ts +57 -0
- package/lib/plugins/export/types.d.ts.map +1 -0
- package/lib/plugins/filtering/FilteringPlugin.d.ts +128 -0
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -0
- package/lib/plugins/filtering/filter-model.d.ts +38 -0
- package/lib/plugins/filtering/filter-model.d.ts.map +1 -0
- package/lib/plugins/filtering/index.d.ts +7 -0
- package/lib/plugins/filtering/index.d.ts.map +1 -0
- package/lib/plugins/filtering/index.js +5 -5
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/filtering/types.d.ts +157 -0
- package/lib/plugins/filtering/types.d.ts.map +1 -0
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +51 -0
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -0
- package/lib/plugins/grouping-columns/grouping-columns.d.ts +41 -0
- package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -0
- package/lib/plugins/grouping-columns/index.d.ts +7 -0
- package/lib/plugins/grouping-columns/index.d.ts.map +1 -0
- package/lib/plugins/grouping-columns/index.js +58 -42
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-columns/types.d.ts +91 -0
- package/lib/plugins/grouping-columns/types.d.ts.map +1 -0
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +120 -0
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -0
- package/lib/plugins/grouping-rows/grouping-rows.d.ts +51 -0
- package/lib/plugins/grouping-rows/grouping-rows.d.ts.map +1 -0
- package/lib/plugins/grouping-rows/index.d.ts +7 -0
- package/lib/plugins/grouping-rows/index.d.ts.map +1 -0
- package/lib/plugins/grouping-rows/index.js +51 -51
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/grouping-rows/types.d.ts +95 -0
- package/lib/plugins/grouping-rows/types.d.ts.map +1 -0
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +147 -0
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -0
- package/lib/plugins/master-detail/index.d.ts +7 -0
- package/lib/plugins/master-detail/index.d.ts.map +1 -0
- package/lib/plugins/master-detail/index.js +235 -78
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/master-detail/master-detail.d.ts +30 -0
- package/lib/plugins/master-detail/master-detail.d.ts.map +1 -0
- package/lib/plugins/master-detail/types.d.ts +40 -0
- package/lib/plugins/master-detail/types.d.ts.map +1 -0
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +58 -0
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -0
- package/lib/plugins/multi-sort/index.d.ts +7 -0
- package/lib/plugins/multi-sort/index.d.ts.map +1 -0
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/multi-sort/multi-sort.d.ts +51 -0
- package/lib/plugins/multi-sort/multi-sort.d.ts.map +1 -0
- package/lib/plugins/multi-sort/types.d.ts +25 -0
- package/lib/plugins/multi-sort/types.d.ts.map +1 -0
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +58 -0
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -0
- package/lib/plugins/pinned-columns/index.d.ts +7 -0
- package/lib/plugins/pinned-columns/index.d.ts.map +1 -0
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +62 -0
- package/lib/plugins/pinned-columns/pinned-columns.d.ts.map +1 -0
- package/lib/plugins/pinned-columns/types.d.ts +20 -0
- package/lib/plugins/pinned-columns/types.d.ts.map +1 -0
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +64 -0
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -0
- package/lib/plugins/pinned-rows/index.d.ts +7 -0
- package/lib/plugins/pinned-rows/index.d.ts.map +1 -0
- package/lib/plugins/pinned-rows/index.js +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pinned-rows/pinned-rows.d.ts +43 -0
- package/lib/plugins/pinned-rows/pinned-rows.d.ts.map +1 -0
- package/lib/plugins/pinned-rows/types.d.ts +95 -0
- package/lib/plugins/pinned-rows/types.d.ts.map +1 -0
- package/lib/plugins/pivot/PivotPlugin.d.ts +94 -0
- package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -0
- package/lib/plugins/pivot/index.d.ts +7 -0
- package/lib/plugins/pivot/index.d.ts.map +1 -0
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/pivot/pivot-engine.d.ts +50 -0
- package/lib/plugins/pivot/pivot-engine.d.ts.map +1 -0
- package/lib/plugins/pivot/pivot-model.d.ts +6 -0
- package/lib/plugins/pivot/pivot-model.d.ts.map +1 -0
- package/lib/plugins/pivot/pivot-panel.d.ts +25 -0
- package/lib/plugins/pivot/pivot-panel.d.ts.map +1 -0
- package/lib/plugins/pivot/pivot-rows.d.ts +33 -0
- package/lib/plugins/pivot/pivot-rows.d.ts.map +1 -0
- package/lib/plugins/pivot/types.d.ts +62 -0
- package/lib/plugins/pivot/types.d.ts.map +1 -0
- package/lib/plugins/reorder/ReorderPlugin.d.ts +81 -0
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -0
- package/lib/plugins/reorder/column-drag.d.ts +41 -0
- package/lib/plugins/reorder/column-drag.d.ts.map +1 -0
- package/lib/plugins/reorder/index.d.ts +7 -0
- package/lib/plugins/reorder/index.d.ts.map +1 -0
- package/lib/plugins/reorder/index.js +51 -48
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/reorder/types.d.ts +54 -0
- package/lib/plugins/reorder/types.d.ts.map +1 -0
- package/lib/plugins/selection/SelectionPlugin.d.ts +77 -0
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -0
- package/lib/plugins/selection/index.d.ts +8 -0
- package/lib/plugins/selection/index.d.ts.map +1 -0
- package/lib/plugins/selection/index.js +86 -75
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/range-selection.d.ts +109 -0
- package/lib/plugins/selection/range-selection.d.ts.map +1 -0
- package/lib/plugins/selection/row-selection.d.ts +48 -0
- package/lib/plugins/selection/row-selection.d.ts.map +1 -0
- package/lib/plugins/selection/types.d.ts +80 -0
- package/lib/plugins/selection/types.d.ts.map +1 -0
- package/lib/plugins/server-side/ServerSidePlugin.d.ts +56 -0
- package/lib/plugins/server-side/ServerSidePlugin.d.ts.map +1 -0
- package/lib/plugins/server-side/cache.d.ts +14 -0
- package/lib/plugins/server-side/cache.d.ts.map +1 -0
- package/lib/plugins/server-side/datasource.d.ts +12 -0
- package/lib/plugins/server-side/datasource.d.ts.map +1 -0
- package/lib/plugins/server-side/index.d.ts +7 -0
- package/lib/plugins/server-side/index.d.ts.map +1 -0
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/server-side/types.d.ts +43 -0
- package/lib/plugins/server-side/types.d.ts.map +1 -0
- package/lib/plugins/tree/TreePlugin.d.ts +49 -0
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -0
- package/lib/plugins/tree/index.d.ts +8 -0
- package/lib/plugins/tree/index.d.ts.map +1 -0
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/tree-data.d.ts +42 -0
- package/lib/plugins/tree/tree-data.d.ts.map +1 -0
- package/lib/plugins/tree/tree-detect.d.ts +24 -0
- package/lib/plugins/tree/tree-detect.d.ts.map +1 -0
- package/lib/plugins/tree/types.d.ts +61 -0
- package/lib/plugins/tree/types.d.ts.map +1 -0
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +68 -0
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -0
- package/lib/plugins/undo-redo/history.d.ts +64 -0
- package/lib/plugins/undo-redo/history.d.ts.map +1 -0
- package/lib/plugins/undo-redo/index.d.ts +7 -0
- package/lib/plugins/undo-redo/index.d.ts.map +1 -0
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/undo-redo/types.d.ts +41 -0
- package/lib/plugins/undo-redo/types.d.ts.map +1 -0
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +135 -0
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -0
- package/lib/plugins/visibility/index.d.ts +8 -0
- package/lib/plugins/visibility/index.d.ts.map +1 -0
- package/lib/plugins/visibility/index.js.map +1 -1
- package/lib/plugins/visibility/types.d.ts +33 -0
- package/lib/plugins/visibility/types.d.ts.map +1 -0
- package/lib/plugins/visibility/visibility.d.ts +30 -0
- package/lib/plugins/visibility/visibility.d.ts.map +1 -0
- package/package.json +6 -2
- package/public.d.ts +52 -0
- package/public.d.ts.map +1 -0
- package/umd/grid.all.umd.js +32 -74
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +22 -64
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/index-YjW60MHD.js +0 -3235
- package/index-YjW60MHD.js.map +0 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { BaseGridPlugin, GridElement, RowClickEvent } from '../../core/plugin/base-plugin';
|
|
2
|
+
import { ColumnConfig } from '../../core/types';
|
|
3
|
+
import { MasterDetailConfig } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Master/Detail Plugin for tbw-grid
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* new MasterDetailPlugin({
|
|
10
|
+
* enabled: true,
|
|
11
|
+
* detailRenderer: (row) => `<div>Details for ${row.name}</div>`,
|
|
12
|
+
* expandOnRowClick: true,
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class MasterDetailPlugin extends BaseGridPlugin<MasterDetailConfig> {
|
|
17
|
+
#private;
|
|
18
|
+
readonly name = "masterDetail";
|
|
19
|
+
readonly version = "1.0.0";
|
|
20
|
+
protected get defaultConfig(): Partial<MasterDetailConfig>;
|
|
21
|
+
/**
|
|
22
|
+
* Called when plugin is attached to the grid.
|
|
23
|
+
* Parses light DOM for `<tbw-grid-detail>` elements to configure detail templates.
|
|
24
|
+
*/
|
|
25
|
+
attach(grid: GridElement): void;
|
|
26
|
+
/**
|
|
27
|
+
* Parse `<tbw-grid-detail>` elements from the grid's light DOM.
|
|
28
|
+
*
|
|
29
|
+
* Allows declarative configuration:
|
|
30
|
+
* ```html
|
|
31
|
+
* <tbw-grid [rows]="data">
|
|
32
|
+
* <tbw-grid-detail>
|
|
33
|
+
* <div class="detail-content">
|
|
34
|
+
* <p>Name: {{ row.name }}</p>
|
|
35
|
+
* <p>Email: {{ row.email }}</p>
|
|
36
|
+
* </div>
|
|
37
|
+
* </tbw-grid-detail>
|
|
38
|
+
* </tbw-grid>
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Attributes:
|
|
42
|
+
* - `animation`: 'slide' | 'fade' | 'false' (default: 'slide')
|
|
43
|
+
* - `show-expand-column`: 'true' | 'false' (default: 'true')
|
|
44
|
+
* - `expand-on-row-click`: 'true' | 'false' (default: 'false')
|
|
45
|
+
* - `collapse-on-click-outside`: 'true' | 'false' (default: 'false')
|
|
46
|
+
* - `height`: number (pixels) or 'auto' (default: 'auto')
|
|
47
|
+
*/
|
|
48
|
+
private parseLightDomDetail;
|
|
49
|
+
/**
|
|
50
|
+
* Check if animations are enabled at the grid level.
|
|
51
|
+
* Respects gridConfig.animation.mode and CSS variable.
|
|
52
|
+
*/
|
|
53
|
+
private get isAnimationEnabled();
|
|
54
|
+
/**
|
|
55
|
+
* Get expand/collapse animation style from plugin config.
|
|
56
|
+
*/
|
|
57
|
+
private get animationStyle();
|
|
58
|
+
/**
|
|
59
|
+
* Get animation duration from CSS variable (set by grid).
|
|
60
|
+
*/
|
|
61
|
+
private get animationDuration();
|
|
62
|
+
/**
|
|
63
|
+
* Apply expand animation to a detail element.
|
|
64
|
+
*/
|
|
65
|
+
private animateExpand;
|
|
66
|
+
/**
|
|
67
|
+
* Apply collapse animation to a detail element and remove after animation.
|
|
68
|
+
*/
|
|
69
|
+
private animateCollapse;
|
|
70
|
+
private expandedRows;
|
|
71
|
+
private detailElements;
|
|
72
|
+
detach(): void;
|
|
73
|
+
processColumns(columns: readonly ColumnConfig[]): ColumnConfig[];
|
|
74
|
+
onRowClick(event: RowClickEvent): boolean | void;
|
|
75
|
+
onCellClick(): boolean | void;
|
|
76
|
+
afterRender(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Called on scroll to sync detail elements with visible rows.
|
|
79
|
+
* Removes details for rows that scrolled out of view and reattaches for visible rows.
|
|
80
|
+
*/
|
|
81
|
+
onScrollRender(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Return total extra height from all expanded detail rows.
|
|
84
|
+
* Used by grid virtualization to adjust scrollbar height.
|
|
85
|
+
*/
|
|
86
|
+
getExtraHeight(): number;
|
|
87
|
+
/**
|
|
88
|
+
* Return extra height that appears before a given row index.
|
|
89
|
+
* This is the sum of heights of all expanded details whose parent row is before the given index.
|
|
90
|
+
*/
|
|
91
|
+
getExtraHeightBefore(beforeRowIndex: number): number;
|
|
92
|
+
/**
|
|
93
|
+
* Adjust the virtualization start index to keep expanded row visible while its detail is visible.
|
|
94
|
+
* This ensures the detail scrolls smoothly out of view instead of disappearing abruptly.
|
|
95
|
+
*/
|
|
96
|
+
adjustVirtualStart(start: number, scrollTop: number, rowHeight: number): number;
|
|
97
|
+
/**
|
|
98
|
+
* Expand the detail row at the given index.
|
|
99
|
+
* @param rowIndex - Index of the row to expand
|
|
100
|
+
*/
|
|
101
|
+
expand(rowIndex: number): void;
|
|
102
|
+
/**
|
|
103
|
+
* Collapse the detail row at the given index.
|
|
104
|
+
* @param rowIndex - Index of the row to collapse
|
|
105
|
+
*/
|
|
106
|
+
collapse(rowIndex: number): void;
|
|
107
|
+
/**
|
|
108
|
+
* Toggle the detail row at the given index.
|
|
109
|
+
* @param rowIndex - Index of the row to toggle
|
|
110
|
+
*/
|
|
111
|
+
toggle(rowIndex: number): void;
|
|
112
|
+
/**
|
|
113
|
+
* Check if the detail row at the given index is expanded.
|
|
114
|
+
* @param rowIndex - Index of the row to check
|
|
115
|
+
* @returns Whether the detail row is expanded
|
|
116
|
+
*/
|
|
117
|
+
isExpanded(rowIndex: number): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Expand all detail rows.
|
|
120
|
+
*/
|
|
121
|
+
expandAll(): void;
|
|
122
|
+
/**
|
|
123
|
+
* Collapse all detail rows.
|
|
124
|
+
*/
|
|
125
|
+
collapseAll(): void;
|
|
126
|
+
/**
|
|
127
|
+
* Get the indices of all expanded rows.
|
|
128
|
+
* @returns Array of row indices that are expanded
|
|
129
|
+
*/
|
|
130
|
+
getExpandedRows(): number[];
|
|
131
|
+
/**
|
|
132
|
+
* Get the detail element for a specific row.
|
|
133
|
+
* @param rowIndex - Index of the row
|
|
134
|
+
* @returns The detail HTMLElement or undefined
|
|
135
|
+
*/
|
|
136
|
+
getDetailElement(rowIndex: number): HTMLElement | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Re-parse light DOM to refresh the detail renderer.
|
|
139
|
+
* Call this after framework templates are registered (e.g., Angular ngAfterContentInit).
|
|
140
|
+
*
|
|
141
|
+
* This allows frameworks to register templates asynchronously and then
|
|
142
|
+
* update the plugin's detailRenderer.
|
|
143
|
+
*/
|
|
144
|
+
refreshDetailRenderer(): void;
|
|
145
|
+
readonly styles: string;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=MasterDetailPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MasterDetailPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/master-detail/MasterDetailPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,kBAAkB,CAAC;AASjE,OAAO,KAAK,EAA+C,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAO/F;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAmB,SAAQ,cAAc,CAAC,kBAAkB,CAAC;;IACxE,QAAQ,CAAC,IAAI,kBAAkB;IAC/B,SAAkB,OAAO,WAAW;IAEpC,cAAuB,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAQlE;IAID;;;OAGG;IACM,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAKxC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,CAAC,mBAAmB;IAqE3B;;;OAGG;IACH,OAAO,KAAK,kBAAkB,GAc7B;IAED;;OAEG;IACH,OAAO,KAAK,cAAc,GAGzB;IAED;;OAEG;IACH,OAAO,KAAK,iBAAiB,GAQ5B;IAED;;OAEG;IACH,OAAO,CAAC,aAAa;IAarB;;OAEG;IACH,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,cAAc,CAAoC;IAKjD,MAAM,IAAI,IAAI;IAQd,cAAc,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,YAAY,EAAE;IAyEhE,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,GAAG,IAAI;IAehD,WAAW,IAAI,OAAO,GAAG,IAAI;IAS7B,WAAW,IAAI,IAAI;IAI5B;;;OAGG;IACM,cAAc,IAAI,IAAI;IA2E/B;;;OAGG;IACM,cAAc,IAAI,MAAM;IAejC;;;OAGG;IACM,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;IAkB7D;;;OAGG;IACM,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAgDxF;;;OAGG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAQ9B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAQhC;;;OAGG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAQ9B;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKrC;;OAEG;IACH,SAAS,IAAI,IAAI;IAOjB;;OAEG;IACH,WAAW,IAAI,IAAI;IAKnB;;;OAGG;IACH,eAAe,IAAI,MAAM,EAAE;IAS3B;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAK3D;;;;;;OAMG;IACH,qBAAqB,IAAI,IAAI;IAc7B,SAAkB,MAAM,SAAU;CAEnC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Master Detail Plugin Entry Point
|
|
3
|
+
* Re-exports plugin class and types for tree-shakeable imports.
|
|
4
|
+
*/
|
|
5
|
+
export { MasterDetailPlugin } from './MasterDetailPlugin';
|
|
6
|
+
export type { ExpandCollapseAnimation, MasterDetailConfig } from './types';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/master-detail/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,4 +1,98 @@
|
|
|
1
|
-
const w =
|
|
1
|
+
const R = /{{\s*([^}]+)\s*}}/g, f = "__DG_EMPTY__", x = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, b = /__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/, E = /* @__PURE__ */ new Set([
|
|
2
|
+
"script",
|
|
3
|
+
"iframe",
|
|
4
|
+
"object",
|
|
5
|
+
"embed",
|
|
6
|
+
"form",
|
|
7
|
+
"input",
|
|
8
|
+
"button",
|
|
9
|
+
"textarea",
|
|
10
|
+
"select",
|
|
11
|
+
"link",
|
|
12
|
+
"meta",
|
|
13
|
+
"base",
|
|
14
|
+
"style",
|
|
15
|
+
"template",
|
|
16
|
+
"slot",
|
|
17
|
+
"portal",
|
|
18
|
+
"frame",
|
|
19
|
+
"frameset",
|
|
20
|
+
"applet",
|
|
21
|
+
"noscript",
|
|
22
|
+
"noembed",
|
|
23
|
+
"plaintext",
|
|
24
|
+
"xmp",
|
|
25
|
+
"listing"
|
|
26
|
+
]), w = /^on\w+$/i, v = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), y = /^\s*(javascript|vbscript|data|blob):/i;
|
|
27
|
+
function S(i) {
|
|
28
|
+
if (!i || typeof i != "string") return "";
|
|
29
|
+
if (i.indexOf("<") === -1) return i;
|
|
30
|
+
const e = document.createElement("template");
|
|
31
|
+
return e.innerHTML = i, C(e.content), e.innerHTML;
|
|
32
|
+
}
|
|
33
|
+
function C(i) {
|
|
34
|
+
const e = [], t = i.querySelectorAll("*");
|
|
35
|
+
for (const n of t) {
|
|
36
|
+
const o = n.tagName.toLowerCase();
|
|
37
|
+
if (E.has(o)) {
|
|
38
|
+
e.push(n);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if ((o === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
|
|
42
|
+
(s) => w.test(s.name) || s.name === "href" || s.name === "xlink:href"
|
|
43
|
+
)) {
|
|
44
|
+
e.push(n);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const l = [];
|
|
48
|
+
for (const r of n.attributes) {
|
|
49
|
+
const s = r.name.toLowerCase();
|
|
50
|
+
if (w.test(s)) {
|
|
51
|
+
l.push(r.name);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (v.has(s) && y.test(r.value)) {
|
|
55
|
+
l.push(r.name);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (s === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(r.value)) {
|
|
59
|
+
l.push(r.name);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
l.forEach((r) => n.removeAttribute(r));
|
|
64
|
+
}
|
|
65
|
+
e.forEach((n) => n.remove());
|
|
66
|
+
}
|
|
67
|
+
function A(i, e) {
|
|
68
|
+
if (!i || i.indexOf("{{") === -1) return i;
|
|
69
|
+
const t = [], n = i.replace(R, (s, a) => {
|
|
70
|
+
const d = D(a, e);
|
|
71
|
+
return t.push({ expr: a.trim(), result: d }), d;
|
|
72
|
+
}), o = H(n), l = t.length && t.every((s) => s.result === "" || s.result === f);
|
|
73
|
+
return /Reflect\.|\bProxy\b|ownKeys\(/.test(i) || l ? "" : o;
|
|
74
|
+
}
|
|
75
|
+
function D(i, e) {
|
|
76
|
+
if (i = (i || "").trim(), !i || /\b(Reflect|Proxy|ownKeys)\b/.test(i)) return f;
|
|
77
|
+
if (i === "value") return e.value == null ? f : String(e.value);
|
|
78
|
+
if (i.startsWith("row.") && !/[()?]/.test(i) && !i.includes(":")) {
|
|
79
|
+
const n = i.slice(4), o = e.row ? e.row[n] : void 0;
|
|
80
|
+
return o == null ? f : String(o);
|
|
81
|
+
}
|
|
82
|
+
if (i.length > 80 || !x.test(i) || b.test(i)) return f;
|
|
83
|
+
const t = i.match(/\./g);
|
|
84
|
+
if (t && t.length > 1) return f;
|
|
85
|
+
try {
|
|
86
|
+
const o = new Function("value", "row", `return (${i});`)(e.value, e.row), l = o == null ? "" : String(o);
|
|
87
|
+
return /Reflect|Proxy|ownKeys/.test(l) ? f : l || f;
|
|
88
|
+
} catch {
|
|
89
|
+
return f;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function H(i) {
|
|
93
|
+
return i && i.replace(new RegExp(f, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
|
|
94
|
+
}
|
|
95
|
+
const k = {
|
|
2
96
|
expand: "▶",
|
|
3
97
|
collapse: "▼",
|
|
4
98
|
sortAsc: "▲",
|
|
@@ -8,7 +102,7 @@ const w = {
|
|
|
8
102
|
dragHandle: "⋮⋮",
|
|
9
103
|
toolPanel: "☰"
|
|
10
104
|
};
|
|
11
|
-
class
|
|
105
|
+
class _ {
|
|
12
106
|
/** Plugin version - override in subclass if needed */
|
|
13
107
|
version = "1.0.0";
|
|
14
108
|
/** CSS styles to inject into the grid's shadow DOM */
|
|
@@ -133,7 +227,7 @@ class m {
|
|
|
133
227
|
*/
|
|
134
228
|
get gridIcons() {
|
|
135
229
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
136
|
-
return { ...
|
|
230
|
+
return { ...k, ...e };
|
|
137
231
|
}
|
|
138
232
|
/**
|
|
139
233
|
* Resolve an icon value to string or HTMLElement.
|
|
@@ -164,31 +258,31 @@ class m {
|
|
|
164
258
|
}
|
|
165
259
|
// #endregion
|
|
166
260
|
}
|
|
167
|
-
function p(
|
|
168
|
-
const t = new Set(
|
|
261
|
+
function p(i, e) {
|
|
262
|
+
const t = new Set(i);
|
|
169
263
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
170
264
|
}
|
|
171
|
-
function
|
|
172
|
-
const t = new Set(
|
|
265
|
+
function L(i, e) {
|
|
266
|
+
const t = new Set(i);
|
|
173
267
|
return t.add(e), t;
|
|
174
268
|
}
|
|
175
|
-
function
|
|
176
|
-
const t = new Set(
|
|
269
|
+
function T(i, e) {
|
|
270
|
+
const t = new Set(i);
|
|
177
271
|
return t.delete(e), t;
|
|
178
272
|
}
|
|
179
|
-
function
|
|
180
|
-
return
|
|
273
|
+
function I(i, e) {
|
|
274
|
+
return i.has(e);
|
|
181
275
|
}
|
|
182
|
-
function
|
|
276
|
+
function O(i, e, t, n) {
|
|
183
277
|
const o = document.createElement("div");
|
|
184
278
|
o.className = "master-detail-row", o.setAttribute("data-detail-for", String(e)), o.setAttribute("role", "row");
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
const r = t(
|
|
188
|
-
return typeof r == "string" ?
|
|
279
|
+
const l = document.createElement("div");
|
|
280
|
+
l.className = "master-detail-cell", l.setAttribute("role", "cell"), l.style.gridColumn = `1 / ${n + 1}`;
|
|
281
|
+
const r = t(i, e);
|
|
282
|
+
return typeof r == "string" ? l.innerHTML = r : r instanceof HTMLElement && l.appendChild(r), o.appendChild(l), o;
|
|
189
283
|
}
|
|
190
|
-
const
|
|
191
|
-
class
|
|
284
|
+
const N = ".master-detail-cell-wrapper{display:flex;align-items:center;gap:4px}.master-detail-toggle{cursor:pointer;opacity:.7;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center}.master-detail-toggle:hover{opacity:1}.master-detail-row{grid-column:1 / -1;display:grid;background:var(--tbw-master-detail-bg, var(--tbw-color-row-alt));border-bottom:1px solid var(--tbw-master-detail-border, var(--tbw-color-border));overflow:hidden}.master-detail-cell{padding:16px;overflow:auto}.master-detail-row.tbw-expanding{animation:tbw-detail-expand var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}.master-detail-row.tbw-collapsing{animation:tbw-detail-collapse var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-detail-expand{0%{opacity:0;max-height:0;padding-top:0;padding-bottom:0}to{opacity:1;max-height:500px;padding-top:16px;padding-bottom:16px}}@keyframes tbw-detail-collapse{0%{opacity:1;max-height:500px}to{opacity:0;max-height:0}}";
|
|
285
|
+
class q extends _ {
|
|
192
286
|
name = "masterDetail";
|
|
193
287
|
version = "1.0.0";
|
|
194
288
|
get defaultConfig() {
|
|
@@ -201,6 +295,58 @@ class C extends m {
|
|
|
201
295
|
// Plugin's own default
|
|
202
296
|
};
|
|
203
297
|
}
|
|
298
|
+
// #region Light DOM Parsing
|
|
299
|
+
/**
|
|
300
|
+
* Called when plugin is attached to the grid.
|
|
301
|
+
* Parses light DOM for `<tbw-grid-detail>` elements to configure detail templates.
|
|
302
|
+
*/
|
|
303
|
+
attach(e) {
|
|
304
|
+
super.attach(e), this.parseLightDomDetail();
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Parse `<tbw-grid-detail>` elements from the grid's light DOM.
|
|
308
|
+
*
|
|
309
|
+
* Allows declarative configuration:
|
|
310
|
+
* ```html
|
|
311
|
+
* <tbw-grid [rows]="data">
|
|
312
|
+
* <tbw-grid-detail>
|
|
313
|
+
* <div class="detail-content">
|
|
314
|
+
* <p>Name: {{ row.name }}</p>
|
|
315
|
+
* <p>Email: {{ row.email }}</p>
|
|
316
|
+
* </div>
|
|
317
|
+
* </tbw-grid-detail>
|
|
318
|
+
* </tbw-grid>
|
|
319
|
+
* ```
|
|
320
|
+
*
|
|
321
|
+
* Attributes:
|
|
322
|
+
* - `animation`: 'slide' | 'fade' | 'false' (default: 'slide')
|
|
323
|
+
* - `show-expand-column`: 'true' | 'false' (default: 'true')
|
|
324
|
+
* - `expand-on-row-click`: 'true' | 'false' (default: 'false')
|
|
325
|
+
* - `collapse-on-click-outside`: 'true' | 'false' (default: 'false')
|
|
326
|
+
* - `height`: number (pixels) or 'auto' (default: 'auto')
|
|
327
|
+
*/
|
|
328
|
+
parseLightDomDetail() {
|
|
329
|
+
const e = this.grid;
|
|
330
|
+
if (!e || typeof e.querySelector != "function") return;
|
|
331
|
+
const t = e.querySelector("tbw-grid-detail");
|
|
332
|
+
if (!t) return;
|
|
333
|
+
const n = e;
|
|
334
|
+
if (n.__frameworkAdapter?.parseDetailElement) {
|
|
335
|
+
const c = n.__frameworkAdapter.parseDetailElement(t);
|
|
336
|
+
if (c) {
|
|
337
|
+
this.config = { ...this.config, detailRenderer: c };
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const o = t.getAttribute("animation"), l = t.getAttribute("show-expand-column"), r = t.getAttribute("expand-on-row-click"), s = t.getAttribute("collapse-on-click-outside"), a = t.getAttribute("height"), d = {};
|
|
342
|
+
o !== null && (d.animation = o === "false" ? !1 : o), l !== null && (d.showExpandColumn = l !== "false"), r !== null && (d.expandOnRowClick = r === "true"), s !== null && (d.collapseOnClickOutside = s === "true"), a !== null && (d.detailHeight = a === "auto" ? "auto" : parseInt(a, 10));
|
|
343
|
+
const u = t.innerHTML.trim();
|
|
344
|
+
u && !this.config.detailRenderer && (d.detailRenderer = (c, h) => {
|
|
345
|
+
const g = A(u, { value: c, row: c });
|
|
346
|
+
return S(g);
|
|
347
|
+
}), Object.keys(d).length > 0 && (this.config = { ...this.config, ...d });
|
|
348
|
+
}
|
|
349
|
+
// #endregion
|
|
204
350
|
// #region Animation Helpers
|
|
205
351
|
/**
|
|
206
352
|
* Check if animations are enabled at the grid level.
|
|
@@ -210,8 +356,8 @@ class C extends m {
|
|
|
210
356
|
const t = this.grid.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
211
357
|
if (t === !1 || t === "off") return !1;
|
|
212
358
|
if (t === !0 || t === "on") return !0;
|
|
213
|
-
const
|
|
214
|
-
return
|
|
359
|
+
const n = this.shadowRoot?.host;
|
|
360
|
+
return n ? getComputedStyle(n).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
215
361
|
}
|
|
216
362
|
/**
|
|
217
363
|
* Get expand/collapse animation style from plugin config.
|
|
@@ -225,8 +371,8 @@ class C extends m {
|
|
|
225
371
|
get animationDuration() {
|
|
226
372
|
const e = this.shadowRoot?.host;
|
|
227
373
|
if (e) {
|
|
228
|
-
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),
|
|
229
|
-
if (!isNaN(
|
|
374
|
+
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), n = parseInt(t, 10);
|
|
375
|
+
if (!isNaN(n)) return n;
|
|
230
376
|
}
|
|
231
377
|
return 200;
|
|
232
378
|
}
|
|
@@ -251,10 +397,10 @@ class C extends m {
|
|
|
251
397
|
return;
|
|
252
398
|
}
|
|
253
399
|
e.classList.add("tbw-collapsing");
|
|
254
|
-
const
|
|
400
|
+
const n = () => {
|
|
255
401
|
e.classList.remove("tbw-collapsing"), t();
|
|
256
402
|
};
|
|
257
|
-
e.addEventListener("animationend",
|
|
403
|
+
e.addEventListener("animationend", n, { once: !0 }), setTimeout(n, this.animationDuration + 50);
|
|
258
404
|
}
|
|
259
405
|
// #endregion
|
|
260
406
|
// #region Internal State
|
|
@@ -272,31 +418,31 @@ class C extends m {
|
|
|
272
418
|
return [...e];
|
|
273
419
|
const t = [...e];
|
|
274
420
|
if (t.length > 0) {
|
|
275
|
-
const
|
|
421
|
+
const n = { ...t[0] }, o = n.viewRenderer;
|
|
276
422
|
if (o?.__masterDetailWrapped)
|
|
277
423
|
return t;
|
|
278
|
-
const
|
|
279
|
-
const { value: s, row:
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
|
|
424
|
+
const l = (r) => {
|
|
425
|
+
const { value: s, row: a } = r, d = this.expandedRows.has(a), u = document.createElement("span");
|
|
426
|
+
u.className = "master-detail-cell-wrapper";
|
|
427
|
+
const c = document.createElement("span");
|
|
428
|
+
c.className = `master-detail-toggle${d ? " expanded" : ""}`, this.setIcon(c, this.resolveIcon(d ? "collapse" : "expand")), c.setAttribute("role", "button"), c.setAttribute("tabindex", "0"), c.setAttribute("aria-expanded", String(d)), c.setAttribute("aria-label", d ? "Collapse details" : "Expand details"), c.addEventListener("click", (g) => {
|
|
283
429
|
g.stopPropagation();
|
|
284
|
-
const
|
|
285
|
-
this.expandedRows = p(this.expandedRows,
|
|
286
|
-
rowIndex:
|
|
287
|
-
row:
|
|
288
|
-
expanded: this.expandedRows.has(
|
|
430
|
+
const m = this.rows.indexOf(a);
|
|
431
|
+
this.expandedRows = p(this.expandedRows, a), this.emit("detail-expand", {
|
|
432
|
+
rowIndex: m,
|
|
433
|
+
row: a,
|
|
434
|
+
expanded: this.expandedRows.has(a)
|
|
289
435
|
}), this.requestRender();
|
|
290
|
-
}),
|
|
291
|
-
const
|
|
436
|
+
}), u.appendChild(c);
|
|
437
|
+
const h = document.createElement("span");
|
|
292
438
|
if (o) {
|
|
293
439
|
const g = o(r);
|
|
294
|
-
g instanceof Node ?
|
|
440
|
+
g instanceof Node ? h.appendChild(g) : h.textContent = String(g ?? s ?? "");
|
|
295
441
|
} else
|
|
296
|
-
|
|
297
|
-
return
|
|
442
|
+
h.textContent = String(s ?? "");
|
|
443
|
+
return u.appendChild(h), u;
|
|
298
444
|
};
|
|
299
|
-
|
|
445
|
+
l.__masterDetailWrapped = !0, n.viewRenderer = l, t[0] = n;
|
|
300
446
|
}
|
|
301
447
|
return t;
|
|
302
448
|
}
|
|
@@ -329,26 +475,26 @@ class C extends m {
|
|
|
329
475
|
if (!this.config.detailRenderer) return;
|
|
330
476
|
const e = this.shadowRoot?.querySelector(".rows");
|
|
331
477
|
if (!e) return;
|
|
332
|
-
const t = /* @__PURE__ */ new Map(),
|
|
333
|
-
for (const r of
|
|
334
|
-
const s = r.querySelector(".cell[data-row]"),
|
|
335
|
-
|
|
478
|
+
const t = /* @__PURE__ */ new Map(), n = e.querySelectorAll(".data-grid-row"), o = this.columns.length;
|
|
479
|
+
for (const r of n) {
|
|
480
|
+
const s = r.querySelector(".cell[data-row]"), a = s ? parseInt(s.getAttribute("data-row") ?? "-1", 10) : -1;
|
|
481
|
+
a >= 0 && t.set(a, r);
|
|
336
482
|
}
|
|
337
|
-
const
|
|
338
|
-
for (const r of
|
|
339
|
-
const s = parseInt(r.getAttribute("data-detail-for") ?? "-1", 10),
|
|
340
|
-
(!d || !
|
|
483
|
+
const l = e.querySelectorAll(".master-detail-row");
|
|
484
|
+
for (const r of l) {
|
|
485
|
+
const s = parseInt(r.getAttribute("data-detail-for") ?? "-1", 10), a = s >= 0 ? this.rows[s] : void 0, d = a && this.expandedRows.has(a), u = t.has(s);
|
|
486
|
+
(!d || !u) && (r.remove(), a && this.detailElements.delete(a));
|
|
341
487
|
}
|
|
342
488
|
for (const [r, s] of t) {
|
|
343
|
-
const
|
|
344
|
-
if (!
|
|
345
|
-
const d = this.detailElements.get(
|
|
489
|
+
const a = this.rows[r];
|
|
490
|
+
if (!a || !this.expandedRows.has(a)) continue;
|
|
491
|
+
const d = this.detailElements.get(a);
|
|
346
492
|
if (d) {
|
|
347
493
|
d.previousElementSibling !== s && s.after(d);
|
|
348
494
|
continue;
|
|
349
495
|
}
|
|
350
|
-
const
|
|
351
|
-
typeof this.config.detailHeight == "number" && (
|
|
496
|
+
const u = O(a, r, this.config.detailRenderer, o);
|
|
497
|
+
typeof this.config.detailHeight == "number" && (u.style.height = `${this.config.detailHeight}px`), s.after(u), this.detailElements.set(a, u), this.animateExpand(u);
|
|
352
498
|
}
|
|
353
499
|
}
|
|
354
500
|
/**
|
|
@@ -358,9 +504,9 @@ class C extends m {
|
|
|
358
504
|
getExtraHeight() {
|
|
359
505
|
let e = 0;
|
|
360
506
|
for (const t of this.expandedRows) {
|
|
361
|
-
const
|
|
362
|
-
if (
|
|
363
|
-
e +=
|
|
507
|
+
const n = this.detailElements.get(t);
|
|
508
|
+
if (n)
|
|
509
|
+
e += n.offsetHeight;
|
|
364
510
|
else {
|
|
365
511
|
const o = this.config?.detailHeight;
|
|
366
512
|
e += typeof o == "number" ? o : 150;
|
|
@@ -374,12 +520,12 @@ class C extends m {
|
|
|
374
520
|
*/
|
|
375
521
|
getExtraHeightBefore(e) {
|
|
376
522
|
let t = 0;
|
|
377
|
-
for (const
|
|
378
|
-
const o = this.rows.indexOf(
|
|
523
|
+
for (const n of this.expandedRows) {
|
|
524
|
+
const o = this.rows.indexOf(n);
|
|
379
525
|
if (o >= 0 && o < e) {
|
|
380
|
-
const
|
|
381
|
-
if (
|
|
382
|
-
t +=
|
|
526
|
+
const l = this.detailElements.get(n);
|
|
527
|
+
if (l)
|
|
528
|
+
t += l.offsetHeight;
|
|
383
529
|
else {
|
|
384
530
|
const r = this.config?.detailHeight;
|
|
385
531
|
t += typeof r == "number" ? r : 150;
|
|
@@ -392,20 +538,20 @@ class C extends m {
|
|
|
392
538
|
* Adjust the virtualization start index to keep expanded row visible while its detail is visible.
|
|
393
539
|
* This ensures the detail scrolls smoothly out of view instead of disappearing abruptly.
|
|
394
540
|
*/
|
|
395
|
-
adjustVirtualStart(e, t,
|
|
541
|
+
adjustVirtualStart(e, t, n) {
|
|
396
542
|
if (this.expandedRows.size === 0) return e;
|
|
397
543
|
const o = [];
|
|
398
544
|
for (const s of this.expandedRows) {
|
|
399
|
-
const
|
|
400
|
-
|
|
545
|
+
const a = this.rows.indexOf(s);
|
|
546
|
+
a >= 0 && o.push({ index: a, row: s });
|
|
401
547
|
}
|
|
402
|
-
o.sort((s,
|
|
403
|
-
let
|
|
404
|
-
for (const { index: s, row:
|
|
405
|
-
const d = s *
|
|
406
|
-
r +=
|
|
548
|
+
o.sort((s, a) => s.index - a.index);
|
|
549
|
+
let l = e, r = 0;
|
|
550
|
+
for (const { index: s, row: a } of o) {
|
|
551
|
+
const d = s * n + r, c = this.detailElements.get(a)?.offsetHeight ?? (typeof this.config?.detailHeight == "number" ? this.config.detailHeight : 150), h = d + n + c;
|
|
552
|
+
r += c, !(s >= e) && h > t && s < l && (l = s);
|
|
407
553
|
}
|
|
408
|
-
return
|
|
554
|
+
return l;
|
|
409
555
|
}
|
|
410
556
|
// #endregion
|
|
411
557
|
// #region Public API
|
|
@@ -415,7 +561,7 @@ class C extends m {
|
|
|
415
561
|
*/
|
|
416
562
|
expand(e) {
|
|
417
563
|
const t = this.rows[e];
|
|
418
|
-
t && (this.expandedRows =
|
|
564
|
+
t && (this.expandedRows = L(this.expandedRows, t), this.requestRender());
|
|
419
565
|
}
|
|
420
566
|
/**
|
|
421
567
|
* Collapse the detail row at the given index.
|
|
@@ -423,7 +569,7 @@ class C extends m {
|
|
|
423
569
|
*/
|
|
424
570
|
collapse(e) {
|
|
425
571
|
const t = this.rows[e];
|
|
426
|
-
t && (this.expandedRows =
|
|
572
|
+
t && (this.expandedRows = T(this.expandedRows, t), this.requestRender());
|
|
427
573
|
}
|
|
428
574
|
/**
|
|
429
575
|
* Toggle the detail row at the given index.
|
|
@@ -440,7 +586,7 @@ class C extends m {
|
|
|
440
586
|
*/
|
|
441
587
|
isExpanded(e) {
|
|
442
588
|
const t = this.rows[e];
|
|
443
|
-
return t ?
|
|
589
|
+
return t ? I(this.expandedRows, t) : !1;
|
|
444
590
|
}
|
|
445
591
|
/**
|
|
446
592
|
* Expand all detail rows.
|
|
@@ -463,8 +609,8 @@ class C extends m {
|
|
|
463
609
|
getExpandedRows() {
|
|
464
610
|
const e = [];
|
|
465
611
|
for (const t of this.expandedRows) {
|
|
466
|
-
const
|
|
467
|
-
|
|
612
|
+
const n = this.rows.indexOf(t);
|
|
613
|
+
n >= 0 && e.push(n);
|
|
468
614
|
}
|
|
469
615
|
return e;
|
|
470
616
|
}
|
|
@@ -477,12 +623,23 @@ class C extends m {
|
|
|
477
623
|
const t = this.rows[e];
|
|
478
624
|
return t ? this.detailElements.get(t) : void 0;
|
|
479
625
|
}
|
|
626
|
+
/**
|
|
627
|
+
* Re-parse light DOM to refresh the detail renderer.
|
|
628
|
+
* Call this after framework templates are registered (e.g., Angular ngAfterContentInit).
|
|
629
|
+
*
|
|
630
|
+
* This allows frameworks to register templates asynchronously and then
|
|
631
|
+
* update the plugin's detailRenderer.
|
|
632
|
+
*/
|
|
633
|
+
refreshDetailRenderer() {
|
|
634
|
+
const e = this.config.detailRenderer;
|
|
635
|
+
this.config = { ...this.config, detailRenderer: void 0 }, this.parseLightDomDetail(), !this.config.detailRenderer && e && (this.config = { ...this.config, detailRenderer: e });
|
|
636
|
+
}
|
|
480
637
|
// #endregion
|
|
481
638
|
// #region Styles
|
|
482
|
-
styles =
|
|
639
|
+
styles = N;
|
|
483
640
|
// #endregion
|
|
484
641
|
}
|
|
485
642
|
export {
|
|
486
|
-
|
|
643
|
+
q as MasterDetailPlugin
|
|
487
644
|
};
|
|
488
645
|
//# sourceMappingURL=index.js.map
|