@toolbox-web/grid 0.1.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -59
- package/all.d.ts +9 -47
- package/all.js +1853 -1366
- package/all.js.map +1 -1
- package/index.d.ts +5 -210
- package/index.js +822 -1346
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +11 -5
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +9 -4
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +11 -5
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +7 -3
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +16 -149
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +13 -6
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +13 -6
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +11 -5
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +13 -6
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +11 -5
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +13 -6
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +19 -9
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +11 -5
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +61 -56
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +11 -5
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +15 -7
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +3 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +13 -6
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +16 -157
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +13 -13
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/export.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -142
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
- package/custom-elements.json +0 -1934
package/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
const Ce = ":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.selected:focus-visible,:host .data-grid-row>.cell:focus-visible:not(.cell-focus){outline:none}:host .data-grid-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}:host .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .data-grid-row>.cell:last-child{border-right:0}:host .data-grid-row>.cell[data-type=boolean]{justify-content:center}:host .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size)}:host .data-grid-row>.cell.editing{overflow:hidden;padding:0}:host .data-grid-row>.cell.editing input:not([type=checkbox]),:host .data-grid-row>.cell.editing select,:host .data-grid-row>.cell.editing textarea{width:100%;height:100%;max-width:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}:host .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}:host .data-grid-row:hover{background:var(--tbw-color-row-hover)}:host .sortable{cursor:pointer;user-select:none}:host .resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius)}:host .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}:host .cell-focus,:host .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-row-alt);font-weight:500;border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height)}:host .group-row .cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px)}:host .group-row .group-toggle{background:none;border:0;cursor:pointer;padding:0 4px 0 0;font:inherit}:host .group-row .group-count{margin-left:4px;opacity:.7}:host .sticky-left,:host .sticky-right{position:sticky;z-index:25}:host .header-row>.cell.sticky-left,:host .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}:host .data-grid-row>.cell.sticky-left,:host .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}:host .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}:host .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}.grid-container{position:relative;width:100%;height:100%}.grid-placeholder{padding:2rem;text-align:center;color:var(--tbw-color-fg);opacity:.6}:host{--tbw-shell-header-height: 44px;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: 14px;--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 280px;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 40px;--tbw-tool-panel-transition: .2s ease-out;--tbw-toolbar-button-size: 32px;--tbw-toolbar-button-gap: 4px}:host .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}:host .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}:host .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}:host .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}:host .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}:host .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}:host .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}:host .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}:host .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}:host .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}:host .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}:host .tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden}:host .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:30;box-shadow:-2px 0 8px var(--tbw-color-shadow)}:host .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}:host .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}:host .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background .15s ease}:host .tbw-tool-panel-resize[data-handle-position=left]{left:0}:host .tbw-tool-panel-resize[data-handle-position=right]{right:0}:host .tbw-tool-panel-resize:hover,:host .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}:host .tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}:host .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}:host .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}:host .tbw-tool-panel-content{flex:1;overflow:auto}:host .tbw-accordion{display:flex;flex-direction:column;gap:0}:host .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}:host .tbw-accordion-section:last-child{border-bottom:none}:host .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:left;cursor:pointer;user-select:none}:host .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}:host .tbw-accordion-section.single .tbw-accordion-header{cursor:default}:host .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}:host .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}:host .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}:host .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}:host .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .tbw-accordion-content{display:none}:host .tbw-accordion-section.expanded .tbw-accordion-content{display:block}:host .tbw-quick-filter-input{flex:1;max-width:300px;height:28px;padding:0 8px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:13px}:host .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}:host .tbw-selection-summary{font-size:13px;color:var(--tbw-color-fg-muted);white-space:nowrap}";
|
|
2
|
-
function
|
|
1
|
+
const ue = ":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.selected:focus-visible,:host .data-grid-row>.cell:focus-visible:not(.cell-focus){outline:none}:host .data-grid-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}:host .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .data-grid-row>.cell:last-child{border-right:0}:host .data-grid-row>.cell[data-type=boolean]{justify-content:center}:host .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size)}:host .data-grid-row>.cell.editing{overflow:hidden;padding:0}:host .data-grid-row>.cell.editing input:not([type=checkbox]),:host .data-grid-row>.cell.editing select,:host .data-grid-row>.cell.editing textarea{width:100%;height:100%;max-width:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}:host .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}:host .data-grid-row:hover{background:var(--tbw-color-row-hover)}:host .sortable{cursor:pointer;user-select:none}:host .resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius)}:host .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}:host .cell-focus,:host .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-row-alt);font-weight:500;border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height)}:host .group-row .cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, 2px 8px)}:host .group-row .group-toggle{background:none;border:0;cursor:pointer;padding:0 4px 0 0;font:inherit}:host .group-row .group-count{margin-left:4px;opacity:.7}:host .sticky-left,:host .sticky-right{position:sticky;z-index:25}:host .header-row>.cell.sticky-left,:host .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}:host .data-grid-row>.cell.sticky-left,:host .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}:host .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}:host .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}.grid-container{position:relative;width:100%;height:100%}.grid-placeholder{padding:2rem;text-align:center;color:var(--tbw-color-fg);opacity:.6}:host{--tbw-shell-header-height: 44px;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: 14px;--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 280px;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 40px;--tbw-tool-panel-transition: .2s ease-out;--tbw-toolbar-button-size: 32px;--tbw-toolbar-button-gap: 4px}:host .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}:host .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}:host .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}:host .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}:host .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}:host .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}:host .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}:host .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}:host .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}:host .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}:host .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}:host .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}:host .tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden}:host .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:30;box-shadow:-2px 0 8px var(--tbw-color-shadow)}:host .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}:host .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}:host .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background .15s ease}:host .tbw-tool-panel-resize[data-handle-position=left]{left:0}:host .tbw-tool-panel-resize[data-handle-position=right]{right:0}:host .tbw-tool-panel-resize:hover,:host .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}:host .tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}:host .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}:host .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}:host .tbw-tool-panel-content{flex:1;overflow:auto}:host .tbw-accordion{display:flex;flex-direction:column;gap:0}:host .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}:host .tbw-accordion-section:last-child{border-bottom:none}:host .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:left;cursor:pointer;user-select:none}:host .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}:host .tbw-accordion-section.single .tbw-accordion-header{cursor:default}:host .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}:host .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}:host .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}:host .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}:host .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .tbw-accordion-content{display:none}:host .tbw-accordion-section.expanded .tbw-accordion-content{display:block}:host .tbw-quick-filter-input{flex:1;max-width:300px;height:28px;padding:0 8px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:13px}:host .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}:host .tbw-selection-summary{font-size:13px;color:var(--tbw-color-fg-muted);white-space:nowrap}";
|
|
2
|
+
function he(t) {
|
|
3
3
|
const e = /* @__PURE__ */ new Map();
|
|
4
4
|
return t.sortState && e.set(t.sortState.field, {
|
|
5
5
|
direction: t.sortState.direction === 1 ? "asc" : "desc",
|
|
6
6
|
priority: 0
|
|
7
7
|
}), e;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
const o = t._columns, n =
|
|
9
|
+
function re(t, e) {
|
|
10
|
+
const o = t._columns, n = he(t);
|
|
11
11
|
return {
|
|
12
|
-
columns: o.map((
|
|
12
|
+
columns: o.map((i, s) => {
|
|
13
13
|
const r = {
|
|
14
|
-
field:
|
|
15
|
-
order:
|
|
14
|
+
field: i.field,
|
|
15
|
+
order: s,
|
|
16
16
|
visible: !0
|
|
17
17
|
// If it's in _columns, it's visible (hidden columns are filtered out)
|
|
18
|
-
}, l =
|
|
19
|
-
l.__renderedWidth !== void 0 ? r.width = l.__renderedWidth :
|
|
20
|
-
const a = n.get(
|
|
18
|
+
}, l = i;
|
|
19
|
+
l.__renderedWidth !== void 0 ? r.width = l.__renderedWidth : i.width !== void 0 && (r.width = typeof i.width == "string" ? parseFloat(i.width) : i.width);
|
|
20
|
+
const a = n.get(i.field);
|
|
21
21
|
a && (r.sort = a);
|
|
22
22
|
for (const d of e)
|
|
23
23
|
if (d.getColumnState) {
|
|
24
|
-
const h = d.getColumnState(
|
|
24
|
+
const h = d.getColumnState(i.field);
|
|
25
25
|
h && Object.assign(r, h);
|
|
26
26
|
}
|
|
27
27
|
return r;
|
|
28
28
|
})
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function fe(t, e, o, n) {
|
|
32
32
|
if (!e.columns || e.columns.length === 0) return;
|
|
33
|
-
const
|
|
34
|
-
const a =
|
|
33
|
+
const i = new Map(e.columns.map((l) => [l.field, l])), s = o.map((l) => {
|
|
34
|
+
const a = i.get(l.field);
|
|
35
35
|
if (!a) return l;
|
|
36
36
|
const d = { ...l };
|
|
37
37
|
return a.width !== void 0 && (d.width = a.width, d.__renderedWidth = a.width), a.visible !== void 0 && (d.hidden = !a.visible), d;
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
const d =
|
|
39
|
+
s.sort((l, a) => {
|
|
40
|
+
const d = i.get(l.field)?.order ?? 1 / 0, h = i.get(a.field)?.order ?? 1 / 0;
|
|
41
41
|
return d - h;
|
|
42
|
-
}), t._columns =
|
|
42
|
+
}), t._columns = s;
|
|
43
43
|
const r = e.columns.filter((l) => l.sort !== void 0).sort((l, a) => (l.sort?.priority ?? 0) - (a.sort?.priority ?? 0));
|
|
44
44
|
if (r.length > 0) {
|
|
45
45
|
const l = r[0];
|
|
@@ -54,13 +54,13 @@ function Re(t, e, o, n) {
|
|
|
54
54
|
for (const a of e.columns)
|
|
55
55
|
l.applyColumnState(a.field, a);
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function pe(t, e, o) {
|
|
58
58
|
let n = null;
|
|
59
59
|
return () => {
|
|
60
60
|
n !== null && clearTimeout(n), n = setTimeout(() => {
|
|
61
61
|
n = null;
|
|
62
|
-
const
|
|
63
|
-
o(
|
|
62
|
+
const i = re(t, e());
|
|
63
|
+
o(i);
|
|
64
64
|
}, 100);
|
|
65
65
|
};
|
|
66
66
|
}
|
|
@@ -77,25 +77,25 @@ const q = {
|
|
|
77
77
|
dragHandle: "⋮⋮",
|
|
78
78
|
toolPanel: "☰"
|
|
79
79
|
};
|
|
80
|
-
function
|
|
80
|
+
function be(t) {
|
|
81
81
|
return t == null ? "string" : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t instanceof Date || typeof t == "string" && /\d{4}-\d{2}-\d{2}/.test(t) && !isNaN(Date.parse(t)) ? "date" : "string";
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function le(t, e) {
|
|
84
84
|
if (e && e.length) {
|
|
85
|
-
const
|
|
85
|
+
const s = {};
|
|
86
86
|
return e.forEach((r) => {
|
|
87
|
-
r.type && (
|
|
88
|
-
}), { columns: e, typeMap:
|
|
89
|
-
}
|
|
90
|
-
const o = t[0] || {}, n = Object.keys(o).map((
|
|
91
|
-
const r = o[
|
|
92
|
-
return { field:
|
|
93
|
-
}),
|
|
94
|
-
return n.forEach((
|
|
95
|
-
s
|
|
96
|
-
}), { columns: n, typeMap:
|
|
97
|
-
}
|
|
98
|
-
const
|
|
87
|
+
r.type && (s[r.field] = r.type);
|
|
88
|
+
}), { columns: e, typeMap: s };
|
|
89
|
+
}
|
|
90
|
+
const o = t[0] || {}, n = Object.keys(o).map((s) => {
|
|
91
|
+
const r = o[s], l = be(r);
|
|
92
|
+
return { field: s, header: s.charAt(0).toUpperCase() + s.slice(1), type: l };
|
|
93
|
+
}), i = {};
|
|
94
|
+
return n.forEach((s) => {
|
|
95
|
+
i[s.field] = s.type || "string";
|
|
96
|
+
}), { columns: n, typeMap: i };
|
|
97
|
+
}
|
|
98
|
+
const we = /{{\s*([^}]+)\s*}}/g, k = "__DG_EMPTY__", ge = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, me = /__(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/, ve = /* @__PURE__ */ new Set([
|
|
99
99
|
"script",
|
|
100
100
|
"iframe",
|
|
101
101
|
"object",
|
|
@@ -120,76 +120,76 @@ const Ae = /{{\s*([^}]+)\s*}}/g, k = "__DG_EMPTY__", Se = /^[\w$. '?+\-*/%:()!<>
|
|
|
120
120
|
"plaintext",
|
|
121
121
|
"xmp",
|
|
122
122
|
"listing"
|
|
123
|
-
]),
|
|
124
|
-
function
|
|
123
|
+
]), Y = /^on\w+$/i, Ee = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), Ce = /^\s*(javascript|vbscript|data|blob):/i;
|
|
124
|
+
function W(t) {
|
|
125
125
|
if (!t || typeof t != "string") return "";
|
|
126
126
|
if (t.indexOf("<") === -1) return t;
|
|
127
127
|
const e = document.createElement("template");
|
|
128
|
-
return e.innerHTML = t,
|
|
128
|
+
return e.innerHTML = t, ye(e.content), e.innerHTML;
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function ye(t) {
|
|
131
131
|
const e = [], o = t.querySelectorAll("*");
|
|
132
132
|
for (const n of o) {
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
133
|
+
const i = n.tagName.toLowerCase();
|
|
134
|
+
if (ve.has(i)) {
|
|
135
135
|
e.push(n);
|
|
136
136
|
continue;
|
|
137
137
|
}
|
|
138
|
-
if ((
|
|
139
|
-
(l) =>
|
|
138
|
+
if ((i === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
|
|
139
|
+
(l) => Y.test(l.name) || l.name === "href" || l.name === "xlink:href"
|
|
140
140
|
)) {
|
|
141
141
|
e.push(n);
|
|
142
142
|
continue;
|
|
143
143
|
}
|
|
144
|
-
const
|
|
144
|
+
const s = [];
|
|
145
145
|
for (const r of n.attributes) {
|
|
146
146
|
const l = r.name.toLowerCase();
|
|
147
|
-
if (
|
|
148
|
-
|
|
147
|
+
if (Y.test(l)) {
|
|
148
|
+
s.push(r.name);
|
|
149
149
|
continue;
|
|
150
150
|
}
|
|
151
|
-
if (
|
|
152
|
-
|
|
151
|
+
if (Ee.has(l) && Ce.test(r.value)) {
|
|
152
|
+
s.push(r.name);
|
|
153
153
|
continue;
|
|
154
154
|
}
|
|
155
155
|
if (l === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(r.value)) {
|
|
156
|
-
|
|
156
|
+
s.push(r.name);
|
|
157
157
|
continue;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
s.forEach((r) => n.removeAttribute(r));
|
|
161
161
|
}
|
|
162
162
|
e.forEach((n) => n.remove());
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function ae(t, e) {
|
|
165
165
|
if (!t || t.indexOf("{{") === -1) return t;
|
|
166
|
-
const o = [], n = t.replace(
|
|
167
|
-
const d =
|
|
166
|
+
const o = [], n = t.replace(we, (l, a) => {
|
|
167
|
+
const d = _e(a, e);
|
|
168
168
|
return o.push({ expr: a.trim(), result: d }), d;
|
|
169
|
-
}),
|
|
170
|
-
return /Reflect\.|\bProxy\b|ownKeys\(/.test(t) ||
|
|
169
|
+
}), i = Re(n), s = o.length && o.every((l) => l.result === "" || l.result === k);
|
|
170
|
+
return /Reflect\.|\bProxy\b|ownKeys\(/.test(t) || s ? "" : i;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function _e(t, e) {
|
|
173
173
|
if (t = (t || "").trim(), !t || /\b(Reflect|Proxy|ownKeys)\b/.test(t)) return k;
|
|
174
174
|
if (t === "value") return e.value == null ? k : String(e.value);
|
|
175
175
|
if (t.startsWith("row.") && !/[()?]/.test(t) && !t.includes(":")) {
|
|
176
|
-
const n = t.slice(4),
|
|
177
|
-
return
|
|
176
|
+
const n = t.slice(4), i = e.row ? e.row[n] : void 0;
|
|
177
|
+
return i == null ? k : String(i);
|
|
178
178
|
}
|
|
179
|
-
if (t.length > 80 || !
|
|
179
|
+
if (t.length > 80 || !ge.test(t) || me.test(t)) return k;
|
|
180
180
|
const o = t.match(/\./g);
|
|
181
181
|
if (o && o.length > 1) return k;
|
|
182
182
|
try {
|
|
183
|
-
const
|
|
184
|
-
return /Reflect|Proxy|ownKeys/.test(
|
|
183
|
+
const i = new Function("value", "row", `return (${t});`)(e.value, e.row), s = i == null ? "" : String(i);
|
|
184
|
+
return /Reflect|Proxy|ownKeys/.test(s) ? k : s || k;
|
|
185
185
|
} catch {
|
|
186
186
|
return k;
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function Re(t) {
|
|
190
190
|
return t && t.replace(new RegExp(k, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function Se(t) {
|
|
193
193
|
if (/Reflect|Proxy|ownKeys/.test(t.textContent || "")) {
|
|
194
194
|
if (Array.from(t.childNodes).forEach((e) => {
|
|
195
195
|
e.nodeType === Node.TEXT_NODE && /Reflect|Proxy|ownKeys/.test(e.textContent || "") && (e.textContent = "");
|
|
@@ -201,40 +201,40 @@ function He(t) {
|
|
|
201
201
|
(t.textContent || "").trim().length === 0 && (t.textContent = "");
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
function
|
|
205
|
-
const e = /Reflect\.|\bProxy\b|ownKeys\(/.test(t), o = (n) => e ? "" :
|
|
204
|
+
function Z(t) {
|
|
205
|
+
const e = /Reflect\.|\bProxy\b|ownKeys\(/.test(t), o = (n) => e ? "" : ae(t, n);
|
|
206
206
|
return o.__blocked = e, o;
|
|
207
207
|
}
|
|
208
|
-
function
|
|
208
|
+
function xe(t) {
|
|
209
209
|
return Array.from(t.querySelectorAll("tbw-grid-column")).map((o) => {
|
|
210
210
|
const n = o.getAttribute("field") || "";
|
|
211
211
|
if (!n) return null;
|
|
212
|
-
const
|
|
212
|
+
const i = o.getAttribute("type") || void 0, r = i && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(i) ? i : void 0, l = o.getAttribute("header") || void 0, a = o.hasAttribute("sortable"), d = o.hasAttribute("editable"), h = { field: n, type: r, header: l, sortable: a, editable: d };
|
|
213
213
|
o.hasAttribute("resizable") && (h.resizable = !0), o.hasAttribute("sizable") && (h.resizable = !0);
|
|
214
214
|
const p = o.getAttribute("options");
|
|
215
215
|
p && (h.options = p.split(",").map((f) => {
|
|
216
|
-
const [
|
|
217
|
-
return { value:
|
|
216
|
+
const [w, v] = f.includes(":") ? f.split(":") : [f.trim(), f.trim()];
|
|
217
|
+
return { value: w.trim(), label: v?.trim() || w.trim() };
|
|
218
218
|
}));
|
|
219
|
-
const
|
|
220
|
-
return
|
|
219
|
+
const b = o.querySelector("tbw-grid-column-view"), c = o.querySelector("tbw-grid-column-editor"), u = o.querySelector("tbw-grid-column-header");
|
|
220
|
+
return b && (h.__viewTemplate = b), c && (h.__editorTemplate = c), u && (h.__headerTemplate = u), h;
|
|
221
221
|
}).filter((o) => !!o);
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function Ae(t, e) {
|
|
224
224
|
if ((!t || !t.length) && (!e || !e.length)) return [];
|
|
225
225
|
if (!t || !t.length) return e || [];
|
|
226
226
|
if (!e || !e.length) return t;
|
|
227
227
|
const o = {};
|
|
228
|
-
e.forEach((
|
|
229
|
-
const n = t.map((
|
|
230
|
-
const
|
|
231
|
-
if (!
|
|
232
|
-
const r = { ...
|
|
233
|
-
return
|
|
228
|
+
e.forEach((i) => o[i.field] = i);
|
|
229
|
+
const n = t.map((i) => {
|
|
230
|
+
const s = o[i.field];
|
|
231
|
+
if (!s) return i;
|
|
232
|
+
const r = { ...i };
|
|
233
|
+
return s.header && !r.header && (r.header = s.header), s.type && !r.type && (r.type = s.type), r.sortable = i.sortable || s.sortable, (i.resizable === !0 || s.resizable === !0) && (r.resizable = !0), r.editable = i.editable || s.editable, s.__viewTemplate && (r.__viewTemplate = s.__viewTemplate), s.__editorTemplate && (r.__editorTemplate = s.__editorTemplate), s.__headerTemplate && (r.__headerTemplate = s.__headerTemplate), delete o[i.field], r;
|
|
234
234
|
});
|
|
235
|
-
return Object.keys(o).forEach((
|
|
235
|
+
return Object.keys(o).forEach((i) => n.push(o[i])), n;
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function U(t, e) {
|
|
238
238
|
try {
|
|
239
239
|
t.part?.add?.(e);
|
|
240
240
|
} catch {
|
|
@@ -242,45 +242,45 @@ function X(t, e) {
|
|
|
242
242
|
const o = t.getAttribute("part");
|
|
243
243
|
o ? o.split(/\s+/).includes(e) || t.setAttribute("part", o + " " + e) : t.setAttribute("part", e);
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function Te(t) {
|
|
246
246
|
t.__lightDomColumnsCache || (t.__originalColumnNodes = Array.from(
|
|
247
247
|
t.querySelectorAll("tbw-grid-column")
|
|
248
|
-
), t.__lightDomColumnsCache = t.__originalColumnNodes.length ?
|
|
249
|
-
const e = t.__lightDomColumnsCache, o =
|
|
250
|
-
o.forEach((
|
|
251
|
-
|
|
248
|
+
), t.__lightDomColumnsCache = t.__originalColumnNodes.length ? xe(t) : []);
|
|
249
|
+
const e = t.__lightDomColumnsCache, o = Ae(t._columns, e);
|
|
250
|
+
o.forEach((i) => {
|
|
251
|
+
i.__viewTemplate && !i.__compiledView && (i.__compiledView = Z(i.__viewTemplate.innerHTML)), i.__editorTemplate && !i.__compiledEditor && (i.__compiledEditor = Z(i.__editorTemplate.innerHTML));
|
|
252
252
|
});
|
|
253
|
-
const { columns: n } =
|
|
253
|
+
const { columns: n } = le(t._rows, o);
|
|
254
254
|
t._columns = n;
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function Le(t) {
|
|
257
257
|
const e = t.effectiveConfig?.fitMode || t.fitMode || q.STRETCH;
|
|
258
258
|
if (e !== q.STRETCH && e !== q.FIXED || t.__didInitialAutoSize || !t.isConnected) return;
|
|
259
259
|
const o = t.headerRowEl?.children || [];
|
|
260
260
|
if (!o.length) return;
|
|
261
261
|
let n = !1;
|
|
262
|
-
t.visibleColumns.forEach((
|
|
263
|
-
if (
|
|
264
|
-
const r = o[
|
|
262
|
+
t.visibleColumns.forEach((i, s) => {
|
|
263
|
+
if (i.width) return;
|
|
264
|
+
const r = o[s];
|
|
265
265
|
let l = r ? r.scrollWidth : 0;
|
|
266
266
|
for (const a of t.rowPool) {
|
|
267
|
-
const d = a.children[
|
|
267
|
+
const d = a.children[s];
|
|
268
268
|
if (d) {
|
|
269
269
|
const h = d.scrollWidth;
|
|
270
270
|
h > l && (l = h);
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
l > 0 && (
|
|
274
|
-
}), n &&
|
|
273
|
+
l > 0 && (i.width = l + 2, i.__autoSized = !0, n = !0);
|
|
274
|
+
}), n && ce(t), t.__didInitialAutoSize = !0;
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function ce(t) {
|
|
277
277
|
(t.effectiveConfig?.fitMode || t.fitMode || q.STRETCH) === q.STRETCH ? t.gridTemplate = t.visibleColumns.map((o) => {
|
|
278
278
|
if (o.width) return `${o.width}px`;
|
|
279
279
|
const n = o.minWidth;
|
|
280
280
|
return n != null ? `minmax(${n}px, 1fr)` : "1fr";
|
|
281
281
|
}).join(" ").trim() : t.gridTemplate = t.visibleColumns.map((o) => o.width ? `${o.width}px` : "max-content").join(" "), t.style.setProperty("--tbw-column-template", t.gridTemplate);
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function ke(t) {
|
|
284
284
|
switch (t.type) {
|
|
285
285
|
case "number":
|
|
286
286
|
return (e) => {
|
|
@@ -305,21 +305,21 @@ function $e(t) {
|
|
|
305
305
|
case "typeahead":
|
|
306
306
|
return (e) => {
|
|
307
307
|
const o = document.createElement("select");
|
|
308
|
-
e.column.multi && (o.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((
|
|
308
|
+
e.column.multi && (o.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((s) => {
|
|
309
309
|
const r = document.createElement("option");
|
|
310
|
-
r.value = String(
|
|
310
|
+
r.value = String(s.value), r.textContent = s.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(s.value) || !e.column.multi && e.value === s.value) && (r.selected = !0), o.appendChild(r);
|
|
311
311
|
});
|
|
312
|
-
const
|
|
312
|
+
const i = () => {
|
|
313
313
|
if (e.column.multi) {
|
|
314
|
-
const
|
|
314
|
+
const s = [];
|
|
315
315
|
Array.from(o.selectedOptions).forEach((r) => {
|
|
316
|
-
|
|
317
|
-
}), e.commit(
|
|
316
|
+
s.push(r.value);
|
|
317
|
+
}), e.commit(s);
|
|
318
318
|
} else
|
|
319
319
|
e.commit(o.value);
|
|
320
320
|
};
|
|
321
|
-
return o.addEventListener("change",
|
|
322
|
-
|
|
321
|
+
return o.addEventListener("change", i), o.addEventListener("blur", i), o.addEventListener("keydown", (s) => {
|
|
322
|
+
s.key === "Escape" && e.cancel();
|
|
323
323
|
}), o.focus(), o;
|
|
324
324
|
};
|
|
325
325
|
default:
|
|
@@ -331,25 +331,25 @@ function $e(t) {
|
|
|
331
331
|
};
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function Pe(t, e) {
|
|
335
335
|
if (t.dispatchKeyDown?.(e))
|
|
336
336
|
return;
|
|
337
|
-
const o = t._rows.length - 1, n = t.visibleColumns.length - 1,
|
|
337
|
+
const o = t._rows.length - 1, n = t.visibleColumns.length - 1, i = t.activeEditRows !== void 0 && t.activeEditRows !== -1, r = t.visibleColumns[t.focusCol]?.type, l = e.composedPath ? e.composedPath() : [], a = l && l.length ? l[0] : e.target, d = (h) => {
|
|
338
338
|
if (!h) return !1;
|
|
339
339
|
const p = h.tagName;
|
|
340
340
|
return !!(p === "INPUT" || p === "SELECT" || p === "TEXTAREA" || h.isContentEditable);
|
|
341
341
|
};
|
|
342
|
-
if (!(d(a) && (e.key === "Home" || e.key === "End")) && !(d(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(d(a) && (e.key === "ArrowLeft" || e.key === "ArrowRight")) && !(d(a) && (e.key === "Enter" || e.key === "Escape")) && !(
|
|
342
|
+
if (!(d(a) && (e.key === "Home" || e.key === "End")) && !(d(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(d(a) && (e.key === "ArrowLeft" || e.key === "ArrowRight")) && !(d(a) && (e.key === "Enter" || e.key === "Escape")) && !(i && (r === "select" || r === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
|
|
343
343
|
switch (e.key) {
|
|
344
344
|
case "Tab": {
|
|
345
|
-
e.preventDefault(), !e.shiftKey ? t.focusCol < n ? t.focusCol += 1 : (typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t.focusRow < o && (t.focusRow += 1, t.focusCol = 0)) : t.focusCol > 0 ? t.focusCol -= 1 : t.focusRow > 0 && (typeof t.commitActiveRowEdit == "function" && t.activeEditRows === t.focusRow && t.commitActiveRowEdit(), t.focusRow -= 1, t.focusCol = n),
|
|
345
|
+
e.preventDefault(), !e.shiftKey ? t.focusCol < n ? t.focusCol += 1 : (typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t.focusRow < o && (t.focusRow += 1, t.focusCol = 0)) : t.focusCol > 0 ? t.focusCol -= 1 : t.focusRow > 0 && (typeof t.commitActiveRowEdit == "function" && t.activeEditRows === t.focusRow && t.commitActiveRowEdit(), t.focusRow -= 1, t.focusCol = n), $(t);
|
|
346
346
|
return;
|
|
347
347
|
}
|
|
348
348
|
case "ArrowDown":
|
|
349
|
-
|
|
349
|
+
i && typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t.focusRow = Math.min(o, t.focusRow + 1), e.preventDefault();
|
|
350
350
|
break;
|
|
351
351
|
case "ArrowUp":
|
|
352
|
-
|
|
352
|
+
i && typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t.focusRow = Math.max(0, t.focusRow - 1), e.preventDefault();
|
|
353
353
|
break;
|
|
354
354
|
case "ArrowRight":
|
|
355
355
|
t.focusCol = Math.min(n, t.focusCol + 1), e.preventDefault();
|
|
@@ -372,26 +372,26 @@ function Be(t, e) {
|
|
|
372
372
|
case "Enter":
|
|
373
373
|
return typeof t.beginBulkEdit == "function" ? t.beginBulkEdit(t.focusRow) : t.dispatchEvent(
|
|
374
374
|
new CustomEvent("activate-cell", { detail: { row: t.focusRow, col: t.focusCol } })
|
|
375
|
-
),
|
|
375
|
+
), $(t);
|
|
376
376
|
default:
|
|
377
377
|
return;
|
|
378
378
|
}
|
|
379
|
-
|
|
379
|
+
$(t);
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
function
|
|
382
|
+
function $(t) {
|
|
383
383
|
if (t.virtualization?.enabled) {
|
|
384
|
-
const { rowHeight:
|
|
384
|
+
const { rowHeight: s, container: r, viewportEl: l } = t.virtualization, a = r, d = l?.clientHeight ?? a?.clientHeight ?? 0;
|
|
385
385
|
if (a && d > 0) {
|
|
386
|
-
const h = t.focusRow *
|
|
387
|
-
h < a.scrollTop ? a.scrollTop = h : h +
|
|
386
|
+
const h = t.focusRow * s;
|
|
387
|
+
h < a.scrollTop ? a.scrollTop = h : h + s > a.scrollTop + d && (a.scrollTop = h - d + s);
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
|
-
t.activeEditRows !== void 0 && t.activeEditRows !== -1 || t.refreshVirtualWindow(!1), Array.from(t.bodyEl.querySelectorAll(".cell-focus")).forEach((
|
|
391
|
-
|
|
390
|
+
t.activeEditRows !== void 0 && t.activeEditRows !== -1 || t.refreshVirtualWindow(!1), Array.from(t.bodyEl.querySelectorAll(".cell-focus")).forEach((s) => s.classList.remove("cell-focus")), Array.from(t.bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((s) => {
|
|
391
|
+
s.setAttribute("aria-selected", "false");
|
|
392
392
|
});
|
|
393
|
-
const o = t.focusRow, n = t.virtualization.start ?? 0,
|
|
394
|
-
if (o >= n && o <
|
|
393
|
+
const o = t.focusRow, n = t.virtualization.start ?? 0, i = t.virtualization.end ?? t._rows.length;
|
|
394
|
+
if (o >= n && o < i) {
|
|
395
395
|
const r = t.bodyEl.querySelectorAll(".data-grid-row")[o - n]?.children[t.focusCol];
|
|
396
396
|
if (r) {
|
|
397
397
|
if (r.classList.add("cell-focus"), r.setAttribute("aria-selected", "true"), t.activeEditRows !== void 0 && t.activeEditRows !== -1 && r.classList.contains("editing")) {
|
|
@@ -413,87 +413,87 @@ function I(t) {
|
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
|
-
const
|
|
417
|
-
function
|
|
418
|
-
t[
|
|
416
|
+
const Oe = "__cellDisplayCache", He = "__cellCacheEpoch";
|
|
417
|
+
function X(t) {
|
|
418
|
+
t[Oe] = void 0, t[He] = void 0, t.__hasSpecialColumns = void 0;
|
|
419
419
|
}
|
|
420
|
-
function
|
|
421
|
-
const
|
|
420
|
+
function Me(t, e, o, n, i) {
|
|
421
|
+
const s = Math.max(0, o - e), r = t.bodyEl, l = t.visibleColumns, a = l.length;
|
|
422
422
|
let d = t.__cachedHeaderRowCount;
|
|
423
|
-
for (d === void 0 && (d = t.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, t.__cachedHeaderRowCount = d); t.rowPool.length <
|
|
423
|
+
for (d === void 0 && (d = t.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, t.__cachedHeaderRowCount = d); t.rowPool.length < s; ) {
|
|
424
424
|
const p = document.createElement("div");
|
|
425
|
-
p.className = "data-grid-row", p.setAttribute("role", "row"), p.addEventListener("click", (
|
|
425
|
+
p.className = "data-grid-row", p.setAttribute("role", "row"), p.addEventListener("click", (b) => J(t, b, p, !1)), p.addEventListener("dblclick", (b) => J(t, b, p, !0)), t.rowPool.push(p);
|
|
426
426
|
}
|
|
427
|
-
if (t.rowPool.length >
|
|
428
|
-
for (let p =
|
|
429
|
-
const
|
|
430
|
-
|
|
427
|
+
if (t.rowPool.length > s) {
|
|
428
|
+
for (let p = s; p < t.rowPool.length; p++) {
|
|
429
|
+
const b = t.rowPool[p];
|
|
430
|
+
b.parentNode === r && b.remove();
|
|
431
431
|
}
|
|
432
|
-
t.rowPool.length =
|
|
432
|
+
t.rowPool.length = s;
|
|
433
433
|
}
|
|
434
|
-
const h =
|
|
435
|
-
for (let p = 0; p <
|
|
436
|
-
const
|
|
437
|
-
if (u.setAttribute("aria-rowindex", String(
|
|
434
|
+
const h = i && t.__hasRenderRowPlugins !== !1;
|
|
435
|
+
for (let p = 0; p < s; p++) {
|
|
436
|
+
const b = e + p, c = t._rows[b], u = t.rowPool[p];
|
|
437
|
+
if (u.setAttribute("aria-rowindex", String(b + d + 1)), h && i(c, u, b)) {
|
|
438
438
|
u.__epoch = n, u.__rowDataRef = c, u.parentNode !== r && r.appendChild(u);
|
|
439
439
|
continue;
|
|
440
440
|
}
|
|
441
|
-
const f = u.__epoch,
|
|
441
|
+
const f = u.__epoch, w = u.__rowDataRef, v = u.children.length, x = f === n && v === a, R = w !== c;
|
|
442
442
|
let T = !1;
|
|
443
|
-
if (
|
|
444
|
-
for (let
|
|
445
|
-
if (l[
|
|
443
|
+
if (x && R) {
|
|
444
|
+
for (let E = 0; E < a; E++)
|
|
445
|
+
if (l[E].externalView && !u.querySelector(`.cell[data-col="${E}"] [data-external-view]`)) {
|
|
446
446
|
T = !0;
|
|
447
447
|
break;
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
|
-
if (!
|
|
451
|
-
const
|
|
452
|
-
if (
|
|
453
|
-
u.__isCustomRow && (u.className = "data-grid-row", u.setAttribute("role", "row"), u.__isCustomRow = !1),
|
|
454
|
-
else if (
|
|
455
|
-
|
|
456
|
-
else if (u.__isCustomRow && (u.className = "data-grid-row", u.setAttribute("role", "row"), u.__isCustomRow = !1),
|
|
457
|
-
const
|
|
458
|
-
for (let C = 0; C <
|
|
450
|
+
if (!x || T) {
|
|
451
|
+
const E = u.querySelector(".cell.editing"), y = t.activeEditRows === b;
|
|
452
|
+
if (E && !y)
|
|
453
|
+
u.__isCustomRow && (u.className = "data-grid-row", u.setAttribute("role", "row"), u.__isCustomRow = !1), M(t, u, c, b), u.__epoch = n, u.__rowDataRef = c;
|
|
454
|
+
else if (E && y)
|
|
455
|
+
G(t, u, c, b), u.__rowDataRef = c;
|
|
456
|
+
else if (u.__isCustomRow && (u.className = "data-grid-row", u.setAttribute("role", "row"), u.__isCustomRow = !1), M(t, u, c, b), u.__epoch = n, u.__rowDataRef = c, y) {
|
|
457
|
+
const _ = u.children;
|
|
458
|
+
for (let C = 0; C < _.length; C++) {
|
|
459
459
|
const L = t.visibleColumns[C];
|
|
460
|
-
L && L.editable &&
|
|
460
|
+
L && L.editable && O(t, c, b, L, _[C]);
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
|
-
} else if (
|
|
464
|
-
const
|
|
465
|
-
if (
|
|
466
|
-
|
|
467
|
-
else if (
|
|
468
|
-
const
|
|
469
|
-
for (let C = 0; C <
|
|
463
|
+
} else if (R) {
|
|
464
|
+
const E = u.querySelector(".cell.editing"), y = t.activeEditRows === b;
|
|
465
|
+
if (E && !y)
|
|
466
|
+
M(t, u, c, b), u.__epoch = n, u.__rowDataRef = c;
|
|
467
|
+
else if (G(t, u, c, b), u.__rowDataRef = c, y && !E) {
|
|
468
|
+
const _ = u.children;
|
|
469
|
+
for (let C = 0; C < _.length; C++) {
|
|
470
470
|
const L = t.visibleColumns[C];
|
|
471
|
-
L && L.editable &&
|
|
471
|
+
L && L.editable && O(t, c, b, L, _[C]);
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
474
|
} else {
|
|
475
|
-
const
|
|
476
|
-
if (
|
|
477
|
-
|
|
478
|
-
else if (
|
|
479
|
-
const
|
|
480
|
-
for (let C = 0; C <
|
|
475
|
+
const E = u.querySelector(".cell.editing"), y = t.activeEditRows === b;
|
|
476
|
+
if (E && !y)
|
|
477
|
+
M(t, u, c, b), u.__epoch = n, u.__rowDataRef = c;
|
|
478
|
+
else if (G(t, u, c, b), y && !E) {
|
|
479
|
+
const _ = u.children;
|
|
480
|
+
for (let C = 0; C < _.length; C++) {
|
|
481
481
|
const L = t.visibleColumns[C];
|
|
482
|
-
L && L.editable &&
|
|
482
|
+
L && L.editable && O(t, c, b, L, _[C]);
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
const
|
|
487
|
-
|
|
486
|
+
const g = t._changedRowIndices.has(b), m = u.classList.contains("changed");
|
|
487
|
+
g !== m && u.classList.toggle("changed", g), u.parentNode !== r && r.appendChild(u);
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
|
-
function
|
|
491
|
-
const
|
|
490
|
+
function G(t, e, o, n) {
|
|
491
|
+
const i = e.children, s = t.visibleColumns, r = s.length, l = i.length, a = r < l ? r : l, d = t.focusRow, h = t.focusCol;
|
|
492
492
|
let p = t.__hasSpecialColumns;
|
|
493
493
|
if (p === void 0) {
|
|
494
494
|
p = !1;
|
|
495
495
|
for (let c = 0; c < r; c++) {
|
|
496
|
-
const u =
|
|
496
|
+
const u = s[c];
|
|
497
497
|
if (u.__viewTemplate || u.__compiledView || u.viewRenderer || u.externalView || u.format || u.type === "date" || u.type === "boolean") {
|
|
498
498
|
p = !0;
|
|
499
499
|
break;
|
|
@@ -501,86 +501,86 @@ function F(t, e, o, n) {
|
|
|
501
501
|
}
|
|
502
502
|
t.__hasSpecialColumns = p;
|
|
503
503
|
}
|
|
504
|
-
const
|
|
504
|
+
const b = String(n);
|
|
505
505
|
if (!p) {
|
|
506
506
|
for (let c = 0; c < a; c++) {
|
|
507
|
-
const u =
|
|
508
|
-
u.textContent = f == null ? "" : String(f), u.getAttribute("data-row") !==
|
|
509
|
-
const
|
|
510
|
-
|
|
507
|
+
const u = i[c], f = o[s[c].field];
|
|
508
|
+
u.textContent = f == null ? "" : String(f), u.getAttribute("data-row") !== b && u.setAttribute("data-row", b);
|
|
509
|
+
const w = d === n && h === c, v = u.classList.contains("cell-focus");
|
|
510
|
+
w !== v && (u.classList.toggle("cell-focus", w), u.setAttribute("aria-selected", String(w)));
|
|
511
511
|
}
|
|
512
512
|
return;
|
|
513
513
|
}
|
|
514
514
|
for (let c = 0; c < a; c++)
|
|
515
|
-
if (
|
|
516
|
-
|
|
515
|
+
if (s[c].externalView && !i[c].querySelector("[data-external-view]")) {
|
|
516
|
+
M(t, e, o, n);
|
|
517
517
|
return;
|
|
518
518
|
}
|
|
519
519
|
for (let c = 0; c < a; c++) {
|
|
520
|
-
const u =
|
|
521
|
-
f.getAttribute("data-row") !==
|
|
522
|
-
const
|
|
523
|
-
if (
|
|
520
|
+
const u = s[c], f = i[c];
|
|
521
|
+
f.getAttribute("data-row") !== b && f.setAttribute("data-row", b);
|
|
522
|
+
const w = d === n && h === c, v = f.classList.contains("cell-focus");
|
|
523
|
+
if (w !== v && (f.classList.toggle("cell-focus", w), f.setAttribute("aria-selected", String(w))), f.classList.contains("editing")) continue;
|
|
524
524
|
if (u.viewRenderer) {
|
|
525
|
-
const
|
|
526
|
-
typeof T == "string" ? f.innerHTML =
|
|
525
|
+
const R = o[u.field], T = u.viewRenderer({ row: o, value: R, field: u.field, column: u });
|
|
526
|
+
typeof T == "string" ? f.innerHTML = W(T) : T ? (f.innerHTML = "", f.appendChild(T)) : f.textContent = R == null ? "" : String(R);
|
|
527
527
|
continue;
|
|
528
528
|
}
|
|
529
529
|
if (u.__viewTemplate || u.__compiledView || u.externalView)
|
|
530
530
|
continue;
|
|
531
|
-
const
|
|
532
|
-
let
|
|
531
|
+
const S = o[u.field];
|
|
532
|
+
let x;
|
|
533
533
|
if (u.format)
|
|
534
534
|
try {
|
|
535
|
-
const
|
|
536
|
-
|
|
535
|
+
const R = u.format(S, o);
|
|
536
|
+
x = R == null ? "" : String(R);
|
|
537
537
|
} catch {
|
|
538
|
-
|
|
538
|
+
x = S == null ? "" : String(S);
|
|
539
539
|
}
|
|
540
540
|
else if (u.type === "date") {
|
|
541
|
-
if (
|
|
542
|
-
|
|
543
|
-
else if (
|
|
544
|
-
|
|
541
|
+
if (S == null || S === "")
|
|
542
|
+
x = "";
|
|
543
|
+
else if (S instanceof Date)
|
|
544
|
+
x = isNaN(S.getTime()) ? "" : S.toLocaleDateString();
|
|
545
545
|
else {
|
|
546
|
-
const
|
|
547
|
-
|
|
546
|
+
const R = new Date(S);
|
|
547
|
+
x = isNaN(R.getTime()) ? "" : R.toLocaleDateString();
|
|
548
548
|
}
|
|
549
|
-
f.textContent =
|
|
549
|
+
f.textContent = x;
|
|
550
550
|
} else if (u.type === "boolean") {
|
|
551
|
-
const
|
|
552
|
-
f.innerHTML = `<span role="checkbox" aria-checked="${
|
|
551
|
+
const R = !!S;
|
|
552
|
+
f.innerHTML = `<span role="checkbox" aria-checked="${R}" aria-label="${R}">${R ? "🗹" : "☐"}</span>`;
|
|
553
553
|
} else
|
|
554
|
-
|
|
554
|
+
x = S == null ? "" : String(S), f.textContent = x;
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
|
-
function
|
|
557
|
+
function M(t, e, o, n) {
|
|
558
558
|
e.innerHTML = "";
|
|
559
|
-
const
|
|
560
|
-
for (let p = 0; p <
|
|
561
|
-
const
|
|
562
|
-
c.className = "cell",
|
|
563
|
-
const u =
|
|
559
|
+
const i = t.visibleColumns, s = i.length, r = t.focusRow, l = t.focusCol, a = t.effectiveConfig?.editOn || t.editOn, d = t, h = document.createDocumentFragment();
|
|
560
|
+
for (let p = 0; p < s; p++) {
|
|
561
|
+
const b = i[p], c = document.createElement("div");
|
|
562
|
+
c.className = "cell", U(c, "cell"), c.setAttribute("role", "gridcell"), c.setAttribute("aria-colindex", String(p + 1)), c.setAttribute("data-col", String(p)), c.setAttribute("data-row", String(n)), b.type, b.type && c.setAttribute("data-type", b.type);
|
|
563
|
+
const u = b.sticky;
|
|
564
564
|
u === "left" ? c.classList.add("sticky-left") : u === "right" && c.classList.add("sticky-right");
|
|
565
|
-
let f = o[
|
|
566
|
-
const
|
|
567
|
-
if (
|
|
565
|
+
let f = o[b.field];
|
|
566
|
+
const w = b.format;
|
|
567
|
+
if (w)
|
|
568
568
|
try {
|
|
569
|
-
f =
|
|
569
|
+
f = w(f, o);
|
|
570
570
|
} catch {
|
|
571
571
|
}
|
|
572
|
-
const
|
|
572
|
+
const v = b.__compiledView, S = b.__viewTemplate, x = b.viewRenderer, R = b.externalView;
|
|
573
573
|
let T = !1;
|
|
574
|
-
if (
|
|
575
|
-
const
|
|
576
|
-
typeof
|
|
577
|
-
} else if (
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
const
|
|
581
|
-
if (
|
|
574
|
+
if (x) {
|
|
575
|
+
const g = x({ row: o, value: f, field: b.field, column: b });
|
|
576
|
+
typeof g == "string" ? (c.innerHTML = W(g), T = !0) : g ? c.appendChild(g) : c.textContent = f == null ? "" : String(f);
|
|
577
|
+
} else if (R) {
|
|
578
|
+
const g = R, m = document.createElement("div");
|
|
579
|
+
m.setAttribute("data-external-view", ""), m.setAttribute("data-field", b.field), c.appendChild(m);
|
|
580
|
+
const E = { row: o, value: f, field: b.field, column: b };
|
|
581
|
+
if (g.mount)
|
|
582
582
|
try {
|
|
583
|
-
|
|
583
|
+
g.mount({ placeholder: m, context: E, spec: g });
|
|
584
584
|
} catch {
|
|
585
585
|
}
|
|
586
586
|
else
|
|
@@ -590,74 +590,74 @@ function O(t, e, o, n) {
|
|
|
590
590
|
new CustomEvent("mount-external-view", {
|
|
591
591
|
bubbles: !0,
|
|
592
592
|
composed: !0,
|
|
593
|
-
detail: { placeholder:
|
|
593
|
+
detail: { placeholder: m, spec: g, context: E }
|
|
594
594
|
})
|
|
595
595
|
);
|
|
596
596
|
} catch {
|
|
597
597
|
}
|
|
598
598
|
});
|
|
599
|
-
|
|
600
|
-
} else if (
|
|
601
|
-
const
|
|
602
|
-
c.innerHTML =
|
|
603
|
-
} else if (
|
|
604
|
-
const
|
|
605
|
-
/Reflect\.|\bProxy\b|ownKeys\(/.test(
|
|
606
|
-
} else if (
|
|
599
|
+
m.setAttribute("data-mounted", "");
|
|
600
|
+
} else if (v) {
|
|
601
|
+
const g = v({ row: o, value: f, field: b.field, column: b }), m = v.__blocked;
|
|
602
|
+
c.innerHTML = m ? "" : W(g), T = !0, m && (c.textContent = "", c.setAttribute("data-blocked-template", ""));
|
|
603
|
+
} else if (S) {
|
|
604
|
+
const g = S.innerHTML;
|
|
605
|
+
/Reflect\.|\bProxy\b|ownKeys\(/.test(g) ? (c.textContent = "", c.setAttribute("data-blocked-template", "")) : (c.innerHTML = W(ae(g, { row: o, value: f })), T = !0);
|
|
606
|
+
} else if (b.type === "date")
|
|
607
607
|
if (f == null || f === "")
|
|
608
608
|
c.textContent = "";
|
|
609
609
|
else {
|
|
610
|
-
let
|
|
611
|
-
if (f instanceof Date)
|
|
610
|
+
let g = null;
|
|
611
|
+
if (f instanceof Date) g = f;
|
|
612
612
|
else if (typeof f == "number" || typeof f == "string") {
|
|
613
|
-
const
|
|
614
|
-
isNaN(
|
|
613
|
+
const m = new Date(f);
|
|
614
|
+
isNaN(m.getTime()) || (g = m);
|
|
615
615
|
}
|
|
616
|
-
c.textContent =
|
|
616
|
+
c.textContent = g ? g.toLocaleDateString() : "";
|
|
617
617
|
}
|
|
618
|
-
else if (
|
|
619
|
-
const
|
|
620
|
-
c.innerHTML = `<span role="checkbox" aria-checked="${
|
|
618
|
+
else if (b.type === "boolean") {
|
|
619
|
+
const g = !!f;
|
|
620
|
+
c.innerHTML = `<span role="checkbox" aria-checked="${g}" aria-label="${g}">${g ? "🗹" : "☐"}</span>`;
|
|
621
621
|
} else
|
|
622
622
|
c.textContent = f == null ? "" : String(f);
|
|
623
623
|
if (T) {
|
|
624
|
-
|
|
625
|
-
const
|
|
626
|
-
/Proxy|Reflect\.ownKeys/.test(
|
|
624
|
+
Se(c);
|
|
625
|
+
const g = c.textContent || "";
|
|
626
|
+
/Proxy|Reflect\.ownKeys/.test(g) && (c.textContent = g.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(c.textContent || "") && (c.textContent = ""));
|
|
627
627
|
}
|
|
628
|
-
c.hasAttribute("data-blocked-template") && (c.textContent || "").trim().length && (c.textContent = ""),
|
|
628
|
+
c.hasAttribute("data-blocked-template") && (c.textContent || "").trim().length && (c.textContent = ""), b.editable ? (c.tabIndex = 0, c.addEventListener("mousedown", () => {
|
|
629
629
|
if (c.classList.contains("editing")) return;
|
|
630
|
-
const
|
|
631
|
-
isNaN(
|
|
632
|
-
}), a === "click" ? c.addEventListener("click", (
|
|
630
|
+
const g = Number(c.getAttribute("data-row")), m = Number(c.getAttribute("data-col"));
|
|
631
|
+
isNaN(g) || isNaN(m) || (t.focusRow = g, t.focusCol = m, $(t));
|
|
632
|
+
}), a === "click" ? c.addEventListener("click", (g) => {
|
|
633
633
|
if (c.classList.contains("editing")) return;
|
|
634
|
-
|
|
635
|
-
const
|
|
636
|
-
if (isNaN(
|
|
637
|
-
const
|
|
638
|
-
!
|
|
639
|
-
}) : c.addEventListener("dblclick", (
|
|
640
|
-
|
|
641
|
-
const
|
|
642
|
-
if (isNaN(
|
|
643
|
-
const
|
|
644
|
-
if (!
|
|
645
|
-
|
|
646
|
-
const
|
|
647
|
-
if (
|
|
648
|
-
const
|
|
649
|
-
for (let C = 0; C <
|
|
634
|
+
g.stopPropagation();
|
|
635
|
+
const m = Number(c.getAttribute("data-row")), E = Number(c.getAttribute("data-col"));
|
|
636
|
+
if (isNaN(m) || isNaN(E)) return;
|
|
637
|
+
const y = t._rows[m], _ = t.visibleColumns[E];
|
|
638
|
+
!y || !_ || (t.focusRow = m, t.focusCol = E, O(t, y, m, _, c));
|
|
639
|
+
}) : c.addEventListener("dblclick", (g) => {
|
|
640
|
+
g.stopPropagation();
|
|
641
|
+
const m = Number(c.getAttribute("data-row"));
|
|
642
|
+
if (isNaN(m)) return;
|
|
643
|
+
const E = t._rows[m];
|
|
644
|
+
if (!E) return;
|
|
645
|
+
z(t, m, E);
|
|
646
|
+
const y = t.findRenderedRowElement?.(m);
|
|
647
|
+
if (y) {
|
|
648
|
+
const _ = y.children;
|
|
649
|
+
for (let C = 0; C < _.length; C++) {
|
|
650
650
|
const L = t.visibleColumns[C];
|
|
651
|
-
L && L.editable &&
|
|
651
|
+
L && L.editable && O(t, E, m, L, _[C]);
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
|
-
}), c.addEventListener("keydown", (
|
|
655
|
-
const
|
|
656
|
-
if (isNaN(
|
|
657
|
-
const
|
|
658
|
-
if (!(!
|
|
659
|
-
if ((
|
|
660
|
-
|
|
654
|
+
}), c.addEventListener("keydown", (g) => {
|
|
655
|
+
const m = Number(c.getAttribute("data-row")), E = Number(c.getAttribute("data-col"));
|
|
656
|
+
if (isNaN(m) || isNaN(E)) return;
|
|
657
|
+
const y = t._rows[m], _ = t.visibleColumns[E];
|
|
658
|
+
if (!(!y || !_)) {
|
|
659
|
+
if ((_.type === "select" || _.type === "typeahead") && !c.classList.contains("editing") && g.key === "Enter") {
|
|
660
|
+
g.preventDefault(), t.activeEditRows !== m && z(t, m, y), O(t, y, m, _, c), setTimeout(() => {
|
|
661
661
|
const C = c.querySelector("select");
|
|
662
662
|
try {
|
|
663
663
|
C?.showPicker?.();
|
|
@@ -667,41 +667,41 @@ function O(t, e, o, n) {
|
|
|
667
667
|
}, 0);
|
|
668
668
|
return;
|
|
669
669
|
}
|
|
670
|
-
if (
|
|
671
|
-
|
|
672
|
-
const C = !
|
|
673
|
-
|
|
670
|
+
if (_.type === "boolean" && g.key === " " && !c.classList.contains("editing")) {
|
|
671
|
+
g.preventDefault(), t.activeEditRows !== m && z(t, m, y);
|
|
672
|
+
const C = !y[_.field];
|
|
673
|
+
j(t, m, _, C, y), c.innerHTML = `<span role="checkbox" aria-checked="${C}" aria-label="${C}">${C ? "🗹" : "☐"}</span>`;
|
|
674
674
|
return;
|
|
675
675
|
}
|
|
676
|
-
if (
|
|
677
|
-
|
|
676
|
+
if (g.key === "Enter" && !c.classList.contains("editing")) {
|
|
677
|
+
g.preventDefault(), g.stopPropagation(), t.focusRow = m, t.focusCol = E, typeof t.beginBulkEdit == "function" ? t.beginBulkEdit(m) : O(t, y, m, _, c);
|
|
678
678
|
return;
|
|
679
679
|
}
|
|
680
|
-
if (
|
|
681
|
-
|
|
680
|
+
if (g.key === "F2" && !c.classList.contains("editing")) {
|
|
681
|
+
g.preventDefault(), O(t, y, m, _, c);
|
|
682
682
|
return;
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
|
-
})) :
|
|
685
|
+
})) : b.type === "boolean" && (c.hasAttribute("tabindex") || (c.tabIndex = 0)), r === n && l === p ? c.setAttribute("aria-selected", "true") : c.setAttribute("aria-selected", "false"), h.appendChild(c);
|
|
686
686
|
}
|
|
687
687
|
e.appendChild(h);
|
|
688
688
|
}
|
|
689
|
-
function
|
|
689
|
+
function J(t, e, o, n) {
|
|
690
690
|
if (e.target?.closest(".resize-handle")) return;
|
|
691
|
-
const
|
|
692
|
-
if (!
|
|
693
|
-
const
|
|
694
|
-
if (isNaN(
|
|
695
|
-
const r = t._rows[
|
|
691
|
+
const i = o.querySelector(".cell[data-row]");
|
|
692
|
+
if (!i) return;
|
|
693
|
+
const s = Number(i.getAttribute("data-row"));
|
|
694
|
+
if (isNaN(s)) return;
|
|
695
|
+
const r = t._rows[s];
|
|
696
696
|
if (!r) return;
|
|
697
697
|
const l = e.target?.closest(".cell[data-col]");
|
|
698
698
|
if (l) {
|
|
699
699
|
if (l.classList.contains("editing")) return;
|
|
700
700
|
const d = Number(l.getAttribute("data-col"));
|
|
701
701
|
if (!isNaN(d)) {
|
|
702
|
-
if (t.dispatchCellClick?.(e,
|
|
702
|
+
if (t.dispatchCellClick?.(e, s, d, l))
|
|
703
703
|
return;
|
|
704
|
-
t.focusRow =
|
|
704
|
+
t.focusRow = s, t.focusCol = d, $(t);
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
707
|
if (o.querySelector(".cell.editing")) {
|
|
@@ -710,11 +710,11 @@ function ne(t, e, o, n) {
|
|
|
710
710
|
d.forEach((h) => h.classList.remove("editing"));
|
|
711
711
|
}
|
|
712
712
|
const a = t.effectiveConfig?.editOn || t.editOn || "doubleClick";
|
|
713
|
-
if (a === "click" || a === "doubleClick" && n)
|
|
713
|
+
if (a === "click" || a === "doubleClick" && n) z(t, s, r);
|
|
714
714
|
else return;
|
|
715
715
|
Array.from(o.children).forEach((d, h) => {
|
|
716
716
|
const p = t.visibleColumns[h];
|
|
717
|
-
p && p.editable &&
|
|
717
|
+
p && p.editable && O(t, r, s, p, d);
|
|
718
718
|
}), l && queueMicrotask(() => {
|
|
719
719
|
const d = o.querySelector(`.cell[data-col="${t.focusCol}"]`);
|
|
720
720
|
if (d?.classList.contains("editing")) {
|
|
@@ -728,13 +728,16 @@ function ne(t, e, o, n) {
|
|
|
728
728
|
}
|
|
729
729
|
});
|
|
730
730
|
}
|
|
731
|
-
function
|
|
731
|
+
function de(t) {
|
|
732
|
+
return !(t === "__proto__" || t === "constructor" || t === "prototype");
|
|
733
|
+
}
|
|
734
|
+
function z(t, e, o) {
|
|
732
735
|
t.activeEditRows !== e && (t.rowEditSnapshots.set(e, { ...o }), t.activeEditRows = e);
|
|
733
736
|
}
|
|
734
737
|
function N(t, e, o) {
|
|
735
738
|
if (t.activeEditRows !== e) return;
|
|
736
|
-
const n = t.rowEditSnapshots.get(e),
|
|
737
|
-
if (!o &&
|
|
739
|
+
const n = t.rowEditSnapshots.get(e), i = t._rows[e], s = t.findRenderedRowElement?.(e);
|
|
740
|
+
if (!o && s && i && s.querySelectorAll(".cell.editing").forEach((l) => {
|
|
738
741
|
const a = Number(l.getAttribute("data-col"));
|
|
739
742
|
if (isNaN(a)) return;
|
|
740
743
|
const d = t.visibleColumns[a];
|
|
@@ -742,17 +745,17 @@ function N(t, e, o) {
|
|
|
742
745
|
const h = l.querySelector("input,textarea,select");
|
|
743
746
|
if (h) {
|
|
744
747
|
let p;
|
|
745
|
-
h instanceof HTMLInputElement && h.type === "checkbox" ? p = h.checked : (p = h.value, d.type === "number" && p !== "" && (p = Number(p))),
|
|
748
|
+
h instanceof HTMLInputElement && h.type === "checkbox" ? p = h.checked : (p = h.value, d.type === "number" && p !== "" && (p = Number(p))), i[d.field] !== p && j(t, e, d, p, i);
|
|
746
749
|
}
|
|
747
|
-
}), o && n &&
|
|
748
|
-
Object.keys(n).forEach((r) =>
|
|
750
|
+
}), o && n && i)
|
|
751
|
+
Object.keys(n).forEach((r) => i[r] = n[r]), t._changedRowIndices.delete(e), X(t);
|
|
749
752
|
else if (!o) {
|
|
750
753
|
const r = t._changedRowIndices.has(e);
|
|
751
754
|
t.dispatchEvent(
|
|
752
755
|
new CustomEvent("row-commit", {
|
|
753
756
|
detail: {
|
|
754
757
|
rowIndex: e,
|
|
755
|
-
row:
|
|
758
|
+
row: i,
|
|
756
759
|
changed: r,
|
|
757
760
|
changedRows: t.changedRows,
|
|
758
761
|
changedRowIndices: t.changedRowIndices
|
|
@@ -760,7 +763,7 @@ function N(t, e, o) {
|
|
|
760
763
|
})
|
|
761
764
|
);
|
|
762
765
|
}
|
|
763
|
-
t.rowEditSnapshots.delete(e), t.activeEditRows = -1,
|
|
766
|
+
t.rowEditSnapshots.delete(e), t.activeEditRows = -1, s && (M(t, s, t._rows[e], e), t._changedRowIndices.has(e) ? s.classList.add("changed") : s.classList.remove("changed")), queueMicrotask(() => {
|
|
764
767
|
try {
|
|
765
768
|
const r = t.focusRow, l = t.focusCol, a = t.findRenderedRowElement?.(r);
|
|
766
769
|
if (a) {
|
|
@@ -772,18 +775,18 @@ function N(t, e, o) {
|
|
|
772
775
|
}
|
|
773
776
|
});
|
|
774
777
|
}
|
|
775
|
-
function
|
|
776
|
-
const
|
|
777
|
-
if (s[
|
|
778
|
-
s
|
|
778
|
+
function j(t, e, o, n, i) {
|
|
779
|
+
const s = o.field;
|
|
780
|
+
if (!de(s) || i[s] === n) return;
|
|
781
|
+
i[s] = n;
|
|
779
782
|
const l = !t._changedRowIndices.has(e);
|
|
780
783
|
t._changedRowIndices.add(e);
|
|
781
784
|
const a = t.findRenderedRowElement?.(e);
|
|
782
785
|
a && a.classList.add("changed"), t.dispatchEvent(
|
|
783
786
|
new CustomEvent("cell-commit", {
|
|
784
787
|
detail: {
|
|
785
|
-
row:
|
|
786
|
-
field:
|
|
788
|
+
row: i,
|
|
789
|
+
field: s,
|
|
787
790
|
value: n,
|
|
788
791
|
rowIndex: e,
|
|
789
792
|
changedRows: t.changedRows,
|
|
@@ -793,59 +796,59 @@ function J(t, e, o, n, s) {
|
|
|
793
796
|
})
|
|
794
797
|
);
|
|
795
798
|
}
|
|
796
|
-
function
|
|
797
|
-
if (!n.editable || (t.activeEditRows !== o &&
|
|
798
|
-
const
|
|
799
|
-
|
|
799
|
+
function O(t, e, o, n, i) {
|
|
800
|
+
if (!n.editable || (t.activeEditRows !== o && z(t, o, e), i.classList.contains("editing"))) return;
|
|
801
|
+
const s = e[n.field];
|
|
802
|
+
i.classList.add("editing");
|
|
800
803
|
let r = !1;
|
|
801
804
|
const l = (c) => {
|
|
802
|
-
r || t.activeEditRows === -1 ||
|
|
805
|
+
r || t.activeEditRows === -1 || j(t, o, n, c, e);
|
|
803
806
|
}, a = () => {
|
|
804
|
-
r = !0, e[n.field] =
|
|
805
|
-
const c =
|
|
806
|
-
c && (typeof HTMLInputElement < "u" && c instanceof HTMLInputElement && c.type === "checkbox" ? c.checked = !!
|
|
807
|
+
r = !0, de(n.field) && (e[n.field] = s);
|
|
808
|
+
const c = i.querySelector("input,textarea,select");
|
|
809
|
+
c && (typeof HTMLInputElement < "u" && c instanceof HTMLInputElement && c.type === "checkbox" ? c.checked = !!s : "value" in c && (c.value = s ?? ""));
|
|
807
810
|
}, d = document.createElement("div");
|
|
808
|
-
d.style.display = "contents",
|
|
811
|
+
d.style.display = "contents", i.innerHTML = "", i.appendChild(d), d.addEventListener("keydown", (c) => {
|
|
809
812
|
c.key === "Enter" && (c.stopPropagation(), c.preventDefault(), r = !0, N(t, o, !1)), c.key === "Escape" && (c.stopPropagation(), c.preventDefault(), a(), N(t, o, !0));
|
|
810
813
|
});
|
|
811
|
-
const h = n.__editorTemplate, p = n.editor || (h ? "template" :
|
|
814
|
+
const h = n.__editorTemplate, p = n.editor || (h ? "template" : ke(n)), b = s;
|
|
812
815
|
if (p === "template" && h) {
|
|
813
816
|
const c = h.cloneNode(!0), u = n.__compiledEditor;
|
|
814
|
-
u ? c.innerHTML = u({ row: e, value:
|
|
815
|
-
|
|
816
|
-
const
|
|
817
|
-
return
|
|
817
|
+
u ? c.innerHTML = u({ row: e, value: s, field: n.field, column: n }) : c.querySelectorAll("*").forEach((w) => {
|
|
818
|
+
w.childNodes.length === 1 && w.firstChild?.nodeType === Node.TEXT_NODE && (w.textContent = w.textContent?.replace(/{{\s*value\s*}}/g, s == null ? "" : String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (v, S) => {
|
|
819
|
+
const x = e[S];
|
|
820
|
+
return x == null ? "" : String(x);
|
|
818
821
|
}) || "");
|
|
819
822
|
});
|
|
820
823
|
const f = c.querySelector("input,textarea,select");
|
|
821
824
|
if (f) {
|
|
822
|
-
const
|
|
823
|
-
|
|
824
|
-
const
|
|
825
|
-
l(
|
|
826
|
-
}), f.addEventListener("keydown", (
|
|
827
|
-
if (
|
|
828
|
-
|
|
829
|
-
const
|
|
830
|
-
l(
|
|
825
|
+
const w = typeof HTMLInputElement < "u";
|
|
826
|
+
w && f instanceof HTMLInputElement && f.type === "checkbox" ? f.checked = !!s : "value" in f && (f.value = s ?? ""), f.addEventListener("blur", () => {
|
|
827
|
+
const v = w && f instanceof HTMLInputElement && f.type === "checkbox" ? f.checked : f.value;
|
|
828
|
+
l(v);
|
|
829
|
+
}), f.addEventListener("keydown", (v) => {
|
|
830
|
+
if (v.key === "Enter") {
|
|
831
|
+
v.stopPropagation(), v.preventDefault(), r = !0;
|
|
832
|
+
const S = w && f instanceof HTMLInputElement && f.type === "checkbox" ? f.checked : f.value;
|
|
833
|
+
l(S), N(t, o, !1);
|
|
831
834
|
}
|
|
832
|
-
|
|
833
|
-
}),
|
|
834
|
-
const
|
|
835
|
-
l(
|
|
835
|
+
v.key === "Escape" && (v.stopPropagation(), v.preventDefault(), a(), N(t, o, !0));
|
|
836
|
+
}), w && f instanceof HTMLInputElement && f.type === "checkbox" && f.addEventListener("change", () => {
|
|
837
|
+
const v = f.checked;
|
|
838
|
+
l(v);
|
|
836
839
|
}), setTimeout(() => f.focus(), 0);
|
|
837
840
|
}
|
|
838
841
|
d.appendChild(c);
|
|
839
842
|
} else if (typeof p == "string") {
|
|
840
843
|
const c = document.createElement(p);
|
|
841
|
-
c.value =
|
|
844
|
+
c.value = b, c.addEventListener("change", () => l(c.value)), d.appendChild(c);
|
|
842
845
|
} else if (typeof p == "function") {
|
|
843
|
-
const c = p({ row: e, value:
|
|
846
|
+
const c = p({ row: e, value: b, field: n.field, column: n, commit: l, cancel: a });
|
|
844
847
|
typeof c == "string" ? d.innerHTML = c : d.appendChild(c);
|
|
845
848
|
} else if (p && typeof p == "object") {
|
|
846
849
|
const c = document.createElement("div");
|
|
847
850
|
c.setAttribute("data-external-editor", ""), c.setAttribute("data-field", n.field), d.appendChild(c);
|
|
848
|
-
const u = { row: e, value:
|
|
851
|
+
const u = { row: e, value: b, field: n.field, column: n, commit: l, cancel: a };
|
|
849
852
|
if (p.mount)
|
|
850
853
|
try {
|
|
851
854
|
p.mount({ placeholder: c, context: u, spec: p });
|
|
@@ -857,62 +860,62 @@ function M(t, e, o, n, s) {
|
|
|
857
860
|
);
|
|
858
861
|
}
|
|
859
862
|
}
|
|
860
|
-
function
|
|
861
|
-
!t.sortState || t.sortState.field !== e.field ? (t.sortState || (t.__originalOrder = t._rows.slice()),
|
|
863
|
+
function Q(t, e) {
|
|
864
|
+
!t.sortState || t.sortState.field !== e.field ? (t.sortState || (t.__originalOrder = t._rows.slice()), ee(t, e, 1)) : t.sortState.direction === 1 ? ee(t, e, -1) : (t.sortState = null, t.__rowRenderEpoch++, t.rowPool.forEach((n) => n.__epoch = -1), t._rows = t.__originalOrder.slice(), K(t), t.headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach((n) => {
|
|
862
865
|
n.getAttribute("aria-sort") ? (n.getAttribute("aria-sort") === "ascending" || n.getAttribute("aria-sort") === "descending") && (t.sortState || n.setAttribute("aria-sort", "none")) : n.setAttribute("aria-sort", "none");
|
|
863
866
|
}), t.refreshVirtualWindow(!0), t.dispatchEvent(
|
|
864
867
|
new CustomEvent("sort-change", { detail: { field: e.field, direction: 0 } })
|
|
865
868
|
), t.requestStateChange?.());
|
|
866
869
|
}
|
|
867
|
-
function
|
|
870
|
+
function ee(t, e, o) {
|
|
868
871
|
t.sortState = { field: e.field, direction: o };
|
|
869
|
-
const n = e.sortComparator || ((
|
|
870
|
-
t._rows.sort((
|
|
872
|
+
const n = e.sortComparator || ((i, s) => i == null && s == null ? 0 : i == null ? -1 : s == null || i > s ? 1 : i < s ? -1 : 0);
|
|
873
|
+
t._rows.sort((i, s) => n(i[e.field], s[e.field], i, s) * o), t.__rowRenderEpoch++, t.rowPool.forEach((i) => i.__epoch = -1), K(t), t.refreshVirtualWindow(!0), t.dispatchEvent(
|
|
871
874
|
new CustomEvent("sort-change", { detail: { field: e.field, direction: o } })
|
|
872
875
|
), t.requestStateChange?.();
|
|
873
876
|
}
|
|
874
|
-
function
|
|
877
|
+
function ze(t, e) {
|
|
875
878
|
typeof e == "string" ? t.textContent = e : e instanceof HTMLElement && (t.innerHTML = "", t.appendChild(e.cloneNode(!0)));
|
|
876
879
|
}
|
|
877
|
-
function
|
|
880
|
+
function K(t) {
|
|
878
881
|
t.headerRowEl = t.findHeaderRow();
|
|
879
882
|
const e = t.headerRowEl;
|
|
880
883
|
e.innerHTML = "", t.visibleColumns.forEach((o, n) => {
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
const
|
|
884
|
-
if (
|
|
884
|
+
const i = document.createElement("div");
|
|
885
|
+
i.className = "cell", U(i, "header-cell"), i.setAttribute("role", "columnheader"), i.setAttribute("aria-colindex", String(n + 1)), i.setAttribute("data-field", o.field), i.setAttribute("data-col", String(n)), o.sticky === "left" ? i.classList.add("sticky-left") : o.sticky === "right" && i.classList.add("sticky-right");
|
|
886
|
+
const s = o.__headerTemplate;
|
|
887
|
+
if (s) Array.from(s.childNodes).forEach((r) => i.appendChild(r.cloneNode(!0)));
|
|
885
888
|
else {
|
|
886
889
|
const r = o.header || o.field, l = document.createElement("span");
|
|
887
|
-
l.textContent = r,
|
|
890
|
+
l.textContent = r, i.appendChild(l);
|
|
888
891
|
}
|
|
889
892
|
if (o.sortable) {
|
|
890
|
-
|
|
893
|
+
i.classList.add("sortable"), i.tabIndex = 0;
|
|
891
894
|
const r = document.createElement("span");
|
|
892
|
-
|
|
895
|
+
U(r, "sort-indicator"), r.style.opacity = "0.6";
|
|
893
896
|
const l = t.sortState?.field === o.field ? t.sortState.direction : 0, a = { ...P, ...t.icons }, d = l === 1 ? a.sortAsc : l === -1 ? a.sortDesc : a.sortNone;
|
|
894
|
-
|
|
895
|
-
t.resizeController?.isResizing || t.dispatchHeaderClick?.(h, n,
|
|
896
|
-
}),
|
|
897
|
+
ze(r, d), i.appendChild(r), i.setAttribute("aria-sort", l === 0 ? "none" : l === 1 ? "ascending" : "descending"), i.addEventListener("click", (h) => {
|
|
898
|
+
t.resizeController?.isResizing || t.dispatchHeaderClick?.(h, n, i) || Q(t, o);
|
|
899
|
+
}), i.addEventListener("keydown", (h) => {
|
|
897
900
|
if (h.key === "Enter" || h.key === " ") {
|
|
898
|
-
if (h.preventDefault(), t.dispatchHeaderClick?.(h, n,
|
|
899
|
-
|
|
901
|
+
if (h.preventDefault(), t.dispatchHeaderClick?.(h, n, i)) return;
|
|
902
|
+
Q(t, o);
|
|
900
903
|
}
|
|
901
904
|
});
|
|
902
905
|
}
|
|
903
906
|
if (o.resizable) {
|
|
904
|
-
o.sticky || (
|
|
907
|
+
o.sticky || (i.style.position = "relative");
|
|
905
908
|
const r = document.createElement("div");
|
|
906
909
|
r.className = "resize-handle", r.setAttribute("aria-hidden", "true"), r.addEventListener("mousedown", (l) => {
|
|
907
|
-
l.stopPropagation(), l.preventDefault(), t.resizeController.start(l, n,
|
|
908
|
-
}),
|
|
910
|
+
l.stopPropagation(), l.preventDefault(), t.resizeController.start(l, n, i);
|
|
911
|
+
}), i.appendChild(r);
|
|
909
912
|
}
|
|
910
|
-
e.appendChild(
|
|
913
|
+
e.appendChild(i);
|
|
911
914
|
});
|
|
912
915
|
try {
|
|
913
916
|
const o = t.shadowRoot;
|
|
914
|
-
o && o.querySelectorAll(".header-group-row .cell").forEach((
|
|
915
|
-
|
|
917
|
+
o && o.querySelectorAll(".header-group-row .cell").forEach((i) => {
|
|
918
|
+
i.getAttribute("data-group") && i.classList.add("grouped");
|
|
916
919
|
});
|
|
917
920
|
} catch {
|
|
918
921
|
}
|
|
@@ -920,9 +923,9 @@ function Q(t) {
|
|
|
920
923
|
o.getAttribute("aria-sort") || o.setAttribute("aria-sort", "none");
|
|
921
924
|
}), e.children.length > 0 ? (e.setAttribute("role", "row"), e.setAttribute("aria-rowindex", "1")) : (e.removeAttribute("role"), e.removeAttribute("aria-rowindex"));
|
|
922
925
|
}
|
|
923
|
-
function
|
|
924
|
-
let e = null, o = null, n = null,
|
|
925
|
-
const
|
|
926
|
+
function De(t) {
|
|
927
|
+
let e = null, o = null, n = null, i = null;
|
|
928
|
+
const s = (a) => {
|
|
926
929
|
if (!e) return;
|
|
927
930
|
const d = a.clientX - e.startX, h = Math.max(40, e.startWidth + d), p = t.visibleColumns[e.colIndex];
|
|
928
931
|
p.width = h, p.__userResized = !0, p.__renderedWidth = h, o == null && (o = requestAnimationFrame(() => {
|
|
@@ -936,7 +939,7 @@ function Ge(t) {
|
|
|
936
939
|
const a = e !== null;
|
|
937
940
|
a && (r = !0, requestAnimationFrame(() => {
|
|
938
941
|
r = !1;
|
|
939
|
-
})), window.removeEventListener("mousemove",
|
|
942
|
+
})), window.removeEventListener("mousemove", s), window.removeEventListener("mouseup", l), n !== null && (document.documentElement.style.cursor = n, n = null), i !== null && (document.body.style.userSelect = i, i = null), e = null, a && t.requestStateChange && t.requestStateChange();
|
|
940
943
|
};
|
|
941
944
|
return {
|
|
942
945
|
get isResizing() {
|
|
@@ -945,17 +948,17 @@ function Ge(t) {
|
|
|
945
948
|
start(a, d, h) {
|
|
946
949
|
a.preventDefault();
|
|
947
950
|
const p = h.getBoundingClientRect();
|
|
948
|
-
e = { startX: a.clientX, colIndex: d, startWidth: p.width }, window.addEventListener("mousemove",
|
|
951
|
+
e = { startX: a.clientX, colIndex: d, startWidth: p.width }, window.addEventListener("mousemove", s), window.addEventListener("mouseup", l), n === null && (n = document.documentElement.style.cursor), document.documentElement.style.cursor = "e-resize", i === null && (i = document.body.style.userSelect), document.body.style.userSelect = "none";
|
|
949
952
|
},
|
|
950
953
|
dispose() {
|
|
951
954
|
l();
|
|
952
955
|
}
|
|
953
956
|
};
|
|
954
957
|
}
|
|
955
|
-
function
|
|
958
|
+
function B(t) {
|
|
956
959
|
return t ? typeof t == "string" ? t : t.outerHTML : "";
|
|
957
960
|
}
|
|
958
|
-
function
|
|
961
|
+
function Ne() {
|
|
959
962
|
return {
|
|
960
963
|
toolPanels: /* @__PURE__ */ new Map(),
|
|
961
964
|
headerContents: /* @__PURE__ */ new Map(),
|
|
@@ -972,27 +975,27 @@ function Ue() {
|
|
|
972
975
|
activePanelCleanup: null
|
|
973
976
|
};
|
|
974
977
|
}
|
|
975
|
-
function
|
|
978
|
+
function qe(t, e) {
|
|
976
979
|
return !!(t?.header?.title || t?.header?.toolbarButtons?.length || e.toolPanels.size > 0 || e.headerContents.size > 0 || e.toolbarButtons.size > 0 || e.lightDomButtons.length > 0 || e.lightDomHeaderContent.length > 0);
|
|
977
980
|
}
|
|
978
|
-
function
|
|
979
|
-
const n = t?.header?.title ?? "",
|
|
981
|
+
function $e(t, e, o = "☰") {
|
|
982
|
+
const n = t?.header?.title ?? "", i = !!n, s = B(o), r = t?.header?.toolbarButtons ?? [], l = r.length > 0, a = e.toolbarButtons.size > 0, d = e.lightDomButtons.length > 0, h = e.toolPanels.size > 0, b = (l || a || d) && h, c = [...r].sort((w, v) => (w.order ?? 100) - (v.order ?? 100)), u = [...e.toolbarButtons.values()].sort((w, v) => (w.order ?? 100) - (v.order ?? 100));
|
|
980
983
|
let f = "";
|
|
981
|
-
for (const
|
|
982
|
-
|
|
983
|
-
for (const
|
|
984
|
-
|
|
985
|
-
for (const
|
|
986
|
-
(
|
|
987
|
-
for (const
|
|
988
|
-
(
|
|
989
|
-
if (d && (f += '<slot name="toolbar"></slot>'),
|
|
990
|
-
const
|
|
991
|
-
f += `<button class="tbw-toolbar-btn${
|
|
984
|
+
for (const w of c)
|
|
985
|
+
w.icon && w.action && (f += `<button class="tbw-toolbar-btn" data-btn="${w.id}" title="${w.label}" aria-label="${w.label}"${w.disabled ? " disabled" : ""}>${w.icon}</button>`);
|
|
986
|
+
for (const w of u)
|
|
987
|
+
w.icon && w.action && (f += `<button class="tbw-toolbar-btn" data-btn="${w.id}" title="${w.label}" aria-label="${w.label}"${w.disabled ? " disabled" : ""}>${w.icon}</button>`);
|
|
988
|
+
for (const w of c)
|
|
989
|
+
(w.element || w.render) && (f += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${w.id}"></div>`);
|
|
990
|
+
for (const w of u)
|
|
991
|
+
(w.element || w.render) && (f += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${w.id}"></div>`);
|
|
992
|
+
if (d && (f += '<slot name="toolbar"></slot>'), b && (f += '<div class="tbw-toolbar-separator"></div>'), h) {
|
|
993
|
+
const w = e.isPanelOpen;
|
|
994
|
+
f += `<button class="tbw-toolbar-btn${w ? " active" : ""}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${w}" aria-controls="tbw-tool-panel">${s}</button>`;
|
|
992
995
|
}
|
|
993
996
|
return `
|
|
994
997
|
<div class="tbw-shell-header" part="shell-header" role="presentation">
|
|
995
|
-
${
|
|
998
|
+
${i ? `<div class="tbw-shell-title">${n}</div>` : ""}
|
|
996
999
|
<div class="tbw-shell-content" part="shell-content" role="presentation">
|
|
997
1000
|
<slot name="header-content"></slot>
|
|
998
1001
|
</div>
|
|
@@ -1002,25 +1005,25 @@ function je(t, e, o = "☰") {
|
|
|
1002
1005
|
</div>
|
|
1003
1006
|
`;
|
|
1004
1007
|
}
|
|
1005
|
-
function
|
|
1006
|
-
const
|
|
1008
|
+
function Ie(t, e, o, n) {
|
|
1009
|
+
const i = t?.toolPanel?.position ?? "right", s = e.toolPanels.size > 0, r = e.isPanelOpen, l = B(n?.expand ?? P.expand), a = B(n?.collapse ?? P.collapse), d = [...e.toolPanels.values()].sort((u, f) => (u.order ?? 100) - (f.order ?? 100)), h = d.length === 1;
|
|
1007
1010
|
let p = "";
|
|
1008
1011
|
for (const u of d) {
|
|
1009
|
-
const f = e.expandedSections.has(u.id),
|
|
1012
|
+
const f = e.expandedSections.has(u.id), w = u.icon ? `<span class="tbw-accordion-icon">${u.icon}</span>` : "", v = h ? "" : `<span class="tbw-accordion-chevron">${f ? a : l}</span>`;
|
|
1010
1013
|
p += `
|
|
1011
1014
|
<div class="${`tbw-accordion-section${f ? " expanded" : ""}${h ? " single" : ""}`}" data-section="${u.id}">
|
|
1012
1015
|
<button class="tbw-accordion-header" aria-expanded="${f}" aria-controls="tbw-section-${u.id}"${h ? ' aria-disabled="true"' : ""}>
|
|
1013
|
-
${
|
|
1016
|
+
${w}
|
|
1014
1017
|
<span class="tbw-accordion-title">${u.title}</span>
|
|
1015
|
-
${
|
|
1018
|
+
${v}
|
|
1016
1019
|
</button>
|
|
1017
1020
|
<div class="tbw-accordion-content" id="tbw-section-${u.id}" role="presentation"></div>
|
|
1018
1021
|
</div>
|
|
1019
1022
|
`;
|
|
1020
1023
|
}
|
|
1021
|
-
const c =
|
|
1022
|
-
<aside class="tbw-tool-panel${r ? " open" : ""}" part="tool-panel" data-position="${
|
|
1023
|
-
<div class="tbw-tool-panel-resize" data-resize-handle data-handle-position="${
|
|
1024
|
+
const c = s ? `
|
|
1025
|
+
<aside class="tbw-tool-panel${r ? " open" : ""}" part="tool-panel" data-position="${i}" role="presentation" id="tbw-tool-panel">
|
|
1026
|
+
<div class="tbw-tool-panel-resize" data-resize-handle data-handle-position="${i === "left" ? "right" : "left"}" aria-hidden="true"></div>
|
|
1024
1027
|
<div class="tbw-tool-panel-content" role="presentation">
|
|
1025
1028
|
<div class="tbw-accordion">
|
|
1026
1029
|
${p}
|
|
@@ -1028,7 +1031,7 @@ function Ye(t, e, o, n) {
|
|
|
1028
1031
|
</div>
|
|
1029
1032
|
</aside>
|
|
1030
1033
|
` : "";
|
|
1031
|
-
return
|
|
1034
|
+
return i === "left" ? `
|
|
1032
1035
|
<div class="tbw-shell-body">
|
|
1033
1036
|
${c}
|
|
1034
1037
|
<div class="tbw-grid-content">
|
|
@@ -1044,25 +1047,25 @@ function Ye(t, e, o, n) {
|
|
|
1044
1047
|
</div>
|
|
1045
1048
|
`;
|
|
1046
1049
|
}
|
|
1047
|
-
function
|
|
1050
|
+
function te(t, e) {
|
|
1048
1051
|
const o = t.querySelector("tbw-grid-header");
|
|
1049
1052
|
if (!o) return;
|
|
1050
1053
|
o.style.display = "none";
|
|
1051
1054
|
const n = o.querySelectorAll("tbw-grid-header-content");
|
|
1052
|
-
e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((
|
|
1053
|
-
|
|
1055
|
+
e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((s) => {
|
|
1056
|
+
s.setAttribute("slot", "header-content");
|
|
1054
1057
|
});
|
|
1055
|
-
const
|
|
1056
|
-
e.lightDomButtons = Array.from(
|
|
1057
|
-
const l = parseInt(
|
|
1058
|
+
const i = o.querySelectorAll("tbw-grid-tool-button");
|
|
1059
|
+
e.lightDomButtons = Array.from(i), e.lightDomButtons.sort((s, r) => {
|
|
1060
|
+
const l = parseInt(s.getAttribute("order") ?? "100", 10), a = parseInt(r.getAttribute("order") ?? "100", 10);
|
|
1058
1061
|
return l - a;
|
|
1059
|
-
}), e.lightDomButtons.forEach((
|
|
1060
|
-
|
|
1062
|
+
}), e.lightDomButtons.forEach((s) => {
|
|
1063
|
+
s.setAttribute("slot", "toolbar");
|
|
1061
1064
|
});
|
|
1062
1065
|
}
|
|
1063
|
-
function
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1066
|
+
function Be(t, e, o, n) {
|
|
1067
|
+
const i = t.querySelector(".tbw-shell-toolbar");
|
|
1068
|
+
i && i.addEventListener("click", (r) => {
|
|
1066
1069
|
const l = r.target;
|
|
1067
1070
|
if (l.closest("[data-panel-toggle]")) {
|
|
1068
1071
|
n.onPanelToggle();
|
|
@@ -1074,8 +1077,8 @@ function Ze(t, e, o, n) {
|
|
|
1074
1077
|
h && n.onToolbarButtonClick(h);
|
|
1075
1078
|
}
|
|
1076
1079
|
});
|
|
1077
|
-
const
|
|
1078
|
-
|
|
1080
|
+
const s = t.querySelector(".tbw-accordion");
|
|
1081
|
+
s && s.addEventListener("click", (r) => {
|
|
1079
1082
|
const a = r.target.closest(".tbw-accordion-header");
|
|
1080
1083
|
if (a) {
|
|
1081
1084
|
const h = a.closest("[data-section]")?.getAttribute("data-section");
|
|
@@ -1083,87 +1086,87 @@ function Ze(t, e, o, n) {
|
|
|
1083
1086
|
}
|
|
1084
1087
|
});
|
|
1085
1088
|
}
|
|
1086
|
-
function
|
|
1087
|
-
const n = t.querySelector(".tbw-tool-panel"),
|
|
1088
|
-
if (!n || !
|
|
1089
|
+
function Ve(t, e, o) {
|
|
1090
|
+
const n = t.querySelector(".tbw-tool-panel"), i = t.querySelector("[data-resize-handle]"), s = t.querySelector(".tbw-shell-body");
|
|
1091
|
+
if (!n || !i || !s)
|
|
1089
1092
|
return () => {
|
|
1090
1093
|
};
|
|
1091
1094
|
const r = e?.toolPanel?.position ?? "right", l = 200;
|
|
1092
1095
|
let a = 0, d = 0, h = 0, p = !1;
|
|
1093
|
-
const
|
|
1096
|
+
const b = (f) => {
|
|
1094
1097
|
if (!p) return;
|
|
1095
1098
|
f.preventDefault();
|
|
1096
|
-
const
|
|
1097
|
-
n.style.width = `${
|
|
1099
|
+
const w = r === "left" ? f.clientX - a : a - f.clientX, v = Math.min(h, Math.max(l, d + w));
|
|
1100
|
+
n.style.width = `${v}px`;
|
|
1098
1101
|
}, c = () => {
|
|
1099
1102
|
if (!p) return;
|
|
1100
|
-
p = !1,
|
|
1103
|
+
p = !1, i.classList.remove("resizing"), n.style.transition = "", document.body.style.cursor = "", document.body.style.userSelect = "";
|
|
1101
1104
|
const f = n.getBoundingClientRect().width;
|
|
1102
|
-
o(f), document.removeEventListener("mousemove",
|
|
1105
|
+
o(f), document.removeEventListener("mousemove", b), document.removeEventListener("mouseup", c);
|
|
1103
1106
|
}, u = (f) => {
|
|
1104
|
-
f.preventDefault(), p = !0, a = f.clientX, d = n.getBoundingClientRect().width, h =
|
|
1107
|
+
f.preventDefault(), p = !0, a = f.clientX, d = n.getBoundingClientRect().width, h = s.getBoundingClientRect().width - 20, i.classList.add("resizing"), n.style.transition = "none", document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", b), document.addEventListener("mouseup", c);
|
|
1105
1108
|
};
|
|
1106
|
-
return
|
|
1107
|
-
|
|
1109
|
+
return i.addEventListener("mousedown", u), () => {
|
|
1110
|
+
i.removeEventListener("mousedown", u), document.removeEventListener("mousemove", b), document.removeEventListener("mouseup", c);
|
|
1108
1111
|
};
|
|
1109
1112
|
}
|
|
1110
|
-
function
|
|
1113
|
+
function We(t, e, o) {
|
|
1111
1114
|
const n = [...e?.header?.toolbarButtons ?? [], ...o.toolbarButtons.values()];
|
|
1112
|
-
for (const
|
|
1113
|
-
const
|
|
1114
|
-
if (!
|
|
1115
|
-
const r = o.toolbarButtonCleanups.get(
|
|
1116
|
-
if (r && (r(), o.toolbarButtonCleanups.delete(
|
|
1117
|
-
|
|
1118
|
-
else if (
|
|
1119
|
-
const l =
|
|
1120
|
-
l && o.toolbarButtonCleanups.set(
|
|
1115
|
+
for (const i of n) {
|
|
1116
|
+
const s = t.querySelector(`[data-btn-slot="${i.id}"]`);
|
|
1117
|
+
if (!s) continue;
|
|
1118
|
+
const r = o.toolbarButtonCleanups.get(i.id);
|
|
1119
|
+
if (r && (r(), o.toolbarButtonCleanups.delete(i.id)), i.element)
|
|
1120
|
+
s.appendChild(i.element);
|
|
1121
|
+
else if (i.render) {
|
|
1122
|
+
const l = i.render(s);
|
|
1123
|
+
l && o.toolbarButtonCleanups.set(i.id, l);
|
|
1121
1124
|
}
|
|
1122
1125
|
}
|
|
1123
1126
|
}
|
|
1124
|
-
function
|
|
1127
|
+
function oe(t, e) {
|
|
1125
1128
|
const o = t.querySelector(".tbw-shell-content");
|
|
1126
1129
|
if (!o) return;
|
|
1127
|
-
const n = [...e.headerContents.values()].sort((
|
|
1128
|
-
for (const
|
|
1129
|
-
const r = e.headerContentCleanups.get(
|
|
1130
|
-
r && (r(), e.headerContentCleanups.delete(
|
|
1131
|
-
let l = o.querySelector(`[data-header-content="${
|
|
1132
|
-
l || (l = document.createElement("div"), l.setAttribute("data-header-content",
|
|
1133
|
-
const a =
|
|
1134
|
-
a && e.headerContentCleanups.set(
|
|
1130
|
+
const n = [...e.headerContents.values()].sort((s, r) => (s.order ?? 100) - (r.order ?? 100)), i = o.querySelector('slot[name="header-content"]');
|
|
1131
|
+
for (const s of n) {
|
|
1132
|
+
const r = e.headerContentCleanups.get(s.id);
|
|
1133
|
+
r && (r(), e.headerContentCleanups.delete(s.id));
|
|
1134
|
+
let l = o.querySelector(`[data-header-content="${s.id}"]`);
|
|
1135
|
+
l || (l = document.createElement("div"), l.setAttribute("data-header-content", s.id), i ? o.insertBefore(l, i) : o.appendChild(l));
|
|
1136
|
+
const a = s.render(l);
|
|
1137
|
+
a && e.headerContentCleanups.set(s.id, a);
|
|
1135
1138
|
}
|
|
1136
1139
|
}
|
|
1137
|
-
function
|
|
1140
|
+
function Ge(t, e, o) {
|
|
1138
1141
|
if (!e.isPanelOpen) return;
|
|
1139
|
-
const n =
|
|
1140
|
-
for (const [
|
|
1141
|
-
const l = e.expandedSections.has(
|
|
1142
|
+
const n = B(o?.expand ?? P.expand), i = B(o?.collapse ?? P.collapse);
|
|
1143
|
+
for (const [s, r] of e.toolPanels) {
|
|
1144
|
+
const l = e.expandedSections.has(s), a = t.querySelector(`[data-section="${s}"]`), d = a?.querySelector(".tbw-accordion-content");
|
|
1142
1145
|
if (!a || !d) continue;
|
|
1143
1146
|
a.classList.toggle("expanded", l);
|
|
1144
1147
|
const h = a.querySelector(".tbw-accordion-header");
|
|
1145
1148
|
h && h.setAttribute("aria-expanded", String(l));
|
|
1146
1149
|
const p = a.querySelector(".tbw-accordion-chevron");
|
|
1147
|
-
if (p && (p.innerHTML = l ?
|
|
1150
|
+
if (p && (p.innerHTML = l ? i : n), l) {
|
|
1148
1151
|
if (d.children.length === 0) {
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1152
|
+
const b = r.render(d);
|
|
1153
|
+
b && e.panelCleanups.set(s, b);
|
|
1151
1154
|
}
|
|
1152
1155
|
} else {
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1156
|
+
const b = e.panelCleanups.get(s);
|
|
1157
|
+
b && (b(), e.panelCleanups.delete(s)), d.innerHTML = "";
|
|
1155
1158
|
}
|
|
1156
1159
|
}
|
|
1157
1160
|
}
|
|
1158
|
-
function
|
|
1161
|
+
function ne(t, e) {
|
|
1159
1162
|
const o = t.querySelector("[data-panel-toggle]");
|
|
1160
1163
|
o && (o.classList.toggle("active", e.isPanelOpen), o.setAttribute("aria-pressed", String(e.isPanelOpen)));
|
|
1161
1164
|
}
|
|
1162
|
-
function
|
|
1165
|
+
function ie(t, e) {
|
|
1163
1166
|
const o = t.querySelector(".tbw-tool-panel");
|
|
1164
1167
|
o && (o.classList.toggle("open", e.isPanelOpen), e.isPanelOpen || (o.style.width = ""));
|
|
1165
1168
|
}
|
|
1166
|
-
function
|
|
1169
|
+
function Fe(t, e) {
|
|
1167
1170
|
const o = [];
|
|
1168
1171
|
for (const n of t?.header?.toolbarButtons ?? [])
|
|
1169
1172
|
o.push({
|
|
@@ -1180,11 +1183,11 @@ function tt(t, e) {
|
|
|
1180
1183
|
source: "config"
|
|
1181
1184
|
});
|
|
1182
1185
|
for (let n = 0; n < e.lightDomButtons.length; n++) {
|
|
1183
|
-
const
|
|
1186
|
+
const s = e.lightDomButtons[n].querySelector("button");
|
|
1184
1187
|
o.push({
|
|
1185
1188
|
id: `light-dom-${n}`,
|
|
1186
|
-
label:
|
|
1187
|
-
disabled:
|
|
1189
|
+
label: s?.getAttribute("title") ?? s?.getAttribute("aria-label") ?? "",
|
|
1190
|
+
disabled: s?.disabled ?? !1,
|
|
1188
1191
|
source: "light-dom"
|
|
1189
1192
|
});
|
|
1190
1193
|
}
|
|
@@ -1198,7 +1201,7 @@ function tt(t, e) {
|
|
|
1198
1201
|
});
|
|
1199
1202
|
return o;
|
|
1200
1203
|
}
|
|
1201
|
-
function
|
|
1204
|
+
function Ue(t) {
|
|
1202
1205
|
for (const e of t.headerContentCleanups.values())
|
|
1203
1206
|
e();
|
|
1204
1207
|
t.headerContentCleanups.clear(), t.activePanelCleanup && (t.activePanelCleanup(), t.activePanelCleanup = null);
|
|
@@ -1206,7 +1209,7 @@ function ot(t) {
|
|
|
1206
1209
|
e();
|
|
1207
1210
|
t.toolbarButtonCleanups.clear(), t.activePanel && t.toolPanels.get(t.activePanel)?.onClose?.(), t.toolPanels.clear(), t.headerContents.clear(), t.toolbarButtons.clear(), t.lightDomButtons = [], t.lightDomHeaderContent = [], t.activePanel = null;
|
|
1208
1211
|
}
|
|
1209
|
-
class
|
|
1212
|
+
class Xe {
|
|
1210
1213
|
constructor(e) {
|
|
1211
1214
|
this.grid = e;
|
|
1212
1215
|
}
|
|
@@ -1299,7 +1302,7 @@ class nt {
|
|
|
1299
1302
|
return this.plugins.filter((e) => e.styles).map((e) => e.styles).join(`
|
|
1300
1303
|
`);
|
|
1301
1304
|
}
|
|
1302
|
-
//
|
|
1305
|
+
// #region Hook execution methods
|
|
1303
1306
|
/**
|
|
1304
1307
|
* Execute processRows hook on all plugins.
|
|
1305
1308
|
*/
|
|
@@ -1365,21 +1368,21 @@ class nt {
|
|
|
1365
1368
|
* Returns the minimum start index from all plugins.
|
|
1366
1369
|
*/
|
|
1367
1370
|
adjustVirtualStart(e, o, n) {
|
|
1368
|
-
let
|
|
1369
|
-
for (const
|
|
1370
|
-
if (typeof
|
|
1371
|
-
const r =
|
|
1372
|
-
r <
|
|
1371
|
+
let i = e;
|
|
1372
|
+
for (const s of this.plugins)
|
|
1373
|
+
if (typeof s.adjustVirtualStart == "function") {
|
|
1374
|
+
const r = s.adjustVirtualStart(e, o, n);
|
|
1375
|
+
r < i && (i = r);
|
|
1373
1376
|
}
|
|
1374
|
-
return
|
|
1377
|
+
return i;
|
|
1375
1378
|
}
|
|
1376
1379
|
/**
|
|
1377
1380
|
* Execute renderRow hook on all plugins.
|
|
1378
1381
|
* Returns true if any plugin handled the row.
|
|
1379
1382
|
*/
|
|
1380
1383
|
renderRow(e, o, n) {
|
|
1381
|
-
for (const
|
|
1382
|
-
if (
|
|
1384
|
+
for (const i of this.plugins)
|
|
1385
|
+
if (i.renderRow?.(e, o, n))
|
|
1383
1386
|
return !0;
|
|
1384
1387
|
return !1;
|
|
1385
1388
|
}
|
|
@@ -1466,12 +1469,13 @@ class nt {
|
|
|
1466
1469
|
getContextMenuItems(e) {
|
|
1467
1470
|
const o = [];
|
|
1468
1471
|
for (const n of this.plugins) {
|
|
1469
|
-
const
|
|
1470
|
-
|
|
1472
|
+
const i = n.getContextMenuItems?.(e);
|
|
1473
|
+
i && o.push(...i);
|
|
1471
1474
|
}
|
|
1472
1475
|
return o;
|
|
1473
1476
|
}
|
|
1474
|
-
//
|
|
1477
|
+
// #endregion
|
|
1478
|
+
// #region Shell Integration Hooks
|
|
1475
1479
|
/**
|
|
1476
1480
|
* Collect tool panels from all plugins.
|
|
1477
1481
|
* Returns panels sorted by order (ascending).
|
|
@@ -1496,72 +1500,77 @@ class nt {
|
|
|
1496
1500
|
}
|
|
1497
1501
|
return e.sort((o, n) => (o.content.order ?? 0) - (n.content.order ?? 0));
|
|
1498
1502
|
}
|
|
1503
|
+
// #endregion
|
|
1499
1504
|
}
|
|
1500
|
-
class
|
|
1505
|
+
class I extends HTMLElement {
|
|
1501
1506
|
// TODO: Rename to 'data-grid' when migration is complete
|
|
1502
1507
|
static tagName = "tbw-grid";
|
|
1503
|
-
|
|
1504
|
-
#
|
|
1508
|
+
static version = "0.2.2";
|
|
1509
|
+
#n;
|
|
1510
|
+
#k = !1;
|
|
1505
1511
|
// ---------------- Ready Promise ----------------
|
|
1506
|
-
#I;
|
|
1507
1512
|
#$;
|
|
1508
|
-
|
|
1513
|
+
#I;
|
|
1514
|
+
// #region Input Properties
|
|
1509
1515
|
// These backing fields store raw user input. They are merged into
|
|
1510
1516
|
// #effectiveConfig by #mergeEffectiveConfig(). Never read directly
|
|
1511
1517
|
// for rendering logic - always use effectiveConfig or derived state.
|
|
1512
|
-
#
|
|
1513
|
-
#
|
|
1514
|
-
#
|
|
1518
|
+
#s = [];
|
|
1519
|
+
#r;
|
|
1520
|
+
#p;
|
|
1521
|
+
#m;
|
|
1515
1522
|
#v;
|
|
1516
|
-
#
|
|
1517
|
-
//
|
|
1523
|
+
// #endregion
|
|
1524
|
+
// #region Single Source of Truth
|
|
1518
1525
|
// All input sources converge here. This is the canonical config
|
|
1519
1526
|
// that all rendering and logic should read from.
|
|
1520
|
-
#
|
|
1521
|
-
#
|
|
1522
|
-
#
|
|
1523
|
-
#
|
|
1524
|
-
#
|
|
1527
|
+
#o = {};
|
|
1528
|
+
#h = !1;
|
|
1529
|
+
#f = 0;
|
|
1530
|
+
#E = null;
|
|
1531
|
+
#C = !1;
|
|
1525
1532
|
// Cached flag for plugin scroll handlers
|
|
1526
1533
|
#P;
|
|
1527
1534
|
// Cached hook to avoid closures
|
|
1528
|
-
#
|
|
1535
|
+
#y = !1;
|
|
1529
1536
|
#_ = null;
|
|
1530
|
-
#
|
|
1531
|
-
#A = null;
|
|
1537
|
+
#R = null;
|
|
1532
1538
|
#S = null;
|
|
1533
|
-
#
|
|
1534
|
-
#
|
|
1539
|
+
#x = null;
|
|
1540
|
+
#l;
|
|
1541
|
+
#b;
|
|
1535
1542
|
// ---------------- Plugin System ----------------
|
|
1536
|
-
#
|
|
1543
|
+
#t;
|
|
1537
1544
|
// ---------------- Column State ----------------
|
|
1538
|
-
#
|
|
1539
|
-
#
|
|
1545
|
+
#O;
|
|
1546
|
+
#d;
|
|
1540
1547
|
// ---------------- Shell State ----------------
|
|
1541
|
-
#e =
|
|
1542
|
-
#
|
|
1543
|
-
#
|
|
1544
|
-
//
|
|
1548
|
+
#e = Ne();
|
|
1549
|
+
#a = !1;
|
|
1550
|
+
#A;
|
|
1551
|
+
// #endregion
|
|
1552
|
+
// #region Derived State
|
|
1545
1553
|
// _rows: result of applying plugin processRows hooks
|
|
1546
1554
|
_rows = [];
|
|
1547
1555
|
// _baseColumns: columns before plugin transformation (analogous to #rows for row processing)
|
|
1548
1556
|
// This is the source of truth for processColumns - plugins transform these
|
|
1549
|
-
#
|
|
1557
|
+
#H = [];
|
|
1550
1558
|
// _columns is a getter/setter that operates on effectiveConfig.columns
|
|
1551
1559
|
// This ensures effectiveConfig.columns is the single source of truth for columns
|
|
1552
1560
|
// _columns always contains ALL columns (including hidden)
|
|
1553
1561
|
get _columns() {
|
|
1554
|
-
return this.#
|
|
1562
|
+
return this.#o.columns ?? [];
|
|
1555
1563
|
}
|
|
1556
1564
|
set _columns(e) {
|
|
1557
|
-
this.#
|
|
1565
|
+
this.#o.columns = e;
|
|
1558
1566
|
}
|
|
1559
1567
|
// visibleColumns returns only visible columns for rendering
|
|
1560
1568
|
// This is what header/row rendering should use
|
|
1561
1569
|
get visibleColumns() {
|
|
1562
1570
|
return this._columns.filter((e) => !e.hidden);
|
|
1563
1571
|
}
|
|
1564
|
-
//
|
|
1572
|
+
// #endregion
|
|
1573
|
+
// #region Runtime State
|
|
1565
1574
|
// User-driven state changes at runtime (sort, etc.)
|
|
1566
1575
|
// Visibility is stored in effectiveConfig.columns[].hidden
|
|
1567
1576
|
rowPool = [];
|
|
@@ -1595,6 +1604,7 @@ class V extends HTMLElement {
|
|
|
1595
1604
|
gridTemplate = "";
|
|
1596
1605
|
rowEditSnapshots = /* @__PURE__ */ new Map();
|
|
1597
1606
|
_changedRowIndices = /* @__PURE__ */ new Set();
|
|
1607
|
+
// #endregion
|
|
1598
1608
|
// ---------------- Public API Props (getters/setters) ----------------
|
|
1599
1609
|
// Getters return the EFFECTIVE value (after merging), not the raw input.
|
|
1600
1610
|
// This is what consumers and plugins need - the current resolved state.
|
|
@@ -1603,49 +1613,49 @@ class V extends HTMLElement {
|
|
|
1603
1613
|
return this._rows;
|
|
1604
1614
|
}
|
|
1605
1615
|
set rows(e) {
|
|
1606
|
-
const o = this.#
|
|
1607
|
-
this.#
|
|
1616
|
+
const o = this.#s;
|
|
1617
|
+
this.#s = e, o !== e && this.#ee();
|
|
1608
1618
|
}
|
|
1609
1619
|
/**
|
|
1610
1620
|
* Get the original unfiltered/unprocessed rows.
|
|
1611
1621
|
* Use this when you need access to all source data regardless of active filters.
|
|
1612
1622
|
*/
|
|
1613
1623
|
get sourceRows() {
|
|
1614
|
-
return this.#
|
|
1624
|
+
return this.#s;
|
|
1615
1625
|
}
|
|
1616
1626
|
get columns() {
|
|
1617
1627
|
return [...this._columns];
|
|
1618
1628
|
}
|
|
1619
1629
|
set columns(e) {
|
|
1620
|
-
const o = this.#
|
|
1621
|
-
this.#
|
|
1630
|
+
const o = this.#r;
|
|
1631
|
+
this.#r = e, o !== e && this.#te();
|
|
1622
1632
|
}
|
|
1623
1633
|
get gridConfig() {
|
|
1624
|
-
return this.#
|
|
1634
|
+
return this.#o;
|
|
1625
1635
|
}
|
|
1626
1636
|
set gridConfig(e) {
|
|
1627
|
-
const o = this.#
|
|
1628
|
-
this.#
|
|
1637
|
+
const o = this.#p;
|
|
1638
|
+
this.#p = e, o !== e && this.#oe();
|
|
1629
1639
|
}
|
|
1630
1640
|
get fitMode() {
|
|
1631
|
-
return this.#
|
|
1641
|
+
return this.#o.fitMode ?? "stretch";
|
|
1632
1642
|
}
|
|
1633
1643
|
set fitMode(e) {
|
|
1634
|
-
const o = this.#
|
|
1635
|
-
this.#
|
|
1644
|
+
const o = this.#m;
|
|
1645
|
+
this.#m = e, o !== e && this.#J();
|
|
1636
1646
|
}
|
|
1637
1647
|
get editOn() {
|
|
1638
|
-
return this.#
|
|
1648
|
+
return this.#o.editOn;
|
|
1639
1649
|
}
|
|
1640
1650
|
set editOn(e) {
|
|
1641
|
-
const o = this.#
|
|
1642
|
-
this.#
|
|
1651
|
+
const o = this.#v;
|
|
1652
|
+
this.#v = e, o !== e && this.#Q();
|
|
1643
1653
|
}
|
|
1644
1654
|
// Effective config accessor for internal modules and plugins
|
|
1645
1655
|
// Returns the merged config (single source of truth) before plugin processing
|
|
1646
1656
|
// Use this when you need the raw merged config (e.g., for column definitions including hidden)
|
|
1647
1657
|
get effectiveConfig() {
|
|
1648
|
-
return this.#
|
|
1658
|
+
return this.#o;
|
|
1649
1659
|
}
|
|
1650
1660
|
/**
|
|
1651
1661
|
* Get the disconnect signal for event listener cleanup.
|
|
@@ -1655,14 +1665,14 @@ class V extends HTMLElement {
|
|
|
1655
1665
|
* element.addEventListener('click', handler, { signal: this.grid.disconnectSignal });
|
|
1656
1666
|
*/
|
|
1657
1667
|
get disconnectSignal() {
|
|
1658
|
-
return this.#
|
|
1668
|
+
return this.#l || (this.#l = new AbortController()), this.#l.signal;
|
|
1659
1669
|
}
|
|
1660
1670
|
constructor() {
|
|
1661
|
-
super(), this.#
|
|
1671
|
+
super(), this.#n = this.attachShadow({ mode: "open" }), this.#j(), this.#$ = new Promise((e) => this.#I = e);
|
|
1662
1672
|
}
|
|
1663
|
-
#
|
|
1673
|
+
#j() {
|
|
1664
1674
|
const e = new CSSStyleSheet();
|
|
1665
|
-
e.replaceSync(
|
|
1675
|
+
e.replaceSync(ue), this.#n.adoptedStyleSheets = [e];
|
|
1666
1676
|
}
|
|
1667
1677
|
// ---------------- Plugin System ----------------
|
|
1668
1678
|
/**
|
|
@@ -1670,14 +1680,14 @@ class V extends HTMLElement {
|
|
|
1670
1680
|
* Used by plugins for inter-plugin communication.
|
|
1671
1681
|
*/
|
|
1672
1682
|
getPlugin(e) {
|
|
1673
|
-
return this.#
|
|
1683
|
+
return this.#t?.getPlugin(e);
|
|
1674
1684
|
}
|
|
1675
1685
|
/**
|
|
1676
1686
|
* Get a plugin instance by its name.
|
|
1677
1687
|
* Used for loose coupling between plugins (avoids static imports).
|
|
1678
1688
|
*/
|
|
1679
1689
|
getPluginByName(e) {
|
|
1680
|
-
return this.#
|
|
1690
|
+
return this.#t?.getPluginByName(e);
|
|
1681
1691
|
}
|
|
1682
1692
|
/**
|
|
1683
1693
|
* Request a full re-render of the grid.
|
|
@@ -1685,7 +1695,7 @@ class V extends HTMLElement {
|
|
|
1685
1695
|
* Note: This does NOT reset plugin state - just re-processes rows/columns and renders.
|
|
1686
1696
|
*/
|
|
1687
1697
|
requestRender() {
|
|
1688
|
-
this.#
|
|
1698
|
+
this.#L(), this.#M(), this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0);
|
|
1689
1699
|
}
|
|
1690
1700
|
/**
|
|
1691
1701
|
* Request a lightweight style update without rebuilding DOM.
|
|
@@ -1693,26 +1703,26 @@ class V extends HTMLElement {
|
|
|
1693
1703
|
* This runs all plugin afterRender hooks without rebuilding row/column DOM.
|
|
1694
1704
|
*/
|
|
1695
1705
|
requestAfterRender() {
|
|
1696
|
-
this.#
|
|
1706
|
+
this.#w();
|
|
1697
1707
|
}
|
|
1698
1708
|
/**
|
|
1699
1709
|
* Initialize plugin system with instances from config.
|
|
1700
1710
|
* Plugins are class instances passed in gridConfig.plugins[].
|
|
1701
1711
|
*/
|
|
1702
1712
|
#B() {
|
|
1703
|
-
this.#
|
|
1704
|
-
const e = this.#
|
|
1705
|
-
this.#
|
|
1713
|
+
this.#t = new Xe(this);
|
|
1714
|
+
const e = this.#o?.plugins, o = Array.isArray(e) ? e : [];
|
|
1715
|
+
this.#t.attachAll(o);
|
|
1706
1716
|
}
|
|
1707
1717
|
/**
|
|
1708
1718
|
* Inject all plugin styles into the shadow DOM.
|
|
1709
1719
|
* Must be called after #render() since innerHTML wipes existing content.
|
|
1710
1720
|
*/
|
|
1711
|
-
#
|
|
1712
|
-
const e = this.#
|
|
1721
|
+
#V() {
|
|
1722
|
+
const e = this.#t?.getAllStyles() ?? "";
|
|
1713
1723
|
if (e) {
|
|
1714
1724
|
const o = document.createElement("style");
|
|
1715
|
-
o.setAttribute("data-plugin", "all"), o.textContent = e, this.#
|
|
1725
|
+
o.setAttribute("data-plugin", "all"), o.textContent = e, this.#n.appendChild(o);
|
|
1716
1726
|
}
|
|
1717
1727
|
}
|
|
1718
1728
|
/**
|
|
@@ -1720,47 +1730,47 @@ class V extends HTMLElement {
|
|
|
1720
1730
|
* With class-based plugins, we need to detach old and attach new.
|
|
1721
1731
|
*/
|
|
1722
1732
|
#W() {
|
|
1723
|
-
this.#
|
|
1733
|
+
this.#t && this.#t.detachAll(), this.#B(), this.#V(), this.#C = this.#t?.getAll().some((e) => e.onScroll) ?? !1;
|
|
1724
1734
|
}
|
|
1725
1735
|
/**
|
|
1726
1736
|
* Clean up plugin states when grid disconnects.
|
|
1727
1737
|
*/
|
|
1728
|
-
#
|
|
1729
|
-
this.#
|
|
1738
|
+
#K() {
|
|
1739
|
+
this.#t?.detachAll();
|
|
1730
1740
|
}
|
|
1731
1741
|
/**
|
|
1732
1742
|
* Collect tool panels and header content from all plugins.
|
|
1733
1743
|
* Called after plugins are attached but before render.
|
|
1734
1744
|
*/
|
|
1735
1745
|
#Y() {
|
|
1736
|
-
if (!this.#
|
|
1737
|
-
const e = this.#
|
|
1746
|
+
if (!this.#t) return;
|
|
1747
|
+
const e = this.#t.getToolPanels();
|
|
1738
1748
|
for (const { panel: n } of e)
|
|
1739
1749
|
this.#e.toolPanels.has(n.id) || this.#e.toolPanels.set(n.id, n);
|
|
1740
|
-
const o = this.#
|
|
1750
|
+
const o = this.#t.getHeaderContents();
|
|
1741
1751
|
for (const { content: n } of o)
|
|
1742
1752
|
this.#e.headerContents.has(n.id) || this.#e.headerContents.set(n.id, n);
|
|
1743
1753
|
}
|
|
1744
1754
|
// ---------------- Lifecycle ----------------
|
|
1745
1755
|
connectedCallback() {
|
|
1746
|
-
this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#
|
|
1756
|
+
this.hasAttribute("tabindex") || (this.tabIndex = 0), this.hasAttribute("version") || this.setAttribute("version", I.version), this._rows = Array.isArray(this.#s) ? [...this.#s] : [], this.#l?.abort(), this.#l = new AbortController(), this.#u(), this.#B(), this.#Y(), this.#k || (this.#X(), this.#V(), this.#k = !0), this.#G();
|
|
1747
1757
|
}
|
|
1748
1758
|
disconnectedCallback() {
|
|
1749
|
-
this.#
|
|
1759
|
+
this.#K(), Ue(this.#e), this.#a = !1, this.#A?.(), this.#A = void 0, this.#l && (this.#l.abort(), this.#l = void 0), this.resizeController && this.resizeController.dispose(), this.#b && (this.#b.disconnect(), this.#b = void 0), this.#h = !1;
|
|
1750
1760
|
}
|
|
1751
|
-
#
|
|
1752
|
-
const o = this.#
|
|
1753
|
-
if (this.headerRowEl = o?.querySelector(".header-row"), this.virtualization.totalHeightEl = o?.querySelector(".faux-vscroll-spacer"), this.virtualization.viewportEl = o?.querySelector(".rows-viewport"), this.bodyEl = o?.querySelector(".rows"), this.#
|
|
1754
|
-
|
|
1755
|
-
const r = this.#
|
|
1761
|
+
#G() {
|
|
1762
|
+
const o = this.#n.querySelector(".tbw-grid-content") ?? this.#n.querySelector(".tbw-grid-root");
|
|
1763
|
+
if (this.headerRowEl = o?.querySelector(".header-row"), this.virtualization.totalHeightEl = o?.querySelector(".faux-vscroll-spacer"), this.virtualization.viewportEl = o?.querySelector(".rows-viewport"), this.bodyEl = o?.querySelector(".rows"), this.#a) {
|
|
1764
|
+
oe(this.#n, this.#e), We(this.#n, this.#o?.shell, this.#e);
|
|
1765
|
+
const r = this.#o?.shell?.toolPanel?.defaultOpen;
|
|
1756
1766
|
r && this.#e.toolPanels.has(r) && (this.openToolPanel(), this.#e.expandedSections.add(r));
|
|
1757
1767
|
}
|
|
1758
|
-
this.setAttribute("data-upgraded", ""), this.#
|
|
1768
|
+
this.setAttribute("data-upgraded", ""), this.#h = !0;
|
|
1759
1769
|
const n = this.disconnectSignal;
|
|
1760
|
-
this.#
|
|
1770
|
+
this.#c(), this.addEventListener("keydown", (r) => Pe(this, r), { signal: n }), document.addEventListener(
|
|
1761
1771
|
"keydown",
|
|
1762
1772
|
(r) => {
|
|
1763
|
-
r.key === "Escape" && this.activeEditRows !== -1 && this.#
|
|
1773
|
+
r.key === "Escape" && this.activeEditRows !== -1 && this.#D(this.activeEditRows, !0);
|
|
1764
1774
|
},
|
|
1765
1775
|
{ capture: !0, signal: n }
|
|
1766
1776
|
), document.addEventListener(
|
|
@@ -1768,64 +1778,64 @@ class V extends HTMLElement {
|
|
|
1768
1778
|
(r) => {
|
|
1769
1779
|
if (this.activeEditRows === -1) return;
|
|
1770
1780
|
const l = this.findRenderedRowElement(this.activeEditRows);
|
|
1771
|
-
!l || (r.composedPath && r.composedPath() || []).includes(l) || this.#
|
|
1781
|
+
!l || (r.composedPath && r.composedPath() || []).includes(l) || this.#D(this.activeEditRows, !1);
|
|
1772
1782
|
},
|
|
1773
1783
|
{ signal: n }
|
|
1774
1784
|
);
|
|
1775
|
-
const
|
|
1776
|
-
if (this.virtualization.container =
|
|
1777
|
-
|
|
1785
|
+
const i = o?.querySelector(".faux-vscroll"), s = o?.querySelector(".rows");
|
|
1786
|
+
if (this.virtualization.container = i ?? this, this.#C = this.#t?.getAll().some((r) => r.onScroll) ?? !1, i && s) {
|
|
1787
|
+
i.addEventListener(
|
|
1778
1788
|
"scroll",
|
|
1779
1789
|
() => {
|
|
1780
|
-
if (!this.virtualization.enabled && !this.#
|
|
1781
|
-
const a =
|
|
1782
|
-
|
|
1783
|
-
this.#
|
|
1790
|
+
if (!this.virtualization.enabled && !this.#C) return;
|
|
1791
|
+
const a = i.scrollTop, d = this.virtualization.rowHeight, h = Math.floor(a / d), p = h - h % 2, b = -(a - p * d);
|
|
1792
|
+
s.style.transform = `translateY(${b}px)`, this.#E = a, this.#f || (this.#f = requestAnimationFrame(() => {
|
|
1793
|
+
this.#f = 0, this.#E !== null && (this.#re(this.#E), this.#E = null);
|
|
1784
1794
|
}));
|
|
1785
1795
|
},
|
|
1786
1796
|
{ passive: !0, signal: n }
|
|
1787
1797
|
);
|
|
1788
|
-
const r = this.#
|
|
1798
|
+
const r = this.#n.querySelector(".tbw-grid-content"), l = this.#n.querySelector(".tbw-scroll-area");
|
|
1789
1799
|
r && (r.addEventListener(
|
|
1790
1800
|
"wheel",
|
|
1791
1801
|
(a) => {
|
|
1792
|
-
a.preventDefault(), a.shiftKey || Math.abs(a.deltaX) > Math.abs(a.deltaY) ? l && (l.scrollLeft += a.shiftKey ? a.deltaY : a.deltaX) :
|
|
1802
|
+
a.preventDefault(), a.shiftKey || Math.abs(a.deltaX) > Math.abs(a.deltaY) ? l && (l.scrollLeft += a.shiftKey ? a.deltaY : a.deltaX) : i.scrollTop += a.deltaY;
|
|
1793
1803
|
},
|
|
1794
1804
|
{ passive: !1, signal: n }
|
|
1795
1805
|
), r.addEventListener(
|
|
1796
1806
|
"touchstart",
|
|
1797
1807
|
(a) => {
|
|
1798
|
-
a.touches.length === 1 && (this.#_ = a.touches[0].clientY, this.#
|
|
1808
|
+
a.touches.length === 1 && (this.#_ = a.touches[0].clientY, this.#R = a.touches[0].clientX, this.#S = i.scrollTop, this.#x = l?.scrollLeft ?? 0);
|
|
1799
1809
|
},
|
|
1800
1810
|
{ passive: !0, signal: n }
|
|
1801
1811
|
), r.addEventListener(
|
|
1802
1812
|
"touchmove",
|
|
1803
1813
|
(a) => {
|
|
1804
|
-
if (a.touches.length === 1 && this.#_ !== null && this.#
|
|
1805
|
-
const d = this.#_ - a.touches[0].clientY, h = this.#
|
|
1806
|
-
|
|
1814
|
+
if (a.touches.length === 1 && this.#_ !== null && this.#R !== null && this.#S !== null && this.#x !== null) {
|
|
1815
|
+
const d = this.#_ - a.touches[0].clientY, h = this.#R - a.touches[0].clientX;
|
|
1816
|
+
i.scrollTop = this.#S + d, l && (l.scrollLeft = this.#x + h), a.preventDefault();
|
|
1807
1817
|
}
|
|
1808
1818
|
},
|
|
1809
1819
|
{ passive: !1, signal: n }
|
|
1810
1820
|
), r.addEventListener(
|
|
1811
1821
|
"touchend",
|
|
1812
1822
|
() => {
|
|
1813
|
-
this.#_ = null, this.#
|
|
1823
|
+
this.#_ = null, this.#R = null, this.#S = null, this.#x = null;
|
|
1814
1824
|
},
|
|
1815
1825
|
{ passive: !0, signal: n }
|
|
1816
1826
|
));
|
|
1817
1827
|
}
|
|
1818
|
-
this.resizeController =
|
|
1828
|
+
this.resizeController = De(this), this.#n.addEventListener("mousedown", (r) => this.#le(r), { signal: n }), document.addEventListener("mousemove", (r) => this.#ae(r), { signal: n }), document.addEventListener("mouseup", (r) => this.#ce(r), { signal: n }), this.virtualization.enabled && requestAnimationFrame(() => this.refreshVirtualWindow(!0)), requestAnimationFrame(() => {
|
|
1819
1829
|
const r = this.bodyEl.querySelector(".data-grid-row");
|
|
1820
1830
|
if (r) {
|
|
1821
1831
|
const l = r.getBoundingClientRect().height;
|
|
1822
1832
|
l && Math.abs(l - this.virtualization.rowHeight) > 0.1 && (this.virtualization.rowHeight = l, this.refreshVirtualWindow(!0));
|
|
1823
1833
|
}
|
|
1824
|
-
}), this.virtualization.viewportEl && (this.#
|
|
1825
|
-
this.#
|
|
1826
|
-
this.#
|
|
1834
|
+
}), this.virtualization.viewportEl && (this.#b = new ResizeObserver(() => {
|
|
1835
|
+
this.#f || (this.#f = requestAnimationFrame(() => {
|
|
1836
|
+
this.#f = 0, this.refreshVirtualWindow(!0);
|
|
1827
1837
|
}));
|
|
1828
|
-
}), this.#
|
|
1838
|
+
}), this.#b.observe(this.virtualization.viewportEl)), queueMicrotask(() => this.#Z()), requestAnimationFrame(() => requestAnimationFrame(() => this.#I?.()));
|
|
1829
1839
|
}
|
|
1830
1840
|
// ---------------- Event Emitters ----------------
|
|
1831
1841
|
#i(e, o) {
|
|
@@ -1849,55 +1859,55 @@ class V extends HTMLElement {
|
|
|
1849
1859
|
/** Update ARIA selection attributes on rendered rows/cells */
|
|
1850
1860
|
#Z() {
|
|
1851
1861
|
this.bodyEl?.querySelectorAll(".data-grid-row")?.forEach((o, n) => {
|
|
1852
|
-
const
|
|
1853
|
-
o.setAttribute("aria-selected", String(
|
|
1854
|
-
|
|
1862
|
+
const i = n === this.focusRow;
|
|
1863
|
+
o.setAttribute("aria-selected", String(i)), o.querySelectorAll(".cell").forEach((s, r) => {
|
|
1864
|
+
s.setAttribute("aria-selected", String(i && r === this.focusCol));
|
|
1855
1865
|
});
|
|
1856
1866
|
});
|
|
1857
1867
|
}
|
|
1858
1868
|
// ---------------- Watch Handlers ----------------
|
|
1859
1869
|
#J() {
|
|
1860
|
-
if (!this.#
|
|
1861
|
-
this.#u(), this.#
|
|
1870
|
+
if (!this.#h) return;
|
|
1871
|
+
this.#u(), this.#o.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, this.#F()) : (this._columns.forEach((o) => {
|
|
1862
1872
|
!o.__userResized && o.__autoSized && delete o.width;
|
|
1863
1873
|
}), this.updateTemplate());
|
|
1864
1874
|
}
|
|
1865
1875
|
#Q() {
|
|
1866
|
-
this.#
|
|
1876
|
+
this.#h && (this.#u(), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0));
|
|
1867
1877
|
}
|
|
1868
1878
|
#ee() {
|
|
1869
|
-
this._rows = Array.isArray(this.#
|
|
1879
|
+
this._rows = Array.isArray(this.#s) ? [...this.#s] : [], this.#L(), !this.#r || Array.isArray(this.#r) && this.#r.length === 0 ? this.#c() : this.refreshVirtualWindow(!0);
|
|
1870
1880
|
}
|
|
1871
1881
|
#te() {
|
|
1872
|
-
|
|
1882
|
+
X(this), this.#h && (this.#u(), this.#c());
|
|
1873
1883
|
}
|
|
1874
1884
|
#oe() {
|
|
1875
|
-
this.#
|
|
1885
|
+
this.#h && (this.#u(), this.#W(), this.#L(), this.#M(), this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0));
|
|
1876
1886
|
}
|
|
1877
1887
|
// ---------------- Helper Wrappers ----------------
|
|
1878
1888
|
#ne() {
|
|
1879
|
-
|
|
1889
|
+
Te(this);
|
|
1880
1890
|
}
|
|
1881
|
-
#
|
|
1882
|
-
|
|
1891
|
+
#T() {
|
|
1892
|
+
K(this);
|
|
1883
1893
|
}
|
|
1884
1894
|
updateTemplate() {
|
|
1885
|
-
|
|
1895
|
+
ce(this);
|
|
1886
1896
|
}
|
|
1887
|
-
#
|
|
1888
|
-
|
|
1889
|
-
}
|
|
1890
|
-
#
|
|
1891
|
-
if (this.#
|
|
1892
|
-
const e = this.#
|
|
1893
|
-
if (
|
|
1894
|
-
const
|
|
1895
|
-
if (!o.some((l) =>
|
|
1896
|
-
this._columns = [...
|
|
1897
|
+
#F() {
|
|
1898
|
+
Le(this);
|
|
1899
|
+
}
|
|
1900
|
+
#M() {
|
|
1901
|
+
if (this.#t) {
|
|
1902
|
+
const e = this.#H.length > 0 ? this.#H : this._columns, o = e.filter((s) => !s.hidden), n = e.filter((s) => s.hidden), i = this.#t.processColumns([...o]);
|
|
1903
|
+
if (i !== o) {
|
|
1904
|
+
const s = new Map(i.map((l, a) => [l.field, { col: l, order: a }]));
|
|
1905
|
+
if (!o.some((l) => s.has(l.field)) && i.length > 0)
|
|
1906
|
+
this._columns = [...i, ...n];
|
|
1897
1907
|
else {
|
|
1898
1908
|
const l = e.map((a) => {
|
|
1899
1909
|
if (a.hidden) return a;
|
|
1900
|
-
const d =
|
|
1910
|
+
const d = s.get(a.field);
|
|
1901
1911
|
return d ? d.col : a;
|
|
1902
1912
|
});
|
|
1903
1913
|
this._columns = l;
|
|
@@ -1907,13 +1917,13 @@ class V extends HTMLElement {
|
|
|
1907
1917
|
}
|
|
1908
1918
|
}
|
|
1909
1919
|
/** Execute all plugin afterRender hooks */
|
|
1910
|
-
#
|
|
1911
|
-
this.#
|
|
1920
|
+
#w() {
|
|
1921
|
+
this.#t?.afterRender();
|
|
1912
1922
|
}
|
|
1913
1923
|
/** Recompute row model via plugin hooks (grouping, tree, filtering, etc.). */
|
|
1914
|
-
#
|
|
1915
|
-
|
|
1916
|
-
const e = Array.isArray(this.#
|
|
1924
|
+
#L() {
|
|
1925
|
+
X(this);
|
|
1926
|
+
const e = Array.isArray(this.#s) ? [...this.#s] : [], o = this.#t?.processRows(e) ?? e;
|
|
1917
1927
|
this._rows = o;
|
|
1918
1928
|
}
|
|
1919
1929
|
/**
|
|
@@ -1935,74 +1945,74 @@ class V extends HTMLElement {
|
|
|
1935
1945
|
* - Plugins receive config via their attach() method
|
|
1936
1946
|
*/
|
|
1937
1947
|
#u() {
|
|
1938
|
-
const e = this.#
|
|
1948
|
+
const e = this.#p ? { ...this.#p } : {};
|
|
1939
1949
|
let o = Array.isArray(e.columns) ? [...e.columns] : [];
|
|
1940
|
-
const n = (this.__lightDomColumnsCache || []).map((
|
|
1941
|
-
...
|
|
1950
|
+
const n = (this.__lightDomColumnsCache || []).map((i) => ({
|
|
1951
|
+
...i
|
|
1942
1952
|
}));
|
|
1943
1953
|
if (n.length) {
|
|
1944
|
-
const
|
|
1945
|
-
o.forEach((
|
|
1946
|
-
const r = s
|
|
1947
|
-
r ? (
|
|
1954
|
+
const i = {};
|
|
1955
|
+
o.forEach((s) => i[s.field] = s), n.forEach((s) => {
|
|
1956
|
+
const r = i[s.field];
|
|
1957
|
+
r ? (s.header && !r.header && (r.header = s.header), s.type && !r.type && (r.type = s.type), r.sortable = r.sortable || s.sortable, s.resizable && (r.resizable = !0), s.editable && (r.editable = !0)) : (o.push(s), i[s.field] = s);
|
|
1948
1958
|
});
|
|
1949
1959
|
}
|
|
1950
|
-
if (this.#
|
|
1960
|
+
if (this.#r && this.#r.length && (o = [...this.#r]), (!o || o.length === 0) && this._rows.length && (o = le(this._rows).columns), o.length) {
|
|
1951
1961
|
o.forEach((r) => {
|
|
1952
1962
|
r.sortable === void 0 && (r.sortable = !0), r.resizable === void 0 && (r.resizable = !0);
|
|
1953
1963
|
});
|
|
1954
|
-
const
|
|
1955
|
-
|
|
1964
|
+
const i = this.#o.columns;
|
|
1965
|
+
i?.some((r) => r.__compiledView || r.__compiledEditor) ? e.columns = i : e.columns = o;
|
|
1956
1966
|
} else {
|
|
1957
|
-
const
|
|
1958
|
-
|
|
1967
|
+
const i = this.#o.columns;
|
|
1968
|
+
i?.some((s) => s.__compiledView || s.__compiledEditor) && (e.columns = i);
|
|
1959
1969
|
}
|
|
1960
|
-
this.#
|
|
1961
|
-
|
|
1970
|
+
this.#m && (e.fitMode = this.#m), e.fitMode || (e.fitMode = "stretch"), this.#v && (e.editOn = this.#v), e.columnState && !this.#d && (this.#d = e.columnState), this.#o = e, e.fitMode === "fixed" && this._columns.forEach((i) => {
|
|
1971
|
+
i.width == null && (i.width = 80);
|
|
1962
1972
|
});
|
|
1963
1973
|
}
|
|
1964
1974
|
// ---------------- Delegate Wrappers ----------------
|
|
1965
|
-
#
|
|
1966
|
-
this.#P || (this.#P = (
|
|
1975
|
+
#z(e, o, n = this.__rowRenderEpoch) {
|
|
1976
|
+
this.#P || (this.#P = (i, s, r) => this.#t?.renderRow(i, s, r) ?? !1), Me(this, e, o, n, this.#P);
|
|
1967
1977
|
}
|
|
1968
|
-
#
|
|
1969
|
-
|
|
1978
|
+
#ie(e, o) {
|
|
1979
|
+
z(this, e, o);
|
|
1970
1980
|
}
|
|
1971
|
-
#
|
|
1981
|
+
#D(e, o) {
|
|
1972
1982
|
N(this, e, o);
|
|
1973
1983
|
}
|
|
1974
1984
|
// ---------------- Core Helpers ----------------
|
|
1975
|
-
#
|
|
1985
|
+
#c() {
|
|
1976
1986
|
if (!this.isConnected || !this.headerRowEl || !this.bodyEl)
|
|
1977
1987
|
return;
|
|
1978
|
-
const e = this.#
|
|
1988
|
+
const e = this.#p?.columns || this.#r || [];
|
|
1979
1989
|
if (e.length) {
|
|
1980
|
-
const n = new Map(this._columns.filter((
|
|
1981
|
-
...
|
|
1982
|
-
hidden: n.get(
|
|
1990
|
+
const n = new Map(this._columns.filter((s) => s.hidden).map((s) => [s.field, !0])), i = e.map((s) => ({
|
|
1991
|
+
...s,
|
|
1992
|
+
hidden: n.get(s.field) ?? s.hidden
|
|
1983
1993
|
}));
|
|
1984
|
-
this._columns =
|
|
1994
|
+
this._columns = i;
|
|
1985
1995
|
}
|
|
1986
|
-
if (this.#ne(), this.#u(), this.#W(), this.#
|
|
1987
|
-
const n = this.#
|
|
1988
|
-
this.#
|
|
1996
|
+
if (this.#ne(), this.#u(), this.#W(), this.#H = [...this._columns], this.#L(), this.#M(), this.#d) {
|
|
1997
|
+
const n = this.#d;
|
|
1998
|
+
this.#d = void 0, this.#U(n);
|
|
1989
1999
|
}
|
|
1990
|
-
this.#
|
|
2000
|
+
this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0), this.#o.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => this.#F()), this.bodyEl && (this.bodyEl.style.display = "", this.bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#w());
|
|
1991
2001
|
}
|
|
1992
2002
|
/** Internal method to apply column state without triggering setup loop */
|
|
1993
|
-
#
|
|
1994
|
-
const o = this.#
|
|
1995
|
-
|
|
1996
|
-
for (const
|
|
1997
|
-
const
|
|
1998
|
-
|
|
2003
|
+
#U(e) {
|
|
2004
|
+
const o = this.#o.columns ?? [], n = this.#t?.getAll() ?? [];
|
|
2005
|
+
fe(this, e, o, n);
|
|
2006
|
+
for (const i of e.columns) {
|
|
2007
|
+
const s = o.find((r) => r.field === i.field);
|
|
2008
|
+
s && (s.hidden = !i.visible);
|
|
1999
2009
|
}
|
|
2000
2010
|
}
|
|
2001
|
-
#
|
|
2011
|
+
#se() {
|
|
2002
2012
|
return this._rows.length <= this.virtualization.bypassThreshold;
|
|
2003
2013
|
}
|
|
2004
2014
|
#re(e) {
|
|
2005
|
-
if (this.refreshVirtualWindow(!1), this.#
|
|
2015
|
+
if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#C) {
|
|
2006
2016
|
const o = this.virtualization.container, n = {
|
|
2007
2017
|
scrollTop: e,
|
|
2008
2018
|
scrollLeft: o?.scrollLeft ?? 0,
|
|
@@ -2012,11 +2022,11 @@ class V extends HTMLElement {
|
|
|
2012
2022
|
clientWidth: o?.clientWidth ?? 0,
|
|
2013
2023
|
originalEvent: new Event("scroll")
|
|
2014
2024
|
};
|
|
2015
|
-
this.#
|
|
2025
|
+
this.#t?.onScroll(n);
|
|
2016
2026
|
}
|
|
2017
2027
|
}
|
|
2018
2028
|
findHeaderRow() {
|
|
2019
|
-
return this.#
|
|
2029
|
+
return this.#n.querySelector(".header-row");
|
|
2020
2030
|
}
|
|
2021
2031
|
findRenderedRowElement(e) {
|
|
2022
2032
|
return Array.from(this.bodyEl.querySelectorAll(".data-grid-row")).find((o) => {
|
|
@@ -2028,42 +2038,42 @@ class V extends HTMLElement {
|
|
|
2028
2038
|
* Dispatch a cell click event to the plugin system.
|
|
2029
2039
|
* Returns true if any plugin handled the event.
|
|
2030
2040
|
*/
|
|
2031
|
-
dispatchCellClick(e, o, n,
|
|
2032
|
-
const
|
|
2033
|
-
if (!
|
|
2041
|
+
dispatchCellClick(e, o, n, i) {
|
|
2042
|
+
const s = this._rows[o], r = this._columns[n];
|
|
2043
|
+
if (!s || !r) return !1;
|
|
2034
2044
|
const l = {
|
|
2035
|
-
row:
|
|
2045
|
+
row: s,
|
|
2036
2046
|
rowIndex: o,
|
|
2037
2047
|
colIndex: n,
|
|
2038
2048
|
field: r.field,
|
|
2039
|
-
value:
|
|
2040
|
-
cellEl:
|
|
2049
|
+
value: s[r.field],
|
|
2050
|
+
cellEl: i,
|
|
2041
2051
|
originalEvent: e
|
|
2042
2052
|
};
|
|
2043
|
-
return this.#
|
|
2053
|
+
return this.#t?.onCellClick(l) ?? !1;
|
|
2044
2054
|
}
|
|
2045
2055
|
/**
|
|
2046
2056
|
* Dispatch a header click event to the plugin system.
|
|
2047
2057
|
* Returns true if any plugin handled the event.
|
|
2048
2058
|
*/
|
|
2049
2059
|
dispatchHeaderClick(e, o, n) {
|
|
2050
|
-
const
|
|
2051
|
-
if (!
|
|
2052
|
-
const
|
|
2060
|
+
const i = this._columns[o];
|
|
2061
|
+
if (!i) return !1;
|
|
2062
|
+
const s = {
|
|
2053
2063
|
colIndex: o,
|
|
2054
|
-
field:
|
|
2055
|
-
column:
|
|
2064
|
+
field: i.field,
|
|
2065
|
+
column: i,
|
|
2056
2066
|
headerEl: n,
|
|
2057
2067
|
originalEvent: e
|
|
2058
2068
|
};
|
|
2059
|
-
return this.#
|
|
2069
|
+
return this.#t?.onHeaderClick(s) ?? !1;
|
|
2060
2070
|
}
|
|
2061
2071
|
/**
|
|
2062
2072
|
* Dispatch a keyboard event to the plugin system.
|
|
2063
2073
|
* Returns true if any plugin handled the event.
|
|
2064
2074
|
*/
|
|
2065
2075
|
dispatchKeyDown(e) {
|
|
2066
|
-
return this.#
|
|
2076
|
+
return this.#t?.onKeyDown(e) ?? !1;
|
|
2067
2077
|
}
|
|
2068
2078
|
/**
|
|
2069
2079
|
* Build a CellMouseEvent from a native MouseEvent.
|
|
@@ -2071,23 +2081,23 @@ class V extends HTMLElement {
|
|
|
2071
2081
|
*/
|
|
2072
2082
|
#N(e, o) {
|
|
2073
2083
|
let n = null;
|
|
2074
|
-
const
|
|
2075
|
-
if (
|
|
2076
|
-
const u = this.#
|
|
2084
|
+
const i = e.composedPath?.();
|
|
2085
|
+
if (i && i.length > 0 ? n = i[0] : n = e.target, n && !this.#n.contains(n)) {
|
|
2086
|
+
const u = this.#n.elementFromPoint(e.clientX, e.clientY);
|
|
2077
2087
|
u && (n = u);
|
|
2078
2088
|
}
|
|
2079
|
-
const
|
|
2080
|
-
let a, d, h, p,
|
|
2081
|
-
return
|
|
2089
|
+
const s = n?.closest?.("[data-col]"), r = n?.closest?.(".data-grid-row"), l = n?.closest?.(".header-row");
|
|
2090
|
+
let a, d, h, p, b, c;
|
|
2091
|
+
return s && (a = parseInt(s.getAttribute("data-row") ?? "-1", 10), d = parseInt(s.getAttribute("data-col") ?? "-1", 10), a >= 0 && d >= 0 && (h = this._rows[a], c = this._columns[d], p = c?.field, b = h && p ? h[p] : void 0)), {
|
|
2082
2092
|
type: o,
|
|
2083
2093
|
row: h,
|
|
2084
2094
|
rowIndex: a !== void 0 && a >= 0 ? a : void 0,
|
|
2085
2095
|
colIndex: d !== void 0 && d >= 0 ? d : void 0,
|
|
2086
2096
|
field: p,
|
|
2087
|
-
value:
|
|
2097
|
+
value: b,
|
|
2088
2098
|
column: c,
|
|
2089
2099
|
originalEvent: e,
|
|
2090
|
-
cellElement:
|
|
2100
|
+
cellElement: s ?? void 0,
|
|
2091
2101
|
rowElement: r ?? void 0,
|
|
2092
2102
|
isHeader: !!l,
|
|
2093
2103
|
cell: a !== void 0 && d !== void 0 && a >= 0 && d >= 0 ? { row: a, col: d } : void 0
|
|
@@ -2098,23 +2108,23 @@ class V extends HTMLElement {
|
|
|
2098
2108
|
*/
|
|
2099
2109
|
#le(e) {
|
|
2100
2110
|
const o = this.#N(e, "mousedown");
|
|
2101
|
-
(this.#
|
|
2111
|
+
(this.#t?.onCellMouseDown(o) ?? !1) && (this.#y = !0);
|
|
2102
2112
|
}
|
|
2103
2113
|
/**
|
|
2104
2114
|
* Handle mousemove events (only when dragging).
|
|
2105
2115
|
*/
|
|
2106
2116
|
#ae(e) {
|
|
2107
|
-
if (!this.#
|
|
2117
|
+
if (!this.#y) return;
|
|
2108
2118
|
const o = this.#N(e, "mousemove");
|
|
2109
|
-
this.#
|
|
2119
|
+
this.#t?.onCellMouseMove(o);
|
|
2110
2120
|
}
|
|
2111
2121
|
/**
|
|
2112
2122
|
* Handle mouseup events.
|
|
2113
2123
|
*/
|
|
2114
2124
|
#ce(e) {
|
|
2115
|
-
if (!this.#
|
|
2125
|
+
if (!this.#y) return;
|
|
2116
2126
|
const o = this.#N(e, "mouseup");
|
|
2117
|
-
this.#
|
|
2127
|
+
this.#t?.onCellMouseUp(o), this.#y = !1;
|
|
2118
2128
|
}
|
|
2119
2129
|
// API consumed by internal utils (rows.ts)
|
|
2120
2130
|
get changedRows() {
|
|
@@ -2127,20 +2137,20 @@ class V extends HTMLElement {
|
|
|
2127
2137
|
this._changedRowIndices.clear(), e || this.#i("changed-rows-reset", { rows: this.changedRows, indices: this.changedRowIndices }), this.rowPool.forEach((o) => o.classList.remove("changed"));
|
|
2128
2138
|
}
|
|
2129
2139
|
async beginBulkEdit(e) {
|
|
2130
|
-
if (!this._columns.some((
|
|
2140
|
+
if (!this._columns.some((s) => s.editable)) return;
|
|
2131
2141
|
const n = this._rows[e];
|
|
2132
|
-
this.#
|
|
2133
|
-
const
|
|
2134
|
-
|
|
2142
|
+
this.#ie(e, n);
|
|
2143
|
+
const i = this.findRenderedRowElement?.(e);
|
|
2144
|
+
i && (Array.from(i.children).forEach((s, r) => {
|
|
2135
2145
|
const l = this.visibleColumns[r];
|
|
2136
2146
|
if (l?.editable) {
|
|
2137
|
-
const a =
|
|
2138
|
-
a.classList.contains("editing") ||
|
|
2147
|
+
const a = s;
|
|
2148
|
+
a.classList.contains("editing") || O(this, n, e, l, a);
|
|
2139
2149
|
}
|
|
2140
2150
|
}), queueMicrotask(() => {
|
|
2141
|
-
const
|
|
2142
|
-
if (
|
|
2143
|
-
const r =
|
|
2151
|
+
const s = i.querySelector(`.cell[data-col="${this.focusCol}"]`);
|
|
2152
|
+
if (s?.classList.contains("editing")) {
|
|
2153
|
+
const r = s.querySelector(
|
|
2144
2154
|
'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
|
|
2145
2155
|
);
|
|
2146
2156
|
try {
|
|
@@ -2151,17 +2161,17 @@ class V extends HTMLElement {
|
|
|
2151
2161
|
}));
|
|
2152
2162
|
}
|
|
2153
2163
|
async commitActiveRowEdit() {
|
|
2154
|
-
this.activeEditRows !== -1 && this.#
|
|
2164
|
+
this.activeEditRows !== -1 && this.#D(this.activeEditRows, !1);
|
|
2155
2165
|
}
|
|
2156
2166
|
async ready() {
|
|
2157
|
-
return this
|
|
2167
|
+
return this.#$;
|
|
2158
2168
|
}
|
|
2159
2169
|
async forceLayout() {
|
|
2160
|
-
this.#
|
|
2170
|
+
this.#c(), await new Promise((e) => requestAnimationFrame(() => requestAnimationFrame(e)));
|
|
2161
2171
|
}
|
|
2162
2172
|
/** Public method: returns a frozen snapshot of the merged effective configuration */
|
|
2163
2173
|
async getConfig() {
|
|
2164
|
-
return Object.freeze({ ...this.#
|
|
2174
|
+
return Object.freeze({ ...this.#o || {} });
|
|
2165
2175
|
}
|
|
2166
2176
|
// ---------------- Column Visibility API ----------------
|
|
2167
2177
|
/**
|
|
@@ -2171,15 +2181,15 @@ class V extends HTMLElement {
|
|
|
2171
2181
|
* @returns True if visibility was changed, false if column not found or locked
|
|
2172
2182
|
*/
|
|
2173
2183
|
setColumnVisible(e, o) {
|
|
2174
|
-
const n = this.#
|
|
2175
|
-
if (!
|
|
2184
|
+
const n = this.#o.columns, i = n?.find((l) => l.field === e);
|
|
2185
|
+
if (!i || !o && i.lockVisible || !o && (n ?? []).filter((a) => !a.hidden && a.field !== e).length === 0)
|
|
2176
2186
|
return !1;
|
|
2177
|
-
const
|
|
2178
|
-
return
|
|
2187
|
+
const s = !!i.hidden, r = !o;
|
|
2188
|
+
return s !== r ? (i.hidden = r, this.#i("column-visibility", {
|
|
2179
2189
|
field: e,
|
|
2180
2190
|
visible: o,
|
|
2181
2191
|
visibleColumns: (n ?? []).filter((l) => !l.hidden).map((l) => l.field)
|
|
2182
|
-
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#
|
|
2192
|
+
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#c(), this.requestStateChange(), !0) : !1;
|
|
2183
2193
|
}
|
|
2184
2194
|
/**
|
|
2185
2195
|
* Toggle the visibility of a column.
|
|
@@ -2187,8 +2197,8 @@ class V extends HTMLElement {
|
|
|
2187
2197
|
* @returns True if visibility was toggled, false if column not found or locked
|
|
2188
2198
|
*/
|
|
2189
2199
|
toggleColumnVisibility(e) {
|
|
2190
|
-
const
|
|
2191
|
-
return this.setColumnVisible(e,
|
|
2200
|
+
const i = !!this.#o.columns?.find((s) => s.field === e)?.hidden;
|
|
2201
|
+
return this.setColumnVisible(e, i);
|
|
2192
2202
|
}
|
|
2193
2203
|
/**
|
|
2194
2204
|
* Check if a column is currently visible.
|
|
@@ -2196,19 +2206,19 @@ class V extends HTMLElement {
|
|
|
2196
2206
|
* @returns True if visible, false if hidden or not found
|
|
2197
2207
|
*/
|
|
2198
2208
|
isColumnVisible(e) {
|
|
2199
|
-
const n = this.#
|
|
2209
|
+
const n = this.#o.columns?.find((i) => i.field === e);
|
|
2200
2210
|
return n ? !n.hidden : !1;
|
|
2201
2211
|
}
|
|
2202
2212
|
/**
|
|
2203
2213
|
* Show all columns.
|
|
2204
2214
|
*/
|
|
2205
2215
|
showAllColumns() {
|
|
2206
|
-
const e = this.#
|
|
2216
|
+
const e = this.#o.columns;
|
|
2207
2217
|
e?.some((n) => n.hidden) && (e?.forEach((n) => {
|
|
2208
2218
|
n.hidden = !1;
|
|
2209
2219
|
}), this.#i("column-visibility", {
|
|
2210
2220
|
visibleColumns: (e ?? []).map((n) => n.field)
|
|
2211
|
-
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#
|
|
2221
|
+
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#c(), this.requestStateChange());
|
|
2212
2222
|
}
|
|
2213
2223
|
/**
|
|
2214
2224
|
* Get list of all column fields (including hidden).
|
|
@@ -2217,7 +2227,7 @@ class V extends HTMLElement {
|
|
|
2217
2227
|
* @returns Array of all field names with their visibility status
|
|
2218
2228
|
*/
|
|
2219
2229
|
getAllColumns() {
|
|
2220
|
-
return (this.#
|
|
2230
|
+
return (this.#o.columns ?? []).map((o) => ({
|
|
2221
2231
|
field: o.field,
|
|
2222
2232
|
header: o.header || o.field,
|
|
2223
2233
|
visible: !o.hidden,
|
|
@@ -2231,14 +2241,14 @@ class V extends HTMLElement {
|
|
|
2231
2241
|
*/
|
|
2232
2242
|
setColumnOrder(e) {
|
|
2233
2243
|
if (!e.length) return;
|
|
2234
|
-
const o = new Map(this._columns.map((
|
|
2235
|
-
for (const
|
|
2236
|
-
const
|
|
2237
|
-
|
|
2244
|
+
const o = new Map(this._columns.map((i) => [i.field, i])), n = [];
|
|
2245
|
+
for (const i of e) {
|
|
2246
|
+
const s = o.get(i);
|
|
2247
|
+
s && (n.push(s), o.delete(i));
|
|
2238
2248
|
}
|
|
2239
|
-
for (const
|
|
2240
|
-
n.push(
|
|
2241
|
-
this._columns = n, this.#
|
|
2249
|
+
for (const i of o.values())
|
|
2250
|
+
n.push(i);
|
|
2251
|
+
this._columns = n, this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0);
|
|
2242
2252
|
}
|
|
2243
2253
|
/**
|
|
2244
2254
|
* Get the current column order as an array of field names.
|
|
@@ -2253,15 +2263,15 @@ class V extends HTMLElement {
|
|
|
2253
2263
|
* Returns a serializable object suitable for localStorage or database storage.
|
|
2254
2264
|
*/
|
|
2255
2265
|
getColumnState() {
|
|
2256
|
-
const e = this.#
|
|
2257
|
-
return
|
|
2266
|
+
const e = this.#t?.getAll() ?? [];
|
|
2267
|
+
return re(this, e);
|
|
2258
2268
|
}
|
|
2259
2269
|
/**
|
|
2260
2270
|
* Set the column state, restoring order, width, visibility, sort, and plugin state.
|
|
2261
2271
|
* Use this to restore previously saved column state.
|
|
2262
2272
|
*/
|
|
2263
2273
|
set columnState(e) {
|
|
2264
|
-
e && (this.#
|
|
2274
|
+
e && (this.#d = e, this.#k && this.#de(e));
|
|
2265
2275
|
}
|
|
2266
2276
|
/**
|
|
2267
2277
|
* Get the current column state.
|
|
@@ -2273,9 +2283,9 @@ class V extends HTMLElement {
|
|
|
2273
2283
|
* Apply column state internally.
|
|
2274
2284
|
*/
|
|
2275
2285
|
#de(e) {
|
|
2276
|
-
(this.#
|
|
2286
|
+
(this.#o.columns ?? []).forEach((n) => {
|
|
2277
2287
|
n.hidden = !1;
|
|
2278
|
-
}), this.#
|
|
2288
|
+
}), this.#U(e), this.#c();
|
|
2279
2289
|
}
|
|
2280
2290
|
/**
|
|
2281
2291
|
* Request a state change event to be emitted.
|
|
@@ -2284,26 +2294,26 @@ class V extends HTMLElement {
|
|
|
2284
2294
|
* The event is debounced to avoid excessive events during drag operations.
|
|
2285
2295
|
*/
|
|
2286
2296
|
requestStateChange() {
|
|
2287
|
-
this.#
|
|
2297
|
+
this.#O || (this.#O = pe(
|
|
2288
2298
|
this,
|
|
2289
|
-
() => this.#
|
|
2299
|
+
() => this.#t?.getAll() ?? [],
|
|
2290
2300
|
(e) => this.#i("column-state-change", e)
|
|
2291
|
-
)), this.#
|
|
2301
|
+
)), this.#O();
|
|
2292
2302
|
}
|
|
2293
2303
|
/**
|
|
2294
2304
|
* Reset column state to initial configuration.
|
|
2295
2305
|
* Clears all user modifications (order, width, visibility, sort).
|
|
2296
2306
|
*/
|
|
2297
2307
|
resetColumnState() {
|
|
2298
|
-
this.#
|
|
2308
|
+
this.#d = void 0, (this.#o.columns ?? []).forEach((n) => {
|
|
2299
2309
|
n.hidden = !1;
|
|
2300
|
-
}), this.sortState = null, this.__originalOrder = [], this.#u(), this.#
|
|
2301
|
-
const o = this.#
|
|
2310
|
+
}), this.sortState = null, this.__originalOrder = [], this.#u(), this.#c();
|
|
2311
|
+
const o = this.#t?.getAll() ?? [];
|
|
2302
2312
|
for (const n of o)
|
|
2303
2313
|
if (n.applyColumnState)
|
|
2304
|
-
for (const
|
|
2305
|
-
n.applyColumnState(
|
|
2306
|
-
field:
|
|
2314
|
+
for (const i of this._columns)
|
|
2315
|
+
n.applyColumnState(i.field, {
|
|
2316
|
+
field: i.field,
|
|
2307
2317
|
order: 0,
|
|
2308
2318
|
visible: !0
|
|
2309
2319
|
});
|
|
@@ -2336,16 +2346,16 @@ class V extends HTMLElement {
|
|
|
2336
2346
|
if (this.#e.isPanelOpen) return;
|
|
2337
2347
|
if (this.#e.isPanelOpen = !0, this.#e.expandedSections.size === 0 && this.#e.toolPanels.size > 0) {
|
|
2338
2348
|
const n = [...this.#e.toolPanels.values()].sort(
|
|
2339
|
-
(
|
|
2349
|
+
(i, s) => (i.order ?? 100) - (s.order ?? 100)
|
|
2340
2350
|
)[0];
|
|
2341
2351
|
n && this.#e.expandedSections.add(n.id);
|
|
2342
2352
|
}
|
|
2343
|
-
|
|
2353
|
+
ne(this.#n, this.#e), ie(this.#n, this.#e);
|
|
2344
2354
|
const e = {
|
|
2345
|
-
expand: this.#
|
|
2346
|
-
collapse: this.#
|
|
2355
|
+
expand: this.#o?.icons?.expand ?? P.expand,
|
|
2356
|
+
collapse: this.#o?.icons?.collapse ?? P.collapse
|
|
2347
2357
|
};
|
|
2348
|
-
|
|
2358
|
+
Ge(this.#n, this.#e, e), this.#i("tool-panel-open", { sections: this.expandedToolPanelSections });
|
|
2349
2359
|
}
|
|
2350
2360
|
/**
|
|
2351
2361
|
* Close the tool panel.
|
|
@@ -2357,7 +2367,7 @@ class V extends HTMLElement {
|
|
|
2357
2367
|
this.#e.panelCleanups.clear(), this.#e.activePanelCleanup && (this.#e.activePanelCleanup(), this.#e.activePanelCleanup = null);
|
|
2358
2368
|
for (const e of this.#e.toolPanels.values())
|
|
2359
2369
|
e.onClose?.();
|
|
2360
|
-
this.#e.isPanelOpen = !1,
|
|
2370
|
+
this.#e.isPanelOpen = !1, ne(this.#n, this.#e), ie(this.#n, this.#e), this.#i("tool-panel-close", {});
|
|
2361
2371
|
}
|
|
2362
2372
|
}
|
|
2363
2373
|
/**
|
|
@@ -2381,17 +2391,17 @@ class V extends HTMLElement {
|
|
|
2381
2391
|
return;
|
|
2382
2392
|
const n = this.#e.expandedSections.has(e);
|
|
2383
2393
|
if (n) {
|
|
2384
|
-
const
|
|
2385
|
-
|
|
2394
|
+
const i = this.#e.panelCleanups.get(e);
|
|
2395
|
+
i && (i(), this.#e.panelCleanups.delete(e)), o.onClose?.(), this.#e.expandedSections.delete(e), this.#q(e, !1);
|
|
2386
2396
|
} else {
|
|
2387
|
-
for (const [
|
|
2388
|
-
if (
|
|
2389
|
-
const r = this.#e.panelCleanups.get(
|
|
2390
|
-
r && (r(), this.#e.panelCleanups.delete(
|
|
2391
|
-
const l = this.#
|
|
2397
|
+
for (const [i, s] of this.#e.toolPanels)
|
|
2398
|
+
if (i !== e && this.#e.expandedSections.has(i)) {
|
|
2399
|
+
const r = this.#e.panelCleanups.get(i);
|
|
2400
|
+
r && (r(), this.#e.panelCleanups.delete(i)), s.onClose?.(), this.#e.expandedSections.delete(i), this.#q(i, !1);
|
|
2401
|
+
const l = this.#n.querySelector(`[data-section="${i}"] .tbw-accordion-content`);
|
|
2392
2402
|
l && (l.innerHTML = "");
|
|
2393
2403
|
}
|
|
2394
|
-
this.#e.expandedSections.add(e), this.#q(e, !0), this.#
|
|
2404
|
+
this.#e.expandedSections.add(e), this.#q(e, !0), this.#ue(e);
|
|
2395
2405
|
}
|
|
2396
2406
|
this.#i("tool-panel-section-toggle", { id: e, expanded: !n });
|
|
2397
2407
|
}
|
|
@@ -2399,19 +2409,19 @@ class V extends HTMLElement {
|
|
|
2399
2409
|
* Update accordion section visual state.
|
|
2400
2410
|
*/
|
|
2401
2411
|
#q(e, o) {
|
|
2402
|
-
const n = this.#
|
|
2412
|
+
const n = this.#n.querySelector(`[data-section="${e}"]`);
|
|
2403
2413
|
n && n.classList.toggle("expanded", o);
|
|
2404
2414
|
}
|
|
2405
2415
|
/**
|
|
2406
2416
|
* Render content for a single accordion section.
|
|
2407
2417
|
*/
|
|
2408
|
-
#
|
|
2418
|
+
#ue(e) {
|
|
2409
2419
|
const o = this.#e.toolPanels.get(e);
|
|
2410
2420
|
if (!o?.render) return;
|
|
2411
|
-
const n = this.#
|
|
2421
|
+
const n = this.#n.querySelector(`[data-section="${e}"] .tbw-accordion-content`);
|
|
2412
2422
|
if (!n) return;
|
|
2413
|
-
const
|
|
2414
|
-
|
|
2423
|
+
const i = o.render(n);
|
|
2424
|
+
i && this.#e.panelCleanups.set(e, i);
|
|
2415
2425
|
}
|
|
2416
2426
|
/**
|
|
2417
2427
|
* Get registered tool panel definitions.
|
|
@@ -2427,13 +2437,13 @@ class V extends HTMLElement {
|
|
|
2427
2437
|
console.warn(`[tbw-grid] Tool panel "${e.id}" already registered`);
|
|
2428
2438
|
return;
|
|
2429
2439
|
}
|
|
2430
|
-
this.#e.toolPanels.set(e.id, e), this.#
|
|
2440
|
+
this.#e.toolPanels.set(e.id, e), this.#a && this.#g();
|
|
2431
2441
|
}
|
|
2432
2442
|
/**
|
|
2433
2443
|
* Unregister a custom tool panel.
|
|
2434
2444
|
*/
|
|
2435
2445
|
unregisterToolPanel(e) {
|
|
2436
|
-
this.#e.activePanel === e && this.closeToolPanel(), this.#e.toolPanels.delete(e), this.#
|
|
2446
|
+
this.#e.activePanel === e && this.closeToolPanel(), this.#e.toolPanels.delete(e), this.#a && this.#g();
|
|
2437
2447
|
}
|
|
2438
2448
|
/**
|
|
2439
2449
|
* Get registered header content definitions.
|
|
@@ -2449,20 +2459,20 @@ class V extends HTMLElement {
|
|
|
2449
2459
|
console.warn(`[tbw-grid] Header content "${e.id}" already registered`);
|
|
2450
2460
|
return;
|
|
2451
2461
|
}
|
|
2452
|
-
this.#e.headerContents.set(e.id, e), this.#
|
|
2462
|
+
this.#e.headerContents.set(e.id, e), this.#a && oe(this.#n, this.#e);
|
|
2453
2463
|
}
|
|
2454
2464
|
/**
|
|
2455
2465
|
* Unregister custom header content.
|
|
2456
2466
|
*/
|
|
2457
2467
|
unregisterHeaderContent(e) {
|
|
2458
2468
|
const o = this.#e.headerContentCleanups.get(e);
|
|
2459
|
-
o && (o(), this.#e.headerContentCleanups.delete(e)), this.#e.headerContents.get(e)?.onDestroy?.(), this.#e.headerContents.delete(e), this.#
|
|
2469
|
+
o && (o(), this.#e.headerContentCleanups.delete(e)), this.#e.headerContents.get(e)?.onDestroy?.(), this.#e.headerContents.delete(e), this.#n.querySelector(`[data-header-content="${e}"]`)?.remove();
|
|
2460
2470
|
}
|
|
2461
2471
|
/**
|
|
2462
2472
|
* Get all registered toolbar buttons.
|
|
2463
2473
|
*/
|
|
2464
2474
|
getToolbarButtons() {
|
|
2465
|
-
return
|
|
2475
|
+
return Fe(this.#o?.shell, this.#e);
|
|
2466
2476
|
}
|
|
2467
2477
|
/**
|
|
2468
2478
|
* Register a custom toolbar button programmatically.
|
|
@@ -2472,14 +2482,14 @@ class V extends HTMLElement {
|
|
|
2472
2482
|
console.warn(`[tbw-grid] Toolbar button "${e.id}" already registered`);
|
|
2473
2483
|
return;
|
|
2474
2484
|
}
|
|
2475
|
-
this.#e.toolbarButtons.set(e.id, e), this.#
|
|
2485
|
+
this.#e.toolbarButtons.set(e.id, e), this.#a && this.#g();
|
|
2476
2486
|
}
|
|
2477
2487
|
/**
|
|
2478
2488
|
* Unregister a custom toolbar button.
|
|
2479
2489
|
*/
|
|
2480
2490
|
unregisterToolbarButton(e) {
|
|
2481
2491
|
const o = this.#e.toolbarButtonCleanups.get(e);
|
|
2482
|
-
o && (o(), this.#e.toolbarButtonCleanups.delete(e)), this.#e.toolbarButtons.delete(e), this.#
|
|
2492
|
+
o && (o(), this.#e.toolbarButtonCleanups.delete(e)), this.#e.toolbarButtons.delete(e), this.#a && this.#g();
|
|
2483
2493
|
}
|
|
2484
2494
|
/**
|
|
2485
2495
|
* Enable/disable a toolbar button by ID.
|
|
@@ -2487,21 +2497,21 @@ class V extends HTMLElement {
|
|
|
2487
2497
|
setToolbarButtonDisabled(e, o) {
|
|
2488
2498
|
const n = this.#e.toolbarButtons.get(e);
|
|
2489
2499
|
n && (n.disabled = o);
|
|
2490
|
-
const
|
|
2491
|
-
|
|
2500
|
+
const i = this.#n.querySelector(`[data-btn="${e}"]`);
|
|
2501
|
+
i && (i.disabled = o);
|
|
2492
2502
|
}
|
|
2493
2503
|
/**
|
|
2494
2504
|
* Re-parse light DOM shell elements and refresh shell header.
|
|
2495
2505
|
* Call this after dynamically modifying <tbw-grid-header> children.
|
|
2496
2506
|
*/
|
|
2497
2507
|
refreshShellHeader() {
|
|
2498
|
-
this.#
|
|
2508
|
+
this.#g();
|
|
2499
2509
|
}
|
|
2500
2510
|
/**
|
|
2501
2511
|
* Internal shell header refresh.
|
|
2502
2512
|
*/
|
|
2503
|
-
#
|
|
2504
|
-
|
|
2513
|
+
#g() {
|
|
2514
|
+
te(this, this.#e), this.#X(), this.#G();
|
|
2505
2515
|
}
|
|
2506
2516
|
// ---------------- Virtual Window ----------------
|
|
2507
2517
|
/**
|
|
@@ -2512,40 +2522,40 @@ class V extends HTMLElement {
|
|
|
2512
2522
|
if (!this.bodyEl) return;
|
|
2513
2523
|
const o = this._rows.length;
|
|
2514
2524
|
if (!this.virtualization.enabled) {
|
|
2515
|
-
this.#
|
|
2525
|
+
this.#z(0, o), this.#w();
|
|
2516
2526
|
return;
|
|
2517
2527
|
}
|
|
2518
|
-
if (this.#
|
|
2519
|
-
this.virtualization.start = 0, this.virtualization.end = o, this.bodyEl.style.transform = "translateY(0px)", this.#
|
|
2520
|
-
const
|
|
2521
|
-
|
|
2528
|
+
if (this.#se()) {
|
|
2529
|
+
this.virtualization.start = 0, this.virtualization.end = o, this.bodyEl.style.transform = "translateY(0px)", this.#z(0, o, this.__rowRenderEpoch), this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${o * this.virtualization.rowHeight}px`);
|
|
2530
|
+
const R = this.#n.querySelector(".rows-body");
|
|
2531
|
+
R?.setAttribute("aria-rowcount", String(o)), R?.setAttribute("aria-colcount", String(this.visibleColumns.length)), this.#w();
|
|
2522
2532
|
return;
|
|
2523
2533
|
}
|
|
2524
|
-
const n = this.virtualization.container ?? this,
|
|
2534
|
+
const n = this.virtualization.container ?? this, s = (this.virtualization.viewportEl ?? n).clientHeight, r = this.virtualization.rowHeight, l = n.scrollTop;
|
|
2525
2535
|
let a = Math.floor(l / r), d = 0;
|
|
2526
2536
|
const h = 10;
|
|
2527
2537
|
for (; d < h; ) {
|
|
2528
|
-
const
|
|
2538
|
+
const R = this.#t?.getExtraHeightBefore?.(a) ?? 0, T = Math.floor((l - R) / r);
|
|
2529
2539
|
if (T >= a || T < 0) break;
|
|
2530
2540
|
a = T, d++;
|
|
2531
2541
|
}
|
|
2532
2542
|
a = a - a % 2, a < 0 && (a = 0);
|
|
2533
|
-
const p = this.#
|
|
2543
|
+
const p = this.#t?.adjustVirtualStart(a, l, r);
|
|
2534
2544
|
p !== void 0 && p < a && (a = p, a = a - a % 2, a < 0 && (a = 0));
|
|
2535
|
-
const
|
|
2536
|
-
let c = a +
|
|
2545
|
+
const b = Math.ceil(s / r) + 3;
|
|
2546
|
+
let c = a + b;
|
|
2537
2547
|
c > o && (c = o), this.virtualization.start = a, this.virtualization.end = c;
|
|
2538
|
-
const f = this.#
|
|
2539
|
-
this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${o * r + r + f +
|
|
2540
|
-
const
|
|
2541
|
-
this.bodyEl.style.transform = `translateY(${
|
|
2542
|
-
const
|
|
2543
|
-
|
|
2548
|
+
const f = this.#n.querySelector(".tbw-footer")?.offsetHeight ?? 0, w = this.#t?.getExtraHeight() ?? 0;
|
|
2549
|
+
this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${o * r + r + f + w}px`);
|
|
2550
|
+
const v = this.#t?.getExtraHeightBefore?.(a) ?? 0, S = -(l - a * r - v);
|
|
2551
|
+
this.bodyEl.style.transform = `translateY(${S}px)`, this.#z(a, c, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch);
|
|
2552
|
+
const x = this.#n.querySelector(".rows-body");
|
|
2553
|
+
x?.setAttribute("aria-rowcount", String(o)), x?.setAttribute("aria-colcount", String(this.visibleColumns.length)), e && this.#w();
|
|
2544
2554
|
}
|
|
2545
2555
|
// ---------------- Render ----------------
|
|
2546
|
-
#
|
|
2547
|
-
|
|
2548
|
-
const e = this.#
|
|
2556
|
+
#X() {
|
|
2557
|
+
te(this, this.#e);
|
|
2558
|
+
const e = this.#o?.shell, o = qe(e, this.#e), n = `
|
|
2549
2559
|
<div class="tbw-scroll-area">
|
|
2550
2560
|
<div class="rows-body-wrapper">
|
|
2551
2561
|
<div class="rows-body" role="grid">
|
|
@@ -2565,18 +2575,18 @@ class V extends HTMLElement {
|
|
|
2565
2575
|
</div>
|
|
2566
2576
|
`;
|
|
2567
2577
|
if (o) {
|
|
2568
|
-
const
|
|
2569
|
-
expand: this.#
|
|
2570
|
-
collapse: this.#
|
|
2571
|
-
}, r =
|
|
2572
|
-
this.#
|
|
2578
|
+
const i = this.#o?.icons?.toolPanel ?? P.toolPanel, s = {
|
|
2579
|
+
expand: this.#o?.icons?.expand ?? P.expand,
|
|
2580
|
+
collapse: this.#o?.icons?.collapse ?? P.collapse
|
|
2581
|
+
}, r = $e(e, this.#e, i), l = Ie(e, this.#e, n, s);
|
|
2582
|
+
this.#n.innerHTML = `
|
|
2573
2583
|
<div class="tbw-grid-root has-shell">
|
|
2574
2584
|
${r}
|
|
2575
2585
|
${l}
|
|
2576
2586
|
</div>
|
|
2577
|
-
`, this.#
|
|
2587
|
+
`, this.#he(), this.#a = !0;
|
|
2578
2588
|
} else
|
|
2579
|
-
this.#
|
|
2589
|
+
this.#n.innerHTML = `
|
|
2580
2590
|
<div class="tbw-grid-root">
|
|
2581
2591
|
<div class="tbw-grid-content">
|
|
2582
2592
|
${n}
|
|
@@ -2587,12 +2597,12 @@ class V extends HTMLElement {
|
|
|
2587
2597
|
/**
|
|
2588
2598
|
* Set up shell event listeners after render.
|
|
2589
2599
|
*/
|
|
2590
|
-
#
|
|
2591
|
-
|
|
2600
|
+
#he() {
|
|
2601
|
+
Be(this.#n, this.#o?.shell, this.#e, {
|
|
2592
2602
|
onPanelToggle: () => this.toggleToolPanel(),
|
|
2593
2603
|
onSectionToggle: (e) => this.toggleToolPanelSection(e),
|
|
2594
2604
|
onToolbarButtonClick: (e) => this.#fe(e)
|
|
2595
|
-
}), this.#
|
|
2605
|
+
}), this.#A?.(), this.#A = Ve(this.#n, this.#o?.shell, (e) => {
|
|
2596
2606
|
this.style.setProperty("--tbw-tool-panel-width", `${e}px`);
|
|
2597
2607
|
});
|
|
2598
2608
|
}
|
|
@@ -2600,17 +2610,17 @@ class V extends HTMLElement {
|
|
|
2600
2610
|
* Handle toolbar button click (for config buttons with action).
|
|
2601
2611
|
*/
|
|
2602
2612
|
#fe(e) {
|
|
2603
|
-
const n = (this.#
|
|
2613
|
+
const n = (this.#o?.shell?.header?.toolbarButtons ?? []).find((s) => s.id === e);
|
|
2604
2614
|
if (n?.action) {
|
|
2605
2615
|
n.action();
|
|
2606
2616
|
return;
|
|
2607
2617
|
}
|
|
2608
|
-
const
|
|
2609
|
-
|
|
2618
|
+
const i = this.#e.toolbarButtons.get(e);
|
|
2619
|
+
i?.action && i.action();
|
|
2610
2620
|
}
|
|
2611
2621
|
}
|
|
2612
|
-
customElements.get(
|
|
2613
|
-
class
|
|
2622
|
+
customElements.get(I.tagName) || customElements.define(I.tagName, I);
|
|
2623
|
+
class Ke {
|
|
2614
2624
|
/** Plugin version - override in subclass if needed */
|
|
2615
2625
|
version = "1.0.0";
|
|
2616
2626
|
/** CSS styles to inject into the grid's shadow DOM */
|
|
@@ -2764,541 +2774,9 @@ class me {
|
|
|
2764
2774
|
warn(e) {
|
|
2765
2775
|
console.warn(`[tbw-grid:${this.name}] ${e}`);
|
|
2766
2776
|
}
|
|
2777
|
+
// #endregion
|
|
2767
2778
|
}
|
|
2768
|
-
|
|
2769
|
-
return {
|
|
2770
|
-
startRow: Math.min(t.startRow, t.endRow),
|
|
2771
|
-
startCol: Math.min(t.startCol, t.endCol),
|
|
2772
|
-
endRow: Math.max(t.startRow, t.endRow),
|
|
2773
|
-
endCol: Math.max(t.startCol, t.endCol)
|
|
2774
|
-
};
|
|
2775
|
-
}
|
|
2776
|
-
function st(t) {
|
|
2777
|
-
const e = W(t);
|
|
2778
|
-
return {
|
|
2779
|
-
from: { row: e.startRow, col: e.startCol },
|
|
2780
|
-
to: { row: e.endRow, col: e.endCol }
|
|
2781
|
-
};
|
|
2782
|
-
}
|
|
2783
|
-
function Y(t) {
|
|
2784
|
-
return t.map(st);
|
|
2785
|
-
}
|
|
2786
|
-
function it(t, e, o) {
|
|
2787
|
-
const n = W(o);
|
|
2788
|
-
return t >= n.startRow && t <= n.endRow && e >= n.startCol && e <= n.endCol;
|
|
2789
|
-
}
|
|
2790
|
-
function de(t, e, o) {
|
|
2791
|
-
return o.some((n) => it(t, e, n));
|
|
2792
|
-
}
|
|
2793
|
-
function rt(t) {
|
|
2794
|
-
const e = [], o = W(t);
|
|
2795
|
-
for (let n = o.startRow; n <= o.endRow; n++)
|
|
2796
|
-
for (let s = o.startCol; s <= o.endCol; s++)
|
|
2797
|
-
e.push({ row: n, col: s });
|
|
2798
|
-
return e;
|
|
2799
|
-
}
|
|
2800
|
-
function lt(t) {
|
|
2801
|
-
const e = /* @__PURE__ */ new Map();
|
|
2802
|
-
for (const o of t)
|
|
2803
|
-
for (const n of rt(o))
|
|
2804
|
-
e.set(`${n.row},${n.col}`, n);
|
|
2805
|
-
return [...e.values()];
|
|
2806
|
-
}
|
|
2807
|
-
function G(t, e) {
|
|
2808
|
-
return {
|
|
2809
|
-
startRow: t.row,
|
|
2810
|
-
startCol: t.col,
|
|
2811
|
-
endRow: e.row,
|
|
2812
|
-
endCol: e.col
|
|
2813
|
-
};
|
|
2814
|
-
}
|
|
2815
|
-
const at = ':host .selecting .data-grid-row>.cell{user-select:none}:host .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}:host([data-selection-mode="row"]) .cell-focus{outline:none}:host .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}:host .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}';
|
|
2816
|
-
function ct(t, e, o) {
|
|
2817
|
-
if (t === "cell" && e.selectedCell)
|
|
2818
|
-
return {
|
|
2819
|
-
mode: t,
|
|
2820
|
-
ranges: [
|
|
2821
|
-
{
|
|
2822
|
-
from: { row: e.selectedCell.row, col: e.selectedCell.col },
|
|
2823
|
-
to: { row: e.selectedCell.row, col: e.selectedCell.col }
|
|
2824
|
-
}
|
|
2825
|
-
]
|
|
2826
|
-
};
|
|
2827
|
-
if (t === "row" && e.selected.size > 0) {
|
|
2828
|
-
const n = [...e.selected].map((s) => ({
|
|
2829
|
-
from: { row: s, col: 0 },
|
|
2830
|
-
to: { row: s, col: o - 1 }
|
|
2831
|
-
}));
|
|
2832
|
-
return { mode: t, ranges: n };
|
|
2833
|
-
}
|
|
2834
|
-
return t === "range" && e.ranges.length > 0 ? { mode: t, ranges: Y(e.ranges) } : { mode: t, ranges: [] };
|
|
2835
|
-
}
|
|
2836
|
-
class wt extends me {
|
|
2837
|
-
name = "selection";
|
|
2838
|
-
version = "1.0.0";
|
|
2839
|
-
get defaultConfig() {
|
|
2840
|
-
return {
|
|
2841
|
-
mode: "cell"
|
|
2842
|
-
};
|
|
2843
|
-
}
|
|
2844
|
-
// ===== Internal State =====
|
|
2845
|
-
/** Row selection state (row mode) */
|
|
2846
|
-
selected = /* @__PURE__ */ new Set();
|
|
2847
|
-
lastSelected = null;
|
|
2848
|
-
anchor = null;
|
|
2849
|
-
/** Range selection state (range mode) */
|
|
2850
|
-
ranges = [];
|
|
2851
|
-
activeRange = null;
|
|
2852
|
-
cellAnchor = null;
|
|
2853
|
-
isDragging = !1;
|
|
2854
|
-
/** Cell selection state (cell mode) */
|
|
2855
|
-
selectedCell = null;
|
|
2856
|
-
// ===== Lifecycle =====
|
|
2857
|
-
detach() {
|
|
2858
|
-
this.selected.clear(), this.ranges = [], this.activeRange = null, this.cellAnchor = null, this.isDragging = !1, this.selectedCell = null;
|
|
2859
|
-
}
|
|
2860
|
-
// ===== Event Handlers =====
|
|
2861
|
-
onCellClick(e) {
|
|
2862
|
-
const { rowIndex: o, colIndex: n, originalEvent: s } = e, { mode: i } = this.config;
|
|
2863
|
-
if (i === "cell")
|
|
2864
|
-
return this.selectedCell = { row: o, col: n }, this.emit("selection-change", this.#s()), this.requestAfterRender(), !1;
|
|
2865
|
-
if (i === "row")
|
|
2866
|
-
return this.selected.clear(), this.selected.add(o), this.lastSelected = o, this.emit("selection-change", this.#s()), this.requestAfterRender(), !1;
|
|
2867
|
-
if (i === "range") {
|
|
2868
|
-
const r = s.shiftKey, l = s.ctrlKey || s.metaKey;
|
|
2869
|
-
if (r && this.cellAnchor) {
|
|
2870
|
-
const a = G(this.cellAnchor, { row: o, col: n });
|
|
2871
|
-
l ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = a : this.ranges.push(a) : this.ranges = [a], this.activeRange = a;
|
|
2872
|
-
} else if (l) {
|
|
2873
|
-
const a = {
|
|
2874
|
-
startRow: o,
|
|
2875
|
-
startCol: n,
|
|
2876
|
-
endRow: o,
|
|
2877
|
-
endCol: n
|
|
2878
|
-
};
|
|
2879
|
-
this.ranges.push(a), this.activeRange = a, this.cellAnchor = { row: o, col: n };
|
|
2880
|
-
} else {
|
|
2881
|
-
const a = {
|
|
2882
|
-
startRow: o,
|
|
2883
|
-
startCol: n,
|
|
2884
|
-
endRow: o,
|
|
2885
|
-
endCol: n
|
|
2886
|
-
};
|
|
2887
|
-
this.ranges = [a], this.activeRange = a, this.cellAnchor = { row: o, col: n };
|
|
2888
|
-
}
|
|
2889
|
-
return this.emit("selection-change", this.#s()), this.requestAfterRender(), !1;
|
|
2890
|
-
}
|
|
2891
|
-
return !1;
|
|
2892
|
-
}
|
|
2893
|
-
onKeyDown(e) {
|
|
2894
|
-
const { mode: o } = this.config, s = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
|
|
2895
|
-
if (e.key === "Escape")
|
|
2896
|
-
return o === "cell" ? this.selectedCell = null : o === "row" ? (this.selected.clear(), this.anchor = null) : o === "range" && (this.ranges = [], this.activeRange = null, this.cellAnchor = null), this.emit("selection-change", this.#s()), this.requestAfterRender(), !0;
|
|
2897
|
-
if (o === "cell" && s)
|
|
2898
|
-
return queueMicrotask(() => {
|
|
2899
|
-
const i = this.grid;
|
|
2900
|
-
this.selectedCell = { row: i.focusRow, col: i.focusCol }, this.emit("selection-change", this.#s()), this.requestAfterRender();
|
|
2901
|
-
}), !1;
|
|
2902
|
-
if (o === "row" && (e.key === "ArrowUp" || e.key === "ArrowDown"))
|
|
2903
|
-
return queueMicrotask(() => {
|
|
2904
|
-
const i = this.grid;
|
|
2905
|
-
this.selected.clear(), this.selected.add(i.focusRow), this.lastSelected = i.focusRow, this.emit("selection-change", this.#s()), this.requestAfterRender();
|
|
2906
|
-
}), !1;
|
|
2907
|
-
if (o === "range" && s) {
|
|
2908
|
-
const i = e.shiftKey;
|
|
2909
|
-
return queueMicrotask(() => {
|
|
2910
|
-
const r = this.grid, l = r.focusRow, a = r.focusCol;
|
|
2911
|
-
if (i) {
|
|
2912
|
-
this.cellAnchor || (this.cellAnchor = { row: l, col: a });
|
|
2913
|
-
const d = G(this.cellAnchor, { row: l, col: a });
|
|
2914
|
-
this.ranges = [d], this.activeRange = d;
|
|
2915
|
-
} else
|
|
2916
|
-
this.ranges = [], this.activeRange = null, this.cellAnchor = { row: l, col: a };
|
|
2917
|
-
this.emit("selection-change", this.#s()), this.requestAfterRender();
|
|
2918
|
-
}), !1;
|
|
2919
|
-
}
|
|
2920
|
-
if (o === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
|
|
2921
|
-
const i = this.rows.length, r = this.columns.length;
|
|
2922
|
-
if (i > 0 && r > 0) {
|
|
2923
|
-
const l = {
|
|
2924
|
-
startRow: 0,
|
|
2925
|
-
startCol: 0,
|
|
2926
|
-
endRow: i - 1,
|
|
2927
|
-
endCol: r - 1
|
|
2928
|
-
};
|
|
2929
|
-
return this.ranges = [l], this.activeRange = l, this.emit("selection-change", this.#s()), this.requestAfterRender(), !0;
|
|
2930
|
-
}
|
|
2931
|
-
}
|
|
2932
|
-
return !1;
|
|
2933
|
-
}
|
|
2934
|
-
onCellMouseDown(e) {
|
|
2935
|
-
if (this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0 || e.originalEvent.shiftKey && this.cellAnchor)
|
|
2936
|
-
return;
|
|
2937
|
-
this.isDragging = !0;
|
|
2938
|
-
const o = e.rowIndex, n = e.colIndex;
|
|
2939
|
-
this.cellAnchor = { row: o, col: n }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
|
|
2940
|
-
const i = {
|
|
2941
|
-
startRow: o,
|
|
2942
|
-
startCol: n,
|
|
2943
|
-
endRow: o,
|
|
2944
|
-
endCol: n
|
|
2945
|
-
};
|
|
2946
|
-
return this.ranges.push(i), this.activeRange = i, this.emit("selection-change", this.#s()), this.requestAfterRender(), !0;
|
|
2947
|
-
}
|
|
2948
|
-
onCellMouseMove(e) {
|
|
2949
|
-
if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
2950
|
-
const o = G(this.cellAnchor, { row: e.rowIndex, col: e.colIndex });
|
|
2951
|
-
return this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = o : this.ranges.push(o), this.activeRange = o, this.emit("selection-change", this.#s()), this.requestAfterRender(), !0;
|
|
2952
|
-
}
|
|
2953
|
-
onCellMouseUp(e) {
|
|
2954
|
-
if (this.config.mode === "range" && this.isDragging)
|
|
2955
|
-
return this.isDragging = !1, !0;
|
|
2956
|
-
}
|
|
2957
|
-
/**
|
|
2958
|
-
* Apply selection classes to visible cells/rows.
|
|
2959
|
-
* Shared by afterRender and onScrollRender.
|
|
2960
|
-
*/
|
|
2961
|
-
#t() {
|
|
2962
|
-
const e = this.shadowRoot;
|
|
2963
|
-
if (!e) return;
|
|
2964
|
-
const { mode: o } = this.config;
|
|
2965
|
-
e.querySelectorAll(".cell").forEach((i) => {
|
|
2966
|
-
i.classList.remove("selected", "top", "bottom", "first", "last");
|
|
2967
|
-
});
|
|
2968
|
-
const s = e.querySelectorAll(".data-grid-row");
|
|
2969
|
-
if (s.forEach((i) => {
|
|
2970
|
-
i.classList.remove("selected", "row-focus");
|
|
2971
|
-
}), o === "row" && (e.querySelectorAll(".cell-focus").forEach((i) => i.classList.remove("cell-focus")), s.forEach((i) => {
|
|
2972
|
-
const r = i.querySelector(".cell[data-row]"), l = parseInt(r?.getAttribute("data-row") ?? "-1", 10);
|
|
2973
|
-
l >= 0 && this.selected.has(l) && i.classList.add("selected", "row-focus");
|
|
2974
|
-
})), o === "range" && this.ranges.length > 0) {
|
|
2975
|
-
const i = this.activeRange ? W(this.activeRange) : null;
|
|
2976
|
-
e.querySelectorAll(".cell[data-row][data-col]").forEach((l) => {
|
|
2977
|
-
const a = parseInt(l.getAttribute("data-row") ?? "-1", 10), d = parseInt(l.getAttribute("data-col") ?? "-1", 10);
|
|
2978
|
-
a >= 0 && d >= 0 && de(a, d, this.ranges) && (l.classList.add("selected"), l.classList.remove("cell-focus"), i && (a === i.startRow && l.classList.add("top"), a === i.endRow && l.classList.add("bottom"), d === i.startCol && l.classList.add("first"), d === i.endCol && l.classList.add("last")));
|
|
2979
|
-
});
|
|
2980
|
-
}
|
|
2981
|
-
o === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((i) => i.classList.remove("cell-focus"));
|
|
2982
|
-
}
|
|
2983
|
-
afterRender() {
|
|
2984
|
-
const e = this.shadowRoot;
|
|
2985
|
-
if (!e) return;
|
|
2986
|
-
const o = e.children[0], { mode: n } = this.config;
|
|
2987
|
-
this.grid.setAttribute("data-selection-mode", n), o && o.classList.toggle("selecting", this.isDragging), this.#t();
|
|
2988
|
-
}
|
|
2989
|
-
/**
|
|
2990
|
-
* Called after scroll-triggered row rendering.
|
|
2991
|
-
* Reapplies selection classes to recycled DOM elements.
|
|
2992
|
-
*/
|
|
2993
|
-
onScrollRender() {
|
|
2994
|
-
this.#t();
|
|
2995
|
-
}
|
|
2996
|
-
// ===== Public API =====
|
|
2997
|
-
/**
|
|
2998
|
-
* Get the selected cell (cell mode only).
|
|
2999
|
-
*/
|
|
3000
|
-
getSelectedCell() {
|
|
3001
|
-
return this.selectedCell;
|
|
3002
|
-
}
|
|
3003
|
-
/**
|
|
3004
|
-
* Get all selected row indices (row mode).
|
|
3005
|
-
*/
|
|
3006
|
-
getSelectedRows() {
|
|
3007
|
-
return [...this.selected];
|
|
3008
|
-
}
|
|
3009
|
-
/**
|
|
3010
|
-
* Get all selected cell ranges in public format.
|
|
3011
|
-
*/
|
|
3012
|
-
getRanges() {
|
|
3013
|
-
return Y(this.ranges);
|
|
3014
|
-
}
|
|
3015
|
-
/**
|
|
3016
|
-
* Get all selected cells across all ranges.
|
|
3017
|
-
*/
|
|
3018
|
-
getSelectedCells() {
|
|
3019
|
-
return lt(this.ranges);
|
|
3020
|
-
}
|
|
3021
|
-
/**
|
|
3022
|
-
* Check if a specific cell is in range selection.
|
|
3023
|
-
*/
|
|
3024
|
-
isCellSelected(e, o) {
|
|
3025
|
-
return de(e, o, this.ranges);
|
|
3026
|
-
}
|
|
3027
|
-
/**
|
|
3028
|
-
* Clear all selection.
|
|
3029
|
-
*/
|
|
3030
|
-
clearSelection() {
|
|
3031
|
-
this.selectedCell = null, this.selected.clear(), this.anchor = null, this.ranges = [], this.activeRange = null, this.cellAnchor = null, this.emit("selection-change", { mode: this.config.mode, ranges: [] }), this.requestAfterRender();
|
|
3032
|
-
}
|
|
3033
|
-
/**
|
|
3034
|
-
* Set selected ranges programmatically.
|
|
3035
|
-
*/
|
|
3036
|
-
setRanges(e) {
|
|
3037
|
-
this.ranges = e.map((o) => ({
|
|
3038
|
-
startRow: o.from.row,
|
|
3039
|
-
startCol: o.from.col,
|
|
3040
|
-
endRow: o.to.row,
|
|
3041
|
-
endCol: o.to.col
|
|
3042
|
-
})), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
|
|
3043
|
-
mode: this.config.mode,
|
|
3044
|
-
ranges: Y(this.ranges)
|
|
3045
|
-
}), this.requestAfterRender();
|
|
3046
|
-
}
|
|
3047
|
-
// ===== Private Helpers =====
|
|
3048
|
-
#s() {
|
|
3049
|
-
return ct(
|
|
3050
|
-
this.config.mode,
|
|
3051
|
-
{
|
|
3052
|
-
selectedCell: this.selectedCell,
|
|
3053
|
-
selected: this.selected,
|
|
3054
|
-
ranges: this.ranges
|
|
3055
|
-
},
|
|
3056
|
-
this.columns.length
|
|
3057
|
-
);
|
|
3058
|
-
}
|
|
3059
|
-
// ===== Styles =====
|
|
3060
|
-
styles = at;
|
|
3061
|
-
}
|
|
3062
|
-
function ee(t, e, o) {
|
|
3063
|
-
return t.id !== void 0 ? String(t.id) : o ? `${o}-${e}` : String(e);
|
|
3064
|
-
}
|
|
3065
|
-
function ve(t, e, o, n = null, s = 0) {
|
|
3066
|
-
const i = e.childrenField ?? "children", r = [];
|
|
3067
|
-
for (let l = 0; l < t.length; l++) {
|
|
3068
|
-
const a = t[l], d = ee(a, l, n), h = a[i], p = Array.isArray(h) && h.length > 0, w = o.has(d);
|
|
3069
|
-
if (r.push({
|
|
3070
|
-
key: d,
|
|
3071
|
-
data: a,
|
|
3072
|
-
depth: s,
|
|
3073
|
-
hasChildren: p,
|
|
3074
|
-
isExpanded: w,
|
|
3075
|
-
parentKey: n
|
|
3076
|
-
}), p && w) {
|
|
3077
|
-
const c = ve(h, e, o, d, s + 1);
|
|
3078
|
-
r.push(...c);
|
|
3079
|
-
}
|
|
3080
|
-
}
|
|
3081
|
-
return r;
|
|
3082
|
-
}
|
|
3083
|
-
function he(t, e) {
|
|
3084
|
-
const o = new Set(t);
|
|
3085
|
-
return o.has(e) ? o.delete(e) : o.add(e), o;
|
|
3086
|
-
}
|
|
3087
|
-
function Z(t, e, o = null, n = 0) {
|
|
3088
|
-
const s = e.childrenField ?? "children", i = /* @__PURE__ */ new Set();
|
|
3089
|
-
for (let r = 0; r < t.length; r++) {
|
|
3090
|
-
const l = t[r], a = ee(l, r, o), d = l[s];
|
|
3091
|
-
if (Array.isArray(d) && d.length > 0) {
|
|
3092
|
-
i.add(a);
|
|
3093
|
-
const h = Z(d, e, a, n + 1);
|
|
3094
|
-
for (const p of h) i.add(p);
|
|
3095
|
-
}
|
|
3096
|
-
}
|
|
3097
|
-
return i;
|
|
3098
|
-
}
|
|
3099
|
-
function dt() {
|
|
3100
|
-
return /* @__PURE__ */ new Set();
|
|
3101
|
-
}
|
|
3102
|
-
function ye(t, e, o, n = null, s = 0) {
|
|
3103
|
-
const i = o.childrenField ?? "children";
|
|
3104
|
-
for (let r = 0; r < t.length; r++) {
|
|
3105
|
-
const l = t[r], a = ee(l, r, n);
|
|
3106
|
-
if (a === e)
|
|
3107
|
-
return [a];
|
|
3108
|
-
const d = l[i];
|
|
3109
|
-
if (Array.isArray(d) && d.length > 0) {
|
|
3110
|
-
const h = ye(d, e, o, a, s + 1);
|
|
3111
|
-
if (h)
|
|
3112
|
-
return [a, ...h];
|
|
3113
|
-
}
|
|
3114
|
-
}
|
|
3115
|
-
return null;
|
|
3116
|
-
}
|
|
3117
|
-
function ht(t, e, o, n) {
|
|
3118
|
-
const s = ye(t, e, o);
|
|
3119
|
-
if (!s) return n;
|
|
3120
|
-
const i = new Set(n);
|
|
3121
|
-
for (let r = 0; r < s.length - 1; r++)
|
|
3122
|
-
i.add(s[r]);
|
|
3123
|
-
return i;
|
|
3124
|
-
}
|
|
3125
|
-
function ue(t, e = "children") {
|
|
3126
|
-
if (!Array.isArray(t) || t.length === 0) return !1;
|
|
3127
|
-
for (const o of t)
|
|
3128
|
-
if (o && Array.isArray(o[e]) && o[e].length > 0)
|
|
3129
|
-
return !0;
|
|
3130
|
-
return !1;
|
|
3131
|
-
}
|
|
3132
|
-
function ut(t) {
|
|
3133
|
-
if (!Array.isArray(t) || t.length === 0) return null;
|
|
3134
|
-
const e = ["children", "items", "nodes", "subRows", "nested"];
|
|
3135
|
-
for (const o of t)
|
|
3136
|
-
if (!(!o || typeof o != "object")) {
|
|
3137
|
-
for (const n of e)
|
|
3138
|
-
if (Array.isArray(o[n]) && o[n].length > 0)
|
|
3139
|
-
return n;
|
|
3140
|
-
}
|
|
3141
|
-
return null;
|
|
3142
|
-
}
|
|
3143
|
-
const ft = ".tree-toggle{cursor:pointer;user-select:none;transition:transform .2s}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}";
|
|
3144
|
-
class gt extends me {
|
|
3145
|
-
name = "tree";
|
|
3146
|
-
version = "1.0.0";
|
|
3147
|
-
get defaultConfig() {
|
|
3148
|
-
return {
|
|
3149
|
-
childrenField: "children",
|
|
3150
|
-
autoDetect: !0,
|
|
3151
|
-
defaultExpanded: !1,
|
|
3152
|
-
indentWidth: 20,
|
|
3153
|
-
showExpandIcons: !0
|
|
3154
|
-
};
|
|
3155
|
-
}
|
|
3156
|
-
// ===== Internal State =====
|
|
3157
|
-
/** Set of expanded row keys */
|
|
3158
|
-
expandedKeys = /* @__PURE__ */ new Set();
|
|
3159
|
-
/** Whether initial expansion (based on defaultExpanded config) has been applied */
|
|
3160
|
-
initialExpansionDone = !1;
|
|
3161
|
-
/** Flattened tree rows for rendering */
|
|
3162
|
-
flattenedRows = [];
|
|
3163
|
-
/** Map from key to flattened row for quick lookup */
|
|
3164
|
-
rowKeyMap = /* @__PURE__ */ new Map();
|
|
3165
|
-
// ===== Lifecycle =====
|
|
3166
|
-
detach() {
|
|
3167
|
-
this.expandedKeys.clear(), this.initialExpansionDone = !1, this.flattenedRows = [], this.rowKeyMap.clear();
|
|
3168
|
-
}
|
|
3169
|
-
// ===== Auto-Detection =====
|
|
3170
|
-
/**
|
|
3171
|
-
* Detects if tree functionality should be enabled based on data structure.
|
|
3172
|
-
* Called by the grid during plugin initialization.
|
|
3173
|
-
*/
|
|
3174
|
-
detect(e) {
|
|
3175
|
-
if (!this.config.autoDetect) return !1;
|
|
3176
|
-
const o = this.config.childrenField ?? ut(e) ?? "children";
|
|
3177
|
-
return ue(e, o);
|
|
3178
|
-
}
|
|
3179
|
-
// ===== Data Processing =====
|
|
3180
|
-
processRows(e) {
|
|
3181
|
-
const o = this.config.childrenField ?? "children";
|
|
3182
|
-
if (!ue(e, o))
|
|
3183
|
-
return this.flattenedRows = [], this.rowKeyMap.clear(), [...e];
|
|
3184
|
-
this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = Z(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = ve(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
|
|
3185
|
-
for (const n of this.flattenedRows)
|
|
3186
|
-
this.rowKeyMap.set(n.key, n);
|
|
3187
|
-
return this.flattenedRows.map((n) => ({
|
|
3188
|
-
...n.data,
|
|
3189
|
-
__treeKey: n.key,
|
|
3190
|
-
__treeDepth: n.depth,
|
|
3191
|
-
__treeHasChildren: n.hasChildren,
|
|
3192
|
-
__treeExpanded: n.isExpanded
|
|
3193
|
-
}));
|
|
3194
|
-
}
|
|
3195
|
-
processColumns(e) {
|
|
3196
|
-
if (this.flattenedRows.length === 0) return [...e];
|
|
3197
|
-
const o = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0, s = [...e];
|
|
3198
|
-
if (s.length > 0) {
|
|
3199
|
-
const i = { ...s[0] }, r = i.viewRenderer;
|
|
3200
|
-
if (r?.__treeWrapped)
|
|
3201
|
-
return s;
|
|
3202
|
-
const l = (a) => {
|
|
3203
|
-
const { value: d, row: h, column: p } = a, w = h.__treeDepth ?? 0, c = h.__treeHasChildren ?? !1, u = h.__treeExpanded ?? !1, f = document.createElement("span");
|
|
3204
|
-
if (f.style.display = "flex", f.style.alignItems = "center", f.style.paddingLeft = `${w * o}px`, c && n) {
|
|
3205
|
-
const b = document.createElement("span");
|
|
3206
|
-
b.className = "tree-toggle", this.setIcon(b, this.resolveIcon(u ? "collapse" : "expand")), b.style.cursor = "pointer", b.style.marginRight = "4px", b.style.fontSize = "10px", b.setAttribute("data-tree-key", h.__treeKey), f.appendChild(b);
|
|
3207
|
-
} else if (n) {
|
|
3208
|
-
const b = document.createElement("span");
|
|
3209
|
-
b.style.width = "14px", b.style.display = "inline-block", f.appendChild(b);
|
|
3210
|
-
}
|
|
3211
|
-
const g = document.createElement("span");
|
|
3212
|
-
if (r) {
|
|
3213
|
-
const b = r(a);
|
|
3214
|
-
b instanceof Node ? g.appendChild(b) : g.textContent = String(b ?? d ?? "");
|
|
3215
|
-
} else
|
|
3216
|
-
g.textContent = String(d ?? "");
|
|
3217
|
-
return f.appendChild(g), f;
|
|
3218
|
-
};
|
|
3219
|
-
l.__treeWrapped = !0, i.viewRenderer = l, s[0] = i;
|
|
3220
|
-
}
|
|
3221
|
-
return s;
|
|
3222
|
-
}
|
|
3223
|
-
// ===== Event Handlers =====
|
|
3224
|
-
onCellClick(e) {
|
|
3225
|
-
const o = e.originalEvent?.target;
|
|
3226
|
-
if (!o?.classList.contains("tree-toggle")) return !1;
|
|
3227
|
-
const n = o.getAttribute("data-tree-key");
|
|
3228
|
-
if (!n) return !1;
|
|
3229
|
-
const s = this.rowKeyMap.get(n);
|
|
3230
|
-
return s ? (this.expandedKeys = he(this.expandedKeys, n), this.emit("tree-expand", {
|
|
3231
|
-
key: n,
|
|
3232
|
-
row: s.data,
|
|
3233
|
-
expanded: this.expandedKeys.has(n),
|
|
3234
|
-
depth: s.depth
|
|
3235
|
-
}), this.requestRender(), !0) : !1;
|
|
3236
|
-
}
|
|
3237
|
-
// ===== Public API =====
|
|
3238
|
-
/**
|
|
3239
|
-
* Expand a specific node by key.
|
|
3240
|
-
*/
|
|
3241
|
-
expand(e) {
|
|
3242
|
-
this.expandedKeys.add(e), this.requestRender();
|
|
3243
|
-
}
|
|
3244
|
-
/**
|
|
3245
|
-
* Collapse a specific node by key.
|
|
3246
|
-
*/
|
|
3247
|
-
collapse(e) {
|
|
3248
|
-
this.expandedKeys.delete(e), this.requestRender();
|
|
3249
|
-
}
|
|
3250
|
-
/**
|
|
3251
|
-
* Toggle the expansion state of a node.
|
|
3252
|
-
*/
|
|
3253
|
-
toggle(e) {
|
|
3254
|
-
this.expandedKeys = he(this.expandedKeys, e), this.requestRender();
|
|
3255
|
-
}
|
|
3256
|
-
/**
|
|
3257
|
-
* Expand all nodes in the tree.
|
|
3258
|
-
*/
|
|
3259
|
-
expandAll() {
|
|
3260
|
-
this.expandedKeys = Z(this.rows, this.config), this.requestRender();
|
|
3261
|
-
}
|
|
3262
|
-
/**
|
|
3263
|
-
* Collapse all nodes in the tree.
|
|
3264
|
-
*/
|
|
3265
|
-
collapseAll() {
|
|
3266
|
-
this.expandedKeys = dt(), this.requestRender();
|
|
3267
|
-
}
|
|
3268
|
-
/**
|
|
3269
|
-
* Check if a node is currently expanded.
|
|
3270
|
-
*/
|
|
3271
|
-
isExpanded(e) {
|
|
3272
|
-
return this.expandedKeys.has(e);
|
|
3273
|
-
}
|
|
3274
|
-
/**
|
|
3275
|
-
* Get all currently expanded keys.
|
|
3276
|
-
*/
|
|
3277
|
-
getExpandedKeys() {
|
|
3278
|
-
return [...this.expandedKeys];
|
|
3279
|
-
}
|
|
3280
|
-
/**
|
|
3281
|
-
* Get the flattened tree rows with metadata.
|
|
3282
|
-
*/
|
|
3283
|
-
getFlattenedRows() {
|
|
3284
|
-
return [...this.flattenedRows];
|
|
3285
|
-
}
|
|
3286
|
-
/**
|
|
3287
|
-
* Get a row's original data by its key.
|
|
3288
|
-
*/
|
|
3289
|
-
getRowByKey(e) {
|
|
3290
|
-
return this.rowKeyMap.get(e)?.data;
|
|
3291
|
-
}
|
|
3292
|
-
/**
|
|
3293
|
-
* Expand all ancestors of a node to make it visible.
|
|
3294
|
-
*/
|
|
3295
|
-
expandToKey(e) {
|
|
3296
|
-
this.expandedKeys = ht(this.rows, e, this.config, this.expandedKeys), this.requestRender();
|
|
3297
|
-
}
|
|
3298
|
-
// ===== Styles =====
|
|
3299
|
-
styles = ft;
|
|
3300
|
-
}
|
|
3301
|
-
const S = {
|
|
2779
|
+
const A = {
|
|
3302
2780
|
// Root structure
|
|
3303
2781
|
ROOT: "tbw-grid-root",
|
|
3304
2782
|
HEADER: "header",
|
|
@@ -3343,31 +2821,31 @@ const S = {
|
|
|
3343
2821
|
// Selection
|
|
3344
2822
|
RANGE_SELECTION: "range-selection",
|
|
3345
2823
|
SELECTION_OVERLAY: "selection-overlay"
|
|
3346
|
-
},
|
|
2824
|
+
}, V = {
|
|
3347
2825
|
ROW_INDEX: "data-row-index",
|
|
3348
2826
|
COL_INDEX: "data-col-index",
|
|
3349
2827
|
FIELD: "data-field",
|
|
3350
2828
|
GROUP_KEY: "data-group-key",
|
|
3351
2829
|
TREE_LEVEL: "data-tree-level",
|
|
3352
2830
|
STICKY: "data-sticky"
|
|
3353
|
-
},
|
|
3354
|
-
ROOT: `.${
|
|
3355
|
-
HEADER: `.${
|
|
3356
|
-
HEADER_ROW: `.${
|
|
3357
|
-
HEADER_CELL: `.${
|
|
3358
|
-
ROWS_VIEWPORT: `.${
|
|
3359
|
-
ROWS_CONTAINER: `.${
|
|
3360
|
-
DATA_ROW: `.${
|
|
3361
|
-
DATA_CELL: `.${
|
|
3362
|
-
GROUP_ROW: `.${
|
|
2831
|
+
}, Ye = {
|
|
2832
|
+
ROOT: `.${A.ROOT}`,
|
|
2833
|
+
HEADER: `.${A.HEADER}`,
|
|
2834
|
+
HEADER_ROW: `.${A.HEADER_ROW}`,
|
|
2835
|
+
HEADER_CELL: `.${A.HEADER_CELL}`,
|
|
2836
|
+
ROWS_VIEWPORT: `.${A.ROWS_VIEWPORT}`,
|
|
2837
|
+
ROWS_CONTAINER: `.${A.ROWS_CONTAINER}`,
|
|
2838
|
+
DATA_ROW: `.${A.DATA_ROW}`,
|
|
2839
|
+
DATA_CELL: `.${A.DATA_CELL}`,
|
|
2840
|
+
GROUP_ROW: `.${A.GROUP_ROW}`,
|
|
3363
2841
|
// By data attribute
|
|
3364
|
-
ROW_BY_INDEX: (t) => `.${
|
|
3365
|
-
CELL_BY_FIELD: (t) => `.${
|
|
3366
|
-
CELL_AT: (t, e) => `.${
|
|
2842
|
+
ROW_BY_INDEX: (t) => `.${A.DATA_ROW}[${V.ROW_INDEX}="${t}"]`,
|
|
2843
|
+
CELL_BY_FIELD: (t) => `.${A.DATA_CELL}[${V.FIELD}="${t}"]`,
|
|
2844
|
+
CELL_AT: (t, e) => `.${A.DATA_ROW}[${V.ROW_INDEX}="${t}"] .${A.DATA_CELL}[${V.COL_INDEX}="${e}"]`,
|
|
3367
2845
|
// State selectors
|
|
3368
|
-
SELECTED_ROWS: `.${
|
|
3369
|
-
EDITING_CELL: `.${
|
|
3370
|
-
},
|
|
2846
|
+
SELECTED_ROWS: `.${A.DATA_ROW}.${A.SELECTED}`,
|
|
2847
|
+
EDITING_CELL: `.${A.DATA_CELL}.${A.EDITING}`
|
|
2848
|
+
}, Ze = {
|
|
3371
2849
|
// Colors
|
|
3372
2850
|
COLOR_BG: "--tbw-color-bg",
|
|
3373
2851
|
COLOR_FG: "--tbw-color-fg",
|
|
@@ -3389,7 +2867,7 @@ const S = {
|
|
|
3389
2867
|
// Borders
|
|
3390
2868
|
BORDER_RADIUS: "--tbw-border-radius",
|
|
3391
2869
|
FOCUS_OUTLINE: "--tbw-focus-outline"
|
|
3392
|
-
},
|
|
2870
|
+
}, Je = {
|
|
3393
2871
|
CELL_COMMIT: "cell-commit",
|
|
3394
2872
|
ROW_COMMIT: "row-commit",
|
|
3395
2873
|
CHANGED_ROWS_RESET: "changed-rows-reset",
|
|
@@ -3400,7 +2878,7 @@ const S = {
|
|
|
3400
2878
|
ACTIVATE_CELL: "activate-cell",
|
|
3401
2879
|
GROUP_TOGGLE: "group-toggle",
|
|
3402
2880
|
COLUMN_STATE_CHANGE: "column-state-change"
|
|
3403
|
-
},
|
|
2881
|
+
}, Qe = {
|
|
3404
2882
|
// Selection plugin
|
|
3405
2883
|
SELECTION_CHANGE: "selection-change",
|
|
3406
2884
|
// Tree plugin
|
|
@@ -3431,10 +2909,10 @@ const S = {
|
|
|
3431
2909
|
DETAIL_EXPAND: "detail-expand",
|
|
3432
2910
|
// Grouping rows plugin
|
|
3433
2911
|
GROUP_EXPAND: "group-expand"
|
|
3434
|
-
},
|
|
2912
|
+
}, F = {
|
|
3435
2913
|
sum: (t, e) => t.reduce((o, n) => o + (Number(n[e]) || 0), 0),
|
|
3436
2914
|
avg: (t, e) => {
|
|
3437
|
-
const o = t.reduce((n,
|
|
2915
|
+
const o = t.reduce((n, i) => n + (Number(i[e]) || 0), 0);
|
|
3438
2916
|
return t.length ? o / t.length : 0;
|
|
3439
2917
|
},
|
|
3440
2918
|
count: (t) => t.length,
|
|
@@ -3442,46 +2920,46 @@ const S = {
|
|
|
3442
2920
|
max: (t, e) => Math.max(...t.map((o) => Number(o[e]) || -1 / 0)),
|
|
3443
2921
|
first: (t, e) => t[0]?.[e],
|
|
3444
2922
|
last: (t, e) => t[t.length - 1]?.[e]
|
|
3445
|
-
},
|
|
2923
|
+
}, D = /* @__PURE__ */ new Map(), H = {
|
|
3446
2924
|
/**
|
|
3447
2925
|
* Register a custom aggregator function.
|
|
3448
2926
|
*/
|
|
3449
2927
|
register(t, e) {
|
|
3450
|
-
|
|
2928
|
+
D.set(t, e);
|
|
3451
2929
|
},
|
|
3452
2930
|
/**
|
|
3453
2931
|
* Unregister a custom aggregator function.
|
|
3454
2932
|
*/
|
|
3455
2933
|
unregister(t) {
|
|
3456
|
-
|
|
2934
|
+
D.delete(t);
|
|
3457
2935
|
},
|
|
3458
2936
|
/**
|
|
3459
2937
|
* Get an aggregator function by reference.
|
|
3460
2938
|
*/
|
|
3461
2939
|
get(t) {
|
|
3462
2940
|
if (t !== void 0)
|
|
3463
|
-
return typeof t == "function" ? t :
|
|
2941
|
+
return typeof t == "function" ? t : D.get(t) ?? F[t];
|
|
3464
2942
|
},
|
|
3465
2943
|
/**
|
|
3466
2944
|
* Run an aggregator on a set of rows.
|
|
3467
2945
|
*/
|
|
3468
2946
|
run(t, e, o, n) {
|
|
3469
|
-
const
|
|
3470
|
-
return
|
|
2947
|
+
const i = this.get(t);
|
|
2948
|
+
return i ? i(e, o, n) : void 0;
|
|
3471
2949
|
},
|
|
3472
2950
|
/**
|
|
3473
2951
|
* Check if an aggregator exists.
|
|
3474
2952
|
*/
|
|
3475
2953
|
has(t) {
|
|
3476
|
-
return
|
|
2954
|
+
return D.has(t) || t in F;
|
|
3477
2955
|
},
|
|
3478
2956
|
/**
|
|
3479
2957
|
* List all available aggregator names.
|
|
3480
2958
|
*/
|
|
3481
2959
|
list() {
|
|
3482
|
-
return [...Object.keys(
|
|
2960
|
+
return [...Object.keys(F), ...D.keys()];
|
|
3483
2961
|
}
|
|
3484
|
-
},
|
|
2962
|
+
}, se = {
|
|
3485
2963
|
sum: (t) => t.reduce((e, o) => e + o, 0),
|
|
3486
2964
|
avg: (t) => t.length ? t.reduce((e, o) => e + o, 0) / t.length : 0,
|
|
3487
2965
|
count: (t) => t.length,
|
|
@@ -3490,35 +2968,33 @@ const S = {
|
|
|
3490
2968
|
first: (t) => t[0] ?? 0,
|
|
3491
2969
|
last: (t) => t[t.length - 1] ?? 0
|
|
3492
2970
|
};
|
|
3493
|
-
function
|
|
3494
|
-
return
|
|
2971
|
+
function je(t) {
|
|
2972
|
+
return se[t] ?? se.sum;
|
|
3495
2973
|
}
|
|
3496
|
-
function
|
|
3497
|
-
return
|
|
2974
|
+
function et(t, e) {
|
|
2975
|
+
return je(t)(e);
|
|
3498
2976
|
}
|
|
3499
|
-
const
|
|
2977
|
+
const tt = H.register.bind(H), ot = H.unregister.bind(H), nt = H.get.bind(H), it = H.run.bind(H), st = H.list.bind(H);
|
|
3500
2978
|
export {
|
|
3501
|
-
|
|
2979
|
+
Ke as BaseGridPlugin,
|
|
3502
2980
|
P as DEFAULT_GRID_ICONS,
|
|
3503
|
-
|
|
3504
|
-
|
|
2981
|
+
Je as DGEvents,
|
|
2982
|
+
I as DataGridElement,
|
|
3505
2983
|
q as FitModeEnum,
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
Ct as runValueAggregator,
|
|
3522
|
-
Rt as unregisterAggregator
|
|
2984
|
+
Ze as GridCSSVars,
|
|
2985
|
+
A as GridClasses,
|
|
2986
|
+
V as GridDataAttrs,
|
|
2987
|
+
I as GridElement,
|
|
2988
|
+
Ye as GridSelectors,
|
|
2989
|
+
Qe as PluginEvents,
|
|
2990
|
+
Xe as PluginManager,
|
|
2991
|
+
H as aggregatorRegistry,
|
|
2992
|
+
nt as getAggregator,
|
|
2993
|
+
je as getValueAggregator,
|
|
2994
|
+
st as listAggregators,
|
|
2995
|
+
tt as registerAggregator,
|
|
2996
|
+
it as runAggregator,
|
|
2997
|
+
et as runValueAggregator,
|
|
2998
|
+
ot as unregisterAggregator
|
|
3523
2999
|
};
|
|
3524
3000
|
//# sourceMappingURL=index.js.map
|