@toolbox-web/grid 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/all.d.ts +19 -19
- package/all.d.ts.map +1 -1
- package/all.js +1775 -1202
- package/all.js.map +1 -1
- package/index.js +2143 -2015
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +22 -12
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/columns.d.ts +0 -9
- package/lib/core/internal/columns.d.ts.map +1 -1
- package/lib/core/internal/config-manager.d.ts +236 -0
- package/lib/core/internal/config-manager.d.ts.map +1 -0
- package/lib/core/internal/event-delegation.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/keyboard.d.ts.map +1 -1
- package/lib/core/internal/render-scheduler.d.ts +123 -0
- package/lib/core/internal/render-scheduler.d.ts.map +1 -0
- package/lib/core/internal/rows.d.ts +8 -3
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/sanitize.d.ts +10 -2
- package/lib/core/internal/sanitize.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +40 -2
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/internal/validate-config.d.ts +11 -0
- package/lib/core/internal/validate-config.d.ts.map +1 -0
- package/lib/core/plugin/base-plugin.d.ts +70 -0
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +13 -2
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +17 -3
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +112 -12
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +50 -18
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +60 -25
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +51 -16
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +117 -0
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -0
- package/lib/{core/internal → plugins/editing}/editors.d.ts +1 -1
- package/lib/plugins/editing/editors.d.ts.map +1 -0
- package/lib/plugins/editing/index.d.ts +8 -0
- package/lib/plugins/editing/index.d.ts.map +1 -0
- package/lib/plugins/editing/index.js +705 -0
- package/lib/plugins/editing/index.js.map +1 -0
- package/lib/plugins/editing/types.d.ts +45 -0
- package/lib/plugins/editing/types.d.ts.map +1 -0
- package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
- package/lib/plugins/export/index.js +74 -39
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +87 -50
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/grouping-columns.d.ts +4 -4
- package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +59 -24
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/grouping-rows.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +46 -11
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +2 -2
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +140 -102
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/master-detail/types.d.ts +12 -2
- package/lib/plugins/master-detail/types.d.ts.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +59 -22
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +41 -6
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +45 -9
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +42 -7
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +59 -19
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +41 -6
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +48 -13
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +3 -3
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +165 -126
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/tree-data.d.ts +6 -6
- package/lib/plugins/tree/tree-data.d.ts.map +1 -1
- package/lib/plugins/tree/tree-detect.d.ts +5 -9
- package/lib/plugins/tree/tree-detect.d.ts.map +1 -1
- package/lib/plugins/tree/types.d.ts +16 -4
- package/lib/plugins/tree/types.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +46 -11
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +37 -2
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +104 -13
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +31 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +18 -6
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +1 -1
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +2 -0
- package/umd/plugins/editing.umd.js.map +1 -0
- package/umd/plugins/export.umd.js +2 -2
- package/umd/plugins/export.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/lib/core/internal/column-state.d.ts +0 -124
- package/lib/core/internal/column-state.d.ts.map +0 -1
- package/lib/core/internal/editing.d.ts +0 -76
- package/lib/core/internal/editing.d.ts.map +0 -1
- package/lib/core/internal/editors.d.ts.map +0 -1
- package/lib/core/internal/grid-internals.d.ts +0 -83
- package/lib/core/internal/grid-internals.d.ts.map +0 -1
package/umd/grid.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(E,W){typeof exports=="object"&&typeof module<"u"?W(exports):typeof define=="function"&&define.amd?define(["exports"],W):(E=typeof globalThis<"u"?globalThis:E||self,W(E.TbwGrid={}))})(this,(function(E){"use strict";const W=':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-cell-white-space: nowrap;--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: 6px;--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-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--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-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px;--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;opacity:.6}:host .header-row>.cell:last-child{border-right:0}:host .header-group-cell:not(:last-child),:host .header-row>.cell.grouped.group-end:not(:last-child){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;content-visibility:auto;contain-intrinsic-size:auto var(--tbw-row-height)}:host .data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}:host .selecting .data-grid-row>.cell{-webkit-user-select:none;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:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);line-height:calc(var(--tbw-row-height) - 5px);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis}:host .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}:host .data-grid-row>.cell:last-child{border-right:0}:host .data-grid-row>.cell[data-type=boolean]{text-align:center}:host .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}:host .data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px)}: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%;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;-webkit-user-select:none;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;-webkit-user-select:none;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 .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: var(--tbw-animation-duration) var(--tbw-animation-easing);--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;overflow-anchor:none}: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 var(--tbw-transition-duration) var(--tbw-transition-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;-webkit-user-select:none;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}@media(forced-colors:active){:host{--tbw-color-border: CanvasText;--tbw-color-border-strong: CanvasText;--tbw-color-border-cell: CanvasText;--tbw-color-border-header: CanvasText;--tbw-color-fg: CanvasText;--tbw-color-bg: Canvas;--tbw-color-panel-bg: Canvas;--tbw-color-header-bg: Canvas;--tbw-color-header-fg: CanvasText;--tbw-color-accent: Highlight;--tbw-color-accent-fg: HighlightText;--tbw-color-selection: Highlight;--tbw-color-row-hover: Highlight;--tbw-focus-outline: 2px solid Highlight;--tbw-range-border-color: Highlight}:host .cell:focus,:host .cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}:host .data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}@media(prefers-reduced-motion:reduce){:host([data-animation-mode="reduced-motion"]){--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}}:host([data-animation-mode="off"]){--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}:host .tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}:host .tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}:host .tbw-fade-in{animation:tbw-fade-in var(--tbw-animation-duration) var(--tbw-animation-easing) forwards}:host .tbw-fade-out{animation:tbw-fade-out var(--tbw-animation-duration) var(--tbw-animation-easing) forwards}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}@keyframes tbw-fade-out{0%{opacity:1}to{opacity:0}}:host .tbw-flip-animating{will-change:transform;z-index:1}:host .tbw-toggle-icon{display:inline-flex;align-items:center;justify-content:center;transition:transform var(--tbw-animation-duration) var(--tbw-animation-easing)}:host .tbw-toggle-icon.tbw-expanded{transform:rotate(90deg)}';function Ke(t){const e=new Map;return t._sortState&&e.set(t._sortState.field,{direction:t._sortState.direction===1?"asc":"desc",priority:0}),e}function he(t,e){const o=t._columns,n=Ke(t);return{columns:o.map((i,r)=>{const l={field:i.field,order:r,visible:!0},s=i;s.__renderedWidth!==void 0?l.width=s.__renderedWidth:i.width!==void 0&&(l.width=typeof i.width=="string"?parseFloat(i.width):i.width);const a=n.get(i.field);a&&(l.sort=a);for(const c of e)if(c.getColumnState){const f=c.getColumnState(i.field);f&&Object.assign(l,f)}return l})}}function Ze(t,e,o,n){if(!e.columns||e.columns.length===0)return;const i=new Map(e.columns.map(s=>[s.field,s])),r=o.map(s=>{const a=i.get(s.field);if(!a)return s;const c={...s};return a.width!==void 0&&(c.width=a.width,c.__renderedWidth=a.width),a.visible!==void 0&&(c.hidden=!a.visible),c});r.sort((s,a)=>{const c=i.get(s.field)?.order??1/0,f=i.get(a.field)?.order??1/0;return c-f}),t._columns=r;const l=e.columns.filter(s=>s.sort!==void 0).sort((s,a)=>(s.sort?.priority??0)-(a.sort?.priority??0));if(l.length>0){const s=l[0];s.sort&&(t._sortState={field:s.field,direction:s.sort.direction==="asc"?1:-1})}else t._sortState=null;for(const s of n)if(s.applyColumnState)for(const a of e.columns)s.applyColumnState(a.field,a)}function Qe(t,e,o){let n=null;return()=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null;const i=he(t,e());o(i)},100)}}function fe(t,e,o,n){const i=t.effectiveConfig?.columns??[],r=i.find(s=>s.field===e);return!r||!o&&r.lockVisible||!o&&i.filter(a=>!a.hidden&&a.field!==e).length===0||!!r.hidden===!o?!1:(r.hidden=!o,n.emit("column-visibility",{field:e,visible:o,visibleColumns:i.filter(s=>!s.hidden).map(s=>s.field)}),n.clearRowPool(),n.setup(),n.requestStateChange(),!0)}function Je(t,e,o){const i=(t.effectiveConfig?.columns??[]).find(r=>r.field===e);return i?fe(t,e,!!i.hidden,o):!1}function et(t,e){const n=(t.effectiveConfig?.columns??[]).find(i=>i.field===e);return n?!n.hidden:!1}function tt(t,e){const o=t.effectiveConfig?.columns??[];o.some(n=>n.hidden)&&(o.forEach(n=>n.hidden=!1),e.emit("column-visibility",{visibleColumns:o.map(n=>n.field)}),e.clearRowPool(),e.setup(),e.requestStateChange())}function ot(t){return(t.effectiveConfig?.columns??[]).map(o=>({field:o.field,header:o.header||o.field,visible:!o.hidden,lockVisible:o.lockVisible}))}function nt(t){return t._columns.map(e=>e.field)}function it(t,e,o){if(!e.length)return;const n=new Map(t._columns.map(r=>[r.field,r])),i=[];for(const r of e){const l=n.get(r);l&&(i.push(l),n.delete(r))}for(const r of n.values())i.push(r);t._columns=i,o.renderHeader(),o.updateTemplate(),o.refreshVirtualWindow()}const V={STRETCH:"stretch",FIXED:"fixed"},pe={mode:"reduced-motion",duration:200,easing:"ease-out"},M={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰"};function rt(t){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"}function we(t,e){if(e&&e.length){const r={};return e.forEach(l=>{l.type&&(r[l.field]=l.type)}),{columns:e,typeMap:r}}const o=t[0]||{},n=Object.keys(o).map(r=>{const l=o[r],s=rt(l);return{field:r,header:r.charAt(0).toUpperCase()+r.slice(1),type:s}}),i={};return n.forEach(r=>{i[r.field]=r.type||"string"}),{columns:n,typeMap:i}}const lt=/{{\s*([^}]+)\s*}}/g,L="__DG_EMPTY__",st=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,at=/__(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/,ct=new Set(["script","iframe","object","embed","form","input","button","textarea","select","link","meta","base","style","template","slot","portal","frame","frameset","applet","noscript","noembed","plaintext","xmp","listing"]),be=/^on\w+$/i,dt=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),ut=/^\s*(javascript|vbscript|data|blob):/i;function J(t){if(!t||typeof t!="string")return"";if(t.indexOf("<")===-1)return t;const e=document.createElement("template");return e.innerHTML=t,ht(e.content),e.innerHTML}function ht(t){const e=[],o=t.querySelectorAll("*");for(const n of o){const i=n.tagName.toLowerCase();if(ct.has(i)){e.push(n);continue}if((i==="svg"||n.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(n.attributes).some(s=>be.test(s.name)||s.name==="href"||s.name==="xlink:href")){e.push(n);continue}const r=[];for(const l of n.attributes){const s=l.name.toLowerCase();if(be.test(s)){r.push(l.name);continue}if(dt.has(s)&&ut.test(l.value)){r.push(l.name);continue}if(s==="style"&&/expression\s*\(|javascript:|behavior\s*:/i.test(l.value)){r.push(l.name);continue}}r.forEach(l=>n.removeAttribute(l))}e.forEach(n=>n.remove())}function ge(t,e){if(!t||t.indexOf("{{")===-1)return t;const o=[],n=t.replace(lt,(s,a)=>{const c=ft(a,e);return o.push({expr:a.trim(),result:c}),c}),i=pt(n),r=o.length&&o.every(s=>s.result===""||s.result===L);return/Reflect\.|\bProxy\b|ownKeys\(/.test(t)||r?"":i}function ft(t,e){if(t=(t||"").trim(),!t||/\b(Reflect|Proxy|ownKeys)\b/.test(t))return L;if(t==="value")return e.value==null?L:String(e.value);if(t.startsWith("row.")&&!/[()?]/.test(t)&&!t.includes(":")){const n=t.slice(4),i=e.row?e.row[n]:void 0;return i==null?L:String(i)}if(t.length>80||!st.test(t)||at.test(t))return L;const o=t.match(/\./g);if(o&&o.length>1)return L;try{const i=new Function("value","row",`return (${t});`)(e.value,e.row),r=i==null?"":String(i);return/Reflect|Proxy|ownKeys/.test(r)?L:r||L}catch{return L}}function pt(t){return t&&t.replace(new RegExp(L,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function wt(t){if(/Reflect|Proxy|ownKeys/.test(t.textContent||"")){if(Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.TEXT_NODE&&/Reflect|Proxy|ownKeys/.test(e.textContent||"")&&(e.textContent="")}),/Reflect|Proxy|ownKeys/.test(t.textContent||"")){if(/Reflect|Proxy|ownKeys/.test(t.textContent||""))for(;t.firstChild;)t.removeChild(t.firstChild);t.textContent=(t.textContent||"").replace(/Reflect|Proxy|ownKeys/g,"")}(t.textContent||"").trim().length===0&&(t.textContent="")}}function me(t){const e=/Reflect\.|\bProxy\b|ownKeys\(/.test(t),o=n=>e?"":ge(t,n);return o.__blocked=e,o}function bt(t){return Array.from(t.querySelectorAll("tbw-grid-column")).map(o=>{const n=o.getAttribute("field")||"";if(!n)return null;const i=o.getAttribute("type")||void 0,l=i&&new Set(["number","string","date","boolean","select","typeahead"]).has(i)?i:void 0,s=o.getAttribute("header")||void 0,a=o.hasAttribute("sortable"),c=o.hasAttribute("editable"),f={field:n,type:l,header:s,sortable:a,editable:c},d=o.getAttribute("width");if(d){const C=parseFloat(d);!isNaN(C)&&/^\d+(\.\d+)?$/.test(d.trim())?f.width=C:f.width=d}const u=o.getAttribute("minWidth")||o.getAttribute("min-width");if(u){const C=parseFloat(u);isNaN(C)||(f.minWidth=C)}o.hasAttribute("resizable")&&(f.resizable=!0),o.hasAttribute("sizable")&&(f.resizable=!0);const w=o.getAttribute("editor"),h=o.getAttribute("renderer");w&&(f.__editorName=w),h&&(f.__rendererName=h);const p=o.getAttribute("options");p&&(f.options=p.split(",").map(C=>{const[P,A]=C.includes(":")?C.split(":"):[C.trim(),C.trim()];return{value:P.trim(),label:A?.trim()||P.trim()}}));const g=o.querySelector("tbw-grid-column-view"),b=o.querySelector("tbw-grid-column-editor"),_=o.querySelector("tbw-grid-column-header");g&&(f.__viewTemplate=g),b&&(f.__editorTemplate=b),_&&(f.__headerTemplate=_);const m=globalThis.DataGridElement?.getAdapters?.()??[],y=g??o,x=m.find(C=>C.canHandle(y));if(x){const C=x.createRenderer(y);C&&(f.viewRenderer=C)}const ie=b??o,T=m.find(C=>C.canHandle(ie));if(T){const C=T.createEditor(ie);C&&(f.editor=C)}return f}).filter(o=>!!o)}function gt(t,e){if((!t||!t.length)&&(!e||!e.length))return[];if(!t||!t.length)return e||[];if(!e||!e.length)return t;const o={};e.forEach(i=>{const r=o[i.field];if(r){i.header&&!r.header&&(r.header=i.header),i.type&&!r.type&&(r.type=i.type),i.sortable&&(r.sortable=!0),i.editable&&(r.editable=!0),i.resizable&&(r.resizable=!0),i.width!=null&&r.width==null&&(r.width=i.width),i.minWidth!=null&&r.minWidth==null&&(r.minWidth=i.minWidth),i.__viewTemplate&&(r.__viewTemplate=i.__viewTemplate),i.__editorTemplate&&(r.__editorTemplate=i.__editorTemplate),i.__headerTemplate&&(r.__headerTemplate=i.__headerTemplate);const l=i.renderer||i.viewRenderer,s=r.renderer||r.viewRenderer;l&&!s&&(r.viewRenderer=l,i.renderer&&(r.renderer=l)),i.editor&&!r.editor&&(r.editor=i.editor)}else o[i.field]={...i}});const n=t.map(i=>{const r=o[i.field];if(!r)return i;const l={...i};r.header&&!l.header&&(l.header=r.header),r.type&&!l.type&&(l.type=r.type),l.sortable=i.sortable||r.sortable,(i.resizable===!0||r.resizable===!0)&&(l.resizable=!0),l.editable=i.editable||r.editable,r.width!=null&&l.width==null&&(l.width=r.width),r.minWidth!=null&&l.minWidth==null&&(l.minWidth=r.minWidth),r.__viewTemplate&&(l.__viewTemplate=r.__viewTemplate),r.__editorTemplate&&(l.__editorTemplate=r.__editorTemplate),r.__headerTemplate&&(l.__headerTemplate=r.__headerTemplate);const s=r.renderer||r.viewRenderer,a=l.renderer||l.viewRenderer;return s&&!a&&(l.viewRenderer=s,r.renderer&&(l.renderer=s)),r.editor&&!l.editor&&(l.editor=r.editor),delete o[i.field],l});return Object.keys(o).forEach(i=>n.push(o[i])),n}function ve(t,e){try{t.part?.add?.(e)}catch{}const o=t.getAttribute("part");o?o.split(/\s+/).includes(e)||t.setAttribute("part",o+" "+e):t.setAttribute("part",e)}function _e(t){t.__lightDomColumnsCache||(t.__originalColumnNodes=Array.from(t.querySelectorAll("tbw-grid-column")),t.__lightDomColumnsCache=t.__originalColumnNodes.length?bt(t):[]);const e=t.__lightDomColumnsCache,o=gt(t._columns,e);o.forEach(i=>{i.__viewTemplate&&!i.__compiledView&&(i.__compiledView=me(i.__viewTemplate.innerHTML)),i.__editorTemplate&&!i.__compiledEditor&&(i.__compiledEditor=me(i.__editorTemplate.innerHTML))});const{columns:n}=we(t._rows,o);t._columns=n}function Ce(t){const e=t.effectiveConfig?.fitMode||t.fitMode||V.STRETCH;if(e!==V.STRETCH&&e!==V.FIXED||t.__didInitialAutoSize||!t.isConnected)return;const o=t._headerRowEl?.children||[];if(!o.length)return;let n=!1;t._visibleColumns.forEach((i,r)=>{if(i.width)return;const l=o[r];let s=l?l.scrollWidth:0;for(const a of t._rowPool){const c=a.children[r];if(c){const f=c.scrollWidth;f>s&&(s=f)}}s>0&&(i.width=s+2,i.__autoSized=!0,n=!0)}),n&&I(t),t.__didInitialAutoSize=!0}function I(t){(t.effectiveConfig?.fitMode||t.fitMode||V.STRETCH)===V.STRETCH?t._gridTemplate=t._visibleColumns.map(o=>{if(o.width)return`${o.width}px`;const n=o.minWidth;return n!=null?`minmax(${n}px, 1fr)`:"1fr"}).join(" ").trim():t._gridTemplate=t._visibleColumns.map(o=>o.width?`${o.width}px`:"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}function mt(t){switch(t.type){case"number":return e=>{const o=document.createElement("input");return o.type="number",o.value=e.value!=null?String(e.value):"",o.addEventListener("blur",()=>e.commit(o.value===""?null:Number(o.value))),o.addEventListener("keydown",n=>{n.key==="Enter"&&e.commit(o.value===""?null:Number(o.value)),n.key==="Escape"&&e.cancel()}),o};case"boolean":return e=>{const o=document.createElement("input");return o.type="checkbox",o.checked=!!e.value,o.addEventListener("change",()=>e.commit(o.checked)),o};case"date":return e=>{const o=document.createElement("input");return o.type="date",e.value instanceof Date&&(o.valueAsDate=e.value),o.addEventListener("change",()=>e.commit(o.valueAsDate)),o.addEventListener("keydown",n=>{n.key==="Escape"&&e.cancel()}),o};case"select":case"typeahead":return e=>{const o=document.createElement("select");e.column.multi&&(o.multiple=!0),(typeof e.column.options=="function"?e.column.options():e.column.options||[]).forEach(r=>{const l=document.createElement("option");l.value=String(r.value),l.textContent=r.label,(e.column.multi&&Array.isArray(e.value)&&e.value.includes(r.value)||!e.column.multi&&e.value===r.value)&&(l.selected=!0),o.appendChild(l)});const i=()=>{if(e.column.multi){const r=[];Array.from(o.selectedOptions).forEach(l=>{r.push(l.value)}),e.commit(r)}else e.commit(o.value)};return o.addEventListener("change",i),o.addEventListener("blur",i),o.addEventListener("keydown",r=>{r.key==="Escape"&&e.cancel()}),o};default:return e=>{const o=document.createElement("input");return o.type="text",o.value=e.value!=null?String(e.value):"",o.addEventListener("blur",()=>e.commit(o.value)),o.addEventListener("keydown",n=>{n.key==="Enter"&&e.commit(o.value),n.key==="Escape"&&e.cancel()}),o}}}function re(t){return`<span role="checkbox" aria-checked="${t}" aria-label="${t}">${t?"🗹":"☐"}</span>`}function Ee(t){if(t==null||t==="")return"";if(t instanceof Date)return isNaN(t.getTime())?"":t.toLocaleDateString();if(typeof t=="number"||typeof t=="string"){const e=new Date(t);return isNaN(e.getTime())?"":e.toLocaleDateString()}return""}function ye(t){if(!t)return-1;const e=t.getAttribute("data-row");return e?parseInt(e,10):-1}function j(t){if(!t)return-1;const e=t.getAttribute("data-col");return e?parseInt(e,10):-1}function le(t){t&&t.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function vt(t,e){if(t._dispatchKeyDown?.(e))return;const o=t._rows.length-1,n=t._visibleColumns.length-1,i=t._activeEditRows!==void 0&&t._activeEditRows!==-1,l=t._visibleColumns[t._focusCol]?.type,s=e.composedPath?e.composedPath():[],a=s&&s.length?s[0]:e.target,c=f=>{if(!f)return!1;const d=f.tagName;return!!(d==="INPUT"||d==="SELECT"||d==="TEXTAREA"||f.isContentEditable)};if(!(c(a)&&(e.key==="Home"||e.key==="End"))&&!(c(a)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&a.tagName==="INPUT"&&a.type==="number")&&!(c(a)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(c(a)&&(e.key==="Enter"||e.key==="Escape"))&&!(i&&(l==="select"||l==="typeahead")&&(e.key==="ArrowDown"||e.key==="ArrowUp"))){switch(e.key){case"Tab":{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),z(t);return}case"ArrowDown":i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.min(o,t._focusRow+1),e.preventDefault();break;case"ArrowUp":i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.max(0,t._focusRow-1),e.preventDefault();break;case"ArrowRight":t._focusCol=Math.min(n,t._focusCol+1),e.preventDefault();break;case"ArrowLeft":t._focusCol=Math.max(0,t._focusCol-1),e.preventDefault();break;case"Home":(e.ctrlKey||e.metaKey)&&(i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=0),t._focusCol=0,e.preventDefault(),z(t,{forceScrollLeft:!0});return;case"End":(e.ctrlKey||e.metaKey)&&(i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=o),t._focusCol=n,e.preventDefault(),z(t,{forceScrollRight:!0});return;case"PageDown":t._focusRow=Math.min(o,t._focusRow+20),e.preventDefault();break;case"PageUp":t._focusRow=Math.max(0,t._focusRow-20),e.preventDefault();break;case"Enter":if(typeof t.beginBulkEdit=="function"){t.beginBulkEdit(t._focusRow);return}else t.dispatchEvent(new CustomEvent("activate-cell",{detail:{row:t._focusRow,col:t._focusCol}}));return z(t);default:return}z(t)}}function z(t,e){if(t._virtualization?.enabled){const{rowHeight:l,container:s,viewportEl:a}=t._virtualization,c=s,f=a?.clientHeight??c?.clientHeight??0;if(c&&f>0){const d=t._focusRow*l;d<c.scrollTop?c.scrollTop=d:d+l>c.scrollTop+f&&(c.scrollTop=d-f+l)}}const o=t._activeEditRows!==void 0&&t._activeEditRows!==-1;o||t.refreshVirtualWindow(!1),le(t._bodyEl),Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(l=>{l.setAttribute("aria-selected","false")});const n=t._focusRow,i=t._virtualization.start??0,r=t._virtualization.end??t._rows.length;if(n>=i&&n<r){const l=t._bodyEl.querySelectorAll(".data-grid-row")[n-i],s=l?.children[t._focusCol];if(s){s.classList.add("cell-focus"),s.setAttribute("aria-selected","true");const a=t.shadowRoot?.querySelector(".tbw-scroll-area");if(a&&s&&!o)if(e?.forceScrollLeft)a.scrollLeft=0;else if(e?.forceScrollRight)a.scrollLeft=a.scrollWidth-a.clientWidth;else{const c=t._getHorizontalScrollOffsets?.(l??void 0,s)??{left:0,right:0};if(!c.skipScroll){const f=s.getBoundingClientRect(),d=a.getBoundingClientRect(),u=f.left-d.left+a.scrollLeft,w=u+f.width,h=a.scrollLeft+c.left,p=a.scrollLeft+a.clientWidth-c.right;u<h?a.scrollLeft=u-c.left:w>p&&(a.scrollLeft=w-a.clientWidth+c.right)}}if(t._activeEditRows!==void 0&&t._activeEditRows!==-1&&s.classList.contains("editing")){const c=s.querySelector(B);if(c&&document.activeElement!==c)try{c.focus({preventScroll:!0})}catch{}}else if(!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}}}}const Se=document.createElement("template");Se.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const Re=document.createElement("template");Re.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function _t(){return Se.content.firstElementChild.cloneNode(!0)}function Ct(){return Re.content.firstElementChild.cloneNode(!0)}const Et="__cellDisplayCache",yt="__cellCacheEpoch";function K(t){t[Et]=void 0,t[yt]=void 0,t.__hasSpecialColumns=void 0}function St(t,e,o,n,i){const r=Math.max(0,o-e),l=t._bodyEl,s=t._visibleColumns,a=s.length;let c=t.__cachedHeaderRowCount;for(c===void 0&&(c=t.shadowRoot?.querySelector(".header-group-row")?2:1,t.__cachedHeaderRowCount=c);t._rowPool.length<r;){const d=Ct();d.addEventListener("click",u=>Te(t,u,d,!1)),d.addEventListener("dblclick",u=>Te(t,u,d,!0)),t._rowPool.push(d)}if(t._rowPool.length>r){for(let d=r;d<t._rowPool.length;d++){const u=t._rowPool[d];u.parentNode===l&&u.remove()}t._rowPool.length=r}const f=i&&t.__hasRenderRowPlugins!==!1;for(let d=0;d<r;d++){const u=e+d,w=t._rows[u],h=t._rowPool[d];if(h.setAttribute("aria-rowindex",String(u+c+1)),f&&i(w,h,u)){h.__epoch=n,h.__rowDataRef=w,h.parentNode!==l&&l.appendChild(h);continue}const p=h.__epoch,g=h.__rowDataRef,b=h.children.length,v=p===n&&b===a,m=g!==w;let y=!1;if(v&&m){for(let T=0;T<a;T++)if(s[T].externalView&&!h.querySelector(`.cell[data-col="${T}"] [data-external-view]`)){y=!0;break}}if(!v||y){const T=ee(h),C=t._activeEditRows===u;if(T&&!C)h.__isCustomRow&&(h.className="data-grid-row",h.setAttribute("role","row"),h.__isCustomRow=!1),te(h),G(t,h,w,u),h.__epoch=n,h.__rowDataRef=w;else if(T&&C)se(t,h,w,u),h.__rowDataRef=w;else if(h.__isCustomRow&&(h.className="data-grid-row",h.setAttribute("role","row"),h.__isCustomRow=!1),G(t,h,w,u),h.__epoch=n,h.__rowDataRef=w,C){const P=h.children;for(let A=0;A<P.length;A++){const O=t._visibleColumns[A];O&&O.editable&&k(t,w,u,O,P[A],!0)}}}else if(m){const T=ee(h),C=t._activeEditRows===u;if(T&&!C)te(h),G(t,h,w,u),h.__epoch=n,h.__rowDataRef=w;else if(se(t,h,w,u),h.__rowDataRef=w,C&&!T){const P=h.children;for(let A=0;A<P.length;A++){const O=t._visibleColumns[A];O&&O.editable&&k(t,w,u,O,P[A],!0)}}}else{const T=ee(h),C=t._activeEditRows===u;if(T&&!C)te(h),G(t,h,w,u),h.__epoch=n,h.__rowDataRef=w;else if(se(t,h,w,u),C&&!T){const P=h.children;for(let A=0;A<P.length;A++){const O=t._visibleColumns[A];O&&O.editable&&k(t,w,u,O,P[A],!0)}}}const x=t._changedRowIndices.has(u),ie=h.classList.contains("changed");x!==ie&&h.classList.toggle("changed",x),h.parentNode!==l&&l.appendChild(h)}}function se(t,e,o,n){const i=e.children,r=t._visibleColumns,l=r.length,s=i.length,a=l<s?l:s,c=t._focusRow,f=t._focusCol;let d=t.__hasSpecialColumns;if(d===void 0){d=!1;for(let w=0;w<l;w++){const h=r[w];if(h.__viewTemplate||h.__compiledView||h.renderer||h.viewRenderer||h.externalView||h.format||h.type==="date"||h.type==="boolean"){d=!0;break}}t.__hasSpecialColumns=d}const u=String(n);if(!d){for(let w=0;w<a;w++){const h=i[w],p=o[r[w].field];h.textContent=p==null?"":String(p),h.getAttribute("data-row")!==u&&h.setAttribute("data-row",u);const g=c===n&&f===w,b=h.classList.contains("cell-focus");g!==b&&(h.classList.toggle("cell-focus",g),h.setAttribute("aria-selected",String(g)))}return}for(let w=0;w<a;w++)if(r[w].externalView&&!i[w].querySelector("[data-external-view]")){G(t,e,o,n);return}for(let w=0;w<a;w++){const h=r[w],p=i[w];p.getAttribute("data-row")!==u&&p.setAttribute("data-row",u);const g=c===n&&f===w,b=p.classList.contains("cell-focus");if(g!==b&&(p.classList.toggle("cell-focus",g),p.setAttribute("aria-selected",String(g))),p.classList.contains("editing"))continue;const _=h.renderer||h.viewRenderer;if(_){const y=o[h.field],x=_({row:o,value:y,field:h.field,column:h,cellEl:p});typeof x=="string"?p.innerHTML=J(x):x?x.parentElement!==p&&(p.innerHTML="",p.appendChild(x)):p.textContent=y==null?"":String(y);continue}if(h.__viewTemplate||h.__compiledView||h.externalView)continue;const v=o[h.field];let m;if(h.format)try{const y=h.format(v,o);m=y==null?"":String(y)}catch{m=v==null?"":String(v)}else h.type==="date"?(m=Ee(v),p.textContent=m):h.type==="boolean"?p.innerHTML=re(!!v):(m=v==null?"":String(v),p.textContent=m)}}function G(t,e,o,n){e.innerHTML="";const i=t._visibleColumns,r=i.length,l=t._focusRow,s=t._focusCol;t.effectiveConfig?.editOn||t.editOn;const a=t,c=document.createDocumentFragment();for(let f=0;f<r;f++){const d=i[f],u=_t();u.setAttribute("aria-colindex",String(f+1)),u.setAttribute("data-col",String(f)),u.setAttribute("data-row",String(n)),u.setAttribute("data-field",d.field),d.type,d.type&&u.setAttribute("data-type",d.type);let w=o[d.field];const h=d.format;if(h)try{w=h(w,o)}catch{}const p=d.__compiledView,g=d.__viewTemplate,b=d.renderer||d.viewRenderer,_=d.externalView;let v=!1;if(b){const m=b({row:o,value:w,field:d.field,column:d,cellEl:u});typeof m=="string"?(u.innerHTML=J(m),v=!0):m?m.parentElement!==u&&(u.textContent="",u.appendChild(m)):u.textContent=w==null?"":String(w)}else if(_){const m=_,y=document.createElement("div");y.setAttribute("data-external-view",""),y.setAttribute("data-field",d.field),u.appendChild(y);const x={row:o,value:w,field:d.field,column:d};if(m.mount)try{m.mount({placeholder:y,context:x,spec:m})}catch{}else queueMicrotask(()=>{try{a.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:y,spec:m,context:x}}))}catch{}});y.setAttribute("data-mounted","")}else if(p){const m=p({row:o,value:w,field:d.field,column:d}),y=p.__blocked;u.innerHTML=y?"":J(m),v=!0,y&&(u.textContent="",u.setAttribute("data-blocked-template",""))}else if(g){const m=g.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(m)?(u.textContent="",u.setAttribute("data-blocked-template","")):(u.innerHTML=J(ge(m,{row:o,value:w})),v=!0)}else d.type==="date"?u.textContent=Ee(w):d.type==="boolean"?u.innerHTML=re(!!w):u.textContent=w==null?"":String(w);if(v){wt(u);const m=u.textContent||"";/Proxy|Reflect\.ownKeys/.test(m)&&(u.textContent=m.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(u.textContent||"")&&(u.textContent=""))}u.hasAttribute("data-blocked-template")&&(u.textContent||"").trim().length&&(u.textContent=""),d.editable?u.tabIndex=0:d.type==="boolean"&&(u.hasAttribute("tabindex")||(u.tabIndex=0)),l===n&&s===f?(u.classList.add("cell-focus"),u.setAttribute("aria-selected","true")):u.setAttribute("aria-selected","false"),c.appendChild(u)}e.appendChild(c)}function Te(t,e,o,n){if(e.target?.closest(".resize-handle"))return;const i=o.querySelector(".cell[data-row]"),r=ye(i);if(r<0)return;const l=t._rows[r];if(!l||t._dispatchRowClick?.(e,r,l,o))return;const s=e.target?.closest(".cell[data-col]");if(s){const d=Number(s.getAttribute("data-col"));if(!isNaN(d)){if(t._dispatchCellClick?.(e,r,d,s))return;const u=t._focusRow!==r||t._focusCol!==d;if(t._focusRow=r,t._focusCol=d,s.classList.contains("editing")){u&&(le(t.shadowRoot??t._bodyEl),s.classList.add("cell-focus"));return}z(t)}}if(t._activeEditRows===r){s&&(le(t.shadowRoot??t._bodyEl),s.classList.add("cell-focus"),queueMicrotask(()=>{const d=Number(s.getAttribute("data-col")),u=t._visibleColumns[d];if(u&&u.editable&&s.classList.contains("editing")){const w=s.querySelector(B);try{w?.focus({preventScroll:!0})}catch{}}}));return}if(ee(o)){if(!n)return;const d=o.children;for(let u=0;u<d.length;u++)d[u].classList.remove("editing");te(o)}const c=t.effectiveConfig?.editOn??t.editOn??"dblClick";if(c===!1)return;const f=c==="dblclick"?"dblClick":c;if(f==="click"||f==="dblClick"&&n){if(typeof t.beginBulkEdit=="function"){t.beginBulkEdit(r);return}$(t,r,l)}else return;Array.from(o.children).forEach((d,u)=>{const w=t._visibleColumns[u];w&&w.editable&&k(t,l,r,w,d,!0)}),s&&queueMicrotask(()=>{const d=o.querySelector(`.cell[data-col="${t._focusCol}"]`);if(d?.classList.contains("editing")){const u=d.querySelector(B);try{u?.focus({preventScroll:!0})}catch{}}})}const B='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function ae(t){return!(t==="__proto__"||t==="constructor"||t==="prototype")}function ee(t){return(t.__editingCellCount??0)>0}function Rt(t){const e=(t.__editingCellCount??0)+1;t.__editingCellCount=e,t.setAttribute("data-has-editing","")}function te(t){t.__editingCellCount=0,t.removeAttribute("data-has-editing")}function Tt(t,e,o,n,i){const r=t.querySelector("input,textarea,select");if(!r)return;const l=()=>{if(r instanceof HTMLInputElement){if(r.type==="checkbox")return r.checked;if(r.type==="number")return r.value===""?null:Number(r.value);if(r.type==="date")return r.valueAsDate}return e.type==="number"&&r.value!==""?Number(r.value):r.value};r.addEventListener("blur",()=>{o(l())}),r instanceof HTMLInputElement&&r.type==="checkbox"?r.addEventListener("change",()=>o(r.checked)):r instanceof HTMLSelectElement&&r.addEventListener("change",()=>o(l()))}function $(t,e,o){t._activeEditRows!==e&&(t._rowEditSnapshots.set(e,{...o}),t._activeEditRows=e)}function N(t,e,o){if(t._activeEditRows!==e)return;const n=t._rowEditSnapshots.get(e),i=t._rows[e],r=t.findRenderedRowElement?.(e);if(!o&&r&&i&&r.querySelectorAll(".cell.editing").forEach(s=>{const a=Number(s.getAttribute("data-col"));if(isNaN(a))return;const c=t._visibleColumns[a];if(!c)return;const f=s.querySelector("input,textarea,select");if(f){let d;f instanceof HTMLInputElement&&f.type==="checkbox"?d=f.checked:(d=f.value,c.type==="number"&&d!==""&&(d=Number(d))),i[c.field]!==d&&ce(t,e,c,d,i)}}),o&&n&&i)Object.keys(n).forEach(l=>i[l]=n[l]),t._changedRowIndices.delete(e),K(t);else if(!o){const l=t._changedRowIndices.has(e);t.dispatchEvent(new CustomEvent("row-commit",{detail:{rowIndex:e,row:i,changed:l,changedRows:t.changedRows,changedRowIndices:t.changedRowIndices}}))}t._rowEditSnapshots.delete(e),t._activeEditRows=-1,r&&(G(t,r,t._rows[e],e),t._changedRowIndices.has(e)?r.classList.add("changed"):r.classList.remove("changed")),queueMicrotask(()=>{try{const l=t._focusRow,s=t._focusCol,a=t.findRenderedRowElement?.(l);if(a){Array.from(t._bodyEl.querySelectorAll(".cell-focus")).forEach(f=>f.classList.remove("cell-focus"));const c=a.querySelector(`.cell[data-row="${l}"][data-col="${s}"]`);c&&(c.classList.add("cell-focus"),c.setAttribute("aria-selected","true"),c.hasAttribute("tabindex")||c.setAttribute("tabindex","-1"),c.focus({preventScroll:!0}))}}catch{}})}function ce(t,e,o,n,i){const r=o.field;if(!ae(r)||i[r]===n)return;i[r]=n;const s=!t._changedRowIndices.has(e);t._changedRowIndices.add(e);const a=t.findRenderedRowElement?.(e);a&&a.classList.add("changed"),t.dispatchEvent(new CustomEvent("cell-commit",{detail:{row:i,field:r,value:n,rowIndex:e,changedRows:t.changedRows,changedRowIndices:t.changedRowIndices,firstTimeForRow:s}}))}function k(t,e,o,n,i,r=!1){if(!n.editable||(t._activeEditRows!==o&&$(t,o,e),i.classList.contains("editing")))return;const l=ae(n.field)?e[n.field]:void 0;i.classList.add("editing");const s=i.parentElement;s&&Rt(s);let a=!1;const c=p=>{a||t._activeEditRows===-1||ce(t,o,n,p,e)},f=()=>{a=!0,e[n.field]=ae(n.field)?l:void 0;const p=i.querySelector("input,textarea,select");p&&(typeof HTMLInputElement<"u"&&p instanceof HTMLInputElement&&p.type==="checkbox"?p.checked=!!l:"value"in p&&(p.value=l??""))},d=document.createElement("div");d.style.display="contents",i.innerHTML="",i.appendChild(d),d.addEventListener("keydown",p=>{p.key==="Enter"&&(p.stopPropagation(),p.preventDefault(),a=!0,N(t,o,!1)),p.key==="Escape"&&(p.stopPropagation(),p.preventDefault(),f(),N(t,o,!0))});const u=n.__editorTemplate,w=n.editor||(u?"template":mt(n)),h=l;if(w==="template"&&u){const p=u.cloneNode(!0),g=n.__compiledEditor;g?p.innerHTML=g({row:e,value:l,field:n.field,column:n}):p.querySelectorAll("*").forEach(_=>{_.childNodes.length===1&&_.firstChild?.nodeType===Node.TEXT_NODE&&(_.textContent=_.textContent?.replace(/{{\s*value\s*}}/g,l==null?"":String(l)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g,(v,m)=>{const y=e[m];return y==null?"":String(y)})||"")});const b=p.querySelector("input,textarea,select");if(b){const _=typeof HTMLInputElement<"u";_&&b instanceof HTMLInputElement&&b.type==="checkbox"?b.checked=!!l:"value"in b&&(b.value=l??""),b.addEventListener("blur",()=>{const v=_&&b instanceof HTMLInputElement&&b.type==="checkbox"?b.checked:b.value;c(v)}),b.addEventListener("keydown",v=>{if(v.key==="Enter"){v.stopPropagation(),v.preventDefault(),a=!0;const m=_&&b instanceof HTMLInputElement&&b.type==="checkbox"?b.checked:b.value;c(m),N(t,o,!1)}v.key==="Escape"&&(v.stopPropagation(),v.preventDefault(),f(),N(t,o,!0))}),_&&b instanceof HTMLInputElement&&b.type==="checkbox"&&b.addEventListener("change",()=>{const v=b.checked;c(v)}),r||setTimeout(()=>b.focus({preventScroll:!0}),0)}d.appendChild(p)}else if(typeof w=="string"){const p=document.createElement(w);p.value=h,p.addEventListener("change",()=>c(p.value)),d.appendChild(p),r||queueMicrotask(()=>{d.querySelector(B)?.focus({preventScroll:!0})})}else if(typeof w=="function"){const p=w({row:e,value:h,field:n.field,column:n,commit:c,cancel:f});typeof p=="string"?(d.innerHTML=p,Tt(d,n,c)):d.appendChild(p),r||queueMicrotask(()=>{d.querySelector(B)?.focus({preventScroll:!0})})}else if(w&&typeof w=="object"){const p=document.createElement("div");p.setAttribute("data-external-editor",""),p.setAttribute("data-field",n.field),d.appendChild(p);const g={row:e,value:h,field:n.field,column:n,commit:c,cancel:f};if(w.mount)try{w.mount({placeholder:p,context:g,spec:w})}catch{}else t.dispatchEvent(new CustomEvent("mount-external-editor",{detail:{placeholder:p,spec:w,context:g}}))}}function At(t,e,o){t.dispatchEvent(new CustomEvent(e,{detail:o,bubbles:!0}))}function Ae(t){return Array.from(t._changedRowIndices).map(e=>t._rows[e])}function xe(t){return Array.from(t._changedRowIndices)}function xt(t,e){t._changedRowIndices.clear(),e||At(t,"changed-rows-reset",{rows:Ae(t),indices:xe(t)}),t._rowPool.forEach(o=>o.classList.remove("changed"))}function Lt(t,e,o){if(t.effectiveConfig?.editOn===!1||!t._columns.some(l=>l.editable))return;const i=t._rows[e];$(t,e,i);const r=o.findRenderedRowElement(e);r&&(Array.from(r.children).forEach((l,s)=>{const a=t._visibleColumns[s];if(a?.editable){const c=l;c.classList.contains("editing")||k(t,i,e,a,c,!0)}}),setTimeout(()=>{let l=r.querySelector(`.cell[data-col="${t._focusCol}"]`);if(l?.classList.contains("editing")||(l=r.querySelector(".cell.editing")),l?.classList.contains("editing")){const s=l.querySelector(B);try{s?.focus({preventScroll:!0})}catch{}}},0))}function Pt(t){t._activeEditRows!==-1&&N(t,t._activeEditRows,!1)}function Ht(t){t._activeEditRows!==-1&&N(t,t._activeEditRows,!0)}function oe(t,e){const o=ye(e),n=j(e);if(o<0||n<0)return null;const i=t._rows[o],r=t._visibleColumns[n];return!i||!r?null:{rowIndex:o,colIndex:n,rowData:i,col:r}}function Ot(t,e){if(e.classList.contains("editing"))return;const o=oe(t,e);o&&(t._focusRow=o.rowIndex,t._focusCol=o.colIndex,z(t))}function Mt(t,e,o){if(e.classList.contains("editing"))return;const n=oe(t,e);n&&(o.stopPropagation(),t._focusRow=n.rowIndex,t._focusCol=n.colIndex,k(t,n.rowData,n.rowIndex,n.col,e))}function kt(t,e,o){o.stopPropagation();const n=oe(t,e);if(!n)return;if(typeof t.beginBulkEdit=="function"){t._focusRow=n.rowIndex,t._focusCol=n.colIndex,t.beginBulkEdit(n.rowIndex);return}$(t,n.rowIndex,n.rowData);const i=t.findRenderedRowElement?.(n.rowIndex);if(i){const r=i.children;for(let l=0;l<r.length;l++){const s=t._visibleColumns[l];s&&s.editable&&k(t,n.rowData,n.rowIndex,s,r[l],!0)}queueMicrotask(()=>{const l=i.querySelector(`.cell[data-col="${t._focusCol}"]`);if(l?.classList.contains("editing")){const s=l.querySelector(B);try{s?.focus({preventScroll:!0})}catch{}}})}}function Dt(t,e,o){const n=oe(t,e);if(!n)return;const{rowIndex:i,colIndex:r,rowData:l,col:s}=n,a=e.classList.contains("editing");if((s.type==="select"||s.type==="typeahead")&&!a&&o.key==="Enter"){o.preventDefault(),t._activeEditRows!==i&&$(t,i,l),k(t,l,i,s,e),setTimeout(()=>{const c=e.querySelector("select");try{c?.showPicker?.()}catch{}c?.focus({preventScroll:!0})},0);return}if(s.type==="boolean"&&o.key===" "&&!a){o.preventDefault(),t._activeEditRows!==i&&$(t,i,l);const c=!l[s.field];ce(t,i,s,c,l),e.innerHTML=re(!!c);return}if(o.key==="Enter"&&!a){o.preventDefault(),o.stopPropagation(),t._focusRow=i,t._focusCol=r,typeof t.beginBulkEdit=="function"?t.beginBulkEdit(i):k(t,l,i,s,e);return}if(o.key==="F2"&&!a){o.preventDefault(),k(t,l,i,s,e);return}}function zt(t,e,o){const n=()=>t.effectiveConfig?.editOn||t.editOn;e.addEventListener("mousedown",i=>{const r=i.target.closest(".cell[data-col]");if(!r)return;const l=j(r);if(l<0)return;const s=t._visibleColumns[l];s&&s.editable&&Ot(t,r)},{signal:o}),e.addEventListener("click",i=>{if(n()!=="click")return;const l=i.target.closest(".cell[data-col]");if(!l)return;const s=j(l);if(s<0)return;const a=t._visibleColumns[s];a&&a.editable&&Mt(t,l,i)},{signal:o}),e.addEventListener("dblclick",i=>{const r=n();if((r==="dblclick"?"dblClick":r)==="click"||r===!1)return;const s=i.target.closest(".cell[data-col]");if(!s)return;const a=j(s);if(a<0)return;const c=t._visibleColumns[a];c&&c.editable&&kt(t,s,i)},{signal:o}),e.addEventListener("keydown",i=>{const r=i.target.closest(".cell[data-col]");if(!r)return;const l=j(r);if(l<0)return;const s=t._visibleColumns[l];s&&s.editable&&Dt(t,r,i)},{signal:o})}function Le(t,e){return t==null&&e==null?0:t==null?-1:e==null||t>e?1:t<e?-1:0}function Pe(t,e,o){const i=o.find(s=>s.field===e.field)?.sortComparator??Le,{field:r,direction:l}=e;return[...t].sort((s,a)=>i(s[r],a[r],s,a)*l)}function He(t,e,o,n){t._rows=e,t.__rowRenderEpoch++,t._rowPool.forEach(i=>i.__epoch=-1),F(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:n}})),t.requestStateChange?.()}function Oe(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),Me(t,e,1)):t._sortState.direction===1?Me(t,e,-1):(t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(n=>n.__epoch=-1),t._rows=t.__originalOrder.slice(),F(t),t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach(n=>{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")}),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e.field,direction:0}})),t.requestStateChange?.())}function Me(t,e,o){t._sortState={field:e.field,direction:o};const n={field:e.field,direction:o},i=t._columns,l=(t.effectiveConfig?.sortHandler??Pe)(t._rows,n,i);l&&typeof l.then=="function"?l.then(s=>{He(t,s,e,o)}):He(t,l,e,o)}function Nt(t,e){typeof e=="string"?t.textContent=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}function F(t){t._headerRowEl=t.findHeaderRow();const e=t._headerRowEl;e.innerHTML="",t._visibleColumns.forEach((o,n)=>{const i=document.createElement("div");i.className="cell",ve(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));const r=o.__headerTemplate;if(r)Array.from(r.childNodes).forEach(l=>i.appendChild(l.cloneNode(!0)));else{const l=o.header||o.field,s=document.createElement("span");s.textContent=l,i.appendChild(s)}if(o.sortable){i.classList.add("sortable"),i.tabIndex=0;const l=document.createElement("span");ve(l,"sort-indicator");const s=t._sortState?.field===o.field?t._sortState.direction:0,a={...M,...t.icons},c=s===1?a.sortAsc:s===-1?a.sortDesc:a.sortNone;Nt(l,c),i.appendChild(l),i.setAttribute("aria-sort",s===0?"none":s===1?"ascending":"descending"),i.addEventListener("click",f=>{t._resizeController?.isResizing||t._dispatchHeaderClick?.(f,n,i)||Oe(t,o)}),i.addEventListener("keydown",f=>{if(f.key==="Enter"||f.key===" "){if(f.preventDefault(),t._dispatchHeaderClick?.(f,n,i))return;Oe(t,o)}})}if(o.resizable){i.style.position="relative";const l=document.createElement("div");l.className="resize-handle",l.setAttribute("aria-hidden","true"),l.addEventListener("mousedown",s=>{s.stopPropagation(),s.preventDefault(),t._resizeController.start(s,n,i)}),l.addEventListener("dblclick",s=>{s.stopPropagation(),s.preventDefault(),t._resizeController.resetColumn(n)}),i.appendChild(l)}e.appendChild(i)}),e.querySelectorAll(".cell.sortable").forEach(o=>{o.getAttribute("aria-sort")||o.setAttribute("aria-sort","none")}),e.children.length>0?(e.setAttribute("role","row"),e.setAttribute("aria-rowindex","1")):(e.removeAttribute("role"),e.removeAttribute("aria-rowindex"))}const ke=typeof requestIdleCallback=="function";function It(t,e){return ke?requestIdleCallback(t,e):window.setTimeout(()=>{const o=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-o))})},1)}function De(t){ke?cancelIdleCallback(t):clearTimeout(t)}function Bt(t){let e=null,o=null,n=null,i=null;const r=a=>{if(!e)return;const c=a.clientX-e.startX,f=Math.max(40,e.startWidth+c),d=t._visibleColumns[e.colIndex];d.width=f,d.__userResized=!0,d.__renderedWidth=f,o==null&&(o=requestAnimationFrame(()=>{o=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:d.field,width:f}}))};let l=!1;const s=()=>{const a=e!==null;a&&(l=!0,requestAnimationFrame(()=>{l=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",s),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()};return{get isResizing(){return e!==null||l},start(a,c,f){a.preventDefault();const d=f.getBoundingClientRect();e={startX:a.clientX,colIndex:c,startWidth:d.width},window.addEventListener("mousemove",r),window.addEventListener("mouseup",s),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"},resetColumn(a){const c=t._visibleColumns[a];c&&(c.__userResized=!1,c.__renderedWidth=void 0,c.width=c.__originalWidth,t.updateTemplate?.(),t.requestStateChange?.(),t.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:c.field,width:c.width}})))},dispose(){s()}}}function ne(t,e,o){const n=document.createElement(t);if(e)for(const i in e){const r=e[i];r!=null&&n.setAttribute(i,r)}return n}function R(t,e){const o=document.createElement("div");if(t&&(o.className=t),e)for(const n in e){const i=e[n];i!=null&&o.setAttribute(n,i)}return o}function ze(t,e,o){const n=document.createElement("button");if(t&&(n.className=t),e)for(const i in e){const r=e[i];r!=null&&n.setAttribute(i,r)}return n}function Ne(t){const e=document.createElement("slot");return t&&(e.name=t),e}const Ie=document.createElement("template");Ie.innerHTML=`
|
|
1
|
+
(function(v,M){typeof exports=="object"&&typeof module<"u"?M(exports):typeof define=="function"&&define.amd?define(["exports"],M):(v=typeof globalThis<"u"?globalThis:v||self,M(v.TbwGrid={}))})(this,(function(v){"use strict";const M=':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-cell-white-space: nowrap;--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: 6px;--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-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--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-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px;--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;opacity:.6}:host .header-row>.cell:last-child{border-right:0}:host .header-group-cell:not(:last-child),:host .header-row>.cell.grouped.group-end:not(:last-child){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;content-visibility:auto;contain-intrinsic-size:auto var(--tbw-row-height)}:host .data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}:host .selecting .data-grid-row>.cell{-webkit-user-select:none;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:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);line-height:calc(var(--tbw-row-height) - 5px);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis}:host .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}:host .data-grid-row>.cell:last-child{border-right:0}:host .data-grid-row>.cell[data-type=boolean]{text-align:center}:host .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}:host .data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px)}: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%;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;-webkit-user-select:none;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;-webkit-user-select:none;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 .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: var(--tbw-animation-duration) var(--tbw-animation-easing);--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;overflow-anchor:none}: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 var(--tbw-transition-duration) var(--tbw-transition-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;-webkit-user-select:none;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}@media(forced-colors:active){:host{--tbw-color-border: CanvasText;--tbw-color-border-strong: CanvasText;--tbw-color-border-cell: CanvasText;--tbw-color-border-header: CanvasText;--tbw-color-fg: CanvasText;--tbw-color-bg: Canvas;--tbw-color-panel-bg: Canvas;--tbw-color-header-bg: Canvas;--tbw-color-header-fg: CanvasText;--tbw-color-accent: Highlight;--tbw-color-accent-fg: HighlightText;--tbw-color-selection: Highlight;--tbw-color-row-hover: Highlight;--tbw-focus-outline: 2px solid Highlight;--tbw-range-border-color: Highlight}:host .cell:focus,:host .cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}:host .data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}@media(prefers-reduced-motion:reduce){:host([data-animation-mode="reduced-motion"]){--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}}:host([data-animation-mode="off"]){--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}:host .tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}:host .tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}:host .tbw-fade-in{animation:tbw-fade-in var(--tbw-animation-duration) var(--tbw-animation-easing) forwards}:host .tbw-fade-out{animation:tbw-fade-out var(--tbw-animation-duration) var(--tbw-animation-easing) forwards}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}@keyframes tbw-fade-out{0%{opacity:1}to{opacity:0}}@keyframes tbw-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}:host .tbw-slide-in{animation:tbw-slide-in var(--tbw-animation-duration) var(--tbw-animation-easing) forwards}:host .tbw-dragging{opacity:.5;cursor:grabbing}:host .tbw-toggle-btn{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;padding:0;font:inherit;color:inherit}:host .tbw-floating-panel{position:fixed;background:var(--tbw-color-panel-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);box-shadow:0 4px 16px var(--tbw-color-shadow);z-index:10000;font-size:13px}:host .tbw-drop-before:before,:host .tbw-drop-after:after{content:"";position:absolute;background:var(--tbw-drop-indicator-color, var(--tbw-color-accent));pointer-events:none}:host .tbw-drop-before-v:before{left:0;top:0;bottom:0;width:2px}:host .tbw-drop-after-v:after{right:0;top:0;bottom:0;width:2px}:host .tbw-drop-before-h:before{left:0;right:0;top:0;height:2px}:host .tbw-drop-after-h:after{left:0;right:0;bottom:0;height:2px}:host .tbw-flip-animating{will-change:transform;z-index:1}:host .tbw-toggle-icon{display:inline-flex;align-items:center;justify-content:center;transition:transform var(--tbw-animation-duration) var(--tbw-animation-easing)}:host .tbw-toggle-icon.tbw-expanded{transform:rotate(90deg)}',N={STRETCH:"stretch",FIXED:"fixed"},oe={mode:"reduced-motion",duration:200,easing:"ease-out"},H={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰"};function Ie(t){return Array.from(t.querySelectorAll("tbw-grid-column")).map(o=>{const i=o.getAttribute("field")||"";if(!i)return null;const n=o.getAttribute("type")||void 0,s=n&&new Set(["number","string","date","boolean","select","typeahead"]).has(n)?n:void 0,l=o.getAttribute("header")||void 0,a=o.hasAttribute("sortable"),c=o.hasAttribute("editable"),u={field:i,type:s,header:l,sortable:a,editable:c},d=o.getAttribute("width");if(d){const C=parseFloat(d);!isNaN(C)&&/^\d+(\.\d+)?$/.test(d.trim())?u.width=C:u.width=d}const f=o.getAttribute("minWidth")||o.getAttribute("min-width");if(f){const C=parseFloat(f);isNaN(C)||(u.minWidth=C)}o.hasAttribute("resizable")&&(u.resizable=!0),o.hasAttribute("sizable")&&(u.resizable=!0);const p=o.getAttribute("editor"),h=o.getAttribute("renderer");p&&(u.__editorName=p),h&&(u.__rendererName=h);const g=o.getAttribute("options");g&&(u.options=g.split(",").map(C=>{const[te,Vt]=C.includes(":")?C.split(":"):[C.trim(),C.trim()];return{value:te.trim(),label:Vt?.trim()||te.trim()}}));const m=o.querySelector("tbw-grid-column-view"),b=o.querySelector("tbw-grid-column-editor"),y=o.querySelector("tbw-grid-column-header");m&&(u.__viewTemplate=m),b&&(u.__editorTemplate=b),y&&(u.__headerTemplate=y);const _=globalThis.DataGridElement?.getAdapters?.()??[],T=m??o,A=_.find(C=>C.canHandle(T));if(A){const C=A.createRenderer(T);C&&(u.viewRenderer=C)}const Y=b??o,x=_.find(C=>C.canHandle(Y));if(x){const C=x.createEditor(Y);C&&(u.editor=C)}return u}).filter(o=>!!o)}function ie(t,e){if((!t||!t.length)&&(!e||!e.length))return[];if(!t||!t.length)return e||[];if(!e||!e.length)return t;const o={};e.forEach(n=>{const r=o[n.field];if(r){n.header&&!r.header&&(r.header=n.header),n.type&&!r.type&&(r.type=n.type),n.sortable&&(r.sortable=!0),n.editable&&(r.editable=!0),n.resizable&&(r.resizable=!0),n.width!=null&&r.width==null&&(r.width=n.width),n.minWidth!=null&&r.minWidth==null&&(r.minWidth=n.minWidth),n.__viewTemplate&&(r.__viewTemplate=n.__viewTemplate),n.__editorTemplate&&(r.__editorTemplate=n.__editorTemplate),n.__headerTemplate&&(r.__headerTemplate=n.__headerTemplate);const s=n.renderer||n.viewRenderer,l=r.renderer||r.viewRenderer;s&&!l&&(r.viewRenderer=s,n.renderer&&(r.renderer=s)),n.editor&&!r.editor&&(r.editor=n.editor)}else o[n.field]={...n}});const i=t.map(n=>{const r=o[n.field];if(!r)return n;const s={...n};r.header&&!s.header&&(s.header=r.header),r.type&&!s.type&&(s.type=r.type),s.sortable=n.sortable||r.sortable,(n.resizable===!0||r.resizable===!0)&&(s.resizable=!0),s.editable=n.editable||r.editable,r.width!=null&&s.width==null&&(s.width=r.width),r.minWidth!=null&&s.minWidth==null&&(s.minWidth=r.minWidth),r.__viewTemplate&&(s.__viewTemplate=r.__viewTemplate),r.__editorTemplate&&(s.__editorTemplate=r.__editorTemplate),r.__headerTemplate&&(s.__headerTemplate=r.__headerTemplate);const l=r.renderer||r.viewRenderer,a=s.renderer||s.viewRenderer;return l&&!a&&(s.viewRenderer=l,r.renderer&&(s.renderer=l)),r.editor&&!s.editor&&(s.editor=r.editor),delete o[n.field],s});return Object.keys(o).forEach(n=>i.push(o[n])),i}function ne(t,e){try{t.part?.add?.(e)}catch{}const o=t.getAttribute("part");o?o.split(/\s+/).includes(e)||t.setAttribute("part",o+" "+e):t.setAttribute("part",e)}function re(t){const e=t.effectiveConfig?.fitMode||t.fitMode||N.STRETCH;if(e!==N.STRETCH&&e!==N.FIXED||t.__didInitialAutoSize||!t.isConnected)return;const o=Array.from(t._headerRowEl?.children||[]);if(!o.length)return;let i=!1;t._visibleColumns.forEach((n,r)=>{if(n.width)return;const s=o[r];let l=s?s.scrollWidth:0;for(const a of t._rowPool){const c=a.children[r];if(c){const u=c.scrollWidth;u>l&&(l=u)}}l>0&&(n.width=l+2,n.__autoSized=!0,i=!0)}),i&&B(t),t.__didInitialAutoSize=!0}function B(t){(t.effectiveConfig?.fitMode||t.fitMode||N.STRETCH)===N.STRETCH?t._gridTemplate=t._visibleColumns.map(o=>{if(o.width)return`${o.width}px`;const i=o.minWidth;return i!=null?`minmax(${i}px, 1fr)`:"1fr"}).join(" ").trim():t._gridTemplate=t._visibleColumns.map(o=>o.width?`${o.width}px`:"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}function Be(t){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"}function qe(t,e){const o=t[0]||{},i=Object.keys(o).map(r=>{const s=o[r],l=Be(s);return{field:r,header:r.charAt(0).toUpperCase()+r.slice(1),type:l}}),n={};return i.forEach(r=>{n[r.field]=r.type||"string"}),{columns:i,typeMap:n}}const We=/{{\s*([^}]+)\s*}}/g,P="__DG_EMPTY__",Ue=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,Ge=/__(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/;function $e(t){return!t||typeof t!="string"?"":t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Ve=new Set(["script","iframe","object","embed","form","input","button","textarea","select","link","meta","base","style","template","slot","portal","frame","frameset","applet","noscript","noembed","plaintext","xmp","listing"]),se=/^on\w+$/i,Fe=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),Xe=/^\s*(javascript|vbscript|data|blob):/i;function $(t){if(!t||typeof t!="string")return"";if(t.indexOf("<")===-1)return t;const e=document.createElement("template");return e.innerHTML=t,Ye(e.content),e.innerHTML}function Ye(t){const e=[],o=t.querySelectorAll("*");for(const i of o){const n=i.tagName.toLowerCase();if(Ve.has(n)){e.push(i);continue}if((n==="svg"||i.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(i.attributes).some(l=>se.test(l.name)||l.name==="href"||l.name==="xlink:href")){e.push(i);continue}const r=[];for(const s of i.attributes){const l=s.name.toLowerCase();if(se.test(l)){r.push(s.name);continue}if(Fe.has(l)&&Xe.test(s.value)){r.push(s.name);continue}if(l==="style"&&/expression\s*\(|javascript:|behavior\s*:/i.test(s.value)){r.push(s.name);continue}}r.forEach(s=>i.removeAttribute(s))}e.forEach(i=>i.remove())}function le(t,e){if(!t||t.indexOf("{{")===-1)return t;const o=[],i=t.replace(We,(l,a)=>{const c=je(a,e);return o.push({expr:a.trim(),result:c}),c}),n=Ke(i),r=o.length&&o.every(l=>l.result===""||l.result===P);return/Reflect\.|\bProxy\b|ownKeys\(/.test(t)||r?"":n}function je(t,e){if(t=(t||"").trim(),!t||/\b(Reflect|Proxy|ownKeys)\b/.test(t))return P;if(t==="value")return e.value==null?P:String(e.value);if(t.startsWith("row.")&&!/[()?]/.test(t)&&!t.includes(":")){const i=t.slice(4),n=e.row?e.row[i]:void 0;return n==null?P:String(n)}if(t.length>80||!Ue.test(t)||Ge.test(t))return P;const o=t.match(/\./g);if(o&&o.length>1)return P;try{const n=new Function("value","row",`return (${t});`)(e.value,e.row),r=n==null?"":String(n);return/Reflect|Proxy|ownKeys/.test(r)?P:r||P}catch{return P}}function Ke(t){return t&&t.replace(new RegExp(P,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function Ze(t){if(/Reflect|Proxy|ownKeys/.test(t.textContent||"")){if(Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.TEXT_NODE&&/Reflect|Proxy|ownKeys/.test(e.textContent||"")&&(e.textContent="")}),/Reflect|Proxy|ownKeys/.test(t.textContent||"")){if(/Reflect|Proxy|ownKeys/.test(t.textContent||""))for(;t.firstChild;)t.removeChild(t.firstChild);t.textContent=(t.textContent||"").replace(/Reflect|Proxy|ownKeys/g,"")}(t.textContent||"").trim().length===0&&(t.textContent="")}}function ae(t){const e=/Reflect\.|\bProxy\b|ownKeys\(/.test(t),o=(i=>e?"":le(t,i));return o.__blocked=e,o}const Qe=100;class Je{#o;#c;#f;#d;#r;#n;#h={};#u={};#p=!0;#l=[];#v;#w;#b;#s;#m;constructor(e){this.#s=e}get original(){return this.#h}get effective(){return this.#u}get columns(){return this.#u.columns??[]}set columns(e){this.#u.columns=e}get lightDomColumnsCache(){return this.#r}set lightDomColumnsCache(e){this.#r=e}get originalColumnNodes(){return this.#n}set originalColumnNodes(e){this.#n=e}get lightDomTitle(){return this.#m}set lightDomTitle(e){this.#m=e}get initialColumnState(){return this.#b}set initialColumnState(e){this.#b=e}get sourcesChanged(){return this.#p}markSourcesChanged(){this.#p=!0}setGridConfig(e){this.#o=e,this.#p=!0,this.#r=void 0}getGridConfig(){return this.#o}setColumns(e){this.#c=e,this.#p=!0}getColumns(){return this.#c}setFitMode(e){this.#f=e,this.#p=!0}getFitMode(){return this.#f}setEditOn(e){this.#d=e,this.#p=!0}getEditOn(){return this.#d}merge(){const e=(this.#u.columns?.length??0)>0;if(!this.#p&&e)return;const o=this.#_();this.#p=!1,this.#h=o,Object.freeze(this.#h),this.#h.columns&&Object.freeze(this.#h.columns),this.#u=this.#x(this.#h),this.#g()}#x(e){const o={...e};return e.columns&&(o.columns=e.columns.map(i=>({...i}))),e.shell&&(o.shell={...e.shell,header:e.shell.header?{...e.shell.header}:void 0,toolPanel:e.shell.toolPanel?{...e.shell.toolPanel}:void 0,toolPanels:e.shell.toolPanels?.map(i=>({...i})),headerContents:e.shell.headerContents?.map(i=>({...i}))}),o}#g(){const e=this.#u;e.rowHeight&&e.rowHeight>0&&this.#s.setRowHeight(e.rowHeight),e.fitMode==="fixed"&&this.columns.forEach(i=>{i.width==null&&(i.width=80)}),this.#s.applyAnimationConfig(e)}#_(){const e=this.#o?{...this.#o}:{},o=Array.isArray(e.columns)?[...e.columns]:[],i=(this.#r??[]).map(s=>({...s}));let n=ie(o,i);this.#c&&this.#c.length&&(n=ie(this.#c,i));const r=this.#s.getRows();return n.length===0&&r.length&&(n=qe(r).columns),n.length&&(n.forEach(s=>{s.sortable===void 0&&(s.sortable=!0),s.resizable===void 0&&(s.resizable=!0),s.__originalWidth===void 0&&typeof s.width=="number"&&(s.__originalWidth=s.width)}),n.forEach(s=>{s.__viewTemplate&&!s.__compiledView&&(s.__compiledView=ae(s.__viewTemplate.innerHTML)),s.__editorTemplate&&!s.__compiledEditor&&(s.__compiledEditor=ae(s.__editorTemplate.innerHTML))}),e.columns=n),this.#f&&(e.fitMode=this.#f),e.fitMode||(e.fitMode="stretch"),this.#d&&(e.editOn=this.#d),this.#y(e),e.columnState&&!this.#b&&(this.#b=e.columnState),e}#y(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const o=this.#s.getShellLightDomTitle();o&&(this.#m=o),this.#m&&!e.shell.header.title&&(e.shell.header.title=this.#m);const i=this.#s.getShellLightDomHeaderContent();i?.length>0&&(e.shell.header.lightDomContent=i),this.#s.getShellHasToolButtonsContainer()&&(e.shell.header.hasToolButtonsContainer=!0);const n=this.#s.getShellToolPanels();if(n.size>0){const d=Array.from(n.values());d.sort((f,p)=>(f.order??100)-(p.order??100)),e.shell.toolPanels=d}const r=this.#s.getShellHeaderContents();if(r.size>0){const d=Array.from(r.values());d.sort((f,p)=>(f.order??100)-(p.order??100)),e.shell.headerContents=d}const s=this.#s.getShellToolbarButtons(),l=Array.from(s.values()),a=this.#o?.shell?.header?.toolbarButtons??[],c=new Set(a.map(d=>d.id)),u=[...a];for(const d of l)c.has(d.id)||u.push(d);u.sort((d,f)=>(d.order??100)-(f.order??100)),e.shell.header.toolbarButtons=u}collectState(e){const o=this.columns,i=this.#C();return{columns:o.map((n,r)=>{const s={field:n.field,order:r,visible:!n.hidden},l=n;l.__renderedWidth!==void 0?s.width=l.__renderedWidth:n.width!==void 0&&(s.width=typeof n.width=="string"?parseFloat(n.width):n.width);const a=i.get(n.field);a&&(s.sort=a);for(const c of e)if(c.getColumnState){const u=c.getColumnState(n.field);u&&Object.assign(s,u)}return s})}}applyState(e,o){if(!e.columns||e.columns.length===0)return;const i=this.columns,n=new Map(e.columns.map(l=>[l.field,l])),r=i.map(l=>{const a=n.get(l.field);if(!a)return l;const c={...l};return a.width!==void 0&&(c.width=a.width,c.__renderedWidth=a.width),a.visible!==void 0&&(c.hidden=!a.visible),c});r.sort((l,a)=>{const c=n.get(l.field)?.order??1/0,u=n.get(a.field)?.order??1/0;return c-u}),this.columns=r;const s=e.columns.filter(l=>l.sort!==void 0).sort((l,a)=>(l.sort?.priority??0)-(a.sort?.priority??0));if(s.length>0){const l=s[0];l.sort&&this.#s.setSortState({field:l.field,direction:l.sort.direction==="asc"?1:-1})}else this.#s.setSortState(null);for(const l of o)if(l.applyColumnState)for(const a of e.columns)l.applyColumnState(a.field,a)}resetState(e){this.#b=void 0,this.#s.setSortState(null),this.#u=this.#x(this.#h),this.#g();for(const o of e)if(o.applyColumnState)for(const i of this.columns)o.applyColumnState(i.field,{field:i.field,order:0,visible:!0});this.requestStateChange(e)}#C(){const e=new Map,o=this.#s.getSortState();return o&&e.set(o.field,{direction:o.direction===1?"asc":"desc",priority:0}),e}requestStateChange(e){this.#w&&clearTimeout(this.#w),this.#w=setTimeout(()=>{this.#w=void 0;const o=this.collectState(e);this.#s.emit("column-state-change",o)},Qe)}setColumnVisible(e,o){const i=this.columns,n=i.find(s=>s.field===e);return!n||!o&&n.lockVisible||!o&&i.filter(l=>!l.hidden&&l.field!==e).length===0||!!n.hidden===!o?!1:(n.hidden=!o,this.#s.emit("column-visibility",{field:e,visible:o,visibleColumns:i.filter(s=>!s.hidden).map(s=>s.field)}),this.#s.clearRowPool(),this.#s.setup(),!0)}toggleColumnVisibility(e){const o=this.columns.find(i=>i.field===e);return o?this.setColumnVisible(e,!!o.hidden):!1}isColumnVisible(e){const o=this.columns.find(i=>i.field===e);return o?!o.hidden:!1}showAllColumns(){const e=this.columns;e.some(o=>o.hidden)&&(e.forEach(o=>o.hidden=!1),this.#s.emit("column-visibility",{visibleColumns:e.map(o=>o.field)}),this.#s.clearRowPool(),this.#s.setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const o=new Map(this.columns.map(n=>[n.field,n])),i=[];for(const n of e){const r=o.get(n);r&&(i.push(r),o.delete(n))}for(const n of o.values())i.push(n);this.columns=i,this.#s.renderHeader(),this.#s.updateTemplate(),this.#s.refreshVirtualWindow()}parseLightDomColumns(e){this.#r||(this.#n=Array.from(e.querySelectorAll("tbw-grid-column")),this.#r=this.#n.length?Ie(e):[])}clearLightDomCache(){this.#r=void 0}#S=new Map;registerLightDomHandler(e,o){this.#S.set(e.toLowerCase(),o)}unregisterLightDomHandler(e){this.#S.delete(e.toLowerCase())}observeLightDOM(e){this.#v&&this.#v.disconnect();const o=new Set;let i=null;const n=()=>{i=null;for(const r of o)this.#S.get(r)?.();o.clear()};this.#v=new MutationObserver(r=>{for(const s of r){for(const l of s.addedNodes){if(l.nodeType!==Node.ELEMENT_NODE)continue;const c=l.tagName.toLowerCase();this.#S.has(c)&&o.add(c)}if(s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE){const a=s.target.tagName.toLowerCase();this.#S.has(a)&&o.add(a)}}o.size>0&&!i&&(i=setTimeout(n,0))}),this.#v.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#l.push(e)}notifyChange(){for(const e of this.#l)e()}dispose(){this.#v?.disconnect(),this.#l=[],this.#w&&clearTimeout(this.#w)}}function ce(t){return`<span role="checkbox" aria-checked="${t}" aria-label="${t}">${t?"🗹":"☐"}</span>`}function de(t){if(t==null||t==="")return"";if(t instanceof Date)return isNaN(t.getTime())?"":t.toLocaleDateString();if(typeof t=="number"||typeof t=="string"){const e=new Date(t);return isNaN(e.getTime())?"":e.toLocaleDateString()}return""}function he(t){if(!t)return-1;const e=t.getAttribute("data-row");return e?parseInt(e,10):-1}function et(t){if(!t)return-1;const e=t.getAttribute("data-col");return e?parseInt(e,10):-1}function j(t){t&&t.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function tt(t,e){const o=he(e),i=et(e);o<0||i<0||(t._focusRow=o,t._focusCol=i,j(t._bodyEl),e.classList.add("cell-focus"),e.setAttribute("aria-selected","true"))}function ot(t,e,o){e.addEventListener("mousedown",i=>{const n=i.target.closest(".cell[data-col]");n&&(n.classList.contains("editing")||tt(t,n))},{signal:o})}function ue(t,e){return t==null&&e==null?0:t==null?-1:e==null||t>e?1:t<e?-1:0}function fe(t,e,o){const n=o.find(l=>l.field===e.field)?.sortComparator??ue,{field:r,direction:s}=e;return[...t].sort((l,a)=>n(l[r],a[r],l,a)*s)}function pe(t,e,o,i){t._rows=e,t.__rowRenderEpoch++,t._rowPool.forEach(n=>n.__epoch=-1),V(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:i}})),t.requestStateChange?.()}function ge(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),we(t,e,1)):t._sortState.direction===1?we(t,e,-1):(t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(i=>i.__epoch=-1),t._rows=t.__originalOrder.slice(),V(t),t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach(i=>{i.getAttribute("aria-sort")?(i.getAttribute("aria-sort")==="ascending"||i.getAttribute("aria-sort")==="descending")&&(t._sortState||i.setAttribute("aria-sort","none")):i.setAttribute("aria-sort","none")}),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e.field,direction:0}})),t.requestStateChange?.())}function we(t,e,o){t._sortState={field:e.field,direction:o};const i={field:e.field,direction:o},n=t._columns,s=(t.effectiveConfig?.sortHandler??fe)(t._rows,i,n);s&&typeof s.then=="function"?s.then(l=>{pe(t,l,e,o)}):pe(t,s,e,o)}function it(t,e){typeof e=="string"?t.textContent=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}function V(t){t._headerRowEl=t.findHeaderRow();const e=t._headerRowEl;e.innerHTML="",t._visibleColumns.forEach((o,i)=>{const n=document.createElement("div");n.className="cell",ne(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(i+1)),n.setAttribute("data-field",o.field),n.setAttribute("data-col",String(i));const r=o.__headerTemplate;if(r)Array.from(r.childNodes).forEach(s=>n.appendChild(s.cloneNode(!0)));else{const s=o.header||o.field,l=document.createElement("span");l.textContent=s,n.appendChild(l)}if(o.sortable){n.classList.add("sortable"),n.tabIndex=0;const s=document.createElement("span");ne(s,"sort-indicator");const l=t._sortState?.field===o.field?t._sortState.direction:0,a={...H,...t.icons},c=l===1?a.sortAsc:l===-1?a.sortDesc:a.sortNone;it(s,c),n.appendChild(s),n.setAttribute("aria-sort",l===0?"none":l===1?"ascending":"descending"),n.addEventListener("click",u=>{t._resizeController?.isResizing||t._dispatchHeaderClick?.(u,i,n)||ge(t,o)}),n.addEventListener("keydown",u=>{if(u.key==="Enter"||u.key===" "){if(u.preventDefault(),t._dispatchHeaderClick?.(u,i,n))return;ge(t,o)}})}if(o.resizable){n.style.position="relative";const s=document.createElement("div");s.className="resize-handle",s.setAttribute("aria-hidden","true"),s.addEventListener("mousedown",l=>{l.stopPropagation(),l.preventDefault(),t._resizeController.start(l,i,n)}),s.addEventListener("dblclick",l=>{l.stopPropagation(),l.preventDefault(),t._resizeController.resetColumn(i)}),n.appendChild(s)}e.appendChild(n)}),e.querySelectorAll(".cell.sortable").forEach(o=>{o.getAttribute("aria-sort")||o.setAttribute("aria-sort","none")}),e.children.length>0?(e.setAttribute("role","row"),e.setAttribute("aria-rowindex","1")):(e.removeAttribute("role"),e.removeAttribute("aria-rowindex"))}const be=typeof requestIdleCallback=="function";function nt(t,e){return be?requestIdleCallback(t,e):window.setTimeout(()=>{const o=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-o))})},1)}function me(t){be?cancelIdleCallback(t):clearTimeout(t)}const ve='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function K(t){return(t.__editingCellCount??0)>0}function Z(t){t.__editingCellCount=0,t.removeAttribute("data-has-editing"),t.querySelectorAll(".cell.editing").forEach(o=>o.classList.remove("editing"))}const Ce=document.createElement("template");Ce.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const _e=document.createElement("template");_e.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function rt(){return Ce.content.firstElementChild.cloneNode(!0)}function st(){return _e.content.firstElementChild.cloneNode(!0)}function F(t){t.__cellDisplayCache=void 0,t.__cellCacheEpoch=void 0,t.__hasSpecialColumns=void 0}function lt(t,e,o,i,n){const r=Math.max(0,o-e),s=t._bodyEl,l=t._visibleColumns,a=l.length;let c=t.__cachedHeaderRowCount;for(c===void 0&&(c=t.shadowRoot?.querySelector(".header-group-row")?2:1,t.__cachedHeaderRowCount=c);t._rowPool.length<r;){const d=st();d.addEventListener("click",f=>ye(t,f,d)),d.addEventListener("dblclick",f=>ye(t,f,d)),t._rowPool.push(d)}if(t._rowPool.length>r){for(let d=r;d<t._rowPool.length;d++){const f=t._rowPool[d];f.parentNode===s&&f.remove()}t._rowPool.length=r}const u=n&&t.__hasRenderRowPlugins!==!1;for(let d=0;d<r;d++){const f=e+d,p=t._rows[f],h=t._rowPool[d];if(h.setAttribute("aria-rowindex",String(f+c+1)),u&&n(p,h,f)){h.__epoch=i,h.__rowDataRef=p,h.parentNode!==s&&s.appendChild(h);continue}const g=h.__epoch,m=h.__rowDataRef,b=h.children.length,w=g===i&&b===a,_=m!==p;let T=!1;if(w&&_){for(let x=0;x<a;x++)if(l[x].externalView&&!h.querySelector(`.cell[data-col="${x}"] [data-external-view]`)){T=!0;break}}if(!w||T){const x=K(h),C=t._activeEditRows===f;x&&!C?(h.__isCustomRow&&(h.className="data-grid-row",h.setAttribute("role","row"),h.__isCustomRow=!1),Z(h),q(t,h,p,f),h.__epoch=i,h.__rowDataRef=p):x&&C?(Q(t,h,p,f),h.__rowDataRef=p):(h.__isCustomRow&&(h.className="data-grid-row",h.setAttribute("role","row"),h.__isCustomRow=!1),q(t,h,p,f),h.__epoch=i,h.__rowDataRef=p)}else if(_){const x=K(h),C=t._activeEditRows===f;x&&!C?(Z(h),q(t,h,p,f),h.__epoch=i,h.__rowDataRef=p):(Q(t,h,p,f),h.__rowDataRef=p)}else{const x=K(h),C=t._activeEditRows===f;x&&!C?(Z(h),q(t,h,p,f),h.__epoch=i,h.__rowDataRef=p):Q(t,h,p,f)}const A=t._changedRowIndices?.has(f)??!1,Y=h.classList.contains("changed");A!==Y&&h.classList.toggle("changed",A),h.parentNode!==s&&s.appendChild(h)}}function Q(t,e,o,i){const n=e.children,r=t._visibleColumns,s=r.length,l=n.length,a=s<l?s:l,c=t._focusRow,u=t._focusCol;let d=t.__hasSpecialColumns;if(d===void 0){d=!1;for(let p=0;p<s;p++){const h=r[p];if(h.__viewTemplate||h.__compiledView||h.renderer||h.viewRenderer||h.externalView||h.format||h.type==="date"||h.type==="boolean"){d=!0;break}}t.__hasSpecialColumns=d}const f=String(i);if(!d){for(let p=0;p<a;p++){const h=n[p],g=o[r[p].field];h.textContent=g==null?"":String(g),h.getAttribute("data-row")!==f&&h.setAttribute("data-row",f);const m=c===i&&u===p,b=h.classList.contains("cell-focus");m!==b&&(h.classList.toggle("cell-focus",m),h.setAttribute("aria-selected",String(m)))}return}for(let p=0;p<a;p++)if(r[p].externalView&&!n[p].querySelector("[data-external-view]")){q(t,e,o,i);return}for(let p=0;p<a;p++){const h=r[p],g=n[p];g.getAttribute("data-row")!==f&&g.setAttribute("data-row",f);const m=c===i&&u===p,b=g.classList.contains("cell-focus");if(m!==b&&(g.classList.toggle("cell-focus",m),g.setAttribute("aria-selected",String(m))),g.classList.contains("editing"))continue;const y=h.renderer||h.viewRenderer;if(y){const T=o[h.field],A=y({row:o,value:T,field:h.field,column:h,cellEl:g});typeof A=="string"?g.innerHTML=$(A):A instanceof Node?A.parentElement!==g&&(g.innerHTML="",g.appendChild(A)):A==null&&(g.textContent=T==null?"":String(T));continue}if(h.__viewTemplate||h.__compiledView||h.externalView)continue;const w=o[h.field];let _;if(h.format)try{const T=h.format(w,o);_=T==null?"":String(T)}catch(T){console.warn(`[tbw-grid] Format error in column '${h.field}':`,T),_=w==null?"":String(w)}else h.type==="date"?(_=de(w),g.textContent=_):h.type==="boolean"?g.innerHTML=ce(!!w):(_=w==null?"":String(w),g.textContent=_)}}function q(t,e,o,i){e.innerHTML="";const n=t._visibleColumns,r=n.length,s=t._focusRow,l=t._focusCol,a=t,c=document.createDocumentFragment();for(let u=0;u<r;u++){const d=n[u],f=rt();f.setAttribute("aria-colindex",String(u+1)),f.setAttribute("data-col",String(u)),f.setAttribute("data-row",String(i)),f.setAttribute("data-field",d.field),d.type&&f.setAttribute("data-type",d.type);let p=o[d.field];if(d.format)try{p=d.format(p,o)}catch(w){console.warn(`[tbw-grid] Format error in column '${d.field}':`,w)}const h=d.__compiledView,g=d.__viewTemplate,m=d.renderer||d.viewRenderer,b=d.externalView;let y=!1;if(m){const w=m({row:o,value:p,field:d.field,column:d,cellEl:f});typeof w=="string"?(f.innerHTML=$(w),y=!0):w instanceof Node?w.parentElement!==f&&(f.textContent="",f.appendChild(w)):w==null&&(f.textContent=p==null?"":String(p))}else if(b){const w=b,_=document.createElement("div");_.setAttribute("data-external-view",""),_.setAttribute("data-field",d.field),f.appendChild(_);const T={row:o,value:p,field:d.field,column:d};if(w.mount)try{w.mount({placeholder:_,context:T,spec:w})}catch(A){console.warn(`[tbw-grid] External view mount error for column '${d.field}':`,A)}else queueMicrotask(()=>{try{a.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:_,spec:w,context:T}}))}catch(A){console.warn(`[tbw-grid] External view event dispatch error for column '${d.field}':`,A)}});_.setAttribute("data-mounted","")}else if(h){const w=h({row:o,value:p,field:d.field,column:d}),_=h.__blocked;f.innerHTML=_?"":$(w),y=!0,_&&(f.textContent="",f.setAttribute("data-blocked-template",""))}else if(g){const w=g.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(w)?(f.textContent="",f.setAttribute("data-blocked-template","")):(f.innerHTML=$(le(w,{row:o,value:p})),y=!0)}else d.type==="date"?f.textContent=de(p):d.type==="boolean"?f.innerHTML=ce(!!p):f.textContent=p==null?"":String(p);if(y){Ze(f);const w=f.textContent||"";/Proxy|Reflect\.ownKeys/.test(w)&&(f.textContent=w.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(f.textContent||"")&&(f.textContent=""))}f.hasAttribute("data-blocked-template")&&(f.textContent||"").trim().length&&(f.textContent=""),d.editable?f.tabIndex=0:d.type==="boolean"&&(f.hasAttribute("tabindex")||(f.tabIndex=0)),s===i&&l===u?(f.classList.add("cell-focus"),f.setAttribute("aria-selected","true")):f.setAttribute("aria-selected","false"),c.appendChild(f)}e.appendChild(c)}function ye(t,e,o,i){if(e.target?.closest(".resize-handle"))return;const n=o.querySelector(".cell[data-row]"),r=he(n);if(r<0)return;const s=t._rows[r];if(!s||t._dispatchRowClick?.(e,r,s,o))return;const l=e.target?.closest(".cell[data-col]");if(l){const a=Number(l.getAttribute("data-col"));if(!isNaN(a)){if(t._dispatchCellClick?.(e,r,a,l))return;const c=t._focusRow!==r||t._focusCol!==a;if(t._focusRow=r,t._focusCol=a,l.classList.contains("editing")){c&&(j(t.shadowRoot??t._bodyEl),l.classList.add("cell-focus"));const u=l.querySelector(ve);try{u?.focus({preventScroll:!0})}catch{}return}W(t)}}}function at(t,e){if(t._dispatchKeyDown?.(e))return;const o=t._rows.length-1,i=t._visibleColumns.length-1,n=t._activeEditRows!==void 0&&t._activeEditRows!==-1,s=t._visibleColumns[t._focusCol]?.type,l=e.composedPath?.()??[],a=l.length?l[0]:e.target,c=u=>{if(!u)return!1;const d=u.tagName;return!!(d==="INPUT"||d==="SELECT"||d==="TEXTAREA"||u.isContentEditable)};if(!(c(a)&&(e.key==="Home"||e.key==="End"))&&!(c(a)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&a.tagName==="INPUT"&&a.type==="number")&&!(c(a)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(c(a)&&(e.key==="Enter"||e.key==="Escape"))&&!(n&&(s==="select"||s==="typeahead")&&(e.key==="ArrowDown"||e.key==="ArrowUp"))){switch(e.key){case"Tab":{e.preventDefault(),!e.shiftKey?t._focusCol<i?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=i),W(t);return}case"ArrowDown":n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.min(o,t._focusRow+1),e.preventDefault();break;case"ArrowUp":n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.max(0,t._focusRow-1),e.preventDefault();break;case"ArrowRight":t._focusCol=Math.min(i,t._focusCol+1),e.preventDefault();break;case"ArrowLeft":t._focusCol=Math.max(0,t._focusCol-1),e.preventDefault();break;case"Home":(e.ctrlKey||e.metaKey)&&(n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=0),t._focusCol=0,e.preventDefault(),W(t,{forceScrollLeft:!0});return;case"End":(e.ctrlKey||e.metaKey)&&(n&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=o),t._focusCol=i,e.preventDefault(),W(t,{forceScrollRight:!0});return;case"PageDown":t._focusRow=Math.min(o,t._focusRow+20),e.preventDefault();break;case"PageUp":t._focusRow=Math.max(0,t._focusRow-20),e.preventDefault();break;case"Enter":t.dispatchEvent(new CustomEvent("activate-cell",{detail:{row:t._focusRow,col:t._focusCol}}));break;default:return}W(t)}}function W(t,e){if(t._virtualization?.enabled){const{rowHeight:s,container:l,viewportEl:a}=t._virtualization,c=l,u=a?.clientHeight??c?.clientHeight??0;if(c&&u>0){const d=t._focusRow*s;d<c.scrollTop?c.scrollTop=d:d+s>c.scrollTop+u&&(c.scrollTop=d-u+s)}}const o=t._activeEditRows!==void 0&&t._activeEditRows!==-1;o||t.refreshVirtualWindow(!1),j(t._bodyEl),Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(s=>{s.setAttribute("aria-selected","false")});const i=t._focusRow,n=t._virtualization.start??0,r=t._virtualization.end??t._rows.length;if(i>=n&&i<r){const s=t._bodyEl.querySelectorAll(".data-grid-row")[i-n],l=s?.children[t._focusCol];if(l){l.classList.add("cell-focus"),l.setAttribute("aria-selected","true");const a=t.shadowRoot?.querySelector(".tbw-scroll-area");if(a&&l&&!o)if(e?.forceScrollLeft)a.scrollLeft=0;else if(e?.forceScrollRight)a.scrollLeft=a.scrollWidth-a.clientWidth;else{const c=t._getHorizontalScrollOffsets?.(s??void 0,l)??{left:0,right:0};if(!c.skipScroll){const u=l.getBoundingClientRect(),d=a.getBoundingClientRect(),f=u.left-d.left+a.scrollLeft,p=f+u.width,h=a.scrollLeft+c.left,g=a.scrollLeft+a.clientWidth-c.right;f<h?a.scrollLeft=f-c.left:p>g&&(a.scrollLeft=p-a.clientWidth+c.right)}}if(t._activeEditRows!==void 0&&t._activeEditRows!==-1&&l.classList.contains("editing")){const c=l.querySelector(ve);if(c&&document.activeElement!==c)try{c.focus({preventScroll:!0})}catch{}}else if(!l.contains(document.activeElement)){l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{}}}}}var S=(t=>(t[t.STYLE=1]="STYLE",t[t.VIRTUALIZATION=2]="VIRTUALIZATION",t[t.HEADER=3]="HEADER",t[t.ROWS=4]="ROWS",t[t.COLUMNS=5]="COLUMNS",t[t.FULL=6]="FULL",t))(S||{});class ct{#o;#c=0;#f=0;#d=null;#r=null;#n=null;#h=!1;constructor(e){this.#o=e}requestPhase(e,o){e>this.#c&&(this.#c=e),this.#f===0&&(this.#u(),this.#f=requestAnimationFrame(()=>this.#p()))}whenReady(){return this.#d?this.#d:Promise.resolve()}setInitialReadyResolver(e){this.#n=e}cancel(){this.#f!==0&&(cancelAnimationFrame(this.#f),this.#f=0),this.#c=0,this.#r&&(this.#r(),this.#r=null,this.#d=null)}get isPending(){return this.#c!==0}get pendingPhase(){return this.#c}#u(){this.#d||(this.#d=new Promise(e=>{this.#r=e}))}#p(){if(this.#f=0,!this.#o.isConnected()){this.#c=0,this.#r&&(this.#r(),this.#r=null,this.#d=null);return}const e=this.#c;this.#c=0,e>=5&&this.#o.mergeConfig(),e>=4&&this.#o.processRows(),e>=5&&(this.#o.processColumns(),this.#o.updateTemplate()),e>=3&&this.#o.renderHeader(),e>=2&&this.#o.renderVirtualWindow(),e>=1&&this.#o.afterRender(),!this.#h&&this.#n&&(this.#h=!0,this.#n()),this.#r&&(this.#r(),this.#r=null,this.#d=null)}}function dt(t){let e=null,o=null,i=null,n=null;const r=a=>{if(!e)return;const c=a.clientX-e.startX,u=Math.max(40,e.startWidth+c),d=t._visibleColumns[e.colIndex];d.width=u,d.__userResized=!0,d.__renderedWidth=u,o==null&&(o=requestAnimationFrame(()=>{o=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:d.field,width:u}}))};let s=!1;const l=()=>{const a=e!==null;a&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),i!==null&&(document.documentElement.style.cursor=i,i=null),n!==null&&(document.body.style.userSelect=n,n=null),e=null,a&&t.requestStateChange&&t.requestStateChange()};return{get isResizing(){return e!==null||s},start(a,c,u){a.preventDefault();const d=u.getBoundingClientRect();e={startX:a.clientX,colIndex:c,startWidth:d.width},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),i===null&&(i=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",n===null&&(n=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(a){const c=t._visibleColumns[a];c&&(c.__userResized=!1,c.__renderedWidth=void 0,c.width=c.__originalWidth,t.updateTemplate?.(),t.requestStateChange?.(),t.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:c.field,width:c.width}})))},dispose(){l()}}}function X(t,e,o){const i=document.createElement(t);if(e)for(const n in e){const r=e[n];r!=null&&i.setAttribute(n,r)}return i}function R(t,e){const o=document.createElement("div");if(t&&(o.className=t),e)for(const i in e){const n=e[i];n!=null&&o.setAttribute(i,n)}return o}function Ee(t,e,o){const i=document.createElement("button");if(t&&(i.className=t),e)for(const n in e){const r=e[n];r!=null&&i.setAttribute(n,r)}return i}function Se(t){const e=document.createElement("slot");return t&&(e.name=t),e}const Te=document.createElement("template");Te.innerHTML=`
|
|
2
2
|
<div class="tbw-scroll-area">
|
|
3
3
|
<div class="rows-body-wrapper">
|
|
4
4
|
<div class="rows-body" role="grid">
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
<div class="faux-vscroll">
|
|
17
17
|
<div class="faux-vscroll-spacer"></div>
|
|
18
18
|
</div>
|
|
19
|
-
`;function
|
|
19
|
+
`;function Re(){return Te.content.cloneNode(!0)}function Ae(t){const e=document.createDocumentFragment(),o=R(t.hasShell?"tbw-grid-root has-shell":"tbw-grid-root");if(t.hasShell&&t.shellHeader&&t.shellBody)o.appendChild(t.shellHeader),o.appendChild(t.shellBody);else{const i=R("tbw-grid-content");i.appendChild(Re()),o.appendChild(i)}return e.appendChild(o),e}function ht(t){const e=R("tbw-shell-header",{part:"shell-header",role:"presentation"});if(t.title){const r=R("tbw-shell-title");r.textContent=t.title,e.appendChild(r)}const o=R("tbw-shell-content",{part:"shell-content",role:"presentation"});o.appendChild(Se("header-content")),e.appendChild(o);const i=R("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const r of t.configButtons)(r.hasElement||r.hasRender)&&i.appendChild(R("tbw-toolbar-btn-slot",{"data-btn-slot":r.id}));for(const r of t.apiButtons)(r.hasElement||r.hasRender)&&i.appendChild(R("tbw-toolbar-btn-slot",{"data-btn-slot":r.id}));if(i.appendChild(Se("toolbar")),(t.configButtons.some(r=>r.hasElement||r.hasRender)||t.apiButtons.some(r=>r.hasElement||r.hasRender))&&t.hasPanels&&i.appendChild(R("tbw-toolbar-separator")),t.hasPanels){const r=Ee(t.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(t.isPanelOpen),"aria-controls":"tbw-tool-panel"});r.innerHTML=t.toolPanelIcon,i.appendChild(r)}return e.appendChild(i),e}function ut(t){const e=R("tbw-shell-body"),o=t.panels.length>0,i=t.panels.length===1,n=R("tbw-grid-content");n.appendChild(Re());let r=null;if(o){r=X("aside",{class:t.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":t.position,role:"presentation",id:"tbw-tool-panel"});const s=t.position==="left"?"right":"left";r.appendChild(R("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":s,"aria-hidden":"true"}));const l=R("tbw-tool-panel-content",{role:"presentation"}),a=R("tbw-accordion");for(const c of t.panels){const u=`tbw-accordion-section${c.isExpanded?" expanded":""}${i?" single":""}`,d=R(u,{"data-section":c.id}),f=Ee("tbw-accordion-header",{"aria-expanded":String(c.isExpanded),"aria-controls":`tbw-section-${c.id}`});if(i&&f.setAttribute("aria-disabled","true"),c.icon){const h=X("span",{class:"tbw-accordion-icon"});h.innerHTML=c.icon,f.appendChild(h)}const p=X("span",{class:"tbw-accordion-title"});if(p.textContent=c.title,f.appendChild(p),!i){const h=X("span",{class:"tbw-accordion-chevron"});h.innerHTML=c.isExpanded?t.collapseIcon:t.expandIcon,f.appendChild(h)}d.appendChild(f),d.appendChild(R("tbw-accordion-content",{id:`tbw-section-${c.id}`,role:"presentation"})),a.appendChild(d)}l.appendChild(a),r.appendChild(l)}return t.position==="left"&&r?(e.appendChild(r),e.appendChild(n)):(e.appendChild(n),r&&e.appendChild(r)),e}function D(t){return t?typeof t=="string"?t:t.outerHTML:""}function ft(){return{toolPanels:new Map,headerContents:new Map,toolbarButtons:new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:new Set,apiToolPanelIds:new Set,isPanelOpen:!1,expandedSections:new Set,headerContentCleanups:new Map,panelCleanups:new Map,toolbarButtonCleanups:new Map}}function xe(t){return!!(t?.header?.title||t?.header?.toolbarButtons?.length||t?.toolPanels?.length||t?.headerContents?.length||t?.header?.lightDomContent?.length||t?.header?.hasToolButtonsContainer)}function Pe(t,e,o="☰"){const i=t?.header?.title??e.lightDomTitle??"",n=!!i,r=D(o),s=t?.header?.toolbarButtons??[],l=s.some(g=>g.element||g.render),a=[...e.toolbarButtons.values()].some(g=>g.element||g.render),c=e.toolPanels.size>0,d=(l||a)&&c,f=[...s].sort((g,m)=>(g.order??100)-(m.order??100)),p=[...e.toolbarButtons.values()].sort((g,m)=>(g.order??100)-(m.order??100));let h="";for(const g of f)(g.element||g.render)&&(h+=`<div class="tbw-toolbar-btn-slot" data-btn-slot="${g.id}"></div>`);for(const g of p)(g.element||g.render)&&(h+=`<div class="tbw-toolbar-btn-slot" data-btn-slot="${g.id}"></div>`);if(h+='<slot name="toolbar"></slot>',d&&(h+='<div class="tbw-toolbar-separator"></div>'),c){const g=e.isPanelOpen;h+=`<button class="${g?"tbw-toolbar-btn active":"tbw-toolbar-btn"}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${g}" aria-controls="tbw-tool-panel">${r}</button>`}return`
|
|
20
20
|
<div class="tbw-shell-header" part="shell-header" role="presentation">
|
|
21
|
-
${
|
|
21
|
+
${n?`<div class="tbw-shell-title">${$e(i)}</div>`:""}
|
|
22
22
|
<div class="tbw-shell-content" part="shell-content" role="presentation">
|
|
23
23
|
<slot name="header-content"></slot>
|
|
24
24
|
</div>
|
|
@@ -26,7 +26,19 @@
|
|
|
26
26
|
${h}
|
|
27
27
|
</div>
|
|
28
28
|
</div>
|
|
29
|
-
`}function U(t,e){const o=t.querySelector("tbw-grid-header");if(!o)return;if(!e.lightDomTitle){const i=o.getAttribute("title");i&&(e.lightDomTitle=i)}const n=o.querySelectorAll("tbw-grid-header-content");n.length>0&&e.lightDomHeaderContent.length===0&&(e.lightDomHeaderContent=Array.from(n),e.lightDomHeaderContent.forEach(i=>{i.setAttribute("slot","header-content")})),o.style.display="none"}function X(t,e){const o=t.querySelector(":scope > tbw-grid-tool-buttons");o&&(e.hasToolButtonsContainer=!0,o.setAttribute("slot","toolbar"))}function Y(t,e,o){t.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(i=>{const r=i,l=r.getAttribute("id"),s=r.getAttribute("title");if(!l||!s){console.warn(`[parseLightDomToolPanels] Tool panel missing required id or title attribute: id="${l??""}", title="${s??""}"`);return}const a=r.getAttribute("icon")??void 0,c=r.getAttribute("tooltip")??void 0,f=parseInt(r.getAttribute("order")??"100",10);let d;const u=o?.(r);if(u)d=u;else{const p=r.innerHTML.trim();d=g=>{const b=document.createElement("div");return b.innerHTML=p,g.appendChild(b),()=>b.remove()}}const w=e.toolPanels.get(l);if(w){if(u){w.render=d,w.order=f,w.icon=a,w.tooltip=c;const p=e.panelCleanups.get(l);p&&(p(),e.panelCleanups.delete(l))}return}const h={id:l,title:s,icon:a,tooltip:c,order:f,render:d};e.toolPanels.set(l,h),e.lightDomToolPanelIds.add(l),r.style.display="none"})}function Gt(t,e,o,n){const i=t.querySelector(".tbw-shell-toolbar");i&&i.addEventListener("click",l=>{const s=l.target;if(s.closest("[data-panel-toggle]")){n.onPanelToggle();return}const c=s.closest("[data-btn]");if(c){const f=c.getAttribute("data-btn");f&&n.onToolbarButtonClick(f)}});const r=t.querySelector(".tbw-accordion");r&&r.addEventListener("click",l=>{const a=l.target.closest(".tbw-accordion-header");if(a){const f=a.closest("[data-section]")?.getAttribute("data-section");f&&n.onSectionToggle(f)}})}function $t(t,e,o){const n=t.querySelector(".tbw-tool-panel"),i=t.querySelector("[data-resize-handle]"),r=t.querySelector(".tbw-shell-body");if(!n||!i||!r)return()=>{};const l=e?.toolPanel?.position??"right",s=200;let a=0,c=0,f=0,d=!1;const u=p=>{if(!d)return;p.preventDefault();const g=l==="left"?p.clientX-a:a-p.clientX,b=Math.min(f,Math.max(s,c+g));n.style.width=`${b}px`},w=()=>{if(!d)return;d=!1,i.classList.remove("resizing"),n.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const p=n.getBoundingClientRect().width;o(p),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",w)},h=p=>{p.preventDefault(),d=!0,a=p.clientX,c=n.getBoundingClientRect().width,f=r.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",u),document.addEventListener("mouseup",w)};return i.addEventListener("mousedown",h),()=>{i.removeEventListener("mousedown",h),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",w)}}function Ft(t,e,o){const n=[...e?.header?.toolbarButtons??[],...o.toolbarButtons.values()];for(const i of n){const r=t.querySelector(`[data-btn-slot="${i.id}"]`);if(!r)continue;const l=o.toolbarButtonCleanups.get(i.id);if(l&&(l(),o.toolbarButtonCleanups.delete(i.id)),i.element)r.appendChild(i.element);else if(i.render){const s=i.render(r);s&&o.toolbarButtonCleanups.set(i.id,s)}}}function Ge(t,e){const o=t.querySelector(".tbw-shell-content");if(!o)return;const n=[...e.headerContents.values()].sort((r,l)=>(r.order??100)-(l.order??100)),i=o.querySelector('slot[name="header-content"]');for(const r of n){const l=e.headerContentCleanups.get(r.id);l&&(l(),e.headerContentCleanups.delete(r.id));let s=o.querySelector(`[data-header-content="${r.id}"]`);s||(s=document.createElement("div"),s.setAttribute("data-header-content",r.id),i?o.insertBefore(s,i):o.appendChild(s));const a=r.render(s);a&&e.headerContentCleanups.set(r.id,a)}}function Ut(t,e,o){if(!e.isPanelOpen)return;const n=q(o?.expand??M.expand),i=q(o?.collapse??M.collapse);for(const[r,l]of e.toolPanels){const s=e.expandedSections.has(r),a=t.querySelector(`[data-section="${r}"]`),c=a?.querySelector(".tbw-accordion-content");if(!a||!c)continue;a.classList.toggle("expanded",s);const f=a.querySelector(".tbw-accordion-header");f&&f.setAttribute("aria-expanded",String(s));const d=a.querySelector(".tbw-accordion-chevron");if(d&&(d.innerHTML=s?i:n),s){if(c.children.length===0){const u=l.render(c);u&&e.panelCleanups.set(r,u)}}else{const u=e.panelCleanups.get(r);u&&(u(),e.panelCleanups.delete(r)),c.innerHTML=""}}}function $e(t,e){const o=t.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",e.isPanelOpen),o.setAttribute("aria-pressed",String(e.isPanelOpen)))}function Fe(t,e){const o=t.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",e.isPanelOpen),e.isPanelOpen||(o.style.width=""))}function Xt(t,e){const o=[];for(const n of t?.header?.toolbarButtons??[])o.push({id:n.id,label:n.label??"",source:"config"});for(const n of e.toolbarButtons.values())o.push({id:n.id,label:n.label??"",source:"config"});for(const n of e.toolPanels.values())o.push({id:`panel-toggle-${n.id}`,label:n.tooltip??n.title,source:"panel-toggle",panelId:n.id});return o}function Yt(t){for(const e of t.headerContentCleanups.values())e();t.headerContentCleanups.clear();for(const e of t.panelCleanups.values())e();t.panelCleanups.clear();for(const e of t.toolbarButtonCleanups.values())e();if(t.toolbarButtonCleanups.clear(),t.isPanelOpen)for(const e of t.expandedSections)t.toolPanels.get(e)?.onClose?.();t.isPanelOpen=!1,t.expandedSections.clear(),t.toolPanels.clear(),t.headerContents.clear(),t.toolbarButtons.clear(),t.lightDomHeaderContent=[]}function jt(t,e){let o=!1;const n={get isInitialized(){return o},setInitialized(i){o=i},get isPanelOpen(){return t.isPanelOpen},get activePanel(){return t.isPanelOpen&&t.expandedSections.size>0?[...t.expandedSections][0]:null},get expandedSections(){return[...t.expandedSections]},openToolPanel(){if(t.isPanelOpen)return;if(t.toolPanels.size===0){console.warn("[tbw-grid] No tool panels registered");return}if(t.isPanelOpen=!0,t.expandedSections.size===0&&t.toolPanels.size>0){const l=[...t.toolPanels.values()].sort((s,a)=>(s.order??100)-(a.order??100))[0];l&&t.expandedSections.add(l.id)}const i=e.getShadow();$e(i,t),Fe(i,t),Ut(i,t,e.getAccordionIcons()),e.emit("tool-panel-open",{sections:n.expandedSections})},closeToolPanel(){if(!t.isPanelOpen)return;for(const r of t.panelCleanups.values())r();t.panelCleanups.clear();for(const r of t.toolPanels.values())r.onClose?.();t.isPanelOpen=!1;const i=e.getShadow();$e(i,t),Fe(i,t),e.emit("tool-panel-close",{})},toggleToolPanel(){t.isPanelOpen?n.closeToolPanel():n.openToolPanel()},toggleToolPanelSection(i){const r=t.toolPanels.get(i);if(!r){console.warn(`[tbw-grid] Tool panel section "${i}" not found`);return}if(t.toolPanels.size===1)return;const l=e.getShadow(),s=t.expandedSections.has(i);if(s){const a=t.panelCleanups.get(i);a&&(a(),t.panelCleanups.delete(i)),r.onClose?.(),t.expandedSections.delete(i),de(l,i,!1)}else{for(const[a,c]of t.toolPanels)if(a!==i&&t.expandedSections.has(a)){const f=t.panelCleanups.get(a);f&&(f(),t.panelCleanups.delete(a)),c.onClose?.(),t.expandedSections.delete(a),de(l,a,!1);const d=l.querySelector(`[data-section="${a}"] .tbw-accordion-content`);d&&(d.innerHTML="")}t.expandedSections.add(i),de(l,i,!0),Kt(l,t,i)}e.emit("tool-panel-section-toggle",{id:i,expanded:!s})},getToolPanels(){return[...t.toolPanels.values()]},registerToolPanel(i){if(t.toolPanels.has(i.id)){console.warn(`[tbw-grid] Tool panel "${i.id}" already registered`);return}t.toolPanels.set(i.id,i),o&&e.refreshShellHeader()},unregisterToolPanel(i){if(t.expandedSections.has(i)){const r=t.panelCleanups.get(i);r&&(r(),t.panelCleanups.delete(i)),t.expandedSections.delete(i)}t.toolPanels.delete(i),o&&e.refreshShellHeader()},getHeaderContents(){return[...t.headerContents.values()]},registerHeaderContent(i){if(t.headerContents.has(i.id)){console.warn(`[tbw-grid] Header content "${i.id}" already registered`);return}t.headerContents.set(i.id,i),o&&Ge(e.getShadow(),t)},unregisterHeaderContent(i){const r=t.headerContentCleanups.get(i);r&&(r(),t.headerContentCleanups.delete(i)),t.headerContents.get(i)?.onDestroy?.(),t.headerContents.delete(i),e.getShadow().querySelector(`[data-header-content="${i}"]`)?.remove()},getToolbarButtons(){return Xt(e.getShellConfig(),t)},registerToolbarButton(i){if(t.toolbarButtons.has(i.id)){console.warn(`[tbw-grid] Toolbar button "${i.id}" already registered`);return}t.toolbarButtons.set(i.id,i),o&&e.refreshShellHeader()},unregisterToolbarButton(i){const r=t.toolbarButtonCleanups.get(i);r&&(r(),t.toolbarButtonCleanups.delete(i)),t.toolbarButtons.delete(i),o&&e.refreshShellHeader()},setToolbarButtonDisabled(i,r){}};return n}function de(t,e,o){const n=t.querySelector(`[data-section="${e}"]`);n&&n.classList.toggle("expanded",o)}function Kt(t,e,o){const n=e.toolPanels.get(o);if(!n?.render)return;const i=t.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!i)return;const r=n.render(i);r&&e.panelCleanups.set(o,r)}function Zt(t,e,o,n){const i=We(e,o);if(t.replaceChildren(),i){const r=q(n?.toolPanel??M.toolPanel),l=q(n?.expand??M.expand),s=q(n?.collapse??M.collapse),c=[...e?.header?.toolbarButtons??[]].sort((b,_)=>(b.order??100)-(_.order??100)),f=[...o.toolbarButtons.values()].sort((b,_)=>(b.order??100)-(_.order??100)),d={title:e?.header?.title??o.lightDomTitle??void 0,hasPanels:o.toolPanels.size>0,isPanelOpen:o.isPanelOpen,toolPanelIcon:r,configButtons:c.map(b=>({id:b.id,hasElement:!!b.element,hasRender:!!b.render})),apiButtons:f.map(b=>({id:b.id,hasElement:!!b.element,hasRender:!!b.render}))},u=[...o.toolPanels.values()].sort((b,_)=>(b.order??100)-(_.order??100)),w={position:e?.toolPanel?.position??"right",isPanelOpen:o.isPanelOpen,expandIcon:l,collapseIcon:s,panels:u.map(b=>({id:b.id,title:b.title,icon:q(b.icon),isExpanded:o.expandedSections.has(b.id)}))},h=qt(d),p=Wt(w),g=qe({hasShell:!0,shellHeader:h,shellBody:p});t.appendChild(g)}else{const r=qe({hasShell:!1});t.appendChild(r)}return i}function Qt(){return{startY:null,startX:null,scrollTop:null,scrollLeft:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0}}function Jt(t){t.startY=null,t.startX=null,t.scrollTop=null,t.scrollLeft=null,t.lastY=null,t.lastX=null,t.lastTime=null}function Ue(t){t.momentumRaf&&(cancelAnimationFrame(t.momentumRaf),t.momentumRaf=0)}function eo(t,e,o){if(t.touches.length!==1)return;Ue(e);const n=t.touches[0];e.startY=n.clientY,e.startX=n.clientX,e.lastY=n.clientY,e.lastX=n.clientX,e.lastTime=performance.now(),e.scrollTop=o.fauxScrollbar.scrollTop,e.scrollLeft=o.scrollArea?.scrollLeft??0,e.velocityY=0,e.velocityX=0}function to(t,e,o){if(t.touches.length!==1||e.startY===null||e.startX===null||e.scrollTop===null||e.scrollLeft===null)return!1;const n=t.touches[0],i=n.clientY,r=n.clientX,l=performance.now(),s=e.startY-i,a=e.startX-r;if(e.lastTime!==null&&e.lastY!==null&&e.lastX!==null){const p=l-e.lastTime;p>0&&(e.velocityY=(e.lastY-i)/p,e.velocityX=(e.lastX-r)/p)}e.lastY=i,e.lastX=r,e.lastTime=l;const{scrollTop:c,scrollHeight:f,clientHeight:d}=o.fauxScrollbar,u=f-d,w=s>0&&c<u||s<0&&c>0;let h=!1;if(o.scrollArea){const{scrollLeft:p,scrollWidth:g,clientWidth:b}=o.scrollArea,_=g-b;h=a>0&&p<_||a<0&&p>0}return w&&(o.fauxScrollbar.scrollTop=e.scrollTop+s),h&&o.scrollArea&&(o.scrollArea.scrollLeft=e.scrollLeft+a),w||h}function oo(t,e){(Math.abs(t.velocityY)>.1||Math.abs(t.velocityX)>.1)&&no(t,e),Jt(t)}function no(t,e){const i=()=>{t.velocityY*=.95,t.velocityX*=.95;const r=t.velocityY*16,l=t.velocityX*16;Math.abs(t.velocityY)>.01&&(e.fauxScrollbar.scrollTop+=r),Math.abs(t.velocityX)>.01&&e.scrollArea&&(e.scrollArea.scrollLeft+=l),Math.abs(t.velocityY)>.01||Math.abs(t.velocityX)>.01?t.momentumRaf=requestAnimationFrame(i):t.momentumRaf=0};t.momentumRaf=requestAnimationFrame(i)}function io(t,e,o,n){t.addEventListener("touchstart",i=>eo(i,e,o),{passive:!0,signal:n}),t.addEventListener("touchmove",i=>{to(i,e,o)&&i.preventDefault()},{passive:!1,signal:n}),t.addEventListener("touchend",()=>oo(e,o),{passive:!0,signal:n})}class Xe{constructor(e){this.grid=e}plugins=[];pluginMap=new Map;cellRenderers=new Map;headerRenderers=new Map;cellEditors=new Map;attachAll(e){for(const o of e)this.attach(o)}attach(e){if(this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[o,n]of Object.entries(e.cellRenderers))this.cellRenderers.set(o,n);if(e.headerRenderers)for(const[o,n]of Object.entries(e.headerRenderers))this.headerRenderers.set(o,n);if(e.cellEditors)for(const[o,n]of Object.entries(e.cellEditors))this.cellEditors.set(o,n);e.attach(this.grid)}detachAll(){for(let e=this.plugins.length-1;e>=0;e--)this.plugins[e].detach();this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear()}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(o=>o.name===e)}hasPlugin(e){return this.pluginMap.has(e)}getAll(){return this.plugins}getCellRenderer(e){return this.cellRenderers.get(e)}getHeaderRenderer(e){return this.headerRenderers.get(e)}getCellEditor(e){return this.cellEditors.get(e)}getAllStyles(){return this.plugins.filter(e=>e.styles).map(e=>e.styles).join(`
|
|
30
|
-
|
|
31
|
-
`);if(r.includes(".tbw-grid-root")&&r.includes(":host")){o=r;break}}catch{continue}o?(e.replaceSync(o),this.#n.adoptedStyleSheets=[e]):(typeof process>"u"||process.env?.NODE_ENV!=="test")&&console.warn("[tbw-grid] Could not find grid.css in document.styleSheets. Grid styling will not work.","Available stylesheets:",Array.from(document.styleSheets).map(n=>n.href||"(inline)"))}catch(o){console.warn("[tbw-grid] Failed to extract grid.css from document stylesheets:",o)}}getPlugin(e){return this.#t?.getPlugin(e)}getPluginByName(e){return this.#t?.getPluginByName(e)}requestRender(){this.#P(),this.#L(),F(this),I(this),this.refreshVirtualWindow(!0)}updateTemplate(){I(this)}requestAfterRender(){this.#t?.afterRender()}#Z(){this.#t=new Xe(this);const e=this.#o?.plugins,o=Array.isArray(e)?e:[];this.#t.attachAll(o)}#Q(){const e=this.#t?.getAllStyles()??"";if(e){const o=document.createElement("style");o.setAttribute("data-plugin","all"),o.textContent=e,this.#n.appendChild(o)}}#J(){this.#t&&this.#t.detachAll();for(const e of this.#e.toolPanels.keys()){const o=this.#e.lightDomToolPanelIds.has(e),n=this.#e.apiToolPanelIds.has(e);if(!o&&!n){const i=this.#e.panelCleanups.get(e);i&&(i(),this.#e.panelCleanups.delete(e)),this.#e.toolPanels.delete(e)}}for(const e of this.#e.headerContents.keys()){const o=this.#e.headerContentCleanups.get(e);o&&(o(),this.#e.headerContentCleanups.delete(e)),this.#e.headerContents.delete(e)}this.#Z(),this.#Q(),this.#ee(),this.#R=this.#t?.getAll().some(e=>e.onScroll)??!1}#se(){this.#t?.detachAll()}#ee(){if(!this.#t)return;const e=this.#t.getToolPanels();for(const{panel:n}of e)this.#e.toolPanels.has(n.id)||this.#e.toolPanels.set(n.id,n);const o=this.#t.getHeaderContents();for(const{content:n}of o)this.#e.headerContents.has(n.id)||this.#e.headerContents.set(n.id,n)}#b(){const e=D.getAdapters();if(e.length===0&&!this.__frameworkAdapter)return;const o=this.__frameworkAdapter;return n=>{if(o?.createToolPanelRenderer){const i=o.createToolPanelRenderer(n);if(i)return i}for(const i of e)if(i.createToolPanelRenderer){const r=i.createToolPanelRenderer(n);if(r)return r}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",D.version),this._rows=Array.isArray(this.#l)?[...this.#l]:[],this.#s&&(this.#s.abort(),this.#A=!1),this.#s=new AbortController,this.#u&&(De(this.#u),this.#u=void 0),U(this,this.#e),X(this,this.#e),Y(this,this.#e,this.#b()),this.#r(),this.#Z(),this.#ee(),this.#H||(this.#U(),this.#Q(),this.#H=!0),this.#I(),this.#u=It(()=>{this.#Se()},{timeout:100})}disconnectedCallback(){this.#u&&(De(this.#u),this.#u=void 0),this.#se(),Yt(this.#e),this.#i.setInitialized(!1),this.#x?.(),this.#x=void 0,Ue(this.#K),this.#s&&(this.#s.abort(),this.#s=void 0),this.#v?.abort(),this.#v=void 0,this.#A=!1,this._resizeController&&this._resizeController.dispose(),this.#p&&(this.#p.disconnect(),this.#p=void 0),this.#w&&(this.#w.disconnect(),this.#w=void 0,this.#B=!1),this.#d&&(this.#d.disconnect(),this.#d=void 0),K(this),this._rowEditSnapshots.clear(),this._changedRowIndices.clear(),this.#C.clear();for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#O=!1}attributeChangedCallback(e,o,n){if(o===n||!n||n==="null"||n==="undefined")return;const r={rows:"rows",columns:"columns","grid-config":"gridConfig","fit-mode":"fitMode","edit-on":"editOn"}[e];if(r)if(e==="rows"||e==="columns"||e==="grid-config")try{this[r]=JSON.parse(n)}catch{console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`,n)}else this[r]=n}#I(){const o=this.#n.querySelector(".tbw-grid-content")??this.#n.querySelector(".tbw-grid-root");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.__rowsBodyEl=o?.querySelector(".rows-body"),this.#i.isInitialized){Ge(this.#n,this.#e),Ft(this.#n,this.#o?.shell,this.#e);const r=this.#o?.shell?.toolPanel?.defaultOpen;r&&this.#e.toolPanels.has(r)&&(this.openToolPanel(),this.#e.expandedSections.add(r))}if(this.setAttribute("data-upgraded",""),this.#O=!0,this._resizeController=Bt(this),this.#a(),this.#ae(o),this.#A)return;this.#A=!0;const n=this.disconnectSignal;this.addEventListener("keydown",r=>vt(this,r),{signal:n}),document.addEventListener("keydown",r=>{r.key==="Escape"&&this._activeEditRows!==-1&&N(this,this._activeEditRows,!0)},{capture:!0,signal:n}),document.addEventListener("mousedown",r=>{if(this._activeEditRows===-1)return;const l=this.findRenderedRowElement(this._activeEditRows);!l||(r.composedPath&&r.composedPath()||[]).includes(l)||N(this,this._activeEditRows,!1)},{signal:n}),this.#n.addEventListener("mousedown",r=>this.#_e(r),{signal:n}),document.addEventListener("mousemove",r=>this.#Ce(r),{signal:n}),document.addEventListener("mouseup",r=>this.#Ee(r),{signal:n});const i=this.#o.rowHeight;i&&i>0?this._virtualization.rowHeight=i:requestAnimationFrame(()=>this.#te()),queueMicrotask(()=>this.#de()),requestAnimationFrame(()=>requestAnimationFrame(()=>this.#j?.()))}#te(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const o=e.querySelectorAll(".cell");let n=0;o.forEach(l=>{const s=l.offsetHeight;s>n&&(n=s)});const i=e.getBoundingClientRect(),r=Math.max(i.height,n);r>0&&r!==this._virtualization.rowHeight&&(this._virtualization.rowHeight=r,this.refreshVirtualWindow(!0))}#ae(e){this.#v?.abort(),this.#v=new AbortController;const o=this.#v.signal,n=e?.querySelector(".faux-vscroll"),i=e?.querySelector(".rows");if(this._virtualization.container=n??this,this.#R=this.#t?.getAll().some(r=>r.onScroll)??!1,n&&i){n.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#R)return;const s=n.scrollTop,a=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)i.style.transform=`translateY(${-s}px)`;else{const c=Math.floor(s/a),f=c-c%2,d=-(s-f*a);i.style.transform=`translateY(${d}px)`}this.#S=s,this.#f||(this.#f=requestAnimationFrame(()=>{this.#f=0,this.#S!==null&&(this.#ve(this.#S),this.#S=null)}))},{passive:!0,signal:o});const r=this.#n.querySelector(".tbw-grid-content"),l=this.#n.querySelector(".tbw-scroll-area");r&&(r.addEventListener("wheel",s=>{const a=s.shiftKey||Math.abs(s.deltaX)>Math.abs(s.deltaY);if(a&&l){const c=s.shiftKey?s.deltaY:s.deltaX,{scrollLeft:f,scrollWidth:d,clientWidth:u}=l;(c>0&&f<d-u||c<0&&f>0)&&(s.preventDefault(),l.scrollLeft+=c)}else if(!a){const{scrollTop:c,scrollHeight:f,clientHeight:d}=n;(s.deltaY>0&&c<f-d||s.deltaY<0&&c>0)&&(s.preventDefault(),n.scrollTop+=s.deltaY)}},{passive:!1,signal:o}),io(r,this.#K,{fauxScrollbar:n,scrollArea:l},o))}this._bodyEl&&zt(this,this._bodyEl,o),this.#p?.disconnect(),this._virtualization.viewportEl&&(this.#p=new ResizeObserver(()=>{this.#f||(this.#f=requestAnimationFrame(()=>{this.#f=0,this.refreshVirtualWindow(!0),z(this)}))}),this.#p.observe(this._virtualization.viewportEl)),this._virtualization.enabled&&requestAnimationFrame(()=>{this.refreshVirtualWindow(!0),this.#ce()})}#B=!1;#ce(){if(this.#B)return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;this.#B=!0,this.#w?.disconnect();const o=e.querySelectorAll(".cell");o.length>0&&(this.#w=new ResizeObserver(()=>{this.#te()}),o.forEach(n=>this.#w.observe(n)))}#q(e,o){this.dispatchEvent(new CustomEvent(e,{detail:o,bubbles:!0,composed:!0}))}#de(){this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((o,n)=>{const i=n===this._focusRow;o.setAttribute("aria-selected",String(i)),o.querySelectorAll(".cell").forEach((r,l)=>{r.setAttribute("aria-selected",String(i&&l===this._focusCol))})})}#_(e){this.#M[e]=!0,!this.#m&&(this.#m=!0,queueMicrotask(()=>this.#ue()))}#ue(){if(!this.#m||!this.#O){this.#m=!1;return}const e=this.#M;if(this.#m=!1,this.#M={rows:!1,columns:!1,gridConfig:!1,fitMode:!1,editMode:!1},e.gridConfig){this.#be();return}e.columns&&this.#fe(),e.rows&&this.#he(),e.fitMode&&this.#pe(),e.editMode&&this.#we()}#he(){this._rows=Array.isArray(this.#l)?[...this.#l]:[],this.#P(),this._columns.length>0||Array.isArray(this.#o?.columns)&&this.#o.columns.length>0||Array.isArray(this.#c)&&this.#c.length>0?(this.#L(),this.refreshVirtualWindow(!0)):this.#a()}#fe(){K(this),this.#r(),this.#a()}#pe(){this.#r(),this.#o.fitMode==="fixed"?(this.__didInitialAutoSize=!1,Ce(this)):(this._columns.forEach(o=>{!o.__userResized&&o.__autoSized&&delete o.width}),I(this))}#we(){this.#r(),this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++,this.refreshVirtualWindow(!0)}#be(){U(this,this.#e),X(this,this.#e);const e=!!this.#n.querySelector(".has-shell"),o=!!this.#n.querySelector(".tbw-tool-panel"),n=this.#n.querySelectorAll(".tbw-accordion-section").length;_e(this),this.#r(),this.#J(),Y(this,this.#e,this.#b());const i=We(this.#o,this.#e),r=this.#e.toolPanels.size>0,l=this.#e.toolPanels.size!==n;if(e!==i||!e&&i||!o&&r||o&&l){this.#U(),this.#I();return}e&&this.#ge(),this.#P(),this.#L(),F(this),I(this),this.refreshVirtualWindow(!0)}#ge(){const e=this.#n.querySelector(".tbw-shell-header");if(!e)return;const o=this.#o.shell?.header?.title??this.#e.lightDomTitle;let n=e.querySelector(".tbw-shell-title");o?(n||(n=document.createElement("h2"),n.className="tbw-shell-title",n.setAttribute("part","shell-title"),e.insertBefore(n,e.firstChild)),n.textContent=o):n&&n.remove()}#L(){if(this.#t){const e=this.#N.length>0?this.#N:this._columns,o=e.filter(r=>!r.hidden),n=e.filter(r=>r.hidden),i=this.#t.processColumns([...o]);if(i!==o){const r=new Map(i.map((s,a)=>[s.field,{col:s,order:a}]));if(!o.some(s=>r.has(s.field))&&i.length>0)this._columns=[...i,...n];else{const s=e.map(a=>{if(a.hidden)return a;const c=r.get(a.field);return c?c.col:a});this._columns=s}}else this._columns=[...e]}}#P(){K(this);const e=Array.isArray(this.#l)?[...this.#l]:[],o=this.#t?.processRows(e)??e;this._rows=o}#r(){const e=this.#g?{...this.#g}:{};let o=Array.isArray(e.columns)?[...e.columns]:[];const n=(this.__lightDomColumnsCache||[]).map(i=>({...i}));if(n.length){const i={};o.forEach(r=>i[r.field]=r),n.forEach(r=>{const l=i[r.field];if(!l)o.push(r),i[r.field]=r;else{r.header&&!l.header&&(l.header=r.header),r.type&&!l.type&&(l.type=r.type),l.sortable=l.sortable||r.sortable,r.resizable&&(l.resizable=!0),r.editable&&(l.editable=!0);const s=r.renderer||r.viewRenderer,a=l.renderer||l.viewRenderer;s&&!a&&(l.viewRenderer=s,r.renderer&&(l.renderer=s)),r.editor&&!l.editor&&(l.editor=r.editor)}})}if(this.#c&&this.#c.length&&(o=[...this.#c]),(!o||o.length===0)&&this._rows.length&&(o=we(this._rows).columns),o.length){o.forEach(l=>{l.sortable===void 0&&(l.sortable=!0),l.resizable===void 0&&(l.resizable=!0);const s=l;s.__originalWidth===void 0&&typeof l.width=="number"&&(s.__originalWidth=l.width)});const i=this.#o.columns;i?.some(l=>l.__compiledView||l.__compiledEditor)?e.columns=i:e.columns=o}else{const i=this.#o.columns;i?.some(r=>r.__compiledView||r.__compiledEditor)&&(e.columns=i)}this.#E&&(e.fitMode=this.#E),e.fitMode||(e.fitMode="stretch"),this.#y&&(e.editOn=this.#y),this.#e.lightDomTitle&&(e.shell||(e.shell={}),e.shell.header||(e.shell.header={}),e.shell.header.title||(e.shell.header.title=this.#e.lightDomTitle)),e.rowHeight&&e.rowHeight>0&&(this._virtualization.rowHeight=e.rowHeight),e.columnState&&!this.#h&&(this.#h=e.columnState),this.#o=e,e.fitMode==="fixed"&&this._columns.forEach(i=>{i.width==null&&(i.width=80)}),this.#me()}#me(){const e={...pe,...this.#o.animation},o=e.mode??"reduced-motion";let n=1;o===!1||o==="off"?n=0:(o===!0||o==="on")&&(n=1),this.style.setProperty("--tbw-animation-duration",`${e.duration}ms`),this.style.setProperty("--tbw-animation-easing",e.easing??"ease-out"),this.style.setProperty("--tbw-animation-enabled",String(n)),this.dataset.animationMode=typeof o=="boolean"?o?"on":"off":o}#W(e,o,n=this.__rowRenderEpoch){this.#k||(this.#k=(i,r,l)=>this.#t?.renderRow(i,r,l)??!1),St(this,e,o,n,this.#k)}#V=-1;#oe=-1;#ne(e,o){if(e===this.#V&&o===this.#oe)return;const n=this.#V;this.#V=e,this.#oe=o,this.__rowsBodyEl&&(this.__rowsBodyEl.setAttribute("aria-rowcount",String(e)),this.__rowsBodyEl.setAttribute("aria-colcount",String(o))),e!==n&&this._bodyEl&&(e>0?this._bodyEl.setAttribute("role","rowgroup"):this._bodyEl.removeAttribute("role"))}#a(){if(!this.isConnected||!this._headerRowEl||!this._bodyEl)return;const e=this.#g?.columns||this.#c||[];if(e.length){const n=new Map(this._columns.filter(r=>r.hidden).map(r=>[r.field,!0])),i=e.map(r=>({...r,hidden:n.get(r.field)??r.hidden}));this._columns=i}if(_e(this),this.#r(),this.#J(),this.#N=[...this._columns],this.#P(),this.#L(),this.#h){const n=this.#h;this.#h=void 0,this.#ie(n)}F(this),I(this),this.refreshVirtualWindow(!0),this.#o.fitMode==="fixed"&&!this.__didInitialAutoSize&&requestAnimationFrame(()=>Ce(this)),this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),queueMicrotask(()=>this.#t?.afterRender())}#ie(e){const o=this.#o.columns??[],n=this.#t?.getAll()??[];Ze(this,e,o,n);for(const i of e.columns){const r=o.find(l=>l.field===i.field);r&&(r.hidden=!i.visible)}}#ve(e){if(this.refreshVirtualWindow(!1),this.#t?.onScrollRender(),this.#R){const o=this._virtualization.container,n=this.#re;n.scrollTop=e,n.scrollLeft=o?.scrollLeft??0,n.scrollHeight=o?.scrollHeight??0,n.scrollWidth=o?.scrollWidth??0,n.clientHeight=o?.clientHeight??0,n.clientWidth=o?.clientWidth??0,this.#t?.onScroll(n)}}findHeaderRow(){return this.#n.querySelector(".header-row")}findRenderedRowElement(e){return Array.from(this._bodyEl.querySelectorAll(".data-grid-row")).find(o=>{const n=o.querySelector(".cell[data-row]");return n&&Number(n.getAttribute("data-row"))===e})||null}_dispatchCellClick(e,o,n,i){const r=this._rows[o],l=this._columns[n];if(!r||!l)return!1;const s={row:r,rowIndex:o,colIndex:n,field:l.field,value:r[l.field],cellEl:i,originalEvent:e};return this.#t?.onCellClick(s)??!1}_dispatchRowClick(e,o,n,i){if(!n)return!1;const r={rowIndex:o,row:n,rowEl:i,originalEvent:e};return this.#t?.onRowClick(r)??!1}_dispatchHeaderClick(e,o,n){const i=this._columns[o];if(!i)return!1;const r={colIndex:o,field:i.field,column:i,headerEl:n,originalEvent:e};return this.#t?.onHeaderClick(r)??!1}_dispatchKeyDown(e){return this.#t?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,o){return this.#t?.getHorizontalScrollOffsets(e,o)??{left:0,right:0}}queryPlugins(e){return this.#t?.queryPlugins(e)??[]}#G(e,o){let n=null;const i=e.composedPath?.();if(i&&i.length>0?n=i[0]:n=e.target,n&&!this.#n.contains(n)){const h=this.#n.elementFromPoint(e.clientX,e.clientY);h&&(n=h)}const r=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),s=n?.closest?.(".header-row");let a,c,f,d,u,w;return r&&(a=parseInt(r.getAttribute("data-row")??"-1",10),c=parseInt(r.getAttribute("data-col")??"-1",10),a>=0&&c>=0&&(f=this._rows[a],w=this._columns[c],d=w?.field,u=f&&d?f[d]:void 0)),{type:o,row:f,rowIndex:a!==void 0&&a>=0?a:void 0,colIndex:c!==void 0&&c>=0?c:void 0,field:d,value:u,column:w,originalEvent:e,cellElement:r??void 0,rowElement:l??void 0,isHeader:!!s,cell:a!==void 0&&c!==void 0&&a>=0&&c>=0?{row:a,col:c}:void 0}}#_e(e){const o=this.#G(e,"mousedown");(this.#t?.onCellMouseDown(o)??!1)&&(this.#T=!0)}#Ce(e){if(!this.#T)return;const o=this.#G(e,"mousemove");this.#t?.onCellMouseMove(o)}#Ee(e){if(!this.#T)return;const o=this.#G(e,"mouseup");this.#t?.onCellMouseUp(o),this.#T=!1}get changedRows(){return Ae(this)}get changedRowIndices(){return xe(this)}async resetChangedRows(e){xt(this,e)}async beginBulkEdit(e){Lt(this,e,{findRenderedRowElement:o=>this.findRenderedRowElement?.(o)??null})}async commitActiveRowEdit(){Pt(this)}async cancelActiveRowEdit(){Ht(this)}async ready(){return this.#Y}async forceLayout(){this.#a(),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)))}async getConfig(){return Object.freeze({...this.#o||{}})}#$={emit:(e,o)=>this.#q(e,o),clearRowPool:()=>{this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++},setup:()=>this.#a(),requestStateChange:()=>this.requestStateChange()};setColumnVisible(e,o){return fe(this,e,o,this.#$)}toggleColumnVisibility(e){return Je(this,e,this.#$)}isColumnVisible(e){return et(this,e)}showAllColumns(){tt(this,this.#$)}getAllColumns(){return ot(this)}setColumnOrder(e){it(this,e,{renderHeader:()=>F(this),updateTemplate:()=>I(this),refreshVirtualWindow:()=>this.refreshVirtualWindow(!0)})}getColumnOrder(){return nt(this)}getColumnState(){const e=this.#t?.getAll()??[];return he(this,e)}set columnState(e){e&&(this.#h=e,this.#H&&this.#ye(e))}get columnState(){return this.getColumnState()}#ye(e){(this.#o.columns??[]).forEach(n=>{n.hidden=!1}),this.#ie(e),this.#a()}requestStateChange(){this.#z||(this.#z=Qe(this,()=>this.#t?.getAll()??[],e=>this.#q("column-state-change",e))),this.#z()}resetColumnState(){this.#h=void 0,(this.#o.columns??[]).forEach(n=>{n.hidden=!1}),this._sortState=null,this.__originalOrder=[],this.#r(),this.#a();const o=this.#t?.getAll()??[];for(const n of o)if(n.applyColumnState)for(const i of this._columns)n.applyColumnState(i.field,{field:i.field,order:0,visible:!0});this.requestStateChange()}get isToolPanelOpen(){return this.#i.isPanelOpen}get activeToolPanel(){return this.#i.activePanel}get expandedToolPanelSections(){return this.#i.expandedSections}openToolPanel(){this.#i.openToolPanel()}closeToolPanel(){this.#i.closeToolPanel()}toggleToolPanel(){this.#i.toggleToolPanel()}toggleToolPanelSection(e){this.#i.toggleToolPanelSection(e)}getToolPanels(){return this.#i.getToolPanels()}registerToolPanel(e){this.#e.apiToolPanelIds.add(e.id),this.#i.registerToolPanel(e)}unregisterToolPanel(e){this.#e.apiToolPanelIds.delete(e),this.#i.unregisterToolPanel(e)}getHeaderContents(){return this.#i.getHeaderContents()}registerHeaderContent(e){this.#i.registerHeaderContent(e)}unregisterHeaderContent(e){this.#i.unregisterHeaderContent(e)}getToolbarButtons(){return this.#i.getToolbarButtons()}registerToolbarButton(e){this.#i.registerToolbarButton(e)}unregisterToolbarButton(e){this.#i.unregisterToolbarButton(e)}setToolbarButtonDisabled(e,o){this.#i.setToolbarButtonDisabled(e,o)}refreshShellHeader(){U(this,this.#e),X(this,this.#e),Y(this,this.#e,this.#b()),this.#U(),this.#I()}#C=new Map;registerStyles(e,o){this.unregisterStyles(e);const n=document.createElement("style");n.id=`tbw-custom-${e}`,n.textContent=o,this.#n.appendChild(n),this.#C.set(e,n)}unregisterStyles(e){const o=this.#C.get(e);o&&(o.remove(),this.#C.delete(e))}getRegisteredStyles(){return Array.from(this.#C.keys())}#Se(){this.#d&&this.#d.disconnect();let e=null,o=!1,n=!1;const i=()=>{if(e=null,o){const r=this.#e.lightDomTitle,l=this.#e.hasToolButtonsContainer;U(this,this.#e),X(this,this.#e),Y(this,this.#e,this.#b());const s=this.#e.lightDomTitle,a=this.#e.hasToolButtonsContainer;if(s&&!r||a&&!l){this.#r();const c=this.#n.querySelector(".tbw-shell-header");if(c){const f=Ve(this.#o.shell,this.#e,this.#o.icons?.toolPanel),d=document.createElement("div");d.innerHTML=f;const u=d.firstElementChild;u&&(c.replaceWith(u),this.#X())}}o=!1}n&&(this.__lightDomColumnsCache=void 0,this.#a(),n=!1)};this.#d=new MutationObserver(r=>{for(const l of r){for(const s of l.addedNodes){if(s.nodeType!==Node.ELEMENT_NODE)continue;const c=s.tagName.toLowerCase();c==="tbw-grid-header"?o=!0:(c==="tbw-grid-column"||c==="tbw-grid-detail")&&(n=!0)}if(l.type==="attributes"&&l.target.nodeType===Node.ELEMENT_NODE){const a=l.target.tagName.toLowerCase();a==="tbw-grid-header"?o=!0:a==="tbw-grid-column"&&(n=!0)}}(o||n)&&!e&&(e=setTimeout(i,0))}),this.#d.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden"]})}refreshColumns(){this.#D||(this.#D=requestAnimationFrame(()=>{this.#D=0,this.#Re()}))}#Re(){this.__lightDomColumnsCache=void 0,K(this);const e=this.#e.lightDomTitle,o=this.#e.hasToolButtonsContainer;U(this,this.#e),X(this,this.#e),Y(this,this.#e,this.#b());const n=this.#e.lightDomTitle,i=this.#e.hasToolButtonsContainer;if(n&&!e||i&&!o){this.#r();const l=this.#n.querySelector(".tbw-shell-header");if(l){const s=Ve(this.#o.shell,this.#e,this.#o.icons?.toolPanel),a=document.createElement("div");a.innerHTML=s;const c=a.firstElementChild;c&&(l.replaceWith(c),this.#X())}}this.#a()}#F(e){const o=this._virtualization.rowHeight,n=this._virtualization.container??this,i=this._virtualization.viewportEl??n,r=n.clientHeight,l=i.clientHeight,a=this.shadowRoot?.querySelector(".tbw-scroll-area"),c=a?a.clientHeight:r,d=c-l,u=this.#t?.getExtraHeight()??0,w=Math.max(0,r-c);return e*o+d+u+w}refreshVirtualWindow(e=!1){if(!this._bodyEl)return;const o=this._rows.length;if(!this._virtualization.enabled){this.#W(0,o),this.#t?.afterRender();return}if(this._rows.length<=this._virtualization.bypassThreshold){this._virtualization.start=0,this._virtualization.end=o,e&&(this._bodyEl.style.transform="translateY(0px)"),this.#W(0,o,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${this.#F(o)}px`),this.#ne(o,this._visibleColumns.length),this.#t?.afterRender();return}const n=this._virtualization.container??this,i=this._virtualization.viewportEl??n,r=i.clientHeight,l=this._virtualization.rowHeight,s=n.scrollTop;let a=Math.floor(s/l),c=0;const f=10;for(;c<f;){const _=this.#t?.getExtraHeightBefore?.(a)??0,v=Math.floor((s-_)/l);if(v>=a||v<0)break;a=v,c++}a=a-a%2,a<0&&(a=0);const d=this.#t?.adjustVirtualStart(a,s,l);d!==void 0&&d<a&&(a=d,a=a-a%2,a<0&&(a=0));const u=Math.ceil(r/l)+3;let w=a+u;if(w>o&&(w=o),this._virtualization.start=a,this._virtualization.end=w,n.clientHeight===0&&r>0){requestAnimationFrame(()=>this.refreshVirtualWindow(e));return}const p=this.#F(o);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${p}px`);const g=this.#t?.getExtraHeightBefore?.(a)??0,b=-(s-a*l-g);this._bodyEl.style.transform=`translateY(${b}px)`,this.#W(a,w,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this.#ne(o,this._visibleColumns.length),e&&(this.#t?.afterRender(),queueMicrotask(()=>{const _=n.clientHeight,v=i.clientHeight;if(_===0&&v>0)return;const m=this.#F(o);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${m}px`)}))}#U(){U(this,this.#e),X(this,this.#e),Y(this,this.#e,this.#b()),this.#r();const e=this.#o?.shell;Zt(this.#n,e,this.#e,this.#o?.icons)&&(this.#X(),this.#i.setInitialized(!0))}#X(){Gt(this.#n,this.#o?.shell,this.#e,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onToolbarButtonClick:e=>this.#Te(e)}),this.#x?.(),this.#x=$t(this.#n,this.#o?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)})}#Te(e){}}customElements.get(D.tagName)||customElements.define(D.tagName,D),globalThis.DataGridElement=D;const ro={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"};class lo{version="1.0.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,o){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:o,bubbles:!0}))}requestRender(){this.grid?.requestRender?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get shadowRoot(){return this.grid?.shadowRoot??null}get disconnectSignal(){return this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...M,...e}}resolveIcon(e,o){return o!==void 0?o:this.gridIcons[e]}setIcon(e,o){typeof o=="string"?e.innerHTML=o:o instanceof HTMLElement&&(e.innerHTML="",e.appendChild(o.cloneNode(!0)))}warn(e){console.warn(`[tbw-grid:${this.name}] ${e}`)}}const S={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},Z={ROW_INDEX:"data-row-index",COL_INDEX:"data-col-index",FIELD:"data-field",GROUP_KEY:"data-group-key",TREE_LEVEL:"data-tree-level",STICKY:"data-sticky"},so={ROOT:`.${S.ROOT}`,HEADER:`.${S.HEADER}`,HEADER_ROW:`.${S.HEADER_ROW}`,HEADER_CELL:`.${S.HEADER_CELL}`,ROWS_VIEWPORT:`.${S.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${S.ROWS_CONTAINER}`,DATA_ROW:`.${S.DATA_ROW}`,DATA_CELL:`.${S.DATA_CELL}`,GROUP_ROW:`.${S.GROUP_ROW}`,ROW_BY_INDEX:t=>`.${S.DATA_ROW}[${Z.ROW_INDEX}="${t}"]`,CELL_BY_FIELD:t=>`.${S.DATA_CELL}[${Z.FIELD}="${t}"]`,CELL_AT:(t,e)=>`.${S.DATA_ROW}[${Z.ROW_INDEX}="${t}"] .${S.DATA_CELL}[${Z.COL_INDEX}="${e}"]`,SELECTED_ROWS:`.${S.DATA_ROW}.${S.SELECTED}`,EDITING_CELL:`.${S.DATA_CELL}.${S.EDITING}`},ao={COLOR_BG:"--tbw-color-bg",COLOR_FG:"--tbw-color-fg",COLOR_FG_MUTED:"--tbw-color-fg-muted",COLOR_BORDER:"--tbw-color-border",COLOR_ACCENT:"--tbw-color-accent",COLOR_HEADER_BG:"--tbw-color-header-bg",COLOR_HEADER_FG:"--tbw-color-header-fg",COLOR_SELECTION:"--tbw-color-selection",COLOR_ROW_HOVER:"--tbw-color-row-hover",COLOR_ROW_ALT:"--tbw-color-row-alt",ROW_HEIGHT:"--tbw-row-height",HEADER_HEIGHT:"--tbw-header-height",CELL_PADDING:"--tbw-cell-padding",FONT_FAMILY:"--tbw-font-family",FONT_SIZE:"--tbw-font-size",BORDER_RADIUS:"--tbw-border-radius",FOCUS_OUTLINE:"--tbw-focus-outline"},co={CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",ACTIVATE_CELL:"activate-cell",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change"},uo={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"},ue={sum:(t,e)=>t.reduce((o,n)=>o+(Number(n[e])||0),0),avg:(t,e)=>{const o=t.reduce((n,i)=>n+(Number(i[e])||0),0);return t.length?o/t.length:0},count:t=>t.length,min:(t,e)=>Math.min(...t.map(o=>Number(o[e])||1/0)),max:(t,e)=>Math.max(...t.map(o=>Number(o[e])||-1/0)),first:(t,e)=>t[0]?.[e],last:(t,e)=>t[t.length-1]?.[e]},Q=new Map,H={register(t,e){Q.set(t,e)},unregister(t){Q.delete(t)},get(t){if(t!==void 0)return typeof t=="function"?t:Q.get(t)??ue[t]},run(t,e,o,n){const i=this.get(t);return i?i(e,o,n):void 0},has(t){return Q.has(t)||t in ue},list(){return[...Object.keys(ue),...Q.keys()]}},Ye={sum:t=>t.reduce((e,o)=>e+o,0),avg:t=>t.length?t.reduce((e,o)=>e+o,0)/t.length:0,count:t=>t.length,min:t=>t.length?Math.min(...t):0,max:t=>t.length?Math.max(...t):0,first:t=>t[0]??0,last:t=>t[t.length-1]??0};function je(t){return Ye[t]??Ye.sum}function ho(t,e){return je(t)(e)}const fo=H.register.bind(H),po=H.unregister.bind(H),wo=H.get.bind(H),bo=H.run.bind(H),go=H.list.bind(H);E.BaseGridPlugin=lo,E.DEFAULT_ANIMATION_CONFIG=pe,E.DEFAULT_GRID_ICONS=M,E.DGEvents=co,E.DataGridElement=D,E.FitModeEnum=V,E.GridCSSVars=ao,E.GridClasses=S,E.GridDataAttrs=Z,E.GridElement=D,E.GridSelectors=so,E.PLUGIN_QUERIES=ro,E.PluginEvents=uo,E.PluginManager=Xe,E.aggregatorRegistry=H,E.builtInSort=Pe,E.defaultComparator=Le,E.getAggregator=wo,E.getValueAggregator=je,E.listAggregators=go,E.registerAggregator=fo,E.runAggregator=bo,E.runValueAggregator=ho,E.unregisterAggregator=po,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}));
|
|
29
|
+
`}function z(t,e){const o=t.querySelector("tbw-grid-header");if(!o)return;if(!e.lightDomTitle){const n=o.getAttribute("title");n&&(e.lightDomTitle=n)}const i=o.querySelectorAll("tbw-grid-header-content");i.length>0&&e.lightDomHeaderContent.length===0&&(e.lightDomHeaderContent=Array.from(i),e.lightDomHeaderContent.forEach(n=>{n.setAttribute("slot","header-content")})),o.style.display="none"}function k(t,e){const o=t.querySelector(":scope > tbw-grid-tool-buttons");o&&(e.hasToolButtonsContainer=!0,o.setAttribute("slot","toolbar"))}function I(t,e,o){t.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(n=>{const r=n,s=r.getAttribute("id"),l=r.getAttribute("title");if(!s||!l){console.warn(`[parseLightDomToolPanels] Tool panel missing required id or title attribute: id="${s??""}", title="${l??""}"`);return}const a=r.getAttribute("icon")??void 0,c=r.getAttribute("tooltip")??void 0,u=parseInt(r.getAttribute("order")??"100",10);let d;const f=o?.(r);if(f)d=f;else{const g=r.innerHTML.trim();d=m=>{const b=document.createElement("div");return b.innerHTML=g,m.appendChild(b),()=>b.remove()}}const p=e.toolPanels.get(s);if(p){if(f){p.render=d,p.order=u,p.icon=a,p.tooltip=c;const g=e.panelCleanups.get(s);g&&(g(),e.panelCleanups.delete(s))}return}const h={id:s,title:l,icon:a,tooltip:c,order:u,render:d};e.toolPanels.set(s,h),e.lightDomToolPanelIds.add(s),r.style.display="none"})}function pt(t,e,o,i){const n=t.querySelector(".tbw-shell-toolbar");n&&n.addEventListener("click",s=>{const l=s.target;if(l.closest("[data-panel-toggle]")){i.onPanelToggle();return}const c=l.closest("[data-btn]");if(c){const u=c.getAttribute("data-btn");u&&i.onToolbarButtonClick(u)}});const r=t.querySelector(".tbw-accordion");r&&r.addEventListener("click",s=>{const a=s.target.closest(".tbw-accordion-header");if(a){const u=a.closest("[data-section]")?.getAttribute("data-section");u&&i.onSectionToggle(u)}})}function gt(t,e,o){const i=t.querySelector(".tbw-tool-panel"),n=t.querySelector("[data-resize-handle]"),r=t.querySelector(".tbw-shell-body");if(!i||!n||!r)return()=>{};const s=e?.toolPanel?.position??"right",l=200;let a=0,c=0,u=0,d=!1;const f=g=>{if(!d)return;g.preventDefault();const m=s==="left"?g.clientX-a:a-g.clientX,b=Math.min(u,Math.max(l,c+m));i.style.width=`${b}px`},p=()=>{if(!d)return;d=!1,n.classList.remove("resizing"),i.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const g=i.getBoundingClientRect().width;o(g),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p)},h=g=>{g.preventDefault(),d=!0,a=g.clientX,c=i.getBoundingClientRect().width,u=r.getBoundingClientRect().width-20,n.classList.add("resizing"),i.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)};return n.addEventListener("mousedown",h),()=>{n.removeEventListener("mousedown",h),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p)}}function wt(t,e,o){const i=[...e?.header?.toolbarButtons??[],...o.toolbarButtons.values()];for(const n of i){const r=t.querySelector(`[data-btn-slot="${n.id}"]`);if(!r)continue;const s=o.toolbarButtonCleanups.get(n.id);if(s&&(s(),o.toolbarButtonCleanups.delete(n.id)),n.element)r.appendChild(n.element);else if(n.render){const l=n.render(r);l&&o.toolbarButtonCleanups.set(n.id,l)}}}function Le(t,e){const o=t.querySelector(".tbw-shell-content");if(!o)return;const i=[...e.headerContents.values()].sort((r,s)=>(r.order??100)-(s.order??100)),n=o.querySelector('slot[name="header-content"]');for(const r of i){const s=e.headerContentCleanups.get(r.id);s&&(s(),e.headerContentCleanups.delete(r.id));let l=o.querySelector(`[data-header-content="${r.id}"]`);l||(l=document.createElement("div"),l.setAttribute("data-header-content",r.id),n?o.insertBefore(l,n):o.appendChild(l));const a=r.render(l);a&&e.headerContentCleanups.set(r.id,a)}}function bt(t,e,o){if(!e.isPanelOpen)return;const i=D(o?.expand??H.expand),n=D(o?.collapse??H.collapse);for(const[r,s]of e.toolPanels){const l=e.expandedSections.has(r),a=t.querySelector(`[data-section="${r}"]`),c=a?.querySelector(".tbw-accordion-content");if(!a||!c)continue;a.classList.toggle("expanded",l);const u=a.querySelector(".tbw-accordion-header");u&&u.setAttribute("aria-expanded",String(l));const d=a.querySelector(".tbw-accordion-chevron");if(d&&(d.innerHTML=l?n:i),l){if(c.children.length===0){const f=s.render(c);f&&e.panelCleanups.set(r,f)}}else{const f=e.panelCleanups.get(r);f&&(f(),e.panelCleanups.delete(r)),c.innerHTML=""}}}function He(t,e){const o=t.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",e.isPanelOpen),o.setAttribute("aria-pressed",String(e.isPanelOpen)))}function Oe(t,e){const o=t.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",e.isPanelOpen),e.isPanelOpen||(o.style.width=""))}function mt(t,e){const o=[];for(const i of t?.header?.toolbarButtons??[])o.push({id:i.id,label:i.label??"",source:"config"});for(const i of e.toolbarButtons.values())o.push({id:i.id,label:i.label??"",source:"config"});for(const i of e.toolPanels.values())o.push({id:`panel-toggle-${i.id}`,label:i.tooltip??i.title,source:"panel-toggle",panelId:i.id});return o}function vt(t){for(const e of t.headerContentCleanups.values())e();t.headerContentCleanups.clear();for(const e of t.panelCleanups.values())e();t.panelCleanups.clear();for(const e of t.toolbarButtonCleanups.values())e();if(t.toolbarButtonCleanups.clear(),t.isPanelOpen)for(const e of t.expandedSections)t.toolPanels.get(e)?.onClose?.();t.isPanelOpen=!1,t.expandedSections.clear(),t.toolPanels.clear(),t.headerContents.clear(),t.toolbarButtons.clear(),t.lightDomHeaderContent=[]}function Ct(t,e){let o=!1;const i={get isInitialized(){return o},setInitialized(n){o=n},get isPanelOpen(){return t.isPanelOpen},get activePanel(){return t.isPanelOpen&&t.expandedSections.size>0?[...t.expandedSections][0]:null},get expandedSections(){return[...t.expandedSections]},openToolPanel(){if(t.isPanelOpen)return;if(t.toolPanels.size===0){console.warn("[tbw-grid] No tool panels registered");return}if(t.isPanelOpen=!0,t.expandedSections.size===0&&t.toolPanels.size>0){const s=[...t.toolPanels.values()].sort((l,a)=>(l.order??100)-(a.order??100))[0];s&&t.expandedSections.add(s.id)}const n=e.getShadow();He(n,t),Oe(n,t),bt(n,t,e.getAccordionIcons()),e.emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!t.isPanelOpen)return;for(const r of t.panelCleanups.values())r();t.panelCleanups.clear();for(const r of t.toolPanels.values())r.onClose?.();t.isPanelOpen=!1;const n=e.getShadow();He(n,t),Oe(n,t),e.emit("tool-panel-close",{})},toggleToolPanel(){t.isPanelOpen?i.closeToolPanel():i.openToolPanel()},toggleToolPanelSection(n){const r=t.toolPanels.get(n);if(!r){console.warn(`[tbw-grid] Tool panel section "${n}" not found`);return}if(t.toolPanels.size===1)return;const s=e.getShadow(),l=t.expandedSections.has(n);if(l){const a=t.panelCleanups.get(n);a&&(a(),t.panelCleanups.delete(n)),r.onClose?.(),t.expandedSections.delete(n),J(s,n,!1)}else{for(const[a,c]of t.toolPanels)if(a!==n&&t.expandedSections.has(a)){const u=t.panelCleanups.get(a);u&&(u(),t.panelCleanups.delete(a)),c.onClose?.(),t.expandedSections.delete(a),J(s,a,!1);const d=s.querySelector(`[data-section="${a}"] .tbw-accordion-content`);d&&(d.innerHTML="")}t.expandedSections.add(n),J(s,n,!0),_t(s,t,n)}e.emit("tool-panel-section-toggle",{id:n,expanded:!l})},getToolPanels(){return[...t.toolPanels.values()]},registerToolPanel(n){if(t.toolPanels.has(n.id)){console.warn(`[tbw-grid] Tool panel "${n.id}" already registered`);return}t.toolPanels.set(n.id,n),o&&e.refreshShellHeader()},unregisterToolPanel(n){if(t.expandedSections.has(n)){const r=t.panelCleanups.get(n);r&&(r(),t.panelCleanups.delete(n)),t.expandedSections.delete(n)}t.toolPanels.delete(n),o&&e.refreshShellHeader()},getHeaderContents(){return[...t.headerContents.values()]},registerHeaderContent(n){if(t.headerContents.has(n.id)){console.warn(`[tbw-grid] Header content "${n.id}" already registered`);return}t.headerContents.set(n.id,n),o&&Le(e.getShadow(),t)},unregisterHeaderContent(n){const r=t.headerContentCleanups.get(n);r&&(r(),t.headerContentCleanups.delete(n)),t.headerContents.get(n)?.onDestroy?.(),t.headerContents.delete(n),e.getShadow().querySelector(`[data-header-content="${n}"]`)?.remove()},getToolbarButtons(){return mt(e.getShellConfig(),t)},registerToolbarButton(n){if(t.toolbarButtons.has(n.id)){console.warn(`[tbw-grid] Toolbar button "${n.id}" already registered`);return}t.toolbarButtons.set(n.id,n),o&&e.refreshShellHeader()},unregisterToolbarButton(n){const r=t.toolbarButtonCleanups.get(n);r&&(r(),t.toolbarButtonCleanups.delete(n)),t.toolbarButtons.delete(n),o&&e.refreshShellHeader()},setToolbarButtonDisabled(n,r){}};return i}function J(t,e,o){const i=t.querySelector(`[data-section="${e}"]`);i&&i.classList.toggle("expanded",o)}function _t(t,e,o){const i=e.toolPanels.get(o);if(!i?.render)return;const n=t.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!n)return;const r=i.render(n);r&&e.panelCleanups.set(o,r)}function yt(t,e,o,i){const n=xe(e);if(t.replaceChildren(),n){const r=D(i?.toolPanel??H.toolPanel),s=D(i?.expand??H.expand),l=D(i?.collapse??H.collapse),c=[...e?.header?.toolbarButtons??[]].sort((b,y)=>(b.order??100)-(y.order??100)),d=[...e?.toolPanels??[]].sort((b,y)=>(b.order??100)-(y.order??100)),f={title:e?.header?.title??void 0,hasPanels:d.length>0,isPanelOpen:o.isPanelOpen,toolPanelIcon:r,configButtons:c.map(b=>({id:b.id,hasElement:!!b.element,hasRender:!!b.render})),apiButtons:[]},p={position:e?.toolPanel?.position??"right",isPanelOpen:o.isPanelOpen,expandIcon:s,collapseIcon:l,panels:d.map(b=>({id:b.id,title:b.title,icon:D(b.icon),isExpanded:o.expandedSections.has(b.id)}))},h=ht(f),g=ut(p),m=Ae({hasShell:!0,shellHeader:h,shellBody:g});t.appendChild(m)}else{const r=Ae({hasShell:!1});t.appendChild(r)}return n}function Et(){return{startY:null,startX:null,scrollTop:null,scrollLeft:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0}}function St(t){t.startY=null,t.startX=null,t.scrollTop=null,t.scrollLeft=null,t.lastY=null,t.lastX=null,t.lastTime=null}function De(t){t.momentumRaf&&(cancelAnimationFrame(t.momentumRaf),t.momentumRaf=0)}function Tt(t,e,o){if(t.touches.length!==1)return;De(e);const i=t.touches[0];e.startY=i.clientY,e.startX=i.clientX,e.lastY=i.clientY,e.lastX=i.clientX,e.lastTime=performance.now(),e.scrollTop=o.fauxScrollbar.scrollTop,e.scrollLeft=o.scrollArea?.scrollLeft??0,e.velocityY=0,e.velocityX=0}function Rt(t,e,o){if(t.touches.length!==1||e.startY===null||e.startX===null||e.scrollTop===null||e.scrollLeft===null)return!1;const i=t.touches[0],n=i.clientY,r=i.clientX,s=performance.now(),l=e.startY-n,a=e.startX-r;if(e.lastTime!==null&&e.lastY!==null&&e.lastX!==null){const g=s-e.lastTime;g>0&&(e.velocityY=(e.lastY-n)/g,e.velocityX=(e.lastX-r)/g)}e.lastY=n,e.lastX=r,e.lastTime=s;const{scrollTop:c,scrollHeight:u,clientHeight:d}=o.fauxScrollbar,f=u-d,p=l>0&&c<f||l<0&&c>0;let h=!1;if(o.scrollArea){const{scrollLeft:g,scrollWidth:m,clientWidth:b}=o.scrollArea,y=m-b;h=a>0&&g<y||a<0&&g>0}return p&&(o.fauxScrollbar.scrollTop=e.scrollTop+l),h&&o.scrollArea&&(o.scrollArea.scrollLeft=e.scrollLeft+a),p||h}function At(t,e){(Math.abs(t.velocityY)>.1||Math.abs(t.velocityX)>.1)&&xt(t,e),St(t)}function xt(t,e){const n=()=>{t.velocityY*=.95,t.velocityX*=.95;const r=t.velocityY*16,s=t.velocityX*16;Math.abs(t.velocityY)>.01&&(e.fauxScrollbar.scrollTop+=r),Math.abs(t.velocityX)>.01&&e.scrollArea&&(e.scrollArea.scrollLeft+=s),Math.abs(t.velocityY)>.01||Math.abs(t.velocityX)>.01?t.momentumRaf=requestAnimationFrame(n):t.momentumRaf=0};t.momentumRaf=requestAnimationFrame(n)}function Pt(t,e,o,i){t.addEventListener("touchstart",n=>Tt(n,e,o),{passive:!0,signal:i}),t.addEventListener("touchmove",n=>{Rt(n,e,o)&&n.preventDefault()},{passive:!1,signal:i}),t.addEventListener("touchend",()=>At(e,o),{passive:!0,signal:i})}const Lt=[{property:"editable",pluginName:"editing",description:'the "editable" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';",isUsed:t=>t===!0},{property:"editor",pluginName:"editing",description:'the "editor" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"group",pluginName:"groupingColumns",description:'the "group" column property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';"},{property:"sticky",pluginName:"pinnedColumns",description:'the "sticky" column property',importHint:"import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';",isUsed:t=>t==="left"||t==="right"}],Ht=[{property:"columnGroups",pluginName:"groupingColumns",description:'the "columnGroups" config property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';",isUsed:t=>Array.isArray(t)&&t.length>0}];function Me(t,e){return t.some(o=>o.name===e)}function Ot(t,e){const o=new Map;function i(r,s,l,a,c=!1){o.has(r)||o.set(r,{description:s,importHint:l,fields:[],isConfigProperty:c});const u=o.get(r);u.fields.includes(a)||u.fields.push(a)}for(const r of Ht){const s=t[r.property];(r.isUsed?r.isUsed(s):s!==void 0)&&!Me(e,r.pluginName)&&i(r.pluginName,r.description,r.importHint,r.property,!0)}const n=t.columns;if(n&&n.length>0)for(const r of n)for(const s of Lt){const l=r[s.property];if((s.isUsed?s.isUsed(l):l!==void 0)&&!Me(e,s.pluginName)){const c=r.field||"<unknown>";i(s.pluginName,s.description,s.importHint,c)}}if(o.size>0){const r=[];for(const[s,{description:l,importHint:a,fields:c,isConfigProperty:u}]of o)if(u)r.push(`Config uses ${l}, but the required plugin is not loaded.
|
|
30
|
+
→ Add the plugin to your gridConfig.plugins array:
|
|
31
|
+
${a}
|
|
32
|
+
plugins: [new ${s.charAt(0).toUpperCase()+s.slice(1)}Plugin(), ...]`);else{const d=c.slice(0,3).join(", ")+(c.length>3?`, ... (${c.length} total)`:"");r.push(`Column(s) [${d}] use ${l}, but the required plugin is not loaded.
|
|
33
|
+
→ Add the plugin to your gridConfig.plugins array:
|
|
34
|
+
${a}
|
|
35
|
+
plugins: [new ${s.charAt(0).toUpperCase()+s.slice(1)}Plugin(), ...]`)}throw new Error(`[tbw-grid] Configuration error:
|
|
36
|
+
|
|
37
|
+
${r.join(`
|
|
38
|
+
|
|
39
|
+
`)}
|
|
40
|
+
|
|
41
|
+
This validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`)}}class Ne{constructor(e){this.grid=e}plugins=[];getPlugins(){return this.plugins}pluginMap=new Map;cellRenderers=new Map;headerRenderers=new Map;cellEditors=new Map;attachAll(e){for(const o of e)this.attach(o)}attach(e){if(this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[o,i]of Object.entries(e.cellRenderers))this.cellRenderers.set(o,i);if(e.headerRenderers)for(const[o,i]of Object.entries(e.headerRenderers))this.headerRenderers.set(o,i);if(e.cellEditors)for(const[o,i]of Object.entries(e.cellEditors))this.cellEditors.set(o,i);e.attach(this.grid);for(const o of this.plugins)o!==e&&o.onPluginAttached&&o.onPluginAttached(e.name,e)}detachAll(){for(const e of this.plugins)for(const o of this.plugins)o!==e&&o.onPluginDetached&&o.onPluginDetached(e.name);for(let e=this.plugins.length-1;e>=0;e--)this.plugins[e].detach();this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear()}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(o=>o.name===e)}hasPlugin(e){return this.pluginMap.has(e)}getAll(){return this.plugins}getRegisteredPluginNames(){return this.plugins.map(e=>e.name)}getCellRenderer(e){return this.cellRenderers.get(e)}getHeaderRenderer(e){return this.headerRenderers.get(e)}getCellEditor(e){return this.cellEditors.get(e)}getAllStyles(){return this.plugins.filter(e=>e.styles).map(e=>e.styles).join(`
|
|
42
|
+
`)}processRows(e){let o=[...e];for(const i of this.plugins)i.processRows&&(o=i.processRows(o));return o}processColumns(e){let o=[...e];for(const i of this.plugins)i.processColumns&&(o=i.processColumns(o));return o}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.plugins)e.afterRender?.()}onScrollRender(){for(const e of this.plugins)e.onScrollRender?.()}getExtraHeight(){let e=0;for(const o of this.plugins)typeof o.getExtraHeight=="function"&&(e+=o.getExtraHeight());return e}getExtraHeightBefore(e){let o=0;for(const i of this.plugins)typeof i.getExtraHeightBefore=="function"&&(o+=i.getExtraHeightBefore(e));return o}adjustVirtualStart(e,o,i){let n=e;for(const r of this.plugins)if(typeof r.adjustVirtualStart=="function"){const s=r.adjustVirtualStart(e,o,i);s<n&&(n=s)}return n}renderRow(e,o,i){for(const n of this.plugins)if(n.renderRow?.(e,o,i))return!0;return!1}queryPlugins(e){const o=[];for(const i of this.plugins){const n=i.onPluginQuery?.(e);n!==void 0&&o.push(n)}return o}onKeyDown(e){for(const o of this.plugins)if(o.onKeyDown?.(e))return!0;return!1}onCellClick(e){for(const o of this.plugins)if(o.onCellClick?.(e))return!0;return!1}onRowClick(e){for(const o of this.plugins)if(o.onRowClick?.(e))return!0;return!1}onHeaderClick(e){for(const o of this.plugins)if(o.onHeaderClick?.(e))return!0;return!1}onScroll(e){for(const o of this.plugins)o.onScroll?.(e)}onCellMouseDown(e){for(const o of this.plugins)if(o.onCellMouseDown?.(e))return!0;return!1}onCellMouseMove(e){for(const o of this.plugins)if(o.onCellMouseMove?.(e))return!0;return!1}onCellMouseUp(e){for(const o of this.plugins)if(o.onCellMouseUp?.(e))return!0;return!1}getHorizontalScrollOffsets(e,o){let i=0,n=0,r=!1;for(const s of this.plugins){const l=s.getHorizontalScrollOffsets?.(e,o);l&&(i+=l.left,n+=l.right,l.skipScroll&&(r=!0))}return{left:i,right:n,skipScroll:r}}getToolPanels(){const e=[];for(const o of this.plugins){const i=o.getToolPanel?.();i&&e.push({plugin:o,panel:i})}return e.sort((o,i)=>(o.panel.order??0)-(i.panel.order??0))}getHeaderContents(){const e=[];for(const o of this.plugins){const i=o.getHeaderContent?.();i&&e.push({plugin:o,content:i})}return e.sort((o,i)=>(o.content.order??0)-(i.content.order??0))}}class O extends HTMLElement{static tagName="tbw-grid";static version=typeof __GRID_VERSION__<"u"?__GRID_VERSION__:"dev";static adapters=[];static registerAdapter(e){this.adapters.push(e)}static getAdapters(){return this.adapters}static clearAdapters(){this.adapters=[]}static get observedAttributes(){return["rows","columns","grid-config","fit-mode","edit-on"]}#o;#c=!1;#f;#d;#r=[];get#n(){return this.#t?.effective??{}}#h=!1;#u=!1;#p={rows:!1,columns:!1,gridConfig:!1,fitMode:!1,editMode:!1};#l;#v=0;#w=null;#b=!1;#s;#m=!1;#x=Et();#g;#_;#y;#C;#S={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#i;#E;#O=!1;#P;#L;#t;#e=ft();#a;#D;_rows=[];#N=[];get _columns(){return this.#n.columns??[]}set _columns(e){this.#n.columns=e}get _visibleColumns(){return this._columns.filter(e=>!e.hidden)}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;_virtualization={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null};_focusRow=0;_focusCol=0;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#t?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#t&&(this.#t.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#t?.originalColumnNodes}set __originalColumnNodes(e){this.#t&&(this.#t.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const o=this.#r;this.#r=e,o!==e&&this.#H("rows")}get sourceRows(){return this.#r}get columns(){return[...this._columns]}set columns(e){const o=this.#t?.getColumns();this.#t?.setColumns(e),o!==e&&this.#H("columns")}get gridConfig(){return this.#n}set gridConfig(e){const o=this.#t?.getGridConfig();this.#t?.setGridConfig(e),o!==e&&(this.#t.clearLightDomCache(),this.#H("gridConfig"))}get fitMode(){return this.#n.fitMode??"stretch"}set fitMode(e){const o=this.#t?.getFitMode();this.#t?.setFitMode(e),o!==e&&this.#H("fitMode")}get editOn(){return this.#n.editOn}set editOn(e){const o=this.#t?.getEditOn();this.#t?.setEditOn(e),o!==e&&this.#H("editMode")}get effectiveConfig(){return this.#n}get disconnectSignal(){return this.#g||(this.#g=new AbortController),this.#g.signal}constructor(){super(),this.#o=this.attachShadow({mode:"open"}),this.#Q(),this.#f=new Promise(e=>this.#d=e),this.#l=new ct({mergeConfig:()=>{this.#t.parseLightDomColumns(this),this.#t.merge(),this.#V(),Ot(this.#n,this.#i?.getPlugins()??[]),this.#N=[...this._columns]},processColumns:()=>this.#de(),processRows:()=>this.#he(),renderHeader:()=>V(this),updateTemplate:()=>B(this),renderVirtualWindow:()=>this.refreshVirtualWindow(!0),afterRender:()=>{this.#i?.afterRender(),this.#n.fitMode==="fixed"&&!this.__didInitialAutoSize&&(this.__didInitialAutoSize=!0,re(this))},isConnected:()=>this.isConnected&&this.#h}),this.#l.setInitialReadyResolver(()=>this.#d?.()),this.#a=Ct(this.#e,{getShadow:()=>this.#o,getShellConfig:()=>this.#n?.shell,getAccordionIcons:()=>({expand:this.#n?.icons?.expand??H.expand,collapse:this.#n?.icons?.collapse??H.collapse}),emit:(e,o)=>this.#Y(e,o),refreshShellHeader:()=>this.refreshShellHeader()}),this.#t=new Je({getRows:()=>this.#r,getSortState:()=>this._sortState,setSortState:e=>{this._sortState=e},onConfigChange:()=>{this.#l.requestPhase(S.FULL,"configChange")},emit:(e,o)=>this.#Y(e,o),clearRowPool:()=>{this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++},setup:()=>this.#R(),renderHeader:()=>V(this),updateTemplate:()=>B(this),refreshVirtualWindow:()=>this.#l.requestPhase(S.VIRTUALIZATION,"configManager"),getVirtualization:()=>this._virtualization,setRowHeight:e=>{this._virtualization.rowHeight=e},applyAnimationConfig:e=>this.#ue(e),getShellLightDomTitle:()=>this.#e.lightDomTitle,getShellToolPanels:()=>this.#e.toolPanels,getShellHeaderContents:()=>this.#e.headerContents,getShellToolbarButtons:()=>this.#e.toolbarButtons,getShellLightDomHeaderContent:()=>this.#e.lightDomHeaderContent,getShellHasToolButtonsContainer:()=>this.#e.hasToolButtonsContainer})}async#Q(){const e=new CSSStyleSheet;if(M.length>0){e.replaceSync(M),this.#o.adoptedStyleSheets=[e];return}await new Promise(o=>setTimeout(o,50));try{let o="";for(const i of Array.from(document.styleSheets))try{const r=Array.from(i.cssRules||[]).map(s=>s.cssText).join(`
|
|
43
|
+
`);if(r.includes(".tbw-grid-root")&&r.includes(":host")){o=r;break}}catch{continue}o?(e.replaceSync(o),this.#o.adoptedStyleSheets=[e]):(typeof process>"u"||process.env?.NODE_ENV!=="test")&&console.warn("[tbw-grid] Could not find grid.css in document.styleSheets. Grid styling will not work.","Available stylesheets:",Array.from(document.styleSheets).map(i=>i.href||"(inline)"))}catch(o){console.warn("[tbw-grid] Failed to extract grid.css from document stylesheets:",o)}}getPlugin(e){return this.#i?.getPlugin(e)}getPluginByName(e){return this.#i?.getPluginByName(e)}requestRender(){this.#l.requestPhase(S.ROWS,"plugin:requestRender")}updateTemplate(){B(this)}requestAfterRender(){this.#l.requestPhase(S.STYLE,"plugin:requestAfterRender")}#$(){this.#i=new Ne(this);const e=this.#n?.plugins,o=Array.isArray(e)?e:[];this.#i.attachAll(o)}#M(){const e=this.#i?.getAllStyles()??"";if(e){const o=document.createElement("style");o.setAttribute("data-plugin","all"),o.textContent=e,this.#o.appendChild(o)}}#V(){const e=this.#n?.plugins,o=Array.isArray(e)?e:[];if(this.#E!==o){if(this.#E&&this.#E.length===o.length&&this.#E.every((i,n)=>i===o[n])){this.#E=o;return}this.#i&&this.#i.detachAll();for(const i of this.#e.toolPanels.keys()){const n=this.#e.lightDomToolPanelIds.has(i),r=this.#e.apiToolPanelIds.has(i);if(!n&&!r){const s=this.#e.panelCleanups.get(i);s&&(s(),this.#e.panelCleanups.delete(i)),this.#e.toolPanels.delete(i)}}for(const i of this.#e.headerContents.keys()){const n=this.#e.headerContentCleanups.get(i);n&&(n(),this.#e.headerContentCleanups.delete(i)),this.#e.headerContents.delete(i)}this.#$(),this.#M(),this.#E=o,this.#F(),this.#b=this.#i?.getAll().some(i=>i.onScroll)??!1}}#J(){this.#i?.detachAll()}#F(){if(!this.#i)return;const e=this.#i.getToolPanels();for(const{panel:i}of e)this.#e.toolPanels.has(i.id)||this.#e.toolPanels.set(i.id,i);const o=this.#i.getHeaderContents();for(const{content:i}of o)this.#e.headerContents.has(i.id)||this.#e.headerContents.set(i.id,i)}#T(){const e=O.getAdapters();if(e.length===0&&!this.__frameworkAdapter)return;const o=this.__frameworkAdapter;return i=>{if(o?.createToolPanelRenderer){const n=o.createToolPanelRenderer(i);if(n)return n}for(const n of e)if(n.createToolPanelRenderer){const r=n.createToolPanelRenderer(i);if(r)return r}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",O.version),this._rows=Array.isArray(this.#r)?[...this.#r]:[],this.#g&&(this.#g.abort(),this.#O=!1),this.#g=new AbortController,this.#C&&(me(this.#C),this.#C=void 0),z(this,this.#e),k(this,this.#e),I(this,this.#e,this.#T()),this.#t.parseLightDomColumns(this),this.#t.merge(),this.#$();const e=this.#n?.plugins;this.#E=Array.isArray(e)?e:[],this.#F(),this.#c||(this.#U(),this.#M(),this.#c=!0),this.#z(),this.#C=nt(()=>{this.#me()},{timeout:100})}disconnectedCallback(){this.#C&&(me(this.#C),this.#C=void 0),this.#J(),vt(this.#e),this.#a.setInitialized(!1),this.#D?.(),this.#D=void 0,De(this.#x),this.#g&&(this.#g.abort(),this.#g=void 0),this.#P?.abort(),this.#P=void 0,this.#O=!1,this._resizeController&&this._resizeController.dispose(),this.#_&&(this.#_.disconnect(),this.#_=void 0),this.#y&&(this.#y.disconnect(),this.#y=void 0,this.#k=!1),F(this),this.#A.clear(),this.#E=void 0;for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#h=!1}attributeChangedCallback(e,o,i){if(!(o===i||!i||i==="null"||i==="undefined"))if(e==="rows"||e==="columns"||e==="grid-config")try{const n=JSON.parse(i);e==="rows"?this.rows=n:e==="columns"?this.columns=n:e==="grid-config"&&(this.gridConfig=n)}catch{console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`,i)}else e==="fit-mode"?this.fitMode=i:e==="edit-on"&&(this.editOn=i)}#z(){const o=this.#o.querySelector(".tbw-grid-content")??this.#o.querySelector(".tbw-grid-root");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.__rowsBodyEl=o?.querySelector(".rows-body"),this.#a.isInitialized){Le(this.#o,this.#e),wt(this.#o,this.#n?.shell,this.#e);const r=this.#n?.shell?.toolPanel?.defaultOpen;r&&this.#e.toolPanels.has(r)&&(this.openToolPanel(),this.#e.expandedSections.add(r))}if(this.setAttribute("data-upgraded",""),this.#h=!0,this._resizeController=dt(this),this.#R(),this.#ee(o),this.#O)return;this.#O=!0;const i=this.disconnectSignal;this.addEventListener("keydown",r=>at(this,r),{signal:i}),this.#o.addEventListener("mousedown",r=>this.#pe(r),{signal:i}),document.addEventListener("mousemove",r=>this.#ge(r),{signal:i}),document.addEventListener("mouseup",r=>this.#we(r),{signal:i});const n=this.#n.rowHeight;n&&n>0?this._virtualization.rowHeight=n:requestAnimationFrame(()=>this.#X()),queueMicrotask(()=>this.#oe()),this.#l.requestPhase(S.FULL,"afterConnect")}#X(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const o=e.querySelectorAll(".cell");let i=0;o.forEach(s=>{const l=s.offsetHeight;l>i&&(i=l)});const n=e.getBoundingClientRect(),r=Math.max(n.height,i);r>0&&r!==this._virtualization.rowHeight&&(this._virtualization.rowHeight=r,this.#l.requestPhase(S.VIRTUALIZATION,"measureRowHeight"))}#ee(e){this.#P?.abort(),this.#P=new AbortController;const o=this.#P.signal,i=e?.querySelector(".faux-vscroll"),n=e?.querySelector(".rows");if(this._virtualization.container=i??this,this.#b=this.#i?.getAll().some(r=>r.onScroll)??!1,i&&n){i.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#b)return;const l=i.scrollTop,a=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)n.style.transform=`translateY(${-l}px)`;else{const c=Math.floor(l/a),u=c-c%2,d=-(l-u*a);n.style.transform=`translateY(${d}px)`}this.#w=l,this.#v||(this.#v=requestAnimationFrame(()=>{this.#v=0,this.#w!==null&&(this.#fe(this.#w),this.#w=null)}))},{passive:!0,signal:o});const r=this.#o.querySelector(".tbw-grid-content"),s=this.#o.querySelector(".tbw-scroll-area");r&&(r.addEventListener("wheel",l=>{const a=l.shiftKey||Math.abs(l.deltaX)>Math.abs(l.deltaY);if(a&&s){const c=l.shiftKey?l.deltaY:l.deltaX,{scrollLeft:u,scrollWidth:d,clientWidth:f}=s;(c>0&&u<d-f||c<0&&u>0)&&(l.preventDefault(),s.scrollLeft+=c)}else if(!a){const{scrollTop:c,scrollHeight:u,clientHeight:d}=i;(l.deltaY>0&&c<u-d||l.deltaY<0&&c>0)&&(l.preventDefault(),i.scrollTop+=l.deltaY)}},{passive:!1,signal:o}),Pt(r,this.#x,{fauxScrollbar:i,scrollArea:s},o))}this._bodyEl&&ot(this,this._bodyEl,o),this.#_?.disconnect(),this._virtualization.viewportEl&&(this.#_=new ResizeObserver(()=>{this.#l.requestPhase(S.VIRTUALIZATION,"resize-observer")}),this.#_.observe(this._virtualization.viewportEl)),this._virtualization.enabled&&(this.#l.requestPhase(S.VIRTUALIZATION,"init-virtualization"),queueMicrotask(()=>this.#te()))}#k=!1;#te(){if(this.#k)return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;this.#k=!0,this.#y?.disconnect();const o=e.querySelectorAll(".cell");o.length>0&&(this.#y=new ResizeObserver(()=>{this.#X()}),o.forEach(i=>this.#y.observe(i)))}#Y(e,o){this.dispatchEvent(new CustomEvent(e,{detail:o,bubbles:!0,composed:!0}))}#oe(){this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((o,i)=>{const n=i===this._focusRow;o.setAttribute("aria-selected",String(n)),o.querySelectorAll(".cell").forEach((r,s)=>{r.setAttribute("aria-selected",String(n&&s===this._focusCol))})})}#H(e){this.#p[e]=!0,!this.#u&&(this.#u=!0,queueMicrotask(()=>this.#ie()))}#ie(){if(!this.#u||!this.#h){this.#u=!1;return}const e=this.#p;if(this.#u=!1,this.#p={rows:!1,columns:!1,gridConfig:!1,fitMode:!1,editMode:!1},e.gridConfig){this.#ae();return}e.columns&&this.#re(),e.rows&&this.#ne(),e.fitMode&&this.#se(),e.editMode&&this.#le()}#ne(){this._rows=Array.isArray(this.#r)?[...this.#r]:[],this.#l.requestPhase(S.ROWS,"applyRowsUpdate")}#re(){F(this),this.#t.merge(),this.#R()}#se(){this.#t.merge(),this.#n.fitMode==="fixed"?(this.__didInitialAutoSize=!1,re(this)):(this._columns.forEach(o=>{!o.__userResized&&o.__autoSized&&delete o.width}),B(this))}#le(){this.#t.merge(),this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++,this.#l.requestPhase(S.VIRTUALIZATION,"applyEditModeUpdate")}#ae(){z(this,this.#e),k(this,this.#e);const e=!!this.#o.querySelector(".has-shell"),o=!!this.#o.querySelector(".tbw-tool-panel"),i=this.#o.querySelectorAll(".tbw-accordion-section").length;this.#t.parseLightDomColumns(this),this.#t.merge(),this.#V(),I(this,this.#e,this.#T()),this.#t.markSourcesChanged(),this.#t.merge();const n=xe(this.#n?.shell),r=(this.#n?.shell?.toolPanels?.length??0)>0,s=(this.#n?.shell?.toolPanels?.length??0)!==i;if(e!==n||!e&&n||!o&&r||o&&s){this.#U(),this.#M(),this.#z();return}e&&this.#ce(),this.#l.requestPhase(S.COLUMNS,"applyGridConfigUpdate")}#ce(){const e=this.#o.querySelector(".tbw-shell-header");if(!e)return;const o=this.#n.shell?.header?.title??this.#e.lightDomTitle;let i=e.querySelector(".tbw-shell-title");o?(i||(i=document.createElement("h2"),i.className="tbw-shell-title",i.setAttribute("part","shell-title"),e.insertBefore(i,e.firstChild)),i.textContent=o):i&&i.remove()}#de(){if(this.#i){const e=this.#N.length>0?this.#N:this._columns,o=e.filter(r=>!r.hidden),i=e.filter(r=>r.hidden),n=this.#i.processColumns([...o]);if(n!==o){const r=new Map(n.map((l,a)=>[l.field,{col:l,order:a}]));if(!o.some(l=>r.has(l.field))&&n.length>0)this._columns=[...n,...i];else{const l=e.map(a=>{if(a.hidden)return a;const c=r.get(a.field);return c?c.col:a});this._columns=l}}else this._columns=[...e]}}#he(){F(this);const e=Array.isArray(this.#r)?[...this.#r]:[],o=this.#i?.processRows(e)??e;this._rows=o}#ue(e){const o={...oe,...e.animation},i=o.mode??"reduced-motion";let n=1;i===!1||i==="off"?n=0:(i===!0||i==="on")&&(n=1),this.style.setProperty("--tbw-animation-duration",`${o.duration}ms`),this.style.setProperty("--tbw-animation-easing",o.easing??"ease-out"),this.style.setProperty("--tbw-animation-enabled",String(n)),this.dataset.animationMode=typeof i=="boolean"?i?"on":"off":i}#I(e,o,i=this.__rowRenderEpoch){this.#s||(this.#s=(n,r,s)=>this.#i?.renderRow(n,r,s)??!1),lt(this,e,o,i,this.#s)}#B=-1;#j=-1;#K(e,o){if(e===this.#B&&o===this.#j)return;const i=this.#B;this.#B=e,this.#j=o,this.__rowsBodyEl&&(this.__rowsBodyEl.setAttribute("aria-rowcount",String(e)),this.__rowsBodyEl.setAttribute("aria-colcount",String(o))),e!==i&&this._bodyEl&&(e>0?this._bodyEl.setAttribute("role","rowgroup"):this._bodyEl.removeAttribute("role"))}#R(){if(this.isConnected&&!(!this._headerRowEl||!this._bodyEl)){if(this.#t.parseLightDomColumns(this),this.#L){const e=this.#L;this.#L=void 0,this.#t.merge();const o=this.#i?.getAll()??[];this.#t.applyState(e,o)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#l.requestPhase(S.FULL,"setup")}}#fe(e){if(this.refreshVirtualWindow(!1),this.#i?.onScrollRender(),this.#b){const o=this._virtualization.container,i=this.#S;i.scrollTop=e,i.scrollLeft=o?.scrollLeft??0,i.scrollHeight=o?.scrollHeight??0,i.scrollWidth=o?.scrollWidth??0,i.clientHeight=o?.clientHeight??0,i.clientWidth=o?.clientWidth??0,this.#i?.onScroll(i)}}findHeaderRow(){return this.#o.querySelector(".header-row")}findRenderedRowElement(e){return Array.from(this._bodyEl.querySelectorAll(".data-grid-row")).find(o=>{const i=o.querySelector(".cell[data-row]");return i&&Number(i.getAttribute("data-row"))===e})||null}_dispatchCellClick(e,o,i,n){const r=this._rows[o],s=this._columns[i];if(!r||!s)return!1;const l={row:r,rowIndex:o,colIndex:i,field:s.field,value:r[s.field],cellEl:n,originalEvent:e};return this.#i?.onCellClick(l)??!1}_dispatchRowClick(e,o,i,n){if(!i)return!1;const r={rowIndex:o,row:i,rowEl:n,originalEvent:e};return this.#i?.onRowClick(r)??!1}_dispatchHeaderClick(e,o,i){const n=this._columns[o];if(!n)return!1;const r={colIndex:o,field:n.field,column:n,headerEl:i,originalEvent:e};return this.#i?.onHeaderClick(r)??!1}_dispatchKeyDown(e){return this.#i?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,o){return this.#i?.getHorizontalScrollOffsets(e,o)??{left:0,right:0}}queryPlugins(e){return this.#i?.queryPlugins(e)??[]}#q(e,o){let i=null;const n=e.composedPath?.();if(n&&n.length>0?i=n[0]:i=e.target,i&&!this.#o.contains(i)){const h=this.#o.elementFromPoint(e.clientX,e.clientY);h&&(i=h)}const r=i?.closest?.("[data-col]"),s=i?.closest?.(".data-grid-row"),l=i?.closest?.(".header-row");let a,c,u,d,f,p;return r&&(a=parseInt(r.getAttribute("data-row")??"-1",10),c=parseInt(r.getAttribute("data-col")??"-1",10),a>=0&&c>=0&&(u=this._rows[a],p=this._columns[c],d=p?.field,f=u&&d?u[d]:void 0)),{type:o,row:u,rowIndex:a!==void 0&&a>=0?a:void 0,colIndex:c!==void 0&&c>=0?c:void 0,field:d,value:f,column:p,originalEvent:e,cellElement:r??void 0,rowElement:s??void 0,isHeader:!!l,cell:a!==void 0&&c!==void 0&&a>=0&&c>=0?{row:a,col:c}:void 0}}#pe(e){const o=this.#q(e,"mousedown");(this.#i?.onCellMouseDown(o)??!1)&&(this.#m=!0)}#ge(e){if(!this.#m)return;const o=this.#q(e,"mousemove");this.#i?.onCellMouseMove(o)}#we(e){if(!this.#m)return;const o=this.#q(e,"mouseup");this.#i?.onCellMouseUp(o),this.#m=!1}async ready(){return this.#f}async forceLayout(){return this.#l.requestPhase(S.FULL,"forceLayout"),this.#l.whenReady()}async getConfig(){return Object.freeze({...this.#n||{}})}setColumnVisible(e,o){const i=this.#t.setColumnVisible(e,o);return i&&this.requestStateChange(),i}toggleColumnVisibility(e){const o=this.#t.toggleColumnVisibility(e);return o&&this.requestStateChange(),o}isColumnVisible(e){return this.#t.isColumnVisible(e)}showAllColumns(){this.#t.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#t.getAllColumns()}setColumnOrder(e){this.#t.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#t.getColumnOrder()}getColumnState(){const e=this.#i?.getAll()??[];return this.#t.collectState(e)}set columnState(e){e&&(this.#L=e,this.#t.initialColumnState=e,this.#c&&this.#be(e))}get columnState(){return this.getColumnState()}#be(e){const o=this.#i?.getAll()??[];this.#t.applyState(e,o),this.#R()}requestStateChange(){const e=this.#i?.getAll()??[];this.#t.requestStateChange(e)}resetColumnState(){this.#L=void 0,this.__originalOrder=[];const e=this.#i?.getAll()??[];this.#t.resetState(e),this.#t.merge(),this.#R()}get isToolPanelOpen(){return this.#a.isPanelOpen}get activeToolPanel(){return this.#a.activePanel}get expandedToolPanelSections(){return this.#a.expandedSections}openToolPanel(){this.#a.openToolPanel()}closeToolPanel(){this.#a.closeToolPanel()}toggleToolPanel(){this.#a.toggleToolPanel()}toggleToolPanelSection(e){this.#a.toggleToolPanelSection(e)}getToolPanels(){return this.#a.getToolPanels()}registerToolPanel(e){this.#e.apiToolPanelIds.add(e.id),this.#a.registerToolPanel(e)}unregisterToolPanel(e){this.#e.apiToolPanelIds.delete(e),this.#a.unregisterToolPanel(e)}getHeaderContents(){return this.#a.getHeaderContents()}registerHeaderContent(e){this.#a.registerHeaderContent(e)}unregisterHeaderContent(e){this.#a.unregisterHeaderContent(e)}getToolbarButtons(){return this.#a.getToolbarButtons()}registerToolbarButton(e){this.#a.registerToolbarButton(e)}unregisterToolbarButton(e){this.#a.unregisterToolbarButton(e)}setToolbarButtonDisabled(e,o){this.#a.setToolbarButtonDisabled(e,o)}refreshShellHeader(){z(this,this.#e),k(this,this.#e),I(this,this.#e,this.#T()),this.#t.markSourcesChanged(),this.#t.merge(),this.#U(),this.#M(),this.#z()}#A=new Map;registerStyles(e,o){let i=this.#A.get(e);i||(i=new CSSStyleSheet,this.#A.set(e,i)),i.replaceSync(o),this.#Z()}unregisterStyles(e){this.#A.delete(e)&&this.#Z()}getRegisteredStyles(){return Array.from(this.#A.keys())}#Z(){const e=this.#o.adoptedStyleSheets[0],o=Array.from(this.#A.values());this.#o.adoptedStyleSheets=e?[e,...o]:o}#me(){const e=()=>{const i=this.#e.lightDomTitle,n=this.#e.hasToolButtonsContainer;z(this,this.#e),k(this,this.#e),I(this,this.#e,this.#T());const r=this.#e.lightDomTitle,s=this.#e.hasToolButtonsContainer;if(r&&!i||s&&!n){this.#t.markSourcesChanged(),this.#t.merge();const l=this.#o.querySelector(".tbw-shell-header");if(l){const a=Pe(this.#n.shell,this.#e,this.#n.icons?.toolPanel),c=document.createElement("div");c.innerHTML=a;const u=c.firstElementChild;u&&(l.replaceWith(u),this.#G())}}},o=()=>{this.__lightDomColumnsCache=void 0,this.#R()};this.#t.registerLightDomHandler("tbw-grid-header",e),this.#t.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#t.registerLightDomHandler("tbw-grid-tool-panel",e),this.#t.registerLightDomHandler("tbw-grid-column",o),this.#t.registerLightDomHandler("tbw-grid-detail",o),this.#t.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,F(this),this.#t.parseLightDomColumns(this);const e=this.#e.lightDomTitle,o=this.#e.hasToolButtonsContainer;z(this,this.#e),k(this,this.#e),I(this,this.#e,this.#T());const i=this.#e.lightDomTitle,n=this.#e.hasToolButtonsContainer;if(i&&!e||n&&!o){this.#t.markSourcesChanged(),this.#t.merge();const s=this.#o.querySelector(".tbw-shell-header");if(s){const l=Pe(this.#n.shell,this.#e,this.#n.icons?.toolPanel),a=document.createElement("div");a.innerHTML=l;const c=a.firstElementChild;c&&(s.replaceWith(c),this.#G())}}this.#l.requestPhase(S.COLUMNS,"refreshColumns")}#W(e){const o=this._virtualization.rowHeight,i=this._virtualization.container??this,n=this._virtualization.viewportEl??i,r=i.clientHeight,s=n.clientHeight,a=this.shadowRoot?.querySelector(".tbw-scroll-area"),c=a?a.clientHeight:r,d=c-s,f=this.#i?.getExtraHeight()??0,p=Math.max(0,r-c);return e*o+d+f+p}refreshVirtualWindow(e=!1){if(!this._bodyEl)return;const o=this._rows.length;if(!this._virtualization.enabled){this.#I(0,o),this.#i?.afterRender();return}if(this._rows.length<=this._virtualization.bypassThreshold){this._virtualization.start=0,this._virtualization.end=o,e&&(this._bodyEl.style.transform="translateY(0px)"),this.#I(0,o,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${this.#W(o)}px`),this.#K(o,this._visibleColumns.length),this.#i?.afterRender();return}const i=this._virtualization.container??this,n=this._virtualization.viewportEl??i,r=n.clientHeight,s=this._virtualization.rowHeight,l=i.scrollTop;let a=Math.floor(l/s),c=0;const u=10;for(;c<u;){const y=this.#i?.getExtraHeightBefore?.(a)??0,w=Math.floor((l-y)/s);if(w>=a||w<0)break;a=w,c++}a=a-a%2,a<0&&(a=0);const d=this.#i?.adjustVirtualStart(a,l,s);d!==void 0&&d<a&&(a=d,a=a-a%2,a<0&&(a=0));const f=Math.ceil(r/s)+3;let p=a+f;if(p>o&&(p=o),this._virtualization.start=a,this._virtualization.end=p,i.clientHeight===0&&r>0){this.#l.requestPhase(S.VIRTUALIZATION,"stale-refs-retry");return}const g=this.#W(o);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${g}px`);const m=this.#i?.getExtraHeightBefore?.(a)??0,b=-(l-a*s-m);this._bodyEl.style.transform=`translateY(${b}px)`,this.#I(a,p,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this.#K(o,this._visibleColumns.length),e&&(this.#i?.afterRender(),queueMicrotask(()=>{const y=i.clientHeight,w=n.clientHeight;if(y===0&&w>0)return;const _=this.#W(o);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${_}px`)}))}#U(){z(this,this.#e),k(this,this.#e),I(this,this.#e,this.#T()),this.#t.markSourcesChanged(),this.#t.merge();const e=this.#n?.shell;yt(this.#o,e,{isPanelOpen:this.#e.isPanelOpen,expandedSections:this.#e.expandedSections},this.#n?.icons)&&(this.#G(),this.#a.setInitialized(!0))}#G(){pt(this.#o,this.#n?.shell,this.#e,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onToolbarButtonClick:e=>this.#ve(e)}),this.#D?.(),this.#D=gt(this.#o,this.#n?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)})}#ve(e){}}customElements.get(O.tagName)||customElements.define(O.tagName,O),globalThis.DataGridElement=O;const Dt={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"};class Mt{version="1.0.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#o;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#o?.abort(),this.#o=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#o?.abort(),this.#o=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,o){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:o,bubbles:!0}))}requestRender(){this.grid?.requestRender?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get shadowRoot(){return this.grid?.shadowRoot??null}get disconnectSignal(){return this.#o?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...H,...e}}resolveIcon(e,o){return o!==void 0?o:this.gridIcons[e]}setIcon(e,o){typeof o=="string"?e.innerHTML=o:o instanceof HTMLElement&&(e.innerHTML="",e.appendChild(o.cloneNode(!0)))}warn(e){console.warn(`[tbw-grid:${this.name}] ${e}`)}}const E={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},U={ROW_INDEX:"data-row-index",COL_INDEX:"data-col-index",FIELD:"data-field",GROUP_KEY:"data-group-key",TREE_LEVEL:"data-tree-level",STICKY:"data-sticky"},Nt={ROOT:`.${E.ROOT}`,HEADER:`.${E.HEADER}`,HEADER_ROW:`.${E.HEADER_ROW}`,HEADER_CELL:`.${E.HEADER_CELL}`,ROWS_VIEWPORT:`.${E.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${E.ROWS_CONTAINER}`,DATA_ROW:`.${E.DATA_ROW}`,DATA_CELL:`.${E.DATA_CELL}`,GROUP_ROW:`.${E.GROUP_ROW}`,ROW_BY_INDEX:t=>`.${E.DATA_ROW}[${U.ROW_INDEX}="${t}"]`,CELL_BY_FIELD:t=>`.${E.DATA_CELL}[${U.FIELD}="${t}"]`,CELL_AT:(t,e)=>`.${E.DATA_ROW}[${U.ROW_INDEX}="${t}"] .${E.DATA_CELL}[${U.COL_INDEX}="${e}"]`,SELECTED_ROWS:`.${E.DATA_ROW}.${E.SELECTED}`,EDITING_CELL:`.${E.DATA_CELL}.${E.EDITING}`},zt={COLOR_BG:"--tbw-color-bg",COLOR_FG:"--tbw-color-fg",COLOR_FG_MUTED:"--tbw-color-fg-muted",COLOR_BORDER:"--tbw-color-border",COLOR_ACCENT:"--tbw-color-accent",COLOR_HEADER_BG:"--tbw-color-header-bg",COLOR_HEADER_FG:"--tbw-color-header-fg",COLOR_SELECTION:"--tbw-color-selection",COLOR_ROW_HOVER:"--tbw-color-row-hover",COLOR_ROW_ALT:"--tbw-color-row-alt",ROW_HEIGHT:"--tbw-row-height",HEADER_HEIGHT:"--tbw-header-height",CELL_PADDING:"--tbw-cell-padding",FONT_FAMILY:"--tbw-font-family",FONT_SIZE:"--tbw-font-size",BORDER_RADIUS:"--tbw-border-radius",FOCUS_OUTLINE:"--tbw-focus-outline"},kt={CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",ACTIVATE_CELL:"activate-cell",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change"},It={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"},ee={sum:(t,e)=>t.reduce((o,i)=>o+(Number(i[e])||0),0),avg:(t,e)=>{const o=t.reduce((i,n)=>i+(Number(n[e])||0),0);return t.length?o/t.length:0},count:t=>t.length,min:(t,e)=>Math.min(...t.map(o=>Number(o[e])||1/0)),max:(t,e)=>Math.max(...t.map(o=>Number(o[e])||-1/0)),first:(t,e)=>t[0]?.[e],last:(t,e)=>t[t.length-1]?.[e]},G=new Map,L={register(t,e){G.set(t,e)},unregister(t){G.delete(t)},get(t){if(t!==void 0)return typeof t=="function"?t:G.get(t)??ee[t]},run(t,e,o,i){const n=this.get(t);return n?n(e,o,i):void 0},has(t){return G.has(t)||t in ee},list(){return[...Object.keys(ee),...G.keys()]}},ze={sum:t=>t.reduce((e,o)=>e+o,0),avg:t=>t.length?t.reduce((e,o)=>e+o,0)/t.length:0,count:t=>t.length,min:t=>t.length?Math.min(...t):0,max:t=>t.length?Math.max(...t):0,first:t=>t[0]??0,last:t=>t[t.length-1]??0};function ke(t){return ze[t]??ze.sum}function Bt(t,e){return ke(t)(e)}const qt=L.register.bind(L),Wt=L.unregister.bind(L),Ut=L.get.bind(L),Gt=L.run.bind(L),$t=L.list.bind(L);v.BaseGridPlugin=Mt,v.DEFAULT_ANIMATION_CONFIG=oe,v.DEFAULT_GRID_ICONS=H,v.DGEvents=kt,v.DataGridElement=O,v.FitModeEnum=N,v.GridCSSVars=zt,v.GridClasses=E,v.GridDataAttrs=U,v.GridElement=O,v.GridSelectors=Nt,v.PLUGIN_QUERIES=Dt,v.PluginEvents=It,v.PluginManager=Ne,v.RenderPhase=S,v.aggregatorRegistry=L,v.builtInSort=fe,v.defaultComparator=ue,v.getAggregator=Ut,v.getValueAggregator=ke,v.listAggregators=$t,v.registerAggregator=qt,v.runAggregator=Gt,v.runValueAggregator=Bt,v.unregisterAggregator=Wt,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
|
32
44
|
//# sourceMappingURL=grid.umd.js.map
|