@toolbox-web/grid 1.2.0 → 1.3.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/README.md +80 -22
- package/all.js +619 -571
- package/all.js.map +1 -1
- package/index.js +362 -302
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +64 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/row-animation.d.ts +37 -0
- package/lib/core/internal/row-animation.d.ts.map +1 -0
- package/lib/core/types.d.ts +17 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +82 -76
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +1 -0
- package/lib/plugins/clipboard/types.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js +43 -41
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +24 -22
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +83 -52
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +22 -20
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +11 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +160 -125
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +20 -18
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +66 -64
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +51 -49
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +17 -15
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +24 -22
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +25 -23
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +49 -47
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +24 -22
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +19 -17
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +38 -36
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +13 -0
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.d.ts +1 -1
- package/lib/plugins/selection/index.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +118 -85
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +50 -6
- package/lib/plugins/selection/types.d.ts.map +1 -1
- package/lib/plugins/server-side/index.js +34 -32
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +25 -23
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +22 -20
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +21 -19
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +21 -4
- package/public.d.ts +1 -1
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +19 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +9 -9
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +5 -5
- 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/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
package/umd/grid.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(C,q){typeof exports=="object"&&typeof module<"u"?q(exports):typeof define=="function"&&define.amd?define(["exports"],q):(C=typeof globalThis<"u"?globalThis:C||self,q(C.TbwGrid={}))})(this,(function(C){"use strict";const q='@layer tbw-base,tbw-plugins,tbw-theme;@layer tbw-base{:root{color-scheme:light dark}tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--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-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--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, #666666);--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-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--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: var(--tbw-spacing-sm);--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--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-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-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm);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}tbw-grid,tbw-grid *{box-sizing:border-box}tbw-grid .header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}tbw-grid .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)}tbw-grid .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))}tbw-grid .header-group-cell:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .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)}tbw-grid .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:visible;min-width:0}tbw-grid .header-row>.cell>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .header-row>.cell>span[part~=sort-indicator]{flex-shrink:0;opacity:.6}tbw-grid .header-row>.cell:last-child{border-right:0}tbw-grid .header-row>.cell.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row>.cell.resizable{position:relative}tbw-grid .header-row>.cell.sticky-left,tbw-grid .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}tbw-grid .tbw-grid-root{display:flex;flex-direction:column;height:100%}tbw-grid .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}tbw-grid .rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}tbw-grid .rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}tbw-grid .rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}tbw-grid .rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip}tbw-grid .rows-viewport .rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}tbw-grid .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)}tbw-grid .faux-vscroll-spacer{width:1px}tbw-grid .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)}tbw-grid .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid .data-grid-row:hover{background:var(--tbw-color-row-hover)}tbw-grid .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}tbw-grid .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}tbw-grid .data-grid-row>.cell:last-child{border-right:0}tbw-grid .data-grid-row>.cell[data-type=boolean]{text-align:center}tbw-grid .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}tbw-grid .data-grid-row>.cell.selected:focus-visible,tbw-grid .data-grid-row>.cell:focus-visible:not(.cell-focus){outline:none}tbw-grid .data-grid-row>.cell.sticky-left,tbw-grid .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}tbw-grid .selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid .sortable{cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .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)}tbw-grid .resize-handle:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-indicator-width, 2px);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}tbw-grid .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}tbw-grid .resize-handle:hover:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}tbw-grid[data-has-focus] .cell-focus,tbw-grid[data-has-focus] .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .sticky-left,tbw-grid .sticky-right{position:sticky;z-index:25}tbw-grid .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}tbw-grid .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}tbw-grid .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}tbw-grid .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}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .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)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}tbw-grid .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}tbw-grid .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}tbw-grid .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)}tbw-grid .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)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .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)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .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}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .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}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .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}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .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}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}tbw-grid .tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}tbw-grid .tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}tbw-grid[data-animation-mode=off]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}@media(forced-colors:active){tbw-grid{--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}tbw-grid .cell:focus,tbw-grid .cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}tbw-grid .data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}@media(prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}}@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)}}}',W={STRETCH:"stretch",FIXED:"fixed"},he={mode:"reduced-motion",duration:200,easing:"ease-out"},z={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰"};function je(t){return Array.from(t.querySelectorAll("tbw-grid-column")).map(o=>{const n=o.getAttribute("field")||"";if(!n)return null;const i=o.getAttribute("type")||void 0,s=i&&new Set(["number","string","date","boolean","select"]).has(i)?i:void 0,l=o.getAttribute("header")||void 0,c=o.hasAttribute("sortable"),a=o.hasAttribute("editable"),h={field:n,type:s,header:l,sortable:c,editable:a},u=o.getAttribute("width");if(u){const E=parseFloat(u);!isNaN(E)&&/^\d+(\.\d+)?$/.test(u.trim())?h.width=E:h.width=u}const g=o.getAttribute("minWidth")||o.getAttribute("min-width");if(g){const E=parseFloat(g);isNaN(E)||(h.minWidth=E)}o.hasAttribute("resizable")&&(h.resizable=!0),o.hasAttribute("sizable")&&(h.resizable=!0);const f=o.getAttribute("editor"),p=o.getAttribute("renderer");f&&(h.__editorName=f),p&&(h.__rendererName=p);const d=o.getAttribute("options");d&&(h.options=d.split(",").map(E=>{const[I,R]=E.includes(":")?E.split(":"):[E.trim(),E.trim()];return{value:I.trim(),label:R?.trim()||I.trim()}}));const w=o.querySelector("tbw-grid-column-view"),b=o.querySelector("tbw-grid-column-editor"),T=o.querySelector("tbw-grid-column-header");w&&(h.__viewTemplate=w),b&&(h.__editorTemplate=b),T&&(h.__headerTemplate=T);const A=globalThis.DataGridElement?.getAdapters?.()??[],m=w??o,_=A.find(E=>E.canHandle(m));if(_){const E=_.createRenderer(m);E&&(h.viewRenderer=E)}const S=b??o,y=A.find(E=>E.canHandle(S));if(y){const E=y.createEditor(S);E&&(h.editor=E)}return h}).filter(o=>!!o)}function ue(t,e){if((!t||!t.length)&&(!e||!e.length))return[];if(!t||!t.length)return e||[];if(!e||!e.length)return t;const o={};e.forEach(i=>{const r=o[i.field];if(r){i.header&&!r.header&&(r.header=i.header),i.type&&!r.type&&(r.type=i.type),i.sortable&&(r.sortable=!0),i.editable&&(r.editable=!0),i.resizable&&(r.resizable=!0),i.width!=null&&r.width==null&&(r.width=i.width),i.minWidth!=null&&r.minWidth==null&&(r.minWidth=i.minWidth),i.__viewTemplate&&(r.__viewTemplate=i.__viewTemplate),i.__editorTemplate&&(r.__editorTemplate=i.__editorTemplate),i.__headerTemplate&&(r.__headerTemplate=i.__headerTemplate);const s=i.renderer||i.viewRenderer,l=r.renderer||r.viewRenderer;s&&!l&&(r.viewRenderer=s,i.renderer&&(r.renderer=s)),i.editor&&!r.editor&&(r.editor=i.editor)}else o[i.field]={...i}});const n=t.map(i=>{const r=o[i.field];if(!r)return i;const s={...i};r.header&&!s.header&&(s.header=r.header),r.type&&!s.type&&(s.type=r.type),s.sortable=i.sortable||r.sortable,(i.resizable===!0||r.resizable===!0)&&(s.resizable=!0),s.editable=i.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,c=s.renderer||s.viewRenderer;return l&&!c&&(s.viewRenderer=l,r.renderer&&(s.renderer=l)),r.editor&&!s.editor&&(s.editor=r.editor),delete o[i.field],s});return Object.keys(o).forEach(i=>n.push(o[i])),n}function fe(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 ge(t){const e=t.effectiveConfig?.fitMode||t.fitMode||W.STRETCH;if(e!==W.STRETCH&&e!==W.FIXED||t.__didInitialAutoSize||!t.isConnected)return;const o=Array.from(t._headerRowEl?.children||[]);if(!o.length)return;let n=!1;t._visibleColumns.forEach((i,r)=>{if(i.width)return;const s=o[r];let l=s?s.scrollWidth:0;for(const c of t._rowPool){const a=c.children[r];if(a){const h=a.scrollWidth;h>l&&(l=h)}}l>0&&(i.width=l+2,i.__autoSized=!0,n=!0)}),n&&G(t),t.__didInitialAutoSize=!0}function G(t){(t.effectiveConfig?.fitMode||t.fitMode||W.STRETCH)===W.STRETCH?t._gridTemplate=t._visibleColumns.map(o=>{if(o.width)return`${o.width}px`;const n=o.minWidth;return n!=null?`minmax(${n}px, 1fr)`:"1fr"}).join(" ").trim():t._gridTemplate=t._visibleColumns.map(o=>o.width?`${o.width}px`:"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}function Ke(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 Ze(t,e){const o=t[0]||{},n=Object.keys(o).map(r=>{const s=o[r],l=Ke(s);return{field:r,header:r.charAt(0).toUpperCase()+r.slice(1),type:l}}),i={};return n.forEach(r=>{i[r.field]=r.type||"string"}),{columns:n,typeMap:i}}const Qe=/{{\s*([^}]+)\s*}}/g,D="__DG_EMPTY__",Je=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,et=/__(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 tt(t){return!t||typeof t!="string"?"":t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const ot=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"]),pe=/^on\w+$/i,nt=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),it=/^\s*(javascript|vbscript|data|blob):/i;function j(t){if(!t||typeof t!="string")return"";if(t.indexOf("<")===-1)return t;const e=document.createElement("template");return e.innerHTML=t,rt(e.content),e.innerHTML}function rt(t){const e=[],o=t.querySelectorAll("*");for(const n of o){const i=n.tagName.toLowerCase();if(ot.has(i)){e.push(n);continue}if((i==="svg"||n.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(n.attributes).some(l=>pe.test(l.name)||l.name==="href"||l.name==="xlink:href")){e.push(n);continue}const r=[];for(const s of n.attributes){const l=s.name.toLowerCase();if(pe.test(l)){r.push(s.name);continue}if(nt.has(l)&&it.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=>n.removeAttribute(s))}e.forEach(n=>n.remove())}function we(t,e){if(!t||t.indexOf("{{")===-1)return t;const o=[],n=t.replace(Qe,(l,c)=>{const a=st(c,e);return o.push({expr:c.trim(),result:a}),a}),i=lt(n),r=o.length&&o.every(l=>l.result===""||l.result===D);return/Reflect\.|\bProxy\b|ownKeys\(/.test(t)||r?"":i}function st(t,e){if(t=(t||"").trim(),!t||/\b(Reflect|Proxy|ownKeys)\b/.test(t))return D;if(t==="value")return e.value==null?D:String(e.value);if(t.startsWith("row.")&&!/[()?]/.test(t)&&!t.includes(":")){const n=t.slice(4),i=e.row?e.row[n]:void 0;return i==null?D:String(i)}if(t.length>80||!Je.test(t)||et.test(t))return D;const o=t.match(/\./g);if(o&&o.length>1)return D;try{const i=new Function("value","row",`return (${t});`)(e.value,e.row),r=i==null?"":String(i);return/Reflect|Proxy|ownKeys/.test(r)?D:r||D}catch{return D}}function lt(t){return t&&t.replace(new RegExp(D,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function at(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 be(t){const e=/Reflect\.|\bProxy\b|ownKeys\(/.test(t),o=(n=>e?"":we(t,n));return o.__blocked=e,o}const ct=100;class dt{#n;#c;#f;#d;#s;#i={};#h={};#u=!0;#b=[];#l;#p;#w;#r;#m;constructor(e){this.#r=e}get original(){return this.#i}get effective(){return this.#h}get columns(){return this.#h.columns??[]}set columns(e){this.#h.columns=e}get lightDomColumnsCache(){return this.#d}set lightDomColumnsCache(e){this.#d=e}get originalColumnNodes(){return this.#s}set originalColumnNodes(e){this.#s=e}get lightDomTitle(){return this.#m}set lightDomTitle(e){this.#m=e}get initialColumnState(){return this.#w}set initialColumnState(e){this.#w=e}get sourcesChanged(){return this.#u}markSourcesChanged(){this.#u=!0}setGridConfig(e){this.#n=e,this.#u=!0,this.#d=void 0}getGridConfig(){return this.#n}setColumns(e){this.#c=e,this.#u=!0}getColumns(){return this.#c}setFitMode(e){this.#f=e,this.#u=!0}getFitMode(){return this.#f}merge(){const e=(this.#h.columns?.length??0)>0;if(!this.#u&&e)return;const o=this.#v();this.#u=!1,this.#i=o,Object.freeze(this.#i),this.#i.columns&&Object.freeze(this.#i.columns),this.#h=this.#x(this.#i),this.#g()}#x(e){const o={...e};return e.columns&&(o.columns=e.columns.map(n=>({...n}))),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(n=>({...n})),headerContents:e.shell.headerContents?.map(n=>({...n}))}),o}#g(){const e=this.#h;e.rowHeight&&e.rowHeight>0&&this.#r.setRowHeight(e.rowHeight),e.fitMode==="fixed"&&this.columns.forEach(n=>{n.width==null&&(n.width=80)}),this.#r.applyAnimationConfig(e)}#v(){const e=this.#n?{...this.#n}:{},o=Array.isArray(e.columns)?[...e.columns]:[],n=(this.#d??[]).map(s=>({...s}));let i=ue(o,n);this.#c&&this.#c.length&&(i=ue(this.#c,n));const r=this.#r.getRows();return i.length===0&&r.length&&(i=Ze(r).columns),i.length&&(i.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)}),i.forEach(s=>{s.__viewTemplate&&!s.__compiledView&&(s.__compiledView=be(s.__viewTemplate.innerHTML)),s.__editorTemplate&&!s.__compiledEditor&&(s.__compiledEditor=be(s.__editorTemplate.innerHTML))}),e.columns=i),this.#f&&(e.fitMode=this.#f),e.fitMode||(e.fitMode="stretch"),this.#y(e),e.columnState&&!this.#w&&(this.#w=e.columnState),e}#y(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const o=this.#r.getShellLightDomTitle();o&&(this.#m=o),this.#m&&!e.shell.header.title&&(e.shell.header.title=this.#m);const n=this.#r.getShellLightDomHeaderContent();n?.length>0&&(e.shell.header.lightDomContent=n),this.#r.getShellHasToolButtonsContainer()&&(e.shell.header.hasToolButtonsContainer=!0);const i=this.#r.getShellToolPanels();if(i.size>0){const u=Array.from(i.values());u.sort((g,f)=>(g.order??100)-(f.order??100)),e.shell.toolPanels=u}const r=this.#r.getShellHeaderContents();if(r.size>0){const u=Array.from(r.values());u.sort((g,f)=>(g.order??100)-(f.order??100)),e.shell.headerContents=u}const s=this.#r.getShellToolbarContents(),l=Array.from(s.values()),c=this.#n?.shell?.header?.toolbarContents??[],a=new Set(c.map(u=>u.id)),h=[...c];for(const u of l)a.has(u.id)||h.push(u);h.sort((u,g)=>(u.order??0)-(g.order??0)),e.shell.header.toolbarContents=h}collectState(e){const o=this.columns,n=this.#C();return{columns:o.map((i,r)=>{const s={field:i.field,order:r,visible:!i.hidden},l=i;l.__renderedWidth!==void 0?s.width=l.__renderedWidth:i.width!==void 0&&(s.width=typeof i.width=="string"?parseFloat(i.width):i.width);const c=n.get(i.field);c&&(s.sort=c);for(const a of e)if(a.getColumnState){const h=a.getColumnState(i.field);h&&Object.assign(s,h)}return s})}}applyState(e,o){if(!e.columns||e.columns.length===0)return;const n=this.columns,i=new Map(e.columns.map(l=>[l.field,l])),r=n.map(l=>{const c=i.get(l.field);if(!c)return l;const a={...l};return c.width!==void 0&&(a.width=c.width,a.__renderedWidth=c.width),c.visible!==void 0&&(a.hidden=!c.visible),a});r.sort((l,c)=>{const a=i.get(l.field)?.order??1/0,h=i.get(c.field)?.order??1/0;return a-h}),this.columns=r;const s=e.columns.filter(l=>l.sort!==void 0).sort((l,c)=>(l.sort?.priority??0)-(c.sort?.priority??0));if(s.length>0){const l=s[0];l.sort&&this.#r.setSortState({field:l.field,direction:l.sort.direction==="asc"?1:-1})}else this.#r.setSortState(null);for(const l of o)if(l.applyColumnState)for(const c of e.columns)l.applyColumnState(c.field,c)}resetState(e){this.#w=void 0,this.#r.setSortState(null),this.#h=this.#x(this.#i),this.#g();for(const o of e)if(o.applyColumnState)for(const n of this.columns)o.applyColumnState(n.field,{field:n.field,order:0,visible:!0});this.requestStateChange(e)}#C(){const e=new Map,o=this.#r.getSortState();return o&&e.set(o.field,{direction:o.direction===1?"asc":"desc",priority:0}),e}requestStateChange(e){this.#p&&clearTimeout(this.#p),this.#p=setTimeout(()=>{this.#p=void 0;const o=this.collectState(e);this.#r.emit("column-state-change",o)},ct)}setColumnVisible(e,o){const n=this.columns,i=n.find(s=>s.field===e);return!i||!o&&i.lockVisible||!o&&n.filter(l=>!l.hidden&&l.field!==e).length===0||!!i.hidden===!o?!1:(i.hidden=!o,this.#r.emit("column-visibility",{field:e,visible:o,visibleColumns:n.filter(s=>!s.hidden).map(s=>s.field)}),this.#r.clearRowPool(),this.#r.setup(),!0)}toggleColumnVisibility(e){const o=this.columns.find(n=>n.field===e);return o?this.setColumnVisible(e,!!o.hidden):!1}isColumnVisible(e){const o=this.columns.find(n=>n.field===e);return o?!o.hidden:!1}showAllColumns(){const e=this.columns;e.some(o=>o.hidden)&&(e.forEach(o=>o.hidden=!1),this.#r.emit("column-visibility",{visibleColumns:e.map(o=>o.field)}),this.#r.clearRowPool(),this.#r.setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:e.meta?.utility===!0}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const o=new Map(this.columns.map(i=>[i.field,i])),n=[];for(const i of e){const r=o.get(i);r&&(n.push(r),o.delete(i))}for(const i of o.values())n.push(i);this.columns=n,this.#r.renderHeader(),this.#r.updateTemplate(),this.#r.refreshVirtualWindow()}parseLightDomColumns(e){this.#d||(this.#s=Array.from(e.querySelectorAll("tbw-grid-column")),this.#d=this.#s.length?je(e):[])}clearLightDomCache(){this.#d=void 0}#E=new Map;registerLightDomHandler(e,o){this.#E.set(e.toLowerCase(),o)}unregisterLightDomHandler(e){this.#E.delete(e.toLowerCase())}observeLightDOM(e){this.#l&&this.#l.disconnect();const o=new Set;let n=null;const i=()=>{n=null;for(const r of o)this.#E.get(r)?.();o.clear()};this.#l=new MutationObserver(r=>{for(const s of r){for(const l of s.addedNodes){if(l.nodeType!==Node.ELEMENT_NODE)continue;const a=l.tagName.toLowerCase();this.#E.has(a)&&o.add(a)}if(s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE){const c=s.target.tagName.toLowerCase();this.#E.has(c)&&o.add(c)}}o.size>0&&!n&&(n=setTimeout(i,0))}),this.#l.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#b.push(e)}notifyChange(){for(const e of this.#b)e()}dispose(){this.#l?.disconnect(),this.#b=[],this.#p&&clearTimeout(this.#p)}}function me(t){return`<span role="checkbox" aria-checked="${t}" aria-label="${t}">${t?"🗹":"☐"}</span>`}function Ce(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 ve(t){if(!t)return-1;const e=t.getAttribute("data-row");if(e)return parseInt(e,10);const o=t.closest(".data-grid-row");if(!o)return-1;const n=o.parentElement;if(!n)return-1;const i=n.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<i.length;r++)if(i[r]===o)return r;return-1}function ht(t){if(!t)return-1;const e=t.getAttribute("data-col");return e?parseInt(e,10):-1}function te(t){t&&t.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function ye(t,e){const o=e.renderer||e.viewRenderer;if(o)return o;if(!e.type)return;const n=t.effectiveConfig?.typeDefaults;if(n?.[e.type]?.renderer)return n[e.type].renderer;const i=t.__frameworkAdapter;if(i?.getTypeDefault){const r=i.getTypeDefault(e.type);if(r?.renderer)return r.renderer}}const _e='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function oe(t){return(t.__editingCellCount??0)>0}function ne(t){t.__editingCellCount=0,t.removeAttribute("data-has-editing"),t.querySelectorAll(".cell.editing").forEach(o=>o.classList.remove("editing"))}const Ee=document.createElement("template");Ee.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const Se=document.createElement("template");Se.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function ut(){return Ee.content.firstElementChild.cloneNode(!0)}function ft(){return Se.content.firstElementChild.cloneNode(!0)}function K(t){t.__cellDisplayCache=void 0,t.__cellCacheEpoch=void 0,t.__hasSpecialColumns=void 0}function gt(t,e,o,n,i){const r=Math.max(0,o-e),s=t._bodyEl,l=t._visibleColumns,c=l.length;let a=t.__cachedHeaderRowCount;for(a===void 0&&(a=t.querySelector(".header-group-row")?2:1,t.__cachedHeaderRowCount=a);t._rowPool.length<r;){const g=ft();t._rowPool.push(g)}if(t._rowPool.length>r){for(let g=r;g<t._rowPool.length;g++){const f=t._rowPool[g];f.parentNode===s&&f.remove()}t._rowPool.length=r}const h=i&&t.__hasRenderRowPlugins!==!1,u=t._hasAfterRowRenderHook?.()??!1;for(let g=0;g<r;g++){const f=e+g,p=t._rows[f],d=t._rowPool[g];if(d.setAttribute("aria-rowindex",String(f+a+1)),h&&i(p,d,f)){d.__epoch=n,d.__rowDataRef=p,d.parentNode!==s&&s.appendChild(d);continue}const w=d.__epoch,b=d.__rowDataRef,T=d.children.length,A=w===n&&T===c,m=b!==p;let _=!1;if(A&&m){for(let R=0;R<c;R++)if(l[R].externalView&&!d.querySelector(`.cell[data-col="${R}"] [data-external-view]`)){_=!0;break}}if(!A||_){const R=oe(d),O=t._activeEditRows===f;R&&!O?(d.__isCustomRow&&(d.className="data-grid-row",d.setAttribute("role","row"),d.__isCustomRow=!1),ne(d),B(t,d,p,f),d.__epoch=n,d.__rowDataRef=p):R&&O?(ie(t,d,p,f),d.__rowDataRef=p):(d.__isCustomRow&&(d.className="data-grid-row",d.setAttribute("role","row"),d.__isCustomRow=!1),B(t,d,p,f),d.__epoch=n,d.__rowDataRef=p)}else if(m){const R=oe(d),O=t._activeEditRows===f;R&&!O?(ne(d),B(t,d,p,f),d.__epoch=n,d.__rowDataRef=p):(ie(t,d,p,f),d.__rowDataRef=p)}else{const R=oe(d),O=t._activeEditRows===f;R&&!O?(ne(d),B(t,d,p,f),d.__epoch=n,d.__rowDataRef=p):ie(t,d,p,f)}let S=!1;const y=t.changedRowIds;if(y&&y.length>0)try{const R=t.getRowId?.(p);R&&(S=y.includes(R))}catch{}const E=d.classList.contains("changed");S!==E&&d.classList.toggle("changed",S);const I=t.effectiveConfig?.rowClass;if(I){const R=d.getAttribute("data-dynamic-classes");R&&R.split(" ").forEach(O=>O&&d.classList.remove(O));try{const O=I(p);if(O&&O.length>0){const de=O.filter(ee=>ee&&typeof ee=="string");de.forEach(ee=>d.classList.add(ee)),d.setAttribute("data-dynamic-classes",de.join(" "))}else d.removeAttribute("data-dynamic-classes")}catch(O){console.warn("[tbw-grid] rowClass callback error:",O),d.removeAttribute("data-dynamic-classes")}}u&&t._afterRowRender?.({row:p,rowIndex:f,rowElement:d}),d.parentNode!==s&&s.appendChild(d)}}function ie(t,e,o,n){const i=e.children,r=t._visibleColumns,s=r.length,l=i.length,c=s<l?s:l,a=t._focusRow,h=t._focusCol,u=t._hasAfterCellRenderHook?.()??!1;let g=t.__hasSpecialColumns;if(g===void 0){g=!1;const p=t.effectiveConfig?.typeDefaults,d=t.__frameworkAdapter;for(let w=0;w<s;w++){const b=r[w];if(b.__viewTemplate||b.__compiledView||b.renderer||b.viewRenderer||b.externalView||b.format||b.type==="date"||b.type==="boolean"||b.type&&p?.[b.type]?.renderer||b.type&&d?.getTypeDefault?.(b.type)?.renderer){g=!0;break}}t.__hasSpecialColumns=g}const f=String(n);if(!g){for(let p=0;p<c;p++){const d=i[p];if(d.classList.contains("editing"))continue;const w=r[p],b=o[w.field];d.textContent=b==null?"":String(b),d.getAttribute("data-row")!==f&&d.setAttribute("data-row",f);const T=a===n&&h===p,v=d.classList.contains("cell-focus");T!==v&&(d.classList.toggle("cell-focus",T),d.setAttribute("aria-selected",String(T))),u&&t._afterCellRender?.({row:o,rowIndex:n,column:w,colIndex:p,value:b,cellElement:d,rowElement:e})}return}for(let p=0;p<c;p++)if(r[p].externalView&&!i[p].querySelector("[data-external-view]")){B(t,e,o,n);return}for(let p=0;p<c;p++){const d=r[p],w=i[p];w.getAttribute("data-row")!==f&&w.setAttribute("data-row",f);const b=a===n&&h===p,T=w.classList.contains("cell-focus");b!==T&&(w.classList.toggle("cell-focus",b),w.setAttribute("aria-selected",String(b)));const v=d.cellClass;if(v){const S=w.getAttribute("data-dynamic-classes");S&&S.split(" ").forEach(y=>y&&w.classList.remove(y));try{const y=o[d.field],E=v(y,o,d);if(E&&E.length>0){const I=E.filter(R=>R&&typeof R=="string");I.forEach(R=>w.classList.add(R)),w.setAttribute("data-dynamic-classes",I.join(" "))}else w.removeAttribute("data-dynamic-classes")}catch(y){console.warn(`[tbw-grid] cellClass callback error for column '${d.field}':`,y),w.removeAttribute("data-dynamic-classes")}}if(w.classList.contains("editing"))continue;const A=ye(t,d);if(A){const S=o[d.field],y=A({row:o,value:S,field:d.field,column:d,cellEl:w});typeof y=="string"?w.innerHTML=j(y):y instanceof Node?y.parentElement!==w&&(w.innerHTML="",w.appendChild(y)):y==null&&(w.textContent=S==null?"":String(S)),u&&t._afterCellRender?.({row:o,rowIndex:n,column:d,colIndex:p,value:S,cellElement:w,rowElement:e});continue}if(d.__viewTemplate||d.__compiledView||d.externalView)continue;const m=o[d.field];let _;if(d.format)try{const S=d.format(m,o);_=S==null?"":String(S)}catch(S){console.warn(`[tbw-grid] Format error in column '${d.field}':`,S),_=m==null?"":String(m)}else d.type==="date"?(_=Ce(m),w.textContent=_):d.type==="boolean"?w.innerHTML=me(!!m):(_=m==null?"":String(m),w.textContent=_);u&&t._afterCellRender?.({row:o,rowIndex:n,column:d,colIndex:p,value:m,cellElement:w,rowElement:e})}}function B(t,e,o,n){e.innerHTML="";const i=t._visibleColumns,r=i.length,s=t._focusRow,l=t._focusCol,c=t,a=t._hasAfterCellRenderHook?.()??!1,h=document.createDocumentFragment();for(let u=0;u<r;u++){const g=i[u],f=ut();f.setAttribute("aria-colindex",String(u+1)),f.setAttribute("data-col",String(u)),f.setAttribute("data-row",String(n)),f.setAttribute("data-field",g.field),f.setAttribute("data-header",g.header??g.field),g.type&&f.setAttribute("data-type",g.type);let p=o[g.field];if(g.format)try{p=g.format(p,o)}catch(m){console.warn(`[tbw-grid] Format error in column '${g.field}':`,m)}const d=g.__compiledView,w=g.__viewTemplate,b=ye(t,g),T=g.externalView;let v=!1;if(b){const m=b({row:o,value:p,field:g.field,column:g,cellEl:f});typeof m=="string"?(f.innerHTML=j(m),v=!0):m instanceof Node?m.parentElement!==f&&(f.textContent="",f.appendChild(m)):m==null&&(f.textContent=p==null?"":String(p))}else if(T){const m=T,_=document.createElement("div");_.setAttribute("data-external-view",""),_.setAttribute("data-field",g.field),f.appendChild(_);const S={row:o,value:p,field:g.field,column:g};if(m.mount)try{m.mount({placeholder:_,context:S,spec:m})}catch(y){console.warn(`[tbw-grid] External view mount error for column '${g.field}':`,y)}else queueMicrotask(()=>{try{c.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:_,spec:m,context:S}}))}catch(y){console.warn(`[tbw-grid] External view event dispatch error for column '${g.field}':`,y)}});_.setAttribute("data-mounted","")}else if(d){const m=d({row:o,value:p,field:g.field,column:g}),_=d.__blocked;f.innerHTML=_?"":j(m),v=!0,_&&(f.textContent="",f.setAttribute("data-blocked-template",""))}else if(w){const m=w.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(m)?(f.textContent="",f.setAttribute("data-blocked-template","")):(f.innerHTML=j(we(m,{row:o,value:p})),v=!0)}else g.type==="date"?f.textContent=Ce(p):g.type==="boolean"?f.innerHTML=me(!!p):f.textContent=p==null?"":String(p);if(v){at(f);const m=f.textContent||"";/Proxy|Reflect\.ownKeys/.test(m)&&(f.textContent=m.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=""),g.editable?f.tabIndex=0:g.type==="boolean"&&(f.hasAttribute("tabindex")||(f.tabIndex=0)),s===n&&l===u?(f.classList.add("cell-focus"),f.setAttribute("aria-selected","true")):f.setAttribute("aria-selected","false");const A=g.cellClass;if(A)try{const m=o[g.field],_=A(m,o,g);if(_&&_.length>0){const S=_.filter(y=>y&&typeof y=="string");S.forEach(y=>f.classList.add(y)),f.setAttribute("data-dynamic-classes",S.join(" "))}}catch(m){console.warn(`[tbw-grid] cellClass callback error for column '${g.field}':`,m)}a&&t._afterCellRender?.({row:o,rowIndex:n,column:g,colIndex:u,value:p,cellElement:f,rowElement:e}),h.appendChild(f)}e.appendChild(h)}function Re(t,e,o){if(e.target?.closest(".resize-handle"))return;const n=o.querySelector(".cell[data-row]"),i=ve(n);if(i<0)return;const r=t._rows[i];if(!r||t._dispatchRowClick?.(e,i,r,o))return;const s=e.target?.closest(".cell[data-col]");if(s){const l=Number(s.getAttribute("data-col"));if(!isNaN(l)){if(t._dispatchCellClick?.(e,i,l,s))return;const c=t._focusRow!==i||t._focusCol!==l;if(t._focusRow=i,t._focusCol=l,s.classList.contains("editing")){c&&(te(t._bodyEl??t),s.classList.add("cell-focus"));const a=s.querySelector(_e);try{a?.focus({preventScroll:!0})}catch{}return}$(t)}}}function pt(t,e){if(t._dispatchKeyDown?.(e))return;const o=t._rows.length-1,n=t._visibleColumns.length-1,i=t._activeEditRows!==void 0&&t._activeEditRows!==-1,s=t._visibleColumns[t._focusCol]?.type,l=e.composedPath?.()??[],c=l.length?l[0]:e.target,a=h=>{if(!h)return!1;const u=h.tagName;return!!(u==="INPUT"||u==="SELECT"||u==="TEXTAREA"||h.isContentEditable)};if(!(a(c)&&(e.key==="Home"||e.key==="End"))&&!(a(c)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&c.tagName==="INPUT"&&c.type==="number")&&!(a(c)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(a(c)&&(e.key==="Enter"||e.key==="Escape"))&&!(i&&s==="select"&&(e.key==="ArrowDown"||e.key==="ArrowUp"))){switch(e.key){case"Tab":{e.preventDefault(),!e.shiftKey?t._focusCol<n?t._focusCol+=1:(typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow<o&&(t._focusRow+=1,t._focusCol=0)):t._focusCol>0?t._focusCol-=1:t._focusRow>0&&(typeof t.commitActiveRowEdit=="function"&&t._activeEditRows===t._focusRow&&t.commitActiveRowEdit(),t._focusRow-=1,t._focusCol=n),$(t);return}case"ArrowDown":i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.min(o,t._focusRow+1),e.preventDefault();break;case"ArrowUp":i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.max(0,t._focusRow-1),e.preventDefault();break;case"ArrowRight":t._focusCol=Math.min(n,t._focusCol+1),e.preventDefault();break;case"ArrowLeft":t._focusCol=Math.max(0,t._focusCol-1),e.preventDefault();break;case"Home":(e.ctrlKey||e.metaKey)&&(i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=0),t._focusCol=0,e.preventDefault(),$(t,{forceScrollLeft:!0});return;case"End":(e.ctrlKey||e.metaKey)&&(i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=o),t._focusCol=n,e.preventDefault(),$(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":{const h=t._focusRow,u=t._focusCol,g=t._visibleColumns[u],f=t._rows[h],p=g?.field??"",d=p&&f?f[p]:void 0,w=t.querySelector(`[data-row="${h}"][data-col="${u}"]`),b={rowIndex:h,colIndex:u,field:p,value:d,row:f,cellEl:w,trigger:"keyboard",originalEvent:e},T=new CustomEvent("cell-activate",{cancelable:!0,detail:b});t.dispatchEvent(T);const v=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:h,col:u}});if(t.dispatchEvent(v),T.defaultPrevented||v.defaultPrevented){e.preventDefault();return}break}default:return}$(t)}}function $(t,e){if(t._virtualization?.enabled){const{rowHeight:s,container:l,viewportEl:c}=t._virtualization,a=l,h=c?.clientHeight??a?.clientHeight??0;if(a&&h>0){const u=t._focusRow*s;u<a.scrollTop?a.scrollTop=u:u+s>a.scrollTop+h&&(a.scrollTop=u-h+s)}}const o=t._activeEditRows!==void 0&&t._activeEditRows!==-1;o||t.refreshVirtualWindow(!1),te(t._bodyEl),Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(s=>{s.setAttribute("aria-selected","false")});const n=t._focusRow,i=t._virtualization.start??0,r=t._virtualization.end??t._rows.length;if(n>=i&&n<r){const s=t._bodyEl.querySelectorAll(".data-grid-row")[n-i];let l=s?.children[t._focusCol];if((!l||!l.classList?.contains("cell"))&&(l=s?.querySelector(`.cell[data-col="${t._focusCol}"]`)??s?.querySelector(".cell[data-col]")),l){l.classList.add("cell-focus"),l.setAttribute("aria-selected","true");const c=t.querySelector(".tbw-scroll-area");if(c&&l&&!o)if(e?.forceScrollLeft)c.scrollLeft=0;else if(e?.forceScrollRight)c.scrollLeft=c.scrollWidth-c.clientWidth;else{const a=t._getHorizontalScrollOffsets?.(s??void 0,l)??{left:0,right:0};if(!a.skipScroll){const h=l.getBoundingClientRect(),u=c.getBoundingClientRect(),g=h.left-u.left+c.scrollLeft,f=g+h.width,p=c.scrollLeft+a.left,d=c.scrollLeft+c.clientWidth-a.right;g<p?c.scrollLeft=g-a.left:f>d&&(c.scrollLeft=f-c.clientWidth+a.right)}}if(t._activeEditRows!==void 0&&t._activeEditRows!==-1&&l.classList.contains("editing")){const a=l.querySelector(_e);if(a&&document.activeElement!==a)try{a.focus({preventScroll:!0})}catch{}}else if(!l.contains(document.activeElement)){l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{}}}}}const Z=new WeakMap;function wt(t,e){const o=ve(e),n=ht(e);o<0||n<0||(t._focusRow=o,t._focusCol=n,te(t._bodyEl),e.classList.add("cell-focus"),e.setAttribute("aria-selected","true"))}function re(t,e,o,n){let i=null;const r=o.composedPath?.();if(r&&r.length>0?i=r[0]:i=o.target,i&&!e.contains(i)){const d=document.elementFromPoint(o.clientX,o.clientY);d&&(i=d)}const s=i?.closest?.("[data-col]"),l=i?.closest?.(".data-grid-row"),c=i?.closest?.(".header-row");let a,h,u,g,f,p;return s&&(a=parseInt(s.getAttribute("data-row")??"-1",10),h=parseInt(s.getAttribute("data-col")??"-1",10),a>=0&&h>=0&&(u=t._rows[a],p=t._columns[h],g=p?.field,f=u&&g?u[g]:void 0)),{type:n,row:u,rowIndex:a!==void 0&&a>=0?a:void 0,colIndex:h!==void 0&&h>=0?h:void 0,field:g,value:f,column:p,originalEvent:o,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!c,cell:a!==void 0&&h!==void 0&&a>=0&&h>=0?{row:a,col:h}:void 0}}function bt(t,e,o){const n=re(t,e,o,"mousedown");(t._dispatchCellMouseDown?.(n)??!1)&&Z.set(t,!0)}function mt(t,e,o){if(!Z.get(t))return;const n=re(t,e,o,"mousemove");t._dispatchCellMouseMove?.(n)}function Ct(t,e,o){if(!Z.get(t))return;const n=re(t,e,o,"mouseup");t._dispatchCellMouseUp?.(n),Z.set(t,!1)}function vt(t,e,o){e.addEventListener("mousedown",n=>{const i=n.target.closest(".cell[data-col]");i&&(i.classList.contains("editing")||wt(t,i))},{signal:o}),e.addEventListener("click",n=>{const i=n.target.closest(".data-grid-row");i&&Re(t,n,i)},{signal:o}),e.addEventListener("dblclick",n=>{const i=n.target.closest(".data-grid-row");i&&Re(t,n,i)},{signal:o})}function yt(t,e,o,n){e.addEventListener("keydown",i=>pt(t,i),{signal:n}),o.addEventListener("mousedown",i=>bt(t,o,i),{signal:n}),document.addEventListener("mousemove",i=>mt(t,o,i),{signal:n}),document.addEventListener("mouseup",i=>Ct(t,o,i),{signal:n})}function Te(t,e){return t==null&&e==null?0:t==null?-1:e==null||t>e?1:t<e?-1:0}function Ae(t,e,o){const i=o.find(l=>l.field===e.field)?.sortComparator??Te,{field:r,direction:s}=e;return[...t].sort((l,c)=>i(l[r],c[r],l,c)*s)}function xe(t,e,o,n){t._rows=e,t.__rowRenderEpoch++,t._rowPool.forEach(i=>i.__epoch=-1),Q(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:n}})),t.requestStateChange?.()}function Pe(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),Le(t,e,1)):t._sortState.direction===1?Le(t,e,-1):(t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(n=>n.__epoch=-1),t._rows=t.__originalOrder.slice(),Q(t),t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach(n=>{n.getAttribute("aria-sort")?(n.getAttribute("aria-sort")==="ascending"||n.getAttribute("aria-sort")==="descending")&&(t._sortState||n.setAttribute("aria-sort","none")):n.setAttribute("aria-sort","none")}),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e.field,direction:0}})),t.requestStateChange?.())}function Le(t,e,o){t._sortState={field:e.field,direction:o};const n={field:e.field,direction:o},i=t._columns,s=(t.effectiveConfig?.sortHandler??Ae)(t._rows,n,i);s&&typeof s.then=="function"?s.then(l=>{xe(t,l,e,o)}):xe(t,s,e,o)}function _t(t,e){typeof e=="string"?t.textContent=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}function Q(t){t._headerRowEl=t.findHeaderRow();const e=t._headerRowEl;e&&(e.innerHTML="",t._visibleColumns.forEach((o,n)=>{const i=document.createElement("div");i.className="cell",fe(i,"header-cell"),i.setAttribute("role","columnheader"),i.setAttribute("aria-colindex",String(n+1)),i.setAttribute("data-field",o.field),i.setAttribute("data-col",String(n));const r=o.__headerTemplate;if(r)Array.from(r.childNodes).forEach(s=>i.appendChild(s.cloneNode(!0)));else{const s=o.header??o.field,l=document.createElement("span");l.textContent=s,i.appendChild(l)}if(o.sortable){i.classList.add("sortable"),i.tabIndex=0;const s=document.createElement("span");fe(s,"sort-indicator");const l=t._sortState?.field===o.field?t._sortState.direction:0,c={...z,...t.icons},a=l===1?c.sortAsc:l===-1?c.sortDesc:c.sortNone;_t(s,a),i.appendChild(s),i.setAttribute("aria-sort",l===0?"none":l===1?"ascending":"descending"),i.addEventListener("click",h=>{t._resizeController?.isResizing||t._dispatchHeaderClick?.(h,n,i)||Pe(t,o)}),i.addEventListener("keydown",h=>{if(h.key==="Enter"||h.key===" "){if(h.preventDefault(),t._dispatchHeaderClick?.(h,n,i))return;Pe(t,o)}})}if(o.resizable){i.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,n,i)}),s.addEventListener("dblclick",l=>{l.stopPropagation(),l.preventDefault(),t._resizeController.resetColumn(n)}),i.appendChild(s)}e.appendChild(i)}),e.querySelectorAll(".cell.sortable").forEach(o=>{o.getAttribute("aria-sort")||o.setAttribute("aria-sort","none")}),e.children.length>0?(e.setAttribute("role","row"),e.setAttribute("aria-rowindex","1")):(e.removeAttribute("role"),e.removeAttribute("aria-rowindex")))}const He=typeof requestIdleCallback=="function";function Et(t,e){return He?requestIdleCallback(t,e):window.setTimeout(()=>{const o=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-o))})},1)}function Oe(t){He?cancelIdleCallback(t):clearTimeout(t)}var x=(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))(x||{});class St{#n;#c=0;#f=0;#d=null;#s=null;#i=null;#h=!1;constructor(e){this.#n=e}requestPhase(e,o){e>this.#c&&(this.#c=e),this.#f===0&&(this.#u(),this.#f=requestAnimationFrame(()=>this.#b()))}whenReady(){return this.#d?this.#d:Promise.resolve()}setInitialReadyResolver(e){this.#i=e}cancel(){this.#f!==0&&(cancelAnimationFrame(this.#f),this.#f=0),this.#c=0,this.#s&&(this.#s(),this.#s=null,this.#d=null)}get isPending(){return this.#c!==0}get pendingPhase(){return this.#c}#u(){this.#d||(this.#d=new Promise(e=>{this.#s=e}))}#b(){if(this.#f=0,!this.#n.isConnected()){this.#c=0,this.#s&&(this.#s(),this.#s=null,this.#d=null);return}const e=this.#c;this.#c=0,e>=5&&this.#n.mergeConfig(),e>=4&&this.#n.processRows(),e>=5&&(this.#n.processColumns(),this.#n.updateTemplate()),e>=3&&this.#n.renderHeader(),e>=2&&this.#n.renderVirtualWindow(),e>=1&&this.#n.afterRender(),!this.#h&&this.#i&&(this.#h=!0,this.#i()),this.#s&&(this.#s(),this.#s=null,this.#d=null)}}function De(t){let e=null,o=null,n=null,i=null;const r=c=>{if(!e)return;const a=c.clientX-e.startX,h=Math.max(40,e.startWidth+a),u=t._visibleColumns[e.colIndex];u.width=h,u.__userResized=!0,u.__renderedWidth=h,o==null&&(o=requestAnimationFrame(()=>{o=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:u.field,width:h}}))};let s=!1;const l=()=>{const c=e!==null;c&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),n!==null&&(document.documentElement.style.cursor=n,n=null),i!==null&&(document.body.style.userSelect=i,i=null),e=null,c&&t.requestStateChange&&t.requestStateChange()};return{get isResizing(){return e!==null||s},start(c,a,h){c.preventDefault();const u=t._visibleColumns[a],g=typeof u?.width=="number"?u.width:void 0,f=u?.__renderedWidth??g??h.getBoundingClientRect().width;e={startX:c.clientX,colIndex:a,startWidth:f},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),n===null&&(n=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",i===null&&(i=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(c){const a=t._visibleColumns[c];a&&(a.__userResized=!1,a.__renderedWidth=void 0,a.width=a.__originalWidth,t.updateTemplate?.(),t.requestStateChange?.(),t.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:a.field,width:a.width}})))},dispose(){l()}}}function J(t,e,o){const n=document.createElement(t);if(e)for(const i in e){const r=e[i];r!=null&&n.setAttribute(i,r)}return n}function H(t,e){const o=document.createElement("div");if(t&&(o.className=t),e)for(const n in e){const i=e[n];i!=null&&o.setAttribute(n,i)}return o}function Me(t,e,o){const n=document.createElement("button");if(t&&(n.className=t),e)for(const i in e){const r=e[i];r!=null&&n.setAttribute(i,r)}return n}const ze=document.createElement("template");ze.innerHTML=`
|
|
1
|
+
(function(v,q){typeof exports=="object"&&typeof module<"u"?q(exports):typeof define=="function"&&define.amd?define(["exports"],q):(v=typeof globalThis<"u"?globalThis:v||self,q(v.TbwGrid={}))})(this,(function(v){"use strict";const q='@layer tbw-base,tbw-plugins,tbw-theme;@layer tbw-base{tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--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-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--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, #666666);--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-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--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: var(--tbw-spacing-sm);--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--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-row-change-duration: .5s;--tbw-row-insert-duration: .3s;--tbw-row-remove-duration: .2s;--tbw-row-change-color: rgba(from var(--tbw-color-accent) r g b / 25%);--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-sort-indicator-visibility: visible;--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm);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}tbw-grid,tbw-grid *{box-sizing:border-box}tbw-grid .header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}tbw-grid .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)}tbw-grid .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))}tbw-grid .header-group-cell:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .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)}tbw-grid .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:visible;min-width:0}tbw-grid .header-row>.cell>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:inherit}tbw-grid .header-row>.cell>span[part~=sort-indicator]{flex-shrink:0;opacity:.6;visibility:var(--tbw-sort-indicator-visibility, visible)}tbw-grid .header-row>.cell:last-child{border-right:0}tbw-grid .header-row>.cell.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row>.cell.resizable{position:relative}tbw-grid .header-row>.cell.sticky-left,tbw-grid .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}tbw-grid .tbw-grid-root{display:flex;flex-direction:column;height:100%}tbw-grid .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}tbw-grid .rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}tbw-grid .rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}tbw-grid .rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}tbw-grid .rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip}tbw-grid .rows-viewport .rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}tbw-grid .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)}tbw-grid .faux-vscroll-spacer{width:1px}tbw-grid .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)}tbw-grid .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid .data-grid-row:hover{background:var(--tbw-color-row-hover)}tbw-grid .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}tbw-grid .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}tbw-grid .data-grid-row>.cell:last-child{border-right:0}tbw-grid .data-grid-row>.cell[data-type=boolean]{text-align:center}tbw-grid .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}tbw-grid .data-grid-row>.cell.selected:focus-visible,tbw-grid .data-grid-row>.cell:focus-visible:not(.cell-focus){outline:none}tbw-grid .data-grid-row>.cell.sticky-left,tbw-grid .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}tbw-grid .selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid .sortable{cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .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)}tbw-grid .resize-handle:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-indicator-width, 2px);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}tbw-grid .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}tbw-grid .resize-handle:hover:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}tbw-grid[data-has-focus] .cell-focus,tbw-grid[data-has-focus] .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .sticky-left,tbw-grid .sticky-right{position:sticky;z-index:25}tbw-grid .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}tbw-grid .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}tbw-grid .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}tbw-grid .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}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .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)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}tbw-grid .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}tbw-grid .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}tbw-grid .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)}tbw-grid .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)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .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)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .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}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .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}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .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}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .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}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}tbw-grid .tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}tbw-grid .tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}tbw-grid[data-animation-mode=off]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}tbw-grid[data-animation-mode=off] .data-grid-row[data-animating]{animation:none}@media(forced-colors:active){tbw-grid{--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}tbw-grid .cell:focus,tbw-grid .cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}tbw-grid .data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}@media(prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}tbw-grid[data-animation-mode=reduced-motion] .data-grid-row[data-animating]{animation:none}}@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)}}@keyframes tbw-row-change{0%{background-color:transparent}20%{background-color:var(--tbw-row-change-color)}to{background-color:transparent}}@keyframes tbw-row-insert{0%{opacity:0;max-height:0;overflow:hidden}to{opacity:1;max-height:var(--tbw-row-height, 28px);overflow:hidden}}@keyframes tbw-row-remove{0%{opacity:1;transform:translateY(0);max-height:var(--tbw-row-height, 28px)}to{opacity:0;max-height:0;transform:translateY(-8px)}}tbw-grid .data-grid-row[data-animating=change]{animation:tbw-row-change var(--tbw-row-change-duration) ease-out}tbw-grid .data-grid-row[data-animating=insert]{animation:tbw-row-insert var(--tbw-row-insert-duration) ease-out;will-change:max-height,opacity}tbw-grid .data-grid-row[data-animating=remove]{animation:tbw-row-remove var(--tbw-row-remove-duration) ease-out forwards;will-change:max-height,opacity,transform;pointer-events:none}}',W={STRETCH:"stretch",FIXED:"fixed"},fe={mode:"reduced-motion",duration:200,easing:"ease-out"},ge='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',z={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:ge,filterActive:ge};function Qe(t){return Array.from(t.querySelectorAll("tbw-grid-column")).map(o=>{const n=o.getAttribute("field")||"";if(!n)return null;const i=o.getAttribute("type")||void 0,s=i&&new Set(["number","string","date","boolean","select"]).has(i)?i:void 0,l=o.getAttribute("header")||void 0,c=o.hasAttribute("sortable"),a=o.hasAttribute("editable"),h={field:n,type:s,header:l,sortable:c,editable:a},u=o.getAttribute("width");if(u){const E=parseFloat(u);!isNaN(E)&&/^\d+(\.\d+)?$/.test(u.trim())?h.width=E:h.width=u}const g=o.getAttribute("minWidth")||o.getAttribute("min-width");if(g){const E=parseFloat(g);isNaN(E)||(h.minWidth=E)}o.hasAttribute("resizable")&&(h.resizable=!0),o.hasAttribute("sizable")&&(h.resizable=!0);const f=o.getAttribute("editor"),p=o.getAttribute("renderer");f&&(h.__editorName=f),p&&(h.__rendererName=p);const d=o.getAttribute("options");d&&(h.options=d.split(",").map(E=>{const[I,R]=E.includes(":")?E.split(":"):[E.trim(),E.trim()];return{value:I.trim(),label:R?.trim()||I.trim()}}));const w=o.querySelector("tbw-grid-column-view"),b=o.querySelector("tbw-grid-column-editor"),T=o.querySelector("tbw-grid-column-header");w&&(h.__viewTemplate=w),b&&(h.__editorTemplate=b),T&&(h.__headerTemplate=T);const A=globalThis.DataGridElement?.getAdapters?.()??[],m=w??o,_=A.find(E=>E.canHandle(m));if(_){const E=_.createRenderer(m);E&&(h.viewRenderer=E)}const S=b??o,y=A.find(E=>E.canHandle(S));if(y){const E=y.createEditor(S);E&&(h.editor=E)}return h}).filter(o=>!!o)}function pe(t,e){if((!t||!t.length)&&(!e||!e.length))return[];if(!t||!t.length)return e||[];if(!e||!e.length)return t;const o={};e.forEach(i=>{const r=o[i.field];if(r){i.header&&!r.header&&(r.header=i.header),i.type&&!r.type&&(r.type=i.type),i.sortable&&(r.sortable=!0),i.editable&&(r.editable=!0),i.resizable&&(r.resizable=!0),i.width!=null&&r.width==null&&(r.width=i.width),i.minWidth!=null&&r.minWidth==null&&(r.minWidth=i.minWidth),i.__viewTemplate&&(r.__viewTemplate=i.__viewTemplate),i.__editorTemplate&&(r.__editorTemplate=i.__editorTemplate),i.__headerTemplate&&(r.__headerTemplate=i.__headerTemplate);const s=i.renderer||i.viewRenderer,l=r.renderer||r.viewRenderer;s&&!l&&(r.viewRenderer=s,i.renderer&&(r.renderer=s)),i.editor&&!r.editor&&(r.editor=i.editor)}else o[i.field]={...i}});const n=t.map(i=>{const r=o[i.field];if(!r)return i;const s={...i};r.header&&!s.header&&(s.header=r.header),r.type&&!s.type&&(s.type=r.type),s.sortable=i.sortable||r.sortable,(i.resizable===!0||r.resizable===!0)&&(s.resizable=!0),s.editable=i.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,c=s.renderer||s.viewRenderer;return l&&!c&&(s.viewRenderer=l,r.renderer&&(s.renderer=l)),r.editor&&!s.editor&&(s.editor=r.editor),delete o[i.field],s});return Object.keys(o).forEach(i=>n.push(o[i])),n}function we(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 be(t){const e=t.effectiveConfig?.fitMode||t.fitMode||W.STRETCH;if(e!==W.STRETCH&&e!==W.FIXED||t.__didInitialAutoSize||!t.isConnected)return;const o=Array.from(t._headerRowEl?.children||[]);if(!o.length)return;let n=!1;t._visibleColumns.forEach((i,r)=>{if(i.width)return;const s=o[r];let l=s?s.scrollWidth:0;for(const c of t._rowPool){const a=c.children[r];if(a){const h=a.scrollWidth;h>l&&(l=h)}}l>0&&(i.width=l+2,i.__autoSized=!0,n=!0)}),n&&G(t),t.__didInitialAutoSize=!0}function G(t){(t.effectiveConfig?.fitMode||t.fitMode||W.STRETCH)===W.STRETCH?t._gridTemplate=t._visibleColumns.map(o=>{if(o.width)return`${o.width}px`;const n=o.minWidth;return n!=null?`minmax(${n}px, 1fr)`:"1fr"}).join(" ").trim():t._gridTemplate=t._visibleColumns.map(o=>o.width?`${o.width}px`:"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}function Je(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 et(t,e){const o=t[0]||{},n=Object.keys(o).map(r=>{const s=o[r],l=Je(s);return{field:r,header:r.charAt(0).toUpperCase()+r.slice(1),type:l}}),i={};return n.forEach(r=>{i[r.field]=r.type||"string"}),{columns:n,typeMap:i}}const tt=/{{\s*([^}]+)\s*}}/g,D="__DG_EMPTY__",ot=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,nt=/__(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 it(t){return!t||typeof t!="string"?"":t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const rt=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"]),me=/^on\w+$/i,st=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),lt=/^\s*(javascript|vbscript|data|blob):/i;function j(t){if(!t||typeof t!="string")return"";if(t.indexOf("<")===-1)return t;const e=document.createElement("template");return e.innerHTML=t,at(e.content),e.innerHTML}function at(t){const e=[],o=t.querySelectorAll("*");for(const n of o){const i=n.tagName.toLowerCase();if(rt.has(i)){e.push(n);continue}if((i==="svg"||n.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(n.attributes).some(l=>me.test(l.name)||l.name==="href"||l.name==="xlink:href")){e.push(n);continue}const r=[];for(const s of n.attributes){const l=s.name.toLowerCase();if(me.test(l)){r.push(s.name);continue}if(st.has(l)&<.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=>n.removeAttribute(s))}e.forEach(n=>n.remove())}function ve(t,e){if(!t||t.indexOf("{{")===-1)return t;const o=[],n=t.replace(tt,(l,c)=>{const a=ct(c,e);return o.push({expr:c.trim(),result:a}),a}),i=dt(n),r=o.length&&o.every(l=>l.result===""||l.result===D);return/Reflect\.|\bProxy\b|ownKeys\(/.test(t)||r?"":i}function ct(t,e){if(t=(t||"").trim(),!t||/\b(Reflect|Proxy|ownKeys)\b/.test(t))return D;if(t==="value")return e.value==null?D:String(e.value);if(t.startsWith("row.")&&!/[()?]/.test(t)&&!t.includes(":")){const n=t.slice(4),i=e.row?e.row[n]:void 0;return i==null?D:String(i)}if(t.length>80||!ot.test(t)||nt.test(t))return D;const o=t.match(/\./g);if(o&&o.length>1)return D;try{const i=new Function("value","row",`return (${t});`)(e.value,e.row),r=i==null?"":String(i);return/Reflect|Proxy|ownKeys/.test(r)?D:r||D}catch{return D}}function dt(t){return t&&t.replace(new RegExp(D,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function ht(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=(n=>e?"":ve(t,n));return o.__blocked=e,o}const ut=100;class ft{#n;#c;#f;#d;#s;#i={};#h={};#u=!0;#b=[];#l;#p;#w;#r;#m;constructor(e){this.#r=e}get original(){return this.#i}get effective(){return this.#h}get columns(){return this.#h.columns??[]}set columns(e){this.#h.columns=e}get lightDomColumnsCache(){return this.#d}set lightDomColumnsCache(e){this.#d=e}get originalColumnNodes(){return this.#s}set originalColumnNodes(e){this.#s=e}get lightDomTitle(){return this.#m}set lightDomTitle(e){this.#m=e}get initialColumnState(){return this.#w}set initialColumnState(e){this.#w=e}get sourcesChanged(){return this.#u}markSourcesChanged(){this.#u=!0}setGridConfig(e){this.#n=e,this.#u=!0,this.#d=void 0}getGridConfig(){return this.#n}setColumns(e){this.#c=e,this.#u=!0}getColumns(){return this.#c}setFitMode(e){this.#f=e,this.#u=!0}getFitMode(){return this.#f}merge(){const e=(this.#h.columns?.length??0)>0;if(!this.#u&&e)return;const o=this.#C();this.#u=!1,this.#i=o,Object.freeze(this.#i),this.#i.columns&&Object.freeze(this.#i.columns),this.#h=this.#x(this.#i),this.#g()}#x(e){const o={...e};return e.columns&&(o.columns=e.columns.map(n=>({...n}))),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(n=>({...n})),headerContents:e.shell.headerContents?.map(n=>({...n}))}),o}#g(){const e=this.#h;e.rowHeight&&e.rowHeight>0&&this.#r.setRowHeight(e.rowHeight),e.fitMode==="fixed"&&this.columns.forEach(n=>{n.width==null&&(n.width=80)}),this.#r.applyAnimationConfig(e)}#C(){const e=this.#n?{...this.#n}:{},o=Array.isArray(e.columns)?[...e.columns]:[],n=(this.#d??[]).map(s=>({...s}));let i=pe(o,n);this.#c&&this.#c.length&&(i=pe(this.#c,n));const r=this.#r.getRows();return i.length===0&&r.length&&(i=et(r).columns),i.length&&(i.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)}),i.forEach(s=>{s.__viewTemplate&&!s.__compiledView&&(s.__compiledView=Ce(s.__viewTemplate.innerHTML)),s.__editorTemplate&&!s.__compiledEditor&&(s.__compiledEditor=Ce(s.__editorTemplate.innerHTML))}),e.columns=i),this.#f&&(e.fitMode=this.#f),e.fitMode||(e.fitMode="stretch"),this.#y(e),e.columnState&&!this.#w&&(this.#w=e.columnState),e}#y(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const o=this.#r.getShellLightDomTitle();o&&(this.#m=o),this.#m&&!e.shell.header.title&&(e.shell.header.title=this.#m);const n=this.#r.getShellLightDomHeaderContent();n?.length>0&&(e.shell.header.lightDomContent=n),this.#r.getShellHasToolButtonsContainer()&&(e.shell.header.hasToolButtonsContainer=!0);const i=this.#r.getShellToolPanels();if(i.size>0){const u=Array.from(i.values());u.sort((g,f)=>(g.order??100)-(f.order??100)),e.shell.toolPanels=u}const r=this.#r.getShellHeaderContents();if(r.size>0){const u=Array.from(r.values());u.sort((g,f)=>(g.order??100)-(f.order??100)),e.shell.headerContents=u}const s=this.#r.getShellToolbarContents(),l=Array.from(s.values()),c=this.#n?.shell?.header?.toolbarContents??[],a=new Set(c.map(u=>u.id)),h=[...c];for(const u of l)a.has(u.id)||h.push(u);h.sort((u,g)=>(u.order??0)-(g.order??0)),e.shell.header.toolbarContents=h}collectState(e){const o=this.columns,n=this.#v();return{columns:o.map((i,r)=>{const s={field:i.field,order:r,visible:!i.hidden},l=i;l.__renderedWidth!==void 0?s.width=l.__renderedWidth:i.width!==void 0&&(s.width=typeof i.width=="string"?parseFloat(i.width):i.width);const c=n.get(i.field);c&&(s.sort=c);for(const a of e)if(a.getColumnState){const h=a.getColumnState(i.field);h&&Object.assign(s,h)}return s})}}applyState(e,o){if(!e.columns||e.columns.length===0)return;const n=this.columns,i=new Map(e.columns.map(l=>[l.field,l])),r=n.map(l=>{const c=i.get(l.field);if(!c)return l;const a={...l};return c.width!==void 0&&(a.width=c.width,a.__renderedWidth=c.width),c.visible!==void 0&&(a.hidden=!c.visible),a});r.sort((l,c)=>{const a=i.get(l.field)?.order??1/0,h=i.get(c.field)?.order??1/0;return a-h}),this.columns=r;const s=e.columns.filter(l=>l.sort!==void 0).sort((l,c)=>(l.sort?.priority??0)-(c.sort?.priority??0));if(s.length>0){const l=s[0];l.sort&&this.#r.setSortState({field:l.field,direction:l.sort.direction==="asc"?1:-1})}else this.#r.setSortState(null);for(const l of o)if(l.applyColumnState)for(const c of e.columns)l.applyColumnState(c.field,c)}resetState(e){this.#w=void 0,this.#r.setSortState(null),this.#h=this.#x(this.#i),this.#g();for(const o of e)if(o.applyColumnState)for(const n of this.columns)o.applyColumnState(n.field,{field:n.field,order:0,visible:!0});this.requestStateChange(e)}#v(){const e=new Map,o=this.#r.getSortState();return o&&e.set(o.field,{direction:o.direction===1?"asc":"desc",priority:0}),e}requestStateChange(e){this.#p&&clearTimeout(this.#p),this.#p=setTimeout(()=>{this.#p=void 0;const o=this.collectState(e);this.#r.emit("column-state-change",o)},ut)}setColumnVisible(e,o){const n=this.columns,i=n.find(s=>s.field===e);return!i||!o&&i.lockVisible||!o&&n.filter(l=>!l.hidden&&l.field!==e).length===0||!!i.hidden===!o?!1:(i.hidden=!o,this.#r.emit("column-visibility",{field:e,visible:o,visibleColumns:n.filter(s=>!s.hidden).map(s=>s.field)}),this.#r.clearRowPool(),this.#r.setup(),!0)}toggleColumnVisibility(e){const o=this.columns.find(n=>n.field===e);return o?this.setColumnVisible(e,!!o.hidden):!1}isColumnVisible(e){const o=this.columns.find(n=>n.field===e);return o?!o.hidden:!1}showAllColumns(){const e=this.columns;e.some(o=>o.hidden)&&(e.forEach(o=>o.hidden=!1),this.#r.emit("column-visibility",{visibleColumns:e.map(o=>o.field)}),this.#r.clearRowPool(),this.#r.setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:e.meta?.utility===!0}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const o=new Map(this.columns.map(i=>[i.field,i])),n=[];for(const i of e){const r=o.get(i);r&&(n.push(r),o.delete(i))}for(const i of o.values())n.push(i);this.columns=n,this.#r.renderHeader(),this.#r.updateTemplate(),this.#r.refreshVirtualWindow()}parseLightDomColumns(e){this.#d||(this.#s=Array.from(e.querySelectorAll("tbw-grid-column")),this.#d=this.#s.length?Qe(e):[])}clearLightDomCache(){this.#d=void 0}#E=new Map;registerLightDomHandler(e,o){this.#E.set(e.toLowerCase(),o)}unregisterLightDomHandler(e){this.#E.delete(e.toLowerCase())}observeLightDOM(e){this.#l&&this.#l.disconnect();const o=new Set;let n=null;const i=()=>{n=null;for(const r of o)this.#E.get(r)?.();o.clear()};this.#l=new MutationObserver(r=>{for(const s of r){for(const l of s.addedNodes){if(l.nodeType!==Node.ELEMENT_NODE)continue;const a=l.tagName.toLowerCase();this.#E.has(a)&&o.add(a)}if(s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE){const c=s.target.tagName.toLowerCase();this.#E.has(c)&&o.add(c)}}o.size>0&&!n&&(n=setTimeout(i,0))}),this.#l.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#b.push(e)}notifyChange(){for(const e of this.#b)e()}dispose(){this.#l?.disconnect(),this.#b=[],this.#p&&clearTimeout(this.#p)}}function ye(t){return`<span role="checkbox" aria-checked="${t}" aria-label="${t}">${t?"🗹":"☐"}</span>`}function _e(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 Ee(t){if(!t)return-1;const e=t.getAttribute("data-row");if(e)return parseInt(e,10);const o=t.closest(".data-grid-row");if(!o)return-1;const n=o.parentElement;if(!n)return-1;const i=n.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<i.length;r++)if(i[r]===o)return r;return-1}function gt(t){if(!t)return-1;const e=t.getAttribute("data-col");return e?parseInt(e,10):-1}function te(t){t&&t.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function Se(t,e){const o=e.renderer||e.viewRenderer;if(o)return o;if(!e.type)return;const n=t.effectiveConfig?.typeDefaults;if(n?.[e.type]?.renderer)return n[e.type].renderer;const i=t.__frameworkAdapter;if(i?.getTypeDefault){const r=i.getTypeDefault(e.type);if(r?.renderer)return r.renderer}}const Re='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function oe(t){return(t.__editingCellCount??0)>0}function ne(t){t.__editingCellCount=0,t.removeAttribute("data-has-editing"),t.querySelectorAll(".cell.editing").forEach(o=>o.classList.remove("editing"))}const Te=document.createElement("template");Te.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const Ae=document.createElement("template");Ae.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function pt(){return Te.content.firstElementChild.cloneNode(!0)}function wt(){return Ae.content.firstElementChild.cloneNode(!0)}function K(t){t.__cellDisplayCache=void 0,t.__cellCacheEpoch=void 0,t.__hasSpecialColumns=void 0}function bt(t,e,o,n,i){const r=Math.max(0,o-e),s=t._bodyEl,l=t._visibleColumns,c=l.length;let a=t.__cachedHeaderRowCount;for(a===void 0&&(a=t.querySelector(".header-group-row")?2:1,t.__cachedHeaderRowCount=a);t._rowPool.length<r;){const g=wt();t._rowPool.push(g)}if(t._rowPool.length>r){for(let g=r;g<t._rowPool.length;g++){const f=t._rowPool[g];f.parentNode===s&&f.remove()}t._rowPool.length=r}const h=i&&t.__hasRenderRowPlugins!==!1,u=t._hasAfterRowRenderHook?.()??!1;for(let g=0;g<r;g++){const f=e+g,p=t._rows[f],d=t._rowPool[g];if(d.setAttribute("aria-rowindex",String(f+a+1)),h&&i(p,d,f)){d.__epoch=n,d.__rowDataRef=p,d.parentNode!==s&&s.appendChild(d);continue}const w=d.__epoch,b=d.__rowDataRef,T=d.children.length,A=w===n&&T===c,m=b!==p;let _=!1;if(A&&m){for(let R=0;R<c;R++)if(l[R].externalView&&!d.querySelector(`.cell[data-col="${R}"] [data-external-view]`)){_=!0;break}}if(!A||_){const R=oe(d),O=t._activeEditRows===f;R&&!O?(d.__isCustomRow&&(d.className="data-grid-row",d.setAttribute("role","row"),d.__isCustomRow=!1),ne(d),B(t,d,p,f),d.__epoch=n,d.__rowDataRef=p):R&&O?(ie(t,d,p,f),d.__rowDataRef=p):(d.__isCustomRow&&(d.className="data-grid-row",d.setAttribute("role","row"),d.__isCustomRow=!1),B(t,d,p,f),d.__epoch=n,d.__rowDataRef=p)}else if(m){const R=oe(d),O=t._activeEditRows===f;R&&!O?(ne(d),B(t,d,p,f),d.__epoch=n,d.__rowDataRef=p):(ie(t,d,p,f),d.__rowDataRef=p)}else{const R=oe(d),O=t._activeEditRows===f;R&&!O?(ne(d),B(t,d,p,f),d.__epoch=n,d.__rowDataRef=p):ie(t,d,p,f)}let S=!1;const y=t.changedRowIds;if(y&&y.length>0)try{const R=t.getRowId?.(p);R&&(S=y.includes(R))}catch{}const E=d.classList.contains("changed");S!==E&&d.classList.toggle("changed",S);const I=t.effectiveConfig?.rowClass;if(I){const R=d.getAttribute("data-dynamic-classes");R&&R.split(" ").forEach(O=>O&&d.classList.remove(O));try{const O=I(p);if(O&&O.length>0){const ue=O.filter(ee=>ee&&typeof ee=="string");ue.forEach(ee=>d.classList.add(ee)),d.setAttribute("data-dynamic-classes",ue.join(" "))}else d.removeAttribute("data-dynamic-classes")}catch(O){console.warn("[tbw-grid] rowClass callback error:",O),d.removeAttribute("data-dynamic-classes")}}u&&t._afterRowRender?.({row:p,rowIndex:f,rowElement:d}),d.parentNode!==s&&s.appendChild(d)}}function ie(t,e,o,n){const i=e.children,r=t._visibleColumns,s=r.length,l=i.length,c=s<l?s:l,a=t._focusRow,h=t._focusCol,u=t._hasAfterCellRenderHook?.()??!1;let g=t.__hasSpecialColumns;if(g===void 0){g=!1;const p=t.effectiveConfig?.typeDefaults,d=t.__frameworkAdapter;for(let w=0;w<s;w++){const b=r[w];if(b.__viewTemplate||b.__compiledView||b.renderer||b.viewRenderer||b.externalView||b.format||b.type==="date"||b.type==="boolean"||b.type&&p?.[b.type]?.renderer||b.type&&d?.getTypeDefault?.(b.type)?.renderer){g=!0;break}}t.__hasSpecialColumns=g}const f=String(n);if(!g){for(let p=0;p<c;p++){const d=i[p];if(d.classList.contains("editing"))continue;const w=r[p],b=o[w.field];d.textContent=b==null?"":String(b),d.getAttribute("data-row")!==f&&d.setAttribute("data-row",f);const T=a===n&&h===p,C=d.classList.contains("cell-focus");T!==C&&(d.classList.toggle("cell-focus",T),d.setAttribute("aria-selected",String(T))),u&&t._afterCellRender?.({row:o,rowIndex:n,column:w,colIndex:p,value:b,cellElement:d,rowElement:e})}return}for(let p=0;p<c;p++)if(r[p].externalView&&!i[p].querySelector("[data-external-view]")){B(t,e,o,n);return}for(let p=0;p<c;p++){const d=r[p],w=i[p];w.getAttribute("data-row")!==f&&w.setAttribute("data-row",f);const b=a===n&&h===p,T=w.classList.contains("cell-focus");b!==T&&(w.classList.toggle("cell-focus",b),w.setAttribute("aria-selected",String(b)));const C=d.cellClass;if(C){const S=w.getAttribute("data-dynamic-classes");S&&S.split(" ").forEach(y=>y&&w.classList.remove(y));try{const y=o[d.field],E=C(y,o,d);if(E&&E.length>0){const I=E.filter(R=>R&&typeof R=="string");I.forEach(R=>w.classList.add(R)),w.setAttribute("data-dynamic-classes",I.join(" "))}else w.removeAttribute("data-dynamic-classes")}catch(y){console.warn(`[tbw-grid] cellClass callback error for column '${d.field}':`,y),w.removeAttribute("data-dynamic-classes")}}if(w.classList.contains("editing"))continue;const A=Se(t,d);if(A){const S=o[d.field],y=A({row:o,value:S,field:d.field,column:d,cellEl:w});typeof y=="string"?w.innerHTML=j(y):y instanceof Node?y.parentElement!==w&&(w.innerHTML="",w.appendChild(y)):y==null&&(w.textContent=S==null?"":String(S)),u&&t._afterCellRender?.({row:o,rowIndex:n,column:d,colIndex:p,value:S,cellElement:w,rowElement:e});continue}if(d.__viewTemplate||d.__compiledView||d.externalView)continue;const m=o[d.field];let _;if(d.format)try{const S=d.format(m,o);_=S==null?"":String(S)}catch(S){console.warn(`[tbw-grid] Format error in column '${d.field}':`,S),_=m==null?"":String(m)}else d.type==="date"?(_=_e(m),w.textContent=_):d.type==="boolean"?w.innerHTML=ye(!!m):(_=m==null?"":String(m),w.textContent=_);u&&t._afterCellRender?.({row:o,rowIndex:n,column:d,colIndex:p,value:m,cellElement:w,rowElement:e})}}function B(t,e,o,n){e.innerHTML="";const i=t._visibleColumns,r=i.length,s=t._focusRow,l=t._focusCol,c=t,a=t._hasAfterCellRenderHook?.()??!1,h=document.createDocumentFragment();for(let u=0;u<r;u++){const g=i[u],f=pt();f.setAttribute("aria-colindex",String(u+1)),f.setAttribute("data-col",String(u)),f.setAttribute("data-row",String(n)),f.setAttribute("data-field",g.field),f.setAttribute("data-header",g.header??g.field),g.type&&f.setAttribute("data-type",g.type);let p=o[g.field];if(g.format)try{p=g.format(p,o)}catch(m){console.warn(`[tbw-grid] Format error in column '${g.field}':`,m)}const d=g.__compiledView,w=g.__viewTemplate,b=Se(t,g),T=g.externalView;let C=!1;if(b){const m=b({row:o,value:p,field:g.field,column:g,cellEl:f});typeof m=="string"?(f.innerHTML=j(m),C=!0):m instanceof Node?m.parentElement!==f&&(f.textContent="",f.appendChild(m)):m==null&&(f.textContent=p==null?"":String(p))}else if(T){const m=T,_=document.createElement("div");_.setAttribute("data-external-view",""),_.setAttribute("data-field",g.field),f.appendChild(_);const S={row:o,value:p,field:g.field,column:g};if(m.mount)try{m.mount({placeholder:_,context:S,spec:m})}catch(y){console.warn(`[tbw-grid] External view mount error for column '${g.field}':`,y)}else queueMicrotask(()=>{try{c.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:_,spec:m,context:S}}))}catch(y){console.warn(`[tbw-grid] External view event dispatch error for column '${g.field}':`,y)}});_.setAttribute("data-mounted","")}else if(d){const m=d({row:o,value:p,field:g.field,column:g}),_=d.__blocked;f.innerHTML=_?"":j(m),C=!0,_&&(f.textContent="",f.setAttribute("data-blocked-template",""))}else if(w){const m=w.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(m)?(f.textContent="",f.setAttribute("data-blocked-template","")):(f.innerHTML=j(ve(m,{row:o,value:p})),C=!0)}else g.type==="date"?f.textContent=_e(p):g.type==="boolean"?f.innerHTML=ye(!!p):f.textContent=p==null?"":String(p);if(C){ht(f);const m=f.textContent||"";/Proxy|Reflect\.ownKeys/.test(m)&&(f.textContent=m.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=""),g.editable?f.tabIndex=0:g.type==="boolean"&&(f.hasAttribute("tabindex")||(f.tabIndex=0)),s===n&&l===u?(f.classList.add("cell-focus"),f.setAttribute("aria-selected","true")):f.setAttribute("aria-selected","false");const A=g.cellClass;if(A)try{const m=o[g.field],_=A(m,o,g);if(_&&_.length>0){const S=_.filter(y=>y&&typeof y=="string");S.forEach(y=>f.classList.add(y)),f.setAttribute("data-dynamic-classes",S.join(" "))}}catch(m){console.warn(`[tbw-grid] cellClass callback error for column '${g.field}':`,m)}a&&t._afterCellRender?.({row:o,rowIndex:n,column:g,colIndex:u,value:p,cellElement:f,rowElement:e}),h.appendChild(f)}e.appendChild(h)}function xe(t,e,o){if(e.target?.closest(".resize-handle"))return;const n=o.querySelector(".cell[data-row]"),i=Ee(n);if(i<0)return;const r=t._rows[i];if(!r||t._dispatchRowClick?.(e,i,r,o))return;const s=e.target?.closest(".cell[data-col]");if(s){const l=Number(s.getAttribute("data-col"));if(!isNaN(l)){if(t._dispatchCellClick?.(e,i,l,s))return;const c=t._focusRow!==i||t._focusCol!==l;if(t._focusRow=i,t._focusCol=l,s.classList.contains("editing")){c&&(te(t._bodyEl??t),s.classList.add("cell-focus"));const a=s.querySelector(Re);try{a?.focus({preventScroll:!0})}catch{}return}$(t)}}}function mt(t,e){if(t._dispatchKeyDown?.(e))return;const o=t._rows.length-1,n=t._visibleColumns.length-1,i=t._activeEditRows!==void 0&&t._activeEditRows!==-1,s=t._visibleColumns[t._focusCol]?.type,l=e.composedPath?.()??[],c=l.length?l[0]:e.target,a=h=>{if(!h)return!1;const u=h.tagName;return!!(u==="INPUT"||u==="SELECT"||u==="TEXTAREA"||h.isContentEditable)};if(!(a(c)&&(e.key==="Home"||e.key==="End"))&&!(a(c)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&c.tagName==="INPUT"&&c.type==="number")&&!(a(c)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(a(c)&&(e.key==="Enter"||e.key==="Escape"))&&!(i&&s==="select"&&(e.key==="ArrowDown"||e.key==="ArrowUp"))){switch(e.key){case"Tab":{e.preventDefault(),!e.shiftKey?t._focusCol<n?t._focusCol+=1:(typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow<o&&(t._focusRow+=1,t._focusCol=0)):t._focusCol>0?t._focusCol-=1:t._focusRow>0&&(typeof t.commitActiveRowEdit=="function"&&t._activeEditRows===t._focusRow&&t.commitActiveRowEdit(),t._focusRow-=1,t._focusCol=n),$(t);return}case"ArrowDown":i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.min(o,t._focusRow+1),e.preventDefault();break;case"ArrowUp":i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=Math.max(0,t._focusRow-1),e.preventDefault();break;case"ArrowRight":t._focusCol=Math.min(n,t._focusCol+1),e.preventDefault();break;case"ArrowLeft":t._focusCol=Math.max(0,t._focusCol-1),e.preventDefault();break;case"Home":(e.ctrlKey||e.metaKey)&&(i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=0),t._focusCol=0,e.preventDefault(),$(t,{forceScrollLeft:!0});return;case"End":(e.ctrlKey||e.metaKey)&&(i&&typeof t.commitActiveRowEdit=="function"&&t.commitActiveRowEdit(),t._focusRow=o),t._focusCol=n,e.preventDefault(),$(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":{const h=t._focusRow,u=t._focusCol,g=t._visibleColumns[u],f=t._rows[h],p=g?.field??"",d=p&&f?f[p]:void 0,w=t.querySelector(`[data-row="${h}"][data-col="${u}"]`),b={rowIndex:h,colIndex:u,field:p,value:d,row:f,cellEl:w,trigger:"keyboard",originalEvent:e},T=new CustomEvent("cell-activate",{cancelable:!0,detail:b});t.dispatchEvent(T);const C=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:h,col:u}});if(t.dispatchEvent(C),T.defaultPrevented||C.defaultPrevented){e.preventDefault();return}break}default:return}$(t)}}function $(t,e){if(t._virtualization?.enabled){const{rowHeight:s,container:l,viewportEl:c}=t._virtualization,a=l,h=c?.clientHeight??a?.clientHeight??0;if(a&&h>0){const u=t._focusRow*s;u<a.scrollTop?a.scrollTop=u:u+s>a.scrollTop+h&&(a.scrollTop=u-h+s)}}const o=t._activeEditRows!==void 0&&t._activeEditRows!==-1;o||t.refreshVirtualWindow(!1),te(t._bodyEl),Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(s=>{s.setAttribute("aria-selected","false")});const n=t._focusRow,i=t._virtualization.start??0,r=t._virtualization.end??t._rows.length;if(n>=i&&n<r){const s=t._bodyEl.querySelectorAll(".data-grid-row")[n-i];let l=s?.children[t._focusCol];if((!l||!l.classList?.contains("cell"))&&(l=s?.querySelector(`.cell[data-col="${t._focusCol}"]`)??s?.querySelector(".cell[data-col]")),l){l.classList.add("cell-focus"),l.setAttribute("aria-selected","true");const c=t.querySelector(".tbw-scroll-area");if(c&&l&&!o)if(e?.forceScrollLeft)c.scrollLeft=0;else if(e?.forceScrollRight)c.scrollLeft=c.scrollWidth-c.clientWidth;else{const a=t._getHorizontalScrollOffsets?.(s??void 0,l)??{left:0,right:0};if(!a.skipScroll){const h=l.getBoundingClientRect(),u=c.getBoundingClientRect(),g=h.left-u.left+c.scrollLeft,f=g+h.width,p=c.scrollLeft+a.left,d=c.scrollLeft+c.clientWidth-a.right;g<p?c.scrollLeft=g-a.left:f>d&&(c.scrollLeft=f-c.clientWidth+a.right)}}if(t._activeEditRows!==void 0&&t._activeEditRows!==-1&&l.classList.contains("editing")){const a=l.querySelector(Re);if(a&&document.activeElement!==a)try{a.focus({preventScroll:!0})}catch{}}else if(!l.contains(document.activeElement)){l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{}}}}}const Z=new WeakMap;function vt(t,e){const o=Ee(e),n=gt(e);o<0||n<0||(t._focusRow=o,t._focusCol=n,te(t._bodyEl),e.classList.add("cell-focus"),e.setAttribute("aria-selected","true"))}function re(t,e,o,n){let i=null;const r=o.composedPath?.();if(r&&r.length>0?i=r[0]:i=o.target,i&&!e.contains(i)){const d=document.elementFromPoint(o.clientX,o.clientY);d&&(i=d)}const s=i?.closest?.("[data-col]"),l=i?.closest?.(".data-grid-row"),c=i?.closest?.(".header-row");let a,h,u,g,f,p;return s&&(a=parseInt(s.getAttribute("data-row")??"-1",10),h=parseInt(s.getAttribute("data-col")??"-1",10),a>=0&&h>=0&&(u=t._rows[a],p=t._columns[h],g=p?.field,f=u&&g?u[g]:void 0)),{type:n,row:u,rowIndex:a!==void 0&&a>=0?a:void 0,colIndex:h!==void 0&&h>=0?h:void 0,field:g,value:f,column:p,originalEvent:o,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!c,cell:a!==void 0&&h!==void 0&&a>=0&&h>=0?{row:a,col:h}:void 0}}function Ct(t,e,o){const n=re(t,e,o,"mousedown");(t._dispatchCellMouseDown?.(n)??!1)&&Z.set(t,!0)}function yt(t,e,o){if(!Z.get(t))return;const n=re(t,e,o,"mousemove");t._dispatchCellMouseMove?.(n)}function _t(t,e,o){if(!Z.get(t))return;const n=re(t,e,o,"mouseup");t._dispatchCellMouseUp?.(n),Z.set(t,!1)}function Et(t,e,o){e.addEventListener("mousedown",n=>{const i=n.target.closest(".cell[data-col]");i&&(i.classList.contains("editing")||vt(t,i))},{signal:o}),e.addEventListener("click",n=>{const i=n.target.closest(".data-grid-row");i&&xe(t,n,i)},{signal:o}),e.addEventListener("dblclick",n=>{const i=n.target.closest(".data-grid-row");i&&xe(t,n,i)},{signal:o})}function St(t,e,o,n){e.addEventListener("keydown",i=>mt(t,i),{signal:n}),o.addEventListener("mousedown",i=>Ct(t,o,i),{signal:n}),document.addEventListener("mousemove",i=>yt(t,o,i),{signal:n}),document.addEventListener("mouseup",i=>_t(t,o,i),{signal:n})}function Pe(t,e){return t==null&&e==null?0:t==null?-1:e==null||t>e?1:t<e?-1:0}function Le(t,e,o){const i=o.find(l=>l.field===e.field)?.sortComparator??Pe,{field:r,direction:s}=e;return[...t].sort((l,c)=>i(l[r],c[r],l,c)*s)}function He(t,e,o,n){t._rows=e,t.__rowRenderEpoch++,t._rowPool.forEach(i=>i.__epoch=-1),Q(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:n}})),t.requestStateChange?.()}function Oe(t,e){!t._sortState||t._sortState.field!==e.field?(t._sortState||(t.__originalOrder=t._rows.slice()),De(t,e,1)):t._sortState.direction===1?De(t,e,-1):(t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(n=>n.__epoch=-1),t._rows=t.__originalOrder.slice(),Q(t),t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach(n=>{n.getAttribute("aria-sort")?(n.getAttribute("aria-sort")==="ascending"||n.getAttribute("aria-sort")==="descending")&&(t._sortState||n.setAttribute("aria-sort","none")):n.setAttribute("aria-sort","none")}),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e.field,direction:0}})),t.requestStateChange?.())}function De(t,e,o){t._sortState={field:e.field,direction:o};const n={field:e.field,direction:o},i=t._columns,s=(t.effectiveConfig?.sortHandler??Le)(t._rows,n,i);s&&typeof s.then=="function"?s.then(l=>{He(t,l,e,o)}):He(t,s,e,o)}function Rt(t,e){typeof e=="string"?t.textContent=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}function Q(t){t._headerRowEl=t.findHeaderRow();const e=t._headerRowEl;e&&(e.innerHTML="",t._visibleColumns.forEach((o,n)=>{const i=document.createElement("div");i.className="cell",we(i,"header-cell"),i.setAttribute("role","columnheader"),i.setAttribute("aria-colindex",String(n+1)),i.setAttribute("data-field",o.field),i.setAttribute("data-col",String(n));const r=o.__headerTemplate;if(r)Array.from(r.childNodes).forEach(s=>i.appendChild(s.cloneNode(!0)));else{const s=o.header??o.field,l=document.createElement("span");l.textContent=s,i.appendChild(l)}if(o.sortable){i.classList.add("sortable"),i.tabIndex=0;const s=document.createElement("span");we(s,"sort-indicator");const l=t._sortState?.field===o.field?t._sortState.direction:0,c={...z,...t.icons},a=l===1?c.sortAsc:l===-1?c.sortDesc:c.sortNone;Rt(s,a),i.appendChild(s),i.setAttribute("aria-sort",l===0?"none":l===1?"ascending":"descending"),i.addEventListener("click",h=>{t._resizeController?.isResizing||t._dispatchHeaderClick?.(h,n,i)||Oe(t,o)}),i.addEventListener("keydown",h=>{if(h.key==="Enter"||h.key===" "){if(h.preventDefault(),t._dispatchHeaderClick?.(h,n,i))return;Oe(t,o)}})}if(o.resizable){i.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,n,i)}),s.addEventListener("dblclick",l=>{l.stopPropagation(),l.preventDefault(),t._resizeController.resetColumn(n)}),i.appendChild(s)}e.appendChild(i)}),e.querySelectorAll(".cell.sortable").forEach(o=>{o.getAttribute("aria-sort")||o.setAttribute("aria-sort","none")}),e.children.length>0?(e.setAttribute("role","row"),e.setAttribute("aria-rowindex","1")):(e.removeAttribute("role"),e.removeAttribute("aria-rowindex")))}const Me=typeof requestIdleCallback=="function";function Tt(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 ze(t){Me?cancelIdleCallback(t):clearTimeout(t)}var x=(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))(x||{});class At{#n;#c=0;#f=0;#d=null;#s=null;#i=null;#h=!1;constructor(e){this.#n=e}requestPhase(e,o){e>this.#c&&(this.#c=e),this.#f===0&&(this.#u(),this.#f=requestAnimationFrame(()=>this.#b()))}whenReady(){return this.#d?this.#d:Promise.resolve()}setInitialReadyResolver(e){this.#i=e}cancel(){this.#f!==0&&(cancelAnimationFrame(this.#f),this.#f=0),this.#c=0,this.#s&&(this.#s(),this.#s=null,this.#d=null)}get isPending(){return this.#c!==0}get pendingPhase(){return this.#c}#u(){this.#d||(this.#d=new Promise(e=>{this.#s=e}))}#b(){if(this.#f=0,!this.#n.isConnected()){this.#c=0,this.#s&&(this.#s(),this.#s=null,this.#d=null);return}const e=this.#c;this.#c=0,e>=5&&this.#n.mergeConfig(),e>=4&&this.#n.processRows(),e>=5&&(this.#n.processColumns(),this.#n.updateTemplate()),e>=3&&this.#n.renderHeader(),e>=2&&this.#n.renderVirtualWindow(),e>=1&&this.#n.afterRender(),!this.#h&&this.#i&&(this.#h=!0,this.#i()),this.#s&&(this.#s(),this.#s=null,this.#d=null)}}function Ne(t){let e=null,o=null,n=null,i=null;const r=c=>{if(!e)return;const a=c.clientX-e.startX,h=Math.max(40,e.startWidth+a),u=t._visibleColumns[e.colIndex];u.width=h,u.__userResized=!0,u.__renderedWidth=h,o==null&&(o=requestAnimationFrame(()=>{o=null,t.updateTemplate?.()})),t.dispatchEvent(new CustomEvent("column-resize",{detail:{field:u.field,width:h}}))};let s=!1;const l=()=>{const c=e!==null;c&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),n!==null&&(document.documentElement.style.cursor=n,n=null),i!==null&&(document.body.style.userSelect=i,i=null),e=null,c&&t.requestStateChange&&t.requestStateChange()};return{get isResizing(){return e!==null||s},start(c,a,h){c.preventDefault();const u=t._visibleColumns[a],g=typeof u?.width=="number"?u.width:void 0,f=u?.__renderedWidth??g??h.getBoundingClientRect().width;e={startX:c.clientX,colIndex:a,startWidth:f},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),n===null&&(n=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",i===null&&(i=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(c){const a=t._visibleColumns[c];a&&(a.__userResized=!1,a.__renderedWidth=void 0,a.width=a.__originalWidth,t.updateTemplate?.(),t.requestStateChange?.(),t.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:a.field,width:a.width}})))},dispose(){l()}}}const se="data-animating",xt={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},Pt={change:500,insert:300,remove:200};function Lt(t){const e=t.trim().toLowerCase();return e.endsWith("ms")?parseFloat(e):e.endsWith("s")?parseFloat(e)*1e3:parseFloat(e)}function Ht(t,e){const o=xt[e],n=getComputedStyle(t).getPropertyValue(o);if(n){const i=Lt(n);if(!isNaN(i)&&i>0)return i}return Pt[e]}function Ot(t,e,o){t.removeAttribute(se),t.offsetWidth,t.setAttribute(se,e);const n=Ht(t,e);setTimeout(()=>{e!=="remove"&&t.removeAttribute(se)},n)}function le(t,e,o){if(e<0)return!1;const n=t.findRenderedRowElement?.(e);return n?(Ot(n,o),!0):!1}function Dt(t,e,o){let n=0;for(const i of e)le(t,i,o)&&n++;return n}function Mt(t,e,o){const n=t._rows??[],i=t.getRowId;if(!i)return!1;const r=n.findIndex(s=>i(s)===e);return r<0?!1:le(t,r,o)}function J(t,e,o){const n=document.createElement(t);if(e)for(const i in e){const r=e[i];r!=null&&n.setAttribute(i,r)}return n}function H(t,e){const o=document.createElement("div");if(t&&(o.className=t),e)for(const n in e){const i=e[n];i!=null&&o.setAttribute(n,i)}return o}function Ie(t,e,o){const n=document.createElement("button");if(t&&(n.className=t),e)for(const i in e){const r=e[i];r!=null&&n.setAttribute(i,r)}return n}const ke=document.createElement("template");ke.innerHTML=`
|
|
2
2
|
<div class="tbw-scroll-area">
|
|
3
3
|
<div class="rows-body-wrapper">
|
|
4
4
|
<div class="rows-body" role="grid">
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
<div class="faux-vscroll">
|
|
17
17
|
<div class="faux-vscroll-spacer"></div>
|
|
18
18
|
</div>
|
|
19
|
-
`;function
|
|
19
|
+
`;function qe(){return ke.content.cloneNode(!0)}function We(t){const e=document.createDocumentFragment(),o=H(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 n=H("tbw-grid-content");n.appendChild(qe()),o.appendChild(n)}return e.appendChild(o),e}function zt(t){const e=H("tbw-shell-header",{part:"shell-header",role:"presentation"});if(t.title){const r=H("tbw-shell-title");r.textContent=t.title,e.appendChild(r)}const o=H("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});e.appendChild(o);const n=H("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const r of t.configButtons)r.hasRender&&n.appendChild(H("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));for(const r of t.apiButtons)r.hasRender&&n.appendChild(H("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));if((t.configButtons.some(r=>r.hasRender)||t.apiButtons.some(r=>r.hasRender))&&t.hasPanels&&n.appendChild(H("tbw-toolbar-separator")),t.hasPanels){const r=Ie(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,n.appendChild(r)}return e.appendChild(n),e}function Nt(t){const e=H("tbw-shell-body"),o=t.panels.length>0,n=t.panels.length===1,i=H("tbw-grid-content");i.appendChild(qe());let r=null;if(o){r=J("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(H("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":s,"aria-hidden":"true"}));const l=H("tbw-tool-panel-content",{role:"presentation"}),c=H("tbw-accordion");for(const a of t.panels){const h=`tbw-accordion-section${a.isExpanded?" expanded":""}${n?" single":""}`,u=H(h,{"data-section":a.id}),g=Ie("tbw-accordion-header",{"aria-expanded":String(a.isExpanded),"aria-controls":`tbw-section-${a.id}`});if(n&&g.setAttribute("aria-disabled","true"),a.icon){const p=J("span",{class:"tbw-accordion-icon"});p.innerHTML=a.icon,g.appendChild(p)}const f=J("span",{class:"tbw-accordion-title"});if(f.textContent=a.title,g.appendChild(f),!n){const p=J("span",{class:"tbw-accordion-chevron"});p.innerHTML=a.isExpanded?t.collapseIcon:t.expandIcon,g.appendChild(p)}u.appendChild(g),u.appendChild(H("tbw-accordion-content",{id:`tbw-section-${a.id}`,role:"presentation"})),c.appendChild(u)}l.appendChild(c),r.appendChild(l)}return t.position==="left"&&r?(e.appendChild(r),e.appendChild(i)):(e.appendChild(i),r&&e.appendChild(r)),e}function k(t){return t?typeof t=="string"?t:t.outerHTML:""}function It(){return{toolPanels:new Map,headerContents:new Map,toolbarContents:new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:new Set,lightDomToolbarContentIds:new Set,apiToolPanelIds:new Set,isPanelOpen:!1,expandedSections:new Set,headerContentCleanups:new Map,panelCleanups:new Map,toolbarContentCleanups:new Map,lightDomContentMoved:!1}}function $e(t){return!!(t?.header?.title||t?.header?.toolbarContents?.length||t?.toolPanels?.length||t?.headerContents?.length||t?.header?.lightDomContent?.length||t?.header?.hasToolButtonsContainer)}function Fe(t,e,o="☰"){const n=t?.header?.title??e.lightDomTitle??"",i=!!n,r=k(o),s=t?.header?.toolbarContents??[],l=[...e.toolbarContents.values()],c=new Set(s.map(d=>d.id)),a=[...s];for(const d of l)c.has(d.id)||a.push(d);const h=a.length>0,u=e.toolPanels.size>0,g=h&&u,f=[...a].sort((d,w)=>(d.order??0)-(w.order??0));let p="";for(const d of f)p+=`<div class="tbw-toolbar-content-slot" data-toolbar-content="${d.id}"></div>`;if(g&&(p+='<div class="tbw-toolbar-separator"></div>'),u){const d=e.isPanelOpen;p+=`<button class="${d?"tbw-toolbar-btn active":"tbw-toolbar-btn"}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${d}" aria-controls="tbw-tool-panel">${r}</button>`}return`
|
|
20
20
|
<div class="tbw-shell-header" part="shell-header" role="presentation">
|
|
21
|
-
${i?`<div class="tbw-shell-title">${
|
|
21
|
+
${i?`<div class="tbw-shell-title">${it(n)}</div>`:""}
|
|
22
22
|
<div class="tbw-shell-content" part="shell-content" role="presentation" data-light-dom-header-content></div>
|
|
23
23
|
<div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">
|
|
24
24
|
${p}
|
|
25
25
|
</div>
|
|
26
26
|
</div>
|
|
27
|
-
`}function F(t,e){const o=t.querySelector("tbw-grid-header");if(!o)return;if(!e.lightDomTitle){const i=o.getAttribute("title");i&&(e.lightDomTitle=i)}const n=o.querySelectorAll("tbw-grid-header-content");n.length>0&&e.lightDomHeaderContent.length===0&&(e.lightDomHeaderContent=Array.from(n)),o.style.display="none"}function U(t,e,o){const n=t.querySelector(":scope > tbw-grid-tool-buttons");if(!n)return;e.hasToolButtonsContainer=!0;const i="light-dom-toolbar-content";if(e.lightDomToolbarContentIds.has(i))return;const r={id:i,order:0,render:(s=>{for(;n.firstChild;)s.appendChild(n.firstChild)})};e.toolbarContents.set(i,r),e.lightDomToolbarContentIds.add(i),n.style.display="none"}function V(t,e,o){t.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(i=>{const r=i,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 c=r.getAttribute("icon")??void 0,a=r.getAttribute("tooltip")??void 0,h=parseInt(r.getAttribute("order")??"100",10);let u;const g=o?.(r);if(g)u=g;else{const d=r.innerHTML.trim();u=w=>{const b=document.createElement("div");return b.innerHTML=d,w.appendChild(b),()=>b.remove()}}const f=e.toolPanels.get(s);if(f){if(g){f.render=u,f.order=h,f.icon=c,f.tooltip=a;const d=e.panelCleanups.get(s);d&&(d(),e.panelCleanups.delete(s))}return}const p={id:s,title:l,icon:c,tooltip:a,order:h,render:u};e.toolPanels.set(s,p),e.lightDomToolPanelIds.add(s),r.style.display="none"})}function xt(t,e,o,n){const i=t.querySelector(".tbw-shell-toolbar");i&&i.addEventListener("click",s=>{if(s.target.closest("[data-panel-toggle]")){n.onPanelToggle();return}});const r=t.querySelector(".tbw-accordion");r&&r.addEventListener("click",s=>{const c=s.target.closest(".tbw-accordion-header");if(c){const h=c.closest("[data-section]")?.getAttribute("data-section");h&&n.onSectionToggle(h)}})}function Pt(t,e,o){const n=t.querySelector(".tbw-tool-panel"),i=t.querySelector("[data-resize-handle]"),r=t.querySelector(".tbw-shell-body");if(!n||!i||!r)return()=>{};const s=e?.toolPanel?.position??"right",l=200;let c=0,a=0,h=0,u=!1;const g=d=>{if(!u)return;d.preventDefault();const w=s==="left"?d.clientX-c:c-d.clientX,b=Math.min(h,Math.max(l,a+w));n.style.width=`${b}px`},f=()=>{if(!u)return;u=!1,i.classList.remove("resizing"),n.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const d=n.getBoundingClientRect().width;o(d),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f)},p=d=>{d.preventDefault(),u=!0,c=d.clientX,a=n.getBoundingClientRect().width,h=r.getBoundingClientRect().width-20,i.classList.add("resizing"),n.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",g),document.addEventListener("mouseup",f)};return i.addEventListener("mousedown",p),()=>{i.removeEventListener("mousedown",p),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f)}}function We(t,e,o){const n=e?.header?.toolbarContents??[],i=[...o.toolbarContents.values()],r=new Set(n.map(l=>l.id)),s=[...n];for(const l of i)r.has(l.id)||s.push(l);for(const l of s){if(o.toolbarContentCleanups.has(l.id)||!l.render)continue;const c=t.querySelector(`[data-toolbar-content="${l.id}"]`);if(!c)continue;const a=l.render(c);a&&o.toolbarContentCleanups.set(l.id,a)}}function se(t,e){const o=e.lightDomHeaderContent.length>0&&!e.lightDomContentMoved,n=e.headerContents.size>0;if(!o&&!n)return;const i=t.querySelector(".tbw-shell-content");if(!i)return;if(o){for(const s of e.lightDomHeaderContent)s.style.display="",i.appendChild(s);e.lightDomContentMoved=!0}const r=[...e.headerContents.values()].sort((s,l)=>(s.order??100)-(l.order??100));for(const s of r){const l=e.headerContentCleanups.get(s.id);l&&(l(),e.headerContentCleanups.delete(s.id));let c=i.querySelector(`[data-header-content="${s.id}"]`);c||(c=document.createElement("div"),c.setAttribute("data-header-content",s.id),i.appendChild(c));const a=s.render(c);a&&e.headerContentCleanups.set(s.id,a)}}function Lt(t,e,o){if(!e.isPanelOpen)return;const n=k(o?.expand??z.expand),i=k(o?.collapse??z.collapse);for(const[r,s]of e.toolPanels){const l=e.expandedSections.has(r),c=t.querySelector(`[data-section="${r}"]`),a=c?.querySelector(".tbw-accordion-content");if(!c||!a)continue;c.classList.toggle("expanded",l);const h=c.querySelector(".tbw-accordion-header");h&&h.setAttribute("aria-expanded",String(l));const u=c.querySelector(".tbw-accordion-chevron");if(u&&(u.innerHTML=l?i:n),l){if(a.children.length===0){const g=s.render(a);g&&e.panelCleanups.set(r,g)}}else{const g=e.panelCleanups.get(r);g&&(g(),e.panelCleanups.delete(r)),a.innerHTML=""}}}function $e(t,e){const o=t.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",e.isPanelOpen),o.setAttribute("aria-pressed",String(e.isPanelOpen)))}function Fe(t,e){const o=t.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",e.isPanelOpen),e.isPanelOpen||(o.style.width=""))}function Ht(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.toolbarContentCleanups.values())e();t.toolbarContentCleanups.clear();for(const e of t.toolbarContents.values())e.onDestroy?.();if(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.toolbarContents.clear(),t.lightDomHeaderContent=[],t.lightDomToolPanelIds.clear(),t.lightDomToolbarContentIds.clear(),t.lightDomContentMoved=!1}function Ot(t,e){let o=!1;const n={get isInitialized(){return o},setInitialized(i){o=i},get isPanelOpen(){return t.isPanelOpen},get activePanel(){return t.isPanelOpen&&t.expandedSections.size>0?[...t.expandedSections][0]:null},get expandedSections(){return[...t.expandedSections]},openToolPanel(){if(t.isPanelOpen)return;if(t.toolPanels.size===0){console.warn("[tbw-grid] No tool panels registered");return}if(t.isPanelOpen=!0,t.expandedSections.size===0&&t.toolPanels.size>0){const s=[...t.toolPanels.values()].sort((l,c)=>(l.order??100)-(c.order??100))[0];s&&t.expandedSections.add(s.id)}const i=e.getShadow();$e(i,t),Fe(i,t),Lt(i,t,e.getAccordionIcons()),e.emit("tool-panel-open",{sections:n.expandedSections})},closeToolPanel(){if(!t.isPanelOpen)return;for(const r of t.panelCleanups.values())r();t.panelCleanups.clear();for(const r of t.toolPanels.values())r.onClose?.();t.isPanelOpen=!1;const i=e.getShadow();$e(i,t),Fe(i,t),e.emit("tool-panel-close",{})},toggleToolPanel(){t.isPanelOpen?n.closeToolPanel():n.openToolPanel()},toggleToolPanelSection(i){const r=t.toolPanels.get(i);if(!r){console.warn(`[tbw-grid] Tool panel section "${i}" not found`);return}if(t.toolPanels.size===1)return;const s=e.getShadow(),l=t.expandedSections.has(i);if(l){const c=t.panelCleanups.get(i);c&&(c(),t.panelCleanups.delete(i)),r.onClose?.(),t.expandedSections.delete(i),le(s,i,!1)}else{for(const[c,a]of t.toolPanels)if(c!==i&&t.expandedSections.has(c)){const h=t.panelCleanups.get(c);h&&(h(),t.panelCleanups.delete(c)),a.onClose?.(),t.expandedSections.delete(c),le(s,c,!1);const u=s.querySelector(`[data-section="${c}"] .tbw-accordion-content`);u&&(u.innerHTML="")}t.expandedSections.add(i),le(s,i,!0),Dt(s,t,i)}e.emit("tool-panel-section-toggle",{id:i,expanded:!l})},getToolPanels(){return[...t.toolPanels.values()]},registerToolPanel(i){if(t.toolPanels.has(i.id)){console.warn(`[tbw-grid] Tool panel "${i.id}" already registered`);return}t.toolPanels.set(i.id,i),o&&e.refreshShellHeader()},unregisterToolPanel(i){if(t.expandedSections.has(i)){const r=t.panelCleanups.get(i);r&&(r(),t.panelCleanups.delete(i)),t.expandedSections.delete(i)}t.toolPanels.delete(i),o&&e.refreshShellHeader()},getHeaderContents(){return[...t.headerContents.values()]},registerHeaderContent(i){if(t.headerContents.has(i.id)){console.warn(`[tbw-grid] Header content "${i.id}" already registered`);return}t.headerContents.set(i.id,i),o&&se(e.getShadow(),t)},unregisterHeaderContent(i){const r=t.headerContentCleanups.get(i);r&&(r(),t.headerContentCleanups.delete(i)),t.headerContents.get(i)?.onDestroy?.(),t.headerContents.delete(i),e.getShadow().querySelector(`[data-header-content="${i}"]`)?.remove()},getToolbarContents(){return[...t.toolbarContents.values()].sort((i,r)=>(i.order??0)-(r.order??0))},registerToolbarContent(i){if(t.toolbarContents.has(i.id)){console.warn(`[tbw-grid] Toolbar content "${i.id}" already registered`);return}t.toolbarContents.set(i.id,i),o&&e.refreshShellHeader()},unregisterToolbarContent(i){const r=t.toolbarContentCleanups.get(i);r&&(r(),t.toolbarContentCleanups.delete(i));const s=t.toolbarContents.get(i);s?.onDestroy&&s.onDestroy(),t.toolbarContents.delete(i),o&&e.refreshShellHeader()}};return n}function le(t,e,o){const n=t.querySelector(`[data-section="${e}"]`);n&&n.classList.toggle("expanded",o)}function Dt(t,e,o){const n=e.toolPanels.get(o);if(!n?.render)return;const i=t.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!i)return;const r=n.render(i);r&&e.panelCleanups.set(o,r)}function Mt(t,e,o,n){const i=ke(e),r=[],s=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const l of s)t.querySelectorAll(`:scope > ${l}`).forEach(a=>r.push(a));t.replaceChildren();for(const l of r)t.appendChild(l);if(i){const l=k(n?.toolPanel??z.toolPanel),c=k(n?.expand??z.expand),a=k(n?.collapse??z.collapse),u=[...e?.header?.toolbarContents??[]].sort((v,A)=>(v.order??0)-(A.order??0)),f=[...e?.toolPanels??[]].sort((v,A)=>(v.order??100)-(A.order??100)),p={title:e?.header?.title??void 0,hasPanels:f.length>0,isPanelOpen:o.isPanelOpen,toolPanelIcon:l,configButtons:u.map(v=>({id:v.id,hasElement:!1,hasRender:!!v.render})),apiButtons:[]},d={position:e?.toolPanel?.position??"right",isPanelOpen:o.isPanelOpen,expandIcon:c,collapseIcon:a,panels:f.map(v=>({id:v.id,title:v.title,icon:k(v.icon),isExpanded:o.expandedSections.has(v.id)}))},w=Rt(p),b=Tt(d),T=Ie({hasShell:!0,shellHeader:w,shellBody:b});t.appendChild(T)}else{const l=Ie({hasShell:!1});t.appendChild(l)}return i}function zt(){return{startY:null,startX:null,scrollTop:null,scrollLeft:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0}}function Nt(t){t.startY=null,t.startX=null,t.scrollTop=null,t.scrollLeft=null,t.lastY=null,t.lastX=null,t.lastTime=null}function Ue(t){t.momentumRaf&&(cancelAnimationFrame(t.momentumRaf),t.momentumRaf=0)}function It(t,e,o){if(t.touches.length!==1)return;Ue(e);const n=t.touches[0];e.startY=n.clientY,e.startX=n.clientX,e.lastY=n.clientY,e.lastX=n.clientX,e.lastTime=performance.now(),e.scrollTop=o.fauxScrollbar.scrollTop,e.scrollLeft=o.scrollArea?.scrollLeft??0,e.velocityY=0,e.velocityX=0}function kt(t,e,o){if(t.touches.length!==1||e.startY===null||e.startX===null||e.scrollTop===null||e.scrollLeft===null)return!1;const n=t.touches[0],i=n.clientY,r=n.clientX,s=performance.now(),l=e.startY-i,c=e.startX-r;if(e.lastTime!==null&&e.lastY!==null&&e.lastX!==null){const d=s-e.lastTime;d>0&&(e.velocityY=(e.lastY-i)/d,e.velocityX=(e.lastX-r)/d)}e.lastY=i,e.lastX=r,e.lastTime=s;const{scrollTop:a,scrollHeight:h,clientHeight:u}=o.fauxScrollbar,g=h-u,f=l>0&&a<g||l<0&&a>0;let p=!1;if(o.scrollArea){const{scrollLeft:d,scrollWidth:w,clientWidth:b}=o.scrollArea,T=w-b;p=c>0&&d<T||c<0&&d>0}return f&&(o.fauxScrollbar.scrollTop=e.scrollTop+l),p&&o.scrollArea&&(o.scrollArea.scrollLeft=e.scrollLeft+c),f||p}function qt(t,e){(Math.abs(t.velocityY)>.1||Math.abs(t.velocityX)>.1)&&Wt(t,e),Nt(t)}function Wt(t,e){const i=()=>{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(i):t.momentumRaf=0};t.momentumRaf=requestAnimationFrame(i)}function $t(t,e,o,n){t.addEventListener("touchstart",i=>It(i,e,o),{passive:!0,signal:n}),t.addEventListener("touchmove",i=>{kt(i,e,o)&&i.preventDefault()},{passive:!1,signal:n}),t.addEventListener("touchend",()=>qt(e,o),{passive:!0,signal:n})}const Ft=[{property:"editable",pluginName:"editing",level:"column",description:'the "editable" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';",isUsed:t=>t===!0},{property:"editor",pluginName:"editing",level:"column",description:'the "editor" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"editorParams",pluginName:"editing",level:"column",description:'the "editorParams" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"group",pluginName:"groupingColumns",level:"column",description:'the "group" column property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';"},{property:"sticky",pluginName:"pinnedColumns",level:"column",description:'the "sticky" column property',importHint:"import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';",isUsed:t=>t==="left"||t==="right"}],Ut=[{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:'the "columnGroups" config property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';",isUsed:t=>Array.isArray(t)&&t.length>0}],Vt={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 ae(t){return Vt[t]??`import { ${N(t)}Plugin } from '@toolbox-web/grid/plugins/${t}';`}function Ve(){if(typeof window<"u"&&window.location){const t=window.location.hostname;if(t==="localhost"||t==="127.0.0.1"||t==="::1")return!0}return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function N(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Ge(t,e){return t.some(o=>o.name===e)}function Gt(t,e){const o=Ft,n=Ut,i=new Map;function r(l,c,a,h,u=!1){i.has(l)||i.set(l,{description:c,importHint:a,fields:[],isConfigProperty:u});const g=i.get(l);g.fields.includes(h)||g.fields.push(h)}for(const l of n){const c=t[l.property];(l.isUsed?l.isUsed(c):c!==void 0)&&!Ge(e,l.pluginName)&&r(l.pluginName,l.description,l.importHint??ae(l.pluginName),l.property,!0)}const s=t.columns;if(s&&s.length>0)for(const l of s)for(const c of o){const a=l[c.property];if((c.isUsed?c.isUsed(a):a!==void 0)&&!Ge(e,c.pluginName)){const u=l.field||"<unknown>";r(c.pluginName,c.description,c.importHint??ae(c.pluginName),u)}}if(i.size>0){const l=[];for(const[c,{description:a,importHint:h,fields:u,isConfigProperty:g}]of i)if(g)l.push(`Config uses ${a}, but the required plugin is not loaded.
|
|
27
|
+
`}function F(t,e){const o=t.querySelector("tbw-grid-header");if(!o)return;if(!e.lightDomTitle){const i=o.getAttribute("title");i&&(e.lightDomTitle=i)}const n=o.querySelectorAll("tbw-grid-header-content");n.length>0&&e.lightDomHeaderContent.length===0&&(e.lightDomHeaderContent=Array.from(n)),o.style.display="none"}function U(t,e,o){const n=t.querySelector(":scope > tbw-grid-tool-buttons");if(!n)return;e.hasToolButtonsContainer=!0;const i="light-dom-toolbar-content";if(e.lightDomToolbarContentIds.has(i))return;const r={id:i,order:0,render:(s=>{for(;n.firstChild;)s.appendChild(n.firstChild)})};e.toolbarContents.set(i,r),e.lightDomToolbarContentIds.add(i),n.style.display="none"}function V(t,e,o){t.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(i=>{const r=i,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 c=r.getAttribute("icon")??void 0,a=r.getAttribute("tooltip")??void 0,h=parseInt(r.getAttribute("order")??"100",10);let u;const g=o?.(r);if(g)u=g;else{const d=r.innerHTML.trim();u=w=>{const b=document.createElement("div");return b.innerHTML=d,w.appendChild(b),()=>b.remove()}}const f=e.toolPanels.get(s);if(f){if(g){f.render=u,f.order=h,f.icon=c,f.tooltip=a;const d=e.panelCleanups.get(s);d&&(d(),e.panelCleanups.delete(s))}return}const p={id:s,title:l,icon:c,tooltip:a,order:h,render:u};e.toolPanels.set(s,p),e.lightDomToolPanelIds.add(s),r.style.display="none"})}function kt(t,e,o,n){const i=t.querySelector(".tbw-shell-toolbar");i&&i.addEventListener("click",s=>{if(s.target.closest("[data-panel-toggle]")){n.onPanelToggle();return}});const r=t.querySelector(".tbw-accordion");r&&r.addEventListener("click",s=>{const c=s.target.closest(".tbw-accordion-header");if(c){const h=c.closest("[data-section]")?.getAttribute("data-section");h&&n.onSectionToggle(h)}})}function qt(t,e,o){const n=t.querySelector(".tbw-tool-panel"),i=t.querySelector("[data-resize-handle]"),r=t.querySelector(".tbw-shell-body");if(!n||!i||!r)return()=>{};const s=e?.toolPanel?.position??"right",l=200;let c=0,a=0,h=0,u=!1;const g=d=>{if(!u)return;d.preventDefault();const w=s==="left"?d.clientX-c:c-d.clientX,b=Math.min(h,Math.max(l,a+w));n.style.width=`${b}px`},f=()=>{if(!u)return;u=!1,i.classList.remove("resizing"),n.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const d=n.getBoundingClientRect().width;o(d),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f)},p=d=>{d.preventDefault(),u=!0,c=d.clientX,a=n.getBoundingClientRect().width,h=r.getBoundingClientRect().width-20,i.classList.add("resizing"),n.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",g),document.addEventListener("mouseup",f)};return i.addEventListener("mousedown",p),()=>{i.removeEventListener("mousedown",p),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f)}}function Ue(t,e,o){const n=e?.header?.toolbarContents??[],i=[...o.toolbarContents.values()],r=new Set(n.map(l=>l.id)),s=[...n];for(const l of i)r.has(l.id)||s.push(l);for(const l of s){if(o.toolbarContentCleanups.has(l.id)||!l.render)continue;const c=t.querySelector(`[data-toolbar-content="${l.id}"]`);if(!c)continue;const a=l.render(c);a&&o.toolbarContentCleanups.set(l.id,a)}}function ae(t,e){const o=e.lightDomHeaderContent.length>0&&!e.lightDomContentMoved,n=e.headerContents.size>0;if(!o&&!n)return;const i=t.querySelector(".tbw-shell-content");if(!i)return;if(o){for(const s of e.lightDomHeaderContent)s.style.display="",i.appendChild(s);e.lightDomContentMoved=!0}const r=[...e.headerContents.values()].sort((s,l)=>(s.order??100)-(l.order??100));for(const s of r){const l=e.headerContentCleanups.get(s.id);l&&(l(),e.headerContentCleanups.delete(s.id));let c=i.querySelector(`[data-header-content="${s.id}"]`);c||(c=document.createElement("div"),c.setAttribute("data-header-content",s.id),i.appendChild(c));const a=s.render(c);a&&e.headerContentCleanups.set(s.id,a)}}function Wt(t,e,o){if(!e.isPanelOpen)return;const n=k(o?.expand??z.expand),i=k(o?.collapse??z.collapse);for(const[r,s]of e.toolPanels){const l=e.expandedSections.has(r),c=t.querySelector(`[data-section="${r}"]`),a=c?.querySelector(".tbw-accordion-content");if(!c||!a)continue;c.classList.toggle("expanded",l);const h=c.querySelector(".tbw-accordion-header");h&&h.setAttribute("aria-expanded",String(l));const u=c.querySelector(".tbw-accordion-chevron");if(u&&(u.innerHTML=l?i:n),l){if(a.children.length===0){const g=s.render(a);g&&e.panelCleanups.set(r,g)}}else{const g=e.panelCleanups.get(r);g&&(g(),e.panelCleanups.delete(r)),a.innerHTML=""}}}function Ve(t,e){const o=t.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",e.isPanelOpen),o.setAttribute("aria-pressed",String(e.isPanelOpen)))}function Ge(t,e){const o=t.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",e.isPanelOpen),e.isPanelOpen||(o.style.width=""))}function $t(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.toolbarContentCleanups.values())e();t.toolbarContentCleanups.clear();for(const e of t.toolbarContents.values())e.onDestroy?.();if(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.toolbarContents.clear(),t.lightDomHeaderContent=[],t.lightDomToolPanelIds.clear(),t.lightDomToolbarContentIds.clear(),t.lightDomContentMoved=!1}function Ft(t,e){let o=!1;const n={get isInitialized(){return o},setInitialized(i){o=i},get isPanelOpen(){return t.isPanelOpen},get activePanel(){return t.isPanelOpen&&t.expandedSections.size>0?[...t.expandedSections][0]:null},get expandedSections(){return[...t.expandedSections]},openToolPanel(){if(t.isPanelOpen)return;if(t.toolPanels.size===0){console.warn("[tbw-grid] No tool panels registered");return}if(t.isPanelOpen=!0,t.expandedSections.size===0&&t.toolPanels.size>0){const s=[...t.toolPanels.values()].sort((l,c)=>(l.order??100)-(c.order??100))[0];s&&t.expandedSections.add(s.id)}const i=e.getShadow();Ve(i,t),Ge(i,t),Wt(i,t,e.getAccordionIcons()),e.emit("tool-panel-open",{sections:n.expandedSections})},closeToolPanel(){if(!t.isPanelOpen)return;for(const r of t.panelCleanups.values())r();t.panelCleanups.clear();for(const r of t.toolPanels.values())r.onClose?.();t.isPanelOpen=!1;const i=e.getShadow();Ve(i,t),Ge(i,t),e.emit("tool-panel-close",{})},toggleToolPanel(){t.isPanelOpen?n.closeToolPanel():n.openToolPanel()},toggleToolPanelSection(i){const r=t.toolPanels.get(i);if(!r){console.warn(`[tbw-grid] Tool panel section "${i}" not found`);return}if(t.toolPanels.size===1)return;const s=e.getShadow(),l=t.expandedSections.has(i);if(l){const c=t.panelCleanups.get(i);c&&(c(),t.panelCleanups.delete(i)),r.onClose?.(),t.expandedSections.delete(i),ce(s,i,!1)}else{for(const[c,a]of t.toolPanels)if(c!==i&&t.expandedSections.has(c)){const h=t.panelCleanups.get(c);h&&(h(),t.panelCleanups.delete(c)),a.onClose?.(),t.expandedSections.delete(c),ce(s,c,!1);const u=s.querySelector(`[data-section="${c}"] .tbw-accordion-content`);u&&(u.innerHTML="")}t.expandedSections.add(i),ce(s,i,!0),Ut(s,t,i)}e.emit("tool-panel-section-toggle",{id:i,expanded:!l})},getToolPanels(){return[...t.toolPanels.values()]},registerToolPanel(i){if(t.toolPanels.has(i.id)){console.warn(`[tbw-grid] Tool panel "${i.id}" already registered`);return}t.toolPanels.set(i.id,i),o&&e.refreshShellHeader()},unregisterToolPanel(i){if(t.expandedSections.has(i)){const r=t.panelCleanups.get(i);r&&(r(),t.panelCleanups.delete(i)),t.expandedSections.delete(i)}t.toolPanels.delete(i),o&&e.refreshShellHeader()},getHeaderContents(){return[...t.headerContents.values()]},registerHeaderContent(i){if(t.headerContents.has(i.id)){console.warn(`[tbw-grid] Header content "${i.id}" already registered`);return}t.headerContents.set(i.id,i),o&&ae(e.getShadow(),t)},unregisterHeaderContent(i){const r=t.headerContentCleanups.get(i);r&&(r(),t.headerContentCleanups.delete(i)),t.headerContents.get(i)?.onDestroy?.(),t.headerContents.delete(i),e.getShadow().querySelector(`[data-header-content="${i}"]`)?.remove()},getToolbarContents(){return[...t.toolbarContents.values()].sort((i,r)=>(i.order??0)-(r.order??0))},registerToolbarContent(i){if(t.toolbarContents.has(i.id)){console.warn(`[tbw-grid] Toolbar content "${i.id}" already registered`);return}t.toolbarContents.set(i.id,i),o&&e.refreshShellHeader()},unregisterToolbarContent(i){const r=t.toolbarContentCleanups.get(i);r&&(r(),t.toolbarContentCleanups.delete(i));const s=t.toolbarContents.get(i);s?.onDestroy&&s.onDestroy(),t.toolbarContents.delete(i),o&&e.refreshShellHeader()}};return n}function ce(t,e,o){const n=t.querySelector(`[data-section="${e}"]`);n&&n.classList.toggle("expanded",o)}function Ut(t,e,o){const n=e.toolPanels.get(o);if(!n?.render)return;const i=t.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!i)return;const r=n.render(i);r&&e.panelCleanups.set(o,r)}function Vt(t,e,o,n){const i=$e(e),r=[],s=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const l of s)t.querySelectorAll(`:scope > ${l}`).forEach(a=>r.push(a));t.replaceChildren();for(const l of r)t.appendChild(l);if(i){const l=k(n?.toolPanel??z.toolPanel),c=k(n?.expand??z.expand),a=k(n?.collapse??z.collapse),u=[...e?.header?.toolbarContents??[]].sort((C,A)=>(C.order??0)-(A.order??0)),f=[...e?.toolPanels??[]].sort((C,A)=>(C.order??100)-(A.order??100)),p={title:e?.header?.title??void 0,hasPanels:f.length>0,isPanelOpen:o.isPanelOpen,toolPanelIcon:l,configButtons:u.map(C=>({id:C.id,hasElement:!1,hasRender:!!C.render})),apiButtons:[]},d={position:e?.toolPanel?.position??"right",isPanelOpen:o.isPanelOpen,expandIcon:c,collapseIcon:a,panels:f.map(C=>({id:C.id,title:C.title,icon:k(C.icon),isExpanded:o.expandedSections.has(C.id)}))},w=zt(p),b=Nt(d),T=We({hasShell:!0,shellHeader:w,shellBody:b});t.appendChild(T)}else{const l=We({hasShell:!1});t.appendChild(l)}return i}function Gt(){return{startY:null,startX:null,scrollTop:null,scrollLeft:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0}}function Bt(t){t.startY=null,t.startX=null,t.scrollTop=null,t.scrollLeft=null,t.lastY=null,t.lastX=null,t.lastTime=null}function Be(t){t.momentumRaf&&(cancelAnimationFrame(t.momentumRaf),t.momentumRaf=0)}function Xt(t,e,o){if(t.touches.length!==1)return;Be(e);const n=t.touches[0];e.startY=n.clientY,e.startX=n.clientX,e.lastY=n.clientY,e.lastX=n.clientX,e.lastTime=performance.now(),e.scrollTop=o.fauxScrollbar.scrollTop,e.scrollLeft=o.scrollArea?.scrollLeft??0,e.velocityY=0,e.velocityX=0}function Yt(t,e,o){if(t.touches.length!==1||e.startY===null||e.startX===null||e.scrollTop===null||e.scrollLeft===null)return!1;const n=t.touches[0],i=n.clientY,r=n.clientX,s=performance.now(),l=e.startY-i,c=e.startX-r;if(e.lastTime!==null&&e.lastY!==null&&e.lastX!==null){const d=s-e.lastTime;d>0&&(e.velocityY=(e.lastY-i)/d,e.velocityX=(e.lastX-r)/d)}e.lastY=i,e.lastX=r,e.lastTime=s;const{scrollTop:a,scrollHeight:h,clientHeight:u}=o.fauxScrollbar,g=h-u,f=l>0&&a<g||l<0&&a>0;let p=!1;if(o.scrollArea){const{scrollLeft:d,scrollWidth:w,clientWidth:b}=o.scrollArea,T=w-b;p=c>0&&d<T||c<0&&d>0}return f&&(o.fauxScrollbar.scrollTop=e.scrollTop+l),p&&o.scrollArea&&(o.scrollArea.scrollLeft=e.scrollLeft+c),f||p}function jt(t,e){(Math.abs(t.velocityY)>.1||Math.abs(t.velocityX)>.1)&&Kt(t,e),Bt(t)}function Kt(t,e){const i=()=>{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(i):t.momentumRaf=0};t.momentumRaf=requestAnimationFrame(i)}function Zt(t,e,o,n){t.addEventListener("touchstart",i=>Xt(i,e,o),{passive:!0,signal:n}),t.addEventListener("touchmove",i=>{Yt(i,e,o)&&i.preventDefault()},{passive:!1,signal:n}),t.addEventListener("touchend",()=>jt(e,o),{passive:!0,signal:n})}const Qt=[{property:"editable",pluginName:"editing",level:"column",description:'the "editable" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';",isUsed:t=>t===!0},{property:"editor",pluginName:"editing",level:"column",description:'the "editor" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"editorParams",pluginName:"editing",level:"column",description:'the "editorParams" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"group",pluginName:"groupingColumns",level:"column",description:'the "group" column property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';"},{property:"sticky",pluginName:"pinnedColumns",level:"column",description:'the "sticky" column property',importHint:"import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';",isUsed:t=>t==="left"||t==="right"}],Jt=[{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:'the "columnGroups" config property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';",isUsed:t=>Array.isArray(t)&&t.length>0}],eo={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 de(t){return eo[t]??`import { ${N(t)}Plugin } from '@toolbox-web/grid/plugins/${t}';`}function Xe(){if(typeof window<"u"&&window.location){const t=window.location.hostname;if(t==="localhost"||t==="127.0.0.1"||t==="::1")return!0}return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function N(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Ye(t,e){return t.some(o=>o.name===e)}function to(t,e){const o=Qt,n=Jt,i=new Map;function r(l,c,a,h,u=!1){i.has(l)||i.set(l,{description:c,importHint:a,fields:[],isConfigProperty:u});const g=i.get(l);g.fields.includes(h)||g.fields.push(h)}for(const l of n){const c=t[l.property];(l.isUsed?l.isUsed(c):c!==void 0)&&!Ye(e,l.pluginName)&&r(l.pluginName,l.description,l.importHint??de(l.pluginName),l.property,!0)}const s=t.columns;if(s&&s.length>0)for(const l of s)for(const c of o){const a=l[c.property];if((c.isUsed?c.isUsed(a):a!==void 0)&&!Ye(e,c.pluginName)){const u=l.field||"<unknown>";r(c.pluginName,c.description,c.importHint??de(c.pluginName),u)}}if(i.size>0){const l=[];for(const[c,{description:a,importHint:h,fields:u,isConfigProperty:g}]of i)if(g)l.push(`Config uses ${a}, but the required plugin is not loaded.
|
|
28
28
|
→ Add the plugin to your gridConfig.plugins array:
|
|
29
29
|
${h}
|
|
30
30
|
plugins: [new ${c.charAt(0).toUpperCase()+c.slice(1)}Plugin(), ...]`);else{const f=u.slice(0,3).join(", ")+(u.length>3?`, ... (${u.length} total)`:"");l.push(`Column(s) [${f}] use ${a}, but the required plugin is not loaded.
|
|
@@ -36,26 +36,26 @@ ${l.join(`
|
|
|
36
36
|
|
|
37
37
|
`)}
|
|
38
38
|
|
|
39
|
-
This validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`)}}function
|
|
39
|
+
This validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`)}}function oo(t){const e=[],o=[];for(const n of t){const r=n.constructor.manifest;if(r?.configRules)for(const s of r.configRules){const l=n.config;if(s.check(l)){const a=`${`[tbw-grid:${N(n.name)}Plugin]`} Configuration warning: ${s.message}`;s.severity==="error"?e.push(a):o.push(a)}}}if(o.length>0&&Xe())for(const n of o)console.warn(n);if(e.length>0)throw new Error(`[tbw-grid] Configuration error:
|
|
40
40
|
|
|
41
41
|
${e.join(`
|
|
42
42
|
|
|
43
|
-
`)}`)}function
|
|
43
|
+
`)}`)}function no(t,e){const o=t.name,i=t.constructor.dependencies??[];for(const r of i){const s=r.name,l=r.required??!0,c=r.reason;if(!e.some(h=>h.name===s)){const h=c??`${N(o)}Plugin requires ${N(s)}Plugin`,u=de(s);if(l)throw new Error(`[tbw-grid] Plugin dependency error:
|
|
44
44
|
|
|
45
45
|
${h}.
|
|
46
46
|
|
|
47
47
|
→ Add the plugin to your gridConfig.plugins array BEFORE ${N(o)}Plugin:
|
|
48
48
|
${u}
|
|
49
|
-
plugins: [new ${N(s)}Plugin(), new ${N(o)}Plugin()]`);console.info(`[tbw-grid] ${N(o)}Plugin: Optional "${s}" plugin not found. Some features may be unavailable.`)}}}function
|
|
49
|
+
plugins: [new ${N(s)}Plugin(), new ${N(o)}Plugin()]`);console.info(`[tbw-grid] ${N(o)}Plugin: Optional "${s}" plugin not found. Some features may be unavailable.`)}}}function io(t){if(!Xe())return;const e=new Set(t.map(n=>n.name)),o=new Set;for(const n of t){const r=n.constructor.manifest;if(r?.incompatibleWith){for(const s of r.incompatibleWith)if(e.has(s.name)){const l=[n.name,s.name].sort().join("↔");if(o.has(l))continue;o.add(l),console.warn(`[tbw-grid] Plugin incompatibility warning:
|
|
50
50
|
|
|
51
51
|
${N(n.name)}Plugin and ${N(s.name)}Plugin are both loaded, but they are currently incompatible.
|
|
52
52
|
|
|
53
53
|
→ ${s.reason}
|
|
54
54
|
|
|
55
|
-
Consider removing one of these plugins to avoid unexpected behavior.`)}}}}class
|
|
55
|
+
Consider removing one of these plugins to avoid unexpected behavior.`)}}}}class je{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(no(e,this.plugins),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[o,n]of Object.entries(e.cellRenderers))this.cellRenderers.set(o,n);if(e.headerRenderers)for(const[o,n]of Object.entries(e.headerRenderers))this.headerRenderers.set(o,n);if(e.cellEditors)for(const[o,n]of Object.entries(e.cellEditors))this.cellEditors.set(o,n);e.attach(this.grid);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)}getPluginStyles(){return this.plugins.filter(e=>e.styles).map(e=>({name:e.name,styles:e.styles}))}processRows(e){let o=[...e];for(const n of this.plugins)n.processRows&&(o=n.processRows(o));return o}processColumns(e){let o=[...e];for(const n of this.plugins)n.processColumns&&(o=n.processColumns(o));return o}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.plugins)e.afterRender?.()}afterCellRender(e){for(const o of this.plugins)o.afterCellRender?.(e)}hasAfterCellRenderHook(){return this.plugins.some(e=>typeof e.afterCellRender=="function")}afterRowRender(e){for(const o of this.plugins)o.afterRowRender?.(e)}hasAfterRowRenderHook(){return this.plugins.some(e=>typeof e.afterRowRender=="function")}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}hasExtraHeight(){for(const e of this.plugins)if(typeof e.getExtraHeight=="function"&&e.getExtraHeight()>0)return!0;return!1}getExtraHeightBefore(e){let o=0;for(const n of this.plugins)typeof n.getExtraHeightBefore=="function"&&(o+=n.getExtraHeightBefore(e));return o}adjustVirtualStart(e,o,n){let i=e;for(const r of this.plugins)if(typeof r.adjustVirtualStart=="function"){const s=r.adjustVirtualStart(e,o,n);s<i&&(i=s)}return i}renderRow(e,o,n){for(const i of this.plugins)if(i.renderRow?.(e,o,n))return!0;return!1}queryPlugins(e){const o=[];for(const n of this.plugins){const i=n.onPluginQuery?.(e);i!==void 0&&o.push(i)}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 n=0,i=0,r=!1;for(const s of this.plugins){const l=s.getHorizontalScrollOffsets?.(e,o);l&&(n+=l.left,i+=l.right,l.skipScroll&&(r=!0))}return{left:n,right:i,skipScroll:r}}getToolPanels(){const e=[];for(const o of this.plugins){const n=o.getToolPanel?.();n&&e.push({plugin:o,panel:n})}return e.sort((o,n)=>(o.panel.order??0)-(n.panel.order??0))}getHeaderContents(){const e=[];for(const o of this.plugins){const n=o.getHeaderContent?.();n&&e.push({plugin:o,content:n})}return e.sort((o,n)=>(o.content.order??0)-(n.content.order??0))}}class L 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"]}get#n(){return this}#c=!1;#f;#d;#s=[];get#i(){return this.#t?.effective??{}}#h=!1;#u=!1;#b={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#l;#p=0;#w=null;#r=!1;#m;#x=Gt();#g;#C;#y;#v;#E={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#o;#_;#O=!1;#P;#L;#t;#e=It();#a;#D;#H=new Map;_rows=[];#k=[];get _columns(){return this.#i.columns??[]}set _columns(e){this.#i.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;_restoreFocusAfterRender=!1;_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.#s;this.#s=e,o!==e&&this.#I("rows")}get sourceRows(){return this.#s}get columns(){return[...this._columns]}set columns(e){const o=this.#t?.getColumns();this.#t?.setColumns(e),o!==e&&this.#I("columns")}get gridConfig(){return this.#i}set gridConfig(e){const o=this.#t?.getGridConfig();this.#t?.setGridConfig(e),o!==e&&(this.#t.clearLightDomCache(),this.#I("gridConfig"))}get fitMode(){return this.#i.fitMode??"stretch"}set fitMode(e){const o=this.#t?.getFitMode();this.#t?.setFitMode(e),o!==e&&this.#I("fitMode")}get effectiveConfig(){return this.#i}get disconnectSignal(){return this.#g||(this.#g=new AbortController),this.#g.signal}constructor(){super(),this.#le(),this.#f=new Promise(e=>this.#d=e),this.#l=new At({mergeConfig:()=>{this.#t.parseLightDomColumns(this),this.#t.merge(),this.#K(),to(this.#i,this.#o?.getPlugins()??[]),oo(this.#o?.getPlugins()??[]),io(this.#o?.getPlugins()??[]),this.#k=[...this._columns]},processColumns:()=>this.#be(),processRows:()=>this.#me(),renderHeader:()=>Q(this),updateTemplate:()=>G(this),renderVirtualWindow:()=>this.refreshVirtualWindow(!0,!0),afterRender:()=>{this.#o?.afterRender(),this.#i.fitMode==="fixed"&&!this.__didInitialAutoSize&&(this.__didInitialAutoSize=!0,be(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,$(this)),this._virtualization.enabled&&!this.#N&&this.#ce()},isConnected:()=>this.isConnected&&this.#h}),this.#l.setInitialReadyResolver(()=>this.#d?.()),this.#a=Ft(this.#e,{getShadow:()=>this.#n,getShellConfig:()=>this.#i?.shell,getAccordionIcons:()=>({expand:this.#i?.icons?.expand??z.expand,collapse:this.#i?.icons?.collapse??z.collapse}),emit:(e,o)=>this.#T(e,o),refreshShellHeader:()=>this.refreshShellHeader()}),this.#t=new ft({getRows:()=>this.#s,getSortState:()=>this._sortState,setSortState:e=>{this._sortState=e},onConfigChange:()=>{this.#l.requestPhase(x.FULL,"configChange")},emit:(e,o)=>this.#T(e,o),clearRowPool:()=>{this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++},setup:()=>this.#A(),renderHeader:()=>Q(this),updateTemplate:()=>G(this),refreshVirtualWindow:()=>this.#l.requestPhase(x.VIRTUALIZATION,"configManager"),getVirtualization:()=>this._virtualization,setRowHeight:e=>{this._virtualization.rowHeight=e},applyAnimationConfig:e=>this.#ve(e),getShellLightDomTitle:()=>this.#e.lightDomTitle,getShellToolPanels:()=>this.#e.toolPanels,getShellHeaderContents:()=>this.#e.headerContents,getShellToolbarContents:()=>this.#e.toolbarContents,getShellLightDomHeaderContent:()=>this.#e.lightDomHeaderContent,getShellHasToolButtonsContainer:()=>this.#e.hasToolButtonsContainer})}static#Y="tbw-grid-styles";static#M="";static#q=new Map;static#se(){let e=document.getElementById(this.#Y);return e||(e=document.createElement("style"),e.id=this.#Y,e.setAttribute("data-tbw-grid","true"),document.head.appendChild(e)),e}static#W(){const e=this.#se(),o=Array.from(this.#q.values()).join(`
|
|
56
56
|
`);e.textContent=`${this.#M}
|
|
57
57
|
|
|
58
58
|
/* Plugin Styles */
|
|
59
59
|
${o}`}async#le(){if(!L.#M){if(q.length>0){L.#M=q,L.#W();return}await new Promise(e=>setTimeout(e,50));try{let e="";for(const o of Array.from(document.styleSheets))try{const i=Array.from(o.cssRules||[]).map(r=>r.cssText).join(`
|
|
60
|
-
`);if(i.includes(".tbw-grid-root")&&i.includes("tbw-grid")){e=i;break}}catch{continue}e?(L.#M=e,L.#W()):(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(o=>o.href||"(inline)"))}catch(e){console.warn("[tbw-grid] Failed to extract grid.css from document stylesheets:",e)}}}getPlugin(e){return this.#o?.getPlugin(e)}getPluginByName(e){return this.#o?.getPluginByName(e)}requestRender(){this.#l.requestPhase(x.ROWS,"plugin:requestRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#l.requestPhase(x.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){G(this)}requestAfterRender(){this.#l.requestPhase(x.STYLE,"plugin:requestAfterRender")}#j(){this.#o=new Be(this);const e=this.#i?.plugins,o=Array.isArray(e)?e:[];this.#o.attachAll(o)}#z(){const e=this.#o?.getPluginStyles()??[];let o=!1;for(const{name:n,styles:i}of e)L.#q.has(n)||(L.#q.set(n,i),o=!0);o&&L.#W()}#K(){const e=this.#i?.plugins,o=Array.isArray(e)?e:[];if(this.#_!==o){if(this.#_&&this.#_.length===o.length&&this.#_.every((n,i)=>n===o[i])){this.#_=o;return}this.#o&&this.#o.detachAll();for(const n of this.#e.toolPanels.keys()){const i=this.#e.lightDomToolPanelIds.has(n),r=this.#e.apiToolPanelIds.has(n);if(!i&&!r){const s=this.#e.panelCleanups.get(n);s&&(s(),this.#e.panelCleanups.delete(n)),this.#e.toolPanels.delete(n)}}for(const n of this.#e.headerContents.keys()){const i=this.#e.headerContentCleanups.get(n);i&&(i(),this.#e.headerContentCleanups.delete(n)),this.#e.headerContents.delete(n)}this.#j(),this.#z(),this.#_=o,this.#Z(),this.#r=this.#o?.getAll().some(n=>n.onScroll)??!1}}#ae(){this.#o?.detachAll()}#Z(){if(!this.#o)return;const e=this.#o.getToolPanels();for(const{panel:n}of e)this.#e.toolPanels.has(n.id)||this.#e.toolPanels.set(n.id,n);const o=this.#o.getHeaderContents();for(const{content:n}of o)this.#e.headerContents.has(n.id)||this.#e.headerContents.set(n.id,n)}#R(){const e=L.getAdapters();if(e.length===0&&!this.__frameworkAdapter)return;const o=this.__frameworkAdapter;return n=>{if(o?.createToolPanelRenderer){const i=o.createToolPanelRenderer(n);if(i)return i}for(const i of e)if(i.createToolPanelRenderer){const r=i.createToolPanelRenderer(n);if(r)return r}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",L.version),this._rows=Array.isArray(this.#s)?[...this.#s]:[],this.#g&&(this.#g.abort(),this.#O=!1),this.#g=new AbortController,this.#C&&(Oe(this.#C),this.#C=void 0),F(this,this.#e),U(this,this.#e),V(this,this.#e,this.#R()),this.#t.parseLightDomColumns(this),this.#t.merge(),this.#j();const e=this.#i?.plugins;this.#_=Array.isArray(e)?e:[],this.#Z(),this.#c||(this.#B(),this.#z(),this.#c=!0),this.#Q(),this.#C=Et(()=>{this.#Ee()},{timeout:100})}disconnectedCallback(){this.#C&&(Oe(this.#C),this.#C=void 0),this.#ae(),Ht(this.#e),this.#a.setInitialized(!1),this.#D?.(),this.#D=void 0,Ue(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.#v&&(this.#v.disconnect(),this.#v=void 0),this.#y&&(this.#y.disconnect(),this.#y=void 0,this.#N=!1),K(this),this.#S.clear(),this.#_=void 0;for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#h=!1}attributeChangedCallback(e,o,n){if(!(o===n||!n||n==="null"||n==="undefined"))if(e==="rows"||e==="columns"||e==="grid-config")try{const i=JSON.parse(n);e==="rows"?this.rows=i:e==="columns"?this.columns=i:e==="grid-config"&&(this.gridConfig=i)}catch{console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`,n)}else e==="fit-mode"&&(this.fitMode=n)}#Q(){const o=this.#n.querySelector(".tbw-grid-content")??this.#n.querySelector(".tbw-grid-root");if(this._headerRowEl=o?.querySelector(".header-row"),this._virtualization.totalHeightEl=o?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=o?.querySelector(".rows-viewport"),this._bodyEl=o?.querySelector(".rows"),this.__rowsBodyEl=o?.querySelector(".rows-body"),this.#a.isInitialized){se(this.#n,this.#e),We(this.#n,this.#i?.shell,this.#e);const r=this.#i?.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=De(this),this.#A(),this.#ee(o),this.#O)return;this.#O=!0;const n=this.disconnectSignal;yt(this,this,this.#n,n);const i=this.#i.rowHeight;i&&i>0?this._virtualization.rowHeight=i:requestAnimationFrame(()=>this.#J()),queueMicrotask(()=>this.#de()),this.#l.requestPhase(x.FULL,"afterConnect")}#J(){if(this.#o.hasExtraHeight())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const o=e.querySelectorAll(".cell");let n=0;o.forEach(s=>{const l=s.offsetHeight;l>n&&(n=l)});const i=e.getBoundingClientRect(),r=Math.max(i.height,n);r>0&&Math.abs(r-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=r,this.#l.requestPhase(x.VIRTUALIZATION,"measureRowHeight"))}#ee(e){this.#P?.abort(),this.#P=new AbortController;const o=this.#P.signal,n=e?.querySelector(".faux-vscroll"),i=e?.querySelector(".rows");if(this._virtualization.container=n??this,this.#r=this.#o?.getAll().some(r=>r.onScroll)??!1,n&&i){n.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#r)return;const l=n.scrollTop,c=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)i.style.transform=`translateY(${-l}px)`;else{const a=Math.floor(l/c),h=a-a%2,u=-(l-h*c);i.style.transform=`translateY(${u}px)`}this.#w=l,this.#p||(this.#p=requestAnimationFrame(()=>{this.#p=0,this.#w!==null&&(this.#ve(this.#w),this.#w=null)}))},{passive:!0,signal:o});const r=this.#n.querySelector(".tbw-grid-content"),s=this.#n.querySelector(".tbw-scroll-area");r&&(r.addEventListener("wheel",l=>{const c=l.shiftKey||Math.abs(l.deltaX)>Math.abs(l.deltaY);if(c&&s){const a=l.shiftKey?l.deltaY:l.deltaX,{scrollLeft:h,scrollWidth:u,clientWidth:g}=s;(a>0&&h<u-g||a<0&&h>0)&&(l.preventDefault(),s.scrollLeft+=a)}else if(!c){const{scrollTop:a,scrollHeight:h,clientHeight:u}=n;(l.deltaY>0&&a<h-u||l.deltaY<0&&a>0)&&(l.preventDefault(),n.scrollTop+=l.deltaY)}},{passive:!1,signal:o}),$t(r,this.#x,{fauxScrollbar:n,scrollArea:s},o))}this._bodyEl&&vt(this,this._bodyEl,o),this.#v?.disconnect(),this._virtualization.viewportEl&&(this.#v=new ResizeObserver(()=>{this.#l.requestPhase(x.VIRTUALIZATION,"resize-observer")}),this.#v.observe(this._virtualization.viewportEl)),this.#n.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:o}),this.#n.addEventListener("focusout",r=>{const s=r.relatedTarget;(!s||!this.#n.contains(s))&&delete this.dataset.hasFocus},{signal:o})}#N=!1;#ce(){if(this.#N)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#N=!0,this.#y?.disconnect(),this.#y=new ResizeObserver(()=>{this.#J()}),this.#y.observe(e))}#T(e,o){this.dispatchEvent(new CustomEvent(e,{detail:o,bubbles:!0,composed:!0}))}#de(){this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((o,n)=>{const i=n===this._focusRow;o.setAttribute("aria-selected",String(i)),o.querySelectorAll(".cell").forEach((r,s)=>{r.setAttribute("aria-selected",String(i&&s===this._focusCol))})})}#I(e){this.#b[e]=!0,!this.#u&&(this.#u=!0,queueMicrotask(()=>this.#he()))}#he(){if(!this.#u||!this.#h){this.#u=!1;return}const e=this.#b;if(this.#u=!1,this.#b={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig){this.#pe(),e.rows&&this.#te();return}e.columns&&this.#fe(),e.rows&&this.#te(),e.fitMode&&this.#ge()}#te(){this._rows=Array.isArray(this.#s)?[...this.#s]:[],this.#$(),this.#l.requestPhase(x.ROWS,"applyRowsUpdate")}#$(){this.#H.clear();const e=this.#i.getRowId;this._rows.forEach((o,n)=>{const i=this.#oe(o,e);i!==void 0&&this.#H.set(i,{row:o,index:n})})}#oe(e,o){if(o)return o(e);const n=e;if("id"in n&&n.id!=null)return String(n.id);if("_id"in n&&n._id!=null)return String(n._id)}#ue(e,o){const n=this.#oe(e,o);if(n===void 0)throw new Error('[tbw-grid] Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.');return n}#fe(){K(this),this.#t.merge(),this.#A()}#ge(){this.#t.merge(),this.#i.fitMode==="fixed"?(this.__didInitialAutoSize=!1,ge(this)):(this._columns.forEach(o=>{!o.__userResized&&o.__autoSized&&delete o.width}),G(this))}#pe(){F(this,this.#e),U(this,this.#e);const e=!!this.#n.querySelector(".has-shell"),o=!!this.#n.querySelector(".tbw-tool-panel"),n=this.#n.querySelectorAll(".tbw-accordion-section").length;this.#t.parseLightDomColumns(this),this.#t.merge(),this.#K(),V(this,this.#e,this.#R()),this.#t.markSourcesChanged(),this.#t.merge();const i=ke(this.#i?.shell),r=(this.#i?.shell?.toolPanels?.length??0)>0,s=(this.#i?.shell?.toolPanels?.length??0)!==n;if(e!==i||!e&&i||!o&&r||o&&s){this.#B(),this.#z(),this.#Q(),this.#$();return}e&&this.#we(),this.#$(),this.#l.requestPhase(x.COLUMNS,"applyGridConfigUpdate")}#we(){const e=this.#n.querySelector(".tbw-shell-header");if(!e)return;const o=this.#i.shell?.header?.title??this.#e.lightDomTitle;let n=e.querySelector(".tbw-shell-title");o?(n||(n=document.createElement("h2"),n.className="tbw-shell-title",n.setAttribute("part","shell-title"),e.insertBefore(n,e.firstChild)),n.textContent=o):n&&n.remove()}#be(){if(this.#o){const e=this.#k.length>0?this.#k:this._columns,o=e.filter(r=>!r.hidden),n=e.filter(r=>r.hidden),i=this.#o.processColumns([...o]);if(i!==o){new Set(o.map(l=>l.field));const r=new Set(i.map(l=>l.field));!o.some(l=>r.has(l.field))&&i.length>0?this._columns=[...i,...n]:this._columns=[...i,...n]}else this._columns=[...e]}}#me(){K(this);const e=Array.isArray(this.#s)?[...this.#s]:[],o=this.#o?.processRows(e)??e;this._rows=o}#Ce(e){const o={...he,...e.animation},n=o.mode??"reduced-motion";let i=1;n===!1||n==="off"?i=0:(n===!0||n==="on")&&(i=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(i)),this.dataset.animationMode=typeof n=="boolean"?n?"on":"off":n}#F(e,o,n=this.__rowRenderEpoch){this.#m||(this.#m=(i,r,s)=>this.#o?.renderRow(i,r,s)??!1),gt(this,e,o,n,this.#m)}#U=-1;#ne=-1;#ie(e,o){if(e===this.#U&&o===this.#ne)return;const n=this.#U;this.#U=e,this.#ne=o,this.__rowsBodyEl&&(this.__rowsBodyEl.setAttribute("aria-rowcount",String(e)),this.__rowsBodyEl.setAttribute("aria-colcount",String(o))),e!==n&&this._bodyEl&&(e>0?this._bodyEl.setAttribute("role","rowgroup"):this._bodyEl.removeAttribute("role"))}#A(){if(this.isConnected&&!(!this._headerRowEl||!this._bodyEl)){if(this.#t.parseLightDomColumns(this),this.#L){const e=this.#L;this.#L=void 0,this.#t.merge();const o=this.#o?.getAll()??[];this.#t.applyState(e,o)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#l.requestPhase(x.FULL,"setup")}}#ve(e){if(this.refreshVirtualWindow(!1),this.#o?.onScrollRender(),this.#r){const o=this._virtualization.container,n=this.#E;n.scrollTop=e,n.scrollLeft=o?.scrollLeft??0,n.scrollHeight=o?.scrollHeight??0,n.scrollWidth=o?.scrollWidth??0,n.clientHeight=o?.clientHeight??0,n.clientWidth=o?.clientWidth??0,this.#o?.onScroll(n)}}findHeaderRow(){return this.#n.querySelector(".header-row")}findRenderedRowElement(e){return Array.from(this._bodyEl.querySelectorAll(".data-grid-row")).find(o=>{const n=o.querySelector(".cell[data-row]");return n&&Number(n.getAttribute("data-row"))===e})||null}_dispatchCellClick(e,o,n,i){const r=this._rows[o],s=this._columns[n];if(!r||!s)return!1;const l=s.field,c=r[l],a=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:o,colIndex:n,field:l,value:c,row:r,cellEl:i,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(a),a.defaultPrevented)return!0;const h={row:r,rowIndex:o,colIndex:n,field:l,value:c,cellEl:i,originalEvent:e},u=this.#o?.onCellClick(h)??!1;return this.#T("cell-click",h),u}_dispatchRowClick(e,o,n,i){if(!n)return!1;const r={rowIndex:o,row:n,rowEl:i,originalEvent:e},s=this.#o?.onRowClick(r)??!1;return this.#T("row-click",r),s}_dispatchHeaderClick(e,o,n){const i=this._columns[o];if(!i)return!1;const r={colIndex:o,field:i.field,column:i,headerEl:n,originalEvent:e};return this.#o?.onHeaderClick(r)??!1}_dispatchKeyDown(e){return this.#o?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,o){return this.#o?.getHorizontalScrollOffsets(e,o)??{left:0,right:0}}queryPlugins(e){return this.#o?.queryPlugins(e)??[]}_dispatchCellMouseDown(e){return this.#o?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#o?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#o?.onCellMouseUp(e)}_afterCellRender(e){this.#o?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#o?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#o?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#o?.hasAfterRowRenderHook()??!1}async ready(){return this.#f}async forceLayout(){return this.#l.requestPhase(x.FULL,"forceLayout"),this.#l.whenReady()}async getConfig(){return Object.freeze({...this.#i||{}})}getRowId(e){return this.#ue(e,this.#i.getRowId)}getRow(e){return this.#H.get(e)?.row}updateRow(e,o,n="api"){const i=this.#H.get(e);if(!i)throw new Error(`[tbw-grid] Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:r,index:s}=i,l=[];for(const[c,a]of Object.entries(o)){const h=r[c];h!==a&&(l.push({field:c,oldValue:h,newValue:a}),r[c]=a)}for(const{field:c,oldValue:a,newValue:h}of l)this.#T("cell-change",{row:r,rowId:e,rowIndex:s,field:c,oldValue:a,newValue:h,changes:o,source:n});l.length>0&&this.#l.requestPhase(x.ROWS,"updateRow")}updateRows(e,o="api"){let n=!1;for(const{id:i,changes:r}of e){const s=this.#H.get(i);if(!s)throw new Error(`[tbw-grid] Row with ID "${i}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:l,index:c}=s;for(const[a,h]of Object.entries(r)){const u=l[a];u!==h&&(n=!0,l[a]=h,this.#T("cell-change",{row:l,rowId:i,rowIndex:c,field:a,oldValue:u,newValue:h,changes:r,source:o}))}}n&&this.#l.requestPhase(x.ROWS,"updateRows")}setColumnVisible(e,o){const n=this.#t.setColumnVisible(e,o);return n&&this.requestStateChange(),n}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.#o?.getAll()??[];return this.#t.collectState(e)}set columnState(e){e&&(this.#L=e,this.#t.initialColumnState=e,this.#c&&this.#ye(e))}get columnState(){return this.getColumnState()}#ye(e){const o=this.#o?.getAll()??[];this.#t.applyState(e,o),this.#A()}requestStateChange(){const e=this.#o?.getAll()??[];this.#t.requestStateChange(e)}resetColumnState(){this.#L=void 0,this.__originalOrder=[];const e=this.#o?.getAll()??[];this.#t.resetState(e),this.#t.merge(),this.#A()}get isToolPanelOpen(){return this.#a.isPanelOpen}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)}getToolbarContents(){return this.#a.getToolbarContents()}registerToolbarContent(e){this.#a.registerToolbarContent(e)}unregisterToolbarContent(e){this.#a.unregisterToolbarContent(e)}#V=!1;refreshShellHeader(){this.#V||(this.#V=!0,queueMicrotask(()=>{this.#V=!1,this.isConnected&&(F(this,this.#e),U(this,this.#e),V(this,this.#e,this.#R()),this.#t.markSourcesChanged(),this.#t.merge(),this.#B(),this.#z(),this.#_e())}))}#_e(){const o=this.#n.querySelector(".tbw-grid-content")??this.#n.querySelector(".tbw-grid-root");if(this._headerRowEl=o?.querySelector(".header-row"),this._virtualization.totalHeightEl=o?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=o?.querySelector(".rows-viewport"),this._bodyEl=o?.querySelector(".rows"),this.__rowsBodyEl=o?.querySelector(".rows-body"),this.#a.isInitialized){se(this.#n,this.#e),We(this.#n,this.#i?.shell,this.#e);const n=this.#i?.shell?.toolPanel?.defaultOpen;n&&this.#e.toolPanels.has(n)&&(this.openToolPanel(),this.#e.expandedSections.add(n))}this._resizeController=De(this),this.#ee(o),this.#l.requestPhase(x.COLUMNS,"shellRefresh")}#S=new Map;registerStyles(e,o){let n=this.#S.get(e);n||(n=new CSSStyleSheet,this.#S.set(e,n)),n.replaceSync(o),this.#re()}unregisterStyles(e){this.#S.delete(e)&&this.#re()}getRegisteredStyles(){return Array.from(this.#S.keys())}#re(){const e=Array.from(this.#S.values()),o=document.adoptedStyleSheets.filter(n=>!Array.from(this.#S.values()).includes(n));document.adoptedStyleSheets=[...o,...e]}#Ee(){const e=()=>{const n=this.#e.lightDomTitle,i=this.#e.hasToolButtonsContainer;F(this,this.#e),U(this,this.#e),V(this,this.#e,this.#R());const r=this.#e.lightDomTitle,s=this.#e.hasToolButtonsContainer;if(r&&!n||s&&!i){this.#t.markSourcesChanged(),this.#t.merge();const l=this.#n.querySelector(".tbw-shell-header");if(l){const c=qe(this.#i.shell,this.#e,this.#i.icons?.toolPanel),a=document.createElement("div");a.innerHTML=c;const h=a.firstElementChild;h&&(l.replaceWith(h),this.#X())}}},o=()=>{this.__lightDomColumnsCache=void 0,this.#A()};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,K(this),this.#t.parseLightDomColumns(this);const e=this.#e.lightDomTitle,o=this.#e.hasToolButtonsContainer;F(this,this.#e),U(this,this.#e),V(this,this.#e,this.#R());const n=this.#e.lightDomTitle,i=this.#e.hasToolButtonsContainer;if(n&&!e||i&&!o){this.#t.markSourcesChanged(),this.#t.merge();const s=this.#n.querySelector(".tbw-shell-header");if(s){const l=qe(this.#i.shell,this.#e,this.#i.icons?.toolPanel),c=document.createElement("div");c.innerHTML=l;const a=c.firstElementChild;a&&(s.replaceWith(a),this.#X())}}this.#l.requestPhase(x.COLUMNS,"refreshColumns")}#G(e){const o=this._virtualization.rowHeight,n=this._virtualization.container??this,i=this._virtualization.viewportEl??n,r=n.clientHeight,s=i.clientHeight,c=this.shadowRoot?.querySelector(".tbw-scroll-area"),a=c?c.clientHeight:r,u=a-s,g=this.#o?.getExtraHeight()??0,f=Math.max(0,r-a);return e*o+u+g+f}refreshVirtualWindow(e=!1,o=!1){if(!this._bodyEl)return;const n=this._rows.length;if(!this._virtualization.enabled){this.#F(0,n),o||this.#o?.afterRender();return}if(this._rows.length<=this._virtualization.bypassThreshold){this._virtualization.start=0,this._virtualization.end=n,e&&(this._bodyEl.style.transform="translateY(0px)"),this.#F(0,n,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${this.#G(n)}px`),this.#ie(n,this._visibleColumns.length),o||this.#o?.afterRender();return}const i=this._virtualization.container??this,r=this._virtualization.viewportEl??i,s=r.clientHeight,l=this._virtualization.rowHeight,c=i.scrollTop;let a=Math.floor(c/l),h=0;const u=10;for(;h<u;){const v=this.#o?.getExtraHeightBefore?.(a)??0,A=Math.floor((c-v)/l);if(A>=a||A<0)break;a=A,h++}a=a-a%2,a<0&&(a=0);const g=this.#o?.adjustVirtualStart(a,c,l);g!==void 0&&g<a&&(a=g,a=a-a%2,a<0&&(a=0));const f=Math.ceil(s/l)+3;let p=a+f;if(p>n&&(p=n),this._virtualization.start=a,this._virtualization.end=p,i.clientHeight===0&&s>0){this.#l.requestPhase(x.VIRTUALIZATION,"stale-refs-retry");return}const w=this.#G(n);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${w}px`);const b=this.#o?.getExtraHeightBefore?.(a)??0,T=-(c-a*l-b);this._bodyEl.style.transform=`translateY(${T}px)`,this.#F(a,p,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this.#ie(n,this._visibleColumns.length),e&&!o&&(this.#o?.afterRender(),queueMicrotask(()=>{const v=i.clientHeight,A=r.clientHeight;if(v===0&&A>0)return;const m=this.#G(n);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${m}px`)}))}#B(){F(this,this.#e),U(this,this.#e),V(this,this.#e,this.#R()),this.#t.markSourcesChanged(),this.#t.merge();const e=this.#i?.shell;Mt(this.#n,e,{isPanelOpen:this.#e.isPanelOpen,expandedSections:this.#e.expandedSections},this.#i?.icons)&&(this.#X(),this.#a.setInitialized(!0))}#X(){xt(this.#n,this.#i?.shell,this.#e,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#D?.(),this.#D=Pt(this.#n,this.#i?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)})}}customElements.get(L.tagName)||customElements.define(L.tagName,L),globalThis.DataGridElement=L;const jt={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"};class Kt{static dependencies;static manifest;version=typeof __GRID_VERSION__<"u"?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#n;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#n?.abort(),this.#n=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#n?.abort(),this.#n=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,o){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:o,bubbles:!0}))}emitCancelable(e,o){const n=new CustomEvent(e,{detail:o,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(n),n.defaultPrevented}requestRender(){this.grid?.requestRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}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 gridElement(){return this.grid}get disconnectSignal(){return this.#n?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...z,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(e===!1||e==="off")return!1;if(e===!0||e==="on")return!0;const o=this.gridElement;return o?getComputedStyle(o).getPropertyValue("--tbw-animation-enabled").trim()!=="0":!0}get animationDuration(){const e=this.gridElement;if(e){const o=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),n=parseInt(o,10);if(!isNaN(n))return n}return 200}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 P={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"},X={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"},Zt={ROOT:`.${P.ROOT}`,HEADER:`.${P.HEADER}`,HEADER_ROW:`.${P.HEADER_ROW}`,HEADER_CELL:`.${P.HEADER_CELL}`,ROWS_VIEWPORT:`.${P.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${P.ROWS_CONTAINER}`,DATA_ROW:`.${P.DATA_ROW}`,DATA_CELL:`.${P.DATA_CELL}`,GROUP_ROW:`.${P.GROUP_ROW}`,ROW_BY_INDEX:t=>`.${P.DATA_ROW}[${X.ROW_INDEX}="${t}"]`,CELL_BY_FIELD:t=>`.${P.DATA_CELL}[${X.FIELD}="${t}"]`,CELL_AT:(t,e)=>`.${P.DATA_ROW}[${X.ROW_INDEX}="${t}"] .${P.DATA_CELL}[${X.COL_INDEX}="${e}"]`,SELECTED_ROWS:`.${P.DATA_ROW}.${P.SELECTED}`,EDITING_CELL:`.${P.DATA_CELL}.${P.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"};function Jt(t){const e=document.createElement("tbw-grid");return t&&(e.gridConfig=t),e}function eo(t,e=document){return e.querySelector(t)}const to={CELL_CHANGE:"cell-change",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",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change"},oo={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"},ce={sum:(t,e)=>t.reduce((o,n)=>o+(Number(n[e])||0),0),avg:(t,e)=>{const o=t.reduce((n,i)=>n+(Number(i[e])||0),0);return t.length?o/t.length:0},count:t=>t.length,min:(t,e)=>Math.min(...t.map(o=>Number(o[e])||1/0)),max:(t,e)=>Math.max(...t.map(o=>Number(o[e])||-1/0)),first:(t,e)=>t[0]?.[e],last:(t,e)=>t[t.length-1]?.[e]},Y=new Map,M={register(t,e){Y.set(t,e)},unregister(t){Y.delete(t)},get(t){if(t!==void 0)return typeof t=="function"?t:Y.get(t)??ce[t]},run(t,e,o,n){const i=this.get(t);return i?i(e,o,n):void 0},has(t){return Y.has(t)||t in ce},list(){return[...Object.keys(ce),...Y.keys()]}},Xe={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 Ye(t){return Xe[t]??Xe.sum}function no(t,e){return Ye(t)(e)}const io=M.register.bind(M),ro=M.unregister.bind(M),so=M.get.bind(M),lo=M.run.bind(M),ao=M.list.bind(M);C.BaseGridPlugin=Kt,C.DEFAULT_ANIMATION_CONFIG=he,C.DEFAULT_GRID_ICONS=z,C.DGEvents=to,C.DataGridElement=L,C.FitModeEnum=W,C.GridCSSVars=Qt,C.GridClasses=P,C.GridDataAttrs=X,C.GridElement=L,C.GridSelectors=Zt,C.PLUGIN_QUERIES=jt,C.PluginEvents=oo,C.PluginManager=Be,C.RenderPhase=x,C.aggregatorRegistry=M,C.builtInSort=Ae,C.createGrid=Jt,C.defaultComparator=Te,C.getAggregator=so,C.getValueAggregator=Ye,C.listAggregators=ao,C.queryGrid=eo,C.registerAggregator=io,C.runAggregator=lo,C.runValueAggregator=no,C.unregisterAggregator=ro,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})}));
|
|
60
|
+
`);if(i.includes(".tbw-grid-root")&&i.includes("tbw-grid")){e=i;break}}catch{continue}e?(L.#M=e,L.#W()):(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(o=>o.href||"(inline)"))}catch(e){console.warn("[tbw-grid] Failed to extract grid.css from document stylesheets:",e)}}}getPlugin(e){return this.#o?.getPlugin(e)}getPluginByName(e){return this.#o?.getPluginByName(e)}requestRender(){this.#l.requestPhase(x.ROWS,"plugin:requestRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#l.requestPhase(x.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){G(this)}requestAfterRender(){this.#l.requestPhase(x.STYLE,"plugin:requestAfterRender")}#j(){this.#o=new je(this);const e=this.#i?.plugins,o=Array.isArray(e)?e:[];this.#o.attachAll(o)}#z(){const e=this.#o?.getPluginStyles()??[];let o=!1;for(const{name:n,styles:i}of e)L.#q.has(n)||(L.#q.set(n,i),o=!0);o&&L.#W()}#K(){const e=this.#i?.plugins,o=Array.isArray(e)?e:[];if(this.#_!==o){if(this.#_&&this.#_.length===o.length&&this.#_.every((n,i)=>n===o[i])){this.#_=o;return}this.#o&&this.#o.detachAll();for(const n of this.#e.toolPanels.keys()){const i=this.#e.lightDomToolPanelIds.has(n),r=this.#e.apiToolPanelIds.has(n);if(!i&&!r){const s=this.#e.panelCleanups.get(n);s&&(s(),this.#e.panelCleanups.delete(n)),this.#e.toolPanels.delete(n)}}for(const n of this.#e.headerContents.keys()){const i=this.#e.headerContentCleanups.get(n);i&&(i(),this.#e.headerContentCleanups.delete(n)),this.#e.headerContents.delete(n)}this.#j(),this.#z(),this.#_=o,this.#Z(),this.#r=this.#o?.getAll().some(n=>n.onScroll)??!1}}#ae(){this.#o?.detachAll()}#Z(){if(!this.#o)return;const e=this.#o.getToolPanels();for(const{panel:n}of e)this.#e.toolPanels.has(n.id)||this.#e.toolPanels.set(n.id,n);const o=this.#o.getHeaderContents();for(const{content:n}of o)this.#e.headerContents.has(n.id)||this.#e.headerContents.set(n.id,n)}#R(){const e=L.getAdapters();if(e.length===0&&!this.__frameworkAdapter)return;const o=this.__frameworkAdapter;return n=>{if(o?.createToolPanelRenderer){const i=o.createToolPanelRenderer(n);if(i)return i}for(const i of e)if(i.createToolPanelRenderer){const r=i.createToolPanelRenderer(n);if(r)return r}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",L.version),this._rows=Array.isArray(this.#s)?[...this.#s]:[],this.#g&&(this.#g.abort(),this.#O=!1),this.#g=new AbortController,this.#v&&(ze(this.#v),this.#v=void 0),F(this,this.#e),U(this,this.#e),V(this,this.#e,this.#R()),this.#t.parseLightDomColumns(this),this.#t.merge(),this.#j();const e=this.#i?.plugins;this.#_=Array.isArray(e)?e:[],this.#Z(),this.#c||(this.#B(),this.#z(),this.#c=!0),this.#Q(),this.#v=Tt(()=>{this.#Ee()},{timeout:100})}disconnectedCallback(){this.#v&&(ze(this.#v),this.#v=void 0),this.#ae(),$t(this.#e),this.#a.setInitialized(!1),this.#D?.(),this.#D=void 0,Be(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.#C&&(this.#C.disconnect(),this.#C=void 0),this.#y&&(this.#y.disconnect(),this.#y=void 0,this.#N=!1),K(this),this.#S.clear(),this.#_=void 0;for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#h=!1}attributeChangedCallback(e,o,n){if(!(o===n||!n||n==="null"||n==="undefined"))if(e==="rows"||e==="columns"||e==="grid-config")try{const i=JSON.parse(n);e==="rows"?this.rows=i:e==="columns"?this.columns=i:e==="grid-config"&&(this.gridConfig=i)}catch{console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`,n)}else e==="fit-mode"&&(this.fitMode=n)}#Q(){const o=this.#n.querySelector(".tbw-grid-content")??this.#n.querySelector(".tbw-grid-root");if(this._headerRowEl=o?.querySelector(".header-row"),this._virtualization.totalHeightEl=o?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=o?.querySelector(".rows-viewport"),this._bodyEl=o?.querySelector(".rows"),this.__rowsBodyEl=o?.querySelector(".rows-body"),this.#a.isInitialized){ae(this.#n,this.#e),Ue(this.#n,this.#i?.shell,this.#e);const r=this.#i?.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=Ne(this),this.#A(),this.#ee(o),this.#O)return;this.#O=!0;const n=this.disconnectSignal;St(this,this,this.#n,n);const i=this.#i.rowHeight;i&&i>0?this._virtualization.rowHeight=i:requestAnimationFrame(()=>this.#J()),queueMicrotask(()=>this.#de()),this.#l.requestPhase(x.FULL,"afterConnect")}#J(){if(this.#o.hasExtraHeight())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const o=e.querySelectorAll(".cell");let n=0;o.forEach(s=>{const l=s.offsetHeight;l>n&&(n=l)});const i=e.getBoundingClientRect(),r=Math.max(i.height,n);r>0&&Math.abs(r-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=r,this.#l.requestPhase(x.VIRTUALIZATION,"measureRowHeight"))}#ee(e){this.#P?.abort(),this.#P=new AbortController;const o=this.#P.signal,n=e?.querySelector(".faux-vscroll"),i=e?.querySelector(".rows");if(this._virtualization.container=n??this,this.#r=this.#o?.getAll().some(r=>r.onScroll)??!1,n&&i){n.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#r)return;const l=n.scrollTop,c=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)i.style.transform=`translateY(${-l}px)`;else{const a=Math.floor(l/c),h=a-a%2,u=-(l-h*c);i.style.transform=`translateY(${u}px)`}this.#w=l,this.#p||(this.#p=requestAnimationFrame(()=>{this.#p=0,this.#w!==null&&(this.#Ce(this.#w),this.#w=null)}))},{passive:!0,signal:o});const r=this.#n.querySelector(".tbw-grid-content"),s=this.#n.querySelector(".tbw-scroll-area");r&&(r.addEventListener("wheel",l=>{const c=l.shiftKey||Math.abs(l.deltaX)>Math.abs(l.deltaY);if(c&&s){const a=l.shiftKey?l.deltaY:l.deltaX,{scrollLeft:h,scrollWidth:u,clientWidth:g}=s;(a>0&&h<u-g||a<0&&h>0)&&(l.preventDefault(),s.scrollLeft+=a)}else if(!c){const{scrollTop:a,scrollHeight:h,clientHeight:u}=n;(l.deltaY>0&&a<h-u||l.deltaY<0&&a>0)&&(l.preventDefault(),n.scrollTop+=l.deltaY)}},{passive:!1,signal:o}),Zt(r,this.#x,{fauxScrollbar:n,scrollArea:s},o))}this._bodyEl&&Et(this,this._bodyEl,o),this.#C?.disconnect(),this._virtualization.viewportEl&&(this.#C=new ResizeObserver(()=>{this.#l.requestPhase(x.VIRTUALIZATION,"resize-observer")}),this.#C.observe(this._virtualization.viewportEl)),this.#n.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:o}),this.#n.addEventListener("focusout",r=>{const s=r.relatedTarget;(!s||!this.#n.contains(s))&&delete this.dataset.hasFocus},{signal:o})}#N=!1;#ce(){if(this.#N)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#N=!0,this.#y?.disconnect(),this.#y=new ResizeObserver(()=>{this.#J()}),this.#y.observe(e))}#T(e,o){this.dispatchEvent(new CustomEvent(e,{detail:o,bubbles:!0,composed:!0}))}#de(){this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((o,n)=>{const i=n===this._focusRow;o.setAttribute("aria-selected",String(i)),o.querySelectorAll(".cell").forEach((r,s)=>{r.setAttribute("aria-selected",String(i&&s===this._focusCol))})})}#I(e){this.#b[e]=!0,!this.#u&&(this.#u=!0,queueMicrotask(()=>this.#he()))}#he(){if(!this.#u||!this.#h){this.#u=!1;return}const e=this.#b;if(this.#u=!1,this.#b={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig){this.#pe(),e.rows&&this.#te();return}e.columns&&this.#fe(),e.rows&&this.#te(),e.fitMode&&this.#ge()}#te(){this._rows=Array.isArray(this.#s)?[...this.#s]:[],this.#$(),this.#l.requestPhase(x.ROWS,"applyRowsUpdate")}#$(){this.#H.clear();const e=this.#i.getRowId;this._rows.forEach((o,n)=>{const i=this.#oe(o,e);i!==void 0&&this.#H.set(i,{row:o,index:n})})}#oe(e,o){if(o)return o(e);const n=e;if("id"in n&&n.id!=null)return String(n.id);if("_id"in n&&n._id!=null)return String(n._id)}#ue(e,o){const n=this.#oe(e,o);if(n===void 0)throw new Error('[tbw-grid] Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.');return n}#fe(){K(this),this.#t.merge(),this.#A()}#ge(){this.#t.merge(),this.#i.fitMode==="fixed"?(this.__didInitialAutoSize=!1,be(this)):(this._columns.forEach(o=>{!o.__userResized&&o.__autoSized&&delete o.width}),G(this))}#pe(){F(this,this.#e),U(this,this.#e);const e=!!this.#n.querySelector(".has-shell"),o=!!this.#n.querySelector(".tbw-tool-panel"),n=this.#n.querySelectorAll(".tbw-accordion-section").length;this.#t.parseLightDomColumns(this),this.#t.merge(),this.#K(),V(this,this.#e,this.#R()),this.#t.markSourcesChanged(),this.#t.merge();const i=$e(this.#i?.shell),r=(this.#i?.shell?.toolPanels?.length??0)>0,s=(this.#i?.shell?.toolPanels?.length??0)!==n;if(e!==i||!e&&i||!o&&r||o&&s){this.#B(),this.#z(),this.#Q(),this.#$();return}e&&this.#we(),this.#$(),this.#l.requestPhase(x.COLUMNS,"applyGridConfigUpdate")}#we(){const e=this.#n.querySelector(".tbw-shell-header");if(!e)return;const o=this.#i.shell?.header?.title??this.#e.lightDomTitle;let n=e.querySelector(".tbw-shell-title");o?(n||(n=document.createElement("h2"),n.className="tbw-shell-title",n.setAttribute("part","shell-title"),e.insertBefore(n,e.firstChild)),n.textContent=o):n&&n.remove()}#be(){if(this.#o){const e=this.#k.length>0?this.#k:this._columns,o=e.filter(r=>!r.hidden),n=e.filter(r=>r.hidden),i=this.#o.processColumns([...o]);if(i!==o){new Set(o.map(l=>l.field));const r=new Set(i.map(l=>l.field));!o.some(l=>r.has(l.field))&&i.length>0?this._columns=[...i,...n]:this._columns=[...i,...n]}else this._columns=[...e]}}#me(){K(this);const e=Array.isArray(this.#s)?[...this.#s]:[],o=this.#o?.processRows(e)??e;this._rows=o}#ve(e){const o={...fe,...e.animation},n=o.mode??"reduced-motion";let i=1;n===!1||n==="off"?i=0:(n===!0||n==="on")&&(i=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(i)),this.dataset.animationMode=typeof n=="boolean"?n?"on":"off":n}#F(e,o,n=this.__rowRenderEpoch){this.#m||(this.#m=(i,r,s)=>this.#o?.renderRow(i,r,s)??!1),bt(this,e,o,n,this.#m)}#U=-1;#ne=-1;#ie(e,o){if(e===this.#U&&o===this.#ne)return;const n=this.#U;this.#U=e,this.#ne=o,this.__rowsBodyEl&&(this.__rowsBodyEl.setAttribute("aria-rowcount",String(e)),this.__rowsBodyEl.setAttribute("aria-colcount",String(o))),e!==n&&this._bodyEl&&(e>0?this._bodyEl.setAttribute("role","rowgroup"):this._bodyEl.removeAttribute("role"))}#A(){if(this.isConnected&&!(!this._headerRowEl||!this._bodyEl)){if(this.#t.parseLightDomColumns(this),this.#L){const e=this.#L;this.#L=void 0,this.#t.merge();const o=this.#o?.getAll()??[];this.#t.applyState(e,o)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#l.requestPhase(x.FULL,"setup")}}#Ce(e){if(this.refreshVirtualWindow(!1),this.#o?.onScrollRender(),this.#r){const o=this._virtualization.container,n=this.#E;n.scrollTop=e,n.scrollLeft=o?.scrollLeft??0,n.scrollHeight=o?.scrollHeight??0,n.scrollWidth=o?.scrollWidth??0,n.clientHeight=o?.clientHeight??0,n.clientWidth=o?.clientWidth??0,this.#o?.onScroll(n)}}findHeaderRow(){return this.#n.querySelector(".header-row")}findRenderedRowElement(e){return Array.from(this._bodyEl.querySelectorAll(".data-grid-row")).find(o=>{const n=o.querySelector(".cell[data-row]");return n&&Number(n.getAttribute("data-row"))===e})||null}_dispatchCellClick(e,o,n,i){const r=this._rows[o],s=this._columns[n];if(!r||!s)return!1;const l=s.field,c=r[l],a=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:o,colIndex:n,field:l,value:c,row:r,cellEl:i,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(a),a.defaultPrevented)return!0;const h={row:r,rowIndex:o,colIndex:n,field:l,value:c,cellEl:i,originalEvent:e},u=this.#o?.onCellClick(h)??!1;return this.#T("cell-click",h),u}_dispatchRowClick(e,o,n,i){if(!n)return!1;const r={rowIndex:o,row:n,rowEl:i,originalEvent:e},s=this.#o?.onRowClick(r)??!1;return this.#T("row-click",r),s}_dispatchHeaderClick(e,o,n){const i=this._columns[o];if(!i)return!1;const r={colIndex:o,field:i.field,column:i,headerEl:n,originalEvent:e};return this.#o?.onHeaderClick(r)??!1}_dispatchKeyDown(e){return this.#o?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,o){return this.#o?.getHorizontalScrollOffsets(e,o)??{left:0,right:0}}queryPlugins(e){return this.#o?.queryPlugins(e)??[]}_dispatchCellMouseDown(e){return this.#o?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#o?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#o?.onCellMouseUp(e)}_afterCellRender(e){this.#o?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#o?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#o?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#o?.hasAfterRowRenderHook()??!1}async ready(){return this.#f}async forceLayout(){return this.#l.requestPhase(x.FULL,"forceLayout"),this.#l.whenReady()}async getConfig(){return Object.freeze({...this.#i||{}})}getRowId(e){return this.#ue(e,this.#i.getRowId)}getRow(e){return this.#H.get(e)?.row}updateRow(e,o,n="api"){const i=this.#H.get(e);if(!i)throw new Error(`[tbw-grid] Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:r,index:s}=i,l=[];for(const[c,a]of Object.entries(o)){const h=r[c];h!==a&&(l.push({field:c,oldValue:h,newValue:a}),r[c]=a)}for(const{field:c,oldValue:a,newValue:h}of l)this.#T("cell-change",{row:r,rowId:e,rowIndex:s,field:c,oldValue:a,newValue:h,changes:o,source:n});l.length>0&&this.#l.requestPhase(x.ROWS,"updateRow")}updateRows(e,o="api"){let n=!1;for(const{id:i,changes:r}of e){const s=this.#H.get(i);if(!s)throw new Error(`[tbw-grid] Row with ID "${i}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:l,index:c}=s;for(const[a,h]of Object.entries(r)){const u=l[a];u!==h&&(n=!0,l[a]=h,this.#T("cell-change",{row:l,rowId:i,rowIndex:c,field:a,oldValue:u,newValue:h,changes:r,source:o}))}}n&&this.#l.requestPhase(x.ROWS,"updateRows")}animateRow(e,o){le(this,e,o)}animateRows(e,o){Dt(this,e,o)}animateRowById(e,o){return Mt(this,e,o)}setColumnVisible(e,o){const n=this.#t.setColumnVisible(e,o);return n&&this.requestStateChange(),n}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.#o?.getAll()??[];return this.#t.collectState(e)}set columnState(e){e&&(this.#L=e,this.#t.initialColumnState=e,this.#c&&this.#ye(e))}get columnState(){return this.getColumnState()}#ye(e){const o=this.#o?.getAll()??[];this.#t.applyState(e,o),this.#A()}requestStateChange(){const e=this.#o?.getAll()??[];this.#t.requestStateChange(e)}resetColumnState(){this.#L=void 0,this.__originalOrder=[];const e=this.#o?.getAll()??[];this.#t.resetState(e),this.#t.merge(),this.#A()}get isToolPanelOpen(){return this.#a.isPanelOpen}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)}getToolbarContents(){return this.#a.getToolbarContents()}registerToolbarContent(e){this.#a.registerToolbarContent(e)}unregisterToolbarContent(e){this.#a.unregisterToolbarContent(e)}#V=!1;refreshShellHeader(){this.#V||(this.#V=!0,queueMicrotask(()=>{this.#V=!1,this.isConnected&&(F(this,this.#e),U(this,this.#e),V(this,this.#e,this.#R()),this.#t.markSourcesChanged(),this.#t.merge(),this.#B(),this.#z(),this.#_e())}))}#_e(){const o=this.#n.querySelector(".tbw-grid-content")??this.#n.querySelector(".tbw-grid-root");if(this._headerRowEl=o?.querySelector(".header-row"),this._virtualization.totalHeightEl=o?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=o?.querySelector(".rows-viewport"),this._bodyEl=o?.querySelector(".rows"),this.__rowsBodyEl=o?.querySelector(".rows-body"),this.#a.isInitialized){ae(this.#n,this.#e),Ue(this.#n,this.#i?.shell,this.#e);const n=this.#i?.shell?.toolPanel?.defaultOpen;n&&this.#e.toolPanels.has(n)&&(this.openToolPanel(),this.#e.expandedSections.add(n))}this._resizeController=Ne(this),this.#ee(o),this.#l.requestPhase(x.COLUMNS,"shellRefresh")}#S=new Map;registerStyles(e,o){let n=this.#S.get(e);n||(n=new CSSStyleSheet,this.#S.set(e,n)),n.replaceSync(o),this.#re()}unregisterStyles(e){this.#S.delete(e)&&this.#re()}getRegisteredStyles(){return Array.from(this.#S.keys())}#re(){const e=Array.from(this.#S.values()),o=document.adoptedStyleSheets.filter(n=>!Array.from(this.#S.values()).includes(n));document.adoptedStyleSheets=[...o,...e]}#Ee(){const e=()=>{const n=this.#e.lightDomTitle,i=this.#e.hasToolButtonsContainer;F(this,this.#e),U(this,this.#e),V(this,this.#e,this.#R());const r=this.#e.lightDomTitle,s=this.#e.hasToolButtonsContainer;if(r&&!n||s&&!i){this.#t.markSourcesChanged(),this.#t.merge();const l=this.#n.querySelector(".tbw-shell-header");if(l){const c=Fe(this.#i.shell,this.#e,this.#i.icons?.toolPanel),a=document.createElement("div");a.innerHTML=c;const h=a.firstElementChild;h&&(l.replaceWith(h),this.#X())}}},o=()=>{this.__lightDomColumnsCache=void 0,this.#A()};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,K(this),this.#t.parseLightDomColumns(this);const e=this.#e.lightDomTitle,o=this.#e.hasToolButtonsContainer;F(this,this.#e),U(this,this.#e),V(this,this.#e,this.#R());const n=this.#e.lightDomTitle,i=this.#e.hasToolButtonsContainer;if(n&&!e||i&&!o){this.#t.markSourcesChanged(),this.#t.merge();const s=this.#n.querySelector(".tbw-shell-header");if(s){const l=Fe(this.#i.shell,this.#e,this.#i.icons?.toolPanel),c=document.createElement("div");c.innerHTML=l;const a=c.firstElementChild;a&&(s.replaceWith(a),this.#X())}}this.#l.requestPhase(x.COLUMNS,"refreshColumns")}#G(e){const o=this._virtualization.rowHeight,n=this._virtualization.container??this,i=this._virtualization.viewportEl??n,r=n.clientHeight,s=i.clientHeight,c=this.shadowRoot?.querySelector(".tbw-scroll-area"),a=c?c.clientHeight:r,u=a-s,g=this.#o?.getExtraHeight()??0,f=Math.max(0,r-a);return e*o+u+g+f}refreshVirtualWindow(e=!1,o=!1){if(!this._bodyEl)return;const n=this._rows.length;if(!this._virtualization.enabled){this.#F(0,n),o||this.#o?.afterRender();return}if(this._rows.length<=this._virtualization.bypassThreshold){this._virtualization.start=0,this._virtualization.end=n,e&&(this._bodyEl.style.transform="translateY(0px)"),this.#F(0,n,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${this.#G(n)}px`),this.#ie(n,this._visibleColumns.length),o||this.#o?.afterRender();return}const i=this._virtualization.container??this,r=this._virtualization.viewportEl??i,s=r.clientHeight,l=this._virtualization.rowHeight,c=i.scrollTop;let a=Math.floor(c/l),h=0;const u=10;for(;h<u;){const C=this.#o?.getExtraHeightBefore?.(a)??0,A=Math.floor((c-C)/l);if(A>=a||A<0)break;a=A,h++}a=a-a%2,a<0&&(a=0);const g=this.#o?.adjustVirtualStart(a,c,l);g!==void 0&&g<a&&(a=g,a=a-a%2,a<0&&(a=0));const f=Math.ceil(s/l)+3;let p=a+f;if(p>n&&(p=n),this._virtualization.start=a,this._virtualization.end=p,i.clientHeight===0&&s>0){this.#l.requestPhase(x.VIRTUALIZATION,"stale-refs-retry");return}const w=this.#G(n);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${w}px`);const b=this.#o?.getExtraHeightBefore?.(a)??0,T=-(c-a*l-b);this._bodyEl.style.transform=`translateY(${T}px)`,this.#F(a,p,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this.#ie(n,this._visibleColumns.length),e&&!o&&(this.#o?.afterRender(),queueMicrotask(()=>{const C=i.clientHeight,A=r.clientHeight;if(C===0&&A>0)return;const m=this.#G(n);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${m}px`)}))}#B(){F(this,this.#e),U(this,this.#e),V(this,this.#e,this.#R()),this.#t.markSourcesChanged(),this.#t.merge();const e=this.#i?.shell;Vt(this.#n,e,{isPanelOpen:this.#e.isPanelOpen,expandedSections:this.#e.expandedSections},this.#i?.icons)&&(this.#X(),this.#a.setInitialized(!0))}#X(){kt(this.#n,this.#i?.shell,this.#e,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#D?.(),this.#D=qt(this.#n,this.#i?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)})}}customElements.get(L.tagName)||customElements.define(L.tagName,L),globalThis.DataGridElement=L;const ro={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"};class so{static dependencies;static manifest;version=typeof __GRID_VERSION__<"u"?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#n;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#n?.abort(),this.#n=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#n?.abort(),this.#n=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,o){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:o,bubbles:!0}))}emitCancelable(e,o){const n=new CustomEvent(e,{detail:o,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(n),n.defaultPrevented}requestRender(){this.grid?.requestRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}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 gridElement(){return this.grid}get disconnectSignal(){return this.#n?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...z,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(e===!1||e==="off")return!1;if(e===!0||e==="on")return!0;const o=this.gridElement;return o?getComputedStyle(o).getPropertyValue("--tbw-animation-enabled").trim()!=="0":!0}get animationDuration(){const e=this.gridElement;if(e){const o=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),n=parseInt(o,10);if(!isNaN(n))return n}return 200}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 P={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"},X={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"},lo={ROOT:`.${P.ROOT}`,HEADER:`.${P.HEADER}`,HEADER_ROW:`.${P.HEADER_ROW}`,HEADER_CELL:`.${P.HEADER_CELL}`,ROWS_VIEWPORT:`.${P.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${P.ROWS_CONTAINER}`,DATA_ROW:`.${P.DATA_ROW}`,DATA_CELL:`.${P.DATA_CELL}`,GROUP_ROW:`.${P.GROUP_ROW}`,ROW_BY_INDEX:t=>`.${P.DATA_ROW}[${X.ROW_INDEX}="${t}"]`,CELL_BY_FIELD:t=>`.${P.DATA_CELL}[${X.FIELD}="${t}"]`,CELL_AT:(t,e)=>`.${P.DATA_ROW}[${X.ROW_INDEX}="${t}"] .${P.DATA_CELL}[${X.COL_INDEX}="${e}"]`,SELECTED_ROWS:`.${P.DATA_ROW}.${P.SELECTED}`,EDITING_CELL:`.${P.DATA_CELL}.${P.EDITING}`},ao={COLOR_BG:"--tbw-color-bg",COLOR_FG:"--tbw-color-fg",COLOR_FG_MUTED:"--tbw-color-fg-muted",COLOR_BORDER:"--tbw-color-border",COLOR_ACCENT:"--tbw-color-accent",COLOR_HEADER_BG:"--tbw-color-header-bg",COLOR_HEADER_FG:"--tbw-color-header-fg",COLOR_SELECTION:"--tbw-color-selection",COLOR_ROW_HOVER:"--tbw-color-row-hover",COLOR_ROW_ALT:"--tbw-color-row-alt",ROW_HEIGHT:"--tbw-row-height",HEADER_HEIGHT:"--tbw-header-height",CELL_PADDING:"--tbw-cell-padding",FONT_FAMILY:"--tbw-font-family",FONT_SIZE:"--tbw-font-size",BORDER_RADIUS:"--tbw-border-radius",FOCUS_OUTLINE:"--tbw-focus-outline"};function co(t){const e=document.createElement("tbw-grid");return t&&(e.gridConfig=t),e}function ho(t,e=document){return e.querySelector(t)}const uo={CELL_CHANGE:"cell-change",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",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change"},fo={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"},he={sum:(t,e)=>t.reduce((o,n)=>o+(Number(n[e])||0),0),avg:(t,e)=>{const o=t.reduce((n,i)=>n+(Number(i[e])||0),0);return t.length?o/t.length:0},count:t=>t.length,min:(t,e)=>Math.min(...t.map(o=>Number(o[e])||1/0)),max:(t,e)=>Math.max(...t.map(o=>Number(o[e])||-1/0)),first:(t,e)=>t[0]?.[e],last:(t,e)=>t[t.length-1]?.[e]},Y=new Map,M={register(t,e){Y.set(t,e)},unregister(t){Y.delete(t)},get(t){if(t!==void 0)return typeof t=="function"?t:Y.get(t)??he[t]},run(t,e,o,n){const i=this.get(t);return i?i(e,o,n):void 0},has(t){return Y.has(t)||t in he},list(){return[...Object.keys(he),...Y.keys()]}},Ke={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 Ze(t){return Ke[t]??Ke.sum}function go(t,e){return Ze(t)(e)}const po=M.register.bind(M),wo=M.unregister.bind(M),bo=M.get.bind(M),mo=M.run.bind(M),vo=M.list.bind(M);v.BaseGridPlugin=so,v.DEFAULT_ANIMATION_CONFIG=fe,v.DEFAULT_GRID_ICONS=z,v.DGEvents=uo,v.DataGridElement=L,v.FitModeEnum=W,v.GridCSSVars=ao,v.GridClasses=P,v.GridDataAttrs=X,v.GridElement=L,v.GridSelectors=lo,v.PLUGIN_QUERIES=ro,v.PluginEvents=fo,v.PluginManager=je,v.RenderPhase=x,v.aggregatorRegistry=M,v.builtInSort=Le,v.createGrid=co,v.defaultComparator=Pe,v.getAggregator=bo,v.getValueAggregator=Ze,v.listAggregators=vo,v.queryGrid=ho,v.registerAggregator=po,v.runAggregator=mo,v.runValueAggregator=go,v.unregisterAggregator=wo,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
|
61
61
|
//# sourceMappingURL=grid.umd.js.map
|