@toolbox-web/grid 3.8.3 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.d.ts +1 -0
- package/all.js +1 -1
- package/all.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +14 -0
- package/lib/core/plugin/plugin-manager.d.ts +5 -1
- package/lib/core/plugin/types.d.ts +2 -0
- package/lib/features/registry.js +1 -1
- package/lib/plugins/clipboard/index.js +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/index.js +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/grouping-rows-plugin.d.ts +20 -24
- package/lib/plugins/grouping-rows/grouping-rows.d.ts +9 -4
- package/lib/plugins/grouping-rows/index.d.ts +1 -1
- package/lib/plugins/grouping-rows/index.js +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/grouping-rows/types.d.ts +32 -4
- package/lib/plugins/hierarchy/hierarchy-plugin.d.ts +79 -0
- package/lib/plugins/hierarchy/hierarchy.d.ts +28 -0
- package/lib/plugins/hierarchy/index.d.ts +9 -0
- package/lib/plugins/hierarchy/index.js +2 -0
- package/lib/plugins/hierarchy/index.js.map +1 -0
- package/lib/plugins/hierarchy/types.d.ts +92 -0
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder-columns/index.js +1 -1
- package/lib/plugins/reorder-columns/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-drag-drop/index.js +1 -1
- package/lib/plugins/row-drag-drop/index.js.map +1 -1
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/shell/index.js +1 -1
- package/lib/plugins/shell/index.js.map +1 -1
- package/lib/plugins/sticky-rows/index.js +1 -1
- package/lib/plugins/sticky-rows/index.js.map +1 -1
- package/lib/plugins/tooltip/index.js +1 -1
- package/lib/plugins/tooltip/index.js.map +1 -1
- package/lib/plugins/tree/index.js +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/tree-datasource.d.ts +7 -10
- package/lib/plugins/tree/tree-plugin.d.ts +23 -3
- package/lib/plugins/undo-redo/index.js +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +1 -1
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +1 -1
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/hierarchy.umd.js +2 -0
- package/umd/plugins/hierarchy.umd.js.map +1 -0
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function e(e,i,r,n){return`${t(r,n)} ${e}: ${i}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(e)}`}var i="editing";function r(t,e){if(!e.capped)return t;const i=e.spacerHeight-e.viewportHeight,r=e.rawContentHeight-e.viewportHeight;return i<=0||r<=0?t:t*i/r}function n(t,e){!function(t){if(!t._virtualization?.enabled)return;const{rowHeight:e,container:i,viewportEl:n,scrollMapping:o}=t._virtualization,s=i,a=n?.clientHeight??s?.clientHeight??0;if(!s||a<=0)return;const d=t._getVerticalScrollOffsets?.(t._focusRow)??{top:0,bottom:0};if(d.skipScroll)return;const l=Math.max(0,d.top),c=a-l-Math.max(0,d.bottom);if(c<=0)return;const u=t._focusRow*e,h=o?function(t,e){if(!e.capped)return t;const i=e.spacerHeight-e.viewportHeight,r=e.rawContentHeight-e.viewportHeight;if(i<=0||r<=0)return t;const n=t*r/i;return n<0?0:n>r?r:n}(s.scrollTop,o):s.scrollTop;if(u<h+l){const t=Math.max(0,u-l);s.scrollTop=o?r(t,o):t}else if(u+e>h+l+c){const t=Math.max(0,u-c+e-l);s.scrollTop=o?r(t,o):t}}(t);const n=function(t){return void 0!==t._activeEditRows&&-1!==t._activeEditRows}(t)||!!t._isGridEditMode;var o;n||t.refreshVirtualWindow(!1),(o=t._bodyEl)&&o.querySelectorAll(".cell-focus").forEach(t=>t.classList.remove("cell-focus")),Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(t=>{t.setAttribute("aria-selected","false")});const s=function(t){const e=t._focusRow,i=t._virtualization.start??0,r=t._virtualization.end??t._rows.length;if(e<i||e>=r)return;const n=t._bodyEl.querySelectorAll(".data-grid-row")[e-i];let o=n?.children[t._focusCol];return o&&o.classList?.contains("cell")||(o=n?.querySelector(`.cell[data-col="${t._focusCol}"]`)??n?.querySelector(".cell[data-col]")),o?{rowEl:n??null,cell:o}:void 0}(t);if(!s)return;const{rowEl:a,cell:d}=s;d.classList.add("cell-focus"),d.setAttribute("aria-selected","true"),n&&!e?.forceHorizontalScroll||function(t,e,i,r){const n=t.querySelector(".tbw-scroll-area");if(!n)return;if(r?.forceScrollLeft)return void(n.scrollLeft=0);if(r?.forceScrollRight)return void(n.scrollLeft=n.scrollWidth-n.clientWidth);const o=t._getHorizontalScrollOffsets?.(e??void 0,i)??{left:0,right:0};if(o.skipScroll)return;const s=i.getBoundingClientRect(),a=n.getBoundingClientRect(),d=s.left-a.left+n.scrollLeft,l=d+s.width,c=n.scrollLeft+o.left,u=n.scrollLeft+n.clientWidth-o.right;d<c?n.scrollLeft=d-o.left:l>u&&(n.scrollLeft=l-n.clientWidth+o.right)}(t,a,d,e),function(t,e,r){if(r&&e.classList.contains(i)){const t=e.querySelector('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])');if(t&&document.activeElement!==t)try{t.focus({preventScroll:!0})}catch{}return}if(r){if(e.contains(document.activeElement))return;e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1");try{e.focus({preventScroll:!0})}catch{}return}const n=document.activeElement;n instanceof HTMLElement&&n!==t&&"function"==typeof t.contains&&t.contains(n)&&!n.classList.contains("cell")&&!n.closest(".cell")||n===t||t.focus({preventScroll:!0})}(t,d,n)}var o=/{{\s*([^}]+)\s*}}/g,s="__DG_EMPTY__",a=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,d="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(t=>t.split("").reverse().join("")),l=new RegExp(`__(proto|defineGetter|defineSetter)|${d.slice(3).join("|")}|this\\b`);var c=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|math".split("|")),u=/^on\w+$/i,h=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),p=/^\s*(javascript|vbscript|data|blob):/i;function g(t){const e=document.createElement("template");return t&&"string"==typeof t&&(e.innerHTML=t,function(t){const e=[],i=t.querySelectorAll("*");for(const r of i){const t=r.tagName.toLowerCase();if(c.has(t)){e.push(r);continue}if(("svg"===t||"http://www.w3.org/2000/svg"===r.namespaceURI)&&Array.from(r.attributes).some(t=>u.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(r);continue}const i=[];for(const e of r.attributes){const t=e.name.toLowerCase();u.test(t)?i.push(e.name):"is"!==t?(h.has(t)&&p.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&i.push(e.name):i.push(e.name)}i.forEach(t=>r.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content)),e.content}function f(t,e){e&&"string"==typeof e?-1!==e.indexOf("<")||-1!==e.indexOf("&")?t.replaceChildren(g(e)):t.textContent=e:t.replaceChildren()}function m(t,e){const i=function(t){const e=[];let i=0;for(;i<t.length;){const r=t[i];if(" "!==r){if(r>="0"&&r<="9"||"."===r&&i+1<t.length&&t[i+1]>="0"&&t[i+1]<="9"){const r=i;for(;i<t.length&&(t[i]>="0"&&t[i]<="9"||"."===t[i]);)i++;e.push({type:"num",v:Number(t.slice(r,i))});continue}if("'"===r){let r="";for(i++;i<t.length&&"'"!==t[i];)r+=t[i++];if(i>=t.length)return null;i++,e.push({type:"str",v:r});continue}if(r>="a"&&r<="z"||r>="A"&&r<="Z"||"_"===r||"$"===r){const r=i;for(;i<t.length&&/[\w$.]/.test(t[i]);)i++;e.push({type:"id",v:t.slice(r,i)});continue}if(i+2<t.length){const r=t.slice(i,i+3);if("==="===r||"!=="===r){e.push({type:"op",v:r}),i+=3;continue}}if(i+1<t.length){const r=t.slice(i,i+2);if("=="===r||"!="===r||"<="===r||">="===r||"&&"===r||"||"===r){e.push({type:"op",v:r}),i+=2;continue}}if(!"+-*/%<>!?:(),".includes(r))return null;e.push({type:"op",v:r}),i++}else i++}return e}(t);if(!i)return;const r=i;let n=0;function o(){return r[n]}function s(){return r[n++]}function a(t,e){const i=o();return!!i&&(i.type===t&&(void 0===e||i.v===e))}function d(){const t=function(){let t=l();for(;a("op","||");)s(),t=t||l();return t}();if(a("op","?")){s();const e=d();if(!a("op",":"))return;s();const i=d();return t?e:i}return t}function l(){let t=c();for(;a("op","&&");)s(),t=t&&c();return t}function c(){let t=u();for(;;){const e=o();if(!e||"op"!==e.type)break;if("==="===e.v)s(),t=t===u();else if("!=="===e.v)s(),t=t!==u();else if("=="===e.v)s(),t=t==u();else{if("!="!==e.v)break;s(),t=t!=u()}}return t}function u(){let t=h();for(;;){const e=o();if(!e||"op"!==e.type)break;if("<"===e.v)s(),t=t<h();else if(">"===e.v)s(),t=t>h();else if("<="===e.v)s(),t=t<=h();else{if(">="!==e.v)break;s(),t=t>=h()}}return t}function h(){let t=p();for(;;){const e=o();if(!e||"op"!==e.type)break;if("+"===e.v)s(),t+=p();else{if("-"!==e.v)break;s(),t-=p()}}return t}function p(){let t=g();for(;;){const e=o();if(!e||"op"!==e.type)break;if("*"===e.v)s(),t*=g();else if("/"===e.v)s(),t/=g();else{if("%"!==e.v)break;s(),t%=g()}}return t}function g(){return a("op","!")?(s(),!g()):f()}function f(){const t=o();if(t){if("num"===t.type)return s(),t.v;if("str"===t.type)return s(),t.v;if("id"===t.type)return s(),function(t){if("value"===t)return e.value;if(t.startsWith("row.")){const i=t.slice(4);return e.row?e.row[i]:void 0}if(t.startsWith("typeDefault.")){const i=t.slice(12);return e.typeDefault?e.typeDefault[i]:void 0}return"row"===t?e.row:"typeDefault"===t?e.typeDefault:void 0}(t.v);if("op"===t.type&&"("===t.v){s();const t=d();return a("op",")")&&s(),t}return"op"===t.type&&"-"===t.v?(s(),-f()):void 0}}const m=d();return n<r.length?void 0:m}function v(t,e){if(!t||-1===t.indexOf("{{"))return t;const i=[],r=(n=t.replace(o,(t,r)=>{const n=function(t,e){if(!(t=(t||"").trim()))return s;if(w.test(t))return s;if("value"===t)return null==e.value?s:String(e.value);if(t.startsWith("row.")&&!/[()?]/.test(t)&&!t.includes(":")){const i=t.slice(4),r=e.row?e.row[i]:void 0;return null==r?s:String(r)}if(t.startsWith("typeDefault.")&&!/[()?]/.test(t)&&!t.includes(":")){const i=t.slice(12),r=e.typeDefault?e.typeDefault[i]:void 0;return null==r?s:String(r)}if(t.length>80)return s;if(!a.test(t)||l.test(t))return s;const i=t.match(/\./g);if(i&&i.length>1)return s;try{const i=m(t,e),r=null==i?"":String(i);return w.test(r)?s:r||s}catch{return s}}(r,e);return i.push({expr:r.trim(),result:n}),n===s?n:(o=n)&&"string"==typeof o?o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):"";var o}),n?n.replace(new RegExp(s,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):n);var n;const d=i.length&&i.every(t=>""===t.result||t.result===s);return w.test(t)||d?"":r}var w=/Reflect|Proxy|ownKeys/;var b={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var y=class{static dependencies;static manifest;aliases;version="3.8.3";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}get resolvedConfig(){return this.#t?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(t){if(0===t.length)return;const i={...this.userConfig},r={};for(const e of Object.keys(i))r[e]=this;for(const n of t){const t=n.userConfig;for(const[o,s]of Object.entries(t)){if(void 0===s)continue;if(!(o in i)){i[o]=s,r[o]=n;continue}if(i[o]===s)continue;const t=r[o]?.constructor.name??this.constructor.name,a=n.constructor.name,d=e("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${o}" supplied by both ${t} and ${a}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(d)}}Object.assign(this.userConfig,i)}refreshUserConfigFrom(t){const e=this.userConfig,i={...t.userConfig};for(const r of Object.keys(e))delete e[r];Object.assign(e,i)}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}broadcast(t,e){this.emitPluginEvent(t,e),this.emit(t,e)}queryBoolean(t,e=null){const i=this.grid?.query?.(t,e);return Array.isArray(i)?i.some(Boolean):!!i}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}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?._hostElement}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...b,...t}}t(t,e){return this.grid?.effectiveConfig?.locale?.[t]??e}get translate(){return(t,e)=>this.t(t,e)}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;return!e||"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(e,10);if(!isNaN(i))return i}return 200}setIcon(t,e,i){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const r=this.#e(e,i);void 0!==r?"string"==typeof r?f(t,r):r instanceof HTMLElement&&t.replaceChildren(r.cloneNode(!0)):t.innerHTML=""}#e(t,e){return void 0!==e?e:this.grid?.gridConfig?.icons?.[t]}updateSortIndicator(t,e){t.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const i=document.createElement("span");i.setAttribute("part","sort-indicator"),i.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(i,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(i,"sortNone"));const r=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return r?t.insertBefore(i,r):t.appendChild(i),i}warn(i,r){void 0!==r?console.warn(e(i,r,this.gridElement.id,this.name)):console.warn(`${t(this.gridElement.id,this.name)} ${i}`)}throwDiagnostic(t,i){throw new Error(e(t,i,this.gridElement.id,this.name))}},R=0,C=/* @__PURE__ */new Set,A="tbw-responsive-column-fade",k="data-responsive-column-fade";function S(t){for(const e of t.getAnimations?.()??[])e.id===A&&(e.finished?.catch(()=>{}),e.cancel())}function E(t){return t.startsWith("minmax(")?t.includes("fr")?"minmax(0px, 0fr)":"minmax(0px, 0px)":t.endsWith("fr")?"0fr":t.endsWith("%")?"0%":"0px"}var _=class extends y{name="responsive";version="1.0.0";styles='tbw-grid[data-responsive-transition]::view-transition-group(*){animation-duration:var(--tbw-responsive-duration,.2s)}tbw-grid[data-responsive-transition] .data-grid-row>.cell{view-transition-class:tbw-responsive-cell}tbw-grid[data-responsive-transition]::view-transition-group(.tbw-responsive-cell){animation-timing-function:ease-in-out}tbw-grid[data-responsive-transition]::view-transition-old(.tbw-responsive-cell){object-fit:none;object-position:right center;width:100%;height:100%}tbw-grid[data-responsive-transition]::view-transition-new(.tbw-responsive-cell){object-fit:none;object-position:right center;width:100%;height:100%}tbw-grid[data-responsive-transition]::view-transition-old(.tbw-responsive-cell){animation-duration:calc(var(--tbw-responsive-duration,.2s) * .35)}tbw-grid[data-responsive-transition]::view-transition-new(.tbw-responsive-cell){animation-duration:calc(var(--tbw-responsive-duration,.2s) * .35)}tbw-grid[data-responsive-animate] .data-grid-row,tbw-grid[data-responsive-animate] .data-grid-row>.cell{transition:opacity var(--tbw-responsive-duration,.2s) ease-out, transform var(--tbw-responsive-duration,.2s) ease-out}tbw-grid[data-responsive][data-responsive-animate] .data-grid-row{animation:responsive-card-enter var(--tbw-responsive-duration,.2s) ease-out}@keyframes responsive-card-enter{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}tbw-grid[data-responsive] .header{display:none!important}tbw-grid[data-responsive] .footer-row{display:none}tbw-grid[data-responsive] .tbw-scroll-area{overflow-x:hidden;min-width:0!important}tbw-grid[data-responsive] .rows-body-wrapper{min-width:0!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row){padding:var(--tbw-cell-padding);border-bottom:1px solid var(--tbw-color-border);background:var(--tbw-color-bg);padding-inline-start:var(--tbw-spacing-xl);position:relative;contain:none!important;content-visibility:visible!important;grid-template-columns:none!important;display:block!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row):nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid[data-responsive] .data-grid-row:not(.group-row):hover{background:var(--tbw-color-row-hover)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)[aria-selected=true]{background:var(--tbw-color-selection)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)[aria-selected=true]:before{content:"";background:var(--tbw-color-accent);inset-inline-start:0;width:4px;position:absolute;top:0;bottom:0}tbw-grid[data-responsive] .data-grid-row:not(.group-row,.responsive-card){height:auto!important;min-height:auto!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell{padding:var(--tbw-spacing-xs) var(--tbw-spacing-md);justify-content:space-between;align-items:center;white-space:normal!important;border:none!important;background:0 0!important;border-inline-end:none!important;width:100%!important;min-width:0!important;height:auto!important;min-height:auto!important;line-height:1.5!important;display:flex!important;position:static!important;left:auto!important;right:auto!important;overflow:visible!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell:before{content:attr(data-header) ": ";color:var(--tbw-color-header-fg);min-width:100px;flex-shrink:0;margin-inline-end:var(--tbw-spacing-md);font-weight:600}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell:after{content:none}tbw-grid[data-responsive] .cell[data-utility],tbw-grid[data-responsive] .data-grid-row>.cell[data-responsive-hidden],tbw-grid[data-responsive] .data-grid-row>.cell[data-responsive-value-only]:before{display:none!important}tbw-grid[data-responsive] .data-grid-row>.cell[data-responsive-value-only]{font-weight:500;justify-content:flex-start!important}tbw-grid[data-responsive][data-responsive-hide-header] .data-grid-row:not(.group-row)>.cell:before{display:none!important}tbw-grid:not([data-responsive]) .cell[data-responsive-hidden]{pointer-events:none;opacity:0;border-inline-width:0!important;padding-inline:0!important;overflow:hidden!important}tbw-grid[data-responsive-column-fade] :is(.header-row,.data-grid-row){transition:grid-template-columns var(--tbw-responsive-duration,.2s) ease-out}tbw-grid[data-responsive] .tbw-footer,tbw-grid[data-responsive] .tbw-header-pinned,tbw-grid[data-responsive] .tbw-pinned-rows,tbw-grid[data-responsive] .tbw-aggregation-rows{display:none!important}tbw-grid[data-responsive] .tbw-pinned-rows,tbw-grid[data-responsive] .tbw-aggregation-rows,tbw-grid[data-responsive] .tbw-aggregation-row{min-width:0!important}tbw-grid[data-responsive] .data-grid-row.responsive-card{padding:var(--tbw-cell-padding);border-bottom:1px solid var(--tbw-color-border);display:block!important}tbw-grid[data-responsive] .data-grid-row.responsive-card>*{width:100%}tbw-grid[data-responsive] .data-grid-row.responsive-card .cell:before{display:none}';static manifest={queries:[{type:"isCardMode",description:"Returns whether the grid is currently in responsive card mode"}]};#i;#r=!1;#n;#o=!1;#s=0;#a;#d=Number.NEGATIVE_INFINITY;#l=++R;#c=`tbw-responsive-row-${this.#l}-`;#u=`tbw-responsive-cell-${this.#l}-`;#h=0;#p=/* @__PURE__ */new Set;#g=C;#f=/* @__PURE__ */new Set;#m=C;#v=/* @__PURE__ */new Set;#w=/* @__PURE__ */new Set;#b=0;#y;#R=!1;#C=null;#A=[];get#k(){return this.grid}isResponsive(){return this.#r}setResponsive(t){t!==this.#r&&(this.#r=t,this.#S(),this.emit("responsive-change",{isResponsive:t,width:this.#s,breakpoint:this.config.breakpoint??0}))}setBreakpoint(t){this.config.breakpoint=t,this.#a=void 0,this.#E(this.#s)}setCardRenderer(t){this.config.cardRenderer=t,this.#r&&this.requestRender()}getWidth(){return this.#s}getActiveBreakpoint(){return this.#C}attach(t){super.attach(t),this.#_(),this.#H(this.config.hiddenColumns),this.config.breakpoints?.length&&(this.#A=[...this.config.breakpoints].sort((t,e)=>e.maxWidth-t.maxWidth)),this.#x(),this.#M(),this.#F=void 0,this.#T=void 0,this.#r&&this.requestRender(),this.#i=new ResizeObserver(t=>{this.#W(t[0]?.contentRect.width??0)}),this.#i.observe(this.gridElement)}#W(t){if(this.#s=t,t===this.#a)return;const e=this.config.debounceMs??100,i=performance.now()-this.#d;if(clearTimeout(this.#n),i>=e)return this.#a=t,void this.#E(t);this.#n=setTimeout(()=>{this.#a=this.#s,this.#E(this.#s)},e-i)}#_(){const t=this.gridElement;if(!t)return;const e=t.querySelector("tbw-grid-responsive-card");if(!e)return;const i=this.#k.__frameworkAdapter;if(i?.parseResponsiveCardElement){const t=i.parseResponsiveCardElement(e);t&&(this.config={...this.config,cardRenderer:t})}const r=e.getAttribute("breakpoint"),n=e.getAttribute("card-row-height"),o=e.getAttribute("hidden-columns"),s=e.getAttribute("hide-header"),a=e.getAttribute("debounce-ms"),d={};if(null!==r){const t=parseInt(r,10);isNaN(t)||(d.breakpoint=t)}if(null!==n&&(d.cardRowHeight="auto"===n?"auto":parseInt(n,10)),null!==o&&(d.hiddenColumns=o.split(",").map(t=>t.trim()).filter(t=>t.length>0)),null!==s&&(d.hideHeader="false"!==s),null!==a){const t=parseInt(a,10);isNaN(t)||(d.debounceMs=t)}const l=e.innerHTML.trim();!l||this.config.cardRenderer||i?.parseResponsiveCardElement||(d.cardRenderer=t=>{const e=v(l,{value:t,row:t}),i=document.createElement("div");return i.className="tbw-responsive-card-content",f(i,e),i}),Object.keys(d).length>0&&(this.config={...this.config,...d})}#H(t){this.#p=/* @__PURE__ */new Set,this.#f.clear();for(const e of t??[])"string"==typeof e?this.#p.add(e):e.showValue?this.#f.add(e.field):this.#p.add(e.field);this.#q()}get#L(){return this.#A.length>0?null!==this.#C:this.#r}#q(){const t=this.#L?this.#p:C;for(const e of this.#g)t.has(e)||this.#G(e,!1);for(const e of t)this.#g.has(e)||this.#G(e,!0);this.#O()}#G(t,e){(e?this.#w:this.#v).delete(t),(e?this.#v:this.#w).add(t)}#O(){const t=this.#D;t<=0||0===this.#v.size&&0===this.#w.size?this.#B():(this.#b=performance.now()+t,this.gridElement?.setAttribute(k,""),clearTimeout(this.#y),this.#y=setTimeout(()=>this.#B(),t))}#B(){clearTimeout(this.#y),this.#y=void 0,this.#b=0,this.#v.clear(),this.#w.clear(),this.gridElement?.removeAttribute(k);for(const t of this.gridElement?.querySelectorAll(".cell[data-field]")??[])S(t)}#$(t,e,i,r){S(t);const n=e?[{opacity:1},{opacity:0}]:[{opacity:0},{opacity:1}],o=t.animate?.(n,{duration:i,easing:"ease-out",fill:e?"forwards":"none"});o&&(o.id=A,o.currentTime=r)}#z(t){const e=this.#k?._gridTemplate??"";if(!e)return;const i=this.visibleColumns,r=function(t){const e=[];let i=0,r=0;for(let n=0;n<t.length;n++){const o=t[n];"("===o?i++:")"===o?i--:" "===o&&0===i&&(n>r&&e.push(t.slice(r,n)),r=n+1)}return r<t.length&&e.push(t.slice(r)),e}(e);let n=!1;if(t.size>0&&r.length===i.length)for(let o=0;o<i.length;o++){const e=i[o]?.field;e&&t.has(e)&&(r[o]=E(r[o]),n=!0)}(n||this.#R)&&(this.gridElement.style.setProperty("--tbw-column-template",n?r.join(" "):e),this.#R=n)}detach(){if(this.#i?.disconnect(),this.#i=void 0,this.#B(),clearTimeout(this.#n),this.#n=void 0,this.#a=void 0,this.#d=Number.NEGATIVE_INFINITY,this.gridElement){this.gridElement.removeAttribute("data-responsive"),this.gridElement.removeAttribute("data-responsive-animate"),this.gridElement.removeAttribute("data-responsive-hide-header"),this.gridElement.removeAttribute("data-responsive-transition");for(const t of this.gridElement.querySelectorAll(".cell[data-responsive-hidden], .cell[data-responsive-value-only]"))t.removeAttribute("data-responsive-hidden"),t.removeAttribute("data-responsive-value-only"),t.removeAttribute("aria-hidden");this.#I()}this.#g=C,this.#m=C,super.detach()}handleQuery(t){if("isCardMode"===t.type)return this.#r}afterRender(){this.#N();const t=this.#A.length>0?null!==this.#C:this.#r,e=t?this.#p:C,i=t?this.#f:C,r=this.#v.size>0||this.#w.size>0,n=this.#g.size>0||this.#m.size>0;if(this.#g=e,this.#m=i,this.#z(this.#r?C:e),0===e.size&&0===i.size&&!r&&!n)return;const o=this.#D,s=r?Math.min(o,Math.max(0,o-(this.#b-performance.now()))):0,a=this.gridElement.querySelectorAll(".cell[data-field]");for(const d of a){const t=d.getAttribute("data-field");if(!t)continue;const r=this.#v.has(t);(r||this.#w.has(t))&&this.#$(d,r,o,s),e.has(t)?(d.setAttribute("data-responsive-hidden",""),d.setAttribute("aria-hidden","true"),d.removeAttribute("data-responsive-value-only")):i.has(t)?(d.setAttribute("data-responsive-value-only",""),d.removeAttribute("data-responsive-hidden"),d.removeAttribute("aria-hidden")):(d.removeAttribute("data-responsive-hidden"),d.removeAttribute("data-responsive-value-only"),d.removeAttribute("aria-hidden"))}}#E(t){if(this.#A.length>0)return void this.#P(t);const e=this.config.breakpoint??0;0!==e||this.#o||(this.#o=!0,this.warn("TBW110","No breakpoint configured. Responsive mode is disabled. Set a breakpoint based on your grid's column count."));const i=e>0&&t<e;i!==this.#r&&(this.#r=i,this.#d=performance.now(),this.#S(),this.emit("responsive-change",{isResponsive:i,width:t,breakpoint:e}))}#P(t){let e=null;for(const i of this.#A)t<=i.maxWidth&&(e=i);if(e!==this.#C){this.#C=e,this.#d=performance.now(),e?.hiddenColumns?this.#H(e.hiddenColumns):this.#H(this.config.hiddenColumns);const i=!0===e?.cardLayout,r=i!==this.#r;r&&(this.#r=i),this.#S(r),this.emit("responsive-change",{isResponsive:this.#r,width:t,breakpoint:e?.maxWidth??0})}}#S(t=!0){this.#x(),t&&this.#B();const e=t?this.#j():null;if(!e)return t&&this.#V(),void this.requestRender();const i=this.gridElement,r=this.#Y(),n=++this.#h;"none"!==r&&this.#U(r),i.setAttribute("data-responsive-transition","");const o=e(async()=>{this.#V(),await(this.#k.forceLayout?.()),"none"!==r&&this.#U(r)}),s=()=>{n===this.#h&&(i.removeAttribute("data-responsive-transition"),"none"!==r&&this.#I())};o.finished.then(s,s),o.ready?.catch(()=>{})}get#K(){const{animation:t,animate:e}=this.config;return void 0!==t?t:!1!==e&&"fade"}get#D(){return!1!==this.#K&&this.isAnimationEnabled?this.config.animationDuration??200:0}#x(){this.gridElement.style.setProperty("--tbw-responsive-duration",`${this.#D}ms`)}#j(){if(!1===this.#K||!this.isAnimationEnabled)return null;const t=this.gridElement,e=t.startViewTransition;return"function"==typeof e?e.bind(t):null}get#J(){return"function"==typeof this.gridElement?.startViewTransition}#U(t){const e=this.gridElement.querySelectorAll(".data-grid-row[aria-rowindex]");for(const i of e){const e=i.getAttribute("aria-rowindex");if("rows"!==t)for(const t of i.querySelectorAll(":scope > .cell[aria-colindex]")){const i=`${this.#u}${e}-${t.getAttribute("aria-colindex")}`;t.style.setProperty("view-transition-name",i)}else i.style.setProperty("view-transition-name",`${this.#c}${e}`)}}#Y(){const t=this.#K;if("morph-cells"===t){const t=this.gridElement.querySelectorAll(".data-grid-row > .cell[aria-colindex]").length;return t>0&&t<=150?"cells":"rows"}return"morph-rows"===t?"rows":"none"}#I(){const t=this.gridElement.querySelectorAll(".data-grid-row, .data-grid-row > .cell");for(const e of t)e.style.removeProperty("view-transition-name")}#Z;#M(){this.gridElement.toggleAttribute("data-responsive",this.#r),this.gridElement.toggleAttribute("data-responsive-animate",!1!==this.#K&&!this.#J),this.gridElement.toggleAttribute("data-responsive-hide-header",this.#r&&!0===this.config.hideHeader)}#V(){this.#M();const t=this.#k;if(this.#r){t._virtualization&&(this.#Z=t._virtualization.rowHeight);const e=this.gridElement.querySelector(".tbw-scroll-area");e&&(e.scrollLeft=0)}else{const e=this.gridElement.querySelectorAll(".data-grid-row");for(const t of e)t.style.height="",t.classList.remove("responsive-card");this.#Z&&this.#Z>0&&t._virtualization&&(t._virtualization.rowHeight=this.#Z,this.#Z=void 0),this.#F=void 0,this.#T=void 0,this.#Q=void 0}}renderRow(t,e,i){if(!this.#r||!this.config.cardRenderer)return;if(t.__isGroupRow)return;e.replaceChildren();const r=this.config.cardRenderer(t,i);e.className="data-grid-row responsive-card";const n=this.config.cardRowHeight;return e.style.height="auto"===n||void 0===n?"auto":`${this.#X()}px`,r.hasAttribute("role")||(r.setAttribute("role","gridcell"),r.setAttribute("aria-colindex","1")),e.appendChild(r),!0}onKeyDown(t){if(!this.#r)return!1;if(this.config.cardRenderer&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(t.key))return!1;const e=this.rows.length-1,i=this.visibleColumns.length-1;switch(t.key){case"ArrowDown":if(this.grid._focusCol<i)return this.grid._focusCol+=1,t.preventDefault(),n(this.#k),!0;if(this.grid._focusRow<e)return this.grid._focusRow+=1,this.grid._focusCol=0,t.preventDefault(),n(this.#k),!0;break;case"ArrowUp":if(this.grid._focusCol>0)return this.grid._focusCol-=1,t.preventDefault(),n(this.#k),!0;if(this.grid._focusRow>0)return this.grid._focusRow-=1,this.grid._focusCol=i,t.preventDefault(),n(this.#k),!0;break;case"ArrowRight":if(this.grid._focusRow<e)return this.grid._focusRow+=1,t.preventDefault(),n(this.#k),!0;break;case"ArrowLeft":if(this.grid._focusRow>0)return this.grid._focusRow-=1,t.preventDefault(),n(this.#k),!0}return!1}#F;#T;#Q;#X(){const t=this.config.cardRowHeight,e=this.#F;return"number"==typeof t&&t>0?e&&e>t?e:t:e&&e>0?e:80}#tt(){return this.#T&&this.#T>0?this.#T:this.#Z??28}#et(){for(const t of this.rows)if(t.__isGroupRow)return!0;return!1}getRowHeight(t,e){if(this.#r&&this.config.cardRenderer)return t.__isGroupRow?this.#tt():this.#X()}#it(){let t=0;for(const e of this.rows)e.__isGroupRow||t++;return t}#rt=!1;#N(){if(!this.#r)return;let t=!1;const e=this.#k,i=this.#et(),r=this.#it();if(r!==this.#Q&&(this.#Q=r,t=!0),i){const e=this.gridElement.querySelector(".data-grid-row.group-row");if(e){const i=e.getBoundingClientRect().height;i>0&&i!==this.#T&&(this.#T=i,t=!0)}}const n=this.config.cardRenderer?".data-grid-row.responsive-card":".data-grid-row:not(.group-row)",o=this.gridElement.querySelector(n);if(o){const r=o.getBoundingClientRect().height;r>0&&r!==this.#F&&(this.#F=r,t=!0,!i&&e._virtualization&&(e._virtualization.rowHeight=r))}t&&!this.#rt&&(this.#rt=!0,queueMicrotask(()=>{this.#rt=!1,this.grid&&this.#r&&this.#k.refreshVirtualWindow?.(!0,!0)}))}};export{_ as ResponsivePlugin};
|
|
1
|
+
function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function e(e,i,r,n){return`${t(r,n)} ${e}: ${i}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(e)}`}var i="editing";function r(t,e){if(!e.capped)return t;const i=e.spacerHeight-e.viewportHeight,r=e.rawContentHeight-e.viewportHeight;return i<=0||r<=0?t:t*i/r}function n(t,e){!function(t){if(!t._virtualization?.enabled)return;const{rowHeight:e,container:i,viewportEl:n,scrollMapping:o}=t._virtualization,s=i,a=n?.clientHeight??s?.clientHeight??0;if(!s||a<=0)return;const d=t._getVerticalScrollOffsets?.(t._focusRow)??{top:0,bottom:0};if(d.skipScroll)return;const l=Math.max(0,d.top),c=a-l-Math.max(0,d.bottom);if(c<=0)return;const u=t._focusRow*e,h=o?function(t,e){if(!e.capped)return t;const i=e.spacerHeight-e.viewportHeight,r=e.rawContentHeight-e.viewportHeight;if(i<=0||r<=0)return t;const n=t*r/i;return n<0?0:n>r?r:n}(s.scrollTop,o):s.scrollTop;if(u<h+l){const t=Math.max(0,u-l);s.scrollTop=o?r(t,o):t}else if(u+e>h+l+c){const t=Math.max(0,u-c+e-l);s.scrollTop=o?r(t,o):t}}(t);const n=function(t){return void 0!==t._activeEditRows&&-1!==t._activeEditRows}(t)||!!t._isGridEditMode;var o;n||t.refreshVirtualWindow(!1),(o=t._bodyEl)&&o.querySelectorAll(".cell-focus").forEach(t=>t.classList.remove("cell-focus")),Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(t=>{t.setAttribute("aria-selected","false")});const s=function(t){const e=t._focusRow,i=t._virtualization.start??0,r=t._virtualization.end??t._rows.length;if(e<i||e>=r)return;const n=t._bodyEl.querySelectorAll(".data-grid-row")[e-i];let o=n?.children[t._focusCol];return o&&o.classList?.contains("cell")||(o=n?.querySelector(`.cell[data-col="${t._focusCol}"]`)??n?.querySelector(".cell[data-col]")),o?{rowEl:n??null,cell:o}:void 0}(t);if(!s)return;const{rowEl:a,cell:d}=s;d.classList.add("cell-focus"),d.setAttribute("aria-selected","true"),n&&!e?.forceHorizontalScroll||function(t,e,i,r){const n=t.querySelector(".tbw-scroll-area");if(!n)return;if(r?.forceScrollLeft)return void(n.scrollLeft=0);if(r?.forceScrollRight)return void(n.scrollLeft=n.scrollWidth-n.clientWidth);const o=t._getHorizontalScrollOffsets?.(e??void 0,i)??{left:0,right:0};if(o.skipScroll)return;const s=i.getBoundingClientRect(),a=n.getBoundingClientRect(),d=s.left-a.left+n.scrollLeft,l=d+s.width,c=n.scrollLeft+o.left,u=n.scrollLeft+n.clientWidth-o.right;d<c?n.scrollLeft=d-o.left:l>u&&(n.scrollLeft=l-n.clientWidth+o.right)}(t,a,d,e),function(t,e,r){if(r&&e.classList.contains(i)){const t=e.querySelector('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])');if(t&&document.activeElement!==t)try{t.focus({preventScroll:!0})}catch{}return}if(r){if(e.contains(document.activeElement))return;e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1");try{e.focus({preventScroll:!0})}catch{}return}const n=document.activeElement;n instanceof HTMLElement&&n!==t&&"function"==typeof t.contains&&t.contains(n)&&!n.classList.contains("cell")&&!n.closest(".cell")||n===t||t.focus({preventScroll:!0})}(t,d,n)}var o=/{{\s*([^}]+)\s*}}/g,s="__DG_EMPTY__",a=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,d="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(t=>t.split("").reverse().join("")),l=new RegExp(`__(proto|defineGetter|defineSetter)|${d.slice(3).join("|")}|this\\b`);var c=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|math".split("|")),u=/^on\w+$/i,h=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),p=/^\s*(javascript|vbscript|data|blob):/i;function g(t){const e=document.createElement("template");return t&&"string"==typeof t&&(e.innerHTML=t,function(t){const e=[],i=t.querySelectorAll("*");for(const r of i){const t=r.tagName.toLowerCase();if(c.has(t)){e.push(r);continue}if(("svg"===t||"http://www.w3.org/2000/svg"===r.namespaceURI)&&Array.from(r.attributes).some(t=>u.test(t.name)||"href"===t.name||"xlink:href"===t.name)){e.push(r);continue}const i=[];for(const e of r.attributes){const t=e.name.toLowerCase();u.test(t)?i.push(e.name):"is"!==t?(h.has(t)&&p.test(e.value)||"style"===t&&/expression\s*\(|javascript:|behavior\s*:/i.test(e.value))&&i.push(e.name):i.push(e.name)}i.forEach(t=>r.removeAttribute(t))}e.forEach(t=>t.remove())}(e.content)),e.content}function f(t,e){e&&"string"==typeof e?-1!==e.indexOf("<")||-1!==e.indexOf("&")?t.replaceChildren(g(e)):t.textContent=e:t.replaceChildren()}function m(t,e){const i=function(t){const e=[];let i=0;for(;i<t.length;){const r=t[i];if(" "!==r){if(r>="0"&&r<="9"||"."===r&&i+1<t.length&&t[i+1]>="0"&&t[i+1]<="9"){const r=i;for(;i<t.length&&(t[i]>="0"&&t[i]<="9"||"."===t[i]);)i++;e.push({type:"num",v:Number(t.slice(r,i))});continue}if("'"===r){let r="";for(i++;i<t.length&&"'"!==t[i];)r+=t[i++];if(i>=t.length)return null;i++,e.push({type:"str",v:r});continue}if(r>="a"&&r<="z"||r>="A"&&r<="Z"||"_"===r||"$"===r){const r=i;for(;i<t.length&&/[\w$.]/.test(t[i]);)i++;e.push({type:"id",v:t.slice(r,i)});continue}if(i+2<t.length){const r=t.slice(i,i+3);if("==="===r||"!=="===r){e.push({type:"op",v:r}),i+=3;continue}}if(i+1<t.length){const r=t.slice(i,i+2);if("=="===r||"!="===r||"<="===r||">="===r||"&&"===r||"||"===r){e.push({type:"op",v:r}),i+=2;continue}}if(!"+-*/%<>!?:(),".includes(r))return null;e.push({type:"op",v:r}),i++}else i++}return e}(t);if(!i)return;const r=i;let n=0;function o(){return r[n]}function s(){return r[n++]}function a(t,e){const i=o();return!!i&&(i.type===t&&(void 0===e||i.v===e))}function d(){const t=function(){let t=l();for(;a("op","||");)s(),t=t||l();return t}();if(a("op","?")){s();const e=d();if(!a("op",":"))return;s();const i=d();return t?e:i}return t}function l(){let t=c();for(;a("op","&&");)s(),t=t&&c();return t}function c(){let t=u();for(;;){const e=o();if(!e||"op"!==e.type)break;if("==="===e.v)s(),t=t===u();else if("!=="===e.v)s(),t=t!==u();else if("=="===e.v)s(),t=t==u();else{if("!="!==e.v)break;s(),t=t!=u()}}return t}function u(){let t=h();for(;;){const e=o();if(!e||"op"!==e.type)break;if("<"===e.v)s(),t=t<h();else if(">"===e.v)s(),t=t>h();else if("<="===e.v)s(),t=t<=h();else{if(">="!==e.v)break;s(),t=t>=h()}}return t}function h(){let t=p();for(;;){const e=o();if(!e||"op"!==e.type)break;if("+"===e.v)s(),t+=p();else{if("-"!==e.v)break;s(),t-=p()}}return t}function p(){let t=g();for(;;){const e=o();if(!e||"op"!==e.type)break;if("*"===e.v)s(),t*=g();else if("/"===e.v)s(),t/=g();else{if("%"!==e.v)break;s(),t%=g()}}return t}function g(){return a("op","!")?(s(),!g()):f()}function f(){const t=o();if(t){if("num"===t.type)return s(),t.v;if("str"===t.type)return s(),t.v;if("id"===t.type)return s(),function(t){if("value"===t)return e.value;if(t.startsWith("row.")){const i=t.slice(4);return e.row?e.row[i]:void 0}if(t.startsWith("typeDefault.")){const i=t.slice(12);return e.typeDefault?e.typeDefault[i]:void 0}return"row"===t?e.row:"typeDefault"===t?e.typeDefault:void 0}(t.v);if("op"===t.type&&"("===t.v){s();const t=d();return a("op",")")&&s(),t}return"op"===t.type&&"-"===t.v?(s(),-f()):void 0}}const m=d();return n<r.length?void 0:m}function v(t,e){if(!t||-1===t.indexOf("{{"))return t;const i=[],r=(n=t.replace(o,(t,r)=>{const n=function(t,e){if(!(t=(t||"").trim()))return s;if(w.test(t))return s;if("value"===t)return null==e.value?s:String(e.value);if(t.startsWith("row.")&&!/[()?]/.test(t)&&!t.includes(":")){const i=t.slice(4),r=e.row?e.row[i]:void 0;return null==r?s:String(r)}if(t.startsWith("typeDefault.")&&!/[()?]/.test(t)&&!t.includes(":")){const i=t.slice(12),r=e.typeDefault?e.typeDefault[i]:void 0;return null==r?s:String(r)}if(t.length>80)return s;if(!a.test(t)||l.test(t))return s;const i=t.match(/\./g);if(i&&i.length>1)return s;try{const i=m(t,e),r=null==i?"":String(i);return w.test(r)?s:r||s}catch{return s}}(r,e);return i.push({expr:r.trim(),result:n}),n===s?n:(o=n)&&"string"==typeof o?o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):"";var o}),n?n.replace(new RegExp(s,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):n);var n;const d=i.length&&i.every(t=>""===t.result||t.result===s);return w.test(t)||d?"":r}var w=/Reflect|Proxy|ownKeys/;var b={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};var y=class{static dependencies;static manifest;aliases;version="3.9.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}get resolvedConfig(){return this.#t?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(t){if(0===t.length)return;const i={...this.userConfig},r={};for(const e of Object.keys(i))r[e]=this;for(const n of t){const t=n.userConfig;for(const[o,s]of Object.entries(t)){if(void 0===s)continue;if(!(o in i)){i[o]=s,r[o]=n;continue}if(i[o]===s)continue;const t=r[o]?.constructor.name??this.constructor.name,a=n.constructor.name,d=e("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${o}" supplied by both ${t} and ${a}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(d)}}Object.assign(this.userConfig,i)}refreshUserConfigFrom(t){const e=this.userConfig,i={...t.userConfig};for(const r of Object.keys(e))delete e[r];Object.assign(e,i)}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}broadcast(t,e){this.emitPluginEvent(t,e),this.emit(t,e)}queryBoolean(t,e=null){const i=this.grid?.query?.(t,e);return Array.isArray(i)?i.some(Boolean):!!i}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}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?._hostElement}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...b,...t}}t(t,e){return this.grid?.effectiveConfig?.locale?.[t]??e}get translate(){return(t,e)=>this.t(t,e)}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;return!e||"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(e,10);if(!isNaN(i))return i}return 200}setIcon(t,e,i){t.dataset.icon=e.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===e?t.dataset.expanded="":"expand"===e&&delete t.dataset.expanded;const r=this.#e(e,i);void 0!==r?"string"==typeof r?f(t,r):r instanceof HTMLElement&&t.replaceChildren(r.cloneNode(!0)):t.innerHTML=""}#e(t,e){return void 0!==e?e:this.grid?.gridConfig?.icons?.[t]}updateSortIndicator(t,e){t.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const i=document.createElement("span");i.setAttribute("part","sort-indicator"),i.className="sort-indicator",e?(t.setAttribute("aria-sort","asc"===e?"ascending":"descending"),t.setAttribute("data-sort",e),this.setIcon(i,"asc"===e?"sortAsc":"sortDesc")):(t.setAttribute("aria-sort","none"),t.removeAttribute("data-sort"),this.setIcon(i,"sortNone"));const r=t.querySelector(".tbw-filter-btn")??t.querySelector(".resize-handle");return r?t.insertBefore(i,r):t.appendChild(i),i}warn(i,r){void 0!==r?console.warn(e(i,r,this.gridElement.id,this.name)):console.warn(`${t(this.gridElement.id,this.name)} ${i}`)}throwDiagnostic(t,i){throw new Error(e(t,i,this.gridElement.id,this.name))}},R=0,C=/* @__PURE__ */new Set,A="tbw-responsive-column-fade",k="data-responsive-column-fade";function S(t){for(const e of t.getAnimations?.()??[])e.id===A&&(e.finished?.catch(()=>{}),e.cancel())}function E(t){return t.startsWith("minmax(")?t.includes("fr")?"minmax(0px, 0fr)":"minmax(0px, 0px)":t.endsWith("fr")?"0fr":t.endsWith("%")?"0%":"0px"}var _=class extends y{name="responsive";version="1.0.0";styles='tbw-grid[data-responsive-transition]::view-transition-group(*){animation-duration:var(--tbw-responsive-duration,.2s)}tbw-grid[data-responsive-transition] .data-grid-row>.cell{view-transition-class:tbw-responsive-cell}tbw-grid[data-responsive-transition]::view-transition-group(.tbw-responsive-cell){animation-timing-function:ease-in-out}tbw-grid[data-responsive-transition]::view-transition-old(.tbw-responsive-cell){object-fit:none;object-position:right center;width:100%;height:100%}tbw-grid[data-responsive-transition]::view-transition-new(.tbw-responsive-cell){object-fit:none;object-position:right center;width:100%;height:100%}tbw-grid[data-responsive-transition]::view-transition-old(.tbw-responsive-cell){animation-duration:calc(var(--tbw-responsive-duration,.2s) * .35)}tbw-grid[data-responsive-transition]::view-transition-new(.tbw-responsive-cell){animation-duration:calc(var(--tbw-responsive-duration,.2s) * .35)}tbw-grid[data-responsive-animate] .data-grid-row,tbw-grid[data-responsive-animate] .data-grid-row>.cell{transition:opacity var(--tbw-responsive-duration,.2s) ease-out, transform var(--tbw-responsive-duration,.2s) ease-out}tbw-grid[data-responsive][data-responsive-animate] .data-grid-row{animation:responsive-card-enter var(--tbw-responsive-duration,.2s) ease-out}@keyframes responsive-card-enter{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}tbw-grid[data-responsive] .header{display:none!important}tbw-grid[data-responsive] .footer-row{display:none}tbw-grid[data-responsive] .tbw-scroll-area{overflow-x:hidden;min-width:0!important}tbw-grid[data-responsive] .rows-body-wrapper{min-width:0!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row){padding:var(--tbw-cell-padding);border-bottom:1px solid var(--tbw-color-border);background:var(--tbw-color-bg);padding-inline-start:var(--tbw-spacing-xl);position:relative;contain:none!important;content-visibility:visible!important;grid-template-columns:none!important;display:block!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row):nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid[data-responsive] .data-grid-row:not(.group-row):hover{background:var(--tbw-color-row-hover)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)[aria-selected=true]{background:var(--tbw-color-selection)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)[aria-selected=true]:before{content:"";background:var(--tbw-color-accent);inset-inline-start:0;width:4px;position:absolute;top:0;bottom:0}tbw-grid[data-responsive] .data-grid-row:not(.group-row,.responsive-card){height:auto!important;min-height:auto!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell{padding:var(--tbw-spacing-xs) var(--tbw-spacing-md);justify-content:space-between;align-items:center;white-space:normal!important;border:none!important;background:0 0!important;border-inline-end:none!important;width:100%!important;min-width:0!important;height:auto!important;min-height:auto!important;line-height:1.5!important;display:flex!important;position:static!important;left:auto!important;right:auto!important;overflow:visible!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell:before{content:attr(data-header) ": ";color:var(--tbw-color-header-fg);min-width:100px;flex-shrink:0;margin-inline-end:var(--tbw-spacing-md);font-weight:600}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell:after{content:none}tbw-grid[data-responsive] .cell[data-utility],tbw-grid[data-responsive] .data-grid-row>.cell[data-responsive-hidden],tbw-grid[data-responsive] .data-grid-row>.cell[data-responsive-value-only]:before{display:none!important}tbw-grid[data-responsive] .data-grid-row>.cell[data-responsive-value-only]{font-weight:500;justify-content:flex-start!important}tbw-grid[data-responsive][data-responsive-hide-header] .data-grid-row:not(.group-row)>.cell:before{display:none!important}tbw-grid:not([data-responsive]) .cell[data-responsive-hidden]{pointer-events:none;opacity:0;border-inline-width:0!important;padding-inline:0!important;overflow:hidden!important}tbw-grid[data-responsive-column-fade] :is(.header-row,.data-grid-row){transition:grid-template-columns var(--tbw-responsive-duration,.2s) ease-out}tbw-grid[data-responsive] .tbw-footer,tbw-grid[data-responsive] .tbw-header-pinned,tbw-grid[data-responsive] .tbw-pinned-rows,tbw-grid[data-responsive] .tbw-aggregation-rows{display:none!important}tbw-grid[data-responsive] .tbw-pinned-rows,tbw-grid[data-responsive] .tbw-aggregation-rows,tbw-grid[data-responsive] .tbw-aggregation-row{min-width:0!important}tbw-grid[data-responsive] .data-grid-row.responsive-card{padding:var(--tbw-cell-padding);border-bottom:1px solid var(--tbw-color-border);display:block!important}tbw-grid[data-responsive] .data-grid-row.responsive-card>*{width:100%}tbw-grid[data-responsive] .data-grid-row.responsive-card .cell:before{display:none}';static manifest={queries:[{type:"isCardMode",description:"Returns whether the grid is currently in responsive card mode"}]};#i;#r=!1;#n;#o=!1;#s=0;#a;#d=Number.NEGATIVE_INFINITY;#l=++R;#c=`tbw-responsive-row-${this.#l}-`;#u=`tbw-responsive-cell-${this.#l}-`;#h=0;#p=/* @__PURE__ */new Set;#g=C;#f=/* @__PURE__ */new Set;#m=C;#v=/* @__PURE__ */new Set;#w=/* @__PURE__ */new Set;#b=0;#y;#R=!1;#C=null;#A=[];get#k(){return this.grid}isResponsive(){return this.#r}setResponsive(t){t!==this.#r&&(this.#r=t,this.#S(),this.emit("responsive-change",{isResponsive:t,width:this.#s,breakpoint:this.config.breakpoint??0}))}setBreakpoint(t){this.config.breakpoint=t,this.#a=void 0,this.#E(this.#s)}setCardRenderer(t){this.config.cardRenderer=t,this.#r&&this.requestRender()}getWidth(){return this.#s}getActiveBreakpoint(){return this.#C}attach(t){super.attach(t),this.#_(),this.#H(this.config.hiddenColumns),this.config.breakpoints?.length&&(this.#A=[...this.config.breakpoints].sort((t,e)=>e.maxWidth-t.maxWidth)),this.#x(),this.#M(),this.#F=void 0,this.#T=void 0,this.#r&&this.requestRender(),this.#i=new ResizeObserver(t=>{this.#W(t[0]?.contentRect.width??0)}),this.#i.observe(this.gridElement)}#W(t){if(this.#s=t,t===this.#a)return;const e=this.config.debounceMs??100,i=performance.now()-this.#d;if(clearTimeout(this.#n),i>=e)return this.#a=t,void this.#E(t);this.#n=setTimeout(()=>{this.#a=this.#s,this.#E(this.#s)},e-i)}#_(){const t=this.gridElement;if(!t)return;const e=t.querySelector("tbw-grid-responsive-card");if(!e)return;const i=this.#k.__frameworkAdapter;if(i?.parseResponsiveCardElement){const t=i.parseResponsiveCardElement(e);t&&(this.config={...this.config,cardRenderer:t})}const r=e.getAttribute("breakpoint"),n=e.getAttribute("card-row-height"),o=e.getAttribute("hidden-columns"),s=e.getAttribute("hide-header"),a=e.getAttribute("debounce-ms"),d={};if(null!==r){const t=parseInt(r,10);isNaN(t)||(d.breakpoint=t)}if(null!==n&&(d.cardRowHeight="auto"===n?"auto":parseInt(n,10)),null!==o&&(d.hiddenColumns=o.split(",").map(t=>t.trim()).filter(t=>t.length>0)),null!==s&&(d.hideHeader="false"!==s),null!==a){const t=parseInt(a,10);isNaN(t)||(d.debounceMs=t)}const l=e.innerHTML.trim();!l||this.config.cardRenderer||i?.parseResponsiveCardElement||(d.cardRenderer=t=>{const e=v(l,{value:t,row:t}),i=document.createElement("div");return i.className="tbw-responsive-card-content",f(i,e),i}),Object.keys(d).length>0&&(this.config={...this.config,...d})}#H(t){this.#p=/* @__PURE__ */new Set,this.#f.clear();for(const e of t??[])"string"==typeof e?this.#p.add(e):e.showValue?this.#f.add(e.field):this.#p.add(e.field);this.#q()}get#L(){return this.#A.length>0?null!==this.#C:this.#r}#q(){const t=this.#L?this.#p:C;for(const e of this.#g)t.has(e)||this.#G(e,!1);for(const e of t)this.#g.has(e)||this.#G(e,!0);this.#O()}#G(t,e){(e?this.#w:this.#v).delete(t),(e?this.#v:this.#w).add(t)}#O(){const t=this.#D;t<=0||0===this.#v.size&&0===this.#w.size?this.#B():(this.#b=performance.now()+t,this.gridElement?.setAttribute(k,""),clearTimeout(this.#y),this.#y=setTimeout(()=>this.#B(),t))}#B(){clearTimeout(this.#y),this.#y=void 0,this.#b=0,this.#v.clear(),this.#w.clear(),this.gridElement?.removeAttribute(k);for(const t of this.gridElement?.querySelectorAll(".cell[data-field]")??[])S(t)}#$(t,e,i,r){S(t);const n=e?[{opacity:1},{opacity:0}]:[{opacity:0},{opacity:1}],o=t.animate?.(n,{duration:i,easing:"ease-out",fill:e?"forwards":"none"});o&&(o.id=A,o.currentTime=r)}#z(t){const e=this.#k?._gridTemplate??"";if(!e)return;const i=this.visibleColumns,r=function(t){const e=[];let i=0,r=0;for(let n=0;n<t.length;n++){const o=t[n];"("===o?i++:")"===o?i--:" "===o&&0===i&&(n>r&&e.push(t.slice(r,n)),r=n+1)}return r<t.length&&e.push(t.slice(r)),e}(e);let n=!1;if(t.size>0&&r.length===i.length)for(let o=0;o<i.length;o++){const e=i[o]?.field;e&&t.has(e)&&(r[o]=E(r[o]),n=!0)}(n||this.#R)&&(this.gridElement.style.setProperty("--tbw-column-template",n?r.join(" "):e),this.#R=n)}detach(){if(this.#i?.disconnect(),this.#i=void 0,this.#B(),clearTimeout(this.#n),this.#n=void 0,this.#a=void 0,this.#d=Number.NEGATIVE_INFINITY,this.gridElement){this.gridElement.removeAttribute("data-responsive"),this.gridElement.removeAttribute("data-responsive-animate"),this.gridElement.removeAttribute("data-responsive-hide-header"),this.gridElement.removeAttribute("data-responsive-transition");for(const t of this.gridElement.querySelectorAll(".cell[data-responsive-hidden], .cell[data-responsive-value-only]"))t.removeAttribute("data-responsive-hidden"),t.removeAttribute("data-responsive-value-only"),t.removeAttribute("aria-hidden");this.#I()}this.#g=C,this.#m=C,super.detach()}handleQuery(t){if("isCardMode"===t.type)return this.#r}afterRender(){this.#N();const t=this.#A.length>0?null!==this.#C:this.#r,e=t?this.#p:C,i=t?this.#f:C,r=this.#v.size>0||this.#w.size>0,n=this.#g.size>0||this.#m.size>0;if(this.#g=e,this.#m=i,this.#z(this.#r?C:e),0===e.size&&0===i.size&&!r&&!n)return;const o=this.#D,s=r?Math.min(o,Math.max(0,o-(this.#b-performance.now()))):0,a=this.gridElement.querySelectorAll(".cell[data-field]");for(const d of a){const t=d.getAttribute("data-field");if(!t)continue;const r=this.#v.has(t);(r||this.#w.has(t))&&this.#$(d,r,o,s),e.has(t)?(d.setAttribute("data-responsive-hidden",""),d.setAttribute("aria-hidden","true"),d.removeAttribute("data-responsive-value-only")):i.has(t)?(d.setAttribute("data-responsive-value-only",""),d.removeAttribute("data-responsive-hidden"),d.removeAttribute("aria-hidden")):(d.removeAttribute("data-responsive-hidden"),d.removeAttribute("data-responsive-value-only"),d.removeAttribute("aria-hidden"))}}#E(t){if(this.#A.length>0)return void this.#P(t);const e=this.config.breakpoint??0;0!==e||this.#o||(this.#o=!0,this.warn("TBW110","No breakpoint configured. Responsive mode is disabled. Set a breakpoint based on your grid's column count."));const i=e>0&&t<e;i!==this.#r&&(this.#r=i,this.#d=performance.now(),this.#S(),this.emit("responsive-change",{isResponsive:i,width:t,breakpoint:e}))}#P(t){let e=null;for(const i of this.#A)t<=i.maxWidth&&(e=i);if(e!==this.#C){this.#C=e,this.#d=performance.now(),e?.hiddenColumns?this.#H(e.hiddenColumns):this.#H(this.config.hiddenColumns);const i=!0===e?.cardLayout,r=i!==this.#r;r&&(this.#r=i),this.#S(r),this.emit("responsive-change",{isResponsive:this.#r,width:t,breakpoint:e?.maxWidth??0})}}#S(t=!0){this.#x(),t&&this.#B();const e=t?this.#j():null;if(!e)return t&&this.#V(),void this.requestRender();const i=this.gridElement,r=this.#Y(),n=++this.#h;"none"!==r&&this.#U(r),i.setAttribute("data-responsive-transition","");const o=e(async()=>{this.#V(),await(this.#k.forceLayout?.()),"none"!==r&&this.#U(r)}),s=()=>{n===this.#h&&(i.removeAttribute("data-responsive-transition"),"none"!==r&&this.#I())};o.finished.then(s,s),o.ready?.catch(()=>{})}get#K(){const{animation:t,animate:e}=this.config;return void 0!==t?t:!1!==e&&"fade"}get#D(){return!1!==this.#K&&this.isAnimationEnabled?this.config.animationDuration??200:0}#x(){this.gridElement.style.setProperty("--tbw-responsive-duration",`${this.#D}ms`)}#j(){if(!1===this.#K||!this.isAnimationEnabled)return null;const t=this.gridElement,e=t.startViewTransition;return"function"==typeof e?e.bind(t):null}get#J(){return"function"==typeof this.gridElement?.startViewTransition}#U(t){const e=this.gridElement.querySelectorAll(".data-grid-row[aria-rowindex]");for(const i of e){const e=i.getAttribute("aria-rowindex");if("rows"!==t)for(const t of i.querySelectorAll(":scope > .cell[aria-colindex]")){const i=`${this.#u}${e}-${t.getAttribute("aria-colindex")}`;t.style.setProperty("view-transition-name",i)}else i.style.setProperty("view-transition-name",`${this.#c}${e}`)}}#Y(){const t=this.#K;if("morph-cells"===t){const t=this.gridElement.querySelectorAll(".data-grid-row > .cell[aria-colindex]").length;return t>0&&t<=150?"cells":"rows"}return"morph-rows"===t?"rows":"none"}#I(){const t=this.gridElement.querySelectorAll(".data-grid-row, .data-grid-row > .cell");for(const e of t)e.style.removeProperty("view-transition-name")}#Z;#M(){this.gridElement.toggleAttribute("data-responsive",this.#r),this.gridElement.toggleAttribute("data-responsive-animate",!1!==this.#K&&!this.#J),this.gridElement.toggleAttribute("data-responsive-hide-header",this.#r&&!0===this.config.hideHeader)}#V(){this.#M();const t=this.#k;if(this.#r){t._virtualization&&(this.#Z=t._virtualization.rowHeight);const e=this.gridElement.querySelector(".tbw-scroll-area");e&&(e.scrollLeft=0)}else{const e=this.gridElement.querySelectorAll(".data-grid-row");for(const t of e)t.style.height="",t.classList.remove("responsive-card");this.#Z&&this.#Z>0&&t._virtualization&&(t._virtualization.rowHeight=this.#Z,this.#Z=void 0),this.#F=void 0,this.#T=void 0,this.#Q=void 0}}renderRow(t,e,i){if(!this.#r||!this.config.cardRenderer)return;if(t.__isGroupRow)return;e.replaceChildren();const r=this.config.cardRenderer(t,i);e.className="data-grid-row responsive-card";const n=this.config.cardRowHeight;return e.style.height="auto"===n||void 0===n?"auto":`${this.#X()}px`,r.hasAttribute("role")||(r.setAttribute("role","gridcell"),r.setAttribute("aria-colindex","1")),e.appendChild(r),!0}onKeyDown(t){if(!this.#r)return!1;if(this.config.cardRenderer&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(t.key))return!1;const e=this.rows.length-1,i=this.visibleColumns.length-1;switch(t.key){case"ArrowDown":if(this.grid._focusCol<i)return this.grid._focusCol+=1,t.preventDefault(),n(this.#k),!0;if(this.grid._focusRow<e)return this.grid._focusRow+=1,this.grid._focusCol=0,t.preventDefault(),n(this.#k),!0;break;case"ArrowUp":if(this.grid._focusCol>0)return this.grid._focusCol-=1,t.preventDefault(),n(this.#k),!0;if(this.grid._focusRow>0)return this.grid._focusRow-=1,this.grid._focusCol=i,t.preventDefault(),n(this.#k),!0;break;case"ArrowRight":if(this.grid._focusRow<e)return this.grid._focusRow+=1,t.preventDefault(),n(this.#k),!0;break;case"ArrowLeft":if(this.grid._focusRow>0)return this.grid._focusRow-=1,t.preventDefault(),n(this.#k),!0}return!1}#F;#T;#Q;#X(){const t=this.config.cardRowHeight,e=this.#F;return"number"==typeof t&&t>0?e&&e>t?e:t:e&&e>0?e:80}#tt(){return this.#T&&this.#T>0?this.#T:this.#Z??28}#et(){for(const t of this.rows)if(t.__isGroupRow)return!0;return!1}getRowHeight(t,e){if(this.#r&&this.config.cardRenderer)return t.__isGroupRow?this.#tt():this.#X()}#it(){let t=0;for(const e of this.rows)e.__isGroupRow||t++;return t}#rt=!1;#N(){if(!this.#r)return;let t=!1;const e=this.#k,i=this.#et(),r=this.#it();if(r!==this.#Q&&(this.#Q=r,t=!0),i){const e=this.gridElement.querySelector(".data-grid-row.group-row");if(e){const i=e.getBoundingClientRect().height;i>0&&i!==this.#T&&(this.#T=i,t=!0)}}const n=this.config.cardRenderer?".data-grid-row.responsive-card":".data-grid-row:not(.group-row)",o=this.gridElement.querySelector(n);if(o){const r=o.getBoundingClientRect().height;r>0&&r!==this.#F&&(this.#F=r,t=!0,!i&&e._virtualization&&(e._virtualization.rowHeight=r))}t&&!this.#rt&&(this.#rt=!0,queueMicrotask(()=>{this.#rt=!1,this.grid&&this.#r&&this.#k.refreshVirtualWindow?.(!0,!0)}))}};export{_ as ResponsivePlugin};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|