@ninebone/datagrid 0.0.11 → 0.0.12
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/dist/css/nine-table.css +61 -31
- package/dist/nine-table.js +16 -7
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +4 -4
- package/dist/nine-table.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/nine-table.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@ninebone/util")):typeof define==`function`&&define.amd?define([`exports`,`@ninebone/util`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.NineTable={},e.nine))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Array.prototype.nineBinarySearch=function(e){let t=0,n=this.length-1,r;for(;t<=n;){if(r=parseInt((t+n)/2),e===this[r])return r;e<this[r]?n=r-1:t=r+1}return-1};var n=new WeakMap;HTMLElement.prototype.addDebounseEventListener=function(e,t,r,i,a=500){let o=this;n.has(o)||n.set(o,{timer:null,cancelFn:null});let s=n.get(o);o.addEventListener(r,e=>{e.actualTarget=e.target,s.timer&&=(clearTimeout(s.timer),null),s.timer=setTimeout(()=>{s.timer=null,s.cancelFn=i.call(o,e)},a)}),o.addEventListener(e,e=>{s.timer&&=(clearTimeout(s.timer),null),s.cancelFn&&=(s.cancelFn(),null),t.call(o,e)})},nine.measureTextSize=(e,t=`12px sans-serif`)=>{if(typeof e==`number`&&(e+=``),!e)return{width:null,height:null};let n=e=>{let t=document.createElement(`DIV`);return t.innerHTML=e,t.textContent||t.innerText||``};e=e.replaceAll(`
|
|
2
|
-
`,`<br>`);let r=document.body.querySelector(`canvas#_nine_measure_canvas_`);r||(r=document.createElement(`canvas`),r.id=`_nine_measure_canvas_`,r.style.cssText=`position: absolute; visibility: hidden; pointer-events: none; left: -9999px;`,document.body.appendChild(r));let i=r.getContext(`2d`);i.font=t;let a=0,o=0;for(let t of e.split(`<br>`)){let e=n(t),r=i.measureText(e);a=Math.max(a,r.width);let s=r.fontBoundingBoxAscent||10,c=r.fontBoundingBoxDescent||3;o+=s+c}return{width:a,height:o}};var r=new class extends t.trace.constructor{constructor(){super(),this.init(`nine-table`,`green`)}},i={META:{INDEX:{ROWID:0,ROW_STATE:1,FILTER:2,GROUP:3}},ROW_STATE:{EMPTY:0,NORMAL:1,INSERT:2,UPDATE:3,DELETE:9},EVENT:{LOAD:`load`,CELL_BUTTON_CLICK:`cell-button-click`}},a=class{#e;#t=-1;constructor(e){this.#e=e}get at(){return this.#t}set at(e){this.#t=parseInt(e,10)}count=()=>this.#e.rawRecords.length},o=class e{#e;#t;#n=0;#r=[];static META_INDEX={FILTER:0};static ROW_STATE={EMPTY:`EMPTY`,NORMAL:`NORMAL`,INSERT:`INSERT`,UPDATE:`UPDATE`,DELETE:`DELETE`};constructor(e,t){this.#e=e,this.#t=t,this.#a()}#i=()=>(this.#t.rawRecords||[]).filter(e=>e.m._[i.META.INDEX.ROW_STATE]!==i.ROW_STATE.DELETE);get count(){return this.length}count=()=>this.length;getArray=(e,t)=>{let n=this.#i();if(e==null)return n;if(e<0||e>=n.length)return null;let r=n[e];if(t!=null){let e=this.getHostFields().indexOf(t);return e>=0?r.v[e]:null}return r};setArray=(t,n,r)=>{let i=this.#i()[t];i.v[n]!==r&&i.__ng.rowState!==e.ROW_STATE.INSERT&&(i.__ng.rowState=e.ROW_STATE.UPDATE),i.v[n]=r};get=(e,t)=>{let n=this.#i();if(e==null)return this.#d(n);if(e<0||e>=n.length)return null;let r=n[e],i=this.getHostFields();if(t!=null){let e=i.indexOf(t);return e>=0?r.v[e]:null}return this.#d(r)};getAll=()=>this.#t.rawRecords||[];getHostFields=()=>typeof this.#e.fields?.get==`function`?this.#e.fields.get():[];#a=()=>{this.#r=[];let e=this.#e.template||[];Array.from(e).forEach(e=>{this.#r.push(e.getBoundingClientRect?.().height||24)}),(this.#t.rawRecords||[]).forEach(e=>{e.__ng||=this.#s(),e.__ng.height=this.#r.slice()})};get source(){return this.#d(this.#t.rawRecords)}set source(e){this.set(e)}#o=()=>{this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`).forEach(e=>{e.invalidate()}),this.#e.shadowRoot.querySelector(`nine-table-sheets-footer`)?.refresh()};set=e=>{let t=()=>{this.#e.loading=!0,setTimeout(()=>{try{this.clear(),this.add(e,!1),this.#o()}finally{this.#e.loading=!1}})};this.#e.loaded?t():this.#e.addEventListener(i.EVENT.LOAD,e=>{t()},{once:!0})};get nextId(){return this.#n++}get length(){return this.#i().length}get count(){return this.length}getRowCount(){return this.length}#s=(t=0)=>({rowState:e.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:this.#r.slice(),o:{},c:{},__:[0,0,0,0,e.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,this.#r.slice(),-1,{},{}],_:[t,i.ROW_STATE.EMPTY,[],[]]});reset=()=>{this.#t.rawRecords=[],this.#o()};clear=()=>{this.#t.rawRecords=[],this.#t.viewRecords?.reset&&this.#t.viewRecords.reset(),this.#n=0,this.#o()};#c=e=>{Array.isArray(e)||(e=[e]);let t=this.getHostFields().length>0?this.getHostFields():Object.keys(e[0]||{}),n=[];return e.forEach(e=>{let r={v:[]};t.forEach(t=>{r.v.push(e[t]!==void 0&&e[t]!==null?e[t]:``)}),n.push(r)}),n};#l=e=>(Array.isArray(e)||(e=[e]),e.forEach(e=>{let t=this.nextId;e.m=this.#s(t),e.__ng=e.m,e.__ng.rowid=t,e.m._[i.META.INDEX.ROWID]=t,e.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.EMPTY}),e);#u=e=>this.#t.rawRecords.findIndex(t=>!t||!t.m||!t.m._?!1:t.m._[i.META.INDEX.ROWID]===e);add=(e,t=!0)=>{e===void 0&&(e={});let n=this.#c(e);this.#t.rawRecords=this.#t.rawRecords.concat(this.#l(n));let r=this.count()-1;return t&&n.forEach((e,t)=>{let n=this.#t.rawRecords[this.#t.rawRecords.length-1-t];n&&(n.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.INSERT)}),this.#o(),r};insert=(e,t,n=!0)=>{t===void 0&&(t={});let r=this.#c(t);if(r.length===0)return-1;let a=this.#u(e),o=this.#l(r);return this.#t.rawRecords.splice(a,0,...o),n&&o.forEach((e,t)=>{let n=this.#t.rawRecords[a+t];n&&n.m&&n.m._&&(n.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.INSERT)}),this.#o(),o[0].m._[i.META.INDEX.ROWID]};remove=e=>{let t=[];t=Array.isArray(e)?at:[parseInt(e,10)];let n=[];t.forEach(e=>{n.push(this.#u(e))});let r=this.#t.rawRecords;n.sort((e,t)=>t-e).forEach(e=>{let t=r[e].m._[i.META.INDEX.ROWID];r[e].m._[i.META.INDEX.ROW_STATE]===i.ROW_STATE.INSERT?this.#t.rawRecords=this.#t.rawRecords.filter(e=>e.m._[i.META.INDEX.ROWID]!==t):this.#t.rawRecords.forEach(e=>{e.m._[i.META.INDEX.ROWID]===t&&(e.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.DELETE)})}),this.#o()};setValue=(e,t,n)=>{e=parseInt(e,10);let r=this.getHostFields().indexOf(t);if(r<0)return;let a=this.#
|
|
2
|
+
`,`<br>`);let r=document.body.querySelector(`canvas#_nine_measure_canvas_`);r||(r=document.createElement(`canvas`),r.id=`_nine_measure_canvas_`,r.style.cssText=`position: absolute; visibility: hidden; pointer-events: none; left: -9999px;`,document.body.appendChild(r));let i=r.getContext(`2d`);i.font=t;let a=0,o=0;for(let t of e.split(`<br>`)){let e=n(t),r=i.measureText(e);a=Math.max(a,r.width);let s=r.fontBoundingBoxAscent||10,c=r.fontBoundingBoxDescent||3;o+=s+c}return{width:a,height:o}};var r=new class extends t.trace.constructor{constructor(){super(),this.init(`nine-table`,`green`)}},i={META:{INDEX:{ROWID:0,ROW_STATE:1,FILTER:2,GROUP:3}},ROW_STATE:{EMPTY:0,NORMAL:1,INSERT:2,UPDATE:3,DELETE:9},EVENT:{LOAD:`load`,CELL_BUTTON_CLICK:`cell-button-click`}},a=class{#e;#t=-1;constructor(e){this.#e=e}get at(){return this.#t}set at(e){this.#t=parseInt(e,10)}count=()=>this.#e.rawRecords.length},o=class e{#e;#t;#n=0;#r=[];static META_INDEX={FILTER:0};static ROW_STATE={EMPTY:`EMPTY`,NORMAL:`NORMAL`,INSERT:`INSERT`,UPDATE:`UPDATE`,DELETE:`DELETE`};constructor(e,t){this.#e=e,this.#t=t,this.#a()}#i=()=>(this.#t.rawRecords||[]).filter(e=>e.m._[i.META.INDEX.ROW_STATE]!==i.ROW_STATE.DELETE);get count(){return this.length}count=()=>this.length;getArray=(e,t)=>{let n=this.#i();if(e==null)return n;if(e<0||e>=n.length)return null;let r=n[e];if(t!=null){let e=this.getHostFields().indexOf(t);return e>=0?r.v[e]:null}return r};setArray=(t,n,r)=>{let i=this.#i()[t];i.v[n]!==r&&i.__ng.rowState!==e.ROW_STATE.INSERT&&(i.__ng.rowState=e.ROW_STATE.UPDATE),i.v[n]=r};get=(e,t)=>{let n=this.#i();if(e==null)return this.#d(n);if(e<0||e>=n.length)return null;let r=n[e],i=this.getHostFields();if(t!=null){let e=i.indexOf(t);return e>=0?r.v[e]:null}return this.#d(r)};getAll=()=>this.#t.rawRecords||[];getHostFields=()=>typeof this.#e.fields?.get==`function`?this.#e.fields.get():[];#a=()=>{this.#r=[];let e=this.#e.template||[];Array.from(e).forEach(e=>{this.#r.push(e.getBoundingClientRect?.().height||24)}),(this.#t.rawRecords||[]).forEach(e=>{e.__ng||=this.#s(),e.__ng.height=this.#r.slice()})};get source(){return this.#d(this.#t.rawRecords)}set source(e){this.set(e)}#o=()=>{this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`).forEach(e=>{e.invalidate()}),this.#e.shadowRoot.querySelector(`nine-table-sheets-footer`)?.refresh()};set=e=>{let t=()=>{this.#e.loading=!0,setTimeout(()=>{try{this.clear(),this.add(e,!1),this.#o()}finally{this.#e.loading=!1}})};this.#e.loaded?t():this.#e.addEventListener(i.EVENT.LOAD,e=>{t()},{once:!0})};get nextId(){return this.#n++}get length(){return this.#i().length}get count(){return this.length}getRowCount(){return this.length}#s=(t=0)=>({rowState:e.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:this.#r.slice(),o:{},c:{},__:[0,0,0,0,e.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,this.#r.slice(),-1,{},{}],_:[t,i.ROW_STATE.EMPTY,[],[]]});reset=()=>{this.#t.rawRecords=[],this.#o()};clear=()=>{this.#t.rawRecords=[],this.#t.viewRecords?.reset&&this.#t.viewRecords.reset(),this.#n=0,this.#o()};#c=e=>{Array.isArray(e)||(e=[e]);let t=this.getHostFields().length>0?this.getHostFields():Object.keys(e[0]||{}),n=[];return e.forEach(e=>{let r={v:[]};t.forEach(t=>{r.v.push(e[t]!==void 0&&e[t]!==null?e[t]:``)}),n.push(r)}),n};#l=e=>(Array.isArray(e)||(e=[e]),e.forEach(e=>{let t=this.nextId;e.m=this.#s(t),e.__ng=e.m,e.__ng.rowid=t,e.m._[i.META.INDEX.ROWID]=t,e.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.EMPTY}),e);#u=e=>this.#t.rawRecords.findIndex(t=>!t||!t.m||!t.m._?!1:t.m._[i.META.INDEX.ROWID]===e);add=(e,t=!0)=>{e===void 0&&(e={});let n=this.#c(e);this.#t.rawRecords=this.#t.rawRecords.concat(this.#l(n));let r=this.count()-1;return t&&n.forEach((e,t)=>{let n=this.#t.rawRecords[this.#t.rawRecords.length-1-t];n&&(n.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.INSERT)}),this.#o(),r};insert=(e,t,n=!0)=>{t===void 0&&(t={});let r=this.#c(t);if(r.length===0)return-1;let a=this.#u(e),o=this.#l(r);return this.#t.rawRecords.splice(a,0,...o),n&&o.forEach((e,t)=>{let n=this.#t.rawRecords[a+t];n&&n.m&&n.m._&&(n.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.INSERT)}),this.#o(),o[0].m._[i.META.INDEX.ROWID]};remove=e=>{let t=[];t=Array.isArray(e)?at:[parseInt(e,10)];let n=[];t.forEach(e=>{n.push(this.#u(e))});let r=this.#t.rawRecords;n.sort((e,t)=>t-e).forEach(e=>{let t=r[e].m._[i.META.INDEX.ROWID];r[e].m._[i.META.INDEX.ROW_STATE]===i.ROW_STATE.INSERT?this.#t.rawRecords=this.#t.rawRecords.filter(e=>e.m._[i.META.INDEX.ROWID]!==t):this.#t.rawRecords.forEach(e=>{e.m._[i.META.INDEX.ROWID]===t&&(e.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.DELETE)})}),this.#o()};setValue=(e,t,n)=>{e=parseInt(e,10);let r=this.getHostFields().indexOf(t);if(r<0)return;let a=this.#u(e),o=this.#t.rawRecords[a];o&&(o.v[r]!==n&&o.m._[i.META.INDEX.ROW_STATE]!==i.ROW_STATE.INSERT&&(o.m._[i.META.INDEX.ROW_STATE]=i.ROW_STATE.UPDATE),o.v[r]=n)};#d=e=>{if(!e)return e;let t=!Array.isArray(e),n=t?[e]:e,r=this.getHostFields(),i=n.filter(e=>!e.__ng?.deleted).map(e=>{let t={};return r.forEach((n,r)=>{t[n]=e.v?e.v[r]:e[n]}),t.__ng=e.__ng,t});return t?i[0]:i}},s=class{#e;constructor(e){this.#e=e,this.row=new a(this),this.data=new o(this.#e,this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{this.#e.view?.redraw&&this.#e.view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{let t=parseInt(e,10);if(!(t>=this.data.count()))return this.data.getValidData()[t]?.__ng?.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,t)=>this.data.get(e,t),this.setColumn=(e,t,n)=>{e=parseInt(e,10),this.data.setValue(e,t,n)},this.setDataSource([])}},c=class{#e;#t=[];constructor(e){this.#e=e,this.#r()}get(){return this.#t.map(e=>e.name)}getFields(){return this.#t}getType(e){let t=this.#t.find(t=>t.name===e);return t?t.type:`string`}add=(e,t=`string`)=>{e.forEach(e=>{this.#t.some(t=>t.name===e)||this.#t.push({name:e,type:t})}),this.#n()};indexOf(e){return this.#t.findIndex(t=>t.name===e)}includes(e){return this.#t.some(t=>t.name===e)}#n=()=>{let e=new Map;this.#t.forEach(t=>{e.set(t.name,t.type)}),this.#t=Array.from(e,([e,t])=>({name:e,type:t})),this.#t=this.#t.filter(e=>e.name!==``&&e.name!==`__ng`),this.#t.sort((e,t)=>e.name.length<t.name.length?1:-1)};#r=()=>{this.#t=[];let e=Array.from(this.#e.querySelectorAll(`table`));if(e&&e.length!==0){for(let t of e)t.querySelectorAll(`[data-bind]`).forEach(e=>{let t=e.dataset.bind,n=e.getAttribute(`data-type`)||`string`;t&&this.#t.push({name:t,type:n})}),[`data-expr`,`background-color`,`color`,`tooltip`,`visible`,`readonly`,`enable-button`,`enable-check`,`class-expr`,`icon-color`,`icon-src`].forEach(e=>{t.querySelectorAll(`[${e}]`).forEach(t=>{let n=t.getAttribute(e);if(n){if(n.indexOf(`data.`)<0){let e=n.search(/[(]/g);if(e>0)try{n=String(window[n.substring(0,e).trim()])}catch{n=``}}n.split(`data.`).forEach(e=>{if(e.trim()!=``){let t=e.search(/[^_A-Za-z0-9]/g),r=``;t>=0?r=e.substring(0,t):n.startsWith(`data.`)&&(r=e.replace(`data.`,``)),r&&this.#t.push({name:r,type:`string`})}})}})});this.#n()}}},l=class extends HTMLElement{constructor(){super()}connectedCallback(){this.#e()}#e=()=>{}};customElements.get(`nine-table-sheets`)||customElements.define(`nine-table-sheets`,l);var u=class extends HTMLElement{#e;constructor(){super()}connectedCallback(){this.#t()}refresh=()=>{this.querySelector(`#row-count`).innerHTML=this.#e.data.count().toLocaleString()};#t=()=>{this.#e=this.getRootNode().host,this.#r(),this.querySelector(`.nine-tab-bar`)?.addEventListener(`click`,e=>{let t=e.ctrlKey||e.metaKey||e.shiftKey,n=e.target.closest(`nt-sheets-tab-item`);if(!n)return;let r=parseInt(n.dataset.index,10);this.#n(r,t)}),setTimeout(()=>{this.#n(0,!1)})};#n=(e,t=!1)=>{let n=()=>{let e=Array.from(this.#e.shadowRoot.querySelectorAll(`nine-table-sheet`));Array.from(this.#e.shadowRoot.querySelectorAll(`nine-splitter`)).forEach(e=>e.style.setProperty(`display`,`none`));let t=e.map((e,t)=>({sheet:e,idx:t})).filter(({sheet:e})=>e.classList.contains(`active`));if(!(t.length<2))for(let e=0;e<t.length-1;e++){let n=t[e].idx,r=this.#e.shadowRoot.querySelector(`nine-splitter[data-split-index="${n}"]`);r&&r.style.setProperty(`display`,``)}},r=this.querySelector(`.nine-tab-bar`),i=this.#e.shadowRoot.querySelector(`nine-table-sheets-body`),a=r.querySelectorAll(`nt-sheets-tab-item`),o=i.querySelectorAll(`nine-table-sheet`);if(!a[e])return;if(!t)a.forEach((t,n)=>{t.setActive(n===e)}),o.forEach((t,n)=>{let r=n===e;t.classList.toggle(`active`,r),t.style.flex=r?`1 1 100%`:``});else{let t=a[e],n=r.querySelectorAll(`nt-sheets-tab-item.active`);if(t.classList.contains(`active`)&&n.length<=1)return;t.classList.toggle(`active`);let o=i.querySelector(`nine-table-sheet[data-index="${e}"]`);o&&(o.classList.toggle(`active`),o.classList.contains(`active`)||(o.style.flex=``))}let s=i.querySelectorAll(`nine-table-sheet.active`);s?.forEach(e=>{e.style.flex=s.length>1?`1 1 0%`:`1 1 100%`,typeof e.refreshLayout==`function`?e.refreshLayout():e.invalidate?.()}),n()};#r(){let e=Array.from(this.#e.children).filter(e=>e.tagName.toUpperCase()===`TABLE`).map((e,t)=>`<nt-sheets-tab-item class="${t===0?`active`:``}" data-index="${t}">${e.getAttribute(`caption`)||`Sheet ${t+1}`}</nt-sheets-tab-item>`).join(``);this.innerHTML=`
|
|
3
3
|
<div class="nine-tab-bar">${e}</div>
|
|
4
4
|
<div class="sheets-counter">Total : <span id="row-count">0</span></div>
|
|
5
5
|
`}},d=class extends HTMLElement{constructor(){super()}connectedCallback(){}setActive(e){this.classList.toggle(`active`,e)}};customElements.get(`nt-sheets-tab-item`)||customElements.define(`nt-sheets-tab-item`,d),customElements.get(`nine-table-sheets-footer`)||customElements.define(`nine-table-sheets-footer`,u);var f=class extends HTMLElement{#e;#t;connectedCallback(){this.#e=this.getRootNode().host,this.#n(),this.#i()}#n(){this.innerHTML=`
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
</div>
|
|
56
56
|
</div>
|
|
57
57
|
</div>
|
|
58
|
-
`};open(e){this.#i=e;let t=e.closest(`th, td`);this.currentCol=t?.dataset.col;let n=t.getBoundingClientRect(),r=this.#e.getBoundingClientRect(),i=this.offsetWidth||240,a=n.right-r.left-i,o=n.bottom-r.top;a<0&&(a=Math.max(0,n.left-r.left)),this.style.left=`${a}px`,this.style.top=`${o}px`;let s=this.querySelector(`.search-box`);s.value=``,this.classList.add(`active`),this.classList.add(`loading`),setTimeout(()=>{try{this.#c(),this.#r.rowManager.scrollToDataRow(0),s.focus()}finally{this.classList.remove(`loading`)}})}#s=e=>{let t=e.composedPath?e.composedPath():[];t.includes(this)||this.#i&&t.includes(this.#i)||this.close()};close(){this.currentCol=null,this.classList.remove(`active`),this.#i=null}#c(){let e=this.#t.data.getArray(),t=this.#i?.columns||[],n=this.#t.fields.get()||[],r=this.#e.filtering?.filters||{},i=this.#t.exprEngine,a=t.flatMap(t=>{let a=t.bind,o=t.expr,s=a||o,c=a?n.indexOf(a):-1,l=r[s]||[],u=new Map;for(let t=0;t<e.length;t++){let n=e[t];if(!n)continue;let r;c>=0&&n.v?r=n.v[c]:a&&a.includes(`data.`)?r=i?i.evaluate(a,n,t):void 0:o&&i&&(r=i.evaluate(o,n,t));let s=r;o&&i&&(s=i.evaluate(o,n,t)),s!=null&&!u.has(s)&&u.set(s,{v:r,v2:s})}let d=[...u.values()];return d.sort((e,t)=>{let n=e.v2,r=t.v2;if(n===r)return 0;if(n==null||n===``)return 1;if(r==null||r===``)return-1;let i=Number(n),a=Number(r);return!isNaN(i)&&!isNaN(a)?i-a:String(n).localeCompare(String(r))}),l.sort((e,t)=>e>t?1:-1),d.map(e=>({LVL:2,DATA:e.v,DATA2:e.v2===``||e.v2===null||e.v2===void 0?`<span class="empty-value">(empty)</span>`:e.v2,COLNM:s,CHK:l.length===0||l.nineBinarySearch(e.v)>=0?`Y`:`N`}))});this.#n.data.set(a);let o=this.querySelector(`#chkSelectAll`);o&&(o.checked=a.length>0&&a.every(e=>e.CHK===`Y`))}#l=()=>{this.#t.loading=!0;let e=this.#r.view.getArray(),t=this.#n.data.getHostFields(),n=e.filter(e=>{let n=e.v[t.indexOf(`CHK`)];return n===`Y`||n===!0}),r={...this.#e.filtering?.filters||{}};this.#i.columns.forEach(e=>{let i=e.expr||e.bind,a=e.expr?t.indexOf(`DATA2`):t.indexOf(`DATA`),o=n.map(e=>e.v[a]);o.length>0?r[i]=o:delete r[i]});let i=this.#n.data.count();setTimeout(()=>{try{i===n.length?this.#i.columns.forEach(e=>{let t=e.expr||e.bind;t&&this.#e.filtering.clear(t)}):this.#e.filtering.set(r),this.#e.querySelectorAll(`nine-table-filter-button`).forEach(e=>{e.updateFilteredState()}),this.#e.invalidate(),this.close()}finally{this.#t.loading=!1}})};#u=e=>{let t=e.target.value.toLowerCase().trim();if(!t)this.#r.filtering.clear();else{let e=this.#n.data.getArray(),n=this.#n.data.getHostFields().indexOf(`DATA2`),r=[];e.forEach(e=>{let i=n>=0&&e.v?e.v[n]:``;String(i).replace(/<[^>]*>?/gm,``).toLowerCase().includes(t)&&r.push(i)}),this.#r.filtering.set({DATA2:[...new Set(r)]})}};#d=e=>{let t=e.target.checked,n=this.#n?.data?.getArray()||[],r=this.#n.data.getHostFields().indexOf(`CHK`);r>=0&&n.forEach(e=>{e.v[r]=t?`Y`:`N`}),this.#n.refresh()}},O=class extends HTMLElement{#e;#t=null;connectedCallback(){this.#e=this.closest(`nine-table-sheet`)||this.getRootNode().host,this.removeEventListener(`click`,this.#n),this.addEventListener(`click`,this.#n)}get columns(){if(this.#t)return this.#t;let e=this.closest(`th, td`)?.dataset.col,t=this.#e.sourceTable,n=[],r=new Set;return t&&e!==void 0&&t.querySelectorAll(`tbody [data-col="${e}"]`).forEach(e=>{let t=e.dataset.bind,i=e.dataset.expr;if(t||i){let e=`${t||``}_${i||``}`;r.has(e)||(r.add(e),n.push({bind:t,expr:i}))}}),this.#t=n,this.#t}updateFilteredState=()=>{let e=this.#e.filtering?.filters||{},t=this.columns.some(t=>{let n=t.expr||t.bind;return n&&e[n]&&e[n].length>0});this.classList.toggle(`filtered`,t)};#n=e=>{e.preventDefault(),e.stopPropagation();let t=this.#e.querySelector(`nine-table-filter-panel`),n=this.closest(`th, td`).dataset.col;t&&t.currentCol===n&&t.classList.contains(`active`)?t.close():t&&t.open(this)}},k=class{#e;#t;#n=!1;#r=null;#i={};constructor(e){this.#e=e,this.#t=this.#e.getRootNode().host,this.#a()}get filters(){return this.#i}#a=()=>{this.#o()};#o=()=>{if(this.#t.tagName.toLowerCase()===`nine-table-simple`)return;let e=this.#e.querySelector(`nine-table-filter-panel`);e||(e=document.createElement(`nine-table-filter-panel`),this.#e.appendChild(e)),this.#r=e};isFiltering(){return this.#n}clear=e=>{e?delete this.#i[e]:this.#i={},this.#n=Object.keys(this.#i).length>0,this.#s(),this.#e.querySelectorAll(`nine-table-filter-button`).forEach(e=>{e.updateFilteredState()})};set=e=>{let t=Array.isArray(e)?Object.fromEntries(Object.keys(e[0]).map(t=>[t,[...new Set(e.map(e=>e[t]))]])):e;this.#i=t,this.#n=Object.keys(t).length>0,this.#e.toggleAttribute(`filtering`,this.#n),this.#s()};#s(){let e=this.#t.data.getArray(),t=this.#t.data.getHostFields(),n=this.#e.index,r=this.#t.exprEngine;if(!(Object.keys(this.#i).length>0)){e.forEach(e=>{e?.m?._?.[i.META.INDEX.FILTER]&&(e.m._[i.META.INDEX.FILTER][n]=!0)}),this.#e.invalidate();return}let a=Object.entries(this.#i).map(([e,n])=>{let r=e.includes(`data.`)||e.includes(`host.`)||e.includes(`rowItem.v`);return{targetKey:e,isExpr:r,fieldIdx:r?-1:t.indexOf(e),allowedSet:new Set(n)}});e.forEach((e,t)=>{if(!e)return;e.m._[i.META.INDEX.FILTER]||(e.m._[i.META.INDEX.FILTER]=[]);let o=!0;for(let n=0;n<a.length;n++){let{targetKey:i,isExpr:s,fieldIdx:c,allowedSet:l}=a[n],u;if(s&&r?u=r.evaluate(i,e,t):c>=0&&e.v&&(u=e.v[c]),!l.has(u)){o=!1;break}}e.m._[i.META.INDEX.FILTER][n]=o}),this.#e.invalidate()}};customElements.get(`nine-table-filter-panel`)||customElements.define(`nine-table-filter-panel`,D),customElements.get(`nine-table-filter-button`)||customElements.define(`nine-table-filter-button`,O);var A=class{#e;#t;#n=[];constructor(e){this.#e=e,this.#t=e.getRootNode().host,setTimeout(()=>{this.#r()},300)}#r(){this.#e.querySelectorAll(`thead`).forEach(e=>{e.addEventListener(`dblclick`,e=>{let t=e.target.closest(`th, td`);if(!t||t.classList.contains(`resizable-edge`)||[`INPUT`,`CELL-CHECKBOX`].includes(e.target.tagName)||e.offsetX<=2||e.offsetX>=t.offsetWidth-2)return;let n=this.#e.getRootNode().host;n.loading=!0,setTimeout(()=>{try{this.#i(e,t)}finally{n.loading=!1}})})})}#i(e,t){let n=t.dataset.col,r=t.closest(`tr`),i=r?r.dataset.subrow||String(r.sectionRowIndex):`0`;if(n===void 0)return;let a=this.#e.sourceTable;if(!a)return;let o=null,s=null;if(a.querySelectorAll(`tbody [data-col="${n}"]`).forEach(e=>{e.dataset.bind&&(o=e.dataset.bind),e.dataset.expr&&(s=e.dataset.expr)}),!o&&!s)return;let c=t.classList.contains(`asc`),l=t.classList.contains(`desc`);!e.ctrlKey&&!e.shiftKey&&(this.#n=[]);let u=this.#n.findIndex(e=>e.colIndex===n&&e.subRowIndex===i||e.colName===o),d={colIndex:n,subRowIndex:i,colname:o||s,colName:o||s,expr:s,asc:!0,"expr-func":s?(e,t)=>this.#t.exprEngine(s,e,t):null};!c&&!l?u>=0?this.#n[u].asc=!0:this.#n.push({...d,asc:!0}):c?u>=0?this.#n[u].asc=!1:this.#n.push({...d,asc:!1}):this.#n=this.#n.filter(e=>!(e.colIndex===n&&e.subRowIndex===i||e.colName===o)),this.#a()}#a(){this.#e.view&&(this.#e.view.setSorting(this.#n),this.#o(),this.#e.invalidate())}#o(){this.#e.querySelectorAll(`thead th, thead td`).forEach(e=>{e.classList.remove(`asc`,`desc`)}),this.#n.length!==0&&this.#n.forEach(e=>{let{colIndex:t,subRowIndex:n,asc:r}=e;if(t!==void 0){let e=`thead [data-col="${t}"]`;n!==void 0&&(e=`thead tr[data-subrow="${n}"] [data-col="${t}"]`),this.#e.querySelectorAll(e).forEach(e=>{e.classList.add(r?`asc`:`desc`)})}})}restore(){this.#n=[],this.#e.view&&this.#e.view.resetSorting(),this.#o(),this.#e.rowManager?.refresh(!0)}},j=class{#e;#t;#n=[];#r=[];#i=null;constructor(e){this.#e=e,this.#t=e.getRootNode().host,this.refresh()}getArray=(e,t)=>{if(!this.#i){let e=this.#t.data.getArray();this.#i=this.#r.map(t=>e[t])}let n=this.#i;if(e==null)return n;if(e<0||e>=n.length)return null;let r=n[e];if(t!=null){let e=this.#t.data.getHostFields().indexOf(t);return e>=0&&r.v?r.v[e]:null}return r};count=()=>{if(!this.#i){let e=this.#t.data.getArray();this.#i=this.#r.map(t=>e[t])}return this.#i.length};get=(e,t)=>{let n=this.getArray(),r=this.#t.data.getHostFields?.()||[];if(e==null)return n.map(e=>this.#a(e,r));if(e<0||e>=n.length)return null;let i=n[e];if(!i)return null;if(t!=null){let e=r.indexOf(t);return e>=0&&i.v?i.v[e]:null}return this.#a(i,r)};#a=(e,t)=>{if(!e)return null;let n={};return t.forEach((t,r)=>{n[t]=e.v?e.v[r]:e[t]}),e.m&&(n.m=e.m),e._&&(n._=e._),n};refresh=()=>{this.#i=null;let e=this.#t.data.getArray(),t=[];e.forEach((e,n)=>{if(!e)return;let r=e.m?._?.[i.META.INDEX.FILTER];r&&r[this.#e.index]===!1||t.push(n)}),this.#n.length>0&&(t=this.#o(t,e)),this.#r=t;let n=t.map(t=>e[t]),r=this.#e.grouping?.columns||[];if(r.length>0){let e=_.apply(n,r,this.#t.data.getHostFields());this.#i=e.renderItems,this.#e.grouping.setGroupMap(e.groupMap)}else this.#i=n};setSorting=e=>{this.#n=e||[],this.refresh()};getSorting=()=>this.#n;resetSorting=()=>{this.#n=[],this.refresh()};#o=(e,t)=>{let n=typeof this.#t.data.getHostFields==`function`?this.#t.data.getHostFields():[],r=this.#n.map(e=>({...e,colIndex:n.indexOf(e.colname||e.colName)}));return e.sort((e,n)=>{let i=t[e],a=t[n];for(let t of r){let r=t.asc,o=t.expr,s,c;o?(s=this.#t.exprEngine.evaluate(o,i,e),c=this.#t.exprEngine.evaluate(o,a,n)):t.colIndex>=0&&i.v&&a.v&&(s=i.v[t.colIndex],c=a.v[t.colIndex]);let l=s==null||s===``,u=c==null||c===``;if(!(l&&u)){if(l)return 1;if(u)return-1;if(s!==c){let e=0;if(typeof s==`number`&&typeof c==`number`)e=s-c;else{let t=String(s),n=String(c);e=t>n?1:t<n?-1:0}if(e!==0)return r?e:-e}}}return e-n})}},M=class e{static initializeTable(t,n){return e.#r(n),e.#a(n),e.#n(n),e.#u(n),e.#i(n),y.resetColIndex(n,n.querySelectorAll(`thead tr`)),y.resetColIndex(n,n.querySelectorAll(`tbody.body tr[grouping="true"]`)),y.resetColIndex(n,n.querySelectorAll(`tbody.body tr:not([grouping="true"])`)),y.resetColIndex(n,n.querySelectorAll(`tfoot tr`)),e.#e(n),e.#o(n),e.#s(t,n),e.#l(n),e.#c(t,n),e.#d(n),n}static#e(t){let n=t.querySelector(`thead`);if(!n||n.querySelector(`.col-indicator-rowgroup`))return;let r=n.insertRow(0);r.setAttribute(`role`,`row`),r.classList.add(`col-indicator-rowgroup`),r.classList.add(`collapse`);let i=t.querySelector(`tbody tr`);if(!i)return;let a=0;i.querySelectorAll(`th, td`).forEach(t=>{if(!t.classList.contains(`dummy`)){let n=t.colSpan||1;for(let t=0;t<n;t++){let t=`<th data-col="@col" class="col-indicator" scope="col"></th>`.replace(`@col`,a).replace(`@text`,e.#t(a++));r.insertAdjacentHTML(`beforeend`,t)}}});let o=Array.from(t.querySelectorAll(`colgroup col`));r.querySelectorAll(`.col-indicator`).forEach((e,t)=>{let n=o[t].getAttribute(`background`);n&&(e.style.background=n)})}static#t(e){let t=``;for(let n=e;n>=0;n=Math.floor(n/26)-1)t=String.fromCharCode(65+n%26)+t;return t}static#n(e){let t=e.querySelector(`tbody:not(.head):not(.foot)`);if(t){if(t.classList.add(`body`),!e.querySelector(`tbody.head`)){let e=document.createElement(`tbody`);e.classList.add(`head`),t.before(e)}if(!e.querySelector(`tbody.foot`)){let e=document.createElement(`tbody`);e.classList.add(`foot`),t.after(e)}}}static#r(e){let t=e.querySelector(`colgroup`);if(t||(t=document.createElement(`colgroup`),e.prepend(t)),t.querySelectorAll(`col`).length===0){let n=e.querySelector(`tbody tr`),r=1;n&&(r=Array.from(n.querySelectorAll(`th, td`)).reduce((e,t)=>e+(parseInt(t.getAttribute(`colspan`)||t.colSpan,10)||1),0)),r=Math.max(r,1);for(let e=0;e<r;e++){let e=document.createElement(`col`);t.appendChild(e)}}}static#i(e){let t=Array.from(e.querySelectorAll(`colgroup col`));if(t.length===0)return;let n=e.clientWidth||0,r=Math.max(Math.floor(n/t.length),100);t.forEach((e,t)=>{e.hasAttribute(`data-col`)||e.setAttribute(`data-col`,t);let n=e.getAttribute(`width`)||parseInt(e.style.width,10)||r;e.setAttribute(`width`,n);let i=String(n).includes(`px`)?n:`${n}px`;e.style.width=i})}static#a(e){if(e.querySelector(`thead`))return;let t=document.createElement(`thead`),n=e.querySelector(`colgroup`);n?n.after(t):e.prepend(t)}static#o(e){e.querySelectorAll(`thead th, thead td`).forEach(e=>{e.getAttribute(`collapsed`)===`true`&&e.getAttribute(`collapsible`)!==`true`&&e.setAttribute(`collapsible`,`true`)})}static#s(e,t){let n=[`data-bind`,`data-expr`,`type`],r=0;t.querySelectorAll(`tbody th, tbody td`).forEach(t=>{let i=`cell-${t.getAttribute(`cell-type`)||`renderer`}`,a=t.querySelector(`datalist`);if(a){let n=[];a.querySelectorAll(`option`).forEach(e=>{n.push({k:e.getAttribute(`k`),v:e.getAttribute(`v`),value:e.getAttribute(`value`)})});let i=`__ds_${Date.now()}_${++r}`;e&&(e[i]=()=>n),t.setAttribute(`data-source`,`host.${i}()`),a.remove()}let o=t.dataset.expr;o&&t.setAttribute(`data-expr`,e.exprEngine.precompile(o)),Array.from(t.attributes).forEach(n=>{[`data-bind`,`data-expr`,`cell-type`,`validator`].includes(n.name)||(n.value.includes(`data.`)||n.value.includes(`host.`))&&t.setAttribute(n.name,e.exprEngine.precompile(n.value))}),t.innerHTML=`<${i} ${n.filter(e=>t.hasAttribute(e)).map(e=>`${e}="${t.getAttribute(e)}"`).join(` `)}></${i}>`,t.setAttribute(`tabindex`,`0`)}),t.querySelectorAll(`thead th, thead td, tfoot th, tfoot td`).forEach(e=>{let t=e.getAttribute(`cell-type`);if(t){let r=e.innerHTML,i=`cell-${t}`;e.innerHTML=`<${i} ${n.filter(t=>e.hasAttribute(t)).map(t=>`${t}="${e.getAttribute(t)}"`).join(` `)} content="${r}"></${i}>`}})}static#c(e,t){let n=e.getAttribute(`filtering`)===`true`,r=t.getAttribute(`filtering`)===`true`;t.querySelectorAll(`thead tr:not(.col-indicator-rowgroup) th, thead tr:not(.col-indicator-rowgroup) td`).forEach(e=>{let t=e.getAttribute(`filtering`)===`true`||r||n;e.setAttribute(`filtering`,t?`true`:`false`),t&&e.appendChild(document.createElement(`nine-table-filter-button`))})}static#l(e){e.querySelectorAll(`thead th, thead td`).forEach(t=>{if(t.getAttribute(`collapsible`)!==`true`&&t.getAttribute(`expandable`)!==`true`)return;let n=parseInt(t.dataset.col,10),r=t.colSpan||1,i=e.querySelector(`colgroup col[data-col="${n}"]`),a=i&&parseInt(i.getAttribute(`width`),10)||100;(!t.dataset.expandWidth||parseInt(t.dataset.expandWidth,10)<=16)&&(t.dataset.expandWidth=String(a>16?a:100));let o=t.querySelector(`nine-table-col-expand`);if(o||(o=document.createElement(`nine-table-col-expand`),t.insertBefore(o,t.firstChild)),t.getAttribute(`collapsed`)===`true`){o.classList.add(`collapsed`),o.classList.remove(`expand`),o.setAttribute(`collapsed`,`true`),t.style.color=`transparent`;let i=Math.max(10,Math.floor(16/r));if(!isNaN(n))for(let t=0;t<r;t++){let r=e.querySelector(`colgroup col[data-col="${n+t}"]`);r&&(r.setAttribute(`width`,i),r.style.width=`${i}px`)}}else o.classList.remove(`collapsed`),o.classList.add(`expand`),o.setAttribute(`collapsed`,`false`),t.style.color=``})}static#u(e,t){let n=e.getAttribute(`row-indicator`)===`true`?48:0,r=e.querySelector(`colgroup`),i=document.createElement(`col`);i.setAttribute(`fixed`,`left`),i.setAttribute(`width`,n),i.style.width=`${n}px`,r.prepend(i),e.querySelectorAll(`thead, tbody, tfoot`).forEach(e=>{let t=Array.from(e.querySelectorAll(`tr`));if(t.length===0)return;let n=t[0],r=document.createElement(`th`);r.className=`row-indicator`,r.setAttribute(`cell-type`,`row-indicator`),t.length>1&&(r.rowSpan=t.length),n.insertBefore(r,n.firstElementChild)})}static#d(e){e.querySelectorAll(`th[data-col], td[data-col]`).forEach(t=>{let n=parseInt(t.getAttribute(`data-col`),10);if(isNaN(n))return;let r=parseInt(t.getAttribute(`colspan`)||t.colSpan,10)||1,i=0;for(let t=0;t<r;t++){let r=n+t,a=e.querySelector(`colgroup col[data-col="${r}"]`);a&&(i+=parseInt(a.getAttribute(`width`),10)||100)}if(i>0){let e=`${i}px`;t.style.width=e,t.style.minWidth=e,t.style.maxWidth=e}})}},N=class extends HTMLElement{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f={table:null};#p;static SCROLLBAR_SIZE=16;constructor(){super(),this.#t=this.getRootNode().host,this.#n=new v(this)}connectedCallback(){this.#b()}get index(){return this.#e}get colResizer(){return this.#a}get filtering(){return this.#l}get grouping(){return this.#u}get colMover(){return this.#o}get colFix(){return this.#s}get rowManager(){return this.#n}get selection(){return this.#r}get navigation(){return this.#i}get templateLength(){return this.#f.tbody.tr.length||0}get elements(){return this.#p}get isAutoFitCol(){let e=this.getAttribute(`auto-fit-col`)===`true`||this.#t?.getAttribute(`auto-fit-col`)===`true`,t=this.#f.table?.getAttribute(`auto-fit-col`)===`true`;return e||t}get sourceTable(){return this.#f.table}get source(){return this.#f}get#m(){return this.#t.hasAttribute(`simple`)||this.#t.getAttribute(`theme`)===`simple`}scrollTo=(e,t)=>{this.rowManager.scrollToDataRow(e,`top`,t)};recompileAndRefresh(){this.#f.table&&(y.recompile(this.#f.table),[`left`,`right`,`body`].forEach(e=>{[`header`,`body`,`footer`].forEach(t=>{let n=this.querySelector(`.ng-sheet-${t} .ng-container-${e}`);n&&n.querySelectorAll(`table`).forEach(e=>e.remove())})}),this.#v(),this.#_(),this.#n.initialize(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`)?.refresh(),requestAnimationFrame(()=>{this.#_(),this.#n?.refresh()}))}refreshLayout(){requestAnimationFrame(()=>{this.classList.contains(`active`)&&this.#f.table&&(this.#_(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`)?.refresh(),this.#h(),this.#a?.refreshLayout(),this.#n?.refresh())})}#h=()=>{let e=this.querySelector(`.ng-container-body thead`),t=this.querySelector(`.nodata-overlay`);t.style.top=`${e.offsetHeight}px`};get view(){return!this.#d&&this.#t?.data&&(this.#d=new j(this)),this.#d}invalidate=()=>{this.view.refresh(),this.#n.refresh(!0),this.isAutoFitCol&&this.autoFit(!0)};autoFit=(e=!0)=>{requestAnimationFrame(()=>{this.#g?.(e)})};#g=(e=!0)=>{let t=this.querySelector(`.ng-sheet-body .ng-container-body`);if(!t)return;let n=this.querySelector(`.ng-container-body table colgroup`);if(n){if(e){this.setAttribute(`auto-fit-col`,`true`);let e=t.clientWidth;if(e<=0)return;let r=0,i=[];n.querySelectorAll(`col`).forEach(e=>{let t=e.getAttribute(`data-col`);if(this.querySelector(`thead th[data-col="${t}"]`)?.getAttribute(`collapsed`)===`true`)i.unshift({globalColIndex:t,width:16,isCollapsed:!0});else{let n=parseInt(e.getAttribute(`width`),10)||100;i.push({globalColIndex:t,width:n,isCollapsed:!1}),r+=n}});let a=i.filter(e=>e.isCollapsed).reduce((e,t)=>e+t.width,0),o=Math.max(0,e-a);if(r>0&&i.length>0){let e=0,t=i.map(t=>{if(t.isCollapsed)return{globalColIndex:t.globalColIndex,remainder:0,width:16};let n=t.width*o/r,i=Math.max(30,Math.floor(n));return e+=i,{globalColIndex:t.globalColIndex,remainder:n-Math.floor(n),width:i}}),n=o-e,a=t.filter(e=>!i.find(t=>t.globalColIndex===e.globalColIndex)?.isCollapsed);if(n>0&&a.length>0){a.sort((e,t)=>t.remainder-e.remainder);for(let e=0;e<n;e++)a[e%a.length].width+=1}else if(n<0&&a.length>0){a.sort((e,t)=>e.remainder-t.remainder);for(let e=0;e<Math.abs(n);e++){let t=a[e%a.length];t.width>30&&--t.width}}t.forEach(({globalColIndex:e,width:t})=>{this.#a?.setColumnWidth(e,t,`body`)})}}else this.removeAttribute(`auto-fit-col`);this.querySelector(`nine-table-hscrollbar`)?.refresh()}};generate=(e,t)=>{e.style.display=`none`,this.#e=t,M.initializeTable(this.#t,e),e.style.display=``,this.#f={table:y.compile(e),tbody:{tr:e.querySelectorAll(`tbody tr`)}},this.#v(),this.#_(),this.#S(),this.#w(),[`left`,`body`,`right`].forEach(e=>{let t=`.ng-container-${e}`;this.#p[e]={thead:this.querySelector(`${t} thead`),tbody:{head:this.querySelector(`${t} tbody.head`),body:this.querySelector(`${t} tbody.body`),foot:this.querySelector(`${t} tbody.foot`)},tfoot:this.querySelector(`${t} tfoot`)}}),this.#n.initialize(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`).refresh(),this.#u.initialize(),this.loaded=!0};#_=()=>{[`left`,`right`,`body`].forEach(e=>{let t=this.querySelectorAll(`.ng-container-${e}`);if(t.length===0)return;let n=t[0].querySelector(`table`);if(!n)return;let r=0;n.querySelectorAll(`col`).forEach(e=>{let t=parseInt(e.getAttribute(`width`),10);isNaN(t)||(r+=t)}),t.forEach(t=>{t.querySelectorAll(`table`),e===`body`?t.style.flex=`1`:(t.style.flex=`0 0 ${r}px`,t.style.width=`${r}px`,t.style.minWidth=`${r}px`,t.style.maxWidth=`${r}px`)})})};#v=()=>{[{selector:`.ng-container-left`,type:`left`},{selector:`.ng-container-body`,type:null},{selector:`.ng-container-right`,type:`right`}].forEach(({selector:e,type:t})=>{this.querySelector(`.ng-sheet-body ${e}`).appendChild(this.#y(t))})};#y=e=>{let t=this.#f.table.cloneNode(!0);return e===`left`?t.querySelectorAll(`col, th, td`).forEach(e=>{e.getAttribute(`fixed`)!==`left`&&e.remove()}):e===`right`?t.querySelectorAll(`col, th, td`).forEach(e=>{e.getAttribute(`fixed`)!==`right`&&e.remove()}):t.querySelectorAll(`[fixed=left], [fixed=right]`).forEach(e=>{e.remove()}),t};getRowHeight=()=>this.#n.getRowHeight();getViewHeight=()=>(this.#p.content.offsetHeight||0)-((this.#p.body.thead?.offsetHeight||0)+(this.#p.body.tfoot?.offsetHeight||0)+(this.#p.body.tbody.head.offsetHeight||0));isLastRow=()=>{let e=this.querySelector(`.ng-sheet-body`),t=this.querySelector(`.ng-container-body tbody.body`),n=this.#p.body.tfoot?.offsetHeight||0,r=e.getBoundingClientRect().bottom,i=t.getBoundingClientRect().bottom;return r-n>=i};scrollToX=e=>{let t=this.querySelector(`.ng-sheet-body .ng-container-body`);t&&(t.scrollLeft=e)};scrollToY=e=>{let t=this.querySelector(`.ng-sheet-body`);t&&(t.scrollTop=e)};#b=()=>{this.#x(),this.#r=new b(this),this.#i=new x(this),this.#a=new C(this),this.#o=new T(this),this.#s=new E(this),this.#d=new j(this),this.#l=new k(this),this.#u=new g(this),this.#m||(this.#c=new A(this)),this.#p.mainBody.addEventListener(`scroll`,()=>{this.querySelector(`nine-table-hscrollbar`).refresh()})};#x=()=>{this.innerHTML=`
|
|
58
|
+
`};open(e){this.#i=e;let t=e.closest(`th, td`);this.currentCol=t?.dataset.col;let n=t.getBoundingClientRect(),r=this.#e.getBoundingClientRect(),i=this.offsetWidth||240,a=n.right-r.left-i,o=n.bottom-r.top;a<0&&(a=Math.max(0,n.left-r.left)),this.style.left=`${a}px`,this.style.top=`${o}px`;let s=this.querySelector(`.search-box`);s.value=``,this.classList.add(`active`),this.classList.add(`loading`),setTimeout(()=>{try{this.#c(),this.#r.rowManager.scrollToDataRow(0),s.focus()}finally{this.classList.remove(`loading`)}})}#s=e=>{let t=e.composedPath?e.composedPath():[];t.includes(this)||this.#i&&t.includes(this.#i)||this.close()};close(){this.currentCol=null,this.classList.remove(`active`),this.#i=null}#c(){let e=this.#t.data.getArray(),t=this.#i?.columns||[],n=this.#t.fields.get()||[],r=this.#e.filtering?.filters||{},i=this.#t.exprEngine,a=t.flatMap(t=>{let a=t.bind,o=t.expr,s=a||o,c=a?n.indexOf(a):-1,l=r[s]||[],u=new Map;for(let t=0;t<e.length;t++){let n=e[t];if(!n)continue;let r;c>=0&&n.v?r=n.v[c]:a&&a.includes(`data.`)?r=i?i.evaluate(a,n,t):void 0:o&&i&&(r=i.evaluate(o,n,t));let s=r;o&&i&&(s=i.evaluate(o,n,t)),s!=null&&!u.has(s)&&u.set(s,{v:r,v2:s})}let d=[...u.values()];return d.sort((e,t)=>{let n=e.v2,r=t.v2;if(n===r)return 0;if(n==null||n===``)return 1;if(r==null||r===``)return-1;let i=Number(n),a=Number(r);return!isNaN(i)&&!isNaN(a)?i-a:String(n).localeCompare(String(r))}),l.sort((e,t)=>e>t?1:-1),d.map(e=>({LVL:2,DATA:e.v,DATA2:e.v2===``||e.v2===null||e.v2===void 0?`<span class="empty-value">(empty)</span>`:e.v2,COLNM:s,CHK:l.length===0||l.nineBinarySearch(e.v)>=0?`Y`:`N`}))});this.#n.data.set(a);let o=this.querySelector(`#chkSelectAll`);o&&(o.checked=a.length>0&&a.every(e=>e.CHK===`Y`))}#l=()=>{this.#t.loading=!0;let e=this.#r.view.getArray(),t=this.#n.data.getHostFields(),n=e.filter(e=>{let n=e.v[t.indexOf(`CHK`)];return n===`Y`||n===!0}),r={...this.#e.filtering?.filters||{}};this.#i.columns.forEach(e=>{let i=e.expr||e.bind,a=e.expr?t.indexOf(`DATA2`):t.indexOf(`DATA`),o=n.map(e=>e.v[a]);o.length>0?r[i]=o:delete r[i]});let i=this.#n.data.count();setTimeout(()=>{try{i===n.length?this.#i.columns.forEach(e=>{let t=e.expr||e.bind;t&&this.#e.filtering.clear(t)}):this.#e.filtering.set(r),this.#e.querySelectorAll(`nine-table-filter-button`).forEach(e=>{e.updateFilteredState()}),this.#e.invalidate(),this.close()}finally{this.#t.loading=!1}})};#u=e=>{let t=e.target.value.toLowerCase().trim();if(!t)this.#r.filtering.clear();else{let e=this.#n.data.getArray(),n=this.#n.data.getHostFields().indexOf(`DATA2`),r=[];e.forEach(e=>{let i=n>=0&&e.v?e.v[n]:``;String(i).replace(/<[^>]*>?/gm,``).toLowerCase().includes(t)&&r.push(i)}),this.#r.filtering.set({DATA2:[...new Set(r)]})}};#d=e=>{let t=e.target.checked,n=this.#n?.data?.getArray()||[],r=this.#n.data.getHostFields().indexOf(`CHK`);r>=0&&n.forEach(e=>{e.v[r]=t?`Y`:`N`}),this.#n.refresh()}},O=class extends HTMLElement{#e;#t=null;connectedCallback(){this.#e=this.closest(`nine-table-sheet`)||this.getRootNode().host,this.removeEventListener(`click`,this.#n),this.addEventListener(`click`,this.#n)}get columns(){if(this.#t)return this.#t;let e=this.closest(`th, td`)?.dataset.col,t=this.#e.sourceTable,n=[],r=new Set;return t&&e!==void 0&&t.querySelectorAll(`tbody [data-col="${e}"]`).forEach(e=>{let t=e.dataset.bind,i=e.dataset.expr;if(t||i){let e=`${t||``}_${i||``}`;r.has(e)||(r.add(e),n.push({bind:t,expr:i}))}}),this.#t=n,this.#t}updateFilteredState=()=>{let e=this.#e.filtering?.filters||{},t=this.columns.some(t=>{let n=t.expr||t.bind;return n&&e[n]&&e[n].length>0});this.classList.toggle(`filtered`,t)};#n=e=>{e.preventDefault(),e.stopPropagation();let t=this.#e.querySelector(`nine-table-filter-panel`),n=this.closest(`th, td`).dataset.col;t&&t.currentCol===n&&t.classList.contains(`active`)?t.close():t&&t.open(this)}},k=class{#e;#t;#n=!1;#r=null;#i={};constructor(e){this.#e=e,this.#t=this.#e.getRootNode().host,this.#a()}get filters(){return this.#i}#a=()=>{this.#o()};#o=()=>{if(this.#t.tagName.toLowerCase()===`nine-table-simple`)return;let e=this.#e.querySelector(`nine-table-filter-panel`);e||(e=document.createElement(`nine-table-filter-panel`),this.#e.appendChild(e)),this.#r=e};isFiltering(){return this.#n}clear=e=>{e?delete this.#i[e]:this.#i={},this.#n=Object.keys(this.#i).length>0,this.#s(),this.#e.querySelectorAll(`nine-table-filter-button`).forEach(e=>{e.updateFilteredState()})};set=e=>{let t=Array.isArray(e)?Object.fromEntries(Object.keys(e[0]).map(t=>[t,[...new Set(e.map(e=>e[t]))]])):e;this.#i=t,this.#n=Object.keys(t).length>0,this.#e.toggleAttribute(`filtering`,this.#n),this.#s()};#s(){let e=this.#t.data.getArray(),t=this.#t.data.getHostFields(),n=this.#e.index,r=this.#t.exprEngine;if(!(Object.keys(this.#i).length>0)){e.forEach(e=>{e?.m?._?.[i.META.INDEX.FILTER]&&(e.m._[i.META.INDEX.FILTER][n]=!0)}),this.#e.invalidate();return}let a=Object.entries(this.#i).map(([e,n])=>{let r=e.includes(`data.`)||e.includes(`host.`)||e.includes(`rowItem.v`);return{targetKey:e,isExpr:r,fieldIdx:r?-1:t.indexOf(e),allowedSet:new Set(n)}});e.forEach((e,t)=>{if(!e)return;e.m._[i.META.INDEX.FILTER]||(e.m._[i.META.INDEX.FILTER]=[]);let o=!0;for(let n=0;n<a.length;n++){let{targetKey:i,isExpr:s,fieldIdx:c,allowedSet:l}=a[n],u;if(s&&r?u=r.evaluate(i,e,t):c>=0&&e.v&&(u=e.v[c]),!l.has(u)){o=!1;break}}e.m._[i.META.INDEX.FILTER][n]=o}),this.#e.invalidate()}};customElements.get(`nine-table-filter-panel`)||customElements.define(`nine-table-filter-panel`,D),customElements.get(`nine-table-filter-button`)||customElements.define(`nine-table-filter-button`,O);var A=class{#e;#t;#n=[];constructor(e){this.#e=e,this.#t=e.getRootNode().host,setTimeout(()=>{this.#r()},300)}#r(){this.#e.querySelectorAll(`thead`).forEach(e=>{e.addEventListener(`dblclick`,e=>{let t=e.target.closest(`th, td`);if(!t||t.classList.contains(`resizable-edge`)||[`INPUT`,`CELL-CHECKBOX`].includes(e.target.tagName)||e.offsetX<=2||e.offsetX>=t.offsetWidth-2)return;let n=this.#e.getRootNode().host;n.loading=!0,setTimeout(()=>{try{this.#i(e,t)}finally{n.loading=!1}})})})}#i(e,t){let n=t.dataset.col,r=t.closest(`tr`),i=r?r.dataset.subrow||String(r.sectionRowIndex):`0`;if(n===void 0)return;let a=this.#e.sourceTable;if(!a)return;let o=null,s=null;if(a.querySelectorAll(`tbody [data-col="${n}"]`).forEach(e=>{e.dataset.bind&&(o=e.dataset.bind),e.dataset.expr&&(s=e.dataset.expr)}),!o&&!s)return;let c=t.classList.contains(`asc`),l=t.classList.contains(`desc`);!e.ctrlKey&&!e.shiftKey&&(this.#n=[]);let u=this.#n.findIndex(e=>e.colIndex===n&&e.subRowIndex===i||e.colName===o),d={colIndex:n,subRowIndex:i,colname:o||s,colName:o||s,expr:s,asc:!0,"expr-func":s?(e,t)=>this.#t.exprEngine(s,e,t):null};!c&&!l?u>=0?this.#n[u].asc=!0:this.#n.push({...d,asc:!0}):c?u>=0?this.#n[u].asc=!1:this.#n.push({...d,asc:!1}):this.#n=this.#n.filter(e=>!(e.colIndex===n&&e.subRowIndex===i||e.colName===o)),this.#a(t)}#a(e){this.#e.view.setSorting(this.#n),this.#o(),this.#e.invalidate(),requestAnimationFrame(()=>{let t=this.#e.querySelectorAll(`tbody.body th, tbody.body td`);t.forEach(t=>{t.classList.remove(`sorting-anim-asc`,`sorting-anim-desc`,`sorting-anim-none`),e.classList.contains(`asc`)?t.classList.add(`sorting-anim-asc`):e.classList.contains(`desc`)?t.classList.add(`sorting-anim-desc`):t.classList.add(`sorting-anim-none`)}),requestAnimationFrame(()=>{t.forEach(e=>{e.classList.remove(`sorting-anim-asc`,`sorting-anim-desc`,`sorting-anim-none`)})})})}#o(){this.#e.querySelectorAll(`thead th, thead td`).forEach(e=>{e.classList.remove(`asc`,`desc`)}),this.#n.length!==0&&this.#n.forEach(e=>{let{colIndex:t,subRowIndex:n,asc:r}=e;if(t!==void 0){let e=`thead [data-col="${t}"]`;n!==void 0&&(e=`thead tr[data-subrow="${n}"] [data-col="${t}"]`),this.#e.querySelectorAll(e).forEach(e=>{e.classList.add(r?`asc`:`desc`)})}})}restore(){this.#n=[],this.#e.view&&this.#e.view.resetSorting(),this.#o(),this.#e.rowManager?.refresh(!0)}},j=class{#e;#t;#n=[];#r=[];#i=null;constructor(e){this.#e=e,this.#t=e.getRootNode().host,this.refresh()}getArray=(e,t)=>{if(!this.#i){let e=this.#t.data.getArray();this.#i=this.#r.map(t=>e[t])}let n=this.#i;if(e==null)return n;if(e<0||e>=n.length)return null;let r=n[e];if(t!=null){let e=this.#t.data.getHostFields().indexOf(t);return e>=0&&r.v?r.v[e]:null}return r};count=()=>{if(!this.#i){let e=this.#t.data.getArray();this.#i=this.#r.map(t=>e[t])}return this.#i.length};get=(e,t)=>{let n=this.getArray(),r=this.#t.data.getHostFields?.()||[];if(e==null)return n.map(e=>this.#a(e,r));if(e<0||e>=n.length)return null;let i=n[e];if(!i)return null;if(t!=null){let e=r.indexOf(t);return e>=0&&i.v?i.v[e]:null}return this.#a(i,r)};#a=(e,t)=>{if(!e)return null;let n={};return t.forEach((t,r)=>{n[t]=e.v?e.v[r]:e[t]}),e.m&&(n.m=e.m),e._&&(n._=e._),n};refresh=()=>{this.#i=null;let e=this.#t.data.getArray(),t=[];e.forEach((e,n)=>{if(!e)return;let r=e.m?._?.[i.META.INDEX.FILTER];r&&r[this.#e.index]===!1||t.push(n)}),this.#n.length>0&&(t=this.#o(t,e)),this.#r=t;let n=t.map(t=>e[t]),r=this.#e.grouping?.columns||[];if(r.length>0){let e=_.apply(n,r,this.#t.data.getHostFields());this.#i=e.renderItems,this.#e.grouping.setGroupMap(e.groupMap)}else this.#i=n};setSorting=e=>{this.#n=e||[],this.refresh()};getSorting=()=>this.#n;resetSorting=()=>{this.#n=[],this.refresh()};#o=(e,t)=>{let n=typeof this.#t.data.getHostFields==`function`?this.#t.data.getHostFields():[],r=this.#n.map(e=>({...e,colIndex:n.indexOf(e.colname||e.colName)}));return e.sort((e,n)=>{let i=t[e],a=t[n];for(let t of r){let r=t.asc,o=t.expr,s,c;o?(s=this.#t.exprEngine.evaluate(o,i,e),c=this.#t.exprEngine.evaluate(o,a,n)):t.colIndex>=0&&i.v&&a.v&&(s=i.v[t.colIndex],c=a.v[t.colIndex]);let l=s==null||s===``,u=c==null||c===``;if(!(l&&u)){if(l)return 1;if(u)return-1;if(s!==c){let e=0;if(typeof s==`number`&&typeof c==`number`)e=s-c;else{let t=String(s),n=String(c);e=t>n?1:t<n?-1:0}if(e!==0)return r?e:-e}}}return e-n})}},M=class e{static initializeTable(t,n){return e.#r(n),e.#a(n),e.#n(n),e.#u(n),e.#i(n),y.resetColIndex(n,n.querySelectorAll(`thead tr`)),y.resetColIndex(n,n.querySelectorAll(`tbody.body tr[grouping="true"]`)),y.resetColIndex(n,n.querySelectorAll(`tbody.body tr:not([grouping="true"])`)),y.resetColIndex(n,n.querySelectorAll(`tfoot tr`)),e.#e(n),e.#o(n),e.#s(t,n),e.#l(n),e.#c(t,n),e.#d(n),n}static#e(t){let n=t.querySelector(`thead`);if(!n||n.querySelector(`.col-indicator-rowgroup`))return;let r=n.insertRow(0);r.setAttribute(`role`,`row`),r.classList.add(`col-indicator-rowgroup`),r.classList.add(`collapse`);let i=t.querySelector(`tbody tr`);if(!i)return;let a=0;i.querySelectorAll(`th, td`).forEach(t=>{if(!t.classList.contains(`dummy`)){let n=t.colSpan||1;for(let t=0;t<n;t++){let t=`<th data-col="@col" class="col-indicator" scope="col"></th>`.replace(`@col`,a).replace(`@text`,e.#t(a++));r.insertAdjacentHTML(`beforeend`,t)}}});let o=Array.from(t.querySelectorAll(`colgroup col`));r.querySelectorAll(`.col-indicator`).forEach((e,t)=>{let n=o[t].getAttribute(`background`);n&&(e.style.background=n)})}static#t(e){let t=``;for(let n=e;n>=0;n=Math.floor(n/26)-1)t=String.fromCharCode(65+n%26)+t;return t}static#n(e){let t=e.querySelector(`tbody:not(.head):not(.foot)`);if(t){if(t.classList.add(`body`),!e.querySelector(`tbody.head`)){let e=document.createElement(`tbody`);e.classList.add(`head`),t.before(e)}if(!e.querySelector(`tbody.foot`)){let e=document.createElement(`tbody`);e.classList.add(`foot`),t.after(e)}}}static#r(e){let t=e.querySelector(`colgroup`);if(t||(t=document.createElement(`colgroup`),e.prepend(t)),t.querySelectorAll(`col`).length===0){let n=e.querySelector(`tbody tr`),r=1;n&&(r=Array.from(n.querySelectorAll(`th, td`)).reduce((e,t)=>e+(parseInt(t.getAttribute(`colspan`)||t.colSpan,10)||1),0)),r=Math.max(r,1);for(let e=0;e<r;e++){let e=document.createElement(`col`);t.appendChild(e)}}}static#i(e){let t=Array.from(e.querySelectorAll(`colgroup col`));if(t.length===0)return;let n=e.clientWidth||0,r=Math.max(Math.floor(n/t.length),100);t.forEach((e,t)=>{e.hasAttribute(`data-col`)||e.setAttribute(`data-col`,t);let n=e.getAttribute(`width`)||parseInt(e.style.width,10)||r;e.setAttribute(`width`,n);let i=String(n).includes(`px`)?n:`${n}px`;e.style.width=i})}static#a(e){if(e.querySelector(`thead`))return;let t=document.createElement(`thead`),n=e.querySelector(`colgroup`);n?n.after(t):e.prepend(t)}static#o(e){e.querySelectorAll(`thead th, thead td`).forEach(e=>{e.getAttribute(`collapsed`)===`true`&&e.getAttribute(`collapsible`)!==`true`&&e.setAttribute(`collapsible`,`true`)})}static#s(e,t){let n=[`data-bind`,`data-expr`,`type`],r=0;t.querySelectorAll(`tbody th, tbody td`).forEach(t=>{let i=`cell-${t.getAttribute(`cell-type`)||`renderer`}`,a=t.querySelector(`datalist`);if(a){let n=[];a.querySelectorAll(`option`).forEach(e=>{n.push({k:e.getAttribute(`k`),v:e.getAttribute(`v`),value:e.getAttribute(`value`)})});let i=`__ds_${Date.now()}_${++r}`;e&&(e[i]=()=>n),t.setAttribute(`data-source`,`host.${i}()`),a.remove()}let o=t.dataset.expr;o&&t.setAttribute(`data-expr`,e.exprEngine.precompile(o)),Array.from(t.attributes).forEach(n=>{[`data-bind`,`data-expr`,`cell-type`,`validator`].includes(n.name)||(n.value.includes(`data.`)||n.value.includes(`host.`))&&t.setAttribute(n.name,e.exprEngine.precompile(n.value))}),t.innerHTML=`<${i} ${n.filter(e=>t.hasAttribute(e)).map(e=>`${e}="${t.getAttribute(e)}"`).join(` `)}></${i}>`,t.setAttribute(`tabindex`,`0`)}),t.querySelectorAll(`thead th, thead td, tfoot th, tfoot td`).forEach(e=>{let t=e.getAttribute(`cell-type`);if(t){let r=e.innerHTML,i=`cell-${t}`;e.innerHTML=`<${i} ${n.filter(t=>e.hasAttribute(t)).map(t=>`${t}="${e.getAttribute(t)}"`).join(` `)} content="${r}"></${i}>`}})}static#c(e,t){let n=e.getAttribute(`filtering`)===`true`,r=t.getAttribute(`filtering`)===`true`;t.querySelectorAll(`thead tr:not(.col-indicator-rowgroup) th, thead tr:not(.col-indicator-rowgroup) td`).forEach(e=>{let t=e.getAttribute(`filtering`)===`true`||r||n;e.setAttribute(`filtering`,t?`true`:`false`),t&&e.appendChild(document.createElement(`nine-table-filter-button`))})}static#l(e){e.querySelectorAll(`thead th, thead td`).forEach(t=>{if(t.getAttribute(`collapsible`)!==`true`&&t.getAttribute(`expandable`)!==`true`)return;let n=parseInt(t.dataset.col,10),r=t.colSpan||1,i=e.querySelector(`colgroup col[data-col="${n}"]`),a=i&&parseInt(i.getAttribute(`width`),10)||100;(!t.dataset.expandWidth||parseInt(t.dataset.expandWidth,10)<=16)&&(t.dataset.expandWidth=String(a>16?a:100));let o=t.querySelector(`nine-table-col-expand`);if(o||(o=document.createElement(`nine-table-col-expand`),t.insertBefore(o,t.firstChild)),t.getAttribute(`collapsed`)===`true`){o.classList.add(`collapsed`),o.classList.remove(`expand`),o.setAttribute(`collapsed`,`true`),t.style.color=`transparent`;let i=Math.max(10,Math.floor(16/r));if(!isNaN(n))for(let t=0;t<r;t++){let r=e.querySelector(`colgroup col[data-col="${n+t}"]`);r&&(r.setAttribute(`width`,i),r.style.width=`${i}px`)}}else o.classList.remove(`collapsed`),o.classList.add(`expand`),o.setAttribute(`collapsed`,`false`),t.style.color=``})}static#u(e,t){let n=e.getAttribute(`row-indicator`)===`true`?48:0,r=e.querySelector(`colgroup`),i=document.createElement(`col`);i.setAttribute(`fixed`,`left`),i.setAttribute(`width`,n),i.style.width=`${n}px`,r.prepend(i),e.querySelectorAll(`thead, tbody, tfoot`).forEach(e=>{let t=Array.from(e.querySelectorAll(`tr`));if(t.length===0)return;let n=t[0],r=document.createElement(`th`);r.className=`row-indicator`,r.setAttribute(`cell-type`,`row-indicator`),t.length>1&&(r.rowSpan=t.length),n.insertBefore(r,n.firstElementChild)})}static#d(e){e.querySelectorAll(`th[data-col], td[data-col]`).forEach(t=>{let n=parseInt(t.getAttribute(`data-col`),10);if(isNaN(n))return;let r=parseInt(t.getAttribute(`colspan`)||t.colSpan,10)||1,i=0;for(let t=0;t<r;t++){let r=n+t,a=e.querySelector(`colgroup col[data-col="${r}"]`);a&&(i+=parseInt(a.getAttribute(`width`),10)||100)}if(i>0){let e=`${i}px`;t.style.width=e,t.style.minWidth=e,t.style.maxWidth=e}})}},N=class extends HTMLElement{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f={table:null};#p;static SCROLLBAR_SIZE=16;constructor(){super(),this.#t=this.getRootNode().host,this.#n=new v(this)}connectedCallback(){this.#b()}get index(){return this.#e}get colResizer(){return this.#a}get filtering(){return this.#l}get grouping(){return this.#u}get colMover(){return this.#o}get colFix(){return this.#s}get rowManager(){return this.#n}get selection(){return this.#r}get navigation(){return this.#i}get templateLength(){return this.#f.tbody.tr.length||0}get elements(){return this.#p}get isAutoFitCol(){let e=this.getAttribute(`auto-fit-col`)===`true`||this.#t?.getAttribute(`auto-fit-col`)===`true`,t=this.#f.table?.getAttribute(`auto-fit-col`)===`true`;return e||t}get sourceTable(){return this.#f.table}get source(){return this.#f}get#m(){return this.#t.hasAttribute(`simple`)||this.#t.getAttribute(`theme`)===`simple`}scrollTo=(e,t)=>{this.rowManager.scrollToDataRow(e,`top`,t)};recompileAndRefresh(){this.#f.table&&(y.recompile(this.#f.table),[`left`,`right`,`body`].forEach(e=>{[`header`,`body`,`footer`].forEach(t=>{let n=this.querySelector(`.ng-sheet-${t} .ng-container-${e}`);n&&n.querySelectorAll(`table`).forEach(e=>e.remove())})}),this.#v(),this.#_(),this.#n.initialize(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`)?.refresh(),requestAnimationFrame(()=>{this.#_(),this.#n?.refresh()}))}refreshLayout(){requestAnimationFrame(()=>{this.classList.contains(`active`)&&this.#f.table&&(this.#_(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`)?.refresh(),this.#h(),this.#a?.refreshLayout(),this.#n?.refresh())})}#h=()=>{let e=this.querySelector(`.ng-container-body thead`),t=this.querySelector(`.nodata-overlay`);t.style.top=`${e.offsetHeight}px`};get view(){return!this.#d&&this.#t?.data&&(this.#d=new j(this)),this.#d}invalidate=()=>{this.view.refresh(),this.#n.refresh(!0),this.isAutoFitCol&&this.autoFit(!0)};autoFit=(e=!0)=>{requestAnimationFrame(()=>{this.#g?.(e)})};#g=(e=!0)=>{let t=this.querySelector(`.ng-sheet-body .ng-container-body`);if(!t)return;let n=this.querySelector(`.ng-container-body table colgroup`);if(n){if(e){this.setAttribute(`auto-fit-col`,`true`);let e=t.clientWidth;if(e<=0)return;let r=0,i=[];n.querySelectorAll(`col`).forEach(e=>{let t=e.getAttribute(`data-col`);if(this.querySelector(`thead th[data-col="${t}"]`)?.getAttribute(`collapsed`)===`true`)i.unshift({globalColIndex:t,width:16,isCollapsed:!0});else{let n=parseInt(e.getAttribute(`width`),10)||100;i.push({globalColIndex:t,width:n,isCollapsed:!1}),r+=n}});let a=i.filter(e=>e.isCollapsed).reduce((e,t)=>e+t.width,0),o=Math.max(0,e-a);if(r>0&&i.length>0){let e=0,t=i.map(t=>{if(t.isCollapsed)return{globalColIndex:t.globalColIndex,remainder:0,width:16};let n=t.width*o/r,i=Math.max(30,Math.floor(n));return e+=i,{globalColIndex:t.globalColIndex,remainder:n-Math.floor(n),width:i}}),n=o-e,a=t.filter(e=>!i.find(t=>t.globalColIndex===e.globalColIndex)?.isCollapsed);if(n>0&&a.length>0){a.sort((e,t)=>t.remainder-e.remainder);for(let e=0;e<n;e++)a[e%a.length].width+=1}else if(n<0&&a.length>0){a.sort((e,t)=>e.remainder-t.remainder);for(let e=0;e<Math.abs(n);e++){let t=a[e%a.length];t.width>30&&--t.width}}t.forEach(({globalColIndex:e,width:t})=>{this.#a?.setColumnWidth(e,t,`body`)})}}else this.removeAttribute(`auto-fit-col`);this.querySelector(`nine-table-hscrollbar`)?.refresh()}};generate=(e,t)=>{e.style.display=`none`,this.#e=t,M.initializeTable(this.#t,e),e.style.display=``,this.#f={table:y.compile(e),tbody:{tr:e.querySelectorAll(`tbody tr`)}},this.#v(),this.#_(),this.#S(),this.#w(),[`left`,`body`,`right`].forEach(e=>{let t=`.ng-container-${e}`;this.#p[e]={thead:this.querySelector(`${t} thead`),tbody:{head:this.querySelector(`${t} tbody.head`),body:this.querySelector(`${t} tbody.body`),foot:this.querySelector(`${t} tbody.foot`)},tfoot:this.querySelector(`${t} tfoot`)}}),this.#n.initialize(),this.isAutoFitCol?this.autoFit(!0):this.querySelector(`nine-table-hscrollbar`).refresh(),this.#u.initialize(),this.loaded=!0};#_=()=>{[`left`,`right`,`body`].forEach(e=>{let t=this.querySelectorAll(`.ng-container-${e}`);if(t.length===0)return;let n=t[0].querySelector(`table`);if(!n)return;let r=0;n.querySelectorAll(`col`).forEach(e=>{let t=parseInt(e.getAttribute(`width`),10);isNaN(t)||(r+=t)}),t.forEach(t=>{t.querySelectorAll(`table`),e===`body`?t.style.flex=`1`:(t.style.flex=`0 0 ${r}px`,t.style.width=`${r}px`,t.style.minWidth=`${r}px`,t.style.maxWidth=`${r}px`)})})};#v=()=>{[{selector:`.ng-container-left`,type:`left`},{selector:`.ng-container-body`,type:null},{selector:`.ng-container-right`,type:`right`}].forEach(({selector:e,type:t})=>{this.querySelector(`.ng-sheet-body ${e}`).appendChild(this.#y(t))})};#y=e=>{let t=this.#f.table.cloneNode(!0);return e===`left`?t.querySelectorAll(`col, th, td`).forEach(e=>{e.getAttribute(`fixed`)!==`left`&&e.remove()}):e===`right`?t.querySelectorAll(`col, th, td`).forEach(e=>{e.getAttribute(`fixed`)!==`right`&&e.remove()}):t.querySelectorAll(`[fixed=left], [fixed=right]`).forEach(e=>{e.remove()}),t};getRowHeight=()=>this.#n.getRowHeight();getViewHeight=()=>(this.#p.content.offsetHeight||0)-((this.#p.body.thead?.offsetHeight||0)+(this.#p.body.tfoot?.offsetHeight||0)+(this.#p.body.tbody.head.offsetHeight||0));isLastRow=()=>{let e=this.querySelector(`.ng-sheet-body`),t=this.querySelector(`.ng-container-body tbody.body`),n=this.#p.body.tfoot?.offsetHeight||0,r=e.getBoundingClientRect().bottom,i=t.getBoundingClientRect().bottom;return r-n>=i};scrollToX=e=>{let t=this.querySelector(`.ng-sheet-body .ng-container-body`);t&&(t.scrollLeft=e)};scrollToY=e=>{let t=this.querySelector(`.ng-sheet-body`);t&&(t.scrollTop=e)};#b=()=>{this.#x(),this.#r=new b(this),this.#i=new x(this),this.#a=new C(this),this.#o=new T(this),this.#s=new E(this),this.#d=new j(this),this.#l=new k(this),this.#u=new g(this),this.#m||(this.#c=new A(this)),this.#p.mainBody.addEventListener(`scroll`,()=>{this.querySelector(`nine-table-hscrollbar`).refresh()})};#x=()=>{this.innerHTML=`
|
|
59
59
|
<div class="ng-sheet-body">
|
|
60
60
|
<div class="ng-sheet-body-content">
|
|
61
61
|
<div class="ng-container-left"></div>
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
|
|
76
76
|
<div class="ng-col-mover-grip"></div>
|
|
77
77
|
<div class="ng-col-mover-indi"></div>
|
|
78
|
-
`,this.#p={mainBody:this.querySelector(`.ng-sheet-body .ng-container-body`),hscrollbar:this.querySelector(`nine-table-hscrollbar`),vscrollbar:this.querySelector(`nine-table-vscrollbar`),content:this.querySelector(`.ng-sheet-body .ng-sheet-body-content`),scrollHolder:this.querySelector(`.ng-sheet-body .ng-virtual-height-holder`)}};#S=()=>{let e=this.querySelector(`.ng-container-left table`),t=this.querySelector(`.ng-container-body table`),n=this.querySelector(`.ng-container-right table`),r=Array.from(e.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`)),i=Array.from(t.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`)),a=Array.from(n.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`));this.#C(r,i,a);let o=Array.from(e.querySelectorAll(`tfoot tr`)),s=Array.from(t.querySelectorAll(`tfoot tr`)),c=Array.from(n.querySelectorAll(`tfoot tr`));this.#C(o,s,c)};#C=(e,t,n)=>{setTimeout(()=>{let r=Math.max(e.length,t.length,n.length);for(let i=0;i<r;i++){let r=[e[i]?.getBoundingClientRect().height||0,t[i]?.getBoundingClientRect().height||0,n[i]?.getBoundingClientRect().height||0],a=Math.max(...r);a>0&&(e[i]&&(e[i].style.height=`${a}px`),t[i]&&(t[i].style.height=`${a}px`),n[i]&&(n[i].style.height=`${a}px`))}})};#w=()=>{let e=this.querySelector(`.ng-sheet-body`);if(!e)return;let t=null;e.addEventListener(`mouseover`,n=>{let r=n.target.closest(`tr`);if(!r||!r.dataset.row&&r.dataset.row!==`0`)return;let i=r.dataset.row;t!==i&&(t=i,e.querySelectorAll(`tr[data-row="${i}"]`).forEach(e=>{e.classList.add(`hover`)}))}),e.addEventListener(`mouseout`,n=>{let r=n.target.closest(`tr`);if(!r)return;let i=n.relatedTarget;r.contains(i)||(e.querySelectorAll(`tr.hover`).forEach(e=>{e.classList.remove(`hover`)}),t=null)})};disconnectedCallback(){this.#a?.destroy(),this.#o?.destroy(),this.innerHTML=``}};customElements.get(`nine-table-sheet`)||customElements.define(`nine-table-sheet`,N);var P=class{#e;constructor(e){this.#e=e,this.#t()}#t=()=>{this.#r(),new ResizeObserver(e=>{for(let t of e)this.#e.getAttribute(`auto-height`)===`true`&&this.#n()}).observe(this.#e)};set loading(e){e?this.#e.classList.add(`loading`):this.#e.classList.remove(`loading`)}#n=()=>{let e=Array.from(this.#e.shadowRoot.querySelectorAll(`nine-table-sheet.active`));if(e.length===0)return;let t=parseInt(this.#e.getAttribute(`max-display-row`),10)||10,n=Math.max(...e.map(e=>e.getRowHeight())),r=this.#e.shadowRoot.querySelector(`nine-table-toolbar`),i=this.#e.shadowRoot.querySelector(`nine-table-sheets-footer`),a=r?r.getBoundingClientRect().height:0,o=i?i.getBoundingClientRect().height:0,s=N.SCROLLBAR_SIZE,c=t*n+a+o+s;this.#e.style.height=`${c}px`};#r=()=>{let e=Array.from(this.#e.children).filter(e=>e.tagName.toUpperCase()===`TABLE`),t=this.#e.getAttribute(`auto-height`)===`true`,n=e.length,r=e.map((e,t)=>{let r=t===0?`active`:``,i=e.id||`sheet${t+1}`;return`<nine-table-sheet class="${r}" data-index="${t}" data-sheet-id="${i}" id="${i}"></nine-table-sheet>`+(t<n-1?`<nine-splitter class="h" data-split-index="${t}"></nine-splitter>`:``)}).join(``),i=[`@import "https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.0.
|
|
78
|
+
`,this.#p={mainBody:this.querySelector(`.ng-sheet-body .ng-container-body`),hscrollbar:this.querySelector(`nine-table-hscrollbar`),vscrollbar:this.querySelector(`nine-table-vscrollbar`),content:this.querySelector(`.ng-sheet-body .ng-sheet-body-content`),scrollHolder:this.querySelector(`.ng-sheet-body .ng-virtual-height-holder`)}};#S=()=>{let e=this.querySelector(`.ng-container-left table`),t=this.querySelector(`.ng-container-body table`),n=this.querySelector(`.ng-container-right table`),r=Array.from(e.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`)),i=Array.from(t.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`)),a=Array.from(n.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`));this.#C(r,i,a);let o=Array.from(e.querySelectorAll(`tfoot tr`)),s=Array.from(t.querySelectorAll(`tfoot tr`)),c=Array.from(n.querySelectorAll(`tfoot tr`));this.#C(o,s,c)};#C=(e,t,n)=>{setTimeout(()=>{let r=Math.max(e.length,t.length,n.length);for(let i=0;i<r;i++){let r=[e[i]?.getBoundingClientRect().height||0,t[i]?.getBoundingClientRect().height||0,n[i]?.getBoundingClientRect().height||0],a=Math.max(...r);a>0&&(e[i]&&(e[i].style.height=`${a}px`),t[i]&&(t[i].style.height=`${a}px`),n[i]&&(n[i].style.height=`${a}px`))}})};#w=()=>{let e=this.querySelector(`.ng-sheet-body`);if(!e)return;let t=null;e.addEventListener(`mouseover`,n=>{let r=n.target.closest(`tr`);if(!r||!r.dataset.row&&r.dataset.row!==`0`)return;let i=r.dataset.row;t!==i&&(t=i,e.querySelectorAll(`tr[data-row="${i}"]`).forEach(e=>{e.classList.add(`hover`)}))}),e.addEventListener(`mouseout`,n=>{let r=n.target.closest(`tr`);if(!r)return;let i=n.relatedTarget;r.contains(i)||(e.querySelectorAll(`tr.hover`).forEach(e=>{e.classList.remove(`hover`)}),t=null)})};disconnectedCallback(){this.#a?.destroy(),this.#o?.destroy(),this.innerHTML=``}};customElements.get(`nine-table-sheet`)||customElements.define(`nine-table-sheet`,N);var P=class{#e;constructor(e){this.#e=e,this.#t()}#t=()=>{this.#r(),new ResizeObserver(e=>{for(let t of e)this.#e.getAttribute(`auto-height`)===`true`&&this.#n()}).observe(this.#e)};set loading(e){e?this.#e.classList.add(`loading`):this.#e.classList.remove(`loading`)}#n=()=>{let e=Array.from(this.#e.shadowRoot.querySelectorAll(`nine-table-sheet.active`));if(e.length===0)return;let t=parseInt(this.#e.getAttribute(`max-display-row`),10)||10,n=Math.max(...e.map(e=>e.getRowHeight())),r=this.#e.shadowRoot.querySelector(`nine-table-toolbar`),i=this.#e.shadowRoot.querySelector(`nine-table-sheets-footer`),a=r?r.getBoundingClientRect().height:0,o=i?i.getBoundingClientRect().height:0,s=N.SCROLLBAR_SIZE,c=t*n+a+o+s;this.#e.style.height=`${c}px`};#r=()=>{let e=Array.from(this.#e.children).filter(e=>e.tagName.toUpperCase()===`TABLE`),t=this.#e.getAttribute(`auto-height`)===`true`,n=e.length,r=e.map((e,t)=>{let r=t===0?`active`:``,i=e.id||`sheet${t+1}`;return`<nine-table-sheet class="${r}" data-index="${t}" data-sheet-id="${i}" id="${i}"></nine-table-sheet>`+(t<n-1?`<nine-splitter class="h" data-split-index="${t}"></nine-splitter>`:``)}).join(``),i=[`@import "https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.0.12/dist/css/nine-table.css";`];nine[`nine-table`]&&nine[`nine-table`].cssFile&&i.push(`@import "${nine[`nine-table`].cssFile}";`),this.#e.shadowRoot.innerHTML=`
|
|
79
79
|
<style>
|
|
80
80
|
${i.join(`
|
|
81
81
|
`)}
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
|
|
103
103
|
if (!data && !host) return "";
|
|
104
104
|
return ${i};
|
|
105
|
-
`),this.#n.set(i,e)),e(t,n,this.#e)}return i}catch{return e}}},I=class extends HTMLElement{#e;#t;#n;#r=0;#i=``;constructor(){super(),[`NINE-TABLE`].includes(this.tagName)&&r.log(`Welcome nine-table`,`0.0.
|
|
105
|
+
`),this.#n.set(i,e)),e(t,n,this.#e)}return i}catch{return e}}},I=class extends HTMLElement{#e;#t;#n;#r=0;#i=``;constructor(){super(),[`NINE-TABLE`].includes(this.tagName)&&r.log(`Welcome nine-table`,`0.0.12`),this.#e=this.attachShadow({mode:`open`}),this.#t=new s(this)}connectedCallback(){setTimeout(()=>{this.#r=this.querySelectorAll(`table`)?.length,this.fields=new c(this),this.exprEngine=new F(this),this.#o(),this.#n=new P(this),this.#a()})}disconnectedCallback(){}#a=()=>{let e=0,t=setInterval(()=>{e++;let n=this.shadow.querySelectorAll(`nine-table-sheet`);if(e>=50&&clearInterval(t),n.length>=this.#r){let e=0;n.forEach(t=>{t.loaded&&e++}),e>=this.#r&&(clearInterval(t),this.loaded=!0,this.dispatchEvent(new CustomEvent(i.EVENT.LOAD,{bubbles:!0,detail:{target:this}})))}},100)};get shadow(){return this.#e}get dataManager(){return this.#t}get data(){return this.#t.data}get row(){return this.#t.row}get customStyle(){return this.#i}scrollTo=(e,t)=>{this.#e.querySelectorAll(`nine-table-sheet.active`).forEach(n=>{n.scrollTo(e,t)})};currentRow=()=>{let e=this.currentRows();return e.length===0?-1:e[0]};currentRows=()=>{let e=[];return this.#e.querySelectorAll(`nine-table-sheet.active`).forEach(t=>{let n=t.view.getArray(t.selection.minRow).m._[i.META.INDEX.ROWID];e.push(n)}),e};addRow=(e,t=!0)=>this.data.add(e,t);insertRow=(e,t,n=!0)=>{let r=this.#e.querySelector(`nine-table-sheet.active`);if(!r)return;let a=r.view.get(e).m._[i.META.INDEX.ROWID],o=this.data.insert(a,t,n);return r.view.getArray().findIndex(e=>!e||!e.m||!e.m._?!1:e.m._[i.META.INDEX.ROWID]===o)};removeRow=e=>{let t=this.#e.querySelector(`nine-table-sheet.active`);if(!t)return;let n=t.view.get(e).m._[i.META.INDEX.ROWID];this.data.remove(n)};currentIndex=()=>{let e=this.currentIndexs();return e.length===0?-1:e[0]};currentIndexs=()=>{let e=[];return this.#e.querySelectorAll(`nine-table-sheet.active`).forEach(t=>{e.push(t.selection.minRow)}),e};addProvider(e){if(!e||typeof e!=`object`)return;let{style:t,...n}=e;if(t&&typeof t==`string`){this.#i=t;let e=this.#e.getElementById(`nine-table-scoped-custom-style`);e&&(e.textContent=t)}Object.keys(n).length>0&&setTimeout(()=>{Object.entries(n).forEach(([e,t])=>{typeof t==`function`&&(this[e]=t)}),this.rerenderer()})}setData(e){this.#t.data.set(e),this.refresh()}refresh(){this.activeSheet?.invalidate()}set loading(e){this.#n&&(this.#n.loading=e)}rerenderer(){this.activeSheet?.querySelectorAll(`tbody.body th,tbody.body td`).forEach(e=>{Array.from(e.children).find(e=>e.tagName.toLowerCase().startsWith(`cell-`)&&typeof e.rerenderer==`function`)?.rerenderer()})}sheet=e=>{if(e===null||e<0)return this.activeSheet;let t=Array.from(this.shadow.querySelectorAll(`nine-table-sheet`));return typeof e==`number`?t[e]||null:typeof e==`string`?this.shadow.querySelector(`nine-table-sheet#${e}, nine-table-sheet[data-sheet-id="${e}"]`)||null:t[0]||null};get sheets(){return Array.from(this.shadow.querySelectorAll(`nine-table-sheet`))}get activeSheet(){return this.shadow.querySelector(`nine-table-sheet.active`)||null}#o(){let e=new Set;this.querySelectorAll(`[data-source]`).forEach(t=>{let n=t.getAttribute(`data-source`);if(!n)return;let r=n.matchAll(/(?:host\.)?([a-zA-Z0-9_$]+)\s*\(/g);for(let t of r){let n=t[1];n&&n!==`host`&&e.add(n)}}),e.forEach(e=>{let t=null;Object.defineProperty(this,e,{set:e=>{t=e,this.rerenderer()},get:()=>t,configurable:!0,enumerable:!0})})}execute=e=>{setTimeout(()=>{this.loading=!0,setTimeout(()=>{try{e.call(this)}finally{this.loading=!1}})})}};customElements.get(`nine-table`)||customElements.define(`nine-table`,I),customElements.get(`nine-table-simple`)||customElements.define(`nine-table-simple`,class extends I{connectedCallback(){this.setAttribute(`theme`,`simple`),super.connectedCallback()}});var L=class extends HTMLElement{constructor(){super()}applyBaseStyle(){}connectedCallback(){}},R=new Map,z=class extends L{#e;#t;#n;#r;#i;constructor(){super()}get host(){return this.#e}get sheet(){return this.#t}get cell(){return this.#r}get tr(){return this.#n}get attr(){return this.#i}connectedCallback(){super.connectedCallback(),this.#e=this.getRootNode().host,this.#r=this.closest(`th,td`),this.#n=this.#r.closest(`tr`),this.#t=this.#n.closest(`nine-table-sheet`),this.#r.classList.add(this.tagName),this.#i={};for(let e=0;e<this.#r.attributes.length;e++){let t=this.#r.attributes[e].name;[`text-align`,`class`,`cell-type`,`data-bind`,`data-expr`,`data-col`,`tabindex`].includes(t)||(this.#i[t]=this.#r.attributes[e].value)}if(!this.#r)return;let e=this.shadowRoot||this;e.querySelectorAll(`button, ng-expand-button`).forEach(e=>{e.addEventListener(`click`,()=>{let e=this.getAttribute(`onbuttonclick`)||this.getAttribute(`onButtonClick`)||this.#r?.getAttribute(`onbuttonclick`)||this.#r?.getAttribute(`onButtonClick`),t=this.data,n=parseInt(this.#r.dataset.row,10);if(e&&this.#e){e=e.replace(`()`,``);let r=e.match(/^(\w+)\s*\(/)?.[1]||e;typeof this.#e[r]==`function`?this.#e[r].call(this.#e,t,n,this.#r):typeof this.#e.exprFunction==`function`&&this.#e.exprFunction(e).call(this,t,n)}})});let t=e.querySelector(`.renderer`);t&&this.getAttribute(`link`)===`true`&&(t.classList.add(`link`),t.addEventListener(`click`,()=>{let e=this.getAttribute(`onlinkclick`)||this.getAttribute(`onLinkClick`),t=this.data,n=parseInt(this.#r.dataset.row,10);if(e&&this.#e){e=e.replace(`()`,``);let r=e.match(/^(\w+)\s*\(/)?.[1]||e;typeof this.#e[r]==`function`?this.#e[r].call(this.#e,t,n,this.#r):typeof this.#e.exprFunction==`function`&&this.#e.exprFunction(e).call(this,t,n)}this.#e?.dispatchEvent(new CustomEvent(ninegrid.EVENT.LINK_CLICK,{detail:{target:this.#r,data:t,currow:n},bubbles:!0,composed:!0}))}))}get data(){let e=this.#n?.data;if(!e)return null;if(!e.v)return e;let t=this.#e;return new Proxy(e,{get(e,n){if(n===`__ng`)return e.__ng;if(n===`v`)return e.v;let r=t?.fields?.indexOf?.(n)??-1;return r>=0?e.v[r]:e[n]}})}get value(){if(!this.#r||!this.#n?.data)return``;let e=this.#r.dataset?.bind;if(!e)return``;let t=this.#n.data;if(t.v&&Array.isArray(t.v)){let n=this.#e.fields.get().indexOf(e)??-1;return n>=0?t.v[n]??``:``}return t[e]??``}set value(e){if(!this.#r||!this.#e?.data)return;let t=parseInt(this.#n.dataset.row,10),n=this.#r.dataset.bind;!isNaN(t)&&n&&this.#e.data.setValue(t,n,e)}get row(){return parseInt(this.#r?.dataset?.row,10)}get index(){return parseInt(this.#r?.dataset?.index,10)}isValid(){return!this.#r.classList.contains(`invalid`)}isInvalid(){return!this.isValid()}getDisplayText=(e=``)=>{if(!this.#r||!this.#r.closest(`tbody`)||!this.#n.data)return e;let t=this.#r.dataset.expr,n=this.#r.dataset.bind,r=parseInt(this.#r.dataset.row,10);if(t)try{return this.#n.getAttribute(`grouping`)===`true`?this.getGroupExprValue(t,this.#n.data,r,this.#r):this.#e.exprEngine.evaluate(t,this.#n.data,r)}catch{return e}return n?this.value??e:e};refresh(){if(!this.#r||!this.#n)return;let e=this.value;return this.#r.classList.remove(`invalid`),[`color`,`background`,`background-color`,`visible`,`enable`,`validator`].forEach(e=>{let t=this.#i[e];if(t){let n=this.#e.exprEngine.evaluate(t,this.#n.data,parseInt(this.#r.dataset.row,10));e===`validator`?n||this.#r.classList.add(`invalid`):e===`visible`?this.style.display=n?``:`none`:e===`enable`?(this.querySelectorAll(`input, button, textarea, select`).forEach(e=>{e.disabled=!n}),n?this.#r.removeAttribute(`disabled`):this.#r.setAttribute(`disabled`,`true`)):this.#r.style[e]=n}}),e}getExprValue(e,t,n){return!this.#e||!this.#e.exprEngine||e==null||e===``?e:this.#e.exprEngine.evaluate(e,t,n)}getGroupExprValue=(e,t,n,r)=>{if(!e)return``;try{n=parseInt(n,10);let i=e.replace(`()`,``).trim();if(this.#e&&typeof this.#e[i]==`function`)return this.#e[i].call(this,t,n,r);let a=i.match(/^(\w+)\s*\(\s*([\w\-]*)\s*\)/);if(a){let e=t[GROUP_IDX.CHILDREN],n=this.#e?.data?.getArray?this.#e.data.getArray():[],r=e?e.map(e=>n[e]).filter(Boolean):[],[,i,o]=a,s=this.#e;switch(i.toLowerCase()){case`count`:return r.length;case`sum`:{let e=s?.fields?.indexOf?.(o)??-1;return r.reduce((t,n)=>{let r=e>=0?n.v?.[e]:n[o];return t+(Number(r)||0)},0)}case`avg`:{if(r.length===0)return 0;let e=s?.fields?.indexOf?.(o)??-1;return r.reduce((t,n)=>{let r=e>=0?n.v?.[e]:n[o];return t+(Number(r)||0)},0)/r.length}}}if(this.#e&&typeof this.#e.exprFunction==`function`)return this.#e.exprFunction(e).call(this,t,n,this.#e.data);if(e.includes(`data.`)||e.includes(`childRecords`)||e.includes(`groupRecord`)){let i=R.get(`grp_`+e);return i||(i=Function(`groupRecord`,`row`,`cell`,`host`,`
|
|
106
106
|
const indices = groupRecord[3]; // GROUP_IDX.CHILDREN = 3
|
|
107
107
|
const allRecords = host?.data?.getArray ? host.data.getArray() : [];
|
|
108
108
|
|