@toolbox-web/grid 0.0.3 → 0.0.4
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 +21 -0
- package/all.js +405 -402
- package/all.js.map +1 -1
- package/index.d.ts +26 -0
- package/index.js +924 -871
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +23 -20
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +110 -92
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +4 -1
- package/themes/dg-theme-contrast.css +43 -43
- package/themes/dg-theme-large.css +54 -54
- package/themes/dg-theme-standard.css +19 -19
- package/themes/dg-theme-vibrant.css +16 -16
- package/umd/grid.all.umd.js +24 -24
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -15
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-success);--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{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}";
|
|
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
2
|
function be(o) {
|
|
3
3
|
const e = /* @__PURE__ */ new Map();
|
|
4
4
|
return o.sortState && e.set(o.sortState.field, {
|
|
@@ -9,58 +9,58 @@ function be(o) {
|
|
|
9
9
|
function ae(o, e) {
|
|
10
10
|
const t = o._columns, n = be(o);
|
|
11
11
|
return {
|
|
12
|
-
columns: t.map((
|
|
13
|
-
const
|
|
14
|
-
field:
|
|
15
|
-
order:
|
|
12
|
+
columns: t.map((s, i) => {
|
|
13
|
+
const l = {
|
|
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
|
-
},
|
|
19
|
-
|
|
20
|
-
const a = n.get(
|
|
21
|
-
a && (
|
|
22
|
-
for (const
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
25
|
-
|
|
18
|
+
}, r = s;
|
|
19
|
+
r.__renderedWidth !== void 0 ? l.width = r.__renderedWidth : s.width !== void 0 && (l.width = typeof s.width == "string" ? parseFloat(s.width) : s.width);
|
|
20
|
+
const a = n.get(s.field);
|
|
21
|
+
a && (l.sort = a);
|
|
22
|
+
for (const f of e)
|
|
23
|
+
if (f.getColumnState) {
|
|
24
|
+
const p = f.getColumnState(s.field);
|
|
25
|
+
p && Object.assign(l, p);
|
|
26
26
|
}
|
|
27
|
-
return
|
|
27
|
+
return l;
|
|
28
28
|
})
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
function ge(o, e, t, n) {
|
|
32
32
|
if (!e.columns || e.columns.length === 0) return;
|
|
33
|
-
const
|
|
34
|
-
const a =
|
|
35
|
-
if (!a) return
|
|
36
|
-
const
|
|
37
|
-
return a.width !== void 0 && (
|
|
33
|
+
const s = new Map(e.columns.map((r) => [r.field, r])), i = t.map((r) => {
|
|
34
|
+
const a = s.get(r.field);
|
|
35
|
+
if (!a) return r;
|
|
36
|
+
const f = { ...r };
|
|
37
|
+
return a.width !== void 0 && (f.width = a.width, f.__renderedWidth = a.width), a.visible !== void 0 && (f.hidden = !a.visible), f;
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
-
}), o._columns =
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
field:
|
|
48
|
-
direction:
|
|
39
|
+
i.sort((r, a) => {
|
|
40
|
+
const f = s.get(r.field)?.order ?? 1 / 0, p = s.get(a.field)?.order ?? 1 / 0;
|
|
41
|
+
return f - p;
|
|
42
|
+
}), o._columns = i;
|
|
43
|
+
const l = e.columns.filter((r) => r.sort !== void 0).sort((r, a) => (r.sort?.priority ?? 0) - (a.sort?.priority ?? 0));
|
|
44
|
+
if (l.length > 0) {
|
|
45
|
+
const r = l[0];
|
|
46
|
+
r.sort && (o.sortState = {
|
|
47
|
+
field: r.field,
|
|
48
|
+
direction: r.sort.direction === "asc" ? 1 : -1
|
|
49
49
|
});
|
|
50
50
|
} else
|
|
51
51
|
o.sortState = null;
|
|
52
|
-
for (const
|
|
53
|
-
if (
|
|
52
|
+
for (const r of n)
|
|
53
|
+
if (r.applyColumnState)
|
|
54
54
|
for (const a of e.columns)
|
|
55
|
-
|
|
55
|
+
r.applyColumnState(a.field, a);
|
|
56
56
|
}
|
|
57
57
|
function me(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 = ae(o, e());
|
|
63
|
+
t(s);
|
|
64
64
|
}, 100);
|
|
65
65
|
};
|
|
66
66
|
}
|
|
@@ -73,20 +73,20 @@ function ve(o) {
|
|
|
73
73
|
}
|
|
74
74
|
function ce(o, e) {
|
|
75
75
|
if (e && e.length) {
|
|
76
|
-
const
|
|
77
|
-
return e.forEach((
|
|
78
|
-
|
|
79
|
-
}), { columns: e, typeMap:
|
|
80
|
-
}
|
|
81
|
-
const t = o[0] || {}, n = Object.keys(t).map((
|
|
82
|
-
const
|
|
83
|
-
return { field:
|
|
84
|
-
}),
|
|
85
|
-
return n.forEach((
|
|
86
|
-
i
|
|
87
|
-
}), { columns: n, typeMap:
|
|
88
|
-
}
|
|
89
|
-
const Ce = /{{\s*([^}]+)\s*}}/g,
|
|
76
|
+
const i = {};
|
|
77
|
+
return e.forEach((l) => {
|
|
78
|
+
l.type && (i[l.field] = l.type);
|
|
79
|
+
}), { columns: e, typeMap: i };
|
|
80
|
+
}
|
|
81
|
+
const t = o[0] || {}, n = Object.keys(t).map((i) => {
|
|
82
|
+
const l = t[i], r = ve(l);
|
|
83
|
+
return { field: i, header: i.charAt(0).toUpperCase() + i.slice(1), type: r };
|
|
84
|
+
}), s = {};
|
|
85
|
+
return n.forEach((i) => {
|
|
86
|
+
s[i.field] = i.type || "string";
|
|
87
|
+
}), { columns: n, typeMap: s };
|
|
88
|
+
}
|
|
89
|
+
const Ce = /{{\s*([^}]+)\s*}}/g, R = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, Ee = /__(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/, Re = /* @__PURE__ */ new Set([
|
|
90
90
|
"script",
|
|
91
91
|
"iframe",
|
|
92
92
|
"object",
|
|
@@ -121,64 +121,64 @@ function N(o) {
|
|
|
121
121
|
function Se(o) {
|
|
122
122
|
const e = [], t = o.querySelectorAll("*");
|
|
123
123
|
for (const n of t) {
|
|
124
|
-
const
|
|
125
|
-
if (Re.has(
|
|
124
|
+
const s = n.tagName.toLowerCase();
|
|
125
|
+
if (Re.has(s)) {
|
|
126
126
|
e.push(n);
|
|
127
127
|
continue;
|
|
128
128
|
}
|
|
129
|
-
if ((
|
|
130
|
-
(
|
|
129
|
+
if ((s === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
|
|
130
|
+
(r) => U.test(r.name) || r.name === "href" || r.name === "xlink:href"
|
|
131
131
|
)) {
|
|
132
132
|
e.push(n);
|
|
133
133
|
continue;
|
|
134
134
|
}
|
|
135
|
-
const
|
|
136
|
-
for (const
|
|
137
|
-
const
|
|
138
|
-
if (U.test(
|
|
139
|
-
|
|
135
|
+
const i = [];
|
|
136
|
+
for (const l of n.attributes) {
|
|
137
|
+
const r = l.name.toLowerCase();
|
|
138
|
+
if (U.test(r)) {
|
|
139
|
+
i.push(l.name);
|
|
140
140
|
continue;
|
|
141
141
|
}
|
|
142
|
-
if (_e.has(
|
|
143
|
-
|
|
142
|
+
if (_e.has(r) && Ae.test(l.value)) {
|
|
143
|
+
i.push(l.name);
|
|
144
144
|
continue;
|
|
145
145
|
}
|
|
146
|
-
if (
|
|
147
|
-
|
|
146
|
+
if (r === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(l.value)) {
|
|
147
|
+
i.push(l.name);
|
|
148
148
|
continue;
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
i.forEach((l) => n.removeAttribute(l));
|
|
152
152
|
}
|
|
153
153
|
e.forEach((n) => n.remove());
|
|
154
154
|
}
|
|
155
155
|
function de(o, e) {
|
|
156
156
|
if (!o || o.indexOf("{{") === -1) return o;
|
|
157
|
-
const t = [], n = o.replace(Ce, (
|
|
158
|
-
const
|
|
159
|
-
return t.push({ expr: a.trim(), result:
|
|
160
|
-
}),
|
|
161
|
-
return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) ||
|
|
157
|
+
const t = [], n = o.replace(Ce, (r, a) => {
|
|
158
|
+
const f = xe(a, e);
|
|
159
|
+
return t.push({ expr: a.trim(), result: f }), f;
|
|
160
|
+
}), s = Te(n), i = t.length && t.every((r) => r.result === "" || r.result === R);
|
|
161
|
+
return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) || i ? "" : s;
|
|
162
162
|
}
|
|
163
163
|
function xe(o, e) {
|
|
164
|
-
if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return
|
|
165
|
-
if (o === "value") return e.value == null ?
|
|
164
|
+
if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return R;
|
|
165
|
+
if (o === "value") return e.value == null ? R : String(e.value);
|
|
166
166
|
if (o.startsWith("row.") && !/[()?]/.test(o) && !o.includes(":")) {
|
|
167
|
-
const n = o.slice(4),
|
|
168
|
-
return
|
|
167
|
+
const n = o.slice(4), s = e.row ? e.row[n] : void 0;
|
|
168
|
+
return s == null ? R : String(s);
|
|
169
169
|
}
|
|
170
|
-
if (o.length > 80 || !ye.test(o) || Ee.test(o)) return
|
|
170
|
+
if (o.length > 80 || !ye.test(o) || Ee.test(o)) return R;
|
|
171
171
|
const t = o.match(/\./g);
|
|
172
|
-
if (t && t.length > 1) return
|
|
172
|
+
if (t && t.length > 1) return R;
|
|
173
173
|
try {
|
|
174
|
-
const
|
|
175
|
-
return /Reflect|Proxy|ownKeys/.test(
|
|
174
|
+
const s = new Function("value", "row", `return (${o});`)(e.value, e.row), i = s == null ? "" : String(s);
|
|
175
|
+
return /Reflect|Proxy|ownKeys/.test(i) ? R : i || R;
|
|
176
176
|
} catch {
|
|
177
|
-
return
|
|
177
|
+
return R;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
function Te(o) {
|
|
181
|
-
return o && o.replace(new RegExp(
|
|
181
|
+
return o && o.replace(new RegExp(R, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
|
|
182
182
|
}
|
|
183
183
|
function Le(o) {
|
|
184
184
|
if (/Reflect|Proxy|ownKeys/.test(o.textContent || "")) {
|
|
@@ -200,15 +200,15 @@ function ke(o) {
|
|
|
200
200
|
return Array.from(o.querySelectorAll("tbw-grid-column")).map((t) => {
|
|
201
201
|
const n = t.getAttribute("field") || "";
|
|
202
202
|
if (!n) return null;
|
|
203
|
-
const
|
|
204
|
-
t.hasAttribute("resizable") && (
|
|
203
|
+
const s = t.getAttribute("type") || void 0, l = s && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(s) ? s : void 0, r = t.getAttribute("header") || void 0, a = t.hasAttribute("sortable"), f = t.hasAttribute("editable"), p = { field: n, type: l, header: r, sortable: a, editable: f };
|
|
204
|
+
t.hasAttribute("resizable") && (p.resizable = !0), t.hasAttribute("sizable") && (p.resizable = !0);
|
|
205
205
|
const w = t.getAttribute("options");
|
|
206
|
-
w && (
|
|
207
|
-
const [b, y] =
|
|
206
|
+
w && (p.options = w.split(",").map((u) => {
|
|
207
|
+
const [b, y] = u.includes(":") ? u.split(":") : [u.trim(), u.trim()];
|
|
208
208
|
return { value: b.trim(), label: y?.trim() || b.trim() };
|
|
209
209
|
}));
|
|
210
|
-
const
|
|
211
|
-
return
|
|
210
|
+
const h = t.querySelector("tbw-grid-column-view"), c = t.querySelector("tbw-grid-column-editor"), d = t.querySelector("tbw-grid-column-header");
|
|
211
|
+
return h && (p.__viewTemplate = h), c && (p.__editorTemplate = c), d && (p.__headerTemplate = d), p;
|
|
212
212
|
}).filter((t) => !!t);
|
|
213
213
|
}
|
|
214
214
|
function Pe(o, e) {
|
|
@@ -216,14 +216,14 @@ function Pe(o, e) {
|
|
|
216
216
|
if (!o || !o.length) return e || [];
|
|
217
217
|
if (!e || !e.length) return o;
|
|
218
218
|
const t = {};
|
|
219
|
-
e.forEach((
|
|
220
|
-
const n = o.map((
|
|
221
|
-
const
|
|
222
|
-
if (!
|
|
223
|
-
const
|
|
224
|
-
return
|
|
219
|
+
e.forEach((s) => t[s.field] = s);
|
|
220
|
+
const n = o.map((s) => {
|
|
221
|
+
const i = t[s.field];
|
|
222
|
+
if (!i) return s;
|
|
223
|
+
const l = { ...s };
|
|
224
|
+
return i.header && !l.header && (l.header = i.header), i.type && !l.type && (l.type = i.type), l.sortable = s.sortable || i.sortable, (s.resizable === !0 || i.resizable === !0) && (l.resizable = !0), l.editable = s.editable || i.editable, i.__viewTemplate && (l.__viewTemplate = i.__viewTemplate), i.__editorTemplate && (l.__editorTemplate = i.__editorTemplate), i.__headerTemplate && (l.__headerTemplate = i.__headerTemplate), delete t[s.field], l;
|
|
225
225
|
});
|
|
226
|
-
return Object.keys(t).forEach((
|
|
226
|
+
return Object.keys(t).forEach((s) => n.push(t[s])), n;
|
|
227
227
|
}
|
|
228
228
|
function B(o, e) {
|
|
229
229
|
try {
|
|
@@ -238,8 +238,8 @@ function Oe(o) {
|
|
|
238
238
|
o.querySelectorAll("tbw-grid-column")
|
|
239
239
|
), o.__lightDomColumnsCache = o.__originalColumnNodes.length ? ke(o) : []);
|
|
240
240
|
const e = o.__lightDomColumnsCache, t = Pe(o._columns, e);
|
|
241
|
-
t.forEach((
|
|
242
|
-
|
|
241
|
+
t.forEach((s) => {
|
|
242
|
+
s.__viewTemplate && !s.__compiledView && (s.__compiledView = X(s.__viewTemplate.innerHTML)), s.__editorTemplate && !s.__compiledEditor && (s.__compiledEditor = X(s.__editorTemplate.innerHTML));
|
|
243
243
|
});
|
|
244
244
|
const { columns: n } = ce(o._rows, t);
|
|
245
245
|
o._columns = n;
|
|
@@ -250,18 +250,18 @@ function Me(o) {
|
|
|
250
250
|
const t = o.headerRowEl?.children || [];
|
|
251
251
|
if (!t.length) return;
|
|
252
252
|
let n = !1;
|
|
253
|
-
o.visibleColumns.forEach((
|
|
254
|
-
if (
|
|
255
|
-
const
|
|
256
|
-
let
|
|
253
|
+
o.visibleColumns.forEach((s, i) => {
|
|
254
|
+
if (s.width) return;
|
|
255
|
+
const l = t[i];
|
|
256
|
+
let r = l ? l.scrollWidth : 0;
|
|
257
257
|
for (const a of o.rowPool) {
|
|
258
|
-
const
|
|
259
|
-
if (
|
|
260
|
-
const
|
|
261
|
-
|
|
258
|
+
const f = a.children[i];
|
|
259
|
+
if (f) {
|
|
260
|
+
const p = f.scrollWidth;
|
|
261
|
+
p > r && (r = p);
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
-
|
|
264
|
+
r > 0 && (s.width = r + 2, s.__autoSized = !0, n = !0);
|
|
265
265
|
}), n && he(o), o.__didInitialAutoSize = !0;
|
|
266
266
|
}
|
|
267
267
|
function he(o) {
|
|
@@ -296,21 +296,21 @@ function De(o) {
|
|
|
296
296
|
case "typeahead":
|
|
297
297
|
return (e) => {
|
|
298
298
|
const t = document.createElement("select");
|
|
299
|
-
e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((
|
|
300
|
-
const
|
|
301
|
-
|
|
299
|
+
e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((i) => {
|
|
300
|
+
const l = document.createElement("option");
|
|
301
|
+
l.value = String(i.value), l.textContent = i.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(i.value) || !e.column.multi && e.value === i.value) && (l.selected = !0), t.appendChild(l);
|
|
302
302
|
});
|
|
303
|
-
const
|
|
303
|
+
const s = () => {
|
|
304
304
|
if (e.column.multi) {
|
|
305
|
-
const
|
|
306
|
-
Array.from(t.selectedOptions).forEach((
|
|
307
|
-
|
|
308
|
-
}), e.commit(
|
|
305
|
+
const i = [];
|
|
306
|
+
Array.from(t.selectedOptions).forEach((l) => {
|
|
307
|
+
i.push(l.value);
|
|
308
|
+
}), e.commit(i);
|
|
309
309
|
} else
|
|
310
310
|
e.commit(t.value);
|
|
311
311
|
};
|
|
312
|
-
return t.addEventListener("change",
|
|
313
|
-
|
|
312
|
+
return t.addEventListener("change", s), t.addEventListener("blur", s), t.addEventListener("keydown", (i) => {
|
|
313
|
+
i.key === "Escape" && e.cancel();
|
|
314
314
|
}), t.focus(), t;
|
|
315
315
|
};
|
|
316
316
|
default:
|
|
@@ -325,22 +325,22 @@ function De(o) {
|
|
|
325
325
|
function He(o, e) {
|
|
326
326
|
if (o.dispatchKeyDown?.(e))
|
|
327
327
|
return;
|
|
328
|
-
const t = o._rows.length - 1, n = o.visibleColumns.length - 1,
|
|
329
|
-
if (!
|
|
330
|
-
const w =
|
|
331
|
-
return !!(w === "INPUT" || w === "SELECT" || w === "TEXTAREA" ||
|
|
328
|
+
const t = o._rows.length - 1, n = o.visibleColumns.length - 1, s = o.activeEditRows !== void 0 && o.activeEditRows !== -1, l = o.visibleColumns[o.focusCol]?.type, r = e.composedPath ? e.composedPath() : [], a = r && r.length ? r[0] : e.target, f = (p) => {
|
|
329
|
+
if (!p) return !1;
|
|
330
|
+
const w = p.tagName;
|
|
331
|
+
return !!(w === "INPUT" || w === "SELECT" || w === "TEXTAREA" || p.isContentEditable);
|
|
332
332
|
};
|
|
333
|
-
if (!(
|
|
333
|
+
if (!(f(a) && (e.key === "Home" || e.key === "End")) && !(f(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(s && (l === "select" || l === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
|
|
334
334
|
switch (e.key) {
|
|
335
335
|
case "Tab": {
|
|
336
336
|
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), M(o);
|
|
337
337
|
return;
|
|
338
338
|
}
|
|
339
339
|
case "ArrowDown":
|
|
340
|
-
|
|
340
|
+
s && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.min(t, o.focusRow + 1), e.preventDefault();
|
|
341
341
|
break;
|
|
342
342
|
case "ArrowUp":
|
|
343
|
-
|
|
343
|
+
s && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.max(0, o.focusRow - 1), e.preventDefault();
|
|
344
344
|
break;
|
|
345
345
|
case "ArrowRight":
|
|
346
346
|
o.focusCol = Math.min(n, o.focusCol + 1), e.preventDefault();
|
|
@@ -372,29 +372,29 @@ function He(o, e) {
|
|
|
372
372
|
}
|
|
373
373
|
function M(o) {
|
|
374
374
|
if (o.virtualization?.enabled) {
|
|
375
|
-
const { rowHeight:
|
|
376
|
-
|
|
375
|
+
const { rowHeight: s } = o.virtualization, i = o, l = o.focusRow * s;
|
|
376
|
+
l < i.scrollTop ? i.scrollTop = l : l + s > i.scrollTop + i.clientHeight && (i.scrollTop = l - i.clientHeight + s);
|
|
377
377
|
}
|
|
378
|
-
o.refreshVirtualWindow(!1), Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach((
|
|
379
|
-
|
|
378
|
+
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) => {
|
|
379
|
+
s.setAttribute("aria-selected", "false");
|
|
380
380
|
});
|
|
381
381
|
const e = o.focusRow, t = o.virtualization.start ?? 0, n = o.virtualization.end ?? o._rows.length;
|
|
382
382
|
if (e >= t && e < n) {
|
|
383
|
-
const
|
|
384
|
-
if (
|
|
385
|
-
if (
|
|
386
|
-
const
|
|
383
|
+
const i = o.bodyEl.querySelectorAll(".data-grid-row")[e - t]?.children[o.focusCol];
|
|
384
|
+
if (i) {
|
|
385
|
+
if (i.classList.add("cell-focus"), i.setAttribute("aria-selected", "true"), o.activeEditRows !== void 0 && o.activeEditRows !== -1 && i.classList.contains("editing")) {
|
|
386
|
+
const l = i.querySelector(
|
|
387
387
|
'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
|
|
388
388
|
);
|
|
389
|
-
if (
|
|
389
|
+
if (l && document.activeElement !== l)
|
|
390
390
|
try {
|
|
391
|
-
|
|
391
|
+
l.focus();
|
|
392
392
|
} catch {
|
|
393
393
|
}
|
|
394
|
-
} else if (!
|
|
395
|
-
|
|
394
|
+
} else if (!i.contains(document.activeElement)) {
|
|
395
|
+
i.hasAttribute("tabindex") || i.setAttribute("tabindex", "-1");
|
|
396
396
|
try {
|
|
397
|
-
|
|
397
|
+
i.focus({ preventScroll: !0 });
|
|
398
398
|
} catch {
|
|
399
399
|
}
|
|
400
400
|
}
|
|
@@ -405,131 +405,135 @@ const ze = "__cellDisplayCache", Ne = "__cellCacheEpoch";
|
|
|
405
405
|
function j(o) {
|
|
406
406
|
o[ze] = void 0, o[Ne] = void 0, o.__hasSpecialColumns = void 0;
|
|
407
407
|
}
|
|
408
|
-
function qe(o, e, t, n,
|
|
409
|
-
const
|
|
410
|
-
let
|
|
411
|
-
for (
|
|
408
|
+
function qe(o, e, t, n, s) {
|
|
409
|
+
const i = Math.max(0, t - e), l = o.bodyEl, r = o.visibleColumns, a = r.length;
|
|
410
|
+
let f = o.__cachedHeaderRowCount;
|
|
411
|
+
for (f === void 0 && (f = o.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, o.__cachedHeaderRowCount = f); o.rowPool.length < i; ) {
|
|
412
412
|
const w = document.createElement("div");
|
|
413
|
-
w.className = "data-grid-row", w.setAttribute("role", "row"), w.addEventListener("click", (
|
|
413
|
+
w.className = "data-grid-row", w.setAttribute("role", "row"), w.addEventListener("click", (h) => Z(o, h, w, !1)), w.addEventListener("dblclick", (h) => Z(o, h, w, !0)), o.rowPool.push(w);
|
|
414
414
|
}
|
|
415
|
-
if (o.rowPool.length >
|
|
416
|
-
for (let w =
|
|
417
|
-
const
|
|
418
|
-
|
|
415
|
+
if (o.rowPool.length > i) {
|
|
416
|
+
for (let w = i; w < o.rowPool.length; w++) {
|
|
417
|
+
const h = o.rowPool[w];
|
|
418
|
+
h.parentNode === l && h.remove();
|
|
419
419
|
}
|
|
420
|
-
o.rowPool.length =
|
|
420
|
+
o.rowPool.length = i;
|
|
421
421
|
}
|
|
422
|
-
const
|
|
423
|
-
for (let w = 0; w <
|
|
424
|
-
const
|
|
425
|
-
if (
|
|
426
|
-
|
|
422
|
+
const p = s && o.__hasRenderRowPlugins !== !1;
|
|
423
|
+
for (let w = 0; w < i; w++) {
|
|
424
|
+
const h = e + w, c = o._rows[h], d = o.rowPool[w];
|
|
425
|
+
if (d.setAttribute("aria-rowindex", String(h + f + 1)), p && s(c, d, h)) {
|
|
426
|
+
d.__epoch = n, d.__rowDataRef = c, d.parentNode !== l && l.appendChild(d);
|
|
427
427
|
continue;
|
|
428
428
|
}
|
|
429
|
-
const
|
|
430
|
-
let
|
|
431
|
-
if (
|
|
432
|
-
for (let
|
|
433
|
-
if (
|
|
434
|
-
|
|
429
|
+
const u = d.__epoch, b = d.__rowDataRef, y = d.children.length, E = u === n && y === a, _ = b !== c;
|
|
430
|
+
let x = !1;
|
|
431
|
+
if (E && _) {
|
|
432
|
+
for (let A = 0; A < a; A++)
|
|
433
|
+
if (r[A].externalView && !d.querySelector(`.cell[data-col="${A}"] [data-external-view]`)) {
|
|
434
|
+
x = !0;
|
|
435
435
|
break;
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
!
|
|
439
|
-
const g = o._changedRowIndices.has(
|
|
440
|
-
g !== m &&
|
|
438
|
+
!E || x ? (d.__isCustomRow && (d.className = "data-grid-row", d.setAttribute("role", "row"), d.__isCustomRow = !1), F(o, d, c, h), d.__epoch = n, d.__rowDataRef = c) : _ ? (Y(o, d, c, h), d.__rowDataRef = c) : Y(o, d, c, h);
|
|
439
|
+
const g = o._changedRowIndices.has(h), m = d.classList.contains("changed");
|
|
440
|
+
g !== m && d.classList.toggle("changed", g), d.parentNode !== l && l.appendChild(d);
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
443
|
function Y(o, e, t, n) {
|
|
444
|
-
const
|
|
445
|
-
let
|
|
446
|
-
if (
|
|
447
|
-
|
|
448
|
-
for (let
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
451
|
-
|
|
444
|
+
const s = e.children, i = o.visibleColumns, l = i.length, r = s.length, a = l < r ? l : r, f = o.focusRow, p = o.focusCol;
|
|
445
|
+
let w = o.__hasSpecialColumns;
|
|
446
|
+
if (w === void 0) {
|
|
447
|
+
w = !1;
|
|
448
|
+
for (let c = 0; c < l; c++) {
|
|
449
|
+
const d = i[c];
|
|
450
|
+
if (d.__viewTemplate || d.__compiledView || d.viewRenderer || d.externalView || d.format || d.type === "date" || d.type === "boolean") {
|
|
451
|
+
w = !0;
|
|
452
452
|
break;
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
|
-
o.__hasSpecialColumns =
|
|
455
|
+
o.__hasSpecialColumns = w;
|
|
456
456
|
}
|
|
457
|
-
const
|
|
458
|
-
if (!
|
|
459
|
-
for (let
|
|
460
|
-
const
|
|
461
|
-
|
|
457
|
+
const h = String(n);
|
|
458
|
+
if (!w) {
|
|
459
|
+
for (let c = 0; c < a; c++) {
|
|
460
|
+
const d = s[c], u = t[i[c].field];
|
|
461
|
+
d.textContent = u == null ? "" : String(u), d.getAttribute("data-row") !== h && d.setAttribute("data-row", h);
|
|
462
|
+
const b = f === n && p === c, y = d.classList.contains("cell-focus");
|
|
463
|
+
b !== y && (d.classList.toggle("cell-focus", b), d.setAttribute("aria-selected", String(b)));
|
|
462
464
|
}
|
|
463
465
|
return;
|
|
464
466
|
}
|
|
465
|
-
for (let
|
|
466
|
-
if (
|
|
467
|
+
for (let c = 0; c < a; c++)
|
|
468
|
+
if (i[c].externalView && !s[c].querySelector("[data-external-view]")) {
|
|
467
469
|
F(o, e, t, n);
|
|
468
470
|
return;
|
|
469
471
|
}
|
|
470
|
-
for (let
|
|
471
|
-
const
|
|
472
|
-
|
|
472
|
+
for (let c = 0; c < a; c++) {
|
|
473
|
+
const d = i[c], u = s[c];
|
|
474
|
+
u.getAttribute("data-row") !== h && u.setAttribute("data-row", h);
|
|
475
|
+
const b = f === n && p === c, y = u.classList.contains("cell-focus");
|
|
476
|
+
if (b !== y && (u.classList.toggle("cell-focus", b), u.setAttribute("aria-selected", String(b))), u.classList.contains("editing") || d.__viewTemplate || d.__compiledView || d.viewRenderer || d.externalView)
|
|
473
477
|
continue;
|
|
474
|
-
const
|
|
475
|
-
let
|
|
476
|
-
if (
|
|
478
|
+
const v = t[d.field];
|
|
479
|
+
let E;
|
|
480
|
+
if (d.format)
|
|
477
481
|
try {
|
|
478
|
-
const
|
|
479
|
-
|
|
482
|
+
const _ = d.format(v, t);
|
|
483
|
+
E = _ == null ? "" : String(_);
|
|
480
484
|
} catch {
|
|
481
|
-
|
|
485
|
+
E = v == null ? "" : String(v);
|
|
482
486
|
}
|
|
483
|
-
else if (
|
|
484
|
-
if (
|
|
485
|
-
|
|
486
|
-
else if (
|
|
487
|
-
|
|
487
|
+
else if (d.type === "date")
|
|
488
|
+
if (v == null || v === "")
|
|
489
|
+
E = "";
|
|
490
|
+
else if (v instanceof Date)
|
|
491
|
+
E = isNaN(v.getTime()) ? "" : v.toLocaleDateString();
|
|
488
492
|
else {
|
|
489
|
-
const
|
|
490
|
-
|
|
493
|
+
const _ = new Date(v);
|
|
494
|
+
E = isNaN(_.getTime()) ? "" : _.toLocaleDateString();
|
|
491
495
|
}
|
|
492
|
-
else
|
|
493
|
-
|
|
496
|
+
else d.type === "boolean" ? (E = v ? "🗹" : "☐", u.setAttribute("aria-checked", String(!!v))) : E = v == null ? "" : String(v);
|
|
497
|
+
u.textContent = E;
|
|
494
498
|
}
|
|
495
499
|
}
|
|
496
500
|
function F(o, e, t, n) {
|
|
497
501
|
e.innerHTML = "";
|
|
498
|
-
const
|
|
499
|
-
for (let w = 0; w <
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
let
|
|
505
|
-
const b =
|
|
502
|
+
const s = o.visibleColumns, i = s.length, l = o.focusRow, r = o.focusCol, a = o.effectiveConfig?.editOn || o.editOn, f = o, p = document.createDocumentFragment();
|
|
503
|
+
for (let w = 0; w < i; w++) {
|
|
504
|
+
const h = s[w], c = document.createElement("div");
|
|
505
|
+
c.className = "cell", B(c, "cell"), h.type !== "boolean" && c.setAttribute("role", "gridcell"), c.setAttribute("data-col", String(w)), c.setAttribute("data-row", String(n)), c.setAttribute("aria-colindex", String(w + 1)), h.type && c.setAttribute("data-type", h.type);
|
|
506
|
+
const d = h.sticky;
|
|
507
|
+
d === "left" ? c.classList.add("sticky-left") : d === "right" && c.classList.add("sticky-right");
|
|
508
|
+
let u = t[h.field];
|
|
509
|
+
const b = h.format;
|
|
506
510
|
if (b)
|
|
507
511
|
try {
|
|
508
|
-
|
|
512
|
+
u = b(u, t);
|
|
509
513
|
} catch {
|
|
510
514
|
}
|
|
511
|
-
const y =
|
|
512
|
-
let
|
|
513
|
-
if (
|
|
514
|
-
const g =
|
|
515
|
-
typeof g == "string" ? (
|
|
516
|
-
} else if (
|
|
517
|
-
const g =
|
|
518
|
-
m.setAttribute("data-external-view", ""), m.setAttribute("data-field",
|
|
519
|
-
const
|
|
515
|
+
const y = h.__compiledView, v = h.__viewTemplate, E = h.viewRenderer, _ = h.externalView;
|
|
516
|
+
let x = !1;
|
|
517
|
+
if (E) {
|
|
518
|
+
const g = E({ row: t, value: u, field: h.field, column: h });
|
|
519
|
+
typeof g == "string" ? (c.innerHTML = N(g), x = !0) : g ? c.appendChild(g) : c.textContent = u == null ? "" : String(u);
|
|
520
|
+
} else if (_) {
|
|
521
|
+
const g = _, m = document.createElement("div");
|
|
522
|
+
m.setAttribute("data-external-view", ""), m.setAttribute("data-field", h.field), c.appendChild(m);
|
|
523
|
+
const A = { row: t, value: u, field: h.field, column: h };
|
|
520
524
|
if (g.mount)
|
|
521
525
|
try {
|
|
522
|
-
g.mount({ placeholder: m, context:
|
|
526
|
+
g.mount({ placeholder: m, context: A, spec: g });
|
|
523
527
|
} catch {
|
|
524
528
|
}
|
|
525
529
|
else
|
|
526
530
|
queueMicrotask(() => {
|
|
527
531
|
try {
|
|
528
|
-
|
|
532
|
+
f.dispatchEvent(
|
|
529
533
|
new CustomEvent("mount-external-view", {
|
|
530
534
|
bubbles: !0,
|
|
531
535
|
composed: !0,
|
|
532
|
-
detail: { placeholder: m, spec: g, context:
|
|
536
|
+
detail: { placeholder: m, spec: g, context: A }
|
|
533
537
|
})
|
|
534
538
|
);
|
|
535
539
|
} catch {
|
|
@@ -537,51 +541,51 @@ function F(o, e, t, n) {
|
|
|
537
541
|
});
|
|
538
542
|
m.setAttribute("data-mounted", "");
|
|
539
543
|
} else if (y) {
|
|
540
|
-
const g = y({ row: t, value:
|
|
541
|
-
|
|
542
|
-
} else if (
|
|
543
|
-
const g =
|
|
544
|
-
/Reflect\.|\bProxy\b|ownKeys\(/.test(g) ? (
|
|
545
|
-
} else if (
|
|
546
|
-
if (
|
|
547
|
-
|
|
544
|
+
const g = y({ row: t, value: u, field: h.field, column: h }), m = y.__blocked;
|
|
545
|
+
c.innerHTML = m ? "" : N(g), x = !0, m && (c.textContent = "", c.setAttribute("data-blocked-template", ""));
|
|
546
|
+
} else if (v) {
|
|
547
|
+
const g = v.innerHTML;
|
|
548
|
+
/Reflect\.|\bProxy\b|ownKeys\(/.test(g) ? (c.textContent = "", c.setAttribute("data-blocked-template", "")) : (c.innerHTML = N(de(g, { row: t, value: u })), x = !0);
|
|
549
|
+
} else if (h.type === "date")
|
|
550
|
+
if (u == null || u === "")
|
|
551
|
+
c.textContent = "";
|
|
548
552
|
else {
|
|
549
553
|
let g = null;
|
|
550
|
-
if (
|
|
551
|
-
else if (typeof
|
|
552
|
-
const m = new Date(
|
|
554
|
+
if (u instanceof Date) g = u;
|
|
555
|
+
else if (typeof u == "number" || typeof u == "string") {
|
|
556
|
+
const m = new Date(u);
|
|
553
557
|
isNaN(m.getTime()) || (g = m);
|
|
554
558
|
}
|
|
555
|
-
|
|
559
|
+
c.textContent = g ? g.toLocaleDateString() : "";
|
|
556
560
|
}
|
|
557
|
-
else if (
|
|
558
|
-
const g = !!
|
|
559
|
-
|
|
561
|
+
else if (h.type === "boolean") {
|
|
562
|
+
const g = !!u;
|
|
563
|
+
c.innerHTML = g ? "🗹" : "☐", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(g)), c.setAttribute("aria-label", String(g));
|
|
560
564
|
} else
|
|
561
|
-
|
|
562
|
-
if (
|
|
563
|
-
Le(
|
|
564
|
-
const g =
|
|
565
|
-
/Proxy|Reflect\.ownKeys/.test(g) && (
|
|
565
|
+
c.textContent = u == null ? "" : String(u);
|
|
566
|
+
if (x) {
|
|
567
|
+
Le(c);
|
|
568
|
+
const g = c.textContent || "";
|
|
569
|
+
/Proxy|Reflect\.ownKeys/.test(g) && (c.textContent = g.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(c.textContent || "") && (c.textContent = ""));
|
|
566
570
|
}
|
|
567
|
-
|
|
571
|
+
c.hasAttribute("data-blocked-template") && (c.textContent || "").trim().length && (c.textContent = ""), h.editable ? (c.tabIndex = 0, c.addEventListener("mousedown", () => {
|
|
568
572
|
o.focusRow = n, o.focusCol = w, M(o);
|
|
569
|
-
}), a === "click" ?
|
|
570
|
-
|
|
571
|
-
}) :
|
|
572
|
-
g.stopPropagation(),
|
|
573
|
+
}), a === "click" ? c.addEventListener("click", (g) => {
|
|
574
|
+
c.classList.contains("editing") || (g.stopPropagation(), o.focusRow = n, o.focusCol = w, L(o, t, n, h, c));
|
|
575
|
+
}) : c.addEventListener("dblclick", (g) => {
|
|
576
|
+
g.stopPropagation(), T(o, n, t);
|
|
573
577
|
const m = o.findRenderedRowElement?.(n);
|
|
574
578
|
if (m) {
|
|
575
|
-
const
|
|
576
|
-
for (let k = 0; k <
|
|
579
|
+
const A = m.children;
|
|
580
|
+
for (let k = 0; k < A.length; k++) {
|
|
577
581
|
const D = o.visibleColumns[k];
|
|
578
|
-
D && D.editable &&
|
|
582
|
+
D && D.editable && L(o, t, n, D, A[k]);
|
|
579
583
|
}
|
|
580
584
|
}
|
|
581
|
-
}),
|
|
582
|
-
if ((
|
|
583
|
-
g.preventDefault(), o.activeEditRows !== n &&
|
|
584
|
-
const m =
|
|
585
|
+
}), c.addEventListener("keydown", (g) => {
|
|
586
|
+
if ((h.type === "select" || h.type === "typeahead") && !c.classList.contains("editing") && g.key === "Enter") {
|
|
587
|
+
g.preventDefault(), o.activeEditRows !== n && T(o, n, t), L(o, t, n, h, c), setTimeout(() => {
|
|
588
|
+
const m = c.querySelector("select");
|
|
585
589
|
try {
|
|
586
590
|
m?.showPicker?.();
|
|
587
591
|
} catch {
|
|
@@ -590,87 +594,87 @@ function F(o, e, t, n) {
|
|
|
590
594
|
}, 0);
|
|
591
595
|
return;
|
|
592
596
|
}
|
|
593
|
-
if (
|
|
594
|
-
g.preventDefault(), o.activeEditRows !== n &&
|
|
595
|
-
const m = !t[
|
|
596
|
-
$(o, n,
|
|
597
|
+
if (h.type === "boolean" && g.key === " " && !c.classList.contains("editing")) {
|
|
598
|
+
g.preventDefault(), o.activeEditRows !== n && T(o, n, t);
|
|
599
|
+
const m = !t[h.field];
|
|
600
|
+
$(o, n, h, m, t), c.innerHTML = m ? "🗹" : "☐", c.setAttribute("aria-label", String(!!m));
|
|
597
601
|
return;
|
|
598
602
|
}
|
|
599
|
-
if (g.key === "Enter" && !
|
|
600
|
-
g.preventDefault(), o.focusRow = n, o.focusCol = w, typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(n) :
|
|
603
|
+
if (g.key === "Enter" && !c.classList.contains("editing")) {
|
|
604
|
+
g.preventDefault(), o.focusRow = n, o.focusCol = w, typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(n) : L(o, t, n, h, c);
|
|
601
605
|
return;
|
|
602
606
|
}
|
|
603
|
-
if (g.key === "F2" && !
|
|
604
|
-
g.preventDefault(),
|
|
607
|
+
if (g.key === "F2" && !c.classList.contains("editing")) {
|
|
608
|
+
g.preventDefault(), L(o, t, n, h, c);
|
|
605
609
|
return;
|
|
606
610
|
}
|
|
607
|
-
})) :
|
|
611
|
+
})) : h.type === "boolean" && (c.hasAttribute("tabindex") || (c.tabIndex = 0), c.addEventListener("keydown", (g) => {
|
|
608
612
|
if (g.key === " ") {
|
|
609
613
|
g.preventDefault();
|
|
610
|
-
const m = !t[
|
|
611
|
-
o.activeEditRows !== n &&
|
|
614
|
+
const m = !t[h.field];
|
|
615
|
+
o.activeEditRows !== n && T(o, n, t), $(o, n, h, m, t), c.innerHTML = m ? "🗹" : "☐", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(!!m)), c.setAttribute("aria-label", String(!!m));
|
|
612
616
|
}
|
|
613
|
-
})),
|
|
617
|
+
})), l === n && r === w ? c.setAttribute("aria-selected", "true") : c.setAttribute("aria-selected", "false"), p.appendChild(c);
|
|
614
618
|
}
|
|
615
|
-
e.appendChild(
|
|
619
|
+
e.appendChild(p);
|
|
616
620
|
}
|
|
617
621
|
function Z(o, e, t, n) {
|
|
618
622
|
if (e.target?.closest(".resize-handle")) return;
|
|
619
|
-
const
|
|
620
|
-
if (!
|
|
621
|
-
const
|
|
622
|
-
if (isNaN(
|
|
623
|
-
const
|
|
624
|
-
if (!
|
|
625
|
-
const
|
|
626
|
-
if (
|
|
627
|
-
const
|
|
628
|
-
if (!isNaN(
|
|
629
|
-
if (o.dispatchCellClick?.(e,
|
|
623
|
+
const s = t.querySelector(".cell[data-row]");
|
|
624
|
+
if (!s) return;
|
|
625
|
+
const i = Number(s.getAttribute("data-row"));
|
|
626
|
+
if (isNaN(i)) return;
|
|
627
|
+
const l = o._rows[i];
|
|
628
|
+
if (!l) return;
|
|
629
|
+
const r = e.target?.closest(".cell[data-col]");
|
|
630
|
+
if (r) {
|
|
631
|
+
const f = Number(r.getAttribute("data-col"));
|
|
632
|
+
if (!isNaN(f)) {
|
|
633
|
+
if (o.dispatchCellClick?.(e, i, f, r))
|
|
630
634
|
return;
|
|
631
|
-
o.focusRow =
|
|
635
|
+
o.focusRow = i, o.focusCol = f, M(o);
|
|
632
636
|
}
|
|
633
637
|
}
|
|
634
638
|
if (t.querySelector(".cell.editing")) {
|
|
635
|
-
const
|
|
639
|
+
const f = t.querySelectorAll(".cell.editing");
|
|
636
640
|
if (!n) return;
|
|
637
|
-
|
|
641
|
+
f.forEach((p) => p.classList.remove("editing"));
|
|
638
642
|
}
|
|
639
643
|
const a = o.effectiveConfig?.editOn || o.editOn || "doubleClick";
|
|
640
|
-
if (a === "click" || a === "doubleClick" && n)
|
|
644
|
+
if (a === "click" || a === "doubleClick" && n) T(o, i, l);
|
|
641
645
|
else return;
|
|
642
|
-
Array.from(t.children).forEach((
|
|
643
|
-
const w = o.visibleColumns[
|
|
644
|
-
w && w.editable &&
|
|
645
|
-
}),
|
|
646
|
-
const
|
|
647
|
-
if (
|
|
648
|
-
const
|
|
646
|
+
Array.from(t.children).forEach((f, p) => {
|
|
647
|
+
const w = o.visibleColumns[p];
|
|
648
|
+
w && w.editable && L(o, l, i, w, f);
|
|
649
|
+
}), r && queueMicrotask(() => {
|
|
650
|
+
const f = t.querySelector(`.cell[data-col="${o.focusCol}"]`);
|
|
651
|
+
if (f?.classList.contains("editing")) {
|
|
652
|
+
const p = f.querySelector(
|
|
649
653
|
'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
|
|
650
654
|
);
|
|
651
655
|
try {
|
|
652
|
-
|
|
656
|
+
p?.focus();
|
|
653
657
|
} catch {
|
|
654
658
|
}
|
|
655
659
|
}
|
|
656
660
|
});
|
|
657
661
|
}
|
|
658
|
-
function
|
|
662
|
+
function T(o, e, t) {
|
|
659
663
|
o.activeEditRows !== e && (o.rowEditSnapshots.set(e, { ...t }), o.activeEditRows = e);
|
|
660
664
|
}
|
|
661
665
|
function Ie(o, e, t) {
|
|
662
666
|
if (o.activeEditRows !== e) return;
|
|
663
|
-
const n = o.rowEditSnapshots.get(e),
|
|
664
|
-
if (t && n &&
|
|
665
|
-
Object.keys(n).forEach((
|
|
667
|
+
const n = o.rowEditSnapshots.get(e), s = o._rows[e];
|
|
668
|
+
if (t && n && s)
|
|
669
|
+
Object.keys(n).forEach((l) => s[l] = n[l]), o._changedRowIndices.delete(e);
|
|
666
670
|
else if (!t) {
|
|
667
|
-
const
|
|
671
|
+
const l = o._changedRowIndices.has(e);
|
|
668
672
|
o.dispatchEvent(
|
|
669
673
|
new CustomEvent("row-commit", {
|
|
670
674
|
detail: {
|
|
671
675
|
rowIndex: e,
|
|
672
|
-
row:
|
|
673
|
-
changed:
|
|
676
|
+
row: s,
|
|
677
|
+
changed: l,
|
|
674
678
|
changedRows: o.changedRows,
|
|
675
679
|
changedRowIndices: o.changedRowIndices
|
|
676
680
|
}
|
|
@@ -678,100 +682,100 @@ function Ie(o, e, t) {
|
|
|
678
682
|
);
|
|
679
683
|
}
|
|
680
684
|
o.rowEditSnapshots.delete(e), o.activeEditRows = -1;
|
|
681
|
-
const
|
|
682
|
-
|
|
685
|
+
const i = o.findRenderedRowElement?.(e);
|
|
686
|
+
i && (F(o, i, o._rows[e], e), o._changedRowIndices.has(e) ? i.classList.add("changed") : i.classList.remove("changed")), t && queueMicrotask(() => {
|
|
683
687
|
try {
|
|
684
688
|
o.focus();
|
|
685
|
-
const
|
|
689
|
+
const l = o.focusRow, r = o.focusCol, a = o.findRenderedRowElement?.(l);
|
|
686
690
|
if (a) {
|
|
687
691
|
Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach(
|
|
688
|
-
(
|
|
692
|
+
(p) => p.classList.remove("cell-focus")
|
|
689
693
|
);
|
|
690
|
-
const
|
|
691
|
-
|
|
694
|
+
const f = a.querySelector(`.cell[data-row="${l}"][data-col="${r}"]`);
|
|
695
|
+
f && f.classList.add("cell-focus");
|
|
692
696
|
}
|
|
693
697
|
} catch {
|
|
694
698
|
}
|
|
695
699
|
});
|
|
696
700
|
}
|
|
697
|
-
function $(o, e, t, n,
|
|
698
|
-
const
|
|
699
|
-
if (i
|
|
700
|
-
i
|
|
701
|
-
const
|
|
701
|
+
function $(o, e, t, n, s) {
|
|
702
|
+
const i = t.field;
|
|
703
|
+
if (s[i] === n) return;
|
|
704
|
+
s[i] = n;
|
|
705
|
+
const r = !o._changedRowIndices.has(e);
|
|
702
706
|
o._changedRowIndices.add(e);
|
|
703
707
|
const a = o.findRenderedRowElement?.(e);
|
|
704
708
|
a && a.classList.add("changed"), o.dispatchEvent(
|
|
705
709
|
new CustomEvent("cell-commit", {
|
|
706
710
|
detail: {
|
|
707
|
-
row:
|
|
708
|
-
field:
|
|
711
|
+
row: s,
|
|
712
|
+
field: i,
|
|
709
713
|
value: n,
|
|
710
714
|
rowIndex: e,
|
|
711
715
|
changedRows: o.changedRows,
|
|
712
716
|
changedRowIndices: o.changedRowIndices,
|
|
713
|
-
firstTimeForRow:
|
|
717
|
+
firstTimeForRow: r
|
|
714
718
|
}
|
|
715
719
|
})
|
|
716
720
|
);
|
|
717
721
|
}
|
|
718
|
-
function
|
|
719
|
-
if (!n.editable || (o.activeEditRows !== t &&
|
|
720
|
-
const
|
|
721
|
-
|
|
722
|
-
const
|
|
723
|
-
$(o, t, n,
|
|
724
|
-
},
|
|
725
|
-
e[n.field] =
|
|
726
|
-
const
|
|
727
|
-
|
|
722
|
+
function L(o, e, t, n, s) {
|
|
723
|
+
if (!n.editable || (o.activeEditRows !== t && T(o, t, e), s.classList.contains("editing"))) return;
|
|
724
|
+
const i = e[n.field];
|
|
725
|
+
s.classList.add("editing");
|
|
726
|
+
const l = (h) => {
|
|
727
|
+
$(o, t, n, h, e);
|
|
728
|
+
}, r = () => {
|
|
729
|
+
e[n.field] = i;
|
|
730
|
+
const h = s.querySelector("input,textarea,select");
|
|
731
|
+
h && (typeof HTMLInputElement < "u" && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!i : "value" in h && (h.value = i ?? ""));
|
|
728
732
|
}, a = document.createElement("div");
|
|
729
|
-
a.style.display = "contents",
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
732
|
-
const
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
const
|
|
736
|
-
return
|
|
733
|
+
a.style.display = "contents", s.innerHTML = "", s.appendChild(a);
|
|
734
|
+
const f = n.__editorTemplate, p = n.editor || (f ? "template" : De(n)), w = i;
|
|
735
|
+
if (p === "template" && f) {
|
|
736
|
+
const h = f.cloneNode(!0), c = n.__compiledEditor;
|
|
737
|
+
c ? h.innerHTML = c({ row: e, value: i, field: n.field, column: n }) : h.querySelectorAll("*").forEach((u) => {
|
|
738
|
+
u.childNodes.length === 1 && u.firstChild?.nodeType === Node.TEXT_NODE && (u.textContent = u.textContent?.replace(/{{\s*value\s*}}/g, i == null ? "" : String(i)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (b, y) => {
|
|
739
|
+
const v = e[y];
|
|
740
|
+
return v == null ? "" : String(v);
|
|
737
741
|
}) || "");
|
|
738
742
|
});
|
|
739
|
-
const
|
|
740
|
-
if (
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
const b =
|
|
744
|
-
|
|
745
|
-
}),
|
|
743
|
+
const d = h.querySelector("input,textarea,select");
|
|
744
|
+
if (d) {
|
|
745
|
+
const u = typeof HTMLInputElement < "u";
|
|
746
|
+
u && d instanceof HTMLInputElement && d.type === "checkbox" ? d.checked = !!i : "value" in d && (d.value = i ?? ""), d.addEventListener("blur", () => {
|
|
747
|
+
const b = u && d instanceof HTMLInputElement && d.type === "checkbox" ? d.checked : d.value;
|
|
748
|
+
l(b);
|
|
749
|
+
}), d.addEventListener("keydown", (b) => {
|
|
746
750
|
if (b.key === "Enter") {
|
|
747
|
-
const y =
|
|
748
|
-
|
|
751
|
+
const y = u && d instanceof HTMLInputElement && d.type === "checkbox" ? d.checked : d.value;
|
|
752
|
+
l(y);
|
|
749
753
|
}
|
|
750
|
-
b.key === "Escape" &&
|
|
751
|
-
}),
|
|
752
|
-
const b =
|
|
753
|
-
|
|
754
|
-
}), setTimeout(() =>
|
|
755
|
-
}
|
|
756
|
-
a.appendChild(
|
|
757
|
-
} else if (typeof
|
|
758
|
-
const
|
|
759
|
-
|
|
760
|
-
} else if (typeof
|
|
761
|
-
const
|
|
762
|
-
typeof
|
|
763
|
-
} else if (
|
|
764
|
-
const
|
|
765
|
-
|
|
766
|
-
const
|
|
767
|
-
if (
|
|
754
|
+
b.key === "Escape" && r();
|
|
755
|
+
}), u && d instanceof HTMLInputElement && d.type === "checkbox" && d.addEventListener("change", () => {
|
|
756
|
+
const b = d.checked;
|
|
757
|
+
l(b);
|
|
758
|
+
}), setTimeout(() => d.focus(), 0);
|
|
759
|
+
}
|
|
760
|
+
a.appendChild(h);
|
|
761
|
+
} else if (typeof p == "string") {
|
|
762
|
+
const h = document.createElement(p);
|
|
763
|
+
h.value = w, h.addEventListener("change", () => l(h.value)), a.appendChild(h);
|
|
764
|
+
} else if (typeof p == "function") {
|
|
765
|
+
const h = p({ row: e, value: w, field: n.field, column: n, commit: l, cancel: r });
|
|
766
|
+
typeof h == "string" ? a.innerHTML = h : a.appendChild(h);
|
|
767
|
+
} else if (p && typeof p == "object") {
|
|
768
|
+
const h = document.createElement("div");
|
|
769
|
+
h.setAttribute("data-external-editor", ""), h.setAttribute("data-field", n.field), a.appendChild(h);
|
|
770
|
+
const c = { row: e, value: w, field: n.field, column: n, commit: l, cancel: r };
|
|
771
|
+
if (p.mount)
|
|
768
772
|
try {
|
|
769
|
-
|
|
773
|
+
p.mount({ placeholder: h, context: c, spec: p });
|
|
770
774
|
} catch {
|
|
771
775
|
}
|
|
772
776
|
else
|
|
773
777
|
o.dispatchEvent(
|
|
774
|
-
new CustomEvent("mount-external-editor", { detail: { placeholder:
|
|
778
|
+
new CustomEvent("mount-external-editor", { detail: { placeholder: h, spec: p, context: c } })
|
|
775
779
|
);
|
|
776
780
|
}
|
|
777
781
|
}
|
|
@@ -784,8 +788,8 @@ function J(o, e) {
|
|
|
784
788
|
}
|
|
785
789
|
function Q(o, e, t) {
|
|
786
790
|
o.sortState = { field: e.field, direction: t };
|
|
787
|
-
const n = e.sortComparator || ((
|
|
788
|
-
o._rows.sort((
|
|
791
|
+
const n = e.sortComparator || ((s, i) => s == null && i == null ? 0 : s == null ? -1 : i == null || s > i ? 1 : s < i ? -1 : 0);
|
|
792
|
+
o._rows.sort((s, i) => n(s[e.field], i[e.field], s, i) * t), o.__rowRenderEpoch++, o.rowPool.forEach((s) => s.__epoch = -1), V(o), o.refreshVirtualWindow(!0), o.dispatchEvent(
|
|
789
793
|
new CustomEvent("sort-change", { detail: { field: e.field, direction: t } })
|
|
790
794
|
), o.requestStateChange?.();
|
|
791
795
|
}
|
|
@@ -793,41 +797,41 @@ function V(o) {
|
|
|
793
797
|
o.headerRowEl = o.findHeaderRow();
|
|
794
798
|
const e = o.headerRowEl;
|
|
795
799
|
e.innerHTML = "", e.setAttribute("role", "row"), e.setAttribute("aria-rowindex", "1"), o.visibleColumns.forEach((t, n) => {
|
|
796
|
-
const
|
|
797
|
-
|
|
798
|
-
const
|
|
799
|
-
if (
|
|
800
|
+
const s = document.createElement("div");
|
|
801
|
+
s.className = "cell", B(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");
|
|
802
|
+
const i = t.__headerTemplate;
|
|
803
|
+
if (i) Array.from(i.childNodes).forEach((l) => s.appendChild(l.cloneNode(!0)));
|
|
800
804
|
else {
|
|
801
|
-
const
|
|
802
|
-
|
|
805
|
+
const l = t.header || t.field, r = document.createElement("span");
|
|
806
|
+
r.textContent = l, s.appendChild(r);
|
|
803
807
|
}
|
|
804
808
|
if (t.sortable) {
|
|
805
|
-
|
|
806
|
-
const
|
|
807
|
-
B(
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
o.resizeController?.isResizing || o.dispatchHeaderClick?.(a, n,
|
|
811
|
-
}),
|
|
809
|
+
s.classList.add("sortable"), s.tabIndex = 0;
|
|
810
|
+
const l = document.createElement("span");
|
|
811
|
+
B(l, "sort-indicator"), l.style.opacity = "0.6";
|
|
812
|
+
const r = o.sortState?.field === t.field ? o.sortState.direction : 0;
|
|
813
|
+
l.textContent = r === 1 ? "▲" : r === -1 ? "▼" : "⇅", s.appendChild(l), s.setAttribute("aria-sort", r === 0 ? "none" : r === 1 ? "ascending" : "descending"), s.addEventListener("click", (a) => {
|
|
814
|
+
o.resizeController?.isResizing || o.dispatchHeaderClick?.(a, n, s) || J(o, t);
|
|
815
|
+
}), s.addEventListener("keydown", (a) => {
|
|
812
816
|
if (a.key === "Enter" || a.key === " ") {
|
|
813
|
-
if (a.preventDefault(), o.dispatchHeaderClick?.(a, n,
|
|
817
|
+
if (a.preventDefault(), o.dispatchHeaderClick?.(a, n, s)) return;
|
|
814
818
|
J(o, t);
|
|
815
819
|
}
|
|
816
820
|
});
|
|
817
821
|
}
|
|
818
822
|
if (t.resizable) {
|
|
819
|
-
t.sticky || (
|
|
820
|
-
const
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
}),
|
|
823
|
+
t.sticky || (s.style.position = "relative");
|
|
824
|
+
const l = document.createElement("div");
|
|
825
|
+
l.className = "resize-handle", l.setAttribute("aria-hidden", "true"), l.addEventListener("mousedown", (r) => {
|
|
826
|
+
r.stopPropagation(), r.preventDefault(), o.resizeController.start(r, n, s);
|
|
827
|
+
}), s.appendChild(l);
|
|
824
828
|
}
|
|
825
|
-
e.appendChild(
|
|
829
|
+
e.appendChild(s);
|
|
826
830
|
});
|
|
827
831
|
try {
|
|
828
832
|
const t = o.shadowRoot;
|
|
829
|
-
t && t.querySelectorAll(".header-group-row .cell").forEach((
|
|
830
|
-
|
|
833
|
+
t && t.querySelectorAll(".header-group-row .cell").forEach((s) => {
|
|
834
|
+
s.getAttribute("data-group") && s.classList.add("grouped");
|
|
831
835
|
});
|
|
832
836
|
} catch {
|
|
833
837
|
}
|
|
@@ -836,34 +840,34 @@ function V(o) {
|
|
|
836
840
|
});
|
|
837
841
|
}
|
|
838
842
|
function Be(o) {
|
|
839
|
-
let e = null, t = null, n = null,
|
|
840
|
-
const
|
|
843
|
+
let e = null, t = null, n = null, s = null;
|
|
844
|
+
const i = (a) => {
|
|
841
845
|
if (!e) return;
|
|
842
|
-
const
|
|
843
|
-
w.width =
|
|
846
|
+
const f = a.clientX - e.startX, p = Math.max(40, e.startWidth + f), w = o.visibleColumns[e.colIndex];
|
|
847
|
+
w.width = p, w.__userResized = !0, w.__renderedWidth = p, t == null && (t = requestAnimationFrame(() => {
|
|
844
848
|
t = null, o.updateTemplate?.();
|
|
845
849
|
})), o.dispatchEvent(
|
|
846
|
-
new CustomEvent("column-resize", { detail: { field: w.field, width:
|
|
850
|
+
new CustomEvent("column-resize", { detail: { field: w.field, width: p } })
|
|
847
851
|
);
|
|
848
852
|
};
|
|
849
|
-
let
|
|
850
|
-
const
|
|
853
|
+
let l = !1;
|
|
854
|
+
const r = () => {
|
|
851
855
|
const a = e !== null;
|
|
852
|
-
a && (
|
|
853
|
-
|
|
854
|
-
})), window.removeEventListener("mousemove",
|
|
856
|
+
a && (l = !0, requestAnimationFrame(() => {
|
|
857
|
+
l = !1;
|
|
858
|
+
})), window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", r), n !== null && (document.documentElement.style.cursor = n, n = null), s !== null && (document.body.style.userSelect = s, s = null), e = null, a && o.requestStateChange && o.requestStateChange();
|
|
855
859
|
};
|
|
856
860
|
return {
|
|
857
861
|
get isResizing() {
|
|
858
|
-
return e !== null ||
|
|
862
|
+
return e !== null || l;
|
|
859
863
|
},
|
|
860
|
-
start(a,
|
|
864
|
+
start(a, f, p) {
|
|
861
865
|
a.preventDefault();
|
|
862
|
-
const w =
|
|
863
|
-
e = { startX: a.clientX, colIndex:
|
|
866
|
+
const w = p.getBoundingClientRect();
|
|
867
|
+
e = { startX: a.clientX, colIndex: f, startWidth: w.width }, window.addEventListener("mousemove", i), window.addEventListener("mouseup", r), 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";
|
|
864
868
|
},
|
|
865
869
|
dispose() {
|
|
866
|
-
|
|
870
|
+
r();
|
|
867
871
|
}
|
|
868
872
|
};
|
|
869
873
|
}
|
|
@@ -884,20 +888,20 @@ function Ke(o, e) {
|
|
|
884
888
|
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);
|
|
885
889
|
}
|
|
886
890
|
function We(o, e) {
|
|
887
|
-
const t = o?.header?.title ?? "", n = !!t,
|
|
888
|
-
let
|
|
889
|
-
for (const
|
|
890
|
-
|
|
891
|
-
for (const
|
|
892
|
-
|
|
893
|
-
for (const
|
|
894
|
-
(
|
|
895
|
-
for (const
|
|
896
|
-
(
|
|
897
|
-
|
|
898
|
-
for (const
|
|
899
|
-
const b = e.activePanel ===
|
|
900
|
-
|
|
891
|
+
const t = o?.header?.title ?? "", n = !!t, s = o?.header?.toolbarButtons ?? [], i = s.length > 0, l = e.toolbarButtons.size > 0, r = e.lightDomButtons.length > 0, a = e.toolPanels.size > 0, p = (i || l || r) && a, w = [...s].sort((u, b) => (u.order ?? 100) - (b.order ?? 100)), h = [...e.toolbarButtons.values()].sort((u, b) => (u.order ?? 100) - (b.order ?? 100)), c = [...e.toolPanels.values()].sort((u, b) => (u.order ?? 100) - (b.order ?? 100));
|
|
892
|
+
let d = "";
|
|
893
|
+
for (const u of w)
|
|
894
|
+
u.icon && u.action && (d += `<button class="tbw-toolbar-btn" data-btn="${u.id}" title="${u.label}" aria-label="${u.label}"${u.disabled ? " disabled" : ""}>${u.icon}</button>`);
|
|
895
|
+
for (const u of h)
|
|
896
|
+
u.icon && u.action && (d += `<button class="tbw-toolbar-btn" data-btn="${u.id}" title="${u.label}" aria-label="${u.label}"${u.disabled ? " disabled" : ""}>${u.icon}</button>`);
|
|
897
|
+
for (const u of w)
|
|
898
|
+
(u.element || u.render) && (d += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${u.id}"></div>`);
|
|
899
|
+
for (const u of h)
|
|
900
|
+
(u.element || u.render) && (d += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${u.id}"></div>`);
|
|
901
|
+
r && (d += '<slot name="toolbar"></slot>'), p && (d += '<div class="tbw-toolbar-separator"></div>');
|
|
902
|
+
for (const u of c) {
|
|
903
|
+
const b = e.activePanel === u.id;
|
|
904
|
+
d += `<button class="tbw-toolbar-btn${b ? " active" : ""}" data-panel="${u.id}" title="${u.tooltip ?? u.title}" aria-label="${u.tooltip ?? u.title}" aria-pressed="${b}" aria-controls="tbw-panel-${u.id}">${u.icon}</button>`;
|
|
901
905
|
}
|
|
902
906
|
return `
|
|
903
907
|
<div class="tbw-shell-header" part="shell-header" role="banner">
|
|
@@ -906,16 +910,16 @@ function We(o, e) {
|
|
|
906
910
|
<slot name="header-content"></slot>
|
|
907
911
|
</div>
|
|
908
912
|
<div class="tbw-shell-toolbar" part="shell-toolbar" role="toolbar" aria-label="Grid tools">
|
|
909
|
-
${
|
|
913
|
+
${d}
|
|
910
914
|
</div>
|
|
911
915
|
</div>
|
|
912
916
|
`;
|
|
913
917
|
}
|
|
914
918
|
function Fe(o, e, t) {
|
|
915
|
-
const n = o?.toolPanel?.position ?? "right",
|
|
916
|
-
<aside class="tbw-tool-panel${
|
|
919
|
+
const n = o?.toolPanel?.position ?? "right", s = e.toolPanels.size > 0, i = e.activePanel !== null, l = e.activePanel ? e.toolPanels.get(e.activePanel) : null, r = s ? `
|
|
920
|
+
<aside class="tbw-tool-panel${i ? " open" : ""}" part="tool-panel" data-position="${n}" role="complementary" aria-label="${l?.title ?? "Tool panel"}" id="tbw-panel-${e.activePanel ?? "closed"}">
|
|
917
921
|
<div class="tbw-tool-panel-header">
|
|
918
|
-
<span class="tbw-tool-panel-title">${
|
|
922
|
+
<span class="tbw-tool-panel-title">${l?.title ?? ""}</span>
|
|
919
923
|
<button class="tbw-tool-panel-close" aria-label="Close panel">✕</button>
|
|
920
924
|
</div>
|
|
921
925
|
<div class="tbw-tool-panel-content" role="region"></div>
|
|
@@ -923,7 +927,7 @@ function Fe(o, e, t) {
|
|
|
923
927
|
` : "";
|
|
924
928
|
return n === "left" ? `
|
|
925
929
|
<div class="tbw-shell-body">
|
|
926
|
-
${
|
|
930
|
+
${r}
|
|
927
931
|
<div class="tbw-grid-content">
|
|
928
932
|
${t}
|
|
929
933
|
</div>
|
|
@@ -933,7 +937,7 @@ function Fe(o, e, t) {
|
|
|
933
937
|
<div class="tbw-grid-content">
|
|
934
938
|
${t}
|
|
935
939
|
</div>
|
|
936
|
-
${
|
|
940
|
+
${r}
|
|
937
941
|
</div>
|
|
938
942
|
`;
|
|
939
943
|
}
|
|
@@ -942,62 +946,62 @@ function ee(o, e) {
|
|
|
942
946
|
if (!t) return;
|
|
943
947
|
t.style.display = "none";
|
|
944
948
|
const n = t.querySelectorAll("tbw-grid-header-content");
|
|
945
|
-
e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((
|
|
946
|
-
|
|
949
|
+
e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((i, l) => {
|
|
950
|
+
i.setAttribute("slot", "header-content");
|
|
947
951
|
});
|
|
948
|
-
const
|
|
949
|
-
e.lightDomButtons = Array.from(
|
|
950
|
-
const
|
|
951
|
-
return
|
|
952
|
-
}), e.lightDomButtons.forEach((
|
|
953
|
-
|
|
952
|
+
const s = t.querySelectorAll("tbw-grid-tool-button");
|
|
953
|
+
e.lightDomButtons = Array.from(s), e.lightDomButtons.sort((i, l) => {
|
|
954
|
+
const r = parseInt(i.getAttribute("order") ?? "100", 10), a = parseInt(l.getAttribute("order") ?? "100", 10);
|
|
955
|
+
return r - a;
|
|
956
|
+
}), e.lightDomButtons.forEach((i) => {
|
|
957
|
+
i.setAttribute("slot", "toolbar");
|
|
954
958
|
});
|
|
955
959
|
}
|
|
956
960
|
function Ve(o, e, t, n) {
|
|
957
|
-
const
|
|
958
|
-
|
|
959
|
-
const
|
|
961
|
+
const s = o.querySelector(".tbw-shell-toolbar");
|
|
962
|
+
s && s.addEventListener("click", (l) => {
|
|
963
|
+
const r = l.target, a = r.closest("[data-panel]");
|
|
960
964
|
if (a) {
|
|
961
|
-
const
|
|
962
|
-
|
|
965
|
+
const p = a.getAttribute("data-panel");
|
|
966
|
+
p && n.onPanelToggle(p);
|
|
963
967
|
return;
|
|
964
968
|
}
|
|
965
|
-
const
|
|
966
|
-
if (
|
|
967
|
-
const
|
|
968
|
-
|
|
969
|
+
const f = r.closest("[data-btn]");
|
|
970
|
+
if (f) {
|
|
971
|
+
const p = f.getAttribute("data-btn");
|
|
972
|
+
p && n.onToolbarButtonClick(p);
|
|
969
973
|
}
|
|
970
974
|
});
|
|
971
|
-
const
|
|
972
|
-
|
|
975
|
+
const i = o.querySelector(".tbw-tool-panel-close");
|
|
976
|
+
i && i.addEventListener("click", () => {
|
|
973
977
|
n.onPanelClose();
|
|
974
978
|
});
|
|
975
979
|
}
|
|
976
980
|
function Ge(o, e, t) {
|
|
977
981
|
const n = [...e?.header?.toolbarButtons ?? [], ...t.toolbarButtons.values()];
|
|
978
|
-
for (const
|
|
979
|
-
const
|
|
980
|
-
if (!
|
|
981
|
-
const
|
|
982
|
-
if (
|
|
983
|
-
|
|
984
|
-
else if (
|
|
985
|
-
const
|
|
986
|
-
|
|
982
|
+
for (const s of n) {
|
|
983
|
+
const i = o.querySelector(`[data-btn-slot="${s.id}"]`);
|
|
984
|
+
if (!i) continue;
|
|
985
|
+
const l = t.toolbarButtonCleanups.get(s.id);
|
|
986
|
+
if (l && (l(), t.toolbarButtonCleanups.delete(s.id)), s.element)
|
|
987
|
+
i.appendChild(s.element);
|
|
988
|
+
else if (s.render) {
|
|
989
|
+
const r = s.render(i);
|
|
990
|
+
r && t.toolbarButtonCleanups.set(s.id, r);
|
|
987
991
|
}
|
|
988
992
|
}
|
|
989
993
|
}
|
|
990
994
|
function te(o, e) {
|
|
991
995
|
const t = o.querySelector(".tbw-shell-content");
|
|
992
996
|
if (!t) return;
|
|
993
|
-
const n = [...e.headerContents.values()].sort((
|
|
994
|
-
for (const
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
let
|
|
998
|
-
|
|
999
|
-
const a =
|
|
1000
|
-
a && e.headerContentCleanups.set(
|
|
997
|
+
const n = [...e.headerContents.values()].sort((i, l) => (i.order ?? 100) - (l.order ?? 100)), s = t.querySelector('slot[name="header-content"]');
|
|
998
|
+
for (const i of n) {
|
|
999
|
+
const l = e.headerContentCleanups.get(i.id);
|
|
1000
|
+
l && (l(), e.headerContentCleanups.delete(i.id));
|
|
1001
|
+
let r = t.querySelector(`[data-header-content="${i.id}"]`);
|
|
1002
|
+
r || (r = document.createElement("div"), r.setAttribute("data-header-content", i.id), s ? t.insertBefore(r, s) : t.appendChild(r));
|
|
1003
|
+
const a = i.render(r);
|
|
1004
|
+
a && e.headerContentCleanups.set(i.id, a);
|
|
1001
1005
|
}
|
|
1002
1006
|
}
|
|
1003
1007
|
function Ue(o, e) {
|
|
@@ -1007,13 +1011,13 @@ function Ue(o, e) {
|
|
|
1007
1011
|
const n = o.querySelector(".tbw-tool-panel-content");
|
|
1008
1012
|
if (!n) return;
|
|
1009
1013
|
e.activePanelCleanup && (e.activePanelCleanup(), e.activePanelCleanup = null), n.innerHTML = "";
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1014
|
+
const s = t.render(n);
|
|
1015
|
+
s && (e.activePanelCleanup = s);
|
|
1012
1016
|
}
|
|
1013
1017
|
function oe(o, e) {
|
|
1014
1018
|
o.querySelectorAll("[data-panel]").forEach((n) => {
|
|
1015
|
-
const
|
|
1016
|
-
n.classList.toggle("active",
|
|
1019
|
+
const i = n.getAttribute("data-panel") === e.activePanel;
|
|
1020
|
+
n.classList.toggle("active", i), n.setAttribute("aria-pressed", String(i));
|
|
1017
1021
|
});
|
|
1018
1022
|
}
|
|
1019
1023
|
function ne(o, e) {
|
|
@@ -1021,8 +1025,8 @@ function ne(o, e) {
|
|
|
1021
1025
|
if (!t) return;
|
|
1022
1026
|
const n = e.activePanel !== null;
|
|
1023
1027
|
if (t.classList.toggle("open", n), n && e.activePanel) {
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1028
|
+
const s = e.toolPanels.get(e.activePanel), i = t.querySelector(".tbw-tool-panel-title");
|
|
1029
|
+
i && (i.textContent = s?.title ?? ""), t.setAttribute("aria-label", `${s?.title ?? "Tool"} panel`), t.id = `tbw-panel-${e.activePanel}`;
|
|
1026
1030
|
}
|
|
1027
1031
|
}
|
|
1028
1032
|
function Xe(o, e) {
|
|
@@ -1042,11 +1046,11 @@ function Xe(o, e) {
|
|
|
1042
1046
|
source: "config"
|
|
1043
1047
|
});
|
|
1044
1048
|
for (let n = 0; n < e.lightDomButtons.length; n++) {
|
|
1045
|
-
const
|
|
1049
|
+
const i = e.lightDomButtons[n].querySelector("button");
|
|
1046
1050
|
t.push({
|
|
1047
1051
|
id: `light-dom-${n}`,
|
|
1048
|
-
label:
|
|
1049
|
-
disabled:
|
|
1052
|
+
label: i?.getAttribute("title") ?? i?.getAttribute("aria-label") ?? "",
|
|
1053
|
+
disabled: i?.disabled ?? !1,
|
|
1050
1054
|
source: "light-dom"
|
|
1051
1055
|
});
|
|
1052
1056
|
}
|
|
@@ -1194,13 +1198,21 @@ class Ye {
|
|
|
1194
1198
|
for (const e of this.plugins)
|
|
1195
1199
|
e.afterRender?.();
|
|
1196
1200
|
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Execute onScrollRender hook on all plugins.
|
|
1203
|
+
* Called after scroll-triggered row rendering for lightweight visual state updates.
|
|
1204
|
+
*/
|
|
1205
|
+
onScrollRender() {
|
|
1206
|
+
for (const e of this.plugins)
|
|
1207
|
+
e.onScrollRender?.();
|
|
1208
|
+
}
|
|
1197
1209
|
/**
|
|
1198
1210
|
* Execute renderRow hook on all plugins.
|
|
1199
1211
|
* Returns true if any plugin handled the row.
|
|
1200
1212
|
*/
|
|
1201
1213
|
renderRow(e, t, n) {
|
|
1202
|
-
for (const
|
|
1203
|
-
if (
|
|
1214
|
+
for (const s of this.plugins)
|
|
1215
|
+
if (s.renderRow?.(e, t, n))
|
|
1204
1216
|
return !0;
|
|
1205
1217
|
return !1;
|
|
1206
1218
|
}
|
|
@@ -1287,8 +1299,8 @@ class Ye {
|
|
|
1287
1299
|
getContextMenuItems(e) {
|
|
1288
1300
|
const t = [];
|
|
1289
1301
|
for (const n of this.plugins) {
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1302
|
+
const s = n.getContextMenuItems?.(e);
|
|
1303
|
+
s && t.push(...s);
|
|
1292
1304
|
}
|
|
1293
1305
|
return t;
|
|
1294
1306
|
}
|
|
@@ -1321,44 +1333,46 @@ class Ye {
|
|
|
1321
1333
|
class q extends HTMLElement {
|
|
1322
1334
|
// TODO: Rename to 'data-grid' when migration is complete
|
|
1323
1335
|
static tagName = "tbw-grid";
|
|
1324
|
-
#
|
|
1325
|
-
#
|
|
1336
|
+
#n;
|
|
1337
|
+
#i = !1;
|
|
1326
1338
|
// ---------------- Ready Promise ----------------
|
|
1327
|
-
#
|
|
1328
|
-
#
|
|
1339
|
+
#z;
|
|
1340
|
+
#N;
|
|
1329
1341
|
// ================== INPUT PROPERTIES ==================
|
|
1330
1342
|
// These backing fields store raw user input. They are merged into
|
|
1331
1343
|
// #effectiveConfig by #mergeEffectiveConfig(). Never read directly
|
|
1332
1344
|
// for rendering logic - always use effectiveConfig or derived state.
|
|
1333
|
-
#
|
|
1345
|
+
#l = [];
|
|
1334
1346
|
#r;
|
|
1335
|
-
#
|
|
1336
|
-
#v;
|
|
1347
|
+
#g;
|
|
1337
1348
|
#C;
|
|
1349
|
+
#y;
|
|
1338
1350
|
// ================== SINGLE SOURCE OF TRUTH ==================
|
|
1339
1351
|
// All input sources converge here. This is the canonical config
|
|
1340
1352
|
// that all rendering and logic should read from.
|
|
1341
|
-
#
|
|
1342
|
-
#
|
|
1343
|
-
#
|
|
1344
|
-
#
|
|
1345
|
-
#
|
|
1353
|
+
#o = {};
|
|
1354
|
+
#u = !1;
|
|
1355
|
+
#L = 0;
|
|
1356
|
+
#E = null;
|
|
1357
|
+
#R = !1;
|
|
1346
1358
|
// Cached flag for plugin scroll handlers
|
|
1347
|
-
#
|
|
1359
|
+
#k;
|
|
1348
1360
|
// Cached hook to avoid closures
|
|
1349
|
-
#u;
|
|
1350
1361
|
#f;
|
|
1351
|
-
#R = !1;
|
|
1352
1362
|
#p;
|
|
1363
|
+
#_ = !1;
|
|
1353
1364
|
#w;
|
|
1365
|
+
#b;
|
|
1366
|
+
#A = null;
|
|
1367
|
+
#S = null;
|
|
1354
1368
|
// ---------------- Plugin System ----------------
|
|
1355
|
-
#
|
|
1369
|
+
#t;
|
|
1356
1370
|
// ---------------- Column State ----------------
|
|
1357
|
-
#
|
|
1358
|
-
#
|
|
1371
|
+
#P;
|
|
1372
|
+
#d;
|
|
1359
1373
|
// ---------------- Shell State ----------------
|
|
1360
1374
|
#e = $e();
|
|
1361
|
-
#
|
|
1375
|
+
#a = !1;
|
|
1362
1376
|
// ================== DERIVED STATE ==================
|
|
1363
1377
|
// _rows: result of applying plugin processRows hooks
|
|
1364
1378
|
_rows = [];
|
|
@@ -1366,10 +1380,10 @@ class q extends HTMLElement {
|
|
|
1366
1380
|
// This ensures effectiveConfig.columns is the single source of truth for columns
|
|
1367
1381
|
// _columns always contains ALL columns (including hidden)
|
|
1368
1382
|
get _columns() {
|
|
1369
|
-
return this.#
|
|
1383
|
+
return this.#o.columns ?? [];
|
|
1370
1384
|
}
|
|
1371
1385
|
set _columns(e) {
|
|
1372
|
-
this.#
|
|
1386
|
+
this.#o.columns = e;
|
|
1373
1387
|
}
|
|
1374
1388
|
// visibleColumns returns only visible columns for rendering
|
|
1375
1389
|
// This is what header/row rendering should use
|
|
@@ -1418,56 +1432,56 @@ class q extends HTMLElement {
|
|
|
1418
1432
|
return this._rows;
|
|
1419
1433
|
}
|
|
1420
1434
|
set rows(e) {
|
|
1421
|
-
const t = this.#
|
|
1422
|
-
this.#
|
|
1435
|
+
const t = this.#l;
|
|
1436
|
+
this.#l = e, t !== e && this.#Z();
|
|
1423
1437
|
}
|
|
1424
1438
|
/**
|
|
1425
1439
|
* Get the original unfiltered/unprocessed rows.
|
|
1426
1440
|
* Use this when you need access to all source data regardless of active filters.
|
|
1427
1441
|
*/
|
|
1428
1442
|
get sourceRows() {
|
|
1429
|
-
return this.#
|
|
1443
|
+
return this.#l;
|
|
1430
1444
|
}
|
|
1431
1445
|
get columns() {
|
|
1432
1446
|
return [...this._columns];
|
|
1433
1447
|
}
|
|
1434
1448
|
set columns(e) {
|
|
1435
1449
|
const t = this.#r;
|
|
1436
|
-
this.#r = e, t !== e && this.#
|
|
1450
|
+
this.#r = e, t !== e && this.#J();
|
|
1437
1451
|
}
|
|
1438
1452
|
get gridConfig() {
|
|
1439
|
-
return this.#
|
|
1453
|
+
return this.#o;
|
|
1440
1454
|
}
|
|
1441
1455
|
set gridConfig(e) {
|
|
1442
|
-
const t = this.#
|
|
1443
|
-
this.#
|
|
1456
|
+
const t = this.#g;
|
|
1457
|
+
this.#g = e, t !== e && this.#Q();
|
|
1444
1458
|
}
|
|
1445
1459
|
get fitMode() {
|
|
1446
|
-
return this.#
|
|
1460
|
+
return this.#o.fitMode ?? "stretch";
|
|
1447
1461
|
}
|
|
1448
1462
|
set fitMode(e) {
|
|
1449
|
-
const t = this.#
|
|
1450
|
-
this.#
|
|
1463
|
+
const t = this.#C;
|
|
1464
|
+
this.#C = e, t !== e && this.#j();
|
|
1451
1465
|
}
|
|
1452
1466
|
get editOn() {
|
|
1453
|
-
return this.#
|
|
1467
|
+
return this.#o.editOn;
|
|
1454
1468
|
}
|
|
1455
1469
|
set editOn(e) {
|
|
1456
|
-
const t = this.#
|
|
1457
|
-
this.#
|
|
1470
|
+
const t = this.#y;
|
|
1471
|
+
this.#y = e, t !== e && this.#Y();
|
|
1458
1472
|
}
|
|
1459
1473
|
// Effective config accessor for internal modules and plugins
|
|
1460
1474
|
// Returns the merged config (single source of truth) before plugin processing
|
|
1461
1475
|
// Use this when you need the raw merged config (e.g., for column definitions including hidden)
|
|
1462
1476
|
get effectiveConfig() {
|
|
1463
|
-
return this.#
|
|
1477
|
+
return this.#o;
|
|
1464
1478
|
}
|
|
1465
1479
|
constructor() {
|
|
1466
|
-
super(), this.#
|
|
1480
|
+
super(), this.#n = this.attachShadow({ mode: "open" }), this.#V(), this.#z = new Promise((e) => this.#N = e);
|
|
1467
1481
|
}
|
|
1468
|
-
#
|
|
1482
|
+
#V() {
|
|
1469
1483
|
const e = new CSSStyleSheet();
|
|
1470
|
-
e.replaceSync(we), this.#
|
|
1484
|
+
e.replaceSync(we), this.#n.adoptedStyleSheets = [e];
|
|
1471
1485
|
}
|
|
1472
1486
|
// ---------------- Plugin System ----------------
|
|
1473
1487
|
/**
|
|
@@ -1475,14 +1489,14 @@ class q extends HTMLElement {
|
|
|
1475
1489
|
* Used by plugins for inter-plugin communication.
|
|
1476
1490
|
*/
|
|
1477
1491
|
getPlugin(e) {
|
|
1478
|
-
return this.#
|
|
1492
|
+
return this.#t?.getPlugin(e);
|
|
1479
1493
|
}
|
|
1480
1494
|
/**
|
|
1481
1495
|
* Get a plugin instance by its name.
|
|
1482
1496
|
* Used for loose coupling between plugins (avoids static imports).
|
|
1483
1497
|
*/
|
|
1484
1498
|
getPluginByName(e) {
|
|
1485
|
-
return this.#
|
|
1499
|
+
return this.#t?.getPluginByName(e);
|
|
1486
1500
|
}
|
|
1487
1501
|
/**
|
|
1488
1502
|
* Request a full re-render of the grid.
|
|
@@ -1490,7 +1504,7 @@ class q extends HTMLElement {
|
|
|
1490
1504
|
* Note: This does NOT reset plugin state - just re-processes rows/columns and renders.
|
|
1491
1505
|
*/
|
|
1492
1506
|
requestRender() {
|
|
1493
|
-
this.#
|
|
1507
|
+
this.#T(), this.#O(), this.#x(), this.updateTemplate(), this.refreshVirtualWindow(!0);
|
|
1494
1508
|
}
|
|
1495
1509
|
/**
|
|
1496
1510
|
* Request a lightweight style update without rebuilding DOM.
|
|
@@ -1498,186 +1512,207 @@ class q extends HTMLElement {
|
|
|
1498
1512
|
* This runs all plugin afterRender hooks without rebuilding row/column DOM.
|
|
1499
1513
|
*/
|
|
1500
1514
|
requestAfterRender() {
|
|
1501
|
-
this.#
|
|
1515
|
+
this.#m();
|
|
1502
1516
|
}
|
|
1503
1517
|
/**
|
|
1504
1518
|
* Initialize plugin system with instances from config.
|
|
1505
1519
|
* Plugins are class instances passed in gridConfig.plugins[].
|
|
1506
1520
|
*/
|
|
1507
|
-
#
|
|
1508
|
-
this.#
|
|
1509
|
-
const e = this.#
|
|
1510
|
-
this.#
|
|
1521
|
+
#q() {
|
|
1522
|
+
this.#t = new Ye(this);
|
|
1523
|
+
const e = this.#o?.plugins, t = Array.isArray(e) ? e : [];
|
|
1524
|
+
this.#t.attachAll(t);
|
|
1511
1525
|
}
|
|
1512
1526
|
/**
|
|
1513
1527
|
* Inject all plugin styles into the shadow DOM.
|
|
1514
1528
|
* Must be called after #render() since innerHTML wipes existing content.
|
|
1515
1529
|
*/
|
|
1516
|
-
#
|
|
1517
|
-
const e = this.#
|
|
1530
|
+
#I() {
|
|
1531
|
+
const e = this.#t?.getAllStyles() ?? "";
|
|
1518
1532
|
if (e) {
|
|
1519
1533
|
const t = document.createElement("style");
|
|
1520
|
-
t.setAttribute("data-plugin", "all"), t.textContent = e, this.#
|
|
1534
|
+
t.setAttribute("data-plugin", "all"), t.textContent = e, this.#n.appendChild(t);
|
|
1521
1535
|
}
|
|
1522
1536
|
}
|
|
1523
1537
|
/**
|
|
1524
1538
|
* Update plugins when grid config changes.
|
|
1525
1539
|
* With class-based plugins, we need to detach old and attach new.
|
|
1526
1540
|
*/
|
|
1527
|
-
#
|
|
1528
|
-
this.#
|
|
1541
|
+
#B() {
|
|
1542
|
+
this.#t && this.#t.detachAll(), this.#q(), this.#I(), this.#R = this.#t?.getAll().some((e) => e.onScroll) ?? !1;
|
|
1529
1543
|
}
|
|
1530
1544
|
/**
|
|
1531
1545
|
* Clean up plugin states when grid disconnects.
|
|
1532
1546
|
*/
|
|
1533
|
-
#
|
|
1534
|
-
this.#
|
|
1547
|
+
#G() {
|
|
1548
|
+
this.#t?.detachAll();
|
|
1535
1549
|
}
|
|
1536
1550
|
/**
|
|
1537
1551
|
* Collect tool panels and header content from all plugins.
|
|
1538
1552
|
* Called after plugins are attached but before render.
|
|
1539
1553
|
*/
|
|
1540
|
-
#
|
|
1541
|
-
if (!this.#
|
|
1542
|
-
const e = this.#
|
|
1554
|
+
#U() {
|
|
1555
|
+
if (!this.#t) return;
|
|
1556
|
+
const e = this.#t.getToolPanels();
|
|
1543
1557
|
for (const { panel: n } of e)
|
|
1544
1558
|
this.#e.toolPanels.has(n.id) || this.#e.toolPanels.set(n.id, n);
|
|
1545
|
-
const t = this.#
|
|
1559
|
+
const t = this.#t.getHeaderContents();
|
|
1546
1560
|
for (const { content: n } of t)
|
|
1547
1561
|
this.#e.headerContents.has(n.id) || this.#e.headerContents.set(n.id, n);
|
|
1548
1562
|
}
|
|
1549
1563
|
// ---------------- Lifecycle ----------------
|
|
1550
1564
|
connectedCallback() {
|
|
1551
|
-
this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#
|
|
1565
|
+
this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#h(), this.#q(), this.#U(), this.#i || (this.#F(), this.#I(), this.#i = !0), this.#$();
|
|
1552
1566
|
}
|
|
1553
1567
|
disconnectedCallback() {
|
|
1554
|
-
this.#
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
const t = this.#
|
|
1558
|
-
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.#
|
|
1559
|
-
te(this.#
|
|
1560
|
-
const
|
|
1561
|
-
|
|
1562
|
-
}
|
|
1563
|
-
this.setAttribute("data-upgraded", ""), this.hasAttribute("role") || this.setAttribute("role", "grid"), this.#
|
|
1564
|
-
|
|
1565
|
-
}, document.addEventListener("keydown", this.#
|
|
1568
|
+
this.#G(), je(this.#e), this.#a = !1, this.#f && (document.removeEventListener("keydown", this.#f, !0), this.#f = void 0), this.#p && (document.removeEventListener("mousedown", this.#p, !1), this.#p = void 0), this.#w && (document.removeEventListener("mousemove", this.#w), this.#w = void 0), this.#b && (document.removeEventListener("mouseup", this.#b), this.#b = void 0), this.resizeController && this.resizeController.dispose(), this.#u = !1;
|
|
1569
|
+
}
|
|
1570
|
+
#$() {
|
|
1571
|
+
const t = this.#n.querySelector(".tbw-grid-content") ?? this.#n.querySelector(".tbw-grid-root");
|
|
1572
|
+
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.#a) {
|
|
1573
|
+
te(this.#n, this.#e), Ge(this.#n, this.#o?.shell, this.#e);
|
|
1574
|
+
const i = this.#o?.shell?.toolPanel?.defaultOpen;
|
|
1575
|
+
i && this.#e.toolPanels.has(i) && this.openToolPanel(i);
|
|
1576
|
+
}
|
|
1577
|
+
this.setAttribute("data-upgraded", ""), this.hasAttribute("role") || this.setAttribute("role", "grid"), this.#u = !0, this.#c(), this.addEventListener("keydown", (i) => He(this, i)), this.#f || (this.#f = (i) => {
|
|
1578
|
+
i.key === "Escape" && this.activeEditRows !== -1 && this.#D(this.activeEditRows, !0);
|
|
1579
|
+
}, document.addEventListener("keydown", this.#f, !0)), this.#p || (this.#p = (i) => {
|
|
1566
1580
|
if (this.activeEditRows === -1) return;
|
|
1567
|
-
const
|
|
1568
|
-
!
|
|
1569
|
-
}, document.addEventListener("mousedown", this.#
|
|
1570
|
-
const n = t?.querySelector(".faux-vscroll"),
|
|
1571
|
-
if (this.virtualization.container = n ?? this, this.#
|
|
1581
|
+
const l = this.findRenderedRowElement(this.activeEditRows);
|
|
1582
|
+
!l || (i.composedPath && i.composedPath() || []).includes(l) || this.#D(this.activeEditRows, !1);
|
|
1583
|
+
}, document.addEventListener("mousedown", this.#p, !1));
|
|
1584
|
+
const n = t?.querySelector(".faux-vscroll"), s = t?.querySelector(".rows");
|
|
1585
|
+
if (this.virtualization.container = n ?? this, this.#R = this.#t?.getAll().some((i) => i.onScroll) ?? !1, n && s) {
|
|
1572
1586
|
n.addEventListener(
|
|
1573
1587
|
"scroll",
|
|
1574
1588
|
() => {
|
|
1575
|
-
if (!this.virtualization.enabled && !this.#
|
|
1576
|
-
const
|
|
1577
|
-
|
|
1578
|
-
this.#
|
|
1589
|
+
if (!this.virtualization.enabled && !this.#R) return;
|
|
1590
|
+
const l = n.scrollTop, r = this.virtualization.rowHeight, a = -(l % r);
|
|
1591
|
+
s.style.transform = `translateY(${a}px)`, this.#E = l, this.#L || (this.#L = requestAnimationFrame(() => {
|
|
1592
|
+
this.#L = 0, this.#E !== null && (this.#ne(this.#E), this.#E = null);
|
|
1579
1593
|
}));
|
|
1580
1594
|
},
|
|
1581
1595
|
{ passive: !0 }
|
|
1582
1596
|
);
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1597
|
+
const i = t?.querySelector(".rows-body");
|
|
1598
|
+
i && (i.addEventListener(
|
|
1585
1599
|
"wheel",
|
|
1586
|
-
(
|
|
1587
|
-
|
|
1600
|
+
(l) => {
|
|
1601
|
+
l.preventDefault(), n.scrollTop += l.deltaY;
|
|
1588
1602
|
},
|
|
1589
1603
|
{ passive: !1 }
|
|
1590
|
-
)
|
|
1604
|
+
), i.addEventListener(
|
|
1605
|
+
"touchstart",
|
|
1606
|
+
(l) => {
|
|
1607
|
+
l.touches.length === 1 && (this.#A = l.touches[0].clientY, this.#S = n.scrollTop);
|
|
1608
|
+
},
|
|
1609
|
+
{ passive: !0 }
|
|
1610
|
+
), i.addEventListener(
|
|
1611
|
+
"touchmove",
|
|
1612
|
+
(l) => {
|
|
1613
|
+
if (l.touches.length === 1 && this.#A !== null && this.#S !== null) {
|
|
1614
|
+
const r = this.#A - l.touches[0].clientY;
|
|
1615
|
+
n.scrollTop = this.#S + r, l.preventDefault();
|
|
1616
|
+
}
|
|
1617
|
+
},
|
|
1618
|
+
{ passive: !1 }
|
|
1619
|
+
), i.addEventListener(
|
|
1620
|
+
"touchend",
|
|
1621
|
+
() => {
|
|
1622
|
+
this.#A = null, this.#S = null;
|
|
1623
|
+
},
|
|
1624
|
+
{ passive: !0 }
|
|
1625
|
+
));
|
|
1591
1626
|
}
|
|
1592
|
-
this.resizeController = Be(this), this.#
|
|
1593
|
-
const
|
|
1594
|
-
if (
|
|
1595
|
-
const
|
|
1596
|
-
|
|
1627
|
+
this.resizeController = Be(this), this.#n.addEventListener("mousedown", (i) => this.#ie(i)), this.#w || (this.#w = (i) => this.#se(i), document.addEventListener("mousemove", this.#w)), this.#b || (this.#b = (i) => this.#le(i), document.addEventListener("mouseup", this.#b)), this.virtualization.enabled && requestAnimationFrame(() => this.refreshVirtualWindow(!0)), requestAnimationFrame(() => {
|
|
1628
|
+
const i = this.bodyEl.querySelector(".data-grid-row");
|
|
1629
|
+
if (i) {
|
|
1630
|
+
const l = i.getBoundingClientRect().height;
|
|
1631
|
+
l && Math.abs(l - this.virtualization.rowHeight) > 0.1 && (this.virtualization.rowHeight = l, this.refreshVirtualWindow(!0));
|
|
1597
1632
|
}
|
|
1598
|
-
}), queueMicrotask(() => this.#
|
|
1633
|
+
}), queueMicrotask(() => this.#X()), requestAnimationFrame(() => requestAnimationFrame(() => this.#N?.()));
|
|
1599
1634
|
}
|
|
1600
1635
|
// ---------------- Event Emitters ----------------
|
|
1601
|
-
#
|
|
1636
|
+
#s(e, t) {
|
|
1602
1637
|
this.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
|
|
1603
1638
|
}
|
|
1604
1639
|
emitCellCommit(e) {
|
|
1605
|
-
this.#
|
|
1640
|
+
this.#s("cell-commit", e);
|
|
1606
1641
|
}
|
|
1607
1642
|
emitRowCommit(e) {
|
|
1608
|
-
this.#
|
|
1643
|
+
this.#s("row-commit", e);
|
|
1609
1644
|
}
|
|
1610
1645
|
emitSortChange(e) {
|
|
1611
|
-
this.#
|
|
1646
|
+
this.#s("sort-change", e);
|
|
1612
1647
|
}
|
|
1613
1648
|
emitColumnResize(e) {
|
|
1614
|
-
this.#
|
|
1649
|
+
this.#s("column-resize", e);
|
|
1615
1650
|
}
|
|
1616
1651
|
emitActivateCell(e) {
|
|
1617
|
-
this.#
|
|
1652
|
+
this.#s("activate-cell", e);
|
|
1618
1653
|
}
|
|
1619
1654
|
/** Update ARIA selection attributes on rendered rows/cells */
|
|
1620
|
-
#
|
|
1655
|
+
#X() {
|
|
1621
1656
|
this.bodyEl?.querySelectorAll(".data-grid-row")?.forEach((t, n) => {
|
|
1622
|
-
const
|
|
1623
|
-
t.setAttribute("aria-selected", String(
|
|
1624
|
-
|
|
1657
|
+
const s = n === this.focusRow;
|
|
1658
|
+
t.setAttribute("aria-selected", String(s)), t.querySelectorAll(".cell").forEach((i, l) => {
|
|
1659
|
+
i.setAttribute("aria-selected", String(s && l === this.focusCol));
|
|
1625
1660
|
});
|
|
1626
1661
|
});
|
|
1627
1662
|
}
|
|
1628
1663
|
// ---------------- Watch Handlers ----------------
|
|
1629
|
-
#
|
|
1630
|
-
if (!this.#
|
|
1631
|
-
this.#
|
|
1664
|
+
#j() {
|
|
1665
|
+
if (!this.#u) return;
|
|
1666
|
+
this.#h(), this.#o.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, this.#K()) : (this._columns.forEach((t) => {
|
|
1632
1667
|
!t.__userResized && t.__autoSized && delete t.width;
|
|
1633
1668
|
}), this.updateTemplate());
|
|
1634
1669
|
}
|
|
1635
|
-
#X() {
|
|
1636
|
-
this.#h && (this.#d(), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0));
|
|
1637
|
-
}
|
|
1638
|
-
#j() {
|
|
1639
|
-
this._rows = Array.isArray(this.#s) ? [...this.#s] : [], this.#A(), !this.#r || Array.isArray(this.#r) && this.#r.length === 0 ? this.#a() : this.refreshVirtualWindow(!0);
|
|
1640
|
-
}
|
|
1641
1670
|
#Y() {
|
|
1642
|
-
|
|
1671
|
+
this.#u && (this.#h(), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0));
|
|
1643
1672
|
}
|
|
1644
1673
|
#Z() {
|
|
1645
|
-
this
|
|
1674
|
+
this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#T(), !this.#r || Array.isArray(this.#r) && this.#r.length === 0 ? this.#c() : this.refreshVirtualWindow(!0);
|
|
1646
1675
|
}
|
|
1647
|
-
// ---------------- Helper Wrappers ----------------
|
|
1648
1676
|
#J() {
|
|
1677
|
+
j(this), this.#u && (this.#h(), this.#c());
|
|
1678
|
+
}
|
|
1679
|
+
#Q() {
|
|
1680
|
+
this.#u && (this.#h(), this.#B(), this.#T(), this.#O(), this.#x(), this.updateTemplate(), this.refreshVirtualWindow(!0));
|
|
1681
|
+
}
|
|
1682
|
+
// ---------------- Helper Wrappers ----------------
|
|
1683
|
+
#ee() {
|
|
1649
1684
|
Oe(this);
|
|
1650
1685
|
}
|
|
1651
|
-
#
|
|
1686
|
+
#x() {
|
|
1652
1687
|
V(this);
|
|
1653
1688
|
}
|
|
1654
1689
|
updateTemplate() {
|
|
1655
1690
|
he(this);
|
|
1656
1691
|
}
|
|
1657
|
-
#
|
|
1692
|
+
#K() {
|
|
1658
1693
|
Me(this);
|
|
1659
1694
|
}
|
|
1660
|
-
#
|
|
1661
|
-
if (this.#
|
|
1662
|
-
const e = this._columns.filter((n) => !n.hidden), t = this.#
|
|
1695
|
+
#O() {
|
|
1696
|
+
if (this.#t) {
|
|
1697
|
+
const e = this._columns.filter((n) => !n.hidden), t = this.#t.processColumns([...e]);
|
|
1663
1698
|
if (t !== e) {
|
|
1664
|
-
const n = new Map(t.map((
|
|
1665
|
-
if (
|
|
1666
|
-
const
|
|
1667
|
-
return
|
|
1699
|
+
const n = new Map(t.map((i, l) => [i.field, { col: i, order: l }])), s = this._columns.map((i) => {
|
|
1700
|
+
if (i.hidden) return i;
|
|
1701
|
+
const l = n.get(i.field);
|
|
1702
|
+
return l ? l.col : i;
|
|
1668
1703
|
});
|
|
1669
|
-
this._columns =
|
|
1704
|
+
this._columns = s;
|
|
1670
1705
|
}
|
|
1671
1706
|
}
|
|
1672
1707
|
}
|
|
1673
1708
|
/** Execute all plugin afterRender hooks */
|
|
1674
|
-
#
|
|
1675
|
-
this.#
|
|
1709
|
+
#m() {
|
|
1710
|
+
this.#t?.afterRender();
|
|
1676
1711
|
}
|
|
1677
1712
|
/** Recompute row model via plugin hooks (grouping, tree, filtering, etc.). */
|
|
1678
|
-
#
|
|
1713
|
+
#T() {
|
|
1679
1714
|
j(this);
|
|
1680
|
-
const e = Array.isArray(this.#
|
|
1715
|
+
const e = Array.isArray(this.#l) ? [...this.#l] : [], t = this.#t?.processRows(e) ?? e;
|
|
1681
1716
|
this._rows = t;
|
|
1682
1717
|
}
|
|
1683
1718
|
/**
|
|
@@ -1698,75 +1733,75 @@ class q extends HTMLElement {
|
|
|
1698
1733
|
* - `_columns` is NOT set here (done by #getColumnConfiguration + #processColumns)
|
|
1699
1734
|
* - Plugins receive config via their attach() method
|
|
1700
1735
|
*/
|
|
1701
|
-
#
|
|
1702
|
-
const e = this.#
|
|
1736
|
+
#h() {
|
|
1737
|
+
const e = this.#g ? { ...this.#g } : {};
|
|
1703
1738
|
let t = Array.isArray(e.columns) ? [...e.columns] : [];
|
|
1704
|
-
const n = (this.__lightDomColumnsCache || []).map((
|
|
1705
|
-
...
|
|
1739
|
+
const n = (this.__lightDomColumnsCache || []).map((s) => ({
|
|
1740
|
+
...s
|
|
1706
1741
|
}));
|
|
1707
1742
|
if (n.length) {
|
|
1708
|
-
const
|
|
1709
|
-
t.forEach((
|
|
1710
|
-
const
|
|
1711
|
-
|
|
1743
|
+
const s = {};
|
|
1744
|
+
t.forEach((i) => s[i.field] = i), n.forEach((i) => {
|
|
1745
|
+
const l = s[i.field];
|
|
1746
|
+
l ? (i.header && !l.header && (l.header = i.header), i.type && !l.type && (l.type = i.type), l.sortable = l.sortable || i.sortable, i.resizable && (l.resizable = !0), i.editable && (l.editable = !0)) : (t.push(i), s[i.field] = i);
|
|
1712
1747
|
});
|
|
1713
1748
|
}
|
|
1714
1749
|
if (this.#r && this.#r.length && (t = [...this.#r]), (!t || t.length === 0) && this._rows.length && (t = ce(this._rows).columns), t.length) {
|
|
1715
|
-
t.forEach((
|
|
1716
|
-
|
|
1750
|
+
t.forEach((l) => {
|
|
1751
|
+
l.sortable === void 0 && (l.sortable = !0), l.resizable === void 0 && (l.resizable = !0);
|
|
1717
1752
|
});
|
|
1718
|
-
const
|
|
1719
|
-
|
|
1753
|
+
const s = this.#o.columns;
|
|
1754
|
+
s?.some((l) => l.__compiledView || l.__compiledEditor) ? e.columns = s : e.columns = t;
|
|
1720
1755
|
} else {
|
|
1721
|
-
const
|
|
1722
|
-
|
|
1756
|
+
const s = this.#o.columns;
|
|
1757
|
+
s?.some((i) => i.__compiledView || i.__compiledEditor) && (e.columns = s);
|
|
1723
1758
|
}
|
|
1724
|
-
this.#
|
|
1725
|
-
|
|
1759
|
+
this.#C && (e.fitMode = this.#C), e.fitMode || (e.fitMode = "stretch"), this.#y && (e.editOn = this.#y), e.columnState && !this.#d && (this.#d = e.columnState), this.#o = e, e.fitMode === "fixed" && this._columns.forEach((s) => {
|
|
1760
|
+
s.width == null && (s.width = 80);
|
|
1726
1761
|
});
|
|
1727
1762
|
}
|
|
1728
1763
|
// ---------------- Delegate Wrappers ----------------
|
|
1729
|
-
#
|
|
1730
|
-
this.#
|
|
1764
|
+
#M(e, t, n = this.__rowRenderEpoch) {
|
|
1765
|
+
this.#k || (this.#k = (s, i, l) => this.#t?.renderRow(s, i, l) ?? !1), qe(this, e, t, n, this.#k);
|
|
1731
1766
|
}
|
|
1732
|
-
#
|
|
1733
|
-
|
|
1767
|
+
#te(e, t) {
|
|
1768
|
+
T(this, e, t);
|
|
1734
1769
|
}
|
|
1735
|
-
#
|
|
1770
|
+
#D(e, t) {
|
|
1736
1771
|
Ie(this, e, t);
|
|
1737
1772
|
}
|
|
1738
1773
|
// ---------------- Core Helpers ----------------
|
|
1739
|
-
#
|
|
1774
|
+
#c() {
|
|
1740
1775
|
if (!this.isConnected || !this.headerRowEl || !this.bodyEl)
|
|
1741
1776
|
return;
|
|
1742
|
-
const e = this.#
|
|
1777
|
+
const e = this.#g?.columns || this.#r || [];
|
|
1743
1778
|
if (e.length) {
|
|
1744
|
-
const n = new Map(this._columns.filter((
|
|
1745
|
-
...
|
|
1746
|
-
hidden: n.get(
|
|
1779
|
+
const n = new Map(this._columns.filter((i) => i.hidden).map((i) => [i.field, !0])), s = e.map((i) => ({
|
|
1780
|
+
...i,
|
|
1781
|
+
hidden: n.get(i.field) ?? i.hidden
|
|
1747
1782
|
}));
|
|
1748
|
-
this._columns =
|
|
1783
|
+
this._columns = s;
|
|
1749
1784
|
}
|
|
1750
|
-
if (this.#
|
|
1751
|
-
const n = this.#
|
|
1752
|
-
this.#
|
|
1785
|
+
if (this.#ee(), this.#h(), this.#B(), this.#T(), this.#O(), this.#d) {
|
|
1786
|
+
const n = this.#d;
|
|
1787
|
+
this.#d = void 0, this.#W(n);
|
|
1753
1788
|
}
|
|
1754
|
-
this.#
|
|
1789
|
+
this.#x(), this.updateTemplate(), this.refreshVirtualWindow(!0), this.#o.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => this.#K()), this.bodyEl && (this.bodyEl.style.display = "", this.bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#m());
|
|
1755
1790
|
}
|
|
1756
1791
|
/** Internal method to apply column state without triggering setup loop */
|
|
1757
|
-
|
|
1758
|
-
const t = this.#
|
|
1792
|
+
#W(e) {
|
|
1793
|
+
const t = this.#o.columns ?? [], n = this.#t?.getAll() ?? [];
|
|
1759
1794
|
ge(this, e, t, n);
|
|
1760
|
-
for (const
|
|
1761
|
-
const
|
|
1762
|
-
|
|
1795
|
+
for (const s of e.columns) {
|
|
1796
|
+
const i = t.find((l) => l.field === s.field);
|
|
1797
|
+
i && (i.hidden = !s.visible);
|
|
1763
1798
|
}
|
|
1764
1799
|
}
|
|
1765
|
-
#
|
|
1800
|
+
#oe() {
|
|
1766
1801
|
return this._rows.length <= this.virtualization.bypassThreshold;
|
|
1767
1802
|
}
|
|
1768
|
-
#
|
|
1769
|
-
if (this.refreshVirtualWindow(!1), this.#
|
|
1803
|
+
#ne(e) {
|
|
1804
|
+
if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#R) {
|
|
1770
1805
|
const t = this.virtualization.container, n = {
|
|
1771
1806
|
scrollTop: e,
|
|
1772
1807
|
scrollLeft: t?.scrollLeft ?? 0,
|
|
@@ -1776,11 +1811,11 @@ class q extends HTMLElement {
|
|
|
1776
1811
|
clientWidth: t?.clientWidth ?? 0,
|
|
1777
1812
|
originalEvent: new Event("scroll")
|
|
1778
1813
|
};
|
|
1779
|
-
this.#
|
|
1814
|
+
this.#t?.onScroll(n);
|
|
1780
1815
|
}
|
|
1781
1816
|
}
|
|
1782
1817
|
findHeaderRow() {
|
|
1783
|
-
return this.#
|
|
1818
|
+
return this.#n.querySelector(".header-row");
|
|
1784
1819
|
}
|
|
1785
1820
|
findRenderedRowElement(e) {
|
|
1786
1821
|
return Array.from(this.bodyEl.querySelectorAll(".data-grid-row")).find((t) => {
|
|
@@ -1792,93 +1827,93 @@ class q extends HTMLElement {
|
|
|
1792
1827
|
* Dispatch a cell click event to the plugin system.
|
|
1793
1828
|
* Returns true if any plugin handled the event.
|
|
1794
1829
|
*/
|
|
1795
|
-
dispatchCellClick(e, t, n,
|
|
1796
|
-
const
|
|
1797
|
-
if (!
|
|
1798
|
-
const
|
|
1799
|
-
row:
|
|
1830
|
+
dispatchCellClick(e, t, n, s) {
|
|
1831
|
+
const i = this._rows[t], l = this._columns[n];
|
|
1832
|
+
if (!i || !l) return !1;
|
|
1833
|
+
const r = {
|
|
1834
|
+
row: i,
|
|
1800
1835
|
rowIndex: t,
|
|
1801
1836
|
colIndex: n,
|
|
1802
|
-
field:
|
|
1803
|
-
value:
|
|
1804
|
-
cellEl:
|
|
1837
|
+
field: l.field,
|
|
1838
|
+
value: i[l.field],
|
|
1839
|
+
cellEl: s,
|
|
1805
1840
|
originalEvent: e
|
|
1806
1841
|
};
|
|
1807
|
-
return this.#
|
|
1842
|
+
return this.#t?.onCellClick(r) ?? !1;
|
|
1808
1843
|
}
|
|
1809
1844
|
/**
|
|
1810
1845
|
* Dispatch a header click event to the plugin system.
|
|
1811
1846
|
* Returns true if any plugin handled the event.
|
|
1812
1847
|
*/
|
|
1813
1848
|
dispatchHeaderClick(e, t, n) {
|
|
1814
|
-
const
|
|
1815
|
-
if (!
|
|
1816
|
-
const
|
|
1849
|
+
const s = this._columns[t];
|
|
1850
|
+
if (!s) return !1;
|
|
1851
|
+
const i = {
|
|
1817
1852
|
colIndex: t,
|
|
1818
|
-
field:
|
|
1819
|
-
column:
|
|
1853
|
+
field: s.field,
|
|
1854
|
+
column: s,
|
|
1820
1855
|
headerEl: n,
|
|
1821
1856
|
originalEvent: e
|
|
1822
1857
|
};
|
|
1823
|
-
return this.#
|
|
1858
|
+
return this.#t?.onHeaderClick(i) ?? !1;
|
|
1824
1859
|
}
|
|
1825
1860
|
/**
|
|
1826
1861
|
* Dispatch a keyboard event to the plugin system.
|
|
1827
1862
|
* Returns true if any plugin handled the event.
|
|
1828
1863
|
*/
|
|
1829
1864
|
dispatchKeyDown(e) {
|
|
1830
|
-
return this.#
|
|
1865
|
+
return this.#t?.onKeyDown(e) ?? !1;
|
|
1831
1866
|
}
|
|
1832
1867
|
/**
|
|
1833
1868
|
* Build a CellMouseEvent from a native MouseEvent.
|
|
1834
1869
|
* Extracts cell/row information from the event target.
|
|
1835
1870
|
*/
|
|
1836
|
-
#
|
|
1871
|
+
#H(e, t) {
|
|
1837
1872
|
let n = null;
|
|
1838
|
-
const
|
|
1839
|
-
if (
|
|
1840
|
-
const
|
|
1841
|
-
|
|
1842
|
-
}
|
|
1843
|
-
const
|
|
1844
|
-
let a,
|
|
1845
|
-
return
|
|
1873
|
+
const s = e.composedPath?.();
|
|
1874
|
+
if (s && s.length > 0 ? n = s[0] : n = e.target, n && !this.#n.contains(n)) {
|
|
1875
|
+
const d = this.#n.elementFromPoint(e.clientX, e.clientY);
|
|
1876
|
+
d && (n = d);
|
|
1877
|
+
}
|
|
1878
|
+
const i = n?.closest?.("[data-col]"), l = n?.closest?.(".data-grid-row"), r = n?.closest?.(".header-row");
|
|
1879
|
+
let a, f, p, w, h, c;
|
|
1880
|
+
return i && (a = parseInt(i.getAttribute("data-row") ?? "-1", 10), f = parseInt(i.getAttribute("data-col") ?? "-1", 10), a >= 0 && f >= 0 && (p = this._rows[a], c = this._columns[f], w = c?.field, h = p && w ? p[w] : void 0)), {
|
|
1846
1881
|
type: t,
|
|
1847
|
-
row:
|
|
1882
|
+
row: p,
|
|
1848
1883
|
rowIndex: a !== void 0 && a >= 0 ? a : void 0,
|
|
1849
|
-
colIndex:
|
|
1884
|
+
colIndex: f !== void 0 && f >= 0 ? f : void 0,
|
|
1850
1885
|
field: w,
|
|
1851
|
-
value:
|
|
1852
|
-
column:
|
|
1886
|
+
value: h,
|
|
1887
|
+
column: c,
|
|
1853
1888
|
originalEvent: e,
|
|
1854
|
-
cellElement:
|
|
1855
|
-
rowElement:
|
|
1856
|
-
isHeader: !!
|
|
1857
|
-
cell: a !== void 0 &&
|
|
1889
|
+
cellElement: i ?? void 0,
|
|
1890
|
+
rowElement: l ?? void 0,
|
|
1891
|
+
isHeader: !!r,
|
|
1892
|
+
cell: a !== void 0 && f !== void 0 && a >= 0 && f >= 0 ? { row: a, col: f } : void 0
|
|
1858
1893
|
};
|
|
1859
1894
|
}
|
|
1860
1895
|
/**
|
|
1861
1896
|
* Handle mousedown events and dispatch to plugin system.
|
|
1862
1897
|
*/
|
|
1863
|
-
#
|
|
1864
|
-
const t = this.#
|
|
1865
|
-
(this.#
|
|
1898
|
+
#ie(e) {
|
|
1899
|
+
const t = this.#H(e, "mousedown");
|
|
1900
|
+
(this.#t?.onCellMouseDown(t) ?? !1) && (this.#_ = !0);
|
|
1866
1901
|
}
|
|
1867
1902
|
/**
|
|
1868
1903
|
* Handle mousemove events (only when dragging).
|
|
1869
1904
|
*/
|
|
1870
|
-
#
|
|
1871
|
-
if (!this.#
|
|
1872
|
-
const t = this.#
|
|
1873
|
-
this.#
|
|
1905
|
+
#se(e) {
|
|
1906
|
+
if (!this.#_) return;
|
|
1907
|
+
const t = this.#H(e, "mousemove");
|
|
1908
|
+
this.#t?.onCellMouseMove(t);
|
|
1874
1909
|
}
|
|
1875
1910
|
/**
|
|
1876
1911
|
* Handle mouseup events.
|
|
1877
1912
|
*/
|
|
1878
|
-
#
|
|
1879
|
-
if (!this.#
|
|
1880
|
-
const t = this.#
|
|
1881
|
-
this.#
|
|
1913
|
+
#le(e) {
|
|
1914
|
+
if (!this.#_) return;
|
|
1915
|
+
const t = this.#H(e, "mouseup");
|
|
1916
|
+
this.#t?.onCellMouseUp(t), this.#_ = !1;
|
|
1882
1917
|
}
|
|
1883
1918
|
// API consumed by internal utils (rows.ts)
|
|
1884
1919
|
get changedRows() {
|
|
@@ -1888,23 +1923,23 @@ class q extends HTMLElement {
|
|
|
1888
1923
|
return Array.from(this._changedRowIndices);
|
|
1889
1924
|
}
|
|
1890
1925
|
async resetChangedRows(e) {
|
|
1891
|
-
this._changedRowIndices.clear(), e || this.#
|
|
1926
|
+
this._changedRowIndices.clear(), e || this.#s("changed-rows-reset", { rows: this.changedRows, indices: this.changedRowIndices }), this.rowPool.forEach((t) => t.classList.remove("changed"));
|
|
1892
1927
|
}
|
|
1893
1928
|
async beginBulkEdit(e) {
|
|
1894
|
-
this.#
|
|
1929
|
+
this.#te(e, this._rows[e]);
|
|
1895
1930
|
}
|
|
1896
1931
|
async commitActiveRowEdit() {
|
|
1897
|
-
this.activeEditRows !== -1 && this.#
|
|
1932
|
+
this.activeEditRows !== -1 && this.#D(this.activeEditRows, !1);
|
|
1898
1933
|
}
|
|
1899
1934
|
async ready() {
|
|
1900
|
-
return this.#
|
|
1935
|
+
return this.#z;
|
|
1901
1936
|
}
|
|
1902
1937
|
async forceLayout() {
|
|
1903
|
-
this.#
|
|
1938
|
+
this.#c(), await new Promise((e) => requestAnimationFrame(() => requestAnimationFrame(e)));
|
|
1904
1939
|
}
|
|
1905
1940
|
/** Public method: returns a frozen snapshot of the merged effective configuration */
|
|
1906
1941
|
async getConfig() {
|
|
1907
|
-
return Object.freeze({ ...this.#
|
|
1942
|
+
return Object.freeze({ ...this.#o || {} });
|
|
1908
1943
|
}
|
|
1909
1944
|
// ---------------- Column Visibility API ----------------
|
|
1910
1945
|
/**
|
|
@@ -1914,15 +1949,15 @@ class q extends HTMLElement {
|
|
|
1914
1949
|
* @returns True if visibility was changed, false if column not found or locked
|
|
1915
1950
|
*/
|
|
1916
1951
|
setColumnVisible(e, t) {
|
|
1917
|
-
const n = this.#
|
|
1918
|
-
if (!
|
|
1952
|
+
const n = this.#o.columns, s = n?.find((r) => r.field === e);
|
|
1953
|
+
if (!s || !t && s.lockVisible || !t && (n ?? []).filter((a) => !a.hidden && a.field !== e).length === 0)
|
|
1919
1954
|
return !1;
|
|
1920
|
-
const
|
|
1921
|
-
return
|
|
1955
|
+
const i = !!s.hidden, l = !t;
|
|
1956
|
+
return i !== l ? (s.hidden = l, this.#s("column-visibility", {
|
|
1922
1957
|
field: e,
|
|
1923
1958
|
visible: t,
|
|
1924
|
-
visibleColumns: (n ?? []).filter((
|
|
1925
|
-
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#
|
|
1959
|
+
visibleColumns: (n ?? []).filter((r) => !r.hidden).map((r) => r.field)
|
|
1960
|
+
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#c(), this.requestStateChange(), !0) : !1;
|
|
1926
1961
|
}
|
|
1927
1962
|
/**
|
|
1928
1963
|
* Toggle the visibility of a column.
|
|
@@ -1930,8 +1965,8 @@ class q extends HTMLElement {
|
|
|
1930
1965
|
* @returns True if visibility was toggled, false if column not found or locked
|
|
1931
1966
|
*/
|
|
1932
1967
|
toggleColumnVisibility(e) {
|
|
1933
|
-
const
|
|
1934
|
-
return this.setColumnVisible(e,
|
|
1968
|
+
const s = !!this.#o.columns?.find((i) => i.field === e)?.hidden;
|
|
1969
|
+
return this.setColumnVisible(e, s);
|
|
1935
1970
|
}
|
|
1936
1971
|
/**
|
|
1937
1972
|
* Check if a column is currently visible.
|
|
@@ -1939,19 +1974,19 @@ class q extends HTMLElement {
|
|
|
1939
1974
|
* @returns True if visible, false if hidden or not found
|
|
1940
1975
|
*/
|
|
1941
1976
|
isColumnVisible(e) {
|
|
1942
|
-
const n = this.#
|
|
1977
|
+
const n = this.#o.columns?.find((s) => s.field === e);
|
|
1943
1978
|
return n ? !n.hidden : !1;
|
|
1944
1979
|
}
|
|
1945
1980
|
/**
|
|
1946
1981
|
* Show all columns.
|
|
1947
1982
|
*/
|
|
1948
1983
|
showAllColumns() {
|
|
1949
|
-
const e = this.#
|
|
1984
|
+
const e = this.#o.columns;
|
|
1950
1985
|
e?.some((n) => n.hidden) && (e?.forEach((n) => {
|
|
1951
1986
|
n.hidden = !1;
|
|
1952
|
-
}), this.#
|
|
1987
|
+
}), this.#s("column-visibility", {
|
|
1953
1988
|
visibleColumns: (e ?? []).map((n) => n.field)
|
|
1954
|
-
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#
|
|
1989
|
+
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#c(), this.requestStateChange());
|
|
1955
1990
|
}
|
|
1956
1991
|
/**
|
|
1957
1992
|
* Get list of all column fields (including hidden).
|
|
@@ -1960,7 +1995,7 @@ class q extends HTMLElement {
|
|
|
1960
1995
|
* @returns Array of all field names with their visibility status
|
|
1961
1996
|
*/
|
|
1962
1997
|
getAllColumns() {
|
|
1963
|
-
return (this.#
|
|
1998
|
+
return (this.#o.columns ?? []).map((t) => ({
|
|
1964
1999
|
field: t.field,
|
|
1965
2000
|
header: t.header || t.field,
|
|
1966
2001
|
visible: !t.hidden,
|
|
@@ -1974,14 +2009,14 @@ class q extends HTMLElement {
|
|
|
1974
2009
|
*/
|
|
1975
2010
|
setColumnOrder(e) {
|
|
1976
2011
|
if (!e.length) return;
|
|
1977
|
-
const t = new Map(this._columns.map((
|
|
1978
|
-
for (const
|
|
1979
|
-
const
|
|
1980
|
-
|
|
2012
|
+
const t = new Map(this._columns.map((s) => [s.field, s])), n = [];
|
|
2013
|
+
for (const s of e) {
|
|
2014
|
+
const i = t.get(s);
|
|
2015
|
+
i && (n.push(i), t.delete(s));
|
|
1981
2016
|
}
|
|
1982
|
-
for (const
|
|
1983
|
-
n.push(
|
|
1984
|
-
this._columns = n, this.#
|
|
2017
|
+
for (const s of t.values())
|
|
2018
|
+
n.push(s);
|
|
2019
|
+
this._columns = n, this.#x(), this.updateTemplate(), this.refreshVirtualWindow(!0);
|
|
1985
2020
|
}
|
|
1986
2021
|
/**
|
|
1987
2022
|
* Get the current column order as an array of field names.
|
|
@@ -1996,7 +2031,7 @@ class q extends HTMLElement {
|
|
|
1996
2031
|
* Returns a serializable object suitable for localStorage or database storage.
|
|
1997
2032
|
*/
|
|
1998
2033
|
getColumnState() {
|
|
1999
|
-
const e = this.#
|
|
2034
|
+
const e = this.#t?.getAll() ?? [];
|
|
2000
2035
|
return ae(this, e);
|
|
2001
2036
|
}
|
|
2002
2037
|
/**
|
|
@@ -2004,7 +2039,7 @@ class q extends HTMLElement {
|
|
|
2004
2039
|
* Use this to restore previously saved column state.
|
|
2005
2040
|
*/
|
|
2006
2041
|
set columnState(e) {
|
|
2007
|
-
e && (this.#
|
|
2042
|
+
e && (this.#d = e, this.#i && this.#re(e));
|
|
2008
2043
|
}
|
|
2009
2044
|
/**
|
|
2010
2045
|
* Get the current column state.
|
|
@@ -2015,10 +2050,10 @@ class q extends HTMLElement {
|
|
|
2015
2050
|
/**
|
|
2016
2051
|
* Apply column state internally.
|
|
2017
2052
|
*/
|
|
2018
|
-
#
|
|
2019
|
-
(this.#
|
|
2053
|
+
#re(e) {
|
|
2054
|
+
(this.#o.columns ?? []).forEach((n) => {
|
|
2020
2055
|
n.hidden = !1;
|
|
2021
|
-
}), this
|
|
2056
|
+
}), this.#W(e), this.#c();
|
|
2022
2057
|
}
|
|
2023
2058
|
/**
|
|
2024
2059
|
* Request a state change event to be emitted.
|
|
@@ -2027,26 +2062,26 @@ class q extends HTMLElement {
|
|
|
2027
2062
|
* The event is debounced to avoid excessive events during drag operations.
|
|
2028
2063
|
*/
|
|
2029
2064
|
requestStateChange() {
|
|
2030
|
-
this.#
|
|
2065
|
+
this.#P || (this.#P = me(
|
|
2031
2066
|
this,
|
|
2032
|
-
() => this.#
|
|
2033
|
-
(e) => this.#
|
|
2034
|
-
)), this.#
|
|
2067
|
+
() => this.#t?.getAll() ?? [],
|
|
2068
|
+
(e) => this.#s("column-state-change", e)
|
|
2069
|
+
)), this.#P();
|
|
2035
2070
|
}
|
|
2036
2071
|
/**
|
|
2037
2072
|
* Reset column state to initial configuration.
|
|
2038
2073
|
* Clears all user modifications (order, width, visibility, sort).
|
|
2039
2074
|
*/
|
|
2040
2075
|
resetColumnState() {
|
|
2041
|
-
this.#
|
|
2076
|
+
this.#d = void 0, (this.#o.columns ?? []).forEach((n) => {
|
|
2042
2077
|
n.hidden = !1;
|
|
2043
|
-
}), this.sortState = null, this.__originalOrder = [], this.#
|
|
2044
|
-
const t = this.#
|
|
2078
|
+
}), this.sortState = null, this.__originalOrder = [], this.#h(), this.#c();
|
|
2079
|
+
const t = this.#t?.getAll() ?? [];
|
|
2045
2080
|
for (const n of t)
|
|
2046
2081
|
if (n.applyColumnState)
|
|
2047
|
-
for (const
|
|
2048
|
-
n.applyColumnState(
|
|
2049
|
-
field:
|
|
2082
|
+
for (const s of this._columns)
|
|
2083
|
+
n.applyColumnState(s.field, {
|
|
2084
|
+
field: s.field,
|
|
2050
2085
|
order: 0,
|
|
2051
2086
|
visible: !0
|
|
2052
2087
|
});
|
|
@@ -2068,7 +2103,7 @@ class q extends HTMLElement {
|
|
|
2068
2103
|
console.warn(`[tbw-grid] Tool panel "${e}" not found`);
|
|
2069
2104
|
return;
|
|
2070
2105
|
}
|
|
2071
|
-
this.#e.activePanel && this.#e.activePanel !== e && this.closeToolPanel(), this.#e.activePanel = e, oe(this.#
|
|
2106
|
+
this.#e.activePanel && this.#e.activePanel !== e && this.closeToolPanel(), this.#e.activePanel = e, oe(this.#n, this.#e), ne(this.#n, this.#e), Ue(this.#n, this.#e), this.#s("tool-panel-open", { id: e });
|
|
2072
2107
|
}
|
|
2073
2108
|
/**
|
|
2074
2109
|
* Close the currently open tool panel.
|
|
@@ -2076,7 +2111,7 @@ class q extends HTMLElement {
|
|
|
2076
2111
|
closeToolPanel() {
|
|
2077
2112
|
if (!this.#e.activePanel) return;
|
|
2078
2113
|
const e = this.#e.activePanel, t = this.#e.toolPanels.get(e);
|
|
2079
|
-
this.#e.activePanelCleanup && (this.#e.activePanelCleanup(), this.#e.activePanelCleanup = null), t?.onClose?.(), this.#e.activePanel = null, oe(this.#
|
|
2114
|
+
this.#e.activePanelCleanup && (this.#e.activePanelCleanup(), this.#e.activePanelCleanup = null), t?.onClose?.(), this.#e.activePanel = null, oe(this.#n, this.#e), ne(this.#n, this.#e), this.#s("tool-panel-close", { id: e });
|
|
2080
2115
|
}
|
|
2081
2116
|
/**
|
|
2082
2117
|
* Toggle a tool panel open/closed.
|
|
@@ -2098,13 +2133,13 @@ class q extends HTMLElement {
|
|
|
2098
2133
|
console.warn(`[tbw-grid] Tool panel "${e.id}" already registered`);
|
|
2099
2134
|
return;
|
|
2100
2135
|
}
|
|
2101
|
-
this.#e.toolPanels.set(e.id, e), this.#
|
|
2136
|
+
this.#e.toolPanels.set(e.id, e), this.#a && this.#v();
|
|
2102
2137
|
}
|
|
2103
2138
|
/**
|
|
2104
2139
|
* Unregister a custom tool panel.
|
|
2105
2140
|
*/
|
|
2106
2141
|
unregisterToolPanel(e) {
|
|
2107
|
-
this.#e.activePanel === e && this.closeToolPanel(), this.#e.toolPanels.delete(e), this.#
|
|
2142
|
+
this.#e.activePanel === e && this.closeToolPanel(), this.#e.toolPanels.delete(e), this.#a && this.#v();
|
|
2108
2143
|
}
|
|
2109
2144
|
/**
|
|
2110
2145
|
* Get registered header content definitions.
|
|
@@ -2120,20 +2155,20 @@ class q extends HTMLElement {
|
|
|
2120
2155
|
console.warn(`[tbw-grid] Header content "${e.id}" already registered`);
|
|
2121
2156
|
return;
|
|
2122
2157
|
}
|
|
2123
|
-
this.#e.headerContents.set(e.id, e), this.#
|
|
2158
|
+
this.#e.headerContents.set(e.id, e), this.#a && te(this.#n, this.#e);
|
|
2124
2159
|
}
|
|
2125
2160
|
/**
|
|
2126
2161
|
* Unregister custom header content.
|
|
2127
2162
|
*/
|
|
2128
2163
|
unregisterHeaderContent(e) {
|
|
2129
2164
|
const t = this.#e.headerContentCleanups.get(e);
|
|
2130
|
-
t && (t(), this.#e.headerContentCleanups.delete(e)), this.#e.headerContents.get(e)?.onDestroy?.(), this.#e.headerContents.delete(e), this.#
|
|
2165
|
+
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();
|
|
2131
2166
|
}
|
|
2132
2167
|
/**
|
|
2133
2168
|
* Get all registered toolbar buttons.
|
|
2134
2169
|
*/
|
|
2135
2170
|
getToolbarButtons() {
|
|
2136
|
-
return Xe(this.#
|
|
2171
|
+
return Xe(this.#o?.shell, this.#e);
|
|
2137
2172
|
}
|
|
2138
2173
|
/**
|
|
2139
2174
|
* Register a custom toolbar button programmatically.
|
|
@@ -2143,14 +2178,14 @@ class q extends HTMLElement {
|
|
|
2143
2178
|
console.warn(`[tbw-grid] Toolbar button "${e.id}" already registered`);
|
|
2144
2179
|
return;
|
|
2145
2180
|
}
|
|
2146
|
-
this.#e.toolbarButtons.set(e.id, e), this.#
|
|
2181
|
+
this.#e.toolbarButtons.set(e.id, e), this.#a && this.#v();
|
|
2147
2182
|
}
|
|
2148
2183
|
/**
|
|
2149
2184
|
* Unregister a custom toolbar button.
|
|
2150
2185
|
*/
|
|
2151
2186
|
unregisterToolbarButton(e) {
|
|
2152
2187
|
const t = this.#e.toolbarButtonCleanups.get(e);
|
|
2153
|
-
t && (t(), this.#e.toolbarButtonCleanups.delete(e)), this.#e.toolbarButtons.delete(e), this.#
|
|
2188
|
+
t && (t(), this.#e.toolbarButtonCleanups.delete(e)), this.#e.toolbarButtons.delete(e), this.#a && this.#v();
|
|
2154
2189
|
}
|
|
2155
2190
|
/**
|
|
2156
2191
|
* Enable/disable a toolbar button by ID.
|
|
@@ -2158,21 +2193,21 @@ class q extends HTMLElement {
|
|
|
2158
2193
|
setToolbarButtonDisabled(e, t) {
|
|
2159
2194
|
const n = this.#e.toolbarButtons.get(e);
|
|
2160
2195
|
n && (n.disabled = t);
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2196
|
+
const s = this.#n.querySelector(`[data-btn="${e}"]`);
|
|
2197
|
+
s && (s.disabled = t);
|
|
2163
2198
|
}
|
|
2164
2199
|
/**
|
|
2165
2200
|
* Re-parse light DOM shell elements and refresh shell header.
|
|
2166
2201
|
* Call this after dynamically modifying <tbw-grid-header> children.
|
|
2167
2202
|
*/
|
|
2168
2203
|
refreshShellHeader() {
|
|
2169
|
-
this.#
|
|
2204
|
+
this.#v();
|
|
2170
2205
|
}
|
|
2171
2206
|
/**
|
|
2172
2207
|
* Internal shell header refresh.
|
|
2173
2208
|
*/
|
|
2174
|
-
#
|
|
2175
|
-
ee(this, this.#e), this.#
|
|
2209
|
+
#v() {
|
|
2210
|
+
ee(this, this.#e), this.#F(), this.#$();
|
|
2176
2211
|
}
|
|
2177
2212
|
// ---------------- Virtual Window ----------------
|
|
2178
2213
|
/**
|
|
@@ -2183,26 +2218,26 @@ class q extends HTMLElement {
|
|
|
2183
2218
|
if (!this.bodyEl) return;
|
|
2184
2219
|
const t = this._rows.length;
|
|
2185
2220
|
if (!this.virtualization.enabled) {
|
|
2186
|
-
this.#
|
|
2221
|
+
this.#M(0, t), this.#m();
|
|
2187
2222
|
return;
|
|
2188
2223
|
}
|
|
2189
|
-
if (this.#
|
|
2190
|
-
this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#
|
|
2224
|
+
if (this.#oe()) {
|
|
2225
|
+
this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#M(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.#m();
|
|
2191
2226
|
return;
|
|
2192
2227
|
}
|
|
2193
|
-
const n = this.virtualization.container ?? this,
|
|
2194
|
-
let a = Math.floor(
|
|
2228
|
+
const n = this.virtualization.container ?? this, i = (this.virtualization.viewportEl ?? n).clientHeight, l = this.virtualization.rowHeight, r = n.scrollTop;
|
|
2229
|
+
let a = Math.floor(r / l);
|
|
2195
2230
|
a < 0 && (a = 0);
|
|
2196
|
-
const
|
|
2197
|
-
let
|
|
2198
|
-
|
|
2199
|
-
const w = -(
|
|
2200
|
-
this.bodyEl.style.transform = `translateY(${w}px)`, this.#
|
|
2231
|
+
const f = Math.ceil(i / l) + 2;
|
|
2232
|
+
let p = a + f;
|
|
2233
|
+
p > t && (p = t), this.virtualization.start = a, this.virtualization.end = p, this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * l}px`);
|
|
2234
|
+
const w = -(r % l);
|
|
2235
|
+
this.bodyEl.style.transform = `translateY(${w}px)`, this.#M(a, p, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), e && this.#m();
|
|
2201
2236
|
}
|
|
2202
2237
|
// ---------------- Render ----------------
|
|
2203
|
-
#
|
|
2238
|
+
#F() {
|
|
2204
2239
|
ee(this, this.#e);
|
|
2205
|
-
const e = this.#
|
|
2240
|
+
const e = this.#o?.shell, t = Ke(e, this.#e), n = `
|
|
2206
2241
|
<div class="tbw-scroll-area">
|
|
2207
2242
|
<div class="rows-body-wrapper">
|
|
2208
2243
|
<div class="rows-body">
|
|
@@ -2222,15 +2257,15 @@ class q extends HTMLElement {
|
|
|
2222
2257
|
</div>
|
|
2223
2258
|
`;
|
|
2224
2259
|
if (t) {
|
|
2225
|
-
const
|
|
2226
|
-
this.#
|
|
2260
|
+
const s = We(e, this.#e), i = Fe(e, this.#e, n);
|
|
2261
|
+
this.#n.innerHTML = `
|
|
2227
2262
|
<div class="tbw-grid-root has-shell">
|
|
2228
|
-
${i}
|
|
2229
2263
|
${s}
|
|
2264
|
+
${i}
|
|
2230
2265
|
</div>
|
|
2231
|
-
`, this.#
|
|
2266
|
+
`, this.#ae(), this.#a = !0;
|
|
2232
2267
|
} else
|
|
2233
|
-
this.#
|
|
2268
|
+
this.#n.innerHTML = `
|
|
2234
2269
|
<div class="tbw-grid-root">
|
|
2235
2270
|
<div class="tbw-grid-content">
|
|
2236
2271
|
${n}
|
|
@@ -2241,24 +2276,24 @@ class q extends HTMLElement {
|
|
|
2241
2276
|
/**
|
|
2242
2277
|
* Set up shell event listeners after render.
|
|
2243
2278
|
*/
|
|
2244
|
-
#
|
|
2245
|
-
Ve(this.#
|
|
2279
|
+
#ae() {
|
|
2280
|
+
Ve(this.#n, this.#o?.shell, this.#e, {
|
|
2246
2281
|
onPanelToggle: (e) => this.toggleToolPanel(e),
|
|
2247
2282
|
onPanelClose: () => this.closeToolPanel(),
|
|
2248
|
-
onToolbarButtonClick: (e) => this.#
|
|
2283
|
+
onToolbarButtonClick: (e) => this.#ce(e)
|
|
2249
2284
|
});
|
|
2250
2285
|
}
|
|
2251
2286
|
/**
|
|
2252
2287
|
* Handle toolbar button click (for config buttons with action).
|
|
2253
2288
|
*/
|
|
2254
|
-
#
|
|
2255
|
-
const n = (this.#
|
|
2289
|
+
#ce(e) {
|
|
2290
|
+
const n = (this.#o?.shell?.header?.toolbarButtons ?? []).find((i) => i.id === e);
|
|
2256
2291
|
if (n?.action) {
|
|
2257
2292
|
n.action();
|
|
2258
2293
|
return;
|
|
2259
2294
|
}
|
|
2260
|
-
const
|
|
2261
|
-
|
|
2295
|
+
const s = this.#e.toolbarButtons.get(e);
|
|
2296
|
+
s?.action && s.action();
|
|
2262
2297
|
}
|
|
2263
2298
|
}
|
|
2264
2299
|
customElements.get(q.tagName) || customElements.define(q.tagName, q);
|
|
@@ -2396,8 +2431,8 @@ function ie(o, e, t) {
|
|
|
2396
2431
|
function Qe(o) {
|
|
2397
2432
|
const e = [], t = z(o);
|
|
2398
2433
|
for (let n = t.startRow; n <= t.endRow; n++)
|
|
2399
|
-
for (let
|
|
2400
|
-
e.push({ row: n, col:
|
|
2434
|
+
for (let s = t.startCol; s <= t.endCol; s++)
|
|
2435
|
+
e.push({ row: n, col: s });
|
|
2401
2436
|
return e;
|
|
2402
2437
|
}
|
|
2403
2438
|
function et(o) {
|
|
@@ -2427,9 +2462,9 @@ function tt(o, e, t) {
|
|
|
2427
2462
|
]
|
|
2428
2463
|
};
|
|
2429
2464
|
if (o === "row" && e.selected.size > 0) {
|
|
2430
|
-
const n = [...e.selected].map((
|
|
2431
|
-
from: { row:
|
|
2432
|
-
to: { row:
|
|
2465
|
+
const n = [...e.selected].map((s) => ({
|
|
2466
|
+
from: { row: s, col: 0 },
|
|
2467
|
+
to: { row: s, col: t - 1 }
|
|
2433
2468
|
}));
|
|
2434
2469
|
return { mode: o, ranges: n };
|
|
2435
2470
|
}
|
|
@@ -2461,17 +2496,17 @@ class st extends ue {
|
|
|
2461
2496
|
}
|
|
2462
2497
|
// ===== Event Handlers =====
|
|
2463
2498
|
onCellClick(e) {
|
|
2464
|
-
const { rowIndex: t, colIndex: n, originalEvent:
|
|
2465
|
-
if (
|
|
2466
|
-
return this.selectedCell = { row: t, col: n }, this.emit("selection-change", this.#
|
|
2467
|
-
if (
|
|
2468
|
-
return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#
|
|
2469
|
-
if (
|
|
2470
|
-
const
|
|
2471
|
-
if (
|
|
2499
|
+
const { rowIndex: t, colIndex: n, originalEvent: s } = e, { mode: i } = this.config;
|
|
2500
|
+
if (i === "cell")
|
|
2501
|
+
return this.selectedCell = { row: t, col: n }, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
|
|
2502
|
+
if (i === "row")
|
|
2503
|
+
return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
|
|
2504
|
+
if (i === "range") {
|
|
2505
|
+
const l = s.shiftKey, r = s.ctrlKey || s.metaKey;
|
|
2506
|
+
if (l && this.cellAnchor) {
|
|
2472
2507
|
const a = se(this.cellAnchor, { row: t, col: n });
|
|
2473
|
-
|
|
2474
|
-
} else if (
|
|
2508
|
+
r ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = a : this.ranges.push(a) : this.ranges = [a], this.activeRange = a;
|
|
2509
|
+
} else if (r) {
|
|
2475
2510
|
const a = {
|
|
2476
2511
|
startRow: t,
|
|
2477
2512
|
startCol: n,
|
|
@@ -2488,24 +2523,24 @@ class st extends ue {
|
|
|
2488
2523
|
};
|
|
2489
2524
|
this.ranges = [a], this.activeRange = a, this.cellAnchor = { row: t, col: n };
|
|
2490
2525
|
}
|
|
2491
|
-
return this.emit("selection-change", this.#
|
|
2526
|
+
return this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
|
|
2492
2527
|
}
|
|
2493
2528
|
return !1;
|
|
2494
2529
|
}
|
|
2495
2530
|
onKeyDown(e) {
|
|
2496
2531
|
const { mode: t } = this.config;
|
|
2497
2532
|
if (e.key === "Escape")
|
|
2498
|
-
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.#
|
|
2533
|
+
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;
|
|
2499
2534
|
if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
|
|
2500
|
-
const n = this.rows.length,
|
|
2501
|
-
if (n > 0 &&
|
|
2502
|
-
const
|
|
2535
|
+
const n = this.rows.length, s = this.columns.length;
|
|
2536
|
+
if (n > 0 && s > 0) {
|
|
2537
|
+
const i = {
|
|
2503
2538
|
startRow: 0,
|
|
2504
2539
|
startCol: 0,
|
|
2505
2540
|
endRow: n - 1,
|
|
2506
|
-
endCol:
|
|
2541
|
+
endCol: s - 1
|
|
2507
2542
|
};
|
|
2508
|
-
return this.ranges = [
|
|
2543
|
+
return this.ranges = [i], this.activeRange = i, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
|
|
2509
2544
|
}
|
|
2510
2545
|
}
|
|
2511
2546
|
return !1;
|
|
@@ -2516,43 +2551,61 @@ class st extends ue {
|
|
|
2516
2551
|
this.isDragging = !0;
|
|
2517
2552
|
const t = e.rowIndex, n = e.colIndex;
|
|
2518
2553
|
this.cellAnchor = { row: t, col: n }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
|
|
2519
|
-
const
|
|
2554
|
+
const i = {
|
|
2520
2555
|
startRow: t,
|
|
2521
2556
|
startCol: n,
|
|
2522
2557
|
endRow: t,
|
|
2523
2558
|
endCol: n
|
|
2524
2559
|
};
|
|
2525
|
-
return this.ranges.push(
|
|
2560
|
+
return this.ranges.push(i), this.activeRange = i, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
|
|
2526
2561
|
}
|
|
2527
2562
|
onCellMouseMove(e) {
|
|
2528
2563
|
if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
2529
2564
|
const t = se(this.cellAnchor, { row: e.rowIndex, col: e.colIndex });
|
|
2530
|
-
return this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = t : this.ranges.push(t), this.activeRange = t, this.emit("selection-change", this.#
|
|
2565
|
+
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;
|
|
2531
2566
|
}
|
|
2532
2567
|
onCellMouseUp(e) {
|
|
2533
2568
|
if (this.config.mode === "range" && this.isDragging)
|
|
2534
2569
|
return this.isDragging = !1, !0;
|
|
2535
2570
|
}
|
|
2536
|
-
|
|
2571
|
+
/**
|
|
2572
|
+
* Apply selection classes to visible cells/rows.
|
|
2573
|
+
* Shared by afterRender and onScrollRender.
|
|
2574
|
+
*/
|
|
2575
|
+
#n() {
|
|
2537
2576
|
const e = this.shadowRoot;
|
|
2538
2577
|
if (!e) return;
|
|
2539
|
-
const
|
|
2540
|
-
|
|
2541
|
-
|
|
2578
|
+
const { mode: t } = this.config;
|
|
2579
|
+
e.querySelectorAll(".cell").forEach((i) => {
|
|
2580
|
+
i.classList.remove("selected", "top", "bottom", "first", "last");
|
|
2542
2581
|
});
|
|
2543
2582
|
const s = e.querySelectorAll(".data-grid-row");
|
|
2544
|
-
if (s.forEach((
|
|
2545
|
-
|
|
2546
|
-
}),
|
|
2547
|
-
const l =
|
|
2548
|
-
|
|
2549
|
-
})
|
|
2550
|
-
const
|
|
2551
|
-
e.querySelectorAll(".cell[data-row][data-col]").forEach((
|
|
2552
|
-
const
|
|
2553
|
-
|
|
2583
|
+
if (s.forEach((i) => {
|
|
2584
|
+
i.classList.remove("selected", "row-focus");
|
|
2585
|
+
}), t === "row" && s.forEach((i) => {
|
|
2586
|
+
const l = i.querySelector(".cell[data-row]"), r = parseInt(l?.getAttribute("data-row") ?? "-1", 10);
|
|
2587
|
+
r >= 0 && this.selected.has(r) && (i.classList.add("selected", "row-focus"), i.querySelectorAll(".cell-focus").forEach((a) => a.classList.remove("cell-focus")));
|
|
2588
|
+
}), t === "range" && this.ranges.length > 0) {
|
|
2589
|
+
const i = this.activeRange ? z(this.activeRange) : null;
|
|
2590
|
+
e.querySelectorAll(".cell[data-row][data-col]").forEach((r) => {
|
|
2591
|
+
const a = parseInt(r.getAttribute("data-row") ?? "-1", 10), f = parseInt(r.getAttribute("data-col") ?? "-1", 10);
|
|
2592
|
+
a >= 0 && f >= 0 && ie(a, f, this.ranges) && (r.classList.add("selected"), r.classList.remove("cell-focus"), i && (a === i.startRow && r.classList.add("top"), a === i.endRow && r.classList.add("bottom"), f === i.startCol && r.classList.add("first"), f === i.endCol && r.classList.add("last")));
|
|
2554
2593
|
});
|
|
2555
2594
|
}
|
|
2595
|
+
t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((i) => i.classList.remove("cell-focus"));
|
|
2596
|
+
}
|
|
2597
|
+
afterRender() {
|
|
2598
|
+
const e = this.shadowRoot;
|
|
2599
|
+
if (!e) return;
|
|
2600
|
+
const t = e.children[0], { mode: n } = this.config;
|
|
2601
|
+
this.grid.setAttribute("data-selection-mode", n), t && t.classList.toggle("selecting", this.isDragging), this.#n();
|
|
2602
|
+
}
|
|
2603
|
+
/**
|
|
2604
|
+
* Called after scroll-triggered row rendering.
|
|
2605
|
+
* Reapplies selection classes to recycled DOM elements.
|
|
2606
|
+
*/
|
|
2607
|
+
onScrollRender() {
|
|
2608
|
+
this.#n();
|
|
2556
2609
|
}
|
|
2557
2610
|
// ===== Public API =====
|
|
2558
2611
|
/**
|
|
@@ -2606,7 +2659,7 @@ class st extends ue {
|
|
|
2606
2659
|
}), this.requestAfterRender();
|
|
2607
2660
|
}
|
|
2608
2661
|
// ===== Private Helpers =====
|
|
2609
|
-
#
|
|
2662
|
+
#i() {
|
|
2610
2663
|
return tt(
|
|
2611
2664
|
this.config.mode,
|
|
2612
2665
|
{
|
|
@@ -2655,67 +2708,67 @@ class st extends ue {
|
|
|
2655
2708
|
function G(o, e, t) {
|
|
2656
2709
|
return o.id !== void 0 ? String(o.id) : t ? `${t}-${e}` : String(e);
|
|
2657
2710
|
}
|
|
2658
|
-
function fe(o, e, t, n = null,
|
|
2659
|
-
const
|
|
2660
|
-
for (let
|
|
2661
|
-
const a = o[
|
|
2662
|
-
if (
|
|
2663
|
-
key:
|
|
2711
|
+
function fe(o, e, t, n = null, s = 0) {
|
|
2712
|
+
const i = e.childrenField ?? "children", l = [];
|
|
2713
|
+
for (let r = 0; r < o.length; r++) {
|
|
2714
|
+
const a = o[r], f = G(a, r, n), p = a[i], w = Array.isArray(p) && p.length > 0, h = t.has(f);
|
|
2715
|
+
if (l.push({
|
|
2716
|
+
key: f,
|
|
2664
2717
|
data: a,
|
|
2665
|
-
depth:
|
|
2718
|
+
depth: s,
|
|
2666
2719
|
hasChildren: w,
|
|
2667
|
-
isExpanded:
|
|
2720
|
+
isExpanded: h,
|
|
2668
2721
|
parentKey: n
|
|
2669
|
-
}), w &&
|
|
2670
|
-
const
|
|
2671
|
-
|
|
2722
|
+
}), w && h) {
|
|
2723
|
+
const c = fe(p, e, t, f, s + 1);
|
|
2724
|
+
l.push(...c);
|
|
2672
2725
|
}
|
|
2673
2726
|
}
|
|
2674
|
-
return
|
|
2727
|
+
return l;
|
|
2675
2728
|
}
|
|
2676
|
-
function
|
|
2729
|
+
function le(o, e) {
|
|
2677
2730
|
const t = new Set(o);
|
|
2678
2731
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
2679
2732
|
}
|
|
2680
2733
|
function W(o, e, t = null, n = 0) {
|
|
2681
|
-
const
|
|
2682
|
-
for (let
|
|
2683
|
-
const
|
|
2684
|
-
if (Array.isArray(
|
|
2685
|
-
|
|
2686
|
-
const
|
|
2687
|
-
for (const w of
|
|
2734
|
+
const s = e.childrenField ?? "children", i = /* @__PURE__ */ new Set();
|
|
2735
|
+
for (let l = 0; l < o.length; l++) {
|
|
2736
|
+
const r = o[l], a = G(r, l, t), f = r[s];
|
|
2737
|
+
if (Array.isArray(f) && f.length > 0) {
|
|
2738
|
+
i.add(a);
|
|
2739
|
+
const p = W(f, e, a, n + 1);
|
|
2740
|
+
for (const w of p) i.add(w);
|
|
2688
2741
|
}
|
|
2689
2742
|
}
|
|
2690
|
-
return
|
|
2743
|
+
return i;
|
|
2691
2744
|
}
|
|
2692
2745
|
function ot() {
|
|
2693
2746
|
return /* @__PURE__ */ new Set();
|
|
2694
2747
|
}
|
|
2695
|
-
function pe(o, e, t, n = null,
|
|
2696
|
-
const
|
|
2697
|
-
for (let
|
|
2698
|
-
const
|
|
2748
|
+
function pe(o, e, t, n = null, s = 0) {
|
|
2749
|
+
const i = t.childrenField ?? "children";
|
|
2750
|
+
for (let l = 0; l < o.length; l++) {
|
|
2751
|
+
const r = o[l], a = G(r, l, n);
|
|
2699
2752
|
if (a === e)
|
|
2700
2753
|
return [a];
|
|
2701
|
-
const
|
|
2702
|
-
if (Array.isArray(
|
|
2703
|
-
const
|
|
2704
|
-
if (
|
|
2705
|
-
return [a, ...
|
|
2754
|
+
const f = r[i];
|
|
2755
|
+
if (Array.isArray(f) && f.length > 0) {
|
|
2756
|
+
const p = pe(f, e, t, a, s + 1);
|
|
2757
|
+
if (p)
|
|
2758
|
+
return [a, ...p];
|
|
2706
2759
|
}
|
|
2707
2760
|
}
|
|
2708
2761
|
return null;
|
|
2709
2762
|
}
|
|
2710
2763
|
function nt(o, e, t, n) {
|
|
2711
|
-
const
|
|
2712
|
-
if (!
|
|
2713
|
-
const
|
|
2714
|
-
for (let
|
|
2715
|
-
|
|
2716
|
-
return
|
|
2717
|
-
}
|
|
2718
|
-
function
|
|
2764
|
+
const s = pe(o, e, t);
|
|
2765
|
+
if (!s) return n;
|
|
2766
|
+
const i = new Set(n);
|
|
2767
|
+
for (let l = 0; l < s.length - 1; l++)
|
|
2768
|
+
i.add(s[l]);
|
|
2769
|
+
return i;
|
|
2770
|
+
}
|
|
2771
|
+
function re(o, e = "children") {
|
|
2719
2772
|
if (!Array.isArray(o) || o.length === 0) return !1;
|
|
2720
2773
|
for (const t of o)
|
|
2721
2774
|
if (t && Array.isArray(t[e]) && t[e].length > 0)
|
|
@@ -2733,7 +2786,7 @@ function it(o) {
|
|
|
2733
2786
|
}
|
|
2734
2787
|
return null;
|
|
2735
2788
|
}
|
|
2736
|
-
class
|
|
2789
|
+
class lt extends ue {
|
|
2737
2790
|
name = "tree";
|
|
2738
2791
|
version = "1.0.0";
|
|
2739
2792
|
get defaultConfig() {
|
|
@@ -2767,12 +2820,12 @@ class rt extends ue {
|
|
|
2767
2820
|
detect(e) {
|
|
2768
2821
|
if (!this.config.autoDetect) return !1;
|
|
2769
2822
|
const t = this.config.childrenField ?? it(e) ?? "children";
|
|
2770
|
-
return
|
|
2823
|
+
return re(e, t);
|
|
2771
2824
|
}
|
|
2772
2825
|
// ===== Data Processing =====
|
|
2773
2826
|
processRows(e) {
|
|
2774
2827
|
const t = this.config.childrenField ?? "children";
|
|
2775
|
-
if (!
|
|
2828
|
+
if (!re(e, t))
|
|
2776
2829
|
return this.flattenedRows = [], this.rowKeyMap.clear(), [...e];
|
|
2777
2830
|
this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = W(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = fe(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
|
|
2778
2831
|
for (const n of this.flattenedRows)
|
|
@@ -2787,28 +2840,28 @@ class rt extends ue {
|
|
|
2787
2840
|
}
|
|
2788
2841
|
processColumns(e) {
|
|
2789
2842
|
if (this.flattenedRows.length === 0) return [...e];
|
|
2790
|
-
const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0,
|
|
2791
|
-
if (
|
|
2792
|
-
const
|
|
2793
|
-
|
|
2794
|
-
const { value: a, row:
|
|
2795
|
-
if (
|
|
2843
|
+
const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0, s = [...e];
|
|
2844
|
+
if (s.length > 0) {
|
|
2845
|
+
const i = { ...s[0] }, l = i.viewRenderer;
|
|
2846
|
+
i.viewRenderer = (r) => {
|
|
2847
|
+
const { value: a, row: f, column: p } = r, w = f.__treeDepth ?? 0, h = f.__treeHasChildren ?? !1, c = f.__treeExpanded ?? !1, d = document.createElement("span");
|
|
2848
|
+
if (d.style.display = "flex", d.style.alignItems = "center", d.style.paddingLeft = `${w * t}px`, h && n) {
|
|
2796
2849
|
const b = document.createElement("span");
|
|
2797
|
-
b.className = "tree-toggle", b.textContent =
|
|
2850
|
+
b.className = "tree-toggle", b.textContent = c ? "▼" : "▶", b.style.cursor = "pointer", b.style.marginRight = "4px", b.style.fontSize = "10px", b.setAttribute("data-tree-key", f.__treeKey), d.appendChild(b);
|
|
2798
2851
|
} else if (n) {
|
|
2799
2852
|
const b = document.createElement("span");
|
|
2800
|
-
b.style.width = "14px", b.style.display = "inline-block",
|
|
2853
|
+
b.style.width = "14px", b.style.display = "inline-block", d.appendChild(b);
|
|
2801
2854
|
}
|
|
2802
|
-
const
|
|
2803
|
-
if (
|
|
2804
|
-
const b = r
|
|
2805
|
-
b instanceof Node ?
|
|
2855
|
+
const u = document.createElement("span");
|
|
2856
|
+
if (l) {
|
|
2857
|
+
const b = l(r);
|
|
2858
|
+
b instanceof Node ? u.appendChild(b) : u.textContent = String(b ?? a ?? "");
|
|
2806
2859
|
} else
|
|
2807
|
-
|
|
2808
|
-
return
|
|
2809
|
-
},
|
|
2860
|
+
u.textContent = String(a ?? "");
|
|
2861
|
+
return d.appendChild(u), d;
|
|
2862
|
+
}, s[0] = i;
|
|
2810
2863
|
}
|
|
2811
|
-
return
|
|
2864
|
+
return s;
|
|
2812
2865
|
}
|
|
2813
2866
|
// ===== Event Handlers =====
|
|
2814
2867
|
onCellClick(e) {
|
|
@@ -2816,12 +2869,12 @@ class rt extends ue {
|
|
|
2816
2869
|
if (!t?.classList.contains("tree-toggle")) return !1;
|
|
2817
2870
|
const n = t.getAttribute("data-tree-key");
|
|
2818
2871
|
if (!n) return !1;
|
|
2819
|
-
const
|
|
2820
|
-
return
|
|
2872
|
+
const s = this.rowKeyMap.get(n);
|
|
2873
|
+
return s ? (this.expandedKeys = le(this.expandedKeys, n), this.emit("tree-expand", {
|
|
2821
2874
|
key: n,
|
|
2822
|
-
row:
|
|
2875
|
+
row: s.data,
|
|
2823
2876
|
expanded: this.expandedKeys.has(n),
|
|
2824
|
-
depth:
|
|
2877
|
+
depth: s.depth
|
|
2825
2878
|
}), this.requestRender(), !0) : !1;
|
|
2826
2879
|
}
|
|
2827
2880
|
// ===== Public API =====
|
|
@@ -2841,7 +2894,7 @@ class rt extends ue {
|
|
|
2841
2894
|
* Toggle the expansion state of a node.
|
|
2842
2895
|
*/
|
|
2843
2896
|
toggle(e) {
|
|
2844
|
-
this.expandedKeys =
|
|
2897
|
+
this.expandedKeys = le(this.expandedKeys, e), this.requestRender();
|
|
2845
2898
|
}
|
|
2846
2899
|
/**
|
|
2847
2900
|
* Expand all nodes in the tree.
|
|
@@ -2897,7 +2950,7 @@ class rt extends ue {
|
|
|
2897
2950
|
}
|
|
2898
2951
|
`;
|
|
2899
2952
|
}
|
|
2900
|
-
const
|
|
2953
|
+
const C = {
|
|
2901
2954
|
// Root structure
|
|
2902
2955
|
ROOT: "tbw-grid-root",
|
|
2903
2956
|
HEADER: "header",
|
|
@@ -2949,23 +3002,23 @@ const v = {
|
|
|
2949
3002
|
GROUP_KEY: "data-group-key",
|
|
2950
3003
|
TREE_LEVEL: "data-tree-level",
|
|
2951
3004
|
STICKY: "data-sticky"
|
|
2952
|
-
},
|
|
2953
|
-
ROOT: `.${
|
|
2954
|
-
HEADER: `.${
|
|
2955
|
-
HEADER_ROW: `.${
|
|
2956
|
-
HEADER_CELL: `.${
|
|
2957
|
-
ROWS_VIEWPORT: `.${
|
|
2958
|
-
ROWS_CONTAINER: `.${
|
|
2959
|
-
DATA_ROW: `.${
|
|
2960
|
-
DATA_CELL: `.${
|
|
2961
|
-
GROUP_ROW: `.${
|
|
3005
|
+
}, rt = {
|
|
3006
|
+
ROOT: `.${C.ROOT}`,
|
|
3007
|
+
HEADER: `.${C.HEADER}`,
|
|
3008
|
+
HEADER_ROW: `.${C.HEADER_ROW}`,
|
|
3009
|
+
HEADER_CELL: `.${C.HEADER_CELL}`,
|
|
3010
|
+
ROWS_VIEWPORT: `.${C.ROWS_VIEWPORT}`,
|
|
3011
|
+
ROWS_CONTAINER: `.${C.ROWS_CONTAINER}`,
|
|
3012
|
+
DATA_ROW: `.${C.DATA_ROW}`,
|
|
3013
|
+
DATA_CELL: `.${C.DATA_CELL}`,
|
|
3014
|
+
GROUP_ROW: `.${C.GROUP_ROW}`,
|
|
2962
3015
|
// By data attribute
|
|
2963
|
-
ROW_BY_INDEX: (o) => `.${
|
|
2964
|
-
CELL_BY_FIELD: (o) => `.${
|
|
2965
|
-
CELL_AT: (o, e) => `.${
|
|
3016
|
+
ROW_BY_INDEX: (o) => `.${C.DATA_ROW}[${H.ROW_INDEX}="${o}"]`,
|
|
3017
|
+
CELL_BY_FIELD: (o) => `.${C.DATA_CELL}[${H.FIELD}="${o}"]`,
|
|
3018
|
+
CELL_AT: (o, e) => `.${C.DATA_ROW}[${H.ROW_INDEX}="${o}"] .${C.DATA_CELL}[${H.COL_INDEX}="${e}"]`,
|
|
2966
3019
|
// State selectors
|
|
2967
|
-
SELECTED_ROWS: `.${
|
|
2968
|
-
EDITING_CELL: `.${
|
|
3020
|
+
SELECTED_ROWS: `.${C.DATA_ROW}.${C.SELECTED}`,
|
|
3021
|
+
EDITING_CELL: `.${C.DATA_CELL}.${C.EDITING}`
|
|
2969
3022
|
}, at = {
|
|
2970
3023
|
// Colors
|
|
2971
3024
|
COLOR_BG: "--tbw-color-bg",
|
|
@@ -3033,7 +3086,7 @@ const v = {
|
|
|
3033
3086
|
}, I = {
|
|
3034
3087
|
sum: (o, e) => o.reduce((t, n) => t + (Number(n[e]) || 0), 0),
|
|
3035
3088
|
avg: (o, e) => {
|
|
3036
|
-
const t = o.reduce((n,
|
|
3089
|
+
const t = o.reduce((n, s) => n + (Number(s[e]) || 0), 0);
|
|
3037
3090
|
return o.length ? t / o.length : 0;
|
|
3038
3091
|
},
|
|
3039
3092
|
count: (o) => o.length,
|
|
@@ -3041,7 +3094,7 @@ const v = {
|
|
|
3041
3094
|
max: (o, e) => Math.max(...o.map((t) => Number(t[e]) || -1 / 0)),
|
|
3042
3095
|
first: (o, e) => o[0]?.[e],
|
|
3043
3096
|
last: (o, e) => o[o.length - 1]?.[e]
|
|
3044
|
-
}, P = /* @__PURE__ */ new Map(),
|
|
3097
|
+
}, P = /* @__PURE__ */ new Map(), S = {
|
|
3045
3098
|
/**
|
|
3046
3099
|
* Register a custom aggregator function.
|
|
3047
3100
|
*/
|
|
@@ -3065,8 +3118,8 @@ const v = {
|
|
|
3065
3118
|
* Run an aggregator on a set of rows.
|
|
3066
3119
|
*/
|
|
3067
3120
|
run(o, e, t, n) {
|
|
3068
|
-
const
|
|
3069
|
-
return
|
|
3121
|
+
const s = this.get(o);
|
|
3122
|
+
return s ? s(e, t, n) : void 0;
|
|
3070
3123
|
},
|
|
3071
3124
|
/**
|
|
3072
3125
|
* Check if an aggregator exists.
|
|
@@ -3080,22 +3133,22 @@ const v = {
|
|
|
3080
3133
|
list() {
|
|
3081
3134
|
return [...Object.keys(I), ...P.keys()];
|
|
3082
3135
|
}
|
|
3083
|
-
}, ht =
|
|
3136
|
+
}, ht = S.register.bind(S), ut = S.unregister.bind(S), ft = S.get.bind(S), pt = S.run.bind(S), wt = S.list.bind(S);
|
|
3084
3137
|
export {
|
|
3085
3138
|
ue as BaseGridPlugin,
|
|
3086
3139
|
ct as DGEvents,
|
|
3087
3140
|
q as DataGridElement,
|
|
3088
3141
|
O as FitModeEnum,
|
|
3089
3142
|
at as GridCSSVars,
|
|
3090
|
-
|
|
3143
|
+
C as GridClasses,
|
|
3091
3144
|
H as GridDataAttrs,
|
|
3092
3145
|
q as GridElement,
|
|
3093
|
-
|
|
3146
|
+
rt as GridSelectors,
|
|
3094
3147
|
dt as PluginEvents,
|
|
3095
3148
|
Ye as PluginManager,
|
|
3096
3149
|
st as SelectionPlugin,
|
|
3097
|
-
|
|
3098
|
-
|
|
3150
|
+
lt as TreePlugin,
|
|
3151
|
+
S as aggregatorRegistry,
|
|
3099
3152
|
ft as getAggregator,
|
|
3100
3153
|
wt as listAggregators,
|
|
3101
3154
|
ht as registerAggregator,
|