@toolbox-web/grid 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +46 -22
- package/all.js.map +1 -1
- package/index.js +516 -451
- package/index.js.map +1 -1
- package/lib/core/internal/editing.d.ts +76 -0
- package/lib/core/internal/editing.d.ts.map +1 -0
- package/lib/core/internal/validate-config.d.ts +14 -0
- package/lib/core/internal/validate-config.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +48 -0
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/index.d.ts +1 -0
- package/lib/core/plugin/index.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +1 -1
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +7 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +28 -4
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +20 -4
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +30 -14
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/index.js +24 -8
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +44 -28
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +16 -0
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +22 -6
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +16 -0
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +16 -0
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +16 -0
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +16 -0
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +16 -0
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +16 -0
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +16 -0
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +16 -0
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +20 -4
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +16 -0
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +7 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +29 -5
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +7 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +24 -0
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +23 -17
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +14 -8
- 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 +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
package/umd/grid.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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=`
|
|
1
|
+
(function(v,z){typeof exports=="object"&&typeof module<"u"?z(exports):typeof define=="function"&&define.amd?define(["exports"],z):(v=typeof globalThis<"u"?globalThis:v||self,z(v.TbwGrid={}))})(this,(function(v){"use strict";const z=':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 .header-row>.cell.resizable{position:relative}:host .tbw-editor-host{display:contents}: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)}: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)}}',N={STRETCH:"stretch",FIXED:"fixed"},ie={mode:"reduced-motion",duration:200,easing:"ease-out"},H={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰"};function Be(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"),h={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())?h.width=C:h.width=d}const f=o.getAttribute("minWidth")||o.getAttribute("min-width");if(f){const C=parseFloat(f);isNaN(C)||(h.minWidth=C)}o.hasAttribute("resizable")&&(h.resizable=!0),o.hasAttribute("sizable")&&(h.resizable=!0);const p=o.getAttribute("editor"),u=o.getAttribute("renderer");p&&(h.__editorName=p),u&&(h.__rendererName=u);const g=o.getAttribute("options");g&&(h.options=g.split(",").map(C=>{const[oe,jt]=C.includes(":")?C.split(":"):[C.trim(),C.trim()];return{value:oe.trim(),label:jt?.trim()||oe.trim()}}));const m=o.querySelector("tbw-grid-column-view"),b=o.querySelector("tbw-grid-column-editor"),y=o.querySelector("tbw-grid-column-header");m&&(h.__viewTemplate=m),b&&(h.__editorTemplate=b),y&&(h.__headerTemplate=y);const _=globalThis.DataGridElement?.getAdapters?.()??[],R=m??o,A=_.find(C=>C.canHandle(R));if(A){const C=A.createRenderer(R);C&&(h.viewRenderer=C)}const j=b??o,x=_.find(C=>C.canHandle(j));if(x){const C=x.createEditor(j);C&&(h.editor=C)}return h}).filter(o=>!!o)}function ne(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 re(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 se(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 h=c.scrollWidth;h>l&&(l=h)}}l>0&&(n.width=l+2,n.__autoSized=!0,i=!0)}),i&&q(t),t.__didInitialAutoSize=!0}function q(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 qe(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 Ue(t,e){const o=t[0]||{},i=Object.keys(o).map(r=>{const s=o[r],l=qe(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__",$e=/^[\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 Ve(t){return!t||typeof t!="string"?"":t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Fe=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"]),le=/^on\w+$/i,Xe=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),Ye=/^\s*(javascript|vbscript|data|blob):/i;function V(t){if(!t||typeof t!="string")return"";if(t.indexOf("<")===-1)return t;const e=document.createElement("template");return e.innerHTML=t,je(e.content),e.innerHTML}function je(t){const e=[],o=t.querySelectorAll("*");for(const i of o){const n=i.tagName.toLowerCase();if(Fe.has(n)){e.push(i);continue}if((n==="svg"||i.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(i.attributes).some(l=>le.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(le.test(l)){r.push(s.name);continue}if(Xe.has(l)&&Ye.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 ae(t,e){if(!t||t.indexOf("{{")===-1)return t;const o=[],i=t.replace(We,(l,a)=>{const c=Ke(a,e);return o.push({expr:a.trim(),result:c}),c}),n=Ze(i),r=o.length&&o.every(l=>l.result===""||l.result===P);return/Reflect\.|\bProxy\b|ownKeys\(/.test(t)||r?"":n}function Ke(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||!$e.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 Ze(t){return t&&t.replace(new RegExp(P,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function Qe(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 ce(t){const e=/Reflect\.|\bProxy\b|ownKeys\(/.test(t),o=(i=>e?"":ae(t,i));return o.__blocked=e,o}const Je=100;class et{#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=ne(o,i);this.#c&&this.#c.length&&(n=ne(this.#c,i));const r=this.#s.getRows();return n.length===0&&r.length&&(n=Ue(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=ce(s.__viewTemplate.innerHTML)),s.__editorTemplate&&!s.__compiledEditor&&(s.__compiledEditor=ce(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)),h=[...a];for(const d of l)c.has(d.id)||h.push(d);h.sort((d,f)=>(d.order??100)-(f.order??100)),e.shell.header.toolbarButtons=h}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 h=c.getColumnState(n.field);h&&Object.assign(s,h)}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,h=n.get(a.field)?.order??1/0;return c-h}),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)},Je)}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?Be(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 de(t){return`<span role="checkbox" aria-checked="${t}" aria-label="${t}">${t?"🗹":"☐"}</span>`}function he(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 ue(t){if(!t)return-1;const e=t.getAttribute("data-row");return e?parseInt(e,10):-1}function tt(t){if(!t)return-1;const e=t.getAttribute("data-col");return e?parseInt(e,10):-1}function K(t){t&&t.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function ot(t,e){const o=ue(e),i=tt(e);o<0||i<0||(t._focusRow=o,t._focusCol=i,K(t._bodyEl),e.classList.add("cell-focus"),e.setAttribute("aria-selected","true"))}function it(t,e,o){e.addEventListener("mousedown",i=>{const n=i.target.closest(".cell[data-col]");n&&(n.classList.contains("editing")||ot(t,n))},{signal:o})}function fe(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 n=o.find(l=>l.field===e.field)?.sortComparator??fe,{field:r,direction:s}=e;return[...t].sort((l,a)=>n(l[r],a[r],l,a)*s)}function ge(t,e,o,i){t._rows=e,t.__rowRenderEpoch++,t._rowPool.forEach(n=>n.__epoch=-1),F(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:i}})),t.requestStateChange?.()}function we(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),be(t,e,1)):t._sortState.direction===1?be(t,e,-1):(t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(i=>i.__epoch=-1),t._rows=t.__originalOrder.slice(),F(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 be(t,e,o){t._sortState={field:e.field,direction:o};const i={field:e.field,direction:o},n=t._columns,s=(t.effectiveConfig?.sortHandler??pe)(t._rows,i,n);s&&typeof s.then=="function"?s.then(l=>{ge(t,l,e,o)}):ge(t,s,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,i)=>{const n=document.createElement("div");n.className="cell",re(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");re(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;nt(s,c),n.appendChild(s),n.setAttribute("aria-sort",l===0?"none":l===1?"ascending":"descending"),n.addEventListener("click",h=>{t._resizeController?.isResizing||t._dispatchHeaderClick?.(h,i,n)||we(t,o)}),n.addEventListener("keydown",h=>{if(h.key==="Enter"||h.key===" "){if(h.preventDefault(),t._dispatchHeaderClick?.(h,i,n))return;we(t,o)}})}if(o.resizable){n.classList.add("resizable");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 me=typeof requestIdleCallback=="function";function rt(t,e){return me?requestIdleCallback(t,e):window.setTimeout(()=>{const o=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-o))})},1)}function ve(t){me?cancelIdleCallback(t):clearTimeout(t)}const Ce='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function Z(t){return(t.__editingCellCount??0)>0}function Q(t){t.__editingCellCount=0,t.removeAttribute("data-has-editing"),t.querySelectorAll(".cell.editing").forEach(o=>o.classList.remove("editing"))}const _e=document.createElement("template");_e.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const ye=document.createElement("template");ye.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function st(){return _e.content.firstElementChild.cloneNode(!0)}function lt(){return ye.content.firstElementChild.cloneNode(!0)}function X(t){t.__cellDisplayCache=void 0,t.__cellCacheEpoch=void 0,t.__hasSpecialColumns=void 0}function at(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=lt();d.addEventListener("click",f=>Ee(t,f,d)),d.addEventListener("dblclick",f=>Ee(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 h=n&&t.__hasRenderRowPlugins!==!1;for(let d=0;d<r;d++){const f=e+d,p=t._rows[f],u=t._rowPool[d];if(u.setAttribute("aria-rowindex",String(f+c+1)),h&&n(p,u,f)){u.__epoch=i,u.__rowDataRef=p,u.parentNode!==s&&s.appendChild(u);continue}const g=u.__epoch,m=u.__rowDataRef,b=u.children.length,w=g===i&&b===a,_=m!==p;let R=!1;if(w&&_){for(let x=0;x<a;x++)if(l[x].externalView&&!u.querySelector(`.cell[data-col="${x}"] [data-external-view]`)){R=!0;break}}if(!w||R){const x=Z(u),C=t._activeEditRows===f;x&&!C?(u.__isCustomRow&&(u.className="data-grid-row",u.setAttribute("role","row"),u.__isCustomRow=!1),Q(u),U(t,u,p,f),u.__epoch=i,u.__rowDataRef=p):x&&C?(J(t,u,p,f),u.__rowDataRef=p):(u.__isCustomRow&&(u.className="data-grid-row",u.setAttribute("role","row"),u.__isCustomRow=!1),U(t,u,p,f),u.__epoch=i,u.__rowDataRef=p)}else if(_){const x=Z(u),C=t._activeEditRows===f;x&&!C?(Q(u),U(t,u,p,f),u.__epoch=i,u.__rowDataRef=p):(J(t,u,p,f),u.__rowDataRef=p)}else{const x=Z(u),C=t._activeEditRows===f;x&&!C?(Q(u),U(t,u,p,f),u.__epoch=i,u.__rowDataRef=p):J(t,u,p,f)}const A=t._changedRowIndices?.has(f)??!1,j=u.classList.contains("changed");A!==j&&u.classList.toggle("changed",A),u.parentNode!==s&&s.appendChild(u)}}function J(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,h=t._focusCol;let d=t.__hasSpecialColumns;if(d===void 0){d=!1;for(let p=0;p<s;p++){const u=r[p];if(u.__viewTemplate||u.__compiledView||u.renderer||u.viewRenderer||u.externalView||u.format||u.type==="date"||u.type==="boolean"){d=!0;break}}t.__hasSpecialColumns=d}const f=String(i);if(!d){for(let p=0;p<a;p++){const u=n[p],g=o[r[p].field];u.textContent=g==null?"":String(g),u.getAttribute("data-row")!==f&&u.setAttribute("data-row",f);const m=c===i&&h===p,b=u.classList.contains("cell-focus");m!==b&&(u.classList.toggle("cell-focus",m),u.setAttribute("aria-selected",String(m)))}return}for(let p=0;p<a;p++)if(r[p].externalView&&!n[p].querySelector("[data-external-view]")){U(t,e,o,i);return}for(let p=0;p<a;p++){const u=r[p],g=n[p];g.getAttribute("data-row")!==f&&g.setAttribute("data-row",f);const m=c===i&&h===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=u.renderer||u.viewRenderer;if(y){const R=o[u.field],A=y({row:o,value:R,field:u.field,column:u,cellEl:g});typeof A=="string"?g.innerHTML=V(A):A instanceof Node?A.parentElement!==g&&(g.innerHTML="",g.appendChild(A)):A==null&&(g.textContent=R==null?"":String(R));continue}if(u.__viewTemplate||u.__compiledView||u.externalView)continue;const w=o[u.field];let _;if(u.format)try{const R=u.format(w,o);_=R==null?"":String(R)}catch(R){console.warn(`[tbw-grid] Format error in column '${u.field}':`,R),_=w==null?"":String(w)}else u.type==="date"?(_=he(w),g.textContent=_):u.type==="boolean"?g.innerHTML=de(!!w):(_=w==null?"":String(w),g.textContent=_)}}function U(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 h=0;h<r;h++){const d=n[h],f=st();f.setAttribute("aria-colindex",String(h+1)),f.setAttribute("data-col",String(h)),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 u=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=V(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 R={row:o,value:p,field:d.field,column:d};if(w.mount)try{w.mount({placeholder:_,context:R,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:R}}))}catch(A){console.warn(`[tbw-grid] External view event dispatch error for column '${d.field}':`,A)}});_.setAttribute("data-mounted","")}else if(u){const w=u({row:o,value:p,field:d.field,column:d}),_=u.__blocked;f.innerHTML=_?"":V(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=V(ae(w,{row:o,value:p})),y=!0)}else d.type==="date"?f.textContent=he(p):d.type==="boolean"?f.innerHTML=de(!!p):f.textContent=p==null?"":String(p);if(y){Qe(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===h?(f.classList.add("cell-focus"),f.setAttribute("aria-selected","true")):f.setAttribute("aria-selected","false"),c.appendChild(f)}e.appendChild(c)}function Ee(t,e,o,i){if(e.target?.closest(".resize-handle"))return;const n=o.querySelector(".cell[data-row]"),r=ue(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&&(K(t.shadowRoot??t._bodyEl),l.classList.add("cell-focus"));const h=l.querySelector(Ce);try{h?.focus({preventScroll:!0})}catch{}return}W(t)}}}function ct(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=h=>{if(!h)return!1;const d=h.tagName;return!!(d==="INPUT"||d==="SELECT"||d==="TEXTAREA"||h.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,h=a?.clientHeight??c?.clientHeight??0;if(c&&h>0){const d=t._focusRow*s;d<c.scrollTop?c.scrollTop=d:d+s>c.scrollTop+h&&(c.scrollTop=d-h+s)}}const o=t._activeEditRows!==void 0&&t._activeEditRows!==-1;o||t.refreshVirtualWindow(!1),K(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 h=l.getBoundingClientRect(),d=a.getBoundingClientRect(),f=h.left-d.left+a.scrollLeft,p=f+h.width,u=a.scrollLeft+c.left,g=a.scrollLeft+a.clientWidth-c.right;f<u?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(Ce);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 dt{#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 ht(t){let e=null,o=null,i=null,n=null;const r=a=>{if(!e)return;const c=a.clientX-e.startX,h=Math.max(40,e.startWidth+c),d=t._visibleColumns[e.colIndex];d.width=h,d.__userResized=!0,d.__renderedWidth=h,o==null&&(o=requestAnimationFrame(()=>{o=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:d.field,width:h}}))};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,h){a.preventDefault();const d=h.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 Y(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 T(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 Se(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 Re(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,17 +16,17 @@
|
|
|
16
16
|
<div class="faux-vscroll">
|
|
17
17
|
<div class="faux-vscroll-spacer"></div>
|
|
18
18
|
</div>
|
|
19
|
-
`;function
|
|
19
|
+
`;function Ae(){return Te.content.cloneNode(!0)}function xe(t){const e=document.createDocumentFragment(),o=T(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=T("tbw-grid-content");i.appendChild(Ae()),o.appendChild(i)}return e.appendChild(o),e}function ut(t){const e=T("tbw-shell-header",{part:"shell-header",role:"presentation"});if(t.title){const r=T("tbw-shell-title");r.textContent=t.title,e.appendChild(r)}const o=T("tbw-shell-content",{part:"shell-content",role:"presentation"});o.appendChild(Re("header-content")),e.appendChild(o);const i=T("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const r of t.configButtons)(r.hasElement||r.hasRender)&&i.appendChild(T("tbw-toolbar-btn-slot",{"data-btn-slot":r.id}));for(const r of t.apiButtons)(r.hasElement||r.hasRender)&&i.appendChild(T("tbw-toolbar-btn-slot",{"data-btn-slot":r.id}));if(i.appendChild(Re("toolbar")),(t.configButtons.some(r=>r.hasElement||r.hasRender)||t.apiButtons.some(r=>r.hasElement||r.hasRender))&&t.hasPanels&&i.appendChild(T("tbw-toolbar-separator")),t.hasPanels){const r=Se(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 ft(t){const e=T("tbw-shell-body"),o=t.panels.length>0,i=t.panels.length===1,n=T("tbw-grid-content");n.appendChild(Ae());let r=null;if(o){r=Y("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(T("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":s,"aria-hidden":"true"}));const l=T("tbw-tool-panel-content",{role:"presentation"}),a=T("tbw-accordion");for(const c of t.panels){const h=`tbw-accordion-section${c.isExpanded?" expanded":""}${i?" single":""}`,d=T(h,{"data-section":c.id}),f=Se("tbw-accordion-header",{"aria-expanded":String(c.isExpanded),"aria-controls":`tbw-section-${c.id}`});if(i&&f.setAttribute("aria-disabled","true"),c.icon){const u=Y("span",{class:"tbw-accordion-icon"});u.innerHTML=c.icon,f.appendChild(u)}const p=Y("span",{class:"tbw-accordion-title"});if(p.textContent=c.title,f.appendChild(p),!i){const u=Y("span",{class:"tbw-accordion-chevron"});u.innerHTML=c.isExpanded?t.collapseIcon:t.expandIcon,f.appendChild(u)}d.appendChild(f),d.appendChild(T("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 pt(){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 Pe(t){return!!(t?.header?.title||t?.header?.toolbarButtons?.length||t?.toolPanels?.length||t?.headerContents?.length||t?.header?.lightDomContent?.length||t?.header?.hasToolButtonsContainer)}function Le(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 u="";for(const g of f)(g.element||g.render)&&(u+=`<div class="tbw-toolbar-btn-slot" data-btn-slot="${g.id}"></div>`);for(const g of p)(g.element||g.render)&&(u+=`<div class="tbw-toolbar-btn-slot" data-btn-slot="${g.id}"></div>`);if(u+='<slot name="toolbar"></slot>',d&&(u+='<div class="tbw-toolbar-separator"></div>'),c){const g=e.isPanelOpen;u+=`<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
|
-
${n?`<div class="tbw-shell-title">${
|
|
21
|
+
${n?`<div class="tbw-shell-title">${Ve(i)}</div>`:""}
|
|
22
22
|
<div class="tbw-shell-content" part="shell-content" role="presentation">
|
|
23
23
|
<slot name="header-content"></slot>
|
|
24
24
|
</div>
|
|
25
25
|
<div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">
|
|
26
|
-
${
|
|
26
|
+
${u}
|
|
27
27
|
</div>
|
|
28
28
|
</div>
|
|
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.
|
|
29
|
+
`}function I(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 B(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,h=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=h,p.icon=a,p.tooltip=c;const g=e.panelCleanups.get(s);g&&(g(),e.panelCleanups.delete(s))}return}const u={id:s,title:l,icon:a,tooltip:c,order:h,render:d};e.toolPanels.set(s,u),e.lightDomToolPanelIds.add(s),r.style.display="none"})}function gt(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 h=c.getAttribute("data-btn");h&&i.onToolbarButtonClick(h)}});const r=t.querySelector(".tbw-accordion");r&&r.addEventListener("click",s=>{const a=s.target.closest(".tbw-accordion-header");if(a){const h=a.closest("[data-section]")?.getAttribute("data-section");h&&i.onSectionToggle(h)}})}function wt(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,h=0,d=!1;const f=g=>{if(!d)return;g.preventDefault();const m=s==="left"?g.clientX-a:a-g.clientX,b=Math.min(h,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)},u=g=>{g.preventDefault(),d=!0,a=g.clientX,c=i.getBoundingClientRect().width,h=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",u),()=>{n.removeEventListener("mousedown",u),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p)}}function bt(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 He(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 mt(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 h=a.querySelector(".tbw-accordion-header");h&&h.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 Oe(t,e){const o=t.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",e.isPanelOpen),o.setAttribute("aria-pressed",String(e.isPanelOpen)))}function De(t,e){const o=t.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",e.isPanelOpen),e.isPanelOpen||(o.style.width=""))}function vt(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 Ct(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 _t(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();Oe(n,t),De(n,t),mt(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();Oe(n,t),De(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),ee(s,n,!1)}else{for(const[a,c]of t.toolPanels)if(a!==n&&t.expandedSections.has(a)){const h=t.panelCleanups.get(a);h&&(h(),t.panelCleanups.delete(a)),c.onClose?.(),t.expandedSections.delete(a),ee(s,a,!1);const d=s.querySelector(`[data-section="${a}"] .tbw-accordion-content`);d&&(d.innerHTML="")}t.expandedSections.add(n),ee(s,n,!0),yt(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&&He(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 vt(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 ee(t,e,o){const i=t.querySelector(`[data-section="${e}"]`);i&&i.classList.toggle("expanded",o)}function yt(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 Et(t,e,o,i){const n=Pe(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)}))},u=ut(f),g=ft(p),m=xe({hasShell:!0,shellHeader:u,shellBody:g});t.appendChild(m)}else{const r=xe({hasShell:!1});t.appendChild(r)}return n}function St(){return{startY:null,startX:null,scrollTop:null,scrollLeft:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0}}function Rt(t){t.startY=null,t.startX=null,t.scrollTop=null,t.scrollLeft=null,t.lastY=null,t.lastX=null,t.lastTime=null}function Me(t){t.momentumRaf&&(cancelAnimationFrame(t.momentumRaf),t.momentumRaf=0)}function Tt(t,e,o){if(t.touches.length!==1)return;Me(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 At(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:h,clientHeight:d}=o.fauxScrollbar,f=h-d,p=l>0&&c<f||l<0&&c>0;let u=!1;if(o.scrollArea){const{scrollLeft:g,scrollWidth:m,clientWidth:b}=o.scrollArea,y=m-b;u=a>0&&g<y||a<0&&g>0}return p&&(o.fauxScrollbar.scrollTop=e.scrollTop+l),u&&o.scrollArea&&(o.scrollArea.scrollLeft=e.scrollLeft+a),p||u}function xt(t,e){(Math.abs(t.velocityY)>.1||Math.abs(t.velocityX)>.1)&&Pt(t,e),Rt(t)}function Pt(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 Lt(t,e,o,i){t.addEventListener("touchstart",n=>Tt(n,e,o),{passive:!0,signal:i}),t.addEventListener("touchmove",n=>{At(n,e,o)&&n.preventDefault()},{passive:!1,signal:i}),t.addEventListener("touchend",()=>xt(e,o),{passive:!0,signal:i})}const Ht=[{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"}],Ot=[{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 M(t){return t.charAt(0).toUpperCase()+t.slice(1)}function ze(t,e){return t.some(o=>o.name===e)}function Dt(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 h=o.get(r);h.fields.includes(a)||h.fields.push(a)}for(const r of Ot){const s=t[r.property];(r.isUsed?r.isUsed(s):s!==void 0)&&!ze(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 Ht){const l=r[s.property];if((s.isUsed?s.isUsed(l):l!==void 0)&&!ze(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:h}]of o)if(h)r.push(`Config uses ${l}, but the required plugin is not loaded.
|
|
30
30
|
→ Add the plugin to your gridConfig.plugins array:
|
|
31
31
|
${a}
|
|
32
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.
|
|
@@ -38,7 +38,13 @@ ${r.join(`
|
|
|
38
38
|
|
|
39
39
|
`)}
|
|
40
40
|
|
|
41
|
-
This validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`)}}
|
|
42
|
-
|
|
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"})}));
|
|
41
|
+
This validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`)}}const Mt={editing:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';",selection:"import { SelectionPlugin } from '@toolbox-web/grid/plugins/selection';",reorder:"import { ReorderPlugin } from '@toolbox-web/grid/plugins/reorder';",clipboard:"import { ClipboardPlugin } from '@toolbox-web/grid/plugins/clipboard';",filtering:"import { FilteringPlugin } from '@toolbox-web/grid/plugins/filtering';",multiSort:"import { MultiSortPlugin } from '@toolbox-web/grid/plugins/multi-sort';",groupingRows:"import { GroupingRowsPlugin } from '@toolbox-web/grid/plugins/grouping-rows';",groupingColumns:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';",tree:"import { TreePlugin } from '@toolbox-web/grid/plugins/tree';",masterDetail:"import { MasterDetailPlugin } from '@toolbox-web/grid/plugins/master-detail';",pinnedColumns:"import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';",pinnedRows:"import { PinnedRowsPlugin } from '@toolbox-web/grid/plugins/pinned-rows';",visibility:"import { VisibilityPlugin } from '@toolbox-web/grid/plugins/visibility';",undoRedo:"import { UndoRedoPlugin } from '@toolbox-web/grid/plugins/undo-redo';",export:"import { ExportPlugin } from '@toolbox-web/grid/plugins/export';",contextMenu:"import { ContextMenuPlugin } from '@toolbox-web/grid/plugins/context-menu';",pivot:"import { PivotPlugin } from '@toolbox-web/grid/plugins/pivot';",serverSide:"import { ServerSidePlugin } from '@toolbox-web/grid/plugins/server-side';",columnVirtualization:"import { ColumnVirtualizationPlugin } from '@toolbox-web/grid/plugins/column-virtualization';"};function zt(t){return Mt[t]??`import { ${M(t)}Plugin } from '@toolbox-web/grid/plugins/${t}';`}function Nt(t,e){const o=t.name,n=t.constructor.dependencies??[];for(const r of n){const s=r.name,l=r.required??!0,a=r.reason;if(!e.some(h=>h.name===s)){const h=a??`${M(o)}Plugin requires ${M(s)}Plugin`,d=zt(s);if(l)throw new Error(`[tbw-grid] Plugin dependency error:
|
|
42
|
+
|
|
43
|
+
${h}.
|
|
44
|
+
|
|
45
|
+
→ Add the plugin to your gridConfig.plugins array BEFORE ${M(o)}Plugin:
|
|
46
|
+
${d}
|
|
47
|
+
plugins: [new ${M(s)}Plugin(), new ${M(o)}Plugin()]`);console.info(`[tbw-grid] ${M(o)}Plugin: Optional "${s}" plugin not found. Some features may be unavailable.`)}}}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(Nt(e,this.plugins),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(`
|
|
48
|
+
`)}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=St();#g;#_;#y;#C;#S={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#i;#E;#O=!1;#P;#L;#t;#e=pt();#a;#D;_rows=[];#z=[];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 dt({mergeConfig:()=>{this.#t.parseLightDomColumns(this),this.#t.merge(),this.#V(),Dt(this.#n,this.#i?.getPlugins()??[]),this.#z=[...this._columns]},processColumns:()=>this.#de(),processRows:()=>this.#he(),renderHeader:()=>F(this),updateTemplate:()=>q(this),renderVirtualWindow:()=>this.refreshVirtualWindow(!0),afterRender:()=>{this.#i?.afterRender(),this.#n.fitMode==="fixed"&&!this.__didInitialAutoSize&&(this.__didInitialAutoSize=!0,se(this))},isConnected:()=>this.isConnected&&this.#h}),this.#l.setInitialReadyResolver(()=>this.#d?.()),this.#a=_t(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 et({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.#T(),renderHeader:()=>F(this),updateTemplate:()=>q(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(z.length>0){e.replaceSync(z),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(`
|
|
49
|
+
`);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(){q(this)}requestAfterRender(){this.#l.requestPhase(S.STYLE,"plugin:requestAfterRender")}#G(){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.#G(),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)}#R(){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&&(ve(this.#C),this.#C=void 0),I(this,this.#e),k(this,this.#e),B(this,this.#e,this.#R()),this.#t.parseLightDomColumns(this),this.#t.merge(),this.#G();const e=this.#n?.plugins;this.#E=Array.isArray(e)?e:[],this.#F(),this.#c||(this.#W(),this.#M(),this.#c=!0),this.#N(),this.#C=rt(()=>{this.#me()},{timeout:100})}disconnectedCallback(){this.#C&&(ve(this.#C),this.#C=void 0),this.#J(),Ct(this.#e),this.#a.setInitialized(!1),this.#D?.(),this.#D=void 0,Me(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.#I=!1),X(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)}#N(){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){He(this.#o,this.#e),bt(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=ht(this),this.#T(),this.#ee(o),this.#O)return;this.#O=!0;const i=this.disconnectSignal;this.addEventListener("keydown",r=>ct(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),h=c-c%2,d=-(l-h*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:h,scrollWidth:d,clientWidth:f}=s;(c>0&&h<d-f||c<0&&h>0)&&(l.preventDefault(),s.scrollLeft+=c)}else if(!a){const{scrollTop:c,scrollHeight:h,clientHeight:d}=i;(l.deltaY>0&&c<h-d||l.deltaY<0&&c>0)&&(l.preventDefault(),i.scrollTop+=l.deltaY)}},{passive:!1,signal:o}),Lt(r,this.#x,{fauxScrollbar:i,scrollArea:s},o))}this._bodyEl&&it(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()))}#I=!1;#te(){if(this.#I)return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;this.#I=!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(){X(this),this.#t.merge(),this.#T()}#se(){this.#t.merge(),this.#n.fitMode==="fixed"?(this.__didInitialAutoSize=!1,se(this)):(this._columns.forEach(o=>{!o.__userResized&&o.__autoSized&&delete o.width}),q(this))}#le(){this.#t.merge(),this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++,this.#l.requestPhase(S.VIRTUALIZATION,"applyEditModeUpdate")}#ae(){I(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(),B(this,this.#e,this.#R()),this.#t.markSourcesChanged(),this.#t.merge();const n=Pe(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.#W(),this.#M(),this.#N();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.#z.length>0?this.#z: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(){X(this);const e=Array.isArray(this.#r)?[...this.#r]:[],o=this.#i?.processRows(e)??e;this._rows=o}#ue(e){const o={...ie,...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}#k(e,o,i=this.__rowRenderEpoch){this.#s||(this.#s=(n,r,s)=>this.#i?.renderRow(n,r,s)??!1),at(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"))}#T(){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 u=this.#o.elementFromPoint(e.clientX,e.clientY);u&&(i=u)}const r=i?.closest?.("[data-col]"),s=i?.closest?.(".data-grid-row"),l=i?.closest?.(".header-row");let a,c,h,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&&(h=this._rows[a],p=this._columns[c],d=p?.field,f=h&&d?h[d]:void 0)),{type:o,row:h,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.#T()}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.#T()}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(){I(this,this.#e),k(this,this.#e),B(this,this.#e,this.#R()),this.#t.markSourcesChanged(),this.#t.merge(),this.#W(),this.#M(),this.#N()}#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;I(this,this.#e),k(this,this.#e),B(this,this.#e,this.#R());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=Le(this.#n.shell,this.#e,this.#n.icons?.toolPanel),c=document.createElement("div");c.innerHTML=a;const h=c.firstElementChild;h&&(l.replaceWith(h),this.#$())}}},o=()=>{this.__lightDomColumnsCache=void 0,this.#T()};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,X(this),this.#t.parseLightDomColumns(this);const e=this.#e.lightDomTitle,o=this.#e.hasToolButtonsContainer;I(this,this.#e),k(this,this.#e),B(this,this.#e,this.#R());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=Le(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.#$())}}this.#l.requestPhase(S.COLUMNS,"refreshColumns")}#U(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.#k(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.#k(0,o,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${this.#U(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 h=10;for(;c<h;){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.#U(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.#k(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.#U(o);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${_}px`)}))}#W(){I(this,this.#e),k(this,this.#e),B(this,this.#e,this.#R()),this.#t.markSourcesChanged(),this.#t.merge();const e=this.#n?.shell;Et(this.#o,e,{isPanelOpen:this.#e.isPanelOpen,expandedSections:this.#e.expandedSections},this.#n?.icons)&&(this.#$(),this.#a.setInitialized(!0))}#$(){gt(this.#o,this.#n?.shell,this.#e,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e),onToolbarButtonClick:e=>this.#ve(e)}),this.#D?.(),this.#D=wt(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 It={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"};class kt{static dependencies;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"},$={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"},Bt={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}[${$.ROW_INDEX}="${t}"]`,CELL_BY_FIELD:t=>`.${E.DATA_CELL}[${$.FIELD}="${t}"]`,CELL_AT:(t,e)=>`.${E.DATA_ROW}[${$.ROW_INDEX}="${t}"] .${E.DATA_CELL}[${$.COL_INDEX}="${e}"]`,SELECTED_ROWS:`.${E.DATA_ROW}.${E.SELECTED}`,EDITING_CELL:`.${E.DATA_CELL}.${E.EDITING}`},qt={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"},Ut={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"},Wt={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"},te={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)??te[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 te},list(){return[...Object.keys(te),...G.keys()]}},Ie={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 Ie[t]??Ie.sum}function $t(t,e){return ke(t)(e)}const Gt=L.register.bind(L),Vt=L.unregister.bind(L),Ft=L.get.bind(L),Xt=L.run.bind(L),Yt=L.list.bind(L);v.BaseGridPlugin=kt,v.DEFAULT_ANIMATION_CONFIG=ie,v.DEFAULT_GRID_ICONS=H,v.DGEvents=Ut,v.DataGridElement=O,v.FitModeEnum=N,v.GridCSSVars=qt,v.GridClasses=E,v.GridDataAttrs=$,v.GridElement=O,v.GridSelectors=Bt,v.PLUGIN_QUERIES=It,v.PluginEvents=Wt,v.PluginManager=Ne,v.RenderPhase=S,v.aggregatorRegistry=L,v.builtInSort=pe,v.defaultComparator=fe,v.getAggregator=Ft,v.getValueAggregator=ke,v.listAggregators=Yt,v.registerAggregator=Gt,v.runAggregator=Xt,v.runValueAggregator=$t,v.unregisterAggregator=Vt,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
|
44
50
|
//# sourceMappingURL=grid.umd.js.map
|