@toolbox-web/grid 0.0.7 → 0.1.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/all.d.ts +151 -95
- package/all.js +1554 -1452
- package/all.js.map +1 -1
- package/custom-elements.json +89 -7
- package/index.d.ts +68 -23
- package/index.js +1066 -948
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +48 -49
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +6 -6
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +32 -34
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +7 -7
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +5 -38
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +4 -32
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +8 -45
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +6 -30
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +19 -42
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +5 -6
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +6 -80
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +673 -145
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +22 -51
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +53 -83
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +2 -2
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +6 -14
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +2 -3
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +13 -105
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/themes/dg-theme-bootstrap.css +73 -0
- package/themes/dg-theme-material.css +71 -0
- package/umd/grid.all.umd.js +40 -415
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +29 -60
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +4 -4
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +2 -2
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/export.umd.js +1 -1
- package/umd/plugins/export.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +2 -34
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -28
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -39
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -26
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -25
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -72
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -7
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -30
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -33
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/server-side.umd.js +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -10
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -93
- package/umd/plugins/visibility.umd.js.map +1 -1
package/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
const we = ":root{color-scheme:light dark}:host{--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #adacac);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: 2px 8px;--tbw-cell-padding: 2px 8px;--tbw-cell-padding-input: 2px 6px;--tbw-row-height: 28px;--tbw-header-height: 30px;--tbw-border-radius: 4px;--tbw-border-input: 1px solid var(--tbw-color-border-strong);--tbw-border-header: 1px solid var(--tbw-color-border-header);--tbw-row-divider: 1px solid var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline: 2px solid var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-resize-handle-width: 4px;--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-scrollbar-thumb: var(--tbw-color-border-strong);--tbw-scrollbar-track: var(--tbw-color-bg);--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-checkbox-size: 16px;--tbw-density-scale: 1}:host{position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none}:host,:host *{box-sizing:border-box}:host .header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}:host .header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}:host .header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start))}:host .header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30)}:host .header-row>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}:host .header-row>.cell>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .header-row>.cell>span[part~=sort-indicator]{flex-shrink:0}:host .header-row>.cell:last-child{border-right:0}:host .header-group-cell,:host .header-row>.cell.grouped.group-end{border-right:2px solid var(--tbw-color-border)}:host .tbw-grid-root{display:flex;flex-direction:column;height:100%}:host .rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}:host .rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}:host .rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}:host .rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip}:host .faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30)}:host .faux-vscroll-spacer{width:1px}:host .rows-viewport .rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}:host .data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style}:host .data-grid-row:has(.editing){background:var(--tbw-editing-bg)}:host .selecting .data-grid-row>.cell{user-select:none}:host .data-grid-row>.cell:focus-visible{outline:none}:host .data-grid-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}:host .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .data-grid-row>.cell:last-child{border-right:0}:host .data-grid-row>.cell[data-type=boolean]{justify-content:center}:host .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size)}:host .data-grid-row>.cell.editing{overflow:hidden;padding:0}:host .data-grid-row>.cell.editing input:not([type=checkbox]),:host .data-grid-row>.cell.editing select,:host .data-grid-row>.cell.editing textarea{width:100%;height:100%;max-width:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}:host .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}:host .data-grid-row:hover{background:var(--tbw-color-row-hover)}:host .sortable{cursor:pointer;user-select:none}:host .resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius)}:host .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}:host .cell-focus,:host .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-row-alt);font-weight:500;border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height)}:host .group-row .cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px)}:host .group-row .group-toggle{background:none;border:0;cursor:pointer;padding:0 4px 0 0;font:inherit}:host .group-row .group-count{margin-left:4px;opacity:.7}:host .sticky-left,:host .sticky-right{position:sticky;z-index:25}:host .header-row>.cell.sticky-left,:host .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}:host .data-grid-row>.cell.sticky-left,:host .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}:host .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}:host .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}.grid-container{position:relative;width:100%;height:100%}.grid-placeholder{padding:2rem;text-align:center;color:var(--tbw-color-fg);opacity:.6}:host{--tbw-shell-header-height: 44px;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: 14px;--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 280px;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 40px;--tbw-tool-panel-transition: .2s ease-out;--tbw-toolbar-button-size: 32px;--tbw-toolbar-button-gap: 4px}:host .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}:host .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}:host .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}:host .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}:host .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}:host .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}:host .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}:host .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}:host .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}:host .tbw-shell-body{display:flex;flex:1;min-height:0;overflow:visible}:host .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}:host .tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden}:host .tbw-tool-panel{width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;flex-shrink:0}:host .tbw-tool-panel[data-position=left]{border-left:none;border-right:1px solid var(--tbw-tool-panel-border);order:-1}:host .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}:host .tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}:host .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}:host .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}:host .tbw-tool-panel-content{flex:1;overflow:auto;padding:12px}:host .tbw-quick-filter-input{flex:1;max-width:300px;height:28px;padding:0 8px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:13px}:host .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}:host .tbw-selection-summary{font-size:13px;color:var(--tbw-color-fg-muted);white-space:nowrap}";
|
|
2
|
-
function
|
|
1
|
+
const me = ":root{color-scheme:light dark}:host{--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #adacac);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: 2px 8px;--tbw-cell-padding: 2px 8px;--tbw-cell-padding-input: 2px 6px;--tbw-row-height: 28px;--tbw-header-height: 30px;--tbw-border-radius: 4px;--tbw-border-input: 1px solid var(--tbw-color-border-strong);--tbw-border-header: 1px solid var(--tbw-color-border-header);--tbw-row-divider: 1px solid var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline: 2px solid var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-resize-handle-width: 4px;--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-scrollbar-thumb: var(--tbw-color-border-strong);--tbw-scrollbar-track: var(--tbw-color-bg);--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-checkbox-size: 16px;--tbw-density-scale: 1}:host{position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none}:host,:host *{box-sizing:border-box}:host .header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}:host .header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}:host .header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start))}:host .header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30)}:host .header-row>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}:host .header-row>.cell>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .header-row>.cell>span[part~=sort-indicator]{flex-shrink:0}:host .header-row>.cell:last-child{border-right:0}:host .header-group-cell,:host .header-row>.cell.grouped.group-end{border-right:2px solid var(--tbw-color-border)}:host .tbw-grid-root{display:flex;flex-direction:column;height:100%}:host .rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}:host .rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}:host .rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}:host .rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip}:host .faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30)}:host .faux-vscroll-spacer{width:1px}:host .rows-viewport .rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}:host .data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style}:host .data-grid-row:has(.editing){background:var(--tbw-editing-bg)}:host .selecting .data-grid-row>.cell{user-select:none}:host .data-grid-row>.cell:focus-visible{outline:none}:host .data-grid-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}:host .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .data-grid-row>.cell:last-child{border-right:0}:host .data-grid-row>.cell[data-type=boolean]{justify-content:center}:host .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size)}:host .data-grid-row>.cell.editing{overflow:hidden;padding:0}:host .data-grid-row>.cell.editing input:not([type=checkbox]),:host .data-grid-row>.cell.editing select,:host .data-grid-row>.cell.editing textarea{width:100%;height:100%;max-width:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}:host .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}:host .data-grid-row:hover{background:var(--tbw-color-row-hover)}:host .sortable{cursor:pointer;user-select:none}:host .resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius)}:host .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}:host .cell-focus,:host .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-row-alt);font-weight:500;border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height)}:host .group-row .cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px)}:host .group-row .group-toggle{background:none;border:0;cursor:pointer;padding:0 4px 0 0;font:inherit}:host .group-row .group-count{margin-left:4px;opacity:.7}:host .sticky-left,:host .sticky-right{position:sticky;z-index:25}:host .header-row>.cell.sticky-left,:host .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}:host .data-grid-row>.cell.sticky-left,:host .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}:host .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}:host .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}.grid-container{position:relative;width:100%;height:100%}.grid-placeholder{padding:2rem;text-align:center;color:var(--tbw-color-fg);opacity:.6}:host{--tbw-shell-header-height: 44px;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: 14px;--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 280px;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 40px;--tbw-tool-panel-transition: .2s ease-out;--tbw-toolbar-button-size: 32px;--tbw-toolbar-button-gap: 4px}:host .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}:host .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}:host .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}:host .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}:host .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}:host .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}:host .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}:host .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}:host .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}:host .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}:host .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}:host .tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden}:host .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:30;box-shadow:-2px 0 8px var(--tbw-color-shadow)}:host .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}:host .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}:host .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background .15s ease}:host .tbw-tool-panel-resize[data-handle-position=left]{left:0}:host .tbw-tool-panel-resize[data-handle-position=right]{right:0}:host .tbw-tool-panel-resize:hover,:host .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}:host .tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}:host .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}:host .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}:host .tbw-tool-panel-content{flex:1;overflow:auto}:host .tbw-accordion{display:flex;flex-direction:column;gap:0}:host .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}:host .tbw-accordion-section:last-child{border-bottom:none}:host .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:left;cursor:pointer;user-select:none}:host .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}:host .tbw-accordion-section.single .tbw-accordion-header{cursor:default}:host .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}:host .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}:host .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}:host .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}:host .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .tbw-accordion-content{display:none}:host .tbw-accordion-section.expanded .tbw-accordion-content{display:block}:host .tbw-quick-filter-input{flex:1;max-width:300px;height:28px;padding:0 8px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:13px}:host .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}:host .tbw-selection-summary{font-size:13px;color:var(--tbw-color-fg-muted);white-space:nowrap}";
|
|
2
|
+
function ve(o) {
|
|
3
3
|
const e = /* @__PURE__ */ new Map();
|
|
4
4
|
return o.sortState && e.set(o.sortState.field, {
|
|
5
5
|
direction: o.sortState.direction === 1 ? "asc" : "desc",
|
|
6
6
|
priority: 0
|
|
7
7
|
}), e;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
const t = o._columns, n =
|
|
9
|
+
function he(o, e) {
|
|
10
|
+
const t = o._columns, n = ve(o);
|
|
11
11
|
return {
|
|
12
|
-
columns: t.map((
|
|
12
|
+
columns: t.map((s, i) => {
|
|
13
13
|
const r = {
|
|
14
|
-
field:
|
|
15
|
-
order:
|
|
14
|
+
field: s.field,
|
|
15
|
+
order: i,
|
|
16
16
|
visible: !0
|
|
17
17
|
// If it's in _columns, it's visible (hidden columns are filtered out)
|
|
18
|
-
}, a =
|
|
19
|
-
a.__renderedWidth !== void 0 ? r.width = a.__renderedWidth :
|
|
20
|
-
const l = n.get(
|
|
18
|
+
}, a = s;
|
|
19
|
+
a.__renderedWidth !== void 0 ? r.width = a.__renderedWidth : s.width !== void 0 && (r.width = typeof s.width == "string" ? parseFloat(s.width) : s.width);
|
|
20
|
+
const l = n.get(s.field);
|
|
21
21
|
l && (r.sort = l);
|
|
22
|
-
for (const
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
25
|
-
|
|
22
|
+
for (const d of e)
|
|
23
|
+
if (d.getColumnState) {
|
|
24
|
+
const u = d.getColumnState(s.field);
|
|
25
|
+
u && Object.assign(r, u);
|
|
26
26
|
}
|
|
27
27
|
return r;
|
|
28
28
|
})
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function ye(o, e, t, n) {
|
|
32
32
|
if (!e.columns || e.columns.length === 0) return;
|
|
33
|
-
const
|
|
34
|
-
const l =
|
|
33
|
+
const s = new Map(e.columns.map((a) => [a.field, a])), i = t.map((a) => {
|
|
34
|
+
const l = s.get(a.field);
|
|
35
35
|
if (!l) return a;
|
|
36
|
-
const
|
|
37
|
-
return l.width !== void 0 && (
|
|
36
|
+
const d = { ...a };
|
|
37
|
+
return l.width !== void 0 && (d.width = l.width, d.__renderedWidth = l.width), l.visible !== void 0 && (d.hidden = !l.visible), d;
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
-
}), o._columns =
|
|
39
|
+
i.sort((a, l) => {
|
|
40
|
+
const d = s.get(a.field)?.order ?? 1 / 0, u = s.get(l.field)?.order ?? 1 / 0;
|
|
41
|
+
return d - u;
|
|
42
|
+
}), o._columns = i;
|
|
43
43
|
const r = e.columns.filter((a) => a.sort !== void 0).sort((a, l) => (a.sort?.priority ?? 0) - (l.sort?.priority ?? 0));
|
|
44
44
|
if (r.length > 0) {
|
|
45
45
|
const a = r[0];
|
|
@@ -54,47 +54,48 @@ function me(o, e, t, n) {
|
|
|
54
54
|
for (const l of e.columns)
|
|
55
55
|
a.applyColumnState(l.field, l);
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function Ce(o, e, t) {
|
|
58
58
|
let n = null;
|
|
59
59
|
return () => {
|
|
60
60
|
n !== null && clearTimeout(n), n = setTimeout(() => {
|
|
61
61
|
n = null;
|
|
62
|
-
const
|
|
63
|
-
t(
|
|
62
|
+
const s = he(o, e());
|
|
63
|
+
t(s);
|
|
64
64
|
}, 100);
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
const
|
|
67
|
+
const O = {
|
|
68
68
|
STRETCH: "stretch",
|
|
69
69
|
FIXED: "fixed"
|
|
70
|
-
},
|
|
70
|
+
}, S = {
|
|
71
71
|
expand: "▶",
|
|
72
72
|
collapse: "▼",
|
|
73
73
|
sortAsc: "▲",
|
|
74
74
|
sortDesc: "▼",
|
|
75
75
|
sortNone: "⇅",
|
|
76
76
|
submenuArrow: "▶",
|
|
77
|
-
dragHandle: "⋮⋮"
|
|
77
|
+
dragHandle: "⋮⋮",
|
|
78
|
+
toolPanel: "☰"
|
|
78
79
|
};
|
|
79
|
-
function
|
|
80
|
+
function Ee(o) {
|
|
80
81
|
return o == null ? "string" : typeof o == "number" ? "number" : typeof o == "boolean" ? "boolean" : o instanceof Date || typeof o == "string" && /\d{4}-\d{2}-\d{2}/.test(o) && !isNaN(Date.parse(o)) ? "date" : "string";
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function ue(o, e) {
|
|
83
84
|
if (e && e.length) {
|
|
84
|
-
const
|
|
85
|
+
const i = {};
|
|
85
86
|
return e.forEach((r) => {
|
|
86
|
-
r.type && (
|
|
87
|
-
}), { columns: e, typeMap:
|
|
88
|
-
}
|
|
89
|
-
const t = o[0] || {}, n = Object.keys(t).map((
|
|
90
|
-
const r = t[
|
|
91
|
-
return { field:
|
|
92
|
-
}),
|
|
93
|
-
return n.forEach((
|
|
94
|
-
i
|
|
95
|
-
}), { columns: n, typeMap:
|
|
96
|
-
}
|
|
97
|
-
const
|
|
87
|
+
r.type && (i[r.field] = r.type);
|
|
88
|
+
}), { columns: e, typeMap: i };
|
|
89
|
+
}
|
|
90
|
+
const t = o[0] || {}, n = Object.keys(t).map((i) => {
|
|
91
|
+
const r = t[i], a = Ee(r);
|
|
92
|
+
return { field: i, header: i.charAt(0).toUpperCase() + i.slice(1), type: a };
|
|
93
|
+
}), s = {};
|
|
94
|
+
return n.forEach((i) => {
|
|
95
|
+
s[i.field] = i.type || "string";
|
|
96
|
+
}), { columns: n, typeMap: s };
|
|
97
|
+
}
|
|
98
|
+
const Re = /{{\s*([^}]+)\s*}}/g, x = "__DG_EMPTY__", _e = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, xe = /__(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/, Se = /* @__PURE__ */ new Set([
|
|
98
99
|
"script",
|
|
99
100
|
"iframe",
|
|
100
101
|
"object",
|
|
@@ -119,76 +120,76 @@ const Ee = /{{\s*([^}]+)\s*}}/g, A = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>
|
|
|
119
120
|
"plaintext",
|
|
120
121
|
"xmp",
|
|
121
122
|
"listing"
|
|
122
|
-
]),
|
|
123
|
-
function
|
|
123
|
+
]), j = /^on\w+$/i, Ae = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), Te = /^\s*(javascript|vbscript|data|blob):/i;
|
|
124
|
+
function q(o) {
|
|
124
125
|
if (!o || typeof o != "string") return "";
|
|
125
126
|
if (o.indexOf("<") === -1) return o;
|
|
126
127
|
const e = document.createElement("template");
|
|
127
|
-
return e.innerHTML = o,
|
|
128
|
+
return e.innerHTML = o, Le(e.content), e.innerHTML;
|
|
128
129
|
}
|
|
129
|
-
function
|
|
130
|
+
function Le(o) {
|
|
130
131
|
const e = [], t = o.querySelectorAll("*");
|
|
131
132
|
for (const n of t) {
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
133
|
+
const s = n.tagName.toLowerCase();
|
|
134
|
+
if (Se.has(s)) {
|
|
134
135
|
e.push(n);
|
|
135
136
|
continue;
|
|
136
137
|
}
|
|
137
|
-
if ((
|
|
138
|
-
(a) =>
|
|
138
|
+
if ((s === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
|
|
139
|
+
(a) => j.test(a.name) || a.name === "href" || a.name === "xlink:href"
|
|
139
140
|
)) {
|
|
140
141
|
e.push(n);
|
|
141
142
|
continue;
|
|
142
143
|
}
|
|
143
|
-
const
|
|
144
|
+
const i = [];
|
|
144
145
|
for (const r of n.attributes) {
|
|
145
146
|
const a = r.name.toLowerCase();
|
|
146
|
-
if (
|
|
147
|
-
|
|
147
|
+
if (j.test(a)) {
|
|
148
|
+
i.push(r.name);
|
|
148
149
|
continue;
|
|
149
150
|
}
|
|
150
|
-
if (Ae.has(a) &&
|
|
151
|
-
|
|
151
|
+
if (Ae.has(a) && Te.test(r.value)) {
|
|
152
|
+
i.push(r.name);
|
|
152
153
|
continue;
|
|
153
154
|
}
|
|
154
155
|
if (a === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(r.value)) {
|
|
155
|
-
|
|
156
|
+
i.push(r.name);
|
|
156
157
|
continue;
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
|
-
|
|
160
|
+
i.forEach((r) => n.removeAttribute(r));
|
|
160
161
|
}
|
|
161
162
|
e.forEach((n) => n.remove());
|
|
162
163
|
}
|
|
163
|
-
function
|
|
164
|
+
function fe(o, e) {
|
|
164
165
|
if (!o || o.indexOf("{{") === -1) return o;
|
|
165
|
-
const t = [], n = o.replace(
|
|
166
|
-
const
|
|
167
|
-
return t.push({ expr: l.trim(), result:
|
|
168
|
-
}),
|
|
169
|
-
return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) ||
|
|
170
|
-
}
|
|
171
|
-
function
|
|
172
|
-
if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return
|
|
173
|
-
if (o === "value") return e.value == null ?
|
|
166
|
+
const t = [], n = o.replace(Re, (a, l) => {
|
|
167
|
+
const d = ke(l, e);
|
|
168
|
+
return t.push({ expr: l.trim(), result: d }), d;
|
|
169
|
+
}), s = Pe(n), i = t.length && t.every((a) => a.result === "" || a.result === x);
|
|
170
|
+
return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) || i ? "" : s;
|
|
171
|
+
}
|
|
172
|
+
function ke(o, e) {
|
|
173
|
+
if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return x;
|
|
174
|
+
if (o === "value") return e.value == null ? x : String(e.value);
|
|
174
175
|
if (o.startsWith("row.") && !/[()?]/.test(o) && !o.includes(":")) {
|
|
175
|
-
const n = o.slice(4),
|
|
176
|
-
return
|
|
176
|
+
const n = o.slice(4), s = e.row ? e.row[n] : void 0;
|
|
177
|
+
return s == null ? x : String(s);
|
|
177
178
|
}
|
|
178
|
-
if (o.length > 80 || !
|
|
179
|
+
if (o.length > 80 || !_e.test(o) || xe.test(o)) return x;
|
|
179
180
|
const t = o.match(/\./g);
|
|
180
|
-
if (t && t.length > 1) return
|
|
181
|
+
if (t && t.length > 1) return x;
|
|
181
182
|
try {
|
|
182
|
-
const
|
|
183
|
-
return /Reflect|Proxy|ownKeys/.test(
|
|
183
|
+
const s = new Function("value", "row", `return (${o});`)(e.value, e.row), i = s == null ? "" : String(s);
|
|
184
|
+
return /Reflect|Proxy|ownKeys/.test(i) ? x : i || x;
|
|
184
185
|
} catch {
|
|
185
|
-
return
|
|
186
|
+
return x;
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
|
-
function
|
|
189
|
-
return o && o.replace(new RegExp(
|
|
189
|
+
function Pe(o) {
|
|
190
|
+
return o && o.replace(new RegExp(x, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
|
|
190
191
|
}
|
|
191
|
-
function
|
|
192
|
+
function Me(o) {
|
|
192
193
|
if (/Reflect|Proxy|ownKeys/.test(o.textContent || "")) {
|
|
193
194
|
if (Array.from(o.childNodes).forEach((e) => {
|
|
194
195
|
e.nodeType === Node.TEXT_NODE && /Reflect|Proxy|ownKeys/.test(e.textContent || "") && (e.textContent = "");
|
|
@@ -200,40 +201,40 @@ function ke(o) {
|
|
|
200
201
|
(o.textContent || "").trim().length === 0 && (o.textContent = "");
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
|
-
function
|
|
204
|
-
const e = /Reflect\.|\bProxy\b|ownKeys\(/.test(o), t = (n) => e ? "" :
|
|
204
|
+
function Y(o) {
|
|
205
|
+
const e = /Reflect\.|\bProxy\b|ownKeys\(/.test(o), t = (n) => e ? "" : fe(o, n);
|
|
205
206
|
return t.__blocked = e, t;
|
|
206
207
|
}
|
|
207
|
-
function
|
|
208
|
+
function Oe(o) {
|
|
208
209
|
return Array.from(o.querySelectorAll("tbw-grid-column")).map((t) => {
|
|
209
210
|
const n = t.getAttribute("field") || "";
|
|
210
211
|
if (!n) return null;
|
|
211
|
-
const
|
|
212
|
-
t.hasAttribute("resizable") && (
|
|
212
|
+
const s = t.getAttribute("type") || void 0, r = s && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(s) ? s : void 0, a = t.getAttribute("header") || void 0, l = t.hasAttribute("sortable"), d = t.hasAttribute("editable"), u = { field: n, type: r, header: a, sortable: l, editable: d };
|
|
213
|
+
t.hasAttribute("resizable") && (u.resizable = !0), t.hasAttribute("sizable") && (u.resizable = !0);
|
|
213
214
|
const g = t.getAttribute("options");
|
|
214
|
-
g && (
|
|
215
|
-
const [
|
|
216
|
-
return { value:
|
|
215
|
+
g && (u.options = g.split(",").map((p) => {
|
|
216
|
+
const [w, m] = p.includes(":") ? p.split(":") : [p.trim(), p.trim()];
|
|
217
|
+
return { value: w.trim(), label: m?.trim() || w.trim() };
|
|
217
218
|
}));
|
|
218
|
-
const h = t.querySelector("tbw-grid-column-view"), c = t.querySelector("tbw-grid-column-editor"),
|
|
219
|
-
return h && (
|
|
219
|
+
const h = t.querySelector("tbw-grid-column-view"), c = t.querySelector("tbw-grid-column-editor"), f = t.querySelector("tbw-grid-column-header");
|
|
220
|
+
return h && (u.__viewTemplate = h), c && (u.__editorTemplate = c), f && (u.__headerTemplate = f), u;
|
|
220
221
|
}).filter((t) => !!t);
|
|
221
222
|
}
|
|
222
|
-
function
|
|
223
|
+
function He(o, e) {
|
|
223
224
|
if ((!o || !o.length) && (!e || !e.length)) return [];
|
|
224
225
|
if (!o || !o.length) return e || [];
|
|
225
226
|
if (!e || !e.length) return o;
|
|
226
227
|
const t = {};
|
|
227
|
-
e.forEach((
|
|
228
|
-
const n = o.map((
|
|
229
|
-
const
|
|
230
|
-
if (!
|
|
231
|
-
const r = { ...
|
|
232
|
-
return
|
|
228
|
+
e.forEach((s) => t[s.field] = s);
|
|
229
|
+
const n = o.map((s) => {
|
|
230
|
+
const i = t[s.field];
|
|
231
|
+
if (!i) return s;
|
|
232
|
+
const r = { ...s };
|
|
233
|
+
return i.header && !r.header && (r.header = i.header), i.type && !r.type && (r.type = i.type), r.sortable = s.sortable || i.sortable, (s.resizable === !0 || i.resizable === !0) && (r.resizable = !0), r.editable = s.editable || i.editable, i.__viewTemplate && (r.__viewTemplate = i.__viewTemplate), i.__editorTemplate && (r.__editorTemplate = i.__editorTemplate), i.__headerTemplate && (r.__headerTemplate = i.__headerTemplate), delete t[s.field], r;
|
|
233
234
|
});
|
|
234
|
-
return Object.keys(t).forEach((
|
|
235
|
+
return Object.keys(t).forEach((s) => n.push(t[s])), n;
|
|
235
236
|
}
|
|
236
|
-
function
|
|
237
|
+
function W(o, e) {
|
|
237
238
|
try {
|
|
238
239
|
o.part?.add?.(e);
|
|
239
240
|
} catch {
|
|
@@ -241,45 +242,45 @@ function B(o, e) {
|
|
|
241
242
|
const t = o.getAttribute("part");
|
|
242
243
|
t ? t.split(/\s+/).includes(e) || o.setAttribute("part", t + " " + e) : o.setAttribute("part", e);
|
|
243
244
|
}
|
|
244
|
-
function
|
|
245
|
+
function ze(o) {
|
|
245
246
|
o.__lightDomColumnsCache || (o.__originalColumnNodes = Array.from(
|
|
246
247
|
o.querySelectorAll("tbw-grid-column")
|
|
247
|
-
), o.__lightDomColumnsCache = o.__originalColumnNodes.length ?
|
|
248
|
-
const e = o.__lightDomColumnsCache, t =
|
|
249
|
-
t.forEach((
|
|
250
|
-
|
|
248
|
+
), o.__lightDomColumnsCache = o.__originalColumnNodes.length ? Oe(o) : []);
|
|
249
|
+
const e = o.__lightDomColumnsCache, t = He(o._columns, e);
|
|
250
|
+
t.forEach((s) => {
|
|
251
|
+
s.__viewTemplate && !s.__compiledView && (s.__compiledView = Y(s.__viewTemplate.innerHTML)), s.__editorTemplate && !s.__compiledEditor && (s.__compiledEditor = Y(s.__editorTemplate.innerHTML));
|
|
251
252
|
});
|
|
252
|
-
const { columns: n } =
|
|
253
|
+
const { columns: n } = ue(o._rows, t);
|
|
253
254
|
o._columns = n;
|
|
254
255
|
}
|
|
255
|
-
function
|
|
256
|
-
const e = o.effectiveConfig?.fitMode || o.fitMode ||
|
|
257
|
-
if (e !==
|
|
256
|
+
function De(o) {
|
|
257
|
+
const e = o.effectiveConfig?.fitMode || o.fitMode || O.STRETCH;
|
|
258
|
+
if (e !== O.STRETCH && e !== O.FIXED || o.__didInitialAutoSize || !o.isConnected) return;
|
|
258
259
|
const t = o.headerRowEl?.children || [];
|
|
259
260
|
if (!t.length) return;
|
|
260
261
|
let n = !1;
|
|
261
|
-
o.visibleColumns.forEach((
|
|
262
|
-
if (
|
|
263
|
-
const r = t[
|
|
262
|
+
o.visibleColumns.forEach((s, i) => {
|
|
263
|
+
if (s.width) return;
|
|
264
|
+
const r = t[i];
|
|
264
265
|
let a = r ? r.scrollWidth : 0;
|
|
265
266
|
for (const l of o.rowPool) {
|
|
266
|
-
const
|
|
267
|
-
if (
|
|
268
|
-
const
|
|
269
|
-
|
|
267
|
+
const d = l.children[i];
|
|
268
|
+
if (d) {
|
|
269
|
+
const u = d.scrollWidth;
|
|
270
|
+
u > a && (a = u);
|
|
270
271
|
}
|
|
271
272
|
}
|
|
272
|
-
a > 0 && (
|
|
273
|
-
}), n &&
|
|
273
|
+
a > 0 && (s.width = a + 2, s.__autoSized = !0, n = !0);
|
|
274
|
+
}), n && pe(o), o.__didInitialAutoSize = !0;
|
|
274
275
|
}
|
|
275
|
-
function
|
|
276
|
-
(o.effectiveConfig?.fitMode || o.fitMode ||
|
|
276
|
+
function pe(o) {
|
|
277
|
+
(o.effectiveConfig?.fitMode || o.fitMode || O.STRETCH) === O.STRETCH ? o.gridTemplate = o.visibleColumns.map((t) => {
|
|
277
278
|
if (t.width) return `${t.width}px`;
|
|
278
279
|
const n = t.minWidth;
|
|
279
280
|
return n != null ? `minmax(${n}px, 1fr)` : "1fr";
|
|
280
281
|
}).join(" ").trim() : o.gridTemplate = o.visibleColumns.map((t) => t.width ? `${t.width}px` : "max-content").join(" "), o.style.setProperty("--tbw-column-template", o.gridTemplate);
|
|
281
282
|
}
|
|
282
|
-
function
|
|
283
|
+
function Ne(o) {
|
|
283
284
|
switch (o.type) {
|
|
284
285
|
case "number":
|
|
285
286
|
return (e) => {
|
|
@@ -304,21 +305,21 @@ function De(o) {
|
|
|
304
305
|
case "typeahead":
|
|
305
306
|
return (e) => {
|
|
306
307
|
const t = document.createElement("select");
|
|
307
|
-
e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((
|
|
308
|
+
e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((i) => {
|
|
308
309
|
const r = document.createElement("option");
|
|
309
|
-
r.value = String(
|
|
310
|
+
r.value = String(i.value), r.textContent = i.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(i.value) || !e.column.multi && e.value === i.value) && (r.selected = !0), t.appendChild(r);
|
|
310
311
|
});
|
|
311
|
-
const
|
|
312
|
+
const s = () => {
|
|
312
313
|
if (e.column.multi) {
|
|
313
|
-
const
|
|
314
|
+
const i = [];
|
|
314
315
|
Array.from(t.selectedOptions).forEach((r) => {
|
|
315
|
-
|
|
316
|
-
}), e.commit(
|
|
316
|
+
i.push(r.value);
|
|
317
|
+
}), e.commit(i);
|
|
317
318
|
} else
|
|
318
319
|
e.commit(t.value);
|
|
319
320
|
};
|
|
320
|
-
return t.addEventListener("change",
|
|
321
|
-
|
|
321
|
+
return t.addEventListener("change", s), t.addEventListener("blur", s), t.addEventListener("keydown", (i) => {
|
|
322
|
+
i.key === "Escape" && e.cancel();
|
|
322
323
|
}), t.focus(), t;
|
|
323
324
|
};
|
|
324
325
|
default:
|
|
@@ -330,25 +331,25 @@ function De(o) {
|
|
|
330
331
|
};
|
|
331
332
|
}
|
|
332
333
|
}
|
|
333
|
-
function
|
|
334
|
+
function qe(o, e) {
|
|
334
335
|
if (o.dispatchKeyDown?.(e))
|
|
335
336
|
return;
|
|
336
|
-
const t = o._rows.length - 1, n = o.visibleColumns.length - 1,
|
|
337
|
-
if (!
|
|
338
|
-
const g =
|
|
339
|
-
return !!(g === "INPUT" || g === "SELECT" || g === "TEXTAREA" ||
|
|
337
|
+
const t = o._rows.length - 1, n = o.visibleColumns.length - 1, s = o.activeEditRows !== void 0 && o.activeEditRows !== -1, r = o.visibleColumns[o.focusCol]?.type, a = e.composedPath ? e.composedPath() : [], l = a && a.length ? a[0] : e.target, d = (u) => {
|
|
338
|
+
if (!u) return !1;
|
|
339
|
+
const g = u.tagName;
|
|
340
|
+
return !!(g === "INPUT" || g === "SELECT" || g === "TEXTAREA" || u.isContentEditable);
|
|
340
341
|
};
|
|
341
|
-
if (!(
|
|
342
|
+
if (!(d(l) && (e.key === "Home" || e.key === "End")) && !(d(l) && (e.key === "ArrowUp" || e.key === "ArrowDown") && l.tagName === "INPUT" && l.type === "number") && !(s && (r === "select" || r === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
|
|
342
343
|
switch (e.key) {
|
|
343
344
|
case "Tab": {
|
|
344
345
|
e.preventDefault(), !e.shiftKey ? o.focusCol < n ? o.focusCol += 1 : (typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow < t && (o.focusRow += 1, o.focusCol = 0)) : o.focusCol > 0 ? o.focusCol -= 1 : o.focusRow > 0 && (typeof o.commitActiveRowEdit == "function" && o.activeEditRows === o.focusRow && o.commitActiveRowEdit(), o.focusRow -= 1, o.focusCol = n), H(o);
|
|
345
346
|
return;
|
|
346
347
|
}
|
|
347
348
|
case "ArrowDown":
|
|
348
|
-
|
|
349
|
+
s && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.min(t, o.focusRow + 1), e.preventDefault();
|
|
349
350
|
break;
|
|
350
351
|
case "ArrowUp":
|
|
351
|
-
|
|
352
|
+
s && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.max(0, o.focusRow - 1), e.preventDefault();
|
|
352
353
|
break;
|
|
353
354
|
case "ArrowRight":
|
|
354
355
|
o.focusCol = Math.min(n, o.focusCol + 1), e.preventDefault();
|
|
@@ -380,18 +381,18 @@ function ze(o, e) {
|
|
|
380
381
|
}
|
|
381
382
|
function H(o) {
|
|
382
383
|
if (o.virtualization?.enabled) {
|
|
383
|
-
const { rowHeight:
|
|
384
|
-
r <
|
|
384
|
+
const { rowHeight: s } = o.virtualization, i = o, r = o.focusRow * s;
|
|
385
|
+
r < i.scrollTop ? i.scrollTop = r : r + s > i.scrollTop + i.clientHeight && (i.scrollTop = r - i.clientHeight + s);
|
|
385
386
|
}
|
|
386
|
-
o.refreshVirtualWindow(!1), Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach((
|
|
387
|
-
|
|
387
|
+
o.refreshVirtualWindow(!1), Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach((s) => s.classList.remove("cell-focus")), Array.from(o.bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((s) => {
|
|
388
|
+
s.setAttribute("aria-selected", "false");
|
|
388
389
|
});
|
|
389
390
|
const e = o.focusRow, t = o.virtualization.start ?? 0, n = o.virtualization.end ?? o._rows.length;
|
|
390
391
|
if (e >= t && e < n) {
|
|
391
|
-
const
|
|
392
|
-
if (
|
|
393
|
-
if (
|
|
394
|
-
const r =
|
|
392
|
+
const i = o.bodyEl.querySelectorAll(".data-grid-row")[e - t]?.children[o.focusCol];
|
|
393
|
+
if (i) {
|
|
394
|
+
if (i.classList.add("cell-focus"), i.setAttribute("aria-selected", "true"), o.activeEditRows !== void 0 && o.activeEditRows !== -1 && i.classList.contains("editing")) {
|
|
395
|
+
const r = i.querySelector(
|
|
395
396
|
'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
|
|
396
397
|
);
|
|
397
398
|
if (r && document.activeElement !== r)
|
|
@@ -399,63 +400,63 @@ function H(o) {
|
|
|
399
400
|
r.focus();
|
|
400
401
|
} catch {
|
|
401
402
|
}
|
|
402
|
-
} else if (!
|
|
403
|
-
|
|
403
|
+
} else if (!i.contains(document.activeElement)) {
|
|
404
|
+
i.hasAttribute("tabindex") || i.setAttribute("tabindex", "-1");
|
|
404
405
|
try {
|
|
405
|
-
|
|
406
|
+
i.focus({ preventScroll: !0 });
|
|
406
407
|
} catch {
|
|
407
408
|
}
|
|
408
409
|
}
|
|
409
410
|
}
|
|
410
411
|
}
|
|
411
412
|
}
|
|
412
|
-
const
|
|
413
|
-
function
|
|
414
|
-
o[
|
|
413
|
+
const Ie = "__cellDisplayCache", $e = "__cellCacheEpoch";
|
|
414
|
+
function Z(o) {
|
|
415
|
+
o[Ie] = void 0, o[$e] = void 0, o.__hasSpecialColumns = void 0;
|
|
415
416
|
}
|
|
416
|
-
function
|
|
417
|
-
const
|
|
418
|
-
let
|
|
419
|
-
for (
|
|
417
|
+
function Be(o, e, t, n, s) {
|
|
418
|
+
const i = Math.max(0, t - e), r = o.bodyEl, a = o.visibleColumns, l = a.length;
|
|
419
|
+
let d = o.__cachedHeaderRowCount;
|
|
420
|
+
for (d === void 0 && (d = o.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, o.__cachedHeaderRowCount = d); o.rowPool.length < i; ) {
|
|
420
421
|
const g = document.createElement("div");
|
|
421
|
-
g.className = "data-grid-row", g.setAttribute("role", "row"), g.addEventListener("click", (h) =>
|
|
422
|
+
g.className = "data-grid-row", g.setAttribute("role", "row"), g.addEventListener("click", (h) => Q(o, h, g, !1)), g.addEventListener("dblclick", (h) => Q(o, h, g, !0)), o.rowPool.push(g);
|
|
422
423
|
}
|
|
423
|
-
if (o.rowPool.length >
|
|
424
|
-
for (let g =
|
|
424
|
+
if (o.rowPool.length > i) {
|
|
425
|
+
for (let g = i; g < o.rowPool.length; g++) {
|
|
425
426
|
const h = o.rowPool[g];
|
|
426
427
|
h.parentNode === r && h.remove();
|
|
427
428
|
}
|
|
428
|
-
o.rowPool.length =
|
|
429
|
+
o.rowPool.length = i;
|
|
429
430
|
}
|
|
430
|
-
const
|
|
431
|
-
for (let g = 0; g <
|
|
432
|
-
const h = e + g, c = o._rows[h],
|
|
433
|
-
if (
|
|
434
|
-
|
|
431
|
+
const u = s && o.__hasRenderRowPlugins !== !1;
|
|
432
|
+
for (let g = 0; g < i; g++) {
|
|
433
|
+
const h = e + g, c = o._rows[h], f = o.rowPool[g];
|
|
434
|
+
if (f.setAttribute("aria-rowindex", String(h + d + 1)), u && s(c, f, h)) {
|
|
435
|
+
f.__epoch = n, f.__rowDataRef = c, f.parentNode !== r && r.appendChild(f);
|
|
435
436
|
continue;
|
|
436
437
|
}
|
|
437
|
-
const
|
|
438
|
+
const p = f.__epoch, w = f.__rowDataRef, m = f.children.length, R = p === n && m === l, C = w !== c;
|
|
438
439
|
let _ = !1;
|
|
439
|
-
if (R &&
|
|
440
|
-
for (let
|
|
441
|
-
if (a[
|
|
440
|
+
if (R && C) {
|
|
441
|
+
for (let A = 0; A < l; A++)
|
|
442
|
+
if (a[A].externalView && !f.querySelector(`.cell[data-col="${A}"] [data-external-view]`)) {
|
|
442
443
|
_ = !0;
|
|
443
444
|
break;
|
|
444
445
|
}
|
|
445
446
|
}
|
|
446
|
-
!R || _ ? (
|
|
447
|
-
const
|
|
448
|
-
|
|
447
|
+
!R || _ ? (f.__isCustomRow && (f.className = "data-grid-row", f.setAttribute("role", "row"), f.__isCustomRow = !1), G(o, f, c, h), f.__epoch = n, f.__rowDataRef = c) : C ? (J(o, f, c, h), f.__rowDataRef = c) : J(o, f, c, h);
|
|
448
|
+
const b = o._changedRowIndices.has(h), v = f.classList.contains("changed");
|
|
449
|
+
b !== v && f.classList.toggle("changed", b), f.parentNode !== r && r.appendChild(f);
|
|
449
450
|
}
|
|
450
451
|
}
|
|
451
|
-
function
|
|
452
|
-
const
|
|
452
|
+
function J(o, e, t, n) {
|
|
453
|
+
const s = e.children, i = o.visibleColumns, r = i.length, a = s.length, l = r < a ? r : a, d = o.focusRow, u = o.focusCol;
|
|
453
454
|
let g = o.__hasSpecialColumns;
|
|
454
455
|
if (g === void 0) {
|
|
455
456
|
g = !1;
|
|
456
457
|
for (let c = 0; c < r; c++) {
|
|
457
|
-
const
|
|
458
|
-
if (
|
|
458
|
+
const f = i[c];
|
|
459
|
+
if (f.__viewTemplate || f.__compiledView || f.viewRenderer || f.externalView || f.format || f.type === "date" || f.type === "boolean") {
|
|
459
460
|
g = !0;
|
|
460
461
|
break;
|
|
461
462
|
}
|
|
@@ -465,89 +466,89 @@ function Y(o, e, t, n) {
|
|
|
465
466
|
const h = String(n);
|
|
466
467
|
if (!g) {
|
|
467
468
|
for (let c = 0; c < l; c++) {
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
const
|
|
471
|
-
|
|
469
|
+
const f = s[c], p = t[i[c].field];
|
|
470
|
+
f.textContent = p == null ? "" : String(p), f.getAttribute("data-row") !== h && f.setAttribute("data-row", h);
|
|
471
|
+
const w = d === n && u === c, m = f.classList.contains("cell-focus");
|
|
472
|
+
w !== m && (f.classList.toggle("cell-focus", w), f.setAttribute("aria-selected", String(w)));
|
|
472
473
|
}
|
|
473
474
|
return;
|
|
474
475
|
}
|
|
475
476
|
for (let c = 0; c < l; c++)
|
|
476
|
-
if (
|
|
477
|
-
|
|
477
|
+
if (i[c].externalView && !s[c].querySelector("[data-external-view]")) {
|
|
478
|
+
G(o, e, t, n);
|
|
478
479
|
return;
|
|
479
480
|
}
|
|
480
481
|
for (let c = 0; c < l; c++) {
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
const
|
|
484
|
-
if (
|
|
485
|
-
if (
|
|
486
|
-
const
|
|
487
|
-
typeof _ == "string" ?
|
|
482
|
+
const f = i[c], p = s[c];
|
|
483
|
+
p.getAttribute("data-row") !== h && p.setAttribute("data-row", h);
|
|
484
|
+
const w = d === n && u === c, m = p.classList.contains("cell-focus");
|
|
485
|
+
if (w !== m && (p.classList.toggle("cell-focus", w), p.setAttribute("aria-selected", String(w))), p.classList.contains("editing")) continue;
|
|
486
|
+
if (f.viewRenderer) {
|
|
487
|
+
const C = t[f.field], _ = f.viewRenderer({ row: t, value: C, field: f.field, column: f });
|
|
488
|
+
typeof _ == "string" ? p.innerHTML = q(_) : _ ? (p.innerHTML = "", p.appendChild(_)) : p.textContent = C == null ? "" : String(C);
|
|
488
489
|
continue;
|
|
489
490
|
}
|
|
490
|
-
if (
|
|
491
|
+
if (f.__viewTemplate || f.__compiledView || f.externalView)
|
|
491
492
|
continue;
|
|
492
|
-
const
|
|
493
|
+
const y = t[f.field];
|
|
493
494
|
let R;
|
|
494
|
-
if (
|
|
495
|
+
if (f.format)
|
|
495
496
|
try {
|
|
496
|
-
const
|
|
497
|
-
R = E == null ? "" : String(E);
|
|
498
|
-
} catch {
|
|
497
|
+
const C = f.format(y, t);
|
|
499
498
|
R = C == null ? "" : String(C);
|
|
499
|
+
} catch {
|
|
500
|
+
R = y == null ? "" : String(y);
|
|
500
501
|
}
|
|
501
|
-
else if (
|
|
502
|
-
if (
|
|
502
|
+
else if (f.type === "date")
|
|
503
|
+
if (y == null || y === "")
|
|
503
504
|
R = "";
|
|
504
|
-
else if (
|
|
505
|
-
R = isNaN(
|
|
505
|
+
else if (y instanceof Date)
|
|
506
|
+
R = isNaN(y.getTime()) ? "" : y.toLocaleDateString();
|
|
506
507
|
else {
|
|
507
|
-
const
|
|
508
|
-
R = isNaN(
|
|
508
|
+
const C = new Date(y);
|
|
509
|
+
R = isNaN(C.getTime()) ? "" : C.toLocaleDateString();
|
|
509
510
|
}
|
|
510
|
-
else
|
|
511
|
-
|
|
511
|
+
else f.type === "boolean" ? (R = y ? "🗹" : "☐", p.setAttribute("aria-checked", String(!!y))) : R = y == null ? "" : String(y);
|
|
512
|
+
p.textContent = R;
|
|
512
513
|
}
|
|
513
514
|
}
|
|
514
|
-
function
|
|
515
|
+
function G(o, e, t, n) {
|
|
515
516
|
e.innerHTML = "";
|
|
516
|
-
const
|
|
517
|
-
for (let g = 0; g <
|
|
518
|
-
const h =
|
|
519
|
-
c.className = "cell",
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
let
|
|
523
|
-
const
|
|
524
|
-
if (
|
|
517
|
+
const s = o.visibleColumns, i = s.length, r = o.focusRow, a = o.focusCol, l = o.effectiveConfig?.editOn || o.editOn, d = o, u = document.createDocumentFragment();
|
|
518
|
+
for (let g = 0; g < i; g++) {
|
|
519
|
+
const h = s[g], c = document.createElement("div");
|
|
520
|
+
c.className = "cell", W(c, "cell"), h.type !== "boolean" && c.setAttribute("role", "gridcell"), c.setAttribute("data-col", String(g)), c.setAttribute("data-row", String(n)), c.setAttribute("aria-colindex", String(g + 1)), h.type && c.setAttribute("data-type", h.type);
|
|
521
|
+
const f = h.sticky;
|
|
522
|
+
f === "left" ? c.classList.add("sticky-left") : f === "right" && c.classList.add("sticky-right");
|
|
523
|
+
let p = t[h.field];
|
|
524
|
+
const w = h.format;
|
|
525
|
+
if (w)
|
|
525
526
|
try {
|
|
526
|
-
|
|
527
|
+
p = w(p, t);
|
|
527
528
|
} catch {
|
|
528
529
|
}
|
|
529
|
-
const m = h.__compiledView,
|
|
530
|
+
const m = h.__compiledView, y = h.__viewTemplate, R = h.viewRenderer, C = h.externalView;
|
|
530
531
|
let _ = !1;
|
|
531
532
|
if (R) {
|
|
532
|
-
const
|
|
533
|
-
typeof
|
|
534
|
-
} else if (
|
|
535
|
-
const
|
|
533
|
+
const b = R({ row: t, value: p, field: h.field, column: h });
|
|
534
|
+
typeof b == "string" ? (c.innerHTML = q(b), _ = !0) : b ? c.appendChild(b) : c.textContent = p == null ? "" : String(p);
|
|
535
|
+
} else if (C) {
|
|
536
|
+
const b = C, v = document.createElement("div");
|
|
536
537
|
v.setAttribute("data-external-view", ""), v.setAttribute("data-field", h.field), c.appendChild(v);
|
|
537
|
-
const
|
|
538
|
-
if (
|
|
538
|
+
const A = { row: t, value: p, field: h.field, column: h };
|
|
539
|
+
if (b.mount)
|
|
539
540
|
try {
|
|
540
|
-
|
|
541
|
+
b.mount({ placeholder: v, context: A, spec: b });
|
|
541
542
|
} catch {
|
|
542
543
|
}
|
|
543
544
|
else
|
|
544
545
|
queueMicrotask(() => {
|
|
545
546
|
try {
|
|
546
|
-
|
|
547
|
+
d.dispatchEvent(
|
|
547
548
|
new CustomEvent("mount-external-view", {
|
|
548
549
|
bubbles: !0,
|
|
549
550
|
composed: !0,
|
|
550
|
-
detail: { placeholder: v, spec:
|
|
551
|
+
detail: { placeholder: v, spec: b, context: A }
|
|
551
552
|
})
|
|
552
553
|
);
|
|
553
554
|
} catch {
|
|
@@ -555,50 +556,50 @@ function F(o, e, t, n) {
|
|
|
555
556
|
});
|
|
556
557
|
v.setAttribute("data-mounted", "");
|
|
557
558
|
} else if (m) {
|
|
558
|
-
const
|
|
559
|
-
c.innerHTML = v ? "" :
|
|
560
|
-
} else if (
|
|
561
|
-
const
|
|
562
|
-
/Reflect\.|\bProxy\b|ownKeys\(/.test(
|
|
559
|
+
const b = m({ row: t, value: p, field: h.field, column: h }), v = m.__blocked;
|
|
560
|
+
c.innerHTML = v ? "" : q(b), _ = !0, v && (c.textContent = "", c.setAttribute("data-blocked-template", ""));
|
|
561
|
+
} else if (y) {
|
|
562
|
+
const b = y.innerHTML;
|
|
563
|
+
/Reflect\.|\bProxy\b|ownKeys\(/.test(b) ? (c.textContent = "", c.setAttribute("data-blocked-template", "")) : (c.innerHTML = q(fe(b, { row: t, value: p })), _ = !0);
|
|
563
564
|
} else if (h.type === "date")
|
|
564
|
-
if (
|
|
565
|
+
if (p == null || p === "")
|
|
565
566
|
c.textContent = "";
|
|
566
567
|
else {
|
|
567
|
-
let
|
|
568
|
-
if (
|
|
569
|
-
else if (typeof
|
|
570
|
-
const v = new Date(
|
|
571
|
-
isNaN(v.getTime()) || (
|
|
568
|
+
let b = null;
|
|
569
|
+
if (p instanceof Date) b = p;
|
|
570
|
+
else if (typeof p == "number" || typeof p == "string") {
|
|
571
|
+
const v = new Date(p);
|
|
572
|
+
isNaN(v.getTime()) || (b = v);
|
|
572
573
|
}
|
|
573
|
-
c.textContent =
|
|
574
|
+
c.textContent = b ? b.toLocaleDateString() : "";
|
|
574
575
|
}
|
|
575
576
|
else if (h.type === "boolean") {
|
|
576
|
-
const
|
|
577
|
-
c.innerHTML =
|
|
577
|
+
const b = !!p;
|
|
578
|
+
c.innerHTML = b ? "🗹" : "☐", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(b)), c.setAttribute("aria-label", String(b));
|
|
578
579
|
} else
|
|
579
|
-
c.textContent =
|
|
580
|
+
c.textContent = p == null ? "" : String(p);
|
|
580
581
|
if (_) {
|
|
581
|
-
|
|
582
|
-
const
|
|
583
|
-
/Proxy|Reflect\.ownKeys/.test(
|
|
582
|
+
Me(c);
|
|
583
|
+
const b = c.textContent || "";
|
|
584
|
+
/Proxy|Reflect\.ownKeys/.test(b) && (c.textContent = b.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(c.textContent || "") && (c.textContent = ""));
|
|
584
585
|
}
|
|
585
586
|
c.hasAttribute("data-blocked-template") && (c.textContent || "").trim().length && (c.textContent = ""), h.editable ? (c.tabIndex = 0, c.addEventListener("mousedown", () => {
|
|
586
587
|
o.focusRow = n, o.focusCol = g, H(o);
|
|
587
|
-
}), l === "click" ? c.addEventListener("click", (
|
|
588
|
-
c.classList.contains("editing") || (
|
|
589
|
-
}) : c.addEventListener("dblclick", (
|
|
590
|
-
|
|
588
|
+
}), l === "click" ? c.addEventListener("click", (b) => {
|
|
589
|
+
c.classList.contains("editing") || (b.stopPropagation(), o.focusRow = n, o.focusCol = g, k(o, t, n, h, c));
|
|
590
|
+
}) : c.addEventListener("dblclick", (b) => {
|
|
591
|
+
b.stopPropagation(), L(o, n, t);
|
|
591
592
|
const v = o.findRenderedRowElement?.(n);
|
|
592
593
|
if (v) {
|
|
593
|
-
const
|
|
594
|
-
for (let
|
|
595
|
-
const
|
|
596
|
-
|
|
594
|
+
const A = v.children;
|
|
595
|
+
for (let P = 0; P < A.length; P++) {
|
|
596
|
+
const D = o.visibleColumns[P];
|
|
597
|
+
D && D.editable && k(o, t, n, D, A[P]);
|
|
597
598
|
}
|
|
598
599
|
}
|
|
599
|
-
}), c.addEventListener("keydown", (
|
|
600
|
-
if ((h.type === "select" || h.type === "typeahead") && !c.classList.contains("editing") &&
|
|
601
|
-
|
|
600
|
+
}), c.addEventListener("keydown", (b) => {
|
|
601
|
+
if ((h.type === "select" || h.type === "typeahead") && !c.classList.contains("editing") && b.key === "Enter") {
|
|
602
|
+
b.preventDefault(), o.activeEditRows !== n && L(o, n, t), k(o, t, n, h, c), setTimeout(() => {
|
|
602
603
|
const v = c.querySelector("select");
|
|
603
604
|
try {
|
|
604
605
|
v?.showPicker?.();
|
|
@@ -608,86 +609,86 @@ function F(o, e, t, n) {
|
|
|
608
609
|
}, 0);
|
|
609
610
|
return;
|
|
610
611
|
}
|
|
611
|
-
if (h.type === "boolean" &&
|
|
612
|
-
|
|
612
|
+
if (h.type === "boolean" && b.key === " " && !c.classList.contains("editing")) {
|
|
613
|
+
b.preventDefault(), o.activeEditRows !== n && L(o, n, t);
|
|
613
614
|
const v = !t[h.field];
|
|
614
|
-
|
|
615
|
+
K(o, n, h, v, t), c.innerHTML = v ? "🗹" : "☐", c.setAttribute("aria-label", String(!!v));
|
|
615
616
|
return;
|
|
616
617
|
}
|
|
617
|
-
if (
|
|
618
|
-
|
|
618
|
+
if (b.key === "Enter" && !c.classList.contains("editing")) {
|
|
619
|
+
b.preventDefault(), o.focusRow = n, o.focusCol = g, typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(n) : k(o, t, n, h, c);
|
|
619
620
|
return;
|
|
620
621
|
}
|
|
621
|
-
if (
|
|
622
|
-
|
|
622
|
+
if (b.key === "F2" && !c.classList.contains("editing")) {
|
|
623
|
+
b.preventDefault(), k(o, t, n, h, c);
|
|
623
624
|
return;
|
|
624
625
|
}
|
|
625
|
-
})) : h.type === "boolean" && (c.hasAttribute("tabindex") || (c.tabIndex = 0), c.addEventListener("keydown", (
|
|
626
|
-
if (
|
|
627
|
-
|
|
626
|
+
})) : h.type === "boolean" && (c.hasAttribute("tabindex") || (c.tabIndex = 0), c.addEventListener("keydown", (b) => {
|
|
627
|
+
if (b.key === " ") {
|
|
628
|
+
b.preventDefault();
|
|
628
629
|
const v = !t[h.field];
|
|
629
|
-
o.activeEditRows !== n &&
|
|
630
|
+
o.activeEditRows !== n && L(o, n, t), K(o, n, h, v, t), c.innerHTML = v ? "🗹" : "☐", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(!!v)), c.setAttribute("aria-label", String(!!v));
|
|
630
631
|
}
|
|
631
|
-
})), r === n && a === g ? c.setAttribute("aria-selected", "true") : c.setAttribute("aria-selected", "false"),
|
|
632
|
+
})), r === n && a === g ? c.setAttribute("aria-selected", "true") : c.setAttribute("aria-selected", "false"), u.appendChild(c);
|
|
632
633
|
}
|
|
633
|
-
e.appendChild(
|
|
634
|
+
e.appendChild(u);
|
|
634
635
|
}
|
|
635
|
-
function
|
|
636
|
+
function Q(o, e, t, n) {
|
|
636
637
|
if (e.target?.closest(".resize-handle")) return;
|
|
637
|
-
const
|
|
638
|
-
if (!
|
|
639
|
-
const
|
|
640
|
-
if (isNaN(
|
|
641
|
-
const r = o._rows[
|
|
638
|
+
const s = t.querySelector(".cell[data-row]");
|
|
639
|
+
if (!s) return;
|
|
640
|
+
const i = Number(s.getAttribute("data-row"));
|
|
641
|
+
if (isNaN(i)) return;
|
|
642
|
+
const r = o._rows[i];
|
|
642
643
|
if (!r) return;
|
|
643
644
|
const a = e.target?.closest(".cell[data-col]");
|
|
644
645
|
if (a) {
|
|
645
|
-
const
|
|
646
|
-
if (!isNaN(
|
|
647
|
-
if (o.dispatchCellClick?.(e,
|
|
646
|
+
const d = Number(a.getAttribute("data-col"));
|
|
647
|
+
if (!isNaN(d)) {
|
|
648
|
+
if (o.dispatchCellClick?.(e, i, d, a))
|
|
648
649
|
return;
|
|
649
|
-
o.focusRow =
|
|
650
|
+
o.focusRow = i, o.focusCol = d, H(o);
|
|
650
651
|
}
|
|
651
652
|
}
|
|
652
653
|
if (t.querySelector(".cell.editing")) {
|
|
653
|
-
const
|
|
654
|
+
const d = t.querySelectorAll(".cell.editing");
|
|
654
655
|
if (!n) return;
|
|
655
|
-
|
|
656
|
+
d.forEach((u) => u.classList.remove("editing"));
|
|
656
657
|
}
|
|
657
658
|
const l = o.effectiveConfig?.editOn || o.editOn || "doubleClick";
|
|
658
|
-
if (l === "click" || l === "doubleClick" && n)
|
|
659
|
+
if (l === "click" || l === "doubleClick" && n) L(o, i, r);
|
|
659
660
|
else return;
|
|
660
|
-
Array.from(t.children).forEach((
|
|
661
|
-
const g = o.visibleColumns[
|
|
662
|
-
g && g.editable &&
|
|
661
|
+
Array.from(t.children).forEach((d, u) => {
|
|
662
|
+
const g = o.visibleColumns[u];
|
|
663
|
+
g && g.editable && k(o, r, i, g, d);
|
|
663
664
|
}), a && queueMicrotask(() => {
|
|
664
|
-
const
|
|
665
|
-
if (
|
|
666
|
-
const
|
|
665
|
+
const d = t.querySelector(`.cell[data-col="${o.focusCol}"]`);
|
|
666
|
+
if (d?.classList.contains("editing")) {
|
|
667
|
+
const u = d.querySelector(
|
|
667
668
|
'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
|
|
668
669
|
);
|
|
669
670
|
try {
|
|
670
|
-
|
|
671
|
+
u?.focus();
|
|
671
672
|
} catch {
|
|
672
673
|
}
|
|
673
674
|
}
|
|
674
675
|
});
|
|
675
676
|
}
|
|
676
|
-
function
|
|
677
|
+
function L(o, e, t) {
|
|
677
678
|
o.activeEditRows !== e && (o.rowEditSnapshots.set(e, { ...t }), o.activeEditRows = e);
|
|
678
679
|
}
|
|
679
|
-
function
|
|
680
|
+
function We(o, e, t) {
|
|
680
681
|
if (o.activeEditRows !== e) return;
|
|
681
|
-
const n = o.rowEditSnapshots.get(e),
|
|
682
|
-
if (t && n &&
|
|
683
|
-
Object.keys(n).forEach((r) =>
|
|
682
|
+
const n = o.rowEditSnapshots.get(e), s = o._rows[e];
|
|
683
|
+
if (t && n && s)
|
|
684
|
+
Object.keys(n).forEach((r) => s[r] = n[r]), o._changedRowIndices.delete(e);
|
|
684
685
|
else if (!t) {
|
|
685
686
|
const r = o._changedRowIndices.has(e);
|
|
686
687
|
o.dispatchEvent(
|
|
687
688
|
new CustomEvent("row-commit", {
|
|
688
689
|
detail: {
|
|
689
690
|
rowIndex: e,
|
|
690
|
-
row:
|
|
691
|
+
row: s,
|
|
691
692
|
changed: r,
|
|
692
693
|
changedRows: o.changedRows,
|
|
693
694
|
changedRowIndices: o.changedRowIndices
|
|
@@ -696,34 +697,34 @@ function Be(o, e, t) {
|
|
|
696
697
|
);
|
|
697
698
|
}
|
|
698
699
|
o.rowEditSnapshots.delete(e), o.activeEditRows = -1;
|
|
699
|
-
const
|
|
700
|
-
|
|
700
|
+
const i = o.findRenderedRowElement?.(e);
|
|
701
|
+
i && (G(o, i, o._rows[e], e), o._changedRowIndices.has(e) ? i.classList.add("changed") : i.classList.remove("changed")), t && queueMicrotask(() => {
|
|
701
702
|
try {
|
|
702
703
|
o.focus();
|
|
703
704
|
const r = o.focusRow, a = o.focusCol, l = o.findRenderedRowElement?.(r);
|
|
704
705
|
if (l) {
|
|
705
706
|
Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach(
|
|
706
|
-
(
|
|
707
|
+
(u) => u.classList.remove("cell-focus")
|
|
707
708
|
);
|
|
708
|
-
const
|
|
709
|
-
|
|
709
|
+
const d = l.querySelector(`.cell[data-row="${r}"][data-col="${a}"]`);
|
|
710
|
+
d && d.classList.add("cell-focus");
|
|
710
711
|
}
|
|
711
712
|
} catch {
|
|
712
713
|
}
|
|
713
714
|
});
|
|
714
715
|
}
|
|
715
|
-
function
|
|
716
|
-
const
|
|
717
|
-
if (i
|
|
718
|
-
i
|
|
716
|
+
function K(o, e, t, n, s) {
|
|
717
|
+
const i = t.field;
|
|
718
|
+
if (s[i] === n) return;
|
|
719
|
+
s[i] = n;
|
|
719
720
|
const a = !o._changedRowIndices.has(e);
|
|
720
721
|
o._changedRowIndices.add(e);
|
|
721
722
|
const l = o.findRenderedRowElement?.(e);
|
|
722
723
|
l && l.classList.add("changed"), o.dispatchEvent(
|
|
723
724
|
new CustomEvent("cell-commit", {
|
|
724
725
|
detail: {
|
|
725
|
-
row:
|
|
726
|
-
field:
|
|
726
|
+
row: s,
|
|
727
|
+
field: i,
|
|
727
728
|
value: n,
|
|
728
729
|
rowIndex: e,
|
|
729
730
|
changedRows: o.changedRows,
|
|
@@ -733,122 +734,122 @@ function $(o, e, t, n, i) {
|
|
|
733
734
|
})
|
|
734
735
|
);
|
|
735
736
|
}
|
|
736
|
-
function
|
|
737
|
-
if (!n.editable || (o.activeEditRows !== t &&
|
|
738
|
-
const
|
|
739
|
-
|
|
737
|
+
function k(o, e, t, n, s) {
|
|
738
|
+
if (!n.editable || (o.activeEditRows !== t && L(o, t, e), s.classList.contains("editing"))) return;
|
|
739
|
+
const i = e[n.field];
|
|
740
|
+
s.classList.add("editing");
|
|
740
741
|
const r = (h) => {
|
|
741
|
-
|
|
742
|
+
K(o, t, n, h, e);
|
|
742
743
|
}, a = () => {
|
|
743
|
-
e[n.field] =
|
|
744
|
-
const h =
|
|
745
|
-
h && (typeof HTMLInputElement < "u" && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!
|
|
744
|
+
e[n.field] = i;
|
|
745
|
+
const h = s.querySelector("input,textarea,select");
|
|
746
|
+
h && (typeof HTMLInputElement < "u" && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!i : "value" in h && (h.value = i ?? ""));
|
|
746
747
|
}, l = document.createElement("div");
|
|
747
|
-
l.style.display = "contents",
|
|
748
|
-
const
|
|
749
|
-
if (
|
|
750
|
-
const h =
|
|
751
|
-
c ? h.innerHTML = c({ row: e, value:
|
|
752
|
-
|
|
753
|
-
const
|
|
754
|
-
return
|
|
748
|
+
l.style.display = "contents", s.innerHTML = "", s.appendChild(l);
|
|
749
|
+
const d = n.__editorTemplate, u = n.editor || (d ? "template" : Ne(n)), g = i;
|
|
750
|
+
if (u === "template" && d) {
|
|
751
|
+
const h = d.cloneNode(!0), c = n.__compiledEditor;
|
|
752
|
+
c ? h.innerHTML = c({ row: e, value: i, field: n.field, column: n }) : h.querySelectorAll("*").forEach((p) => {
|
|
753
|
+
p.childNodes.length === 1 && p.firstChild?.nodeType === Node.TEXT_NODE && (p.textContent = p.textContent?.replace(/{{\s*value\s*}}/g, i == null ? "" : String(i)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (w, m) => {
|
|
754
|
+
const y = e[m];
|
|
755
|
+
return y == null ? "" : String(y);
|
|
755
756
|
}) || "");
|
|
756
757
|
});
|
|
757
|
-
const
|
|
758
|
-
if (
|
|
759
|
-
const
|
|
760
|
-
|
|
761
|
-
const
|
|
762
|
-
r(
|
|
763
|
-
}),
|
|
764
|
-
if (
|
|
765
|
-
const m =
|
|
758
|
+
const f = h.querySelector("input,textarea,select");
|
|
759
|
+
if (f) {
|
|
760
|
+
const p = typeof HTMLInputElement < "u";
|
|
761
|
+
p && f instanceof HTMLInputElement && f.type === "checkbox" ? f.checked = !!i : "value" in f && (f.value = i ?? ""), f.addEventListener("blur", () => {
|
|
762
|
+
const w = p && f instanceof HTMLInputElement && f.type === "checkbox" ? f.checked : f.value;
|
|
763
|
+
r(w);
|
|
764
|
+
}), f.addEventListener("keydown", (w) => {
|
|
765
|
+
if (w.key === "Enter") {
|
|
766
|
+
const m = p && f instanceof HTMLInputElement && f.type === "checkbox" ? f.checked : f.value;
|
|
766
767
|
r(m);
|
|
767
768
|
}
|
|
768
|
-
|
|
769
|
-
}),
|
|
770
|
-
const
|
|
771
|
-
r(
|
|
772
|
-
}), setTimeout(() =>
|
|
769
|
+
w.key === "Escape" && a();
|
|
770
|
+
}), p && f instanceof HTMLInputElement && f.type === "checkbox" && f.addEventListener("change", () => {
|
|
771
|
+
const w = f.checked;
|
|
772
|
+
r(w);
|
|
773
|
+
}), setTimeout(() => f.focus(), 0);
|
|
773
774
|
}
|
|
774
775
|
l.appendChild(h);
|
|
775
|
-
} else if (typeof
|
|
776
|
-
const h = document.createElement(
|
|
776
|
+
} else if (typeof u == "string") {
|
|
777
|
+
const h = document.createElement(u);
|
|
777
778
|
h.value = g, h.addEventListener("change", () => r(h.value)), l.appendChild(h);
|
|
778
|
-
} else if (typeof
|
|
779
|
-
const h =
|
|
779
|
+
} else if (typeof u == "function") {
|
|
780
|
+
const h = u({ row: e, value: g, field: n.field, column: n, commit: r, cancel: a });
|
|
780
781
|
typeof h == "string" ? l.innerHTML = h : l.appendChild(h);
|
|
781
|
-
} else if (
|
|
782
|
+
} else if (u && typeof u == "object") {
|
|
782
783
|
const h = document.createElement("div");
|
|
783
784
|
h.setAttribute("data-external-editor", ""), h.setAttribute("data-field", n.field), l.appendChild(h);
|
|
784
785
|
const c = { row: e, value: g, field: n.field, column: n, commit: r, cancel: a };
|
|
785
|
-
if (
|
|
786
|
+
if (u.mount)
|
|
786
787
|
try {
|
|
787
|
-
|
|
788
|
+
u.mount({ placeholder: h, context: c, spec: u });
|
|
788
789
|
} catch {
|
|
789
790
|
}
|
|
790
791
|
else
|
|
791
792
|
o.dispatchEvent(
|
|
792
|
-
new CustomEvent("mount-external-editor", { detail: { placeholder: h, spec:
|
|
793
|
+
new CustomEvent("mount-external-editor", { detail: { placeholder: h, spec: u, context: c } })
|
|
793
794
|
);
|
|
794
795
|
}
|
|
795
796
|
}
|
|
796
|
-
function
|
|
797
|
-
!o.sortState || o.sortState.field !== e.field ? (o.sortState || (o.__originalOrder = o._rows.slice()),
|
|
797
|
+
function ee(o, e) {
|
|
798
|
+
!o.sortState || o.sortState.field !== e.field ? (o.sortState || (o.__originalOrder = o._rows.slice()), te(o, e, 1)) : o.sortState.direction === 1 ? te(o, e, -1) : (o.sortState = null, o.__rowRenderEpoch++, o.rowPool.forEach((n) => n.__epoch = -1), o._rows = o.__originalOrder.slice(), U(o), o.headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach((n) => {
|
|
798
799
|
n.getAttribute("aria-sort") ? (n.getAttribute("aria-sort") === "ascending" || n.getAttribute("aria-sort") === "descending") && (o.sortState || n.setAttribute("aria-sort", "none")) : n.setAttribute("aria-sort", "none");
|
|
799
800
|
}), o.refreshVirtualWindow(!0), o.dispatchEvent(
|
|
800
801
|
new CustomEvent("sort-change", { detail: { field: e.field, direction: 0 } })
|
|
801
802
|
), o.requestStateChange?.());
|
|
802
803
|
}
|
|
803
|
-
function
|
|
804
|
+
function te(o, e, t) {
|
|
804
805
|
o.sortState = { field: e.field, direction: t };
|
|
805
|
-
const n = e.sortComparator || ((
|
|
806
|
-
o._rows.sort((
|
|
806
|
+
const n = e.sortComparator || ((s, i) => s == null && i == null ? 0 : s == null ? -1 : i == null || s > i ? 1 : s < i ? -1 : 0);
|
|
807
|
+
o._rows.sort((s, i) => n(s[e.field], i[e.field], s, i) * t), o.__rowRenderEpoch++, o.rowPool.forEach((s) => s.__epoch = -1), U(o), o.refreshVirtualWindow(!0), o.dispatchEvent(
|
|
807
808
|
new CustomEvent("sort-change", { detail: { field: e.field, direction: t } })
|
|
808
809
|
), o.requestStateChange?.();
|
|
809
810
|
}
|
|
810
|
-
function
|
|
811
|
+
function Ke(o, e) {
|
|
811
812
|
typeof e == "string" ? o.textContent = e : e instanceof HTMLElement && (o.innerHTML = "", o.appendChild(e.cloneNode(!0)));
|
|
812
813
|
}
|
|
813
|
-
function
|
|
814
|
+
function U(o) {
|
|
814
815
|
o.headerRowEl = o.findHeaderRow();
|
|
815
816
|
const e = o.headerRowEl;
|
|
816
817
|
e.innerHTML = "", e.setAttribute("role", "row"), e.setAttribute("aria-rowindex", "1"), o.visibleColumns.forEach((t, n) => {
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
const
|
|
820
|
-
if (
|
|
818
|
+
const s = document.createElement("div");
|
|
819
|
+
s.className = "cell", W(s, "header-cell"), s.setAttribute("role", "columnheader"), s.setAttribute("aria-colindex", String(n + 1)), s.setAttribute("data-field", t.field), s.setAttribute("data-col", String(n)), t.sticky === "left" ? s.classList.add("sticky-left") : t.sticky === "right" && s.classList.add("sticky-right");
|
|
820
|
+
const i = t.__headerTemplate;
|
|
821
|
+
if (i) Array.from(i.childNodes).forEach((r) => s.appendChild(r.cloneNode(!0)));
|
|
821
822
|
else {
|
|
822
823
|
const r = t.header || t.field, a = document.createElement("span");
|
|
823
|
-
a.textContent = r,
|
|
824
|
+
a.textContent = r, s.appendChild(a);
|
|
824
825
|
}
|
|
825
826
|
if (t.sortable) {
|
|
826
|
-
|
|
827
|
+
s.classList.add("sortable"), s.tabIndex = 0;
|
|
827
828
|
const r = document.createElement("span");
|
|
828
|
-
|
|
829
|
-
const a = o.sortState?.field === t.field ? o.sortState.direction : 0, l = { ...
|
|
830
|
-
|
|
831
|
-
o.resizeController?.isResizing || o.dispatchHeaderClick?.(
|
|
832
|
-
}),
|
|
833
|
-
if (
|
|
834
|
-
if (
|
|
835
|
-
|
|
829
|
+
W(r, "sort-indicator"), r.style.opacity = "0.6";
|
|
830
|
+
const a = o.sortState?.field === t.field ? o.sortState.direction : 0, l = { ...S, ...o.icons }, d = a === 1 ? l.sortAsc : a === -1 ? l.sortDesc : l.sortNone;
|
|
831
|
+
Ke(r, d), s.appendChild(r), s.setAttribute("aria-sort", a === 0 ? "none" : a === 1 ? "ascending" : "descending"), s.addEventListener("click", (u) => {
|
|
832
|
+
o.resizeController?.isResizing || o.dispatchHeaderClick?.(u, n, s) || ee(o, t);
|
|
833
|
+
}), s.addEventListener("keydown", (u) => {
|
|
834
|
+
if (u.key === "Enter" || u.key === " ") {
|
|
835
|
+
if (u.preventDefault(), o.dispatchHeaderClick?.(u, n, s)) return;
|
|
836
|
+
ee(o, t);
|
|
836
837
|
}
|
|
837
838
|
});
|
|
838
839
|
}
|
|
839
840
|
if (t.resizable) {
|
|
840
|
-
t.sticky || (
|
|
841
|
+
t.sticky || (s.style.position = "relative");
|
|
841
842
|
const r = document.createElement("div");
|
|
842
843
|
r.className = "resize-handle", r.setAttribute("aria-hidden", "true"), r.addEventListener("mousedown", (a) => {
|
|
843
|
-
a.stopPropagation(), a.preventDefault(), o.resizeController.start(a, n,
|
|
844
|
-
}),
|
|
844
|
+
a.stopPropagation(), a.preventDefault(), o.resizeController.start(a, n, s);
|
|
845
|
+
}), s.appendChild(r);
|
|
845
846
|
}
|
|
846
|
-
e.appendChild(
|
|
847
|
+
e.appendChild(s);
|
|
847
848
|
});
|
|
848
849
|
try {
|
|
849
850
|
const t = o.shadowRoot;
|
|
850
|
-
t && t.querySelectorAll(".header-group-row .cell").forEach((
|
|
851
|
-
|
|
851
|
+
t && t.querySelectorAll(".header-group-row .cell").forEach((s) => {
|
|
852
|
+
s.getAttribute("data-group") && s.classList.add("grouped");
|
|
852
853
|
});
|
|
853
854
|
} catch {
|
|
854
855
|
}
|
|
@@ -856,15 +857,15 @@ function V(o) {
|
|
|
856
857
|
t.getAttribute("aria-sort") || t.setAttribute("aria-sort", "none");
|
|
857
858
|
});
|
|
858
859
|
}
|
|
859
|
-
function
|
|
860
|
-
let e = null, t = null, n = null,
|
|
861
|
-
const
|
|
860
|
+
function Ve(o) {
|
|
861
|
+
let e = null, t = null, n = null, s = null;
|
|
862
|
+
const i = (l) => {
|
|
862
863
|
if (!e) return;
|
|
863
|
-
const
|
|
864
|
-
g.width =
|
|
864
|
+
const d = l.clientX - e.startX, u = Math.max(40, e.startWidth + d), g = o.visibleColumns[e.colIndex];
|
|
865
|
+
g.width = u, g.__userResized = !0, g.__renderedWidth = u, t == null && (t = requestAnimationFrame(() => {
|
|
865
866
|
t = null, o.updateTemplate?.();
|
|
866
867
|
})), o.dispatchEvent(
|
|
867
|
-
new CustomEvent("column-resize", { detail: { field: g.field, width:
|
|
868
|
+
new CustomEvent("column-resize", { detail: { field: g.field, width: u } })
|
|
868
869
|
);
|
|
869
870
|
};
|
|
870
871
|
let r = !1;
|
|
@@ -872,79 +873,101 @@ function Ke(o) {
|
|
|
872
873
|
const l = e !== null;
|
|
873
874
|
l && (r = !0, requestAnimationFrame(() => {
|
|
874
875
|
r = !1;
|
|
875
|
-
})), window.removeEventListener("mousemove",
|
|
876
|
+
})), window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", a), n !== null && (document.documentElement.style.cursor = n, n = null), s !== null && (document.body.style.userSelect = s, s = null), e = null, l && o.requestStateChange && o.requestStateChange();
|
|
876
877
|
};
|
|
877
878
|
return {
|
|
878
879
|
get isResizing() {
|
|
879
880
|
return e !== null || r;
|
|
880
881
|
},
|
|
881
|
-
start(l,
|
|
882
|
+
start(l, d, u) {
|
|
882
883
|
l.preventDefault();
|
|
883
|
-
const g =
|
|
884
|
-
e = { startX: l.clientX, colIndex:
|
|
884
|
+
const g = u.getBoundingClientRect();
|
|
885
|
+
e = { startX: l.clientX, colIndex: d, startWidth: g.width }, window.addEventListener("mousemove", i), window.addEventListener("mouseup", a), n === null && (n = document.documentElement.style.cursor), document.documentElement.style.cursor = "e-resize", s === null && (s = document.body.style.userSelect), document.body.style.userSelect = "none";
|
|
885
886
|
},
|
|
886
887
|
dispose() {
|
|
887
888
|
a();
|
|
888
889
|
}
|
|
889
890
|
};
|
|
890
891
|
}
|
|
891
|
-
function
|
|
892
|
+
function z(o) {
|
|
893
|
+
return o ? typeof o == "string" ? o : o.outerHTML : "";
|
|
894
|
+
}
|
|
895
|
+
function Fe() {
|
|
892
896
|
return {
|
|
893
897
|
toolPanels: /* @__PURE__ */ new Map(),
|
|
894
898
|
headerContents: /* @__PURE__ */ new Map(),
|
|
895
899
|
toolbarButtons: /* @__PURE__ */ new Map(),
|
|
896
900
|
lightDomButtons: [],
|
|
897
901
|
lightDomHeaderContent: [],
|
|
898
|
-
|
|
902
|
+
isPanelOpen: !1,
|
|
903
|
+
expandedSections: /* @__PURE__ */ new Set(),
|
|
899
904
|
headerContentCleanups: /* @__PURE__ */ new Map(),
|
|
900
|
-
|
|
901
|
-
toolbarButtonCleanups: /* @__PURE__ */ new Map()
|
|
905
|
+
panelCleanups: /* @__PURE__ */ new Map(),
|
|
906
|
+
toolbarButtonCleanups: /* @__PURE__ */ new Map(),
|
|
907
|
+
// Deprecated - kept for backward compatibility
|
|
908
|
+
activePanel: null,
|
|
909
|
+
activePanelCleanup: null
|
|
902
910
|
};
|
|
903
911
|
}
|
|
904
|
-
function
|
|
912
|
+
function Ge(o, e) {
|
|
905
913
|
return !!(o?.header?.title || o?.header?.toolbarButtons?.length || e.toolPanels.size > 0 || e.headerContents.size > 0 || e.toolbarButtons.size > 0 || e.lightDomButtons.length > 0 || e.lightDomHeaderContent.length > 0);
|
|
906
914
|
}
|
|
907
|
-
function
|
|
908
|
-
const
|
|
909
|
-
let
|
|
910
|
-
for (const
|
|
911
|
-
|
|
912
|
-
for (const
|
|
913
|
-
|
|
914
|
-
for (const
|
|
915
|
-
(
|
|
916
|
-
for (const
|
|
917
|
-
(
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
u += `<button class="tbw-toolbar-btn${b ? " active" : ""}" data-panel="${d.id}" title="${d.tooltip ?? d.title}" aria-label="${d.tooltip ?? d.title}" aria-pressed="${b}" aria-controls="tbw-panel-${d.id}">${d.icon}</button>`;
|
|
915
|
+
function Ue(o, e, t = "☰") {
|
|
916
|
+
const n = o?.header?.title ?? "", s = !!n, i = z(t), r = o?.header?.toolbarButtons ?? [], a = r.length > 0, l = e.toolbarButtons.size > 0, d = e.lightDomButtons.length > 0, u = e.toolPanels.size > 0, h = (a || l || d) && u, c = [...r].sort((w, m) => (w.order ?? 100) - (m.order ?? 100)), f = [...e.toolbarButtons.values()].sort((w, m) => (w.order ?? 100) - (m.order ?? 100));
|
|
917
|
+
let p = "";
|
|
918
|
+
for (const w of c)
|
|
919
|
+
w.icon && w.action && (p += `<button class="tbw-toolbar-btn" data-btn="${w.id}" title="${w.label}" aria-label="${w.label}"${w.disabled ? " disabled" : ""}>${w.icon}</button>`);
|
|
920
|
+
for (const w of f)
|
|
921
|
+
w.icon && w.action && (p += `<button class="tbw-toolbar-btn" data-btn="${w.id}" title="${w.label}" aria-label="${w.label}"${w.disabled ? " disabled" : ""}>${w.icon}</button>`);
|
|
922
|
+
for (const w of c)
|
|
923
|
+
(w.element || w.render) && (p += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${w.id}"></div>`);
|
|
924
|
+
for (const w of f)
|
|
925
|
+
(w.element || w.render) && (p += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${w.id}"></div>`);
|
|
926
|
+
if (d && (p += '<slot name="toolbar"></slot>'), h && (p += '<div class="tbw-toolbar-separator"></div>'), u) {
|
|
927
|
+
const w = e.isPanelOpen;
|
|
928
|
+
p += `<button class="tbw-toolbar-btn${w ? " active" : ""}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${w}" aria-controls="tbw-tool-panel">${i}</button>`;
|
|
922
929
|
}
|
|
923
930
|
return `
|
|
924
931
|
<div class="tbw-shell-header" part="shell-header" role="banner">
|
|
925
|
-
${
|
|
932
|
+
${s ? `<div class="tbw-shell-title">${n}</div>` : ""}
|
|
926
933
|
<div class="tbw-shell-content" part="shell-content" role="region" aria-label="Grid information">
|
|
927
934
|
<slot name="header-content"></slot>
|
|
928
935
|
</div>
|
|
929
936
|
<div class="tbw-shell-toolbar" part="shell-toolbar" role="toolbar" aria-label="Grid tools">
|
|
930
|
-
${
|
|
937
|
+
${p}
|
|
931
938
|
</div>
|
|
932
939
|
</div>
|
|
933
940
|
`;
|
|
934
941
|
}
|
|
935
|
-
function
|
|
936
|
-
const
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
942
|
+
function Xe(o, e, t, n) {
|
|
943
|
+
const s = o?.toolPanel?.position ?? "right", i = e.toolPanels.size > 0, r = e.isPanelOpen, a = z(n?.expand ?? S.expand), l = z(n?.collapse ?? S.collapse), d = [...e.toolPanels.values()].sort((f, p) => (f.order ?? 100) - (p.order ?? 100)), u = d.length === 1;
|
|
944
|
+
let g = "";
|
|
945
|
+
for (const f of d) {
|
|
946
|
+
const p = e.expandedSections.has(f.id), w = f.icon ? `<span class="tbw-accordion-icon">${f.icon}</span>` : "", m = u ? "" : `<span class="tbw-accordion-chevron">${p ? l : a}</span>`;
|
|
947
|
+
g += `
|
|
948
|
+
<div class="${`tbw-accordion-section${p ? " expanded" : ""}${u ? " single" : ""}`}" data-section="${f.id}">
|
|
949
|
+
<button class="tbw-accordion-header" aria-expanded="${p}" aria-controls="tbw-section-${f.id}"${u ? ' aria-disabled="true"' : ""}>
|
|
950
|
+
${w}
|
|
951
|
+
<span class="tbw-accordion-title">${f.title}</span>
|
|
952
|
+
${m}
|
|
953
|
+
</button>
|
|
954
|
+
<div class="tbw-accordion-content" id="tbw-section-${f.id}" role="region" aria-labelledby="tbw-section-header-${f.id}"></div>
|
|
955
|
+
</div>
|
|
956
|
+
`;
|
|
957
|
+
}
|
|
958
|
+
const c = i ? `
|
|
959
|
+
<aside class="tbw-tool-panel${r ? " open" : ""}" part="tool-panel" data-position="${s}" role="complementary" aria-label="Tool panel" id="tbw-tool-panel">
|
|
960
|
+
<div class="tbw-tool-panel-resize" data-resize-handle data-handle-position="${s === "left" ? "right" : "left"}" aria-hidden="true"></div>
|
|
961
|
+
<div class="tbw-tool-panel-content" role="region">
|
|
962
|
+
<div class="tbw-accordion">
|
|
963
|
+
${g}
|
|
964
|
+
</div>
|
|
941
965
|
</div>
|
|
942
|
-
<div class="tbw-tool-panel-content" role="region"></div>
|
|
943
966
|
</aside>
|
|
944
967
|
` : "";
|
|
945
|
-
return
|
|
968
|
+
return s === "left" ? `
|
|
946
969
|
<div class="tbw-shell-body">
|
|
947
|
-
${
|
|
970
|
+
${c}
|
|
948
971
|
<div class="tbw-grid-content">
|
|
949
972
|
${t}
|
|
950
973
|
</div>
|
|
@@ -954,99 +977,130 @@ function Ge(o, e, t) {
|
|
|
954
977
|
<div class="tbw-grid-content">
|
|
955
978
|
${t}
|
|
956
979
|
</div>
|
|
957
|
-
${
|
|
980
|
+
${c}
|
|
958
981
|
</div>
|
|
959
982
|
`;
|
|
960
983
|
}
|
|
961
|
-
function
|
|
984
|
+
function oe(o, e) {
|
|
962
985
|
const t = o.querySelector("tbw-grid-header");
|
|
963
986
|
if (!t) return;
|
|
964
987
|
t.style.display = "none";
|
|
965
988
|
const n = t.querySelectorAll("tbw-grid-header-content");
|
|
966
|
-
e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((
|
|
967
|
-
|
|
989
|
+
e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((i) => {
|
|
990
|
+
i.setAttribute("slot", "header-content");
|
|
968
991
|
});
|
|
969
|
-
const
|
|
970
|
-
e.lightDomButtons = Array.from(
|
|
971
|
-
const a = parseInt(
|
|
992
|
+
const s = t.querySelectorAll("tbw-grid-tool-button");
|
|
993
|
+
e.lightDomButtons = Array.from(s), e.lightDomButtons.sort((i, r) => {
|
|
994
|
+
const a = parseInt(i.getAttribute("order") ?? "100", 10), l = parseInt(r.getAttribute("order") ?? "100", 10);
|
|
972
995
|
return a - l;
|
|
973
|
-
}), e.lightDomButtons.forEach((
|
|
974
|
-
|
|
996
|
+
}), e.lightDomButtons.forEach((i) => {
|
|
997
|
+
i.setAttribute("slot", "toolbar");
|
|
975
998
|
});
|
|
976
999
|
}
|
|
977
|
-
function
|
|
978
|
-
const
|
|
979
|
-
|
|
980
|
-
const a = r.target
|
|
981
|
-
if (
|
|
982
|
-
|
|
983
|
-
p && n.onPanelToggle(p);
|
|
1000
|
+
function je(o, e, t, n) {
|
|
1001
|
+
const s = o.querySelector(".tbw-shell-toolbar");
|
|
1002
|
+
s && s.addEventListener("click", (r) => {
|
|
1003
|
+
const a = r.target;
|
|
1004
|
+
if (a.closest("[data-panel-toggle]")) {
|
|
1005
|
+
n.onPanelToggle();
|
|
984
1006
|
return;
|
|
985
1007
|
}
|
|
986
|
-
const
|
|
987
|
-
if (
|
|
988
|
-
const
|
|
989
|
-
|
|
1008
|
+
const d = a.closest("[data-btn]");
|
|
1009
|
+
if (d) {
|
|
1010
|
+
const u = d.getAttribute("data-btn");
|
|
1011
|
+
u && n.onToolbarButtonClick(u);
|
|
990
1012
|
}
|
|
991
1013
|
});
|
|
992
|
-
const
|
|
993
|
-
|
|
994
|
-
|
|
1014
|
+
const i = o.querySelector(".tbw-accordion");
|
|
1015
|
+
i && i.addEventListener("click", (r) => {
|
|
1016
|
+
const l = r.target.closest(".tbw-accordion-header");
|
|
1017
|
+
if (l) {
|
|
1018
|
+
const u = l.closest("[data-section]")?.getAttribute("data-section");
|
|
1019
|
+
u && n.onSectionToggle(u);
|
|
1020
|
+
}
|
|
995
1021
|
});
|
|
996
1022
|
}
|
|
997
|
-
function
|
|
1023
|
+
function Ye(o, e, t) {
|
|
1024
|
+
const n = o.querySelector(".tbw-tool-panel"), s = o.querySelector("[data-resize-handle]"), i = o.querySelector(".tbw-shell-body");
|
|
1025
|
+
if (!n || !s || !i)
|
|
1026
|
+
return () => {
|
|
1027
|
+
};
|
|
1028
|
+
const r = e?.toolPanel?.position ?? "right", a = 200;
|
|
1029
|
+
let l = 0, d = 0, u = 0, g = !1;
|
|
1030
|
+
const h = (p) => {
|
|
1031
|
+
if (!g) return;
|
|
1032
|
+
p.preventDefault();
|
|
1033
|
+
const w = r === "left" ? p.clientX - l : l - p.clientX, m = Math.min(u, Math.max(a, d + w));
|
|
1034
|
+
n.style.width = `${m}px`;
|
|
1035
|
+
}, c = () => {
|
|
1036
|
+
if (!g) return;
|
|
1037
|
+
g = !1, s.classList.remove("resizing"), n.style.transition = "", document.body.style.cursor = "", document.body.style.userSelect = "";
|
|
1038
|
+
const p = n.getBoundingClientRect().width;
|
|
1039
|
+
t(p), document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", c);
|
|
1040
|
+
}, f = (p) => {
|
|
1041
|
+
p.preventDefault(), g = !0, l = p.clientX, d = n.getBoundingClientRect().width, u = i.getBoundingClientRect().width - 20, s.classList.add("resizing"), n.style.transition = "none", document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", h), document.addEventListener("mouseup", c);
|
|
1042
|
+
};
|
|
1043
|
+
return s.addEventListener("mousedown", f), () => {
|
|
1044
|
+
s.removeEventListener("mousedown", f), document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", c);
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
function Ze(o, e, t) {
|
|
998
1048
|
const n = [...e?.header?.toolbarButtons ?? [], ...t.toolbarButtons.values()];
|
|
999
|
-
for (const
|
|
1000
|
-
const
|
|
1001
|
-
if (!
|
|
1002
|
-
const r = t.toolbarButtonCleanups.get(
|
|
1003
|
-
if (r && (r(), t.toolbarButtonCleanups.delete(
|
|
1004
|
-
|
|
1005
|
-
else if (
|
|
1006
|
-
const a =
|
|
1007
|
-
a && t.toolbarButtonCleanups.set(
|
|
1049
|
+
for (const s of n) {
|
|
1050
|
+
const i = o.querySelector(`[data-btn-slot="${s.id}"]`);
|
|
1051
|
+
if (!i) continue;
|
|
1052
|
+
const r = t.toolbarButtonCleanups.get(s.id);
|
|
1053
|
+
if (r && (r(), t.toolbarButtonCleanups.delete(s.id)), s.element)
|
|
1054
|
+
i.appendChild(s.element);
|
|
1055
|
+
else if (s.render) {
|
|
1056
|
+
const a = s.render(i);
|
|
1057
|
+
a && t.toolbarButtonCleanups.set(s.id, a);
|
|
1008
1058
|
}
|
|
1009
1059
|
}
|
|
1010
1060
|
}
|
|
1011
|
-
function
|
|
1061
|
+
function ne(o, e) {
|
|
1012
1062
|
const t = o.querySelector(".tbw-shell-content");
|
|
1013
1063
|
if (!t) return;
|
|
1014
|
-
const n = [...e.headerContents.values()].sort((
|
|
1015
|
-
for (const
|
|
1016
|
-
const r = e.headerContentCleanups.get(
|
|
1017
|
-
r && (r(), e.headerContentCleanups.delete(
|
|
1018
|
-
let a = t.querySelector(`[data-header-content="${
|
|
1019
|
-
a || (a = document.createElement("div"), a.setAttribute("data-header-content",
|
|
1020
|
-
const l =
|
|
1021
|
-
l && e.headerContentCleanups.set(
|
|
1064
|
+
const n = [...e.headerContents.values()].sort((i, r) => (i.order ?? 100) - (r.order ?? 100)), s = t.querySelector('slot[name="header-content"]');
|
|
1065
|
+
for (const i of n) {
|
|
1066
|
+
const r = e.headerContentCleanups.get(i.id);
|
|
1067
|
+
r && (r(), e.headerContentCleanups.delete(i.id));
|
|
1068
|
+
let a = t.querySelector(`[data-header-content="${i.id}"]`);
|
|
1069
|
+
a || (a = document.createElement("div"), a.setAttribute("data-header-content", i.id), s ? t.insertBefore(a, s) : t.appendChild(a));
|
|
1070
|
+
const l = i.render(a);
|
|
1071
|
+
l && e.headerContentCleanups.set(i.id, l);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
function Je(o, e, t) {
|
|
1075
|
+
if (!e.isPanelOpen) return;
|
|
1076
|
+
const n = z(t?.expand ?? S.expand), s = z(t?.collapse ?? S.collapse);
|
|
1077
|
+
for (const [i, r] of e.toolPanels) {
|
|
1078
|
+
const a = e.expandedSections.has(i), l = o.querySelector(`[data-section="${i}"]`), d = l?.querySelector(".tbw-accordion-content");
|
|
1079
|
+
if (!l || !d) continue;
|
|
1080
|
+
l.classList.toggle("expanded", a);
|
|
1081
|
+
const u = l.querySelector(".tbw-accordion-header");
|
|
1082
|
+
u && u.setAttribute("aria-expanded", String(a));
|
|
1083
|
+
const g = l.querySelector(".tbw-accordion-chevron");
|
|
1084
|
+
if (g && (g.innerHTML = a ? s : n), a) {
|
|
1085
|
+
if (d.children.length === 0) {
|
|
1086
|
+
const h = r.render(d);
|
|
1087
|
+
h && e.panelCleanups.set(i, h);
|
|
1088
|
+
}
|
|
1089
|
+
} else {
|
|
1090
|
+
const h = e.panelCleanups.get(i);
|
|
1091
|
+
h && (h(), e.panelCleanups.delete(i)), d.innerHTML = "";
|
|
1092
|
+
}
|
|
1022
1093
|
}
|
|
1023
1094
|
}
|
|
1024
|
-
function
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
if (!t) return;
|
|
1028
|
-
const n = o.querySelector(".tbw-tool-panel-content");
|
|
1029
|
-
if (!n) return;
|
|
1030
|
-
e.activePanelCleanup && (e.activePanelCleanup(), e.activePanelCleanup = null), n.innerHTML = "";
|
|
1031
|
-
const i = t.render(n);
|
|
1032
|
-
i && (e.activePanelCleanup = i);
|
|
1033
|
-
}
|
|
1034
|
-
function oe(o, e) {
|
|
1035
|
-
o.querySelectorAll("[data-panel]").forEach((n) => {
|
|
1036
|
-
const s = n.getAttribute("data-panel") === e.activePanel;
|
|
1037
|
-
n.classList.toggle("active", s), n.setAttribute("aria-pressed", String(s));
|
|
1038
|
-
});
|
|
1095
|
+
function se(o, e) {
|
|
1096
|
+
const t = o.querySelector("[data-panel-toggle]");
|
|
1097
|
+
t && (t.classList.toggle("active", e.isPanelOpen), t.setAttribute("aria-pressed", String(e.isPanelOpen)));
|
|
1039
1098
|
}
|
|
1040
|
-
function
|
|
1099
|
+
function ie(o, e) {
|
|
1041
1100
|
const t = o.querySelector(".tbw-tool-panel");
|
|
1042
|
-
|
|
1043
|
-
const n = e.activePanel !== null;
|
|
1044
|
-
if (t.classList.toggle("open", n), n && e.activePanel) {
|
|
1045
|
-
const i = e.toolPanels.get(e.activePanel), s = t.querySelector(".tbw-tool-panel-title");
|
|
1046
|
-
s && (s.textContent = i?.title ?? ""), t.setAttribute("aria-label", `${i?.title ?? "Tool"} panel`), t.id = `tbw-panel-${e.activePanel}`;
|
|
1047
|
-
}
|
|
1101
|
+
t && (t.classList.toggle("open", e.isPanelOpen), e.isPanelOpen || (t.style.width = ""));
|
|
1048
1102
|
}
|
|
1049
|
-
function
|
|
1103
|
+
function Qe(o, e) {
|
|
1050
1104
|
const t = [];
|
|
1051
1105
|
for (const n of o?.header?.toolbarButtons ?? [])
|
|
1052
1106
|
t.push({
|
|
@@ -1063,11 +1117,11 @@ function Ye(o, e) {
|
|
|
1063
1117
|
source: "config"
|
|
1064
1118
|
});
|
|
1065
1119
|
for (let n = 0; n < e.lightDomButtons.length; n++) {
|
|
1066
|
-
const
|
|
1120
|
+
const i = e.lightDomButtons[n].querySelector("button");
|
|
1067
1121
|
t.push({
|
|
1068
1122
|
id: `light-dom-${n}`,
|
|
1069
|
-
label:
|
|
1070
|
-
disabled:
|
|
1123
|
+
label: i?.getAttribute("title") ?? i?.getAttribute("aria-label") ?? "",
|
|
1124
|
+
disabled: i?.disabled ?? !1,
|
|
1071
1125
|
source: "light-dom"
|
|
1072
1126
|
});
|
|
1073
1127
|
}
|
|
@@ -1081,7 +1135,7 @@ function Ye(o, e) {
|
|
|
1081
1135
|
});
|
|
1082
1136
|
return t;
|
|
1083
1137
|
}
|
|
1084
|
-
function
|
|
1138
|
+
function et(o) {
|
|
1085
1139
|
for (const e of o.headerContentCleanups.values())
|
|
1086
1140
|
e();
|
|
1087
1141
|
o.headerContentCleanups.clear(), o.activePanelCleanup && (o.activePanelCleanup(), o.activePanelCleanup = null);
|
|
@@ -1089,7 +1143,7 @@ function Ze(o) {
|
|
|
1089
1143
|
e();
|
|
1090
1144
|
o.toolbarButtonCleanups.clear(), o.activePanel && o.toolPanels.get(o.activePanel)?.onClose?.(), o.toolPanels.clear(), o.headerContents.clear(), o.toolbarButtons.clear(), o.lightDomButtons = [], o.lightDomHeaderContent = [], o.activePanel = null;
|
|
1091
1145
|
}
|
|
1092
|
-
class
|
|
1146
|
+
class tt {
|
|
1093
1147
|
constructor(e) {
|
|
1094
1148
|
this.grid = e;
|
|
1095
1149
|
}
|
|
@@ -1248,21 +1302,21 @@ class Je {
|
|
|
1248
1302
|
* Returns the minimum start index from all plugins.
|
|
1249
1303
|
*/
|
|
1250
1304
|
adjustVirtualStart(e, t, n) {
|
|
1251
|
-
let
|
|
1252
|
-
for (const
|
|
1253
|
-
if (typeof
|
|
1254
|
-
const r =
|
|
1255
|
-
r <
|
|
1305
|
+
let s = e;
|
|
1306
|
+
for (const i of this.plugins)
|
|
1307
|
+
if (typeof i.adjustVirtualStart == "function") {
|
|
1308
|
+
const r = i.adjustVirtualStart(e, t, n);
|
|
1309
|
+
r < s && (s = r);
|
|
1256
1310
|
}
|
|
1257
|
-
return
|
|
1311
|
+
return s;
|
|
1258
1312
|
}
|
|
1259
1313
|
/**
|
|
1260
1314
|
* Execute renderRow hook on all plugins.
|
|
1261
1315
|
* Returns true if any plugin handled the row.
|
|
1262
1316
|
*/
|
|
1263
1317
|
renderRow(e, t, n) {
|
|
1264
|
-
for (const
|
|
1265
|
-
if (
|
|
1318
|
+
for (const s of this.plugins)
|
|
1319
|
+
if (s.renderRow?.(e, t, n))
|
|
1266
1320
|
return !0;
|
|
1267
1321
|
return !1;
|
|
1268
1322
|
}
|
|
@@ -1349,8 +1403,8 @@ class Je {
|
|
|
1349
1403
|
getContextMenuItems(e) {
|
|
1350
1404
|
const t = [];
|
|
1351
1405
|
for (const n of this.plugins) {
|
|
1352
|
-
const
|
|
1353
|
-
|
|
1406
|
+
const s = n.getContextMenuItems?.(e);
|
|
1407
|
+
s && t.push(...s);
|
|
1354
1408
|
}
|
|
1355
1409
|
return t;
|
|
1356
1410
|
}
|
|
@@ -1380,14 +1434,14 @@ class Je {
|
|
|
1380
1434
|
return e.sort((t, n) => (t.content.order ?? 0) - (n.content.order ?? 0));
|
|
1381
1435
|
}
|
|
1382
1436
|
}
|
|
1383
|
-
class
|
|
1437
|
+
class $ extends HTMLElement {
|
|
1384
1438
|
// TODO: Rename to 'data-grid' when migration is complete
|
|
1385
1439
|
static tagName = "tbw-grid";
|
|
1386
|
-
#
|
|
1440
|
+
#n;
|
|
1387
1441
|
#i = !1;
|
|
1388
1442
|
// ---------------- Ready Promise ----------------
|
|
1389
|
-
#
|
|
1390
|
-
|
|
1443
|
+
#I;
|
|
1444
|
+
#$;
|
|
1391
1445
|
// ================== INPUT PROPERTIES ==================
|
|
1392
1446
|
// These backing fields store raw user input. They are merged into
|
|
1393
1447
|
// #effectiveConfig by #mergeEffectiveConfig(). Never read directly
|
|
@@ -1396,44 +1450,48 @@ class I extends HTMLElement {
|
|
|
1396
1450
|
#l;
|
|
1397
1451
|
#g;
|
|
1398
1452
|
#v;
|
|
1399
|
-
#
|
|
1453
|
+
#y;
|
|
1400
1454
|
// ================== SINGLE SOURCE OF TRUTH ==================
|
|
1401
1455
|
// All input sources converge here. This is the canonical config
|
|
1402
1456
|
// that all rendering and logic should read from.
|
|
1403
|
-
#
|
|
1457
|
+
#o = {};
|
|
1404
1458
|
#f = !1;
|
|
1405
1459
|
#p = 0;
|
|
1406
|
-
#
|
|
1407
|
-
#
|
|
1460
|
+
#C = null;
|
|
1461
|
+
#E = !1;
|
|
1408
1462
|
// Cached flag for plugin scroll handlers
|
|
1409
|
-
#
|
|
1463
|
+
#P;
|
|
1410
1464
|
// Cached hook to avoid closures
|
|
1411
1465
|
#R = !1;
|
|
1412
1466
|
#_ = null;
|
|
1413
|
-
#A = null;
|
|
1414
|
-
#S = null;
|
|
1415
1467
|
#x = null;
|
|
1468
|
+
#S = null;
|
|
1469
|
+
#A = null;
|
|
1416
1470
|
#a;
|
|
1417
1471
|
#w;
|
|
1418
1472
|
// ---------------- Plugin System ----------------
|
|
1419
1473
|
#t;
|
|
1420
1474
|
// ---------------- Column State ----------------
|
|
1421
|
-
#
|
|
1475
|
+
#M;
|
|
1422
1476
|
#h;
|
|
1423
1477
|
// ---------------- Shell State ----------------
|
|
1424
|
-
#e =
|
|
1478
|
+
#e = Fe();
|
|
1425
1479
|
#c = !1;
|
|
1480
|
+
#T;
|
|
1426
1481
|
// ================== DERIVED STATE ==================
|
|
1427
1482
|
// _rows: result of applying plugin processRows hooks
|
|
1428
1483
|
_rows = [];
|
|
1484
|
+
// _baseColumns: columns before plugin transformation (analogous to #rows for row processing)
|
|
1485
|
+
// This is the source of truth for processColumns - plugins transform these
|
|
1486
|
+
#O = [];
|
|
1429
1487
|
// _columns is a getter/setter that operates on effectiveConfig.columns
|
|
1430
1488
|
// This ensures effectiveConfig.columns is the single source of truth for columns
|
|
1431
1489
|
// _columns always contains ALL columns (including hidden)
|
|
1432
1490
|
get _columns() {
|
|
1433
|
-
return this.#
|
|
1491
|
+
return this.#o.columns ?? [];
|
|
1434
1492
|
}
|
|
1435
1493
|
set _columns(e) {
|
|
1436
|
-
this.#
|
|
1494
|
+
this.#o.columns = e;
|
|
1437
1495
|
}
|
|
1438
1496
|
// visibleColumns returns only visible columns for rendering
|
|
1439
1497
|
// This is what header/row rendering should use
|
|
@@ -1483,7 +1541,7 @@ class I extends HTMLElement {
|
|
|
1483
1541
|
}
|
|
1484
1542
|
set rows(e) {
|
|
1485
1543
|
const t = this.#r;
|
|
1486
|
-
this.#r = e, t !== e && this.#
|
|
1544
|
+
this.#r = e, t !== e && this.#ee();
|
|
1487
1545
|
}
|
|
1488
1546
|
/**
|
|
1489
1547
|
* Get the original unfiltered/unprocessed rows.
|
|
@@ -1497,34 +1555,34 @@ class I extends HTMLElement {
|
|
|
1497
1555
|
}
|
|
1498
1556
|
set columns(e) {
|
|
1499
1557
|
const t = this.#l;
|
|
1500
|
-
this.#l = e, t !== e && this.#
|
|
1558
|
+
this.#l = e, t !== e && this.#te();
|
|
1501
1559
|
}
|
|
1502
1560
|
get gridConfig() {
|
|
1503
|
-
return this.#
|
|
1561
|
+
return this.#o;
|
|
1504
1562
|
}
|
|
1505
1563
|
set gridConfig(e) {
|
|
1506
1564
|
const t = this.#g;
|
|
1507
|
-
this.#g = e, t !== e && this.#
|
|
1565
|
+
this.#g = e, t !== e && this.#oe();
|
|
1508
1566
|
}
|
|
1509
1567
|
get fitMode() {
|
|
1510
|
-
return this.#
|
|
1568
|
+
return this.#o.fitMode ?? "stretch";
|
|
1511
1569
|
}
|
|
1512
1570
|
set fitMode(e) {
|
|
1513
1571
|
const t = this.#v;
|
|
1514
|
-
this.#v = e, t !== e && this.#
|
|
1572
|
+
this.#v = e, t !== e && this.#J();
|
|
1515
1573
|
}
|
|
1516
1574
|
get editOn() {
|
|
1517
|
-
return this.#
|
|
1575
|
+
return this.#o.editOn;
|
|
1518
1576
|
}
|
|
1519
1577
|
set editOn(e) {
|
|
1520
|
-
const t = this.#
|
|
1521
|
-
this.#
|
|
1578
|
+
const t = this.#y;
|
|
1579
|
+
this.#y = e, t !== e && this.#Q();
|
|
1522
1580
|
}
|
|
1523
1581
|
// Effective config accessor for internal modules and plugins
|
|
1524
1582
|
// Returns the merged config (single source of truth) before plugin processing
|
|
1525
1583
|
// Use this when you need the raw merged config (e.g., for column definitions including hidden)
|
|
1526
1584
|
get effectiveConfig() {
|
|
1527
|
-
return this.#
|
|
1585
|
+
return this.#o;
|
|
1528
1586
|
}
|
|
1529
1587
|
/**
|
|
1530
1588
|
* Get the disconnect signal for event listener cleanup.
|
|
@@ -1537,11 +1595,11 @@ class I extends HTMLElement {
|
|
|
1537
1595
|
return this.#a || (this.#a = new AbortController()), this.#a.signal;
|
|
1538
1596
|
}
|
|
1539
1597
|
constructor() {
|
|
1540
|
-
super(), this.#
|
|
1598
|
+
super(), this.#n = this.attachShadow({ mode: "open" }), this.#X(), this.#I = new Promise((e) => this.#$ = e);
|
|
1541
1599
|
}
|
|
1542
|
-
#
|
|
1600
|
+
#X() {
|
|
1543
1601
|
const e = new CSSStyleSheet();
|
|
1544
|
-
e.replaceSync(
|
|
1602
|
+
e.replaceSync(me), this.#n.adoptedStyleSheets = [e];
|
|
1545
1603
|
}
|
|
1546
1604
|
// ---------------- Plugin System ----------------
|
|
1547
1605
|
/**
|
|
@@ -1564,7 +1622,7 @@ class I extends HTMLElement {
|
|
|
1564
1622
|
* Note: This does NOT reset plugin state - just re-processes rows/columns and renders.
|
|
1565
1623
|
*/
|
|
1566
1624
|
requestRender() {
|
|
1567
|
-
this.#
|
|
1625
|
+
this.#k(), this.#H(), this.#L(), this.updateTemplate(), this.refreshVirtualWindow(!0);
|
|
1568
1626
|
}
|
|
1569
1627
|
/**
|
|
1570
1628
|
* Request a lightweight style update without rebuilding DOM.
|
|
@@ -1578,40 +1636,40 @@ class I extends HTMLElement {
|
|
|
1578
1636
|
* Initialize plugin system with instances from config.
|
|
1579
1637
|
* Plugins are class instances passed in gridConfig.plugins[].
|
|
1580
1638
|
*/
|
|
1581
|
-
#
|
|
1582
|
-
this.#t = new
|
|
1583
|
-
const e = this.#
|
|
1639
|
+
#B() {
|
|
1640
|
+
this.#t = new tt(this);
|
|
1641
|
+
const e = this.#o?.plugins, t = Array.isArray(e) ? e : [];
|
|
1584
1642
|
this.#t.attachAll(t);
|
|
1585
1643
|
}
|
|
1586
1644
|
/**
|
|
1587
1645
|
* Inject all plugin styles into the shadow DOM.
|
|
1588
1646
|
* Must be called after #render() since innerHTML wipes existing content.
|
|
1589
1647
|
*/
|
|
1590
|
-
#
|
|
1648
|
+
#W() {
|
|
1591
1649
|
const e = this.#t?.getAllStyles() ?? "";
|
|
1592
1650
|
if (e) {
|
|
1593
1651
|
const t = document.createElement("style");
|
|
1594
|
-
t.setAttribute("data-plugin", "all"), t.textContent = e, this.#
|
|
1652
|
+
t.setAttribute("data-plugin", "all"), t.textContent = e, this.#n.appendChild(t);
|
|
1595
1653
|
}
|
|
1596
1654
|
}
|
|
1597
1655
|
/**
|
|
1598
1656
|
* Update plugins when grid config changes.
|
|
1599
1657
|
* With class-based plugins, we need to detach old and attach new.
|
|
1600
1658
|
*/
|
|
1601
|
-
#
|
|
1602
|
-
this.#t && this.#t.detachAll(), this.#
|
|
1659
|
+
#K() {
|
|
1660
|
+
this.#t && this.#t.detachAll(), this.#B(), this.#W(), this.#E = this.#t?.getAll().some((e) => e.onScroll) ?? !1;
|
|
1603
1661
|
}
|
|
1604
1662
|
/**
|
|
1605
1663
|
* Clean up plugin states when grid disconnects.
|
|
1606
1664
|
*/
|
|
1607
|
-
#
|
|
1665
|
+
#j() {
|
|
1608
1666
|
this.#t?.detachAll();
|
|
1609
1667
|
}
|
|
1610
1668
|
/**
|
|
1611
1669
|
* Collect tool panels and header content from all plugins.
|
|
1612
1670
|
* Called after plugins are attached but before render.
|
|
1613
1671
|
*/
|
|
1614
|
-
#
|
|
1672
|
+
#Y() {
|
|
1615
1673
|
if (!this.#t) return;
|
|
1616
1674
|
const e = this.#t.getToolPanels();
|
|
1617
1675
|
for (const { panel: n } of e)
|
|
@@ -1622,24 +1680,24 @@ class I extends HTMLElement {
|
|
|
1622
1680
|
}
|
|
1623
1681
|
// ---------------- Lifecycle ----------------
|
|
1624
1682
|
connectedCallback() {
|
|
1625
|
-
this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#a?.abort(), this.#a = new AbortController(), this.#u(), this.#
|
|
1683
|
+
this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#a?.abort(), this.#a = new AbortController(), this.#u(), this.#B(), this.#Y(), this.#i || (this.#U(), this.#W(), this.#i = !0), this.#V();
|
|
1626
1684
|
}
|
|
1627
1685
|
disconnectedCallback() {
|
|
1628
|
-
this.#
|
|
1686
|
+
this.#j(), et(this.#e), this.#c = !1, this.#T?.(), this.#T = void 0, this.#a && (this.#a.abort(), this.#a = void 0), this.resizeController && this.resizeController.dispose(), this.#w && (this.#w.disconnect(), this.#w = void 0), this.#f = !1;
|
|
1629
1687
|
}
|
|
1630
|
-
|
|
1631
|
-
const t = this.#
|
|
1688
|
+
#V() {
|
|
1689
|
+
const t = this.#n.querySelector(".tbw-grid-content") ?? this.#n.querySelector(".tbw-grid-root");
|
|
1632
1690
|
if (this.headerRowEl = t?.querySelector(".header-row"), this.virtualization.totalHeightEl = t?.querySelector(".faux-vscroll-spacer"), this.virtualization.viewportEl = t?.querySelector(".rows-viewport"), this.bodyEl = t?.querySelector(".rows"), this.#c) {
|
|
1633
|
-
|
|
1634
|
-
const r = this.#
|
|
1635
|
-
r && this.#e.toolPanels.has(r) && this.openToolPanel(r);
|
|
1691
|
+
ne(this.#n, this.#e), Ze(this.#n, this.#o?.shell, this.#e);
|
|
1692
|
+
const r = this.#o?.shell?.toolPanel?.defaultOpen;
|
|
1693
|
+
r && this.#e.toolPanels.has(r) && (this.openToolPanel(), this.#e.expandedSections.add(r));
|
|
1636
1694
|
}
|
|
1637
1695
|
this.setAttribute("data-upgraded", ""), this.hasAttribute("role") || this.setAttribute("role", "grid"), this.#f = !0;
|
|
1638
1696
|
const n = this.disconnectSignal;
|
|
1639
|
-
this.#d(), this.addEventListener("keydown", (r) =>
|
|
1697
|
+
this.#d(), this.addEventListener("keydown", (r) => qe(this, r), { signal: n }), document.addEventListener(
|
|
1640
1698
|
"keydown",
|
|
1641
1699
|
(r) => {
|
|
1642
|
-
r.key === "Escape" && this.activeEditRows !== -1 && this.#
|
|
1700
|
+
r.key === "Escape" && this.activeEditRows !== -1 && this.#D(this.activeEditRows, !0);
|
|
1643
1701
|
},
|
|
1644
1702
|
{ capture: !0, signal: n }
|
|
1645
1703
|
), document.addEventListener(
|
|
@@ -1647,54 +1705,54 @@ class I extends HTMLElement {
|
|
|
1647
1705
|
(r) => {
|
|
1648
1706
|
if (this.activeEditRows === -1) return;
|
|
1649
1707
|
const a = this.findRenderedRowElement(this.activeEditRows);
|
|
1650
|
-
!a || (r.composedPath && r.composedPath() || []).includes(a) || this.#
|
|
1708
|
+
!a || (r.composedPath && r.composedPath() || []).includes(a) || this.#D(this.activeEditRows, !1);
|
|
1651
1709
|
},
|
|
1652
1710
|
{ signal: n }
|
|
1653
1711
|
);
|
|
1654
|
-
const
|
|
1655
|
-
if (this.virtualization.container =
|
|
1656
|
-
|
|
1712
|
+
const s = t?.querySelector(".faux-vscroll"), i = t?.querySelector(".rows");
|
|
1713
|
+
if (this.virtualization.container = s ?? this, this.#E = this.#t?.getAll().some((r) => r.onScroll) ?? !1, s && i) {
|
|
1714
|
+
s.addEventListener(
|
|
1657
1715
|
"scroll",
|
|
1658
1716
|
() => {
|
|
1659
|
-
if (!this.virtualization.enabled && !this.#
|
|
1660
|
-
const l =
|
|
1661
|
-
|
|
1662
|
-
this.#p = 0, this.#
|
|
1717
|
+
if (!this.virtualization.enabled && !this.#E) return;
|
|
1718
|
+
const l = s.scrollTop, d = this.virtualization.rowHeight, u = Math.floor(l / d), g = u - u % 2, h = -(l - g * d);
|
|
1719
|
+
i.style.transform = `translateY(${h}px)`, this.#C = l, this.#p || (this.#p = requestAnimationFrame(() => {
|
|
1720
|
+
this.#p = 0, this.#C !== null && (this.#re(this.#C), this.#C = null);
|
|
1663
1721
|
}));
|
|
1664
1722
|
},
|
|
1665
1723
|
{ passive: !0, signal: n }
|
|
1666
1724
|
);
|
|
1667
|
-
const r = this.#
|
|
1725
|
+
const r = this.#n.querySelector(".tbw-grid-content"), a = this.#n.querySelector(".tbw-scroll-area");
|
|
1668
1726
|
r && (r.addEventListener(
|
|
1669
1727
|
"wheel",
|
|
1670
1728
|
(l) => {
|
|
1671
|
-
l.preventDefault(), l.shiftKey || Math.abs(l.deltaX) > Math.abs(l.deltaY) ? a && (a.scrollLeft += l.shiftKey ? l.deltaY : l.deltaX) :
|
|
1729
|
+
l.preventDefault(), l.shiftKey || Math.abs(l.deltaX) > Math.abs(l.deltaY) ? a && (a.scrollLeft += l.shiftKey ? l.deltaY : l.deltaX) : s.scrollTop += l.deltaY;
|
|
1672
1730
|
},
|
|
1673
1731
|
{ passive: !1, signal: n }
|
|
1674
1732
|
), r.addEventListener(
|
|
1675
1733
|
"touchstart",
|
|
1676
1734
|
(l) => {
|
|
1677
|
-
l.touches.length === 1 && (this.#_ = l.touches[0].clientY, this.#
|
|
1735
|
+
l.touches.length === 1 && (this.#_ = l.touches[0].clientY, this.#x = l.touches[0].clientX, this.#S = s.scrollTop, this.#A = a?.scrollLeft ?? 0);
|
|
1678
1736
|
},
|
|
1679
1737
|
{ passive: !0, signal: n }
|
|
1680
1738
|
), r.addEventListener(
|
|
1681
1739
|
"touchmove",
|
|
1682
1740
|
(l) => {
|
|
1683
|
-
if (l.touches.length === 1 && this.#_ !== null && this.#
|
|
1684
|
-
const
|
|
1685
|
-
|
|
1741
|
+
if (l.touches.length === 1 && this.#_ !== null && this.#x !== null && this.#S !== null && this.#A !== null) {
|
|
1742
|
+
const d = this.#_ - l.touches[0].clientY, u = this.#x - l.touches[0].clientX;
|
|
1743
|
+
s.scrollTop = this.#S + d, a && (a.scrollLeft = this.#A + u), l.preventDefault();
|
|
1686
1744
|
}
|
|
1687
1745
|
},
|
|
1688
1746
|
{ passive: !1, signal: n }
|
|
1689
1747
|
), r.addEventListener(
|
|
1690
1748
|
"touchend",
|
|
1691
1749
|
() => {
|
|
1692
|
-
this.#_ = null, this.#
|
|
1750
|
+
this.#_ = null, this.#x = null, this.#S = null, this.#A = null;
|
|
1693
1751
|
},
|
|
1694
1752
|
{ passive: !0, signal: n }
|
|
1695
1753
|
));
|
|
1696
1754
|
}
|
|
1697
|
-
this.resizeController =
|
|
1755
|
+
this.resizeController = Ve(this), this.#n.addEventListener("mousedown", (r) => this.#le(r), { signal: n }), document.addEventListener("mousemove", (r) => this.#ae(r), { signal: n }), document.addEventListener("mouseup", (r) => this.#ce(r), { signal: n }), this.virtualization.enabled && requestAnimationFrame(() => this.refreshVirtualWindow(!0)), requestAnimationFrame(() => {
|
|
1698
1756
|
const r = this.bodyEl.querySelector(".data-grid-row");
|
|
1699
1757
|
if (r) {
|
|
1700
1758
|
const a = r.getBoundingClientRect().height;
|
|
@@ -1704,7 +1762,7 @@ class I extends HTMLElement {
|
|
|
1704
1762
|
this.#p || (this.#p = requestAnimationFrame(() => {
|
|
1705
1763
|
this.#p = 0, this.refreshVirtualWindow(!0);
|
|
1706
1764
|
}));
|
|
1707
|
-
}), this.#w.observe(this.virtualization.viewportEl)), queueMicrotask(() => this.#
|
|
1765
|
+
}), this.#w.observe(this.virtualization.viewportEl)), queueMicrotask(() => this.#Z()), requestAnimationFrame(() => requestAnimationFrame(() => this.#$?.()));
|
|
1708
1766
|
}
|
|
1709
1767
|
// ---------------- Event Emitters ----------------
|
|
1710
1768
|
#s(e, t) {
|
|
@@ -1726,57 +1784,63 @@ class I extends HTMLElement {
|
|
|
1726
1784
|
this.#s("activate-cell", e);
|
|
1727
1785
|
}
|
|
1728
1786
|
/** Update ARIA selection attributes on rendered rows/cells */
|
|
1729
|
-
#
|
|
1787
|
+
#Z() {
|
|
1730
1788
|
this.bodyEl?.querySelectorAll(".data-grid-row")?.forEach((t, n) => {
|
|
1731
|
-
const
|
|
1732
|
-
t.setAttribute("aria-selected", String(
|
|
1733
|
-
|
|
1789
|
+
const s = n === this.focusRow;
|
|
1790
|
+
t.setAttribute("aria-selected", String(s)), t.querySelectorAll(".cell").forEach((i, r) => {
|
|
1791
|
+
i.setAttribute("aria-selected", String(s && r === this.focusCol));
|
|
1734
1792
|
});
|
|
1735
1793
|
});
|
|
1736
1794
|
}
|
|
1737
1795
|
// ---------------- Watch Handlers ----------------
|
|
1738
|
-
#
|
|
1796
|
+
#J() {
|
|
1739
1797
|
if (!this.#f) return;
|
|
1740
|
-
this.#u(), this.#
|
|
1798
|
+
this.#u(), this.#o.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, this.#F()) : (this._columns.forEach((t) => {
|
|
1741
1799
|
!t.__userResized && t.__autoSized && delete t.width;
|
|
1742
1800
|
}), this.updateTemplate());
|
|
1743
1801
|
}
|
|
1744
|
-
#
|
|
1802
|
+
#Q() {
|
|
1745
1803
|
this.#f && (this.#u(), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0));
|
|
1746
1804
|
}
|
|
1747
|
-
#
|
|
1748
|
-
this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#
|
|
1805
|
+
#ee() {
|
|
1806
|
+
this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#k(), !this.#l || Array.isArray(this.#l) && this.#l.length === 0 ? this.#d() : this.refreshVirtualWindow(!0);
|
|
1749
1807
|
}
|
|
1750
|
-
#
|
|
1751
|
-
|
|
1808
|
+
#te() {
|
|
1809
|
+
Z(this), this.#f && (this.#u(), this.#d());
|
|
1752
1810
|
}
|
|
1753
|
-
#
|
|
1754
|
-
this.#f && (this.#u(), this.#
|
|
1811
|
+
#oe() {
|
|
1812
|
+
this.#f && (this.#u(), this.#K(), this.#k(), this.#H(), this.#L(), this.updateTemplate(), this.refreshVirtualWindow(!0));
|
|
1755
1813
|
}
|
|
1756
1814
|
// ---------------- Helper Wrappers ----------------
|
|
1757
|
-
#
|
|
1758
|
-
|
|
1815
|
+
#ne() {
|
|
1816
|
+
ze(this);
|
|
1759
1817
|
}
|
|
1760
|
-
#
|
|
1761
|
-
|
|
1818
|
+
#L() {
|
|
1819
|
+
U(this);
|
|
1762
1820
|
}
|
|
1763
1821
|
updateTemplate() {
|
|
1764
|
-
|
|
1822
|
+
pe(this);
|
|
1765
1823
|
}
|
|
1766
|
-
#
|
|
1767
|
-
|
|
1824
|
+
#F() {
|
|
1825
|
+
De(this);
|
|
1768
1826
|
}
|
|
1769
|
-
#
|
|
1827
|
+
#H() {
|
|
1770
1828
|
if (this.#t) {
|
|
1771
|
-
const e = this._columns.filter((
|
|
1772
|
-
if (
|
|
1773
|
-
const
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1829
|
+
const e = this.#O.length > 0 ? this.#O : this._columns, t = e.filter((i) => !i.hidden), n = e.filter((i) => i.hidden), s = this.#t.processColumns([...t]);
|
|
1830
|
+
if (s !== t) {
|
|
1831
|
+
const i = new Map(s.map((a, l) => [a.field, { col: a, order: l }]));
|
|
1832
|
+
if (!t.some((a) => i.has(a.field)) && s.length > 0)
|
|
1833
|
+
this._columns = [...s, ...n];
|
|
1834
|
+
else {
|
|
1835
|
+
const a = e.map((l) => {
|
|
1836
|
+
if (l.hidden) return l;
|
|
1837
|
+
const d = i.get(l.field);
|
|
1838
|
+
return d ? d.col : l;
|
|
1839
|
+
});
|
|
1840
|
+
this._columns = a;
|
|
1841
|
+
}
|
|
1842
|
+
} else
|
|
1843
|
+
this._columns = [...e];
|
|
1780
1844
|
}
|
|
1781
1845
|
}
|
|
1782
1846
|
/** Execute all plugin afterRender hooks */
|
|
@@ -1784,8 +1848,8 @@ class I extends HTMLElement {
|
|
|
1784
1848
|
this.#t?.afterRender();
|
|
1785
1849
|
}
|
|
1786
1850
|
/** Recompute row model via plugin hooks (grouping, tree, filtering, etc.). */
|
|
1787
|
-
#
|
|
1788
|
-
|
|
1851
|
+
#k() {
|
|
1852
|
+
Z(this);
|
|
1789
1853
|
const e = Array.isArray(this.#r) ? [...this.#r] : [], t = this.#t?.processRows(e) ?? e;
|
|
1790
1854
|
this._rows = t;
|
|
1791
1855
|
}
|
|
@@ -1810,39 +1874,39 @@ class I extends HTMLElement {
|
|
|
1810
1874
|
#u() {
|
|
1811
1875
|
const e = this.#g ? { ...this.#g } : {};
|
|
1812
1876
|
let t = Array.isArray(e.columns) ? [...e.columns] : [];
|
|
1813
|
-
const n = (this.__lightDomColumnsCache || []).map((
|
|
1814
|
-
...
|
|
1877
|
+
const n = (this.__lightDomColumnsCache || []).map((s) => ({
|
|
1878
|
+
...s
|
|
1815
1879
|
}));
|
|
1816
1880
|
if (n.length) {
|
|
1817
|
-
const
|
|
1818
|
-
t.forEach((
|
|
1819
|
-
const r = i
|
|
1820
|
-
r ? (
|
|
1881
|
+
const s = {};
|
|
1882
|
+
t.forEach((i) => s[i.field] = i), n.forEach((i) => {
|
|
1883
|
+
const r = s[i.field];
|
|
1884
|
+
r ? (i.header && !r.header && (r.header = i.header), i.type && !r.type && (r.type = i.type), r.sortable = r.sortable || i.sortable, i.resizable && (r.resizable = !0), i.editable && (r.editable = !0)) : (t.push(i), s[i.field] = i);
|
|
1821
1885
|
});
|
|
1822
1886
|
}
|
|
1823
|
-
if (this.#l && this.#l.length && (t = [...this.#l]), (!t || t.length === 0) && this._rows.length && (t =
|
|
1887
|
+
if (this.#l && this.#l.length && (t = [...this.#l]), (!t || t.length === 0) && this._rows.length && (t = ue(this._rows).columns), t.length) {
|
|
1824
1888
|
t.forEach((r) => {
|
|
1825
1889
|
r.sortable === void 0 && (r.sortable = !0), r.resizable === void 0 && (r.resizable = !0);
|
|
1826
1890
|
});
|
|
1827
|
-
const
|
|
1828
|
-
|
|
1891
|
+
const s = this.#o.columns;
|
|
1892
|
+
s?.some((r) => r.__compiledView || r.__compiledEditor) ? e.columns = s : e.columns = t;
|
|
1829
1893
|
} else {
|
|
1830
|
-
const
|
|
1831
|
-
|
|
1894
|
+
const s = this.#o.columns;
|
|
1895
|
+
s?.some((i) => i.__compiledView || i.__compiledEditor) && (e.columns = s);
|
|
1832
1896
|
}
|
|
1833
|
-
this.#v && (e.fitMode = this.#v), e.fitMode || (e.fitMode = "stretch"), this.#
|
|
1834
|
-
|
|
1897
|
+
this.#v && (e.fitMode = this.#v), e.fitMode || (e.fitMode = "stretch"), this.#y && (e.editOn = this.#y), e.columnState && !this.#h && (this.#h = e.columnState), this.#o = e, e.fitMode === "fixed" && this._columns.forEach((s) => {
|
|
1898
|
+
s.width == null && (s.width = 80);
|
|
1835
1899
|
});
|
|
1836
1900
|
}
|
|
1837
1901
|
// ---------------- Delegate Wrappers ----------------
|
|
1838
|
-
#
|
|
1839
|
-
this.#
|
|
1902
|
+
#z(e, t, n = this.__rowRenderEpoch) {
|
|
1903
|
+
this.#P || (this.#P = (s, i, r) => this.#t?.renderRow(s, i, r) ?? !1), Be(this, e, t, n, this.#P);
|
|
1840
1904
|
}
|
|
1841
|
-
#
|
|
1842
|
-
|
|
1905
|
+
#se(e, t) {
|
|
1906
|
+
L(this, e, t);
|
|
1843
1907
|
}
|
|
1844
|
-
#
|
|
1845
|
-
|
|
1908
|
+
#D(e, t) {
|
|
1909
|
+
We(this, e, t);
|
|
1846
1910
|
}
|
|
1847
1911
|
// ---------------- Core Helpers ----------------
|
|
1848
1912
|
#d() {
|
|
@@ -1850,32 +1914,32 @@ class I extends HTMLElement {
|
|
|
1850
1914
|
return;
|
|
1851
1915
|
const e = this.#g?.columns || this.#l || [];
|
|
1852
1916
|
if (e.length) {
|
|
1853
|
-
const n = new Map(this._columns.filter((
|
|
1854
|
-
...
|
|
1855
|
-
hidden: n.get(
|
|
1917
|
+
const n = new Map(this._columns.filter((i) => i.hidden).map((i) => [i.field, !0])), s = e.map((i) => ({
|
|
1918
|
+
...i,
|
|
1919
|
+
hidden: n.get(i.field) ?? i.hidden
|
|
1856
1920
|
}));
|
|
1857
|
-
this._columns =
|
|
1921
|
+
this._columns = s;
|
|
1858
1922
|
}
|
|
1859
|
-
if (this.#
|
|
1923
|
+
if (this.#ne(), this.#u(), this.#K(), this.#O = [...this._columns], this.#k(), this.#H(), this.#h) {
|
|
1860
1924
|
const n = this.#h;
|
|
1861
|
-
this.#h = void 0, this.#
|
|
1925
|
+
this.#h = void 0, this.#G(n);
|
|
1862
1926
|
}
|
|
1863
|
-
this.#
|
|
1927
|
+
this.#L(), this.updateTemplate(), this.refreshVirtualWindow(!0), this.#o.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => this.#F()), this.bodyEl && (this.bodyEl.style.display = "", this.bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#b());
|
|
1864
1928
|
}
|
|
1865
1929
|
/** Internal method to apply column state without triggering setup loop */
|
|
1866
|
-
#
|
|
1867
|
-
const t = this.#
|
|
1868
|
-
|
|
1869
|
-
for (const
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1930
|
+
#G(e) {
|
|
1931
|
+
const t = this.#o.columns ?? [], n = this.#t?.getAll() ?? [];
|
|
1932
|
+
ye(this, e, t, n);
|
|
1933
|
+
for (const s of e.columns) {
|
|
1934
|
+
const i = t.find((r) => r.field === s.field);
|
|
1935
|
+
i && (i.hidden = !s.visible);
|
|
1872
1936
|
}
|
|
1873
1937
|
}
|
|
1874
|
-
#
|
|
1938
|
+
#ie() {
|
|
1875
1939
|
return this._rows.length <= this.virtualization.bypassThreshold;
|
|
1876
1940
|
}
|
|
1877
|
-
#
|
|
1878
|
-
if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#
|
|
1941
|
+
#re(e) {
|
|
1942
|
+
if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#E) {
|
|
1879
1943
|
const t = this.virtualization.container, n = {
|
|
1880
1944
|
scrollTop: e,
|
|
1881
1945
|
scrollLeft: t?.scrollLeft ?? 0,
|
|
@@ -1889,7 +1953,7 @@ class I extends HTMLElement {
|
|
|
1889
1953
|
}
|
|
1890
1954
|
}
|
|
1891
1955
|
findHeaderRow() {
|
|
1892
|
-
return this.#
|
|
1956
|
+
return this.#n.querySelector(".header-row");
|
|
1893
1957
|
}
|
|
1894
1958
|
findRenderedRowElement(e) {
|
|
1895
1959
|
return Array.from(this.bodyEl.querySelectorAll(".data-grid-row")).find((t) => {
|
|
@@ -1901,16 +1965,16 @@ class I extends HTMLElement {
|
|
|
1901
1965
|
* Dispatch a cell click event to the plugin system.
|
|
1902
1966
|
* Returns true if any plugin handled the event.
|
|
1903
1967
|
*/
|
|
1904
|
-
dispatchCellClick(e, t, n,
|
|
1905
|
-
const
|
|
1906
|
-
if (!
|
|
1968
|
+
dispatchCellClick(e, t, n, s) {
|
|
1969
|
+
const i = this._rows[t], r = this._columns[n];
|
|
1970
|
+
if (!i || !r) return !1;
|
|
1907
1971
|
const a = {
|
|
1908
|
-
row:
|
|
1972
|
+
row: i,
|
|
1909
1973
|
rowIndex: t,
|
|
1910
1974
|
colIndex: n,
|
|
1911
1975
|
field: r.field,
|
|
1912
|
-
value:
|
|
1913
|
-
cellEl:
|
|
1976
|
+
value: i[r.field],
|
|
1977
|
+
cellEl: s,
|
|
1914
1978
|
originalEvent: e
|
|
1915
1979
|
};
|
|
1916
1980
|
return this.#t?.onCellClick(a) ?? !1;
|
|
@@ -1920,16 +1984,16 @@ class I extends HTMLElement {
|
|
|
1920
1984
|
* Returns true if any plugin handled the event.
|
|
1921
1985
|
*/
|
|
1922
1986
|
dispatchHeaderClick(e, t, n) {
|
|
1923
|
-
const
|
|
1924
|
-
if (!
|
|
1925
|
-
const
|
|
1987
|
+
const s = this._columns[t];
|
|
1988
|
+
if (!s) return !1;
|
|
1989
|
+
const i = {
|
|
1926
1990
|
colIndex: t,
|
|
1927
|
-
field:
|
|
1928
|
-
column:
|
|
1991
|
+
field: s.field,
|
|
1992
|
+
column: s,
|
|
1929
1993
|
headerEl: n,
|
|
1930
1994
|
originalEvent: e
|
|
1931
1995
|
};
|
|
1932
|
-
return this.#t?.onHeaderClick(
|
|
1996
|
+
return this.#t?.onHeaderClick(i) ?? !1;
|
|
1933
1997
|
}
|
|
1934
1998
|
/**
|
|
1935
1999
|
* Dispatch a keyboard event to the plugin system.
|
|
@@ -1942,51 +2006,51 @@ class I extends HTMLElement {
|
|
|
1942
2006
|
* Build a CellMouseEvent from a native MouseEvent.
|
|
1943
2007
|
* Extracts cell/row information from the event target.
|
|
1944
2008
|
*/
|
|
1945
|
-
#
|
|
2009
|
+
#N(e, t) {
|
|
1946
2010
|
let n = null;
|
|
1947
|
-
const
|
|
1948
|
-
if (
|
|
1949
|
-
const
|
|
1950
|
-
|
|
1951
|
-
}
|
|
1952
|
-
const
|
|
1953
|
-
let l,
|
|
1954
|
-
return
|
|
2011
|
+
const s = e.composedPath?.();
|
|
2012
|
+
if (s && s.length > 0 ? n = s[0] : n = e.target, n && !this.#n.contains(n)) {
|
|
2013
|
+
const f = this.#n.elementFromPoint(e.clientX, e.clientY);
|
|
2014
|
+
f && (n = f);
|
|
2015
|
+
}
|
|
2016
|
+
const i = n?.closest?.("[data-col]"), r = n?.closest?.(".data-grid-row"), a = n?.closest?.(".header-row");
|
|
2017
|
+
let l, d, u, g, h, c;
|
|
2018
|
+
return i && (l = parseInt(i.getAttribute("data-row") ?? "-1", 10), d = parseInt(i.getAttribute("data-col") ?? "-1", 10), l >= 0 && d >= 0 && (u = this._rows[l], c = this._columns[d], g = c?.field, h = u && g ? u[g] : void 0)), {
|
|
1955
2019
|
type: t,
|
|
1956
|
-
row:
|
|
2020
|
+
row: u,
|
|
1957
2021
|
rowIndex: l !== void 0 && l >= 0 ? l : void 0,
|
|
1958
|
-
colIndex:
|
|
2022
|
+
colIndex: d !== void 0 && d >= 0 ? d : void 0,
|
|
1959
2023
|
field: g,
|
|
1960
2024
|
value: h,
|
|
1961
2025
|
column: c,
|
|
1962
2026
|
originalEvent: e,
|
|
1963
|
-
cellElement:
|
|
2027
|
+
cellElement: i ?? void 0,
|
|
1964
2028
|
rowElement: r ?? void 0,
|
|
1965
2029
|
isHeader: !!a,
|
|
1966
|
-
cell: l !== void 0 &&
|
|
2030
|
+
cell: l !== void 0 && d !== void 0 && l >= 0 && d >= 0 ? { row: l, col: d } : void 0
|
|
1967
2031
|
};
|
|
1968
2032
|
}
|
|
1969
2033
|
/**
|
|
1970
2034
|
* Handle mousedown events and dispatch to plugin system.
|
|
1971
2035
|
*/
|
|
1972
|
-
#
|
|
1973
|
-
const t = this.#
|
|
2036
|
+
#le(e) {
|
|
2037
|
+
const t = this.#N(e, "mousedown");
|
|
1974
2038
|
(this.#t?.onCellMouseDown(t) ?? !1) && (this.#R = !0);
|
|
1975
2039
|
}
|
|
1976
2040
|
/**
|
|
1977
2041
|
* Handle mousemove events (only when dragging).
|
|
1978
2042
|
*/
|
|
1979
|
-
#
|
|
2043
|
+
#ae(e) {
|
|
1980
2044
|
if (!this.#R) return;
|
|
1981
|
-
const t = this.#
|
|
2045
|
+
const t = this.#N(e, "mousemove");
|
|
1982
2046
|
this.#t?.onCellMouseMove(t);
|
|
1983
2047
|
}
|
|
1984
2048
|
/**
|
|
1985
2049
|
* Handle mouseup events.
|
|
1986
2050
|
*/
|
|
1987
|
-
#
|
|
2051
|
+
#ce(e) {
|
|
1988
2052
|
if (!this.#R) return;
|
|
1989
|
-
const t = this.#
|
|
2053
|
+
const t = this.#N(e, "mouseup");
|
|
1990
2054
|
this.#t?.onCellMouseUp(t), this.#R = !1;
|
|
1991
2055
|
}
|
|
1992
2056
|
// API consumed by internal utils (rows.ts)
|
|
@@ -2000,20 +2064,20 @@ class I extends HTMLElement {
|
|
|
2000
2064
|
this._changedRowIndices.clear(), e || this.#s("changed-rows-reset", { rows: this.changedRows, indices: this.changedRowIndices }), this.rowPool.forEach((t) => t.classList.remove("changed"));
|
|
2001
2065
|
}
|
|
2002
2066
|
async beginBulkEdit(e) {
|
|
2003
|
-
this.#
|
|
2067
|
+
this.#se(e, this._rows[e]);
|
|
2004
2068
|
}
|
|
2005
2069
|
async commitActiveRowEdit() {
|
|
2006
|
-
this.activeEditRows !== -1 && this.#
|
|
2070
|
+
this.activeEditRows !== -1 && this.#D(this.activeEditRows, !1);
|
|
2007
2071
|
}
|
|
2008
2072
|
async ready() {
|
|
2009
|
-
return this.#
|
|
2073
|
+
return this.#I;
|
|
2010
2074
|
}
|
|
2011
2075
|
async forceLayout() {
|
|
2012
2076
|
this.#d(), await new Promise((e) => requestAnimationFrame(() => requestAnimationFrame(e)));
|
|
2013
2077
|
}
|
|
2014
2078
|
/** Public method: returns a frozen snapshot of the merged effective configuration */
|
|
2015
2079
|
async getConfig() {
|
|
2016
|
-
return Object.freeze({ ...this.#
|
|
2080
|
+
return Object.freeze({ ...this.#o || {} });
|
|
2017
2081
|
}
|
|
2018
2082
|
// ---------------- Column Visibility API ----------------
|
|
2019
2083
|
/**
|
|
@@ -2023,11 +2087,11 @@ class I extends HTMLElement {
|
|
|
2023
2087
|
* @returns True if visibility was changed, false if column not found or locked
|
|
2024
2088
|
*/
|
|
2025
2089
|
setColumnVisible(e, t) {
|
|
2026
|
-
const n = this.#
|
|
2027
|
-
if (!
|
|
2090
|
+
const n = this.#o.columns, s = n?.find((a) => a.field === e);
|
|
2091
|
+
if (!s || !t && s.lockVisible || !t && (n ?? []).filter((l) => !l.hidden && l.field !== e).length === 0)
|
|
2028
2092
|
return !1;
|
|
2029
|
-
const
|
|
2030
|
-
return
|
|
2093
|
+
const i = !!s.hidden, r = !t;
|
|
2094
|
+
return i !== r ? (s.hidden = r, this.#s("column-visibility", {
|
|
2031
2095
|
field: e,
|
|
2032
2096
|
visible: t,
|
|
2033
2097
|
visibleColumns: (n ?? []).filter((a) => !a.hidden).map((a) => a.field)
|
|
@@ -2039,8 +2103,8 @@ class I extends HTMLElement {
|
|
|
2039
2103
|
* @returns True if visibility was toggled, false if column not found or locked
|
|
2040
2104
|
*/
|
|
2041
2105
|
toggleColumnVisibility(e) {
|
|
2042
|
-
const
|
|
2043
|
-
return this.setColumnVisible(e,
|
|
2106
|
+
const s = !!this.#o.columns?.find((i) => i.field === e)?.hidden;
|
|
2107
|
+
return this.setColumnVisible(e, s);
|
|
2044
2108
|
}
|
|
2045
2109
|
/**
|
|
2046
2110
|
* Check if a column is currently visible.
|
|
@@ -2048,14 +2112,14 @@ class I extends HTMLElement {
|
|
|
2048
2112
|
* @returns True if visible, false if hidden or not found
|
|
2049
2113
|
*/
|
|
2050
2114
|
isColumnVisible(e) {
|
|
2051
|
-
const n = this.#
|
|
2115
|
+
const n = this.#o.columns?.find((s) => s.field === e);
|
|
2052
2116
|
return n ? !n.hidden : !1;
|
|
2053
2117
|
}
|
|
2054
2118
|
/**
|
|
2055
2119
|
* Show all columns.
|
|
2056
2120
|
*/
|
|
2057
2121
|
showAllColumns() {
|
|
2058
|
-
const e = this.#
|
|
2122
|
+
const e = this.#o.columns;
|
|
2059
2123
|
e?.some((n) => n.hidden) && (e?.forEach((n) => {
|
|
2060
2124
|
n.hidden = !1;
|
|
2061
2125
|
}), this.#s("column-visibility", {
|
|
@@ -2069,7 +2133,7 @@ class I extends HTMLElement {
|
|
|
2069
2133
|
* @returns Array of all field names with their visibility status
|
|
2070
2134
|
*/
|
|
2071
2135
|
getAllColumns() {
|
|
2072
|
-
return (this.#
|
|
2136
|
+
return (this.#o.columns ?? []).map((t) => ({
|
|
2073
2137
|
field: t.field,
|
|
2074
2138
|
header: t.header || t.field,
|
|
2075
2139
|
visible: !t.hidden,
|
|
@@ -2083,14 +2147,14 @@ class I extends HTMLElement {
|
|
|
2083
2147
|
*/
|
|
2084
2148
|
setColumnOrder(e) {
|
|
2085
2149
|
if (!e.length) return;
|
|
2086
|
-
const t = new Map(this._columns.map((
|
|
2087
|
-
for (const
|
|
2088
|
-
const
|
|
2089
|
-
|
|
2150
|
+
const t = new Map(this._columns.map((s) => [s.field, s])), n = [];
|
|
2151
|
+
for (const s of e) {
|
|
2152
|
+
const i = t.get(s);
|
|
2153
|
+
i && (n.push(i), t.delete(s));
|
|
2090
2154
|
}
|
|
2091
|
-
for (const
|
|
2092
|
-
n.push(
|
|
2093
|
-
this._columns = n, this.#
|
|
2155
|
+
for (const s of t.values())
|
|
2156
|
+
n.push(s);
|
|
2157
|
+
this._columns = n, this.#L(), this.updateTemplate(), this.refreshVirtualWindow(!0);
|
|
2094
2158
|
}
|
|
2095
2159
|
/**
|
|
2096
2160
|
* Get the current column order as an array of field names.
|
|
@@ -2106,14 +2170,14 @@ class I extends HTMLElement {
|
|
|
2106
2170
|
*/
|
|
2107
2171
|
getColumnState() {
|
|
2108
2172
|
const e = this.#t?.getAll() ?? [];
|
|
2109
|
-
return
|
|
2173
|
+
return he(this, e);
|
|
2110
2174
|
}
|
|
2111
2175
|
/**
|
|
2112
2176
|
* Set the column state, restoring order, width, visibility, sort, and plugin state.
|
|
2113
2177
|
* Use this to restore previously saved column state.
|
|
2114
2178
|
*/
|
|
2115
2179
|
set columnState(e) {
|
|
2116
|
-
e && (this.#h = e, this.#i && this.#
|
|
2180
|
+
e && (this.#h = e, this.#i && this.#de(e));
|
|
2117
2181
|
}
|
|
2118
2182
|
/**
|
|
2119
2183
|
* Get the current column state.
|
|
@@ -2124,10 +2188,10 @@ class I extends HTMLElement {
|
|
|
2124
2188
|
/**
|
|
2125
2189
|
* Apply column state internally.
|
|
2126
2190
|
*/
|
|
2127
|
-
#
|
|
2128
|
-
(this.#
|
|
2191
|
+
#de(e) {
|
|
2192
|
+
(this.#o.columns ?? []).forEach((n) => {
|
|
2129
2193
|
n.hidden = !1;
|
|
2130
|
-
}), this.#
|
|
2194
|
+
}), this.#G(e), this.#d();
|
|
2131
2195
|
}
|
|
2132
2196
|
/**
|
|
2133
2197
|
* Request a state change event to be emitted.
|
|
@@ -2136,62 +2200,134 @@ class I extends HTMLElement {
|
|
|
2136
2200
|
* The event is debounced to avoid excessive events during drag operations.
|
|
2137
2201
|
*/
|
|
2138
2202
|
requestStateChange() {
|
|
2139
|
-
this.#
|
|
2203
|
+
this.#M || (this.#M = Ce(
|
|
2140
2204
|
this,
|
|
2141
2205
|
() => this.#t?.getAll() ?? [],
|
|
2142
2206
|
(e) => this.#s("column-state-change", e)
|
|
2143
|
-
)), this.#
|
|
2207
|
+
)), this.#M();
|
|
2144
2208
|
}
|
|
2145
2209
|
/**
|
|
2146
2210
|
* Reset column state to initial configuration.
|
|
2147
2211
|
* Clears all user modifications (order, width, visibility, sort).
|
|
2148
2212
|
*/
|
|
2149
2213
|
resetColumnState() {
|
|
2150
|
-
this.#h = void 0, (this.#
|
|
2214
|
+
this.#h = void 0, (this.#o.columns ?? []).forEach((n) => {
|
|
2151
2215
|
n.hidden = !1;
|
|
2152
2216
|
}), this.sortState = null, this.__originalOrder = [], this.#u(), this.#d();
|
|
2153
2217
|
const t = this.#t?.getAll() ?? [];
|
|
2154
2218
|
for (const n of t)
|
|
2155
2219
|
if (n.applyColumnState)
|
|
2156
|
-
for (const
|
|
2157
|
-
n.applyColumnState(
|
|
2158
|
-
field:
|
|
2220
|
+
for (const s of this._columns)
|
|
2221
|
+
n.applyColumnState(s.field, {
|
|
2222
|
+
field: s.field,
|
|
2159
2223
|
order: 0,
|
|
2160
2224
|
visible: !0
|
|
2161
2225
|
});
|
|
2162
2226
|
this.requestStateChange();
|
|
2163
2227
|
}
|
|
2164
2228
|
// ---------------- Shell / Tool Panel API ----------------
|
|
2229
|
+
/**
|
|
2230
|
+
* Check if the tool panel is currently open.
|
|
2231
|
+
*/
|
|
2232
|
+
get isToolPanelOpen() {
|
|
2233
|
+
return this.#e.isPanelOpen;
|
|
2234
|
+
}
|
|
2165
2235
|
/**
|
|
2166
2236
|
* Get the currently active tool panel ID, or null if none is open.
|
|
2237
|
+
* @deprecated Use isToolPanelOpen and expandedToolPanelSections instead.
|
|
2167
2238
|
*/
|
|
2168
2239
|
get activeToolPanel() {
|
|
2169
2240
|
return this.#e.activePanel;
|
|
2170
2241
|
}
|
|
2171
2242
|
/**
|
|
2172
|
-
*
|
|
2173
|
-
* Closes any currently open panel first.
|
|
2243
|
+
* Get the IDs of expanded accordion sections.
|
|
2174
2244
|
*/
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2245
|
+
get expandedToolPanelSections() {
|
|
2246
|
+
return [...this.#e.expandedSections];
|
|
2247
|
+
}
|
|
2248
|
+
/**
|
|
2249
|
+
* Open the tool panel (accordion view with all registered panels).
|
|
2250
|
+
*/
|
|
2251
|
+
openToolPanel() {
|
|
2252
|
+
if (this.#e.isPanelOpen) return;
|
|
2253
|
+
if (this.#e.isPanelOpen = !0, this.#e.expandedSections.size === 0 && this.#e.toolPanels.size > 0) {
|
|
2254
|
+
const n = [...this.#e.toolPanels.values()].sort(
|
|
2255
|
+
(s, i) => (s.order ?? 100) - (i.order ?? 100)
|
|
2256
|
+
)[0];
|
|
2257
|
+
n && this.#e.expandedSections.add(n.id);
|
|
2179
2258
|
}
|
|
2180
|
-
|
|
2259
|
+
se(this.#n, this.#e), ie(this.#n, this.#e);
|
|
2260
|
+
const e = {
|
|
2261
|
+
expand: this.#o?.icons?.expand ?? S.expand,
|
|
2262
|
+
collapse: this.#o?.icons?.collapse ?? S.collapse
|
|
2263
|
+
};
|
|
2264
|
+
Je(this.#n, this.#e, e), this.#s("tool-panel-open", { sections: this.expandedToolPanelSections });
|
|
2181
2265
|
}
|
|
2182
2266
|
/**
|
|
2183
|
-
* Close the
|
|
2267
|
+
* Close the tool panel.
|
|
2184
2268
|
*/
|
|
2185
2269
|
closeToolPanel() {
|
|
2186
|
-
if (
|
|
2187
|
-
|
|
2188
|
-
|
|
2270
|
+
if (this.#e.isPanelOpen) {
|
|
2271
|
+
for (const e of this.#e.panelCleanups.values())
|
|
2272
|
+
e();
|
|
2273
|
+
this.#e.panelCleanups.clear(), this.#e.activePanelCleanup && (this.#e.activePanelCleanup(), this.#e.activePanelCleanup = null);
|
|
2274
|
+
for (const e of this.#e.toolPanels.values())
|
|
2275
|
+
e.onClose?.();
|
|
2276
|
+
this.#e.isPanelOpen = !1, se(this.#n, this.#e), ie(this.#n, this.#e), this.#s("tool-panel-close", {});
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
/**
|
|
2280
|
+
* Toggle the tool panel open/closed.
|
|
2281
|
+
*/
|
|
2282
|
+
toggleToolPanel() {
|
|
2283
|
+
this.#e.isPanelOpen ? this.closeToolPanel() : this.openToolPanel();
|
|
2189
2284
|
}
|
|
2190
2285
|
/**
|
|
2191
|
-
* Toggle
|
|
2286
|
+
* Toggle an accordion section expanded/collapsed.
|
|
2287
|
+
* Only one section can be expanded at a time (exclusive accordion).
|
|
2288
|
+
* When there's only one panel, toggling is disabled (always expanded).
|
|
2192
2289
|
*/
|
|
2193
|
-
|
|
2194
|
-
|
|
2290
|
+
toggleToolPanelSection(e) {
|
|
2291
|
+
const t = this.#e.toolPanels.get(e);
|
|
2292
|
+
if (!t) {
|
|
2293
|
+
console.warn(`[tbw-grid] Tool panel section "${e}" not found`);
|
|
2294
|
+
return;
|
|
2295
|
+
}
|
|
2296
|
+
if (this.#e.toolPanels.size === 1)
|
|
2297
|
+
return;
|
|
2298
|
+
const n = this.#e.expandedSections.has(e);
|
|
2299
|
+
if (n) {
|
|
2300
|
+
const s = this.#e.panelCleanups.get(e);
|
|
2301
|
+
s && (s(), this.#e.panelCleanups.delete(e)), t.onClose?.(), this.#e.expandedSections.delete(e), this.#q(e, !1);
|
|
2302
|
+
} else {
|
|
2303
|
+
for (const [s, i] of this.#e.toolPanels)
|
|
2304
|
+
if (s !== e && this.#e.expandedSections.has(s)) {
|
|
2305
|
+
const r = this.#e.panelCleanups.get(s);
|
|
2306
|
+
r && (r(), this.#e.panelCleanups.delete(s)), i.onClose?.(), this.#e.expandedSections.delete(s), this.#q(s, !1);
|
|
2307
|
+
const a = this.#n.querySelector(`[data-section="${s}"] .tbw-accordion-content`);
|
|
2308
|
+
a && (a.innerHTML = "");
|
|
2309
|
+
}
|
|
2310
|
+
this.#e.expandedSections.add(e), this.#q(e, !0), this.#he(e);
|
|
2311
|
+
}
|
|
2312
|
+
this.#s("tool-panel-section-toggle", { id: e, expanded: !n });
|
|
2313
|
+
}
|
|
2314
|
+
/**
|
|
2315
|
+
* Update accordion section visual state.
|
|
2316
|
+
*/
|
|
2317
|
+
#q(e, t) {
|
|
2318
|
+
const n = this.#n.querySelector(`[data-section="${e}"]`);
|
|
2319
|
+
n && n.classList.toggle("expanded", t);
|
|
2320
|
+
}
|
|
2321
|
+
/**
|
|
2322
|
+
* Render content for a single accordion section.
|
|
2323
|
+
*/
|
|
2324
|
+
#he(e) {
|
|
2325
|
+
const t = this.#e.toolPanels.get(e);
|
|
2326
|
+
if (!t?.render) return;
|
|
2327
|
+
const n = this.#n.querySelector(`[data-section="${e}"] .tbw-accordion-content`);
|
|
2328
|
+
if (!n) return;
|
|
2329
|
+
const s = t.render(n);
|
|
2330
|
+
s && this.#e.panelCleanups.set(e, s);
|
|
2195
2331
|
}
|
|
2196
2332
|
/**
|
|
2197
2333
|
* Get registered tool panel definitions.
|
|
@@ -2229,20 +2365,20 @@ class I extends HTMLElement {
|
|
|
2229
2365
|
console.warn(`[tbw-grid] Header content "${e.id}" already registered`);
|
|
2230
2366
|
return;
|
|
2231
2367
|
}
|
|
2232
|
-
this.#e.headerContents.set(e.id, e), this.#c &&
|
|
2368
|
+
this.#e.headerContents.set(e.id, e), this.#c && ne(this.#n, this.#e);
|
|
2233
2369
|
}
|
|
2234
2370
|
/**
|
|
2235
2371
|
* Unregister custom header content.
|
|
2236
2372
|
*/
|
|
2237
2373
|
unregisterHeaderContent(e) {
|
|
2238
2374
|
const t = this.#e.headerContentCleanups.get(e);
|
|
2239
|
-
t && (t(), this.#e.headerContentCleanups.delete(e)), this.#e.headerContents.get(e)?.onDestroy?.(), this.#e.headerContents.delete(e), this.#
|
|
2375
|
+
t && (t(), this.#e.headerContentCleanups.delete(e)), this.#e.headerContents.get(e)?.onDestroy?.(), this.#e.headerContents.delete(e), this.#n.querySelector(`[data-header-content="${e}"]`)?.remove();
|
|
2240
2376
|
}
|
|
2241
2377
|
/**
|
|
2242
2378
|
* Get all registered toolbar buttons.
|
|
2243
2379
|
*/
|
|
2244
2380
|
getToolbarButtons() {
|
|
2245
|
-
return
|
|
2381
|
+
return Qe(this.#o?.shell, this.#e);
|
|
2246
2382
|
}
|
|
2247
2383
|
/**
|
|
2248
2384
|
* Register a custom toolbar button programmatically.
|
|
@@ -2267,8 +2403,8 @@ class I extends HTMLElement {
|
|
|
2267
2403
|
setToolbarButtonDisabled(e, t) {
|
|
2268
2404
|
const n = this.#e.toolbarButtons.get(e);
|
|
2269
2405
|
n && (n.disabled = t);
|
|
2270
|
-
const
|
|
2271
|
-
|
|
2406
|
+
const s = this.#n.querySelector(`[data-btn="${e}"]`);
|
|
2407
|
+
s && (s.disabled = t);
|
|
2272
2408
|
}
|
|
2273
2409
|
/**
|
|
2274
2410
|
* Re-parse light DOM shell elements and refresh shell header.
|
|
@@ -2281,7 +2417,7 @@ class I extends HTMLElement {
|
|
|
2281
2417
|
* Internal shell header refresh.
|
|
2282
2418
|
*/
|
|
2283
2419
|
#m() {
|
|
2284
|
-
|
|
2420
|
+
oe(this, this.#e), this.#U(), this.#V();
|
|
2285
2421
|
}
|
|
2286
2422
|
// ---------------- Virtual Window ----------------
|
|
2287
2423
|
/**
|
|
@@ -2292,36 +2428,36 @@ class I extends HTMLElement {
|
|
|
2292
2428
|
if (!this.bodyEl) return;
|
|
2293
2429
|
const t = this._rows.length;
|
|
2294
2430
|
if (!this.virtualization.enabled) {
|
|
2295
|
-
this.#
|
|
2431
|
+
this.#z(0, t), this.#b();
|
|
2296
2432
|
return;
|
|
2297
2433
|
}
|
|
2298
|
-
if (this.#
|
|
2299
|
-
this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#
|
|
2434
|
+
if (this.#ie()) {
|
|
2435
|
+
this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#z(0, t, this.__rowRenderEpoch), this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * this.virtualization.rowHeight}px`), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), this.#b();
|
|
2300
2436
|
return;
|
|
2301
2437
|
}
|
|
2302
|
-
const n = this.virtualization.container ?? this,
|
|
2303
|
-
let l = Math.floor(a / r),
|
|
2304
|
-
const
|
|
2305
|
-
for (;
|
|
2306
|
-
const R = this.#t?.getExtraHeightBefore?.(l) ?? 0,
|
|
2307
|
-
if (
|
|
2308
|
-
l =
|
|
2438
|
+
const n = this.virtualization.container ?? this, i = (this.virtualization.viewportEl ?? n).clientHeight, r = this.virtualization.rowHeight, a = n.scrollTop;
|
|
2439
|
+
let l = Math.floor(a / r), d = 0;
|
|
2440
|
+
const u = 10;
|
|
2441
|
+
for (; d < u; ) {
|
|
2442
|
+
const R = this.#t?.getExtraHeightBefore?.(l) ?? 0, C = Math.floor((a - R) / r);
|
|
2443
|
+
if (C >= l || C < 0) break;
|
|
2444
|
+
l = C, d++;
|
|
2309
2445
|
}
|
|
2310
2446
|
l = l - l % 2, l < 0 && (l = 0);
|
|
2311
2447
|
const g = this.#t?.adjustVirtualStart(l, a, r);
|
|
2312
2448
|
g !== void 0 && g < l && (l = g, l = l - l % 2, l < 0 && (l = 0));
|
|
2313
|
-
const h = Math.ceil(
|
|
2449
|
+
const h = Math.ceil(i / r) + 3;
|
|
2314
2450
|
let c = l + h;
|
|
2315
2451
|
c > t && (c = t), this.virtualization.start = l, this.virtualization.end = c;
|
|
2316
|
-
const
|
|
2317
|
-
this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * r + r +
|
|
2318
|
-
const m = this.#t?.getExtraHeightBefore?.(l) ?? 0,
|
|
2319
|
-
this.bodyEl.style.transform = `translateY(${
|
|
2452
|
+
const p = this.#n.querySelector(".tbw-footer")?.offsetHeight ?? 0, w = this.#t?.getExtraHeight() ?? 0;
|
|
2453
|
+
this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * r + r + p + w}px`);
|
|
2454
|
+
const m = this.#t?.getExtraHeightBefore?.(l) ?? 0, y = -(a - l * r - m);
|
|
2455
|
+
this.bodyEl.style.transform = `translateY(${y}px)`, this.#z(l, c, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), e && this.#b();
|
|
2320
2456
|
}
|
|
2321
2457
|
// ---------------- Render ----------------
|
|
2322
|
-
#
|
|
2323
|
-
|
|
2324
|
-
const e = this.#
|
|
2458
|
+
#U() {
|
|
2459
|
+
oe(this, this.#e);
|
|
2460
|
+
const e = this.#o?.shell, t = Ge(e, this.#e), n = `
|
|
2325
2461
|
<div class="tbw-scroll-area">
|
|
2326
2462
|
<div class="rows-body-wrapper">
|
|
2327
2463
|
<div class="rows-body">
|
|
@@ -2341,15 +2477,18 @@ class I extends HTMLElement {
|
|
|
2341
2477
|
</div>
|
|
2342
2478
|
`;
|
|
2343
2479
|
if (t) {
|
|
2344
|
-
const
|
|
2345
|
-
|
|
2480
|
+
const s = this.#o?.icons?.toolPanel ?? S.toolPanel, i = {
|
|
2481
|
+
expand: this.#o?.icons?.expand ?? S.expand,
|
|
2482
|
+
collapse: this.#o?.icons?.collapse ?? S.collapse
|
|
2483
|
+
}, r = Ue(e, this.#e, s), a = Xe(e, this.#e, n, i);
|
|
2484
|
+
this.#n.innerHTML = `
|
|
2346
2485
|
<div class="tbw-grid-root has-shell">
|
|
2347
|
-
${
|
|
2348
|
-
${
|
|
2486
|
+
${r}
|
|
2487
|
+
${a}
|
|
2349
2488
|
</div>
|
|
2350
|
-
`, this.#
|
|
2489
|
+
`, this.#ue(), this.#c = !0;
|
|
2351
2490
|
} else
|
|
2352
|
-
this.#
|
|
2491
|
+
this.#n.innerHTML = `
|
|
2353
2492
|
<div class="tbw-grid-root">
|
|
2354
2493
|
<div class="tbw-grid-content">
|
|
2355
2494
|
${n}
|
|
@@ -2360,28 +2499,30 @@ class I extends HTMLElement {
|
|
|
2360
2499
|
/**
|
|
2361
2500
|
* Set up shell event listeners after render.
|
|
2362
2501
|
*/
|
|
2363
|
-
#
|
|
2364
|
-
|
|
2365
|
-
onPanelToggle: (
|
|
2366
|
-
|
|
2367
|
-
onToolbarButtonClick: (e) => this.#
|
|
2502
|
+
#ue() {
|
|
2503
|
+
je(this.#n, this.#o?.shell, this.#e, {
|
|
2504
|
+
onPanelToggle: () => this.toggleToolPanel(),
|
|
2505
|
+
onSectionToggle: (e) => this.toggleToolPanelSection(e),
|
|
2506
|
+
onToolbarButtonClick: (e) => this.#fe(e)
|
|
2507
|
+
}), this.#T?.(), this.#T = Ye(this.#n, this.#o?.shell, (e) => {
|
|
2508
|
+
this.style.setProperty("--tbw-tool-panel-width", `${e}px`);
|
|
2368
2509
|
});
|
|
2369
2510
|
}
|
|
2370
2511
|
/**
|
|
2371
2512
|
* Handle toolbar button click (for config buttons with action).
|
|
2372
2513
|
*/
|
|
2373
|
-
#
|
|
2374
|
-
const n = (this.#
|
|
2514
|
+
#fe(e) {
|
|
2515
|
+
const n = (this.#o?.shell?.header?.toolbarButtons ?? []).find((i) => i.id === e);
|
|
2375
2516
|
if (n?.action) {
|
|
2376
2517
|
n.action();
|
|
2377
2518
|
return;
|
|
2378
2519
|
}
|
|
2379
|
-
const
|
|
2380
|
-
|
|
2520
|
+
const s = this.#e.toolbarButtons.get(e);
|
|
2521
|
+
s?.action && s.action();
|
|
2381
2522
|
}
|
|
2382
2523
|
}
|
|
2383
|
-
customElements.get(
|
|
2384
|
-
class
|
|
2524
|
+
customElements.get($.tagName) || customElements.define($.tagName, $);
|
|
2525
|
+
class ge {
|
|
2385
2526
|
/** Plugin version - override in subclass if needed */
|
|
2386
2527
|
version = "1.0.0";
|
|
2387
2528
|
/** CSS styles to inject into the grid's shadow DOM */
|
|
@@ -2506,7 +2647,7 @@ class fe {
|
|
|
2506
2647
|
*/
|
|
2507
2648
|
get gridIcons() {
|
|
2508
2649
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
2509
|
-
return { ...
|
|
2650
|
+
return { ...S, ...e };
|
|
2510
2651
|
}
|
|
2511
2652
|
/**
|
|
2512
2653
|
* Resolve an icon value to string or HTMLElement.
|
|
@@ -2536,7 +2677,7 @@ class fe {
|
|
|
2536
2677
|
console.warn(`[tbw-grid:${this.name}] ${e}`);
|
|
2537
2678
|
}
|
|
2538
2679
|
}
|
|
2539
|
-
function
|
|
2680
|
+
function I(o) {
|
|
2540
2681
|
return {
|
|
2541
2682
|
startRow: Math.min(o.startRow, o.endRow),
|
|
2542
2683
|
startCol: Math.min(o.startCol, o.endCol),
|
|
@@ -2544,38 +2685,38 @@ function N(o) {
|
|
|
2544
2685
|
endCol: Math.max(o.startCol, o.endCol)
|
|
2545
2686
|
};
|
|
2546
2687
|
}
|
|
2547
|
-
function
|
|
2548
|
-
const e =
|
|
2688
|
+
function ot(o) {
|
|
2689
|
+
const e = I(o);
|
|
2549
2690
|
return {
|
|
2550
2691
|
from: { row: e.startRow, col: e.startCol },
|
|
2551
2692
|
to: { row: e.endRow, col: e.endCol }
|
|
2552
2693
|
};
|
|
2553
2694
|
}
|
|
2554
|
-
function
|
|
2555
|
-
return o.map(
|
|
2695
|
+
function V(o) {
|
|
2696
|
+
return o.map(ot);
|
|
2556
2697
|
}
|
|
2557
|
-
function
|
|
2558
|
-
const n =
|
|
2698
|
+
function nt(o, e, t) {
|
|
2699
|
+
const n = I(t);
|
|
2559
2700
|
return o >= n.startRow && o <= n.endRow && e >= n.startCol && e <= n.endCol;
|
|
2560
2701
|
}
|
|
2561
|
-
function
|
|
2562
|
-
return t.some((n) =>
|
|
2702
|
+
function re(o, e, t) {
|
|
2703
|
+
return t.some((n) => nt(o, e, n));
|
|
2563
2704
|
}
|
|
2564
|
-
function
|
|
2565
|
-
const e = [], t =
|
|
2705
|
+
function st(o) {
|
|
2706
|
+
const e = [], t = I(o);
|
|
2566
2707
|
for (let n = t.startRow; n <= t.endRow; n++)
|
|
2567
|
-
for (let
|
|
2568
|
-
e.push({ row: n, col:
|
|
2708
|
+
for (let s = t.startCol; s <= t.endCol; s++)
|
|
2709
|
+
e.push({ row: n, col: s });
|
|
2569
2710
|
return e;
|
|
2570
2711
|
}
|
|
2571
|
-
function
|
|
2712
|
+
function it(o) {
|
|
2572
2713
|
const e = /* @__PURE__ */ new Map();
|
|
2573
2714
|
for (const t of o)
|
|
2574
|
-
for (const n of
|
|
2715
|
+
for (const n of st(t))
|
|
2575
2716
|
e.set(`${n.row},${n.col}`, n);
|
|
2576
2717
|
return [...e.values()];
|
|
2577
2718
|
}
|
|
2578
|
-
function
|
|
2719
|
+
function le(o, e) {
|
|
2579
2720
|
return {
|
|
2580
2721
|
startRow: o.row,
|
|
2581
2722
|
startCol: o.col,
|
|
@@ -2583,7 +2724,8 @@ function se(o, e) {
|
|
|
2583
2724
|
endCol: e.col
|
|
2584
2725
|
};
|
|
2585
2726
|
}
|
|
2586
|
-
|
|
2727
|
+
const rt = ':host .selecting .data-grid-row>.cell{user-select:none}:host .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}:host([data-selection-mode="row"]) .cell-focus{outline:none}:host .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}:host .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}';
|
|
2728
|
+
function lt(o, e, t) {
|
|
2587
2729
|
if (o === "cell" && e.selectedCell)
|
|
2588
2730
|
return {
|
|
2589
2731
|
mode: o,
|
|
@@ -2595,15 +2737,15 @@ function nt(o, e, t) {
|
|
|
2595
2737
|
]
|
|
2596
2738
|
};
|
|
2597
2739
|
if (o === "row" && e.selected.size > 0) {
|
|
2598
|
-
const n = [...e.selected].map((
|
|
2599
|
-
from: { row:
|
|
2600
|
-
to: { row:
|
|
2740
|
+
const n = [...e.selected].map((s) => ({
|
|
2741
|
+
from: { row: s, col: 0 },
|
|
2742
|
+
to: { row: s, col: t - 1 }
|
|
2601
2743
|
}));
|
|
2602
2744
|
return { mode: o, ranges: n };
|
|
2603
2745
|
}
|
|
2604
|
-
return o === "range" && e.ranges.length > 0 ? { mode: o, ranges:
|
|
2746
|
+
return o === "range" && e.ranges.length > 0 ? { mode: o, ranges: V(e.ranges) } : { mode: o, ranges: [] };
|
|
2605
2747
|
}
|
|
2606
|
-
class
|
|
2748
|
+
class ft extends ge {
|
|
2607
2749
|
name = "selection";
|
|
2608
2750
|
version = "1.0.0";
|
|
2609
2751
|
get defaultConfig() {
|
|
@@ -2629,15 +2771,15 @@ class lt extends fe {
|
|
|
2629
2771
|
}
|
|
2630
2772
|
// ===== Event Handlers =====
|
|
2631
2773
|
onCellClick(e) {
|
|
2632
|
-
const { rowIndex: t, colIndex: n, originalEvent:
|
|
2633
|
-
if (
|
|
2774
|
+
const { rowIndex: t, colIndex: n, originalEvent: s } = e, { mode: i } = this.config;
|
|
2775
|
+
if (i === "cell")
|
|
2634
2776
|
return this.selectedCell = { row: t, col: n }, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
|
|
2635
|
-
if (
|
|
2777
|
+
if (i === "row")
|
|
2636
2778
|
return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
|
|
2637
|
-
if (
|
|
2638
|
-
const r =
|
|
2779
|
+
if (i === "range") {
|
|
2780
|
+
const r = s.shiftKey, a = s.ctrlKey || s.metaKey;
|
|
2639
2781
|
if (r && this.cellAnchor) {
|
|
2640
|
-
const l =
|
|
2782
|
+
const l = le(this.cellAnchor, { row: t, col: n });
|
|
2641
2783
|
a ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = l : this.ranges.push(l) : this.ranges = [l], this.activeRange = l;
|
|
2642
2784
|
} else if (a) {
|
|
2643
2785
|
const l = {
|
|
@@ -2665,15 +2807,15 @@ class lt extends fe {
|
|
|
2665
2807
|
if (e.key === "Escape")
|
|
2666
2808
|
return t === "cell" ? this.selectedCell = null : t === "row" ? (this.selected.clear(), this.anchor = null) : t === "range" && (this.ranges = [], this.activeRange = null, this.cellAnchor = null), this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
|
|
2667
2809
|
if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
|
|
2668
|
-
const n = this.rows.length,
|
|
2669
|
-
if (n > 0 &&
|
|
2670
|
-
const
|
|
2810
|
+
const n = this.rows.length, s = this.columns.length;
|
|
2811
|
+
if (n > 0 && s > 0) {
|
|
2812
|
+
const i = {
|
|
2671
2813
|
startRow: 0,
|
|
2672
2814
|
startCol: 0,
|
|
2673
2815
|
endRow: n - 1,
|
|
2674
|
-
endCol:
|
|
2816
|
+
endCol: s - 1
|
|
2675
2817
|
};
|
|
2676
|
-
return this.ranges = [
|
|
2818
|
+
return this.ranges = [i], this.activeRange = i, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
|
|
2677
2819
|
}
|
|
2678
2820
|
}
|
|
2679
2821
|
return !1;
|
|
@@ -2684,17 +2826,17 @@ class lt extends fe {
|
|
|
2684
2826
|
this.isDragging = !0;
|
|
2685
2827
|
const t = e.rowIndex, n = e.colIndex;
|
|
2686
2828
|
this.cellAnchor = { row: t, col: n }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
|
|
2687
|
-
const
|
|
2829
|
+
const i = {
|
|
2688
2830
|
startRow: t,
|
|
2689
2831
|
startCol: n,
|
|
2690
2832
|
endRow: t,
|
|
2691
2833
|
endCol: n
|
|
2692
2834
|
};
|
|
2693
|
-
return this.ranges.push(
|
|
2835
|
+
return this.ranges.push(i), this.activeRange = i, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
|
|
2694
2836
|
}
|
|
2695
2837
|
onCellMouseMove(e) {
|
|
2696
2838
|
if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
2697
|
-
const t =
|
|
2839
|
+
const t = le(this.cellAnchor, { row: e.rowIndex, col: e.colIndex });
|
|
2698
2840
|
return this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = t : this.ranges.push(t), this.activeRange = t, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
|
|
2699
2841
|
}
|
|
2700
2842
|
onCellMouseUp(e) {
|
|
@@ -2705,40 +2847,40 @@ class lt extends fe {
|
|
|
2705
2847
|
* Apply selection classes to visible cells/rows.
|
|
2706
2848
|
* Shared by afterRender and onScrollRender.
|
|
2707
2849
|
*/
|
|
2708
|
-
#
|
|
2850
|
+
#n() {
|
|
2709
2851
|
const e = this.shadowRoot;
|
|
2710
2852
|
if (!e) return;
|
|
2711
2853
|
const { mode: t } = this.config;
|
|
2712
|
-
e.querySelectorAll(".cell").forEach((
|
|
2713
|
-
|
|
2854
|
+
e.querySelectorAll(".cell").forEach((i) => {
|
|
2855
|
+
i.classList.remove("selected", "top", "bottom", "first", "last");
|
|
2714
2856
|
});
|
|
2715
|
-
const
|
|
2716
|
-
if (
|
|
2717
|
-
|
|
2718
|
-
}), t === "row" &&
|
|
2719
|
-
const r =
|
|
2720
|
-
a >= 0 && this.selected.has(a) && (
|
|
2857
|
+
const s = e.querySelectorAll(".data-grid-row");
|
|
2858
|
+
if (s.forEach((i) => {
|
|
2859
|
+
i.classList.remove("selected", "row-focus");
|
|
2860
|
+
}), t === "row" && s.forEach((i) => {
|
|
2861
|
+
const r = i.querySelector(".cell[data-row]"), a = parseInt(r?.getAttribute("data-row") ?? "-1", 10);
|
|
2862
|
+
a >= 0 && this.selected.has(a) && (i.classList.add("selected", "row-focus"), i.querySelectorAll(".cell-focus").forEach((l) => l.classList.remove("cell-focus")));
|
|
2721
2863
|
}), t === "range" && this.ranges.length > 0) {
|
|
2722
|
-
const
|
|
2864
|
+
const i = this.activeRange ? I(this.activeRange) : null;
|
|
2723
2865
|
e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
|
|
2724
|
-
const l = parseInt(a.getAttribute("data-row") ?? "-1", 10),
|
|
2725
|
-
l >= 0 &&
|
|
2866
|
+
const l = parseInt(a.getAttribute("data-row") ?? "-1", 10), d = parseInt(a.getAttribute("data-col") ?? "-1", 10);
|
|
2867
|
+
l >= 0 && d >= 0 && re(l, d, this.ranges) && (a.classList.add("selected"), a.classList.remove("cell-focus"), i && (l === i.startRow && a.classList.add("top"), l === i.endRow && a.classList.add("bottom"), d === i.startCol && a.classList.add("first"), d === i.endCol && a.classList.add("last")));
|
|
2726
2868
|
});
|
|
2727
2869
|
}
|
|
2728
|
-
t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((
|
|
2870
|
+
t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((i) => i.classList.remove("cell-focus"));
|
|
2729
2871
|
}
|
|
2730
2872
|
afterRender() {
|
|
2731
2873
|
const e = this.shadowRoot;
|
|
2732
2874
|
if (!e) return;
|
|
2733
2875
|
const t = e.children[0], { mode: n } = this.config;
|
|
2734
|
-
this.grid.setAttribute("data-selection-mode", n), t && t.classList.toggle("selecting", this.isDragging), this.#
|
|
2876
|
+
this.grid.setAttribute("data-selection-mode", n), t && t.classList.toggle("selecting", this.isDragging), this.#n();
|
|
2735
2877
|
}
|
|
2736
2878
|
/**
|
|
2737
2879
|
* Called after scroll-triggered row rendering.
|
|
2738
2880
|
* Reapplies selection classes to recycled DOM elements.
|
|
2739
2881
|
*/
|
|
2740
2882
|
onScrollRender() {
|
|
2741
|
-
this.#
|
|
2883
|
+
this.#n();
|
|
2742
2884
|
}
|
|
2743
2885
|
// ===== Public API =====
|
|
2744
2886
|
/**
|
|
@@ -2757,19 +2899,19 @@ class lt extends fe {
|
|
|
2757
2899
|
* Get all selected cell ranges in public format.
|
|
2758
2900
|
*/
|
|
2759
2901
|
getRanges() {
|
|
2760
|
-
return
|
|
2902
|
+
return V(this.ranges);
|
|
2761
2903
|
}
|
|
2762
2904
|
/**
|
|
2763
2905
|
* Get all selected cells across all ranges.
|
|
2764
2906
|
*/
|
|
2765
2907
|
getSelectedCells() {
|
|
2766
|
-
return
|
|
2908
|
+
return it(this.ranges);
|
|
2767
2909
|
}
|
|
2768
2910
|
/**
|
|
2769
2911
|
* Check if a specific cell is in range selection.
|
|
2770
2912
|
*/
|
|
2771
2913
|
isCellSelected(e, t) {
|
|
2772
|
-
return
|
|
2914
|
+
return re(e, t, this.ranges);
|
|
2773
2915
|
}
|
|
2774
2916
|
/**
|
|
2775
2917
|
* Clear all selection.
|
|
@@ -2788,12 +2930,12 @@ class lt extends fe {
|
|
|
2788
2930
|
endCol: t.to.col
|
|
2789
2931
|
})), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
|
|
2790
2932
|
mode: this.config.mode,
|
|
2791
|
-
ranges:
|
|
2933
|
+
ranges: V(this.ranges)
|
|
2792
2934
|
}), this.requestAfterRender();
|
|
2793
2935
|
}
|
|
2794
2936
|
// ===== Private Helpers =====
|
|
2795
2937
|
#i() {
|
|
2796
|
-
return
|
|
2938
|
+
return lt(
|
|
2797
2939
|
this.config.mode,
|
|
2798
2940
|
{
|
|
2799
2941
|
selectedCell: this.selectedCell,
|
|
@@ -2804,111 +2946,79 @@ class lt extends fe {
|
|
|
2804
2946
|
);
|
|
2805
2947
|
}
|
|
2806
2948
|
// ===== Styles =====
|
|
2807
|
-
styles =
|
|
2808
|
-
/* Prevent text selection during range drag */
|
|
2809
|
-
:host .selecting .data-grid-row > .cell {
|
|
2810
|
-
user-select: none;
|
|
2811
|
-
}
|
|
2812
|
-
|
|
2813
|
-
/* Row selection - use accent color for row focus */
|
|
2814
|
-
:host .data-grid-row.row-focus {
|
|
2815
|
-
background-color: var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%));
|
|
2816
|
-
}
|
|
2817
|
-
|
|
2818
|
-
/* Disable cell-focus outline in row mode - row is the focus unit */
|
|
2819
|
-
:host([data-selection-mode="row"]) .cell-focus {
|
|
2820
|
-
outline: none;
|
|
2821
|
-
}
|
|
2822
|
-
|
|
2823
|
-
/* Selection cell styles - for range mode */
|
|
2824
|
-
:host .data-grid-row > .cell.selected {
|
|
2825
|
-
background-color: var(--tbw-range-selection-bg);
|
|
2826
|
-
}
|
|
2827
|
-
:host .data-grid-row > .cell.selected.top {
|
|
2828
|
-
border-top: 2px solid var(--tbw-range-border-color);
|
|
2829
|
-
}
|
|
2830
|
-
:host .data-grid-row > .cell.selected.bottom {
|
|
2831
|
-
border-bottom: 2px solid var(--tbw-range-border-color);
|
|
2832
|
-
}
|
|
2833
|
-
:host .data-grid-row > .cell.selected.first {
|
|
2834
|
-
border-left: 2px solid var(--tbw-range-border-color);
|
|
2835
|
-
}
|
|
2836
|
-
:host .data-grid-row > .cell.selected.last {
|
|
2837
|
-
border-right: 2px solid var(--tbw-range-border-color);
|
|
2838
|
-
}
|
|
2839
|
-
`;
|
|
2949
|
+
styles = rt;
|
|
2840
2950
|
}
|
|
2841
|
-
function
|
|
2951
|
+
function X(o, e, t) {
|
|
2842
2952
|
return o.id !== void 0 ? String(o.id) : t ? `${t}-${e}` : String(e);
|
|
2843
2953
|
}
|
|
2844
|
-
function
|
|
2845
|
-
const
|
|
2954
|
+
function we(o, e, t, n = null, s = 0) {
|
|
2955
|
+
const i = e.childrenField ?? "children", r = [];
|
|
2846
2956
|
for (let a = 0; a < o.length; a++) {
|
|
2847
|
-
const l = o[a],
|
|
2957
|
+
const l = o[a], d = X(l, a, n), u = l[i], g = Array.isArray(u) && u.length > 0, h = t.has(d);
|
|
2848
2958
|
if (r.push({
|
|
2849
|
-
key:
|
|
2959
|
+
key: d,
|
|
2850
2960
|
data: l,
|
|
2851
|
-
depth:
|
|
2961
|
+
depth: s,
|
|
2852
2962
|
hasChildren: g,
|
|
2853
2963
|
isExpanded: h,
|
|
2854
2964
|
parentKey: n
|
|
2855
2965
|
}), g && h) {
|
|
2856
|
-
const c =
|
|
2966
|
+
const c = we(u, e, t, d, s + 1);
|
|
2857
2967
|
r.push(...c);
|
|
2858
2968
|
}
|
|
2859
2969
|
}
|
|
2860
2970
|
return r;
|
|
2861
2971
|
}
|
|
2862
|
-
function
|
|
2972
|
+
function ae(o, e) {
|
|
2863
2973
|
const t = new Set(o);
|
|
2864
2974
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
2865
2975
|
}
|
|
2866
|
-
function
|
|
2867
|
-
const
|
|
2976
|
+
function F(o, e, t = null, n = 0) {
|
|
2977
|
+
const s = e.childrenField ?? "children", i = /* @__PURE__ */ new Set();
|
|
2868
2978
|
for (let r = 0; r < o.length; r++) {
|
|
2869
|
-
const a = o[r], l =
|
|
2870
|
-
if (Array.isArray(
|
|
2871
|
-
|
|
2872
|
-
const
|
|
2873
|
-
for (const g of
|
|
2979
|
+
const a = o[r], l = X(a, r, t), d = a[s];
|
|
2980
|
+
if (Array.isArray(d) && d.length > 0) {
|
|
2981
|
+
i.add(l);
|
|
2982
|
+
const u = F(d, e, l, n + 1);
|
|
2983
|
+
for (const g of u) i.add(g);
|
|
2874
2984
|
}
|
|
2875
2985
|
}
|
|
2876
|
-
return
|
|
2986
|
+
return i;
|
|
2877
2987
|
}
|
|
2878
|
-
function
|
|
2988
|
+
function at() {
|
|
2879
2989
|
return /* @__PURE__ */ new Set();
|
|
2880
2990
|
}
|
|
2881
|
-
function
|
|
2882
|
-
const
|
|
2991
|
+
function be(o, e, t, n = null, s = 0) {
|
|
2992
|
+
const i = t.childrenField ?? "children";
|
|
2883
2993
|
for (let r = 0; r < o.length; r++) {
|
|
2884
|
-
const a = o[r], l =
|
|
2994
|
+
const a = o[r], l = X(a, r, n);
|
|
2885
2995
|
if (l === e)
|
|
2886
2996
|
return [l];
|
|
2887
|
-
const
|
|
2888
|
-
if (Array.isArray(
|
|
2889
|
-
const
|
|
2890
|
-
if (
|
|
2891
|
-
return [l, ...
|
|
2997
|
+
const d = a[i];
|
|
2998
|
+
if (Array.isArray(d) && d.length > 0) {
|
|
2999
|
+
const u = be(d, e, t, l, s + 1);
|
|
3000
|
+
if (u)
|
|
3001
|
+
return [l, ...u];
|
|
2892
3002
|
}
|
|
2893
3003
|
}
|
|
2894
3004
|
return null;
|
|
2895
3005
|
}
|
|
2896
|
-
function
|
|
2897
|
-
const
|
|
2898
|
-
if (!
|
|
2899
|
-
const
|
|
2900
|
-
for (let r = 0; r <
|
|
2901
|
-
|
|
2902
|
-
return
|
|
3006
|
+
function ct(o, e, t, n) {
|
|
3007
|
+
const s = be(o, e, t);
|
|
3008
|
+
if (!s) return n;
|
|
3009
|
+
const i = new Set(n);
|
|
3010
|
+
for (let r = 0; r < s.length - 1; r++)
|
|
3011
|
+
i.add(s[r]);
|
|
3012
|
+
return i;
|
|
2903
3013
|
}
|
|
2904
|
-
function
|
|
3014
|
+
function ce(o, e = "children") {
|
|
2905
3015
|
if (!Array.isArray(o) || o.length === 0) return !1;
|
|
2906
3016
|
for (const t of o)
|
|
2907
3017
|
if (t && Array.isArray(t[e]) && t[e].length > 0)
|
|
2908
3018
|
return !0;
|
|
2909
3019
|
return !1;
|
|
2910
3020
|
}
|
|
2911
|
-
function
|
|
3021
|
+
function dt(o) {
|
|
2912
3022
|
if (!Array.isArray(o) || o.length === 0) return null;
|
|
2913
3023
|
const e = ["children", "items", "nodes", "subRows", "nested"];
|
|
2914
3024
|
for (const t of o)
|
|
@@ -2919,12 +3029,12 @@ function rt(o) {
|
|
|
2919
3029
|
}
|
|
2920
3030
|
return null;
|
|
2921
3031
|
}
|
|
2922
|
-
|
|
3032
|
+
const ht = ".tree-toggle{cursor:pointer;user-select:none;transition:transform .2s}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}";
|
|
3033
|
+
class pt extends ge {
|
|
2923
3034
|
name = "tree";
|
|
2924
3035
|
version = "1.0.0";
|
|
2925
3036
|
get defaultConfig() {
|
|
2926
3037
|
return {
|
|
2927
|
-
enabled: !0,
|
|
2928
3038
|
childrenField: "children",
|
|
2929
3039
|
autoDetect: !0,
|
|
2930
3040
|
defaultExpanded: !1,
|
|
@@ -2952,15 +3062,15 @@ class at extends fe {
|
|
|
2952
3062
|
*/
|
|
2953
3063
|
detect(e) {
|
|
2954
3064
|
if (!this.config.autoDetect) return !1;
|
|
2955
|
-
const t = this.config.childrenField ??
|
|
2956
|
-
return
|
|
3065
|
+
const t = this.config.childrenField ?? dt(e) ?? "children";
|
|
3066
|
+
return ce(e, t);
|
|
2957
3067
|
}
|
|
2958
3068
|
// ===== Data Processing =====
|
|
2959
3069
|
processRows(e) {
|
|
2960
3070
|
const t = this.config.childrenField ?? "children";
|
|
2961
|
-
if (!
|
|
3071
|
+
if (!ce(e, t))
|
|
2962
3072
|
return this.flattenedRows = [], this.rowKeyMap.clear(), [...e];
|
|
2963
|
-
this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys =
|
|
3073
|
+
this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = F(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = we(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
|
|
2964
3074
|
for (const n of this.flattenedRows)
|
|
2965
3075
|
this.rowKeyMap.set(n.key, n);
|
|
2966
3076
|
return this.flattenedRows.map((n) => ({
|
|
@@ -2973,31 +3083,31 @@ class at extends fe {
|
|
|
2973
3083
|
}
|
|
2974
3084
|
processColumns(e) {
|
|
2975
3085
|
if (this.flattenedRows.length === 0) return [...e];
|
|
2976
|
-
const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0,
|
|
2977
|
-
if (
|
|
2978
|
-
const
|
|
3086
|
+
const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0, s = [...e];
|
|
3087
|
+
if (s.length > 0) {
|
|
3088
|
+
const i = { ...s[0] }, r = i.viewRenderer;
|
|
2979
3089
|
if (r?.__treeWrapped)
|
|
2980
|
-
return
|
|
3090
|
+
return s;
|
|
2981
3091
|
const a = (l) => {
|
|
2982
|
-
const { value:
|
|
2983
|
-
if (
|
|
3092
|
+
const { value: d, row: u, column: g } = l, h = u.__treeDepth ?? 0, c = u.__treeHasChildren ?? !1, f = u.__treeExpanded ?? !1, p = document.createElement("span");
|
|
3093
|
+
if (p.style.display = "flex", p.style.alignItems = "center", p.style.paddingLeft = `${h * t}px`, c && n) {
|
|
2984
3094
|
const m = document.createElement("span");
|
|
2985
|
-
m.className = "tree-toggle", this.setIcon(m, this.resolveIcon(
|
|
3095
|
+
m.className = "tree-toggle", this.setIcon(m, this.resolveIcon(f ? "collapse" : "expand")), m.style.cursor = "pointer", m.style.marginRight = "4px", m.style.fontSize = "10px", m.setAttribute("data-tree-key", u.__treeKey), p.appendChild(m);
|
|
2986
3096
|
} else if (n) {
|
|
2987
3097
|
const m = document.createElement("span");
|
|
2988
|
-
m.style.width = "14px", m.style.display = "inline-block",
|
|
3098
|
+
m.style.width = "14px", m.style.display = "inline-block", p.appendChild(m);
|
|
2989
3099
|
}
|
|
2990
|
-
const
|
|
3100
|
+
const w = document.createElement("span");
|
|
2991
3101
|
if (r) {
|
|
2992
3102
|
const m = r(l);
|
|
2993
|
-
m instanceof Node ?
|
|
3103
|
+
m instanceof Node ? w.appendChild(m) : w.textContent = String(m ?? d ?? "");
|
|
2994
3104
|
} else
|
|
2995
|
-
|
|
2996
|
-
return
|
|
3105
|
+
w.textContent = String(d ?? "");
|
|
3106
|
+
return p.appendChild(w), p;
|
|
2997
3107
|
};
|
|
2998
|
-
a.__treeWrapped = !0,
|
|
3108
|
+
a.__treeWrapped = !0, i.viewRenderer = a, s[0] = i;
|
|
2999
3109
|
}
|
|
3000
|
-
return
|
|
3110
|
+
return s;
|
|
3001
3111
|
}
|
|
3002
3112
|
// ===== Event Handlers =====
|
|
3003
3113
|
onCellClick(e) {
|
|
@@ -3005,12 +3115,12 @@ class at extends fe {
|
|
|
3005
3115
|
if (!t?.classList.contains("tree-toggle")) return !1;
|
|
3006
3116
|
const n = t.getAttribute("data-tree-key");
|
|
3007
3117
|
if (!n) return !1;
|
|
3008
|
-
const
|
|
3009
|
-
return
|
|
3118
|
+
const s = this.rowKeyMap.get(n);
|
|
3119
|
+
return s ? (this.expandedKeys = ae(this.expandedKeys, n), this.emit("tree-expand", {
|
|
3010
3120
|
key: n,
|
|
3011
|
-
row:
|
|
3121
|
+
row: s.data,
|
|
3012
3122
|
expanded: this.expandedKeys.has(n),
|
|
3013
|
-
depth:
|
|
3123
|
+
depth: s.depth
|
|
3014
3124
|
}), this.requestRender(), !0) : !1;
|
|
3015
3125
|
}
|
|
3016
3126
|
// ===== Public API =====
|
|
@@ -3030,19 +3140,19 @@ class at extends fe {
|
|
|
3030
3140
|
* Toggle the expansion state of a node.
|
|
3031
3141
|
*/
|
|
3032
3142
|
toggle(e) {
|
|
3033
|
-
this.expandedKeys =
|
|
3143
|
+
this.expandedKeys = ae(this.expandedKeys, e), this.requestRender();
|
|
3034
3144
|
}
|
|
3035
3145
|
/**
|
|
3036
3146
|
* Expand all nodes in the tree.
|
|
3037
3147
|
*/
|
|
3038
3148
|
expandAll() {
|
|
3039
|
-
this.expandedKeys =
|
|
3149
|
+
this.expandedKeys = F(this.rows, this.config), this.requestRender();
|
|
3040
3150
|
}
|
|
3041
3151
|
/**
|
|
3042
3152
|
* Collapse all nodes in the tree.
|
|
3043
3153
|
*/
|
|
3044
3154
|
collapseAll() {
|
|
3045
|
-
this.expandedKeys =
|
|
3155
|
+
this.expandedKeys = at(), this.requestRender();
|
|
3046
3156
|
}
|
|
3047
3157
|
/**
|
|
3048
3158
|
* Check if a node is currently expanded.
|
|
@@ -3072,21 +3182,12 @@ class at extends fe {
|
|
|
3072
3182
|
* Expand all ancestors of a node to make it visible.
|
|
3073
3183
|
*/
|
|
3074
3184
|
expandToKey(e) {
|
|
3075
|
-
this.expandedKeys =
|
|
3185
|
+
this.expandedKeys = ct(this.rows, e, this.config, this.expandedKeys), this.requestRender();
|
|
3076
3186
|
}
|
|
3077
3187
|
// ===== Styles =====
|
|
3078
|
-
styles =
|
|
3079
|
-
.tree-toggle {
|
|
3080
|
-
cursor: pointer;
|
|
3081
|
-
user-select: none;
|
|
3082
|
-
transition: transform 0.2s;
|
|
3083
|
-
}
|
|
3084
|
-
.tree-toggle:hover {
|
|
3085
|
-
color: var(--tbw-tree-accent, var(--tbw-color-accent));
|
|
3086
|
-
}
|
|
3087
|
-
`;
|
|
3188
|
+
styles = ht;
|
|
3088
3189
|
}
|
|
3089
|
-
const
|
|
3190
|
+
const E = {
|
|
3090
3191
|
// Root structure
|
|
3091
3192
|
ROOT: "tbw-grid-root",
|
|
3092
3193
|
HEADER: "header",
|
|
@@ -3131,31 +3232,31 @@ const y = {
|
|
|
3131
3232
|
// Selection
|
|
3132
3233
|
RANGE_SELECTION: "range-selection",
|
|
3133
3234
|
SELECTION_OVERLAY: "selection-overlay"
|
|
3134
|
-
},
|
|
3235
|
+
}, N = {
|
|
3135
3236
|
ROW_INDEX: "data-row-index",
|
|
3136
3237
|
COL_INDEX: "data-col-index",
|
|
3137
3238
|
FIELD: "data-field",
|
|
3138
3239
|
GROUP_KEY: "data-group-key",
|
|
3139
3240
|
TREE_LEVEL: "data-tree-level",
|
|
3140
3241
|
STICKY: "data-sticky"
|
|
3141
|
-
},
|
|
3142
|
-
ROOT: `.${
|
|
3143
|
-
HEADER: `.${
|
|
3144
|
-
HEADER_ROW: `.${
|
|
3145
|
-
HEADER_CELL: `.${
|
|
3146
|
-
ROWS_VIEWPORT: `.${
|
|
3147
|
-
ROWS_CONTAINER: `.${
|
|
3148
|
-
DATA_ROW: `.${
|
|
3149
|
-
DATA_CELL: `.${
|
|
3150
|
-
GROUP_ROW: `.${
|
|
3242
|
+
}, gt = {
|
|
3243
|
+
ROOT: `.${E.ROOT}`,
|
|
3244
|
+
HEADER: `.${E.HEADER}`,
|
|
3245
|
+
HEADER_ROW: `.${E.HEADER_ROW}`,
|
|
3246
|
+
HEADER_CELL: `.${E.HEADER_CELL}`,
|
|
3247
|
+
ROWS_VIEWPORT: `.${E.ROWS_VIEWPORT}`,
|
|
3248
|
+
ROWS_CONTAINER: `.${E.ROWS_CONTAINER}`,
|
|
3249
|
+
DATA_ROW: `.${E.DATA_ROW}`,
|
|
3250
|
+
DATA_CELL: `.${E.DATA_CELL}`,
|
|
3251
|
+
GROUP_ROW: `.${E.GROUP_ROW}`,
|
|
3151
3252
|
// By data attribute
|
|
3152
|
-
ROW_BY_INDEX: (o) => `.${
|
|
3153
|
-
CELL_BY_FIELD: (o) => `.${
|
|
3154
|
-
CELL_AT: (o, e) => `.${
|
|
3253
|
+
ROW_BY_INDEX: (o) => `.${E.DATA_ROW}[${N.ROW_INDEX}="${o}"]`,
|
|
3254
|
+
CELL_BY_FIELD: (o) => `.${E.DATA_CELL}[${N.FIELD}="${o}"]`,
|
|
3255
|
+
CELL_AT: (o, e) => `.${E.DATA_ROW}[${N.ROW_INDEX}="${o}"] .${E.DATA_CELL}[${N.COL_INDEX}="${e}"]`,
|
|
3155
3256
|
// State selectors
|
|
3156
|
-
SELECTED_ROWS: `.${
|
|
3157
|
-
EDITING_CELL: `.${
|
|
3158
|
-
},
|
|
3257
|
+
SELECTED_ROWS: `.${E.DATA_ROW}.${E.SELECTED}`,
|
|
3258
|
+
EDITING_CELL: `.${E.DATA_CELL}.${E.EDITING}`
|
|
3259
|
+
}, wt = {
|
|
3159
3260
|
// Colors
|
|
3160
3261
|
COLOR_BG: "--tbw-color-bg",
|
|
3161
3262
|
COLOR_FG: "--tbw-color-fg",
|
|
@@ -3177,7 +3278,7 @@ const y = {
|
|
|
3177
3278
|
// Borders
|
|
3178
3279
|
BORDER_RADIUS: "--tbw-border-radius",
|
|
3179
3280
|
FOCUS_OUTLINE: "--tbw-focus-outline"
|
|
3180
|
-
},
|
|
3281
|
+
}, bt = {
|
|
3181
3282
|
CELL_COMMIT: "cell-commit",
|
|
3182
3283
|
ROW_COMMIT: "row-commit",
|
|
3183
3284
|
CHANGED_ROWS_RESET: "changed-rows-reset",
|
|
@@ -3188,7 +3289,7 @@ const y = {
|
|
|
3188
3289
|
ACTIVATE_CELL: "activate-cell",
|
|
3189
3290
|
GROUP_TOGGLE: "group-toggle",
|
|
3190
3291
|
COLUMN_STATE_CHANGE: "column-state-change"
|
|
3191
|
-
},
|
|
3292
|
+
}, mt = {
|
|
3192
3293
|
// Selection plugin
|
|
3193
3294
|
SELECTION_CHANGE: "selection-change",
|
|
3194
3295
|
// Tree plugin
|
|
@@ -3219,10 +3320,10 @@ const y = {
|
|
|
3219
3320
|
DETAIL_EXPAND: "detail-expand",
|
|
3220
3321
|
// Grouping rows plugin
|
|
3221
3322
|
GROUP_EXPAND: "group-expand"
|
|
3222
|
-
},
|
|
3323
|
+
}, B = {
|
|
3223
3324
|
sum: (o, e) => o.reduce((t, n) => t + (Number(n[e]) || 0), 0),
|
|
3224
3325
|
avg: (o, e) => {
|
|
3225
|
-
const t = o.reduce((n,
|
|
3326
|
+
const t = o.reduce((n, s) => n + (Number(s[e]) || 0), 0);
|
|
3226
3327
|
return o.length ? t / o.length : 0;
|
|
3227
3328
|
},
|
|
3228
3329
|
count: (o) => o.length,
|
|
@@ -3230,66 +3331,83 @@ const y = {
|
|
|
3230
3331
|
max: (o, e) => Math.max(...o.map((t) => Number(t[e]) || -1 / 0)),
|
|
3231
3332
|
first: (o, e) => o[0]?.[e],
|
|
3232
3333
|
last: (o, e) => o[o.length - 1]?.[e]
|
|
3233
|
-
},
|
|
3334
|
+
}, M = /* @__PURE__ */ new Map(), T = {
|
|
3234
3335
|
/**
|
|
3235
3336
|
* Register a custom aggregator function.
|
|
3236
3337
|
*/
|
|
3237
3338
|
register(o, e) {
|
|
3238
|
-
|
|
3339
|
+
M.set(o, e);
|
|
3239
3340
|
},
|
|
3240
3341
|
/**
|
|
3241
3342
|
* Unregister a custom aggregator function.
|
|
3242
3343
|
*/
|
|
3243
3344
|
unregister(o) {
|
|
3244
|
-
|
|
3345
|
+
M.delete(o);
|
|
3245
3346
|
},
|
|
3246
3347
|
/**
|
|
3247
3348
|
* Get an aggregator function by reference.
|
|
3248
3349
|
*/
|
|
3249
3350
|
get(o) {
|
|
3250
3351
|
if (o !== void 0)
|
|
3251
|
-
return typeof o == "function" ? o :
|
|
3352
|
+
return typeof o == "function" ? o : M.get(o) ?? B[o];
|
|
3252
3353
|
},
|
|
3253
3354
|
/**
|
|
3254
3355
|
* Run an aggregator on a set of rows.
|
|
3255
3356
|
*/
|
|
3256
3357
|
run(o, e, t, n) {
|
|
3257
|
-
const
|
|
3258
|
-
return
|
|
3358
|
+
const s = this.get(o);
|
|
3359
|
+
return s ? s(e, t, n) : void 0;
|
|
3259
3360
|
},
|
|
3260
3361
|
/**
|
|
3261
3362
|
* Check if an aggregator exists.
|
|
3262
3363
|
*/
|
|
3263
3364
|
has(o) {
|
|
3264
|
-
return
|
|
3365
|
+
return M.has(o) || o in B;
|
|
3265
3366
|
},
|
|
3266
3367
|
/**
|
|
3267
3368
|
* List all available aggregator names.
|
|
3268
3369
|
*/
|
|
3269
3370
|
list() {
|
|
3270
|
-
return [...Object.keys(
|
|
3371
|
+
return [...Object.keys(B), ...M.keys()];
|
|
3271
3372
|
}
|
|
3272
|
-
},
|
|
3373
|
+
}, de = {
|
|
3374
|
+
sum: (o) => o.reduce((e, t) => e + t, 0),
|
|
3375
|
+
avg: (o) => o.length ? o.reduce((e, t) => e + t, 0) / o.length : 0,
|
|
3376
|
+
count: (o) => o.length,
|
|
3377
|
+
min: (o) => o.length ? Math.min(...o) : 0,
|
|
3378
|
+
max: (o) => o.length ? Math.max(...o) : 0,
|
|
3379
|
+
first: (o) => o[0] ?? 0,
|
|
3380
|
+
last: (o) => o[o.length - 1] ?? 0
|
|
3381
|
+
};
|
|
3382
|
+
function ut(o) {
|
|
3383
|
+
return de[o] ?? de.sum;
|
|
3384
|
+
}
|
|
3385
|
+
function vt(o, e) {
|
|
3386
|
+
return ut(o)(e);
|
|
3387
|
+
}
|
|
3388
|
+
const yt = T.register.bind(T), Ct = T.unregister.bind(T), Et = T.get.bind(T), Rt = T.run.bind(T), _t = T.list.bind(T);
|
|
3273
3389
|
export {
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3390
|
+
ge as BaseGridPlugin,
|
|
3391
|
+
S as DEFAULT_GRID_ICONS,
|
|
3392
|
+
bt as DGEvents,
|
|
3393
|
+
$ as DataGridElement,
|
|
3394
|
+
O as FitModeEnum,
|
|
3395
|
+
wt as GridCSSVars,
|
|
3396
|
+
E as GridClasses,
|
|
3397
|
+
N as GridDataAttrs,
|
|
3398
|
+
$ as GridElement,
|
|
3399
|
+
gt as GridSelectors,
|
|
3400
|
+
mt as PluginEvents,
|
|
3401
|
+
tt as PluginManager,
|
|
3402
|
+
ft as SelectionPlugin,
|
|
3403
|
+
pt as TreePlugin,
|
|
3404
|
+
T as aggregatorRegistry,
|
|
3405
|
+
Et as getAggregator,
|
|
3406
|
+
ut as getValueAggregator,
|
|
3407
|
+
_t as listAggregators,
|
|
3408
|
+
yt as registerAggregator,
|
|
3409
|
+
Rt as runAggregator,
|
|
3410
|
+
vt as runValueAggregator,
|
|
3411
|
+
Ct as unregisterAggregator
|
|
3294
3412
|
};
|
|
3295
3413
|
//# sourceMappingURL=index.js.map
|