@ninebone/datagrid 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/nine-table.js +42 -49
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +7 -7
- package/dist/nine-table.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/nine-table.umd.js
CHANGED
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
|
|
88
88
|
<div class="ng-col-mover-grip"></div>
|
|
89
89
|
<div class="ng-col-mover-indi"></div>
|
|
90
|
-
`,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`)},r.log(`444*****************`)};#S=()=>{r.log(`**********************`,`#syncHeaderAndFooterHeights`);let e=this.querySelector(`.ng-container-left table`),t=this.querySelector(`.ng-container-body table`),n=this.querySelector(`.ng-container-right table`),i=Array.from(e.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`)),a=Array.from(t.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`)),o=Array.from(n.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`));this.#C(i,a,o);let s=Array.from(e.querySelectorAll(`tfoot tr`)),c=Array.from(t.querySelectorAll(`tfoot tr`)),l=Array.from(n.querySelectorAll(`tfoot tr`));this.#C(s,c,l)};#C=(e,t,n)=>{setTimeout(()=>{let i=Math.max(e.length,t.length,n.length);r.log(this.#t);for(let a=0;a<i;a++){r.log(i);let o=[e[a]?.getBoundingClientRect().height||0,t[a]?.getBoundingClientRect().height||0,n[a]?.getBoundingClientRect().height||0],s=Math.max(...o);r.log(o,s),s>0&&(e[a]&&(e[a].style.height=`${s}px`),t[a]&&(t[a].style.height=`${s}px`),n[a]&&(n[a].style.height=`${s}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,i=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(``);r.log(`Welcome nine-table`,`0.
|
|
90
|
+
`,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`)},r.log(`444*****************`)};#S=()=>{r.log(`**********************`,`#syncHeaderAndFooterHeights`);let e=this.querySelector(`.ng-container-left table`),t=this.querySelector(`.ng-container-body table`),n=this.querySelector(`.ng-container-right table`),i=Array.from(e.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`)),a=Array.from(t.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`)),o=Array.from(n.querySelectorAll(`thead tr:not(.col-indicator-rowgroup)`));this.#C(i,a,o);let s=Array.from(e.querySelectorAll(`tfoot tr`)),c=Array.from(t.querySelectorAll(`tfoot tr`)),l=Array.from(n.querySelectorAll(`tfoot tr`));this.#C(s,c,l)};#C=(e,t,n)=>{setTimeout(()=>{let i=Math.max(e.length,t.length,n.length);r.log(this.#t);for(let a=0;a<i;a++){r.log(i);let o=[e[a]?.getBoundingClientRect().height||0,t[a]?.getBoundingClientRect().height||0,n[a]?.getBoundingClientRect().height||0],s=Math.max(...o);r.log(o,s),s>0&&(e[a]&&(e[a].style.height=`${s}px`),t[a]&&(t[a].style.height=`${s}px`),n[a]&&(n[a].style.height=`${s}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,i=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(``);r.log(`Welcome nine-table`,`0.0.3`);let a=[`@import "https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.0.3/dist/css/nine-table.css";`];nine[`nine-table`]&&nine[`nine-table`].cssFile&&a.push(`@import "${nine[`nine-table`].cssFile}";`),this.#e.shadowRoot.innerHTML=`
|
|
91
91
|
<style>
|
|
92
92
|
${a.join(`
|
|
93
93
|
`)}
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
|
|
113
113
|
if (!data && !host) return "";
|
|
114
114
|
return ${i};
|
|
115
|
-
`),this.#n.set(i,e)),e(t,n,this.#e)}return i}catch{return e}}},I=class extends HTMLElement{#e;#t;#n;#r=0;constructor(){super(),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.#a(),this.#n=new P(this),this.#i()})}disconnectedCallback(){r.log(`NineTable disconnected.`)}#i=()=>{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}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}#a(){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{
|
|
115
|
+
`),this.#n.set(i,e)),e(t,n,this.#e)}return i}catch{return e}}},I=class extends HTMLElement{#e;#t;#n;#r=0;constructor(){super(),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.#a(),this.#n=new P(this),this.#i()})}disconnectedCallback(){r.log(`NineTable disconnected.`)}#i=()=>{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}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}#a(){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.#r.dataset.row,10),n=this.#r.dataset.bind;if(isNaN(t)||!n)return;let r=this.getAttribute(`update-row-state`)!==`false`;this.#e.data.setValue(t,n,e,r)}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`,`
|
|
116
116
|
const indices = groupRecord[3]; // GROUP_IDX.CHILDREN = 3
|
|
117
117
|
const allRecords = host?.data?.getArray ? host.data.getArray() : [];
|
|
118
118
|
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
`};#n=()=>{this.#e.addEventListener(`keydown`,this.#i),this.#e.addEventListener(`input`,e=>{this.value=e.target.value,this.sheet.rowManager.refresh(!0)}),this.#e.addEventListener(`change`,e=>{this.value=e.target.value,this.sheet.rowManager.refresh(!0)})};refresh=()=>{let e=super.refresh();this.#e.value=e,this.isValid()&&this.#r()};#r=()=>{let e=this.#e.value;if(e!==``&&e!=null){let t=Number(e);if(isNaN(t)||this.#o&&t>Number(this.#o)||this.#a&&t<Number(this.#a))this.cell.classList.add(`invalid`);else if(this.#s){let t=String(e),n=t.indexOf(`.`);n>=0&&t.substring(n+1).length>Number(this.#s)&&this.cell.classList.add(`invalid`)}}};#i=e=>{if([`Escape`,`Enter`,`Tab`,`Home`,`End`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`,`Backspace`,`Delete`].includes(e.code))return;let t=e.target,n=t.value,r=t.selectionStart,i=e.key;if(i===`-`&&(n.includes(`-`)||r!==0)){e.preventDefault();return}if(i===`.`){let t=Number(this.#s);if(isNaN(t)||t<=0||n.includes(`.`)){e.preventDefault();return}}let a=[];this.#s&&Number(this.#s)>0&&a.push(`.`),(this.#a||Number(this.#a)>0)&&a.push(`-`);let o=e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=105;if(!o&&!a.includes(e.key))e.preventDefault();else{if(this.#s&&o&&e.target.selectionStart==e.target.selectionEnd){let t=e.target.value,n=t.indexOf(`.`);n>=0&&e.target.selectionStart>n&&t.substr(n+1).length>=Number(this.#s)&&e.preventDefault()}this.#c&&nine.getByteLength(e.target.value)>=Number(this.#c)&&e.target.selectionStart==e.target.selectionEnd&&e.preventDefault()}};get#a(){return this.cell.getAttribute(`min`)||``}get#o(){return this.cell.getAttribute(`max`)||``}get#s(){return this.cell.getAttribute(`scale`)||``}get#c(){return this.cell.getAttribute(`maxbyte`)||this.cell.getAttribute(`max-byte`)}};customElements.get(`cell-input-number`)||customElements.define(`cell-input-number`,H);var U=class extends B{#e;#t;#n;constructor(){super()}connectedCallback(){super.connectedCallback(),this.#i(),this.#e=this.querySelector(`input[type=color]`),this.#t=this.querySelector(`button`),this.#r()}#r=()=>{this.#t.addEventListener(`click`,()=>{this.#e.click()}),this.#e.addEventListener(`input`,e=>{let t=e.target.value;this.value=t,this.#o(t),this.sheet.rowManager.refresh(!0)}),this.#e.addEventListener(`change`,e=>{let t=e.target.value;this.value=t,this.#o(t),this.sheet.rowManager.refresh(!0)})};#i=()=>{this.innerHTML=`
|
|
144
144
|
<input type="color" ondragstart="return false;">
|
|
145
145
|
<button tabindex="-1" type="button"></button>
|
|
146
|
-
`};rerenderer=()=>{this.refresh()};#a=()=>{
|
|
146
|
+
`};rerenderer=()=>{this.refresh()};#a=()=>{let e=this.cell.getAttribute(`data-source`);if(e&&(this.#n=super.getExprValue(e,this.tr.data,this.tr.dataset.row),this.querySelector(`datalist`)?.remove(),this.#n&&Array.isArray(this.#n))){let e=`color-list-${Math.random().toString(36).substr(2,9)}`,t=document.createElement(`datalist`);t.id=e;let n=document.createDocumentFragment();this.#n.forEach(e=>{if(e.value){let t=document.createElement(`option`);t.value=e.value,n.appendChild(t)}}),t.appendChild(n),this.appendChild(t),this.#e.setAttribute(`list`,e)}};refresh=()=>{if(!this.tr.data)return;let e=super.refresh();this.#a(),this.#e.value=e!=null&&e!==``?e:`#ffffff`,this.isValid()&&this.#o()};#o=()=>{let e=this.#e.value;e!==``&&e!=null&&(this.#s(e)?this.#n&&Array.isArray(this.#n)&&this.#n.length>0&&(this.#n.some(t=>(t.value===void 0?t.code===void 0?``:t.code:t.value).toLowerCase()===e.toLowerCase())||this.cell.classList.add(`invalid`)):this.cell.classList.add(`invalid`))};#s=e=>{if(typeof e!=`string`||e.length!=7||!e.startsWith(`#`))return!1;var t=parseInt(e.substr(1,2),16),n=parseInt(e.substr(3,2),16),r=parseInt(e.substr(5,2),16);return!(isNaN(t)||isNaN(n)||isNaN(r)||t<0||t>255||n<0||n>255||r<0||r>255)}};customElements.get(`cell-input-color`)||customElements.define(`cell-input-color`,U);var W=class extends B{#e;#t;constructor(){super()}connectedCallback(){super.connectedCallback(),this.#n(),this.#e=this.querySelector(`input`),this.#e.addEventListener(`input`,e=>{let t=e.target.value;this.value=t,this.#e.classList.toggle(`has-value`,!!t),this.#r(t),super.sheet.rowManager.refresh(!0)}),this.#e.addEventListener(`change`,e=>{let t=e.target.value;this.value=t,this.#r(t),super.sheet.rowManager.refresh(!0)})}#n=()=>{if(this.#t=this.cell.getAttribute(`date-type`)||`date`,![`date`,`datetime-local`,`time`,`week`,`month`].includes(this.#t))throw`invalid type : ${this.#t}`;let e=[];for(let t=0;t<this.cell.attributes.length;t++)[`value`,`max`,`min`,`step`].includes(this.cell.attributes[t].name)&&e.push(`${this.cell.attributes[t].name}="${this.cell.attributes[t].value}"`);this.innerHTML=`
|
|
147
147
|
<input
|
|
148
148
|
type="${this.#t}"
|
|
149
149
|
data-placeholder="${this.cell.getAttribute(`placeholder`)||`Select`}"
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
${n}
|
|
155
155
|
`};refresh=()=>{let e=super.refresh();this.#e.checked=e===this.trueValue,this.isValid()&&this.#i(e);let t=e===this.trueValue?this.#a:e===this.falseValue?this.#o:e;this.#t&&(this.#t.textContent=t)};#i=e=>{this.cell.classList.remove(`invalid`),e!==``&&e!=null&&e!==this.trueValue&&e!==this.falseValue&&this.cell.classList.add(`invalid`)};selectAll=e=>{if(this.closest(`thead`))return;let t=this.host.data.getArray(),n=this.host.fields.indexOf(this.cell.dataset.bind);if(!(n<0)){for(let r=0;r<t.length;r++)this.#c&&super.getExprValue(this.#c,t[r],r,this.cell)===!1||this.#l&&super.getExprValue(this.#l,t[r],r,this.cell)===!0||this.#u&&super.getExprValue(this.#u,t[r],r,this.cell)===!1||(t[r].v[n]=e?this.trueValue:this.falseValue);super.sheet.invalidate()}};get trueValue(){return this.cell.getAttribute(`true-value`)||`Y`}get falseValue(){return this.cell.getAttribute(`false-value`)||`N`}get#a(){return this.cell.getAttribute(`true-text`)||``}get#o(){return this.cell.getAttribute(`false-text`)||``}get#s(){return this.cell.getAttribute(`is-radio`)||!1}get#c(){return this.cell.getAttribute(`enable`)||!1}get#l(){return this.cell.getAttribute(`readonly`)||!1}get#u(){return this.cell.getAttribute(`visible`)||!1}};customElements.get(`cell-checkbox`)||customElements.define(`cell-checkbox`,G);var K=class extends B{#e;#t;#n=[];constructor(){super()}connectedCallback(){super.connectedCallback(),this.#a(),this.#i(),this.#r()}#r=()=>{this.cell.addEventListener(`keydown`,e=>{if(!(this.cell.hasAttribute(`readonly`)||this.cell.classList.contains(`readonly`))&&this.cell.getAttribute(`disabled`)!==`true`&&e.code===`Space`){e.preventDefault();let t=-1;this.#t.forEach((e,n)=>{if(this.value===e.getAttribute(`value`))return t=n,!1}),t=t===this.#t.length-1?0:t>=0?t+1:0,this.value=this.#t[t].getAttribute(`value`),this.sheet.rowManager.refresh(!0)}})};#i=()=>{r.log(`rendererRadio`);let e=this.cell.getAttribute(`data-source`);if(e&&(this.#n=super.getExprValue(e,this.tr.data,this.tr.dataset.row),this.#e.replaceChildren(),this.#n&&Array.isArray(this.#n))){let e=document.createDocumentFragment();this.#n.forEach(t=>{let n=t[this.#s]===void 0?``:t[this.#s],r=t[this.#c]===void 0?``:t[this.#c],i=document.createElement(`label`),a=document.createElement(`input`);a.type=`radio`,a.value=n;let o=document.createElement(`span`);o.textContent=r,i.appendChild(a),i.appendChild(o),e.appendChild(i)}),this.#e.appendChild(e),this.#t=Array.from(this.querySelectorAll(`input`)),this.#t.forEach(e=>{e.addEventListener(`change`,e=>{this.value=e.target.value,this.sheet.rowManager.refresh(!0)})})}};#a=()=>{this.innerHTML=`
|
|
156
156
|
<div></div>
|
|
157
|
-
`,this.#e=this.querySelector(`div`)};rerenderer=()=>{this.#i(),this.refresh()};refresh=()=>{let e=super.refresh();this.#t.forEach(t=>{t.checked=e===t.value}),this.isValid()&&this.#o()};#o=()=>{this.value!==null&&this.value!==void 0&&this.value!==``&&Array.isArray(this.#n)&&this.#n.findIndex(e=>this.value===e[this.#s])<0&&this.cell.classList.add(`invalid`)};get dataSource(){return this.#n}get#s(){return this.cell.getAttribute(`key-name`)||`k`}get#c(){return this.cell.getAttribute(`value-name`)||`v`}};customElements.get(`cell-radio`)||customElements.define(`cell-radio`,K);var q=class extends HTMLElement{#e;#t;#n;#r=!1;constructor(){super()}connectedCallback(){this.#u(),this.#l()}#i=(e,t,n,i
|
|
157
|
+
`,this.#e=this.querySelector(`div`)};rerenderer=()=>{this.#i(),this.refresh()};refresh=()=>{let e=super.refresh();this.#t.forEach(t=>{t.checked=e===t.value}),this.isValid()&&this.#o()};#o=()=>{this.value!==null&&this.value!==void 0&&this.value!==``&&Array.isArray(this.#n)&&this.#n.findIndex(e=>this.value===e[this.#s])<0&&this.cell.classList.add(`invalid`)};get dataSource(){return this.#n}get#s(){return this.cell.getAttribute(`key-name`)||`k`}get#c(){return this.cell.getAttribute(`value-name`)||`v`}};customElements.get(`cell-radio`)||customElements.define(`cell-radio`,K);var q=class extends HTMLElement{#e;#t;#n;#r=!1;constructor(){super()}connectedCallback(){this.#u(),this.#l()}#i=(e,t,n,r,i)=>{let a=this.querySelector(`nine-table-simple`);if(!a||!e||e.length===0)return;let o=this.#e.getAttribute(`items`),s=[];s=o?o.split(`,`).map(e=>e.trim()):[n].filter(Boolean);let c=s.length;a.shadowRoot.querySelector(`.ng-container-left`).style.display=r?``:`none`,a.shadowRoot.querySelectorAll(`table colgroup col, tbody td`).forEach((e,t)=>{let n=parseInt(e.dataset.col,10);n>=2&&(e.style.display=n-2>=c?`none`:``)});let l=e.map(e=>{let n={CHK:`N`,k:t&&e[t]!==void 0?e[t]:e[0]===void 0?``:e[0]};return s.forEach((t,r)=>{n[`tmp${r+1}`]=e[t]===void 0?e[r]===void 0?``:e[r]:e[t]}),n});if(a.data.set(l),r&&this.#e.value){let e=String(this.#e.value).split(i||`,`);a.data.getValidData().forEach(t=>{e.includes(String(t.v[1]))&&(t.v[0]=`Y`)}),a.refreshData()}};open=(e,t,n,r,i,a)=>{this.#e=e,this.#t=n,this.#n=r,this.#r=!0,this.classList.add(`active`);let o=this.querySelector(`nine-table-simple`);if(!o||!t)return;this.querySelector(`.search-input`).value=``,this.querySelector(`#chkAll`).checked=!0,t.length>10?this.classList.add(`expand`):this.classList.remove(`expand`),i?this.classList.add(`multi`):this.classList.remove(`multi`);let s=e.closest(`nine-table-sheet`),c=e.querySelector(`.btn1`);if(!c||!s)return;let l=c.getBoundingClientRect(),u=s.getBoundingClientRect(),d=l.left-u.left,f=l.bottom-u.top+2,p=this.offsetWidth||250,m=this.offsetHeight||250;if(d+p>u.width&&(d=Math.max(0,u.width-p-5)),d<0&&(d=5),f+m>u.height){let e=l.top-u.top-m-2;f=e>=0?e:Math.max(0,u.height-m-5)}this.style.left=`${d}px`,this.style.top=`${f}px`,setTimeout(()=>{this.#i(t,n,r,i,a);let e=o.shadowRoot.querySelector(`.ng-container-body table tbody.body`);e.__hasClickEvent||=(e.addEventListener(`mousedown`,e=>{e.target.closest(`tr`)&&(i||this.#a(e))}),!0)},100)};close=()=>{this.classList.remove(`active`),this.#r=!1,this.#e&&this.#e.cell&&this.#e.cell.focus()};#a=e=>{let t=e.target.closest(`nine-table-sheet`),n=e.target.closest(`tr`),r=parseInt(n.dataset.row,10),i=t.view.get(r);this.#e.value=i.k,this.#e.sheet.rowManager.refresh(!0),this.close()};#o=()=>{let e=this.querySelector(`nine-table-simple`).data.getValidData(),t=[];e.forEach(e=>{e.v[0]===`Y`&&t.push(e.v[1])}),this.#e.value=t.join(this.#e.getAttribute(`multi-separator`)||`,`),this.#e.sheet.rowManager.refresh(!0),this.close()};#s=e=>{let t=this.querySelector(`nine-table-simple`),n=e.target.checked?`Y`:`N`;t.data.getValidData().forEach(e=>{e.v[0]=n}),t.refreshData()};#c=e=>{let t=e.target.value.toLowerCase(),n=this.querySelector(`nine-table-simple`);n.data.getValidDataNF().forEach(e=>{let n=Object.values(e.v).some(e=>e!=null&&String(e).toLowerCase().includes(t));e.__ng.filtered=!n}),n.data.resetRecords(),n.dataManager.viewRecords.reset()};get isOpen(){return this.#r}get targetCell(){return this.#e}#l=()=>{this.querySelector(`.search-input`).addEventListener(`input`,this.#c),this.querySelector(`#btnOk`).addEventListener(`click`,this.#o),this.querySelector(`#chkAll`).addEventListener(`change`,this.#s),document.addEventListener(`mousedown`,e=>{(e.composedPath?e.composedPath():[]).includes(this)||this.close()})};#u=()=>{this.innerHTML=`
|
|
158
158
|
<div class="head">
|
|
159
159
|
<input type="text" class="search-input" placeholder="Search..." />
|
|
160
160
|
</div>
|
|
@@ -201,14 +201,14 @@
|
|
|
201
201
|
</div>
|
|
202
202
|
<button id="btnOk">OK</button>
|
|
203
203
|
</div>
|
|
204
|
-
`}};customElements.get(`cell-combo-panel`)||customElements.define(`cell-combo-panel`,q);var J=class extends B{#e;#t=[];#n;#r;#i;#a;#o;constructor(){super()
|
|
204
|
+
`}};customElements.get(`cell-combo-panel`)||customElements.define(`cell-combo-panel`,q);var J=class extends B{#e;#t=[];#n;#r;#i;#a;#o;constructor(){super()}connectedCallback(){this.#u(),super.connectedCallback(),this.#n=super.cell.getAttribute(`key-name`)||`k`,this.#r=super.cell.getAttribute(`value-name`)||`v`,this.#i=super.cell.getAttribute(`multi`)===`true`,this.#a=super.cell.getAttribute(`multi-separator`)||`,`,this.#s(),this.#c()}rerenderer=()=>{this.#s(),this.refresh()};#s=()=>{if(!super.sheet||!super.cell)return;let e=super.cell?.getAttribute(`data-source`);e&&(this.#t=super.getExprValue(e,super.tr.data,super.tr.dataset.row))};#c=()=>{this.querySelectorAll(`button`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),this.#l()})})};#l=()=>{this.#o||(this.#o=super.sheet.querySelector(`cell-combo-panel`),this.#o||(this.#o=document.createElement(`cell-combo-panel`),super.sheet.appendChild(this.#o))),this.#o.isOpen&&this.#o.targetCell===this?this.#o.close():this.#o.open(this,this.#t,this.#n,this.#r,this.#i,this.#a)};#u=()=>{this.innerHTML=`
|
|
205
205
|
<button class="btn1" type="button" tabindex="-1">Select</button>
|
|
206
206
|
<button class="btn2" type="button" tabindex="-1"></button>
|
|
207
207
|
`,this.#e=this.querySelector(`.btn1`)};refresh=()=>{let e=super.refresh();return this.#e&&(this.#e.textContent=this.#d()||`Select`,this.#f()),e};#d=()=>{if(!this.value||!Array.isArray(this.#t))return``;if(this.#i){let e=String(this.value).split(this.#a);return this.#t.filter(t=>e.includes(String(t[this.#n]))).map(e=>e[this.#r]).join(this.#a)}{let e=this.#t.find(e=>String(e[this.#n])===String(this.value));return e?e[this.#r]:this.value}};#f=()=>{if(!super.cell||(super.cell.classList.remove(`invalid`),this.value===null||this.value===void 0||this.value===``||!Array.isArray(this.#t)))return;let e=this.#i?String(this.value).split(this.#a):[this.value];for(let t of e)if(this.#t.findIndex(e=>String(t)===String(e[this.#n]))<0){super.cell.classList.add(`invalid`);break}};get dataSource(){return this.#t}};customElements.get(`cell-combo`)||customElements.define(`cell-combo`,J);var Y=class extends z{#e;constructor(){super()}connectedCallback(){super.connectedCallback(),this.#t(),this.#e=this.querySelector(`span`)}refresh=()=>{super.refresh(),this.cell.getAttribute(`html`)===`true`?this.#e.innerHTML=this.getDisplayText():this.#e.textContent=this.getDisplayText()};#t=()=>{this.innerHTML=`
|
|
208
208
|
<span class="wrapper"></span>
|
|
209
|
-
`}};customElements.get(`cell-renderer`)||customElements.define(`cell-renderer`,Y);var X=class extends z{#e;constructor(){super()}connectedCallback(){this.#n(),super.connectedCallback(),this.#e=this.querySelector(`button`),this.#e.removeEventListener(`click`,this.#t),this.#e.addEventListener(`click`,this.#t)}#t=e=>{e.stopPropagation();let t=parseInt(this.cell.dataset.row,10),n=new CustomEvent(i.EVENT.CELL_BUTTON_CLICK,{bubbles:!0,composed:!0,detail:{originalEvent:e,cell:this.cell,row:t,col:parseInt(this.cell.dataset.col,10),bind:this.dataset.bind,data:this.host.data.get(t),value:this.value}});this.dispatchEvent(n)};refresh=()=>{let e=super.refresh?super.refresh():this.value;this.#e.innerHTML=this.getDisplayText(e)};#n=()=>{
|
|
209
|
+
`}};customElements.get(`cell-renderer`)||customElements.define(`cell-renderer`,Y);var X=class extends z{#e;constructor(){super()}connectedCallback(){this.#n(),super.connectedCallback(),this.#e=this.querySelector(`button`),this.#e.removeEventListener(`click`,this.#t),this.#e.addEventListener(`click`,this.#t)}#t=e=>{e.stopPropagation();let t=parseInt(this.cell.dataset.row,10),n=new CustomEvent(i.EVENT.CELL_BUTTON_CLICK,{bubbles:!0,composed:!0,detail:{originalEvent:e,cell:this.cell,row:t,col:parseInt(this.cell.dataset.col,10),bind:this.dataset.bind,data:this.host.data.get(t),value:this.value}});this.dispatchEvent(n)};refresh=()=>{let e=super.refresh?super.refresh():this.value;this.#e.innerHTML=this.getDisplayText(e)};#n=()=>{this.innerHTML=`
|
|
210
210
|
<button class="button">...</button>
|
|
211
|
-
`}};customElements.get(`cell-button`)||customElements.define(`cell-button`,X);var Z=class extends z{#e;#t;#n;constructor(){super()
|
|
211
|
+
`}};customElements.get(`cell-button`)||customElements.define(`cell-button`,X);var Z=class extends z{#e;#t;#n;constructor(){super()}connectedCallback(){this.#r(),super.connectedCallback(),this.cell&&(this.cell.removeAttribute(`tabindex`),this.cell.dataset.bind=`rowState`,this.cell.dataset.expr,this.cell.setAttribute(`text-align`,`right`)),this.#e=this.querySelector(`.ng-row-main`),this.#t=this.querySelector(`.ng-row-sub`),this.#n=this.querySelector(`.ng-row-status`)}#r=()=>{this.innerHTML=`
|
|
212
212
|
<span class="ng-row-main"></span>
|
|
213
213
|
<span class="ng-row-sub"></span>
|
|
214
214
|
<span class="ng-row-status"></span>
|