@stonecrop/atable 0.3.2 → 0.3.3
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/assets/index.css +1 -1
- package/dist/atable.d.ts +14 -7
- package/dist/atable.js +156 -150
- package/dist/atable.js.map +1 -1
- package/dist/atable.umd.cjs +2 -2
- package/dist/atable.umd.cjs.map +1 -1
- package/dist/src/stores/table.d.ts +12 -6
- package/dist/src/stores/table.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +2 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/ACell.vue +5 -4
- package/src/components/ATable.vue +2 -5
- package/src/components/ATableModal.vue +34 -11
- package/src/types/index.ts +2 -1
package/dist/atable.umd.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(k,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],t):(k=typeof globalThis<"u"?globalThis:k||self,t(k["@stonecrop/atable"]={},k.Vue,k.pinia))})(this,function(k,t,
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(oe);function ne(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function W(e){return typeof e=="function"?e():t.unref(e)}const Ee=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ce=e=>e!=null,Ae=Object.prototype.toString,Se=e=>Ae.call(e)==="[object Object]",Ie=()=>{},B=Ee?window:void 0;function R(e){var o;const n=W(e);return(o=n==null?void 0:n.$el)!=null?o:n}function O(...e){let o,n,r,a;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,r,a]=e,o=B):[o,n,r,a]=e,!o)return Ie;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);const c=[],l=()=>{c.forEach(f=>f()),c.length=0},i=(f,p,u,b)=>(f.addEventListener(p,u,b),()=>f.removeEventListener(p,u,b)),s=t.watch(()=>[R(o),W(a)],([f,p])=>{if(l(),!f)return;const u=Se(p)?{...p}:p;c.push(...n.flatMap(b=>r.map(y=>i(f,b,y,u))))},{immediate:!0,flush:"post"}),d=()=>{s(),l()};return ne(d),d}function Te(){const e=t.ref(!1),o=t.getCurrentInstance();return o&&t.onMounted(()=>{e.value=!0},o),e}function Me(e){const o=Te();return t.computed(()=>(o.value,!!e()))}function $e(e,o,n={}){const{window:r=B,...a}=n;let c;const l=Me(()=>r&&"MutationObserver"in r),i=()=>{c&&(c.disconnect(),c=void 0)},s=t.computed(()=>{const u=W(e),b=(Array.isArray(u)?u:[u]).map(R).filter(Ce);return new Set(b)}),d=t.watch(()=>s.value,u=>{i(),l.value&&u.size&&(c=new MutationObserver(o),u.forEach(b=>c.observe(b,a)))},{immediate:!0,flush:"post"}),f=()=>c==null?void 0:c.takeRecords(),p=()=>{d(),i()};return ne(p),{isSupported:l,stop:p,takeRecords:f}}function Be(e={}){var o;const{window:n=B,deep:r=!0,triggerOnRemoval:a=!1}=e,c=(o=e.document)!=null?o:n==null?void 0:n.document,l=()=>{var d;let f=c==null?void 0:c.activeElement;if(r)for(;f!=null&&f.shadowRoot;)f=(d=f==null?void 0:f.shadowRoot)==null?void 0:d.activeElement;return f},i=t.ref(),s=()=>{i.value=l()};return n&&(O(n,"blur",d=>{d.relatedTarget===null&&s()},!0),O(n,"focus",s,!0)),a&&$e(c,d=>{d.filter(f=>f.removedNodes.length).map(f=>Array.from(f.removedNodes)).flat().forEach(f=>{f===i.value&&s()})},{childList:!0,subtree:!0}),s(),i}const Re="focusin",Oe="focusout";function De(e,o={}){const{window:n=B}=o,r=t.computed(()=>R(e)),a=t.ref(!1),c=t.computed(()=>a.value),l=Be(o);return!n||!l.value?{focused:c}:(O(r,Re,()=>a.value=!0),O(r,Oe,()=>a.value=!1),{focused:c})}function Le(e,{window:o=B,scrollTarget:n}={}){const r=t.ref(!1),a=()=>{if(!o)return;const c=o.document,l=R(e);if(!l)r.value=!1;else{const i=l.getBoundingClientRect();r.value=i.top<=(o.innerHeight||c.documentElement.clientHeight)&&i.left<=(o.innerWidth||c.documentElement.clientWidth)&&i.bottom>=0&&i.right>=0}};return t.watch(()=>R(e),()=>a(),{immediate:!0,flush:"post"}),o&&O(n||o,"scroll",a,{capture:!1,passive:!0}),r}const I=e=>{let o=Le(e).value;return o=o&&e.offsetHeight>0,o},T=e=>e.tabIndex>=0,re=e=>{const o=e.target;return H(o)},H=e=>{var o;let n;if(e instanceof HTMLTableCellElement){const r=(o=e.parentElement)==null?void 0:o.previousElementSibling;if(r){const a=Array.from(r.children)[e.cellIndex];a&&(n=a)}}else if(e instanceof HTMLTableRowElement){const r=e.previousElementSibling;r&&(n=r)}return n&&(!T(n)||!I(n))?H(n):n},ze=e=>{var o;const n=e.target;let r;if(n instanceof HTMLTableCellElement){const a=(o=n.parentElement)==null?void 0:o.parentElement;if(a){const c=a.firstElementChild.children[n.cellIndex];c&&(r=c)}}else if(n instanceof HTMLTableRowElement){const a=n.parentElement;if(a){const c=a.firstElementChild;c&&(r=c)}}return r&&(!T(r)||!I(r))?j(r):r},le=e=>{const o=e.target;return j(o)},j=e=>{var o;let n;if(e instanceof HTMLTableCellElement){const r=(o=e.parentElement)==null?void 0:o.nextElementSibling;if(r){const a=Array.from(r.children)[e.cellIndex];a&&(n=a)}}else if(e instanceof HTMLTableRowElement){const r=e.nextElementSibling;r&&(n=r)}return n&&(!T(n)||!I(n))?j(n):n},Pe=e=>{var o;const n=e.target;let r;if(n instanceof HTMLTableCellElement){const a=(o=n.parentElement)==null?void 0:o.parentElement;if(a){const c=a.lastElementChild.children[n.cellIndex];c&&(r=c)}}else if(n instanceof HTMLTableRowElement){const a=n.parentElement;if(a){const c=a.lastElementChild;c&&(r=c)}}return r&&(!T(r)||!I(r))?H(r):r},ae=e=>{const o=e.target;return F(o)},F=e=>{var o;let n;if(e.previousElementSibling)n=e.previousElementSibling;else{const r=(o=e.parentElement)==null?void 0:o.previousElementSibling;n=r==null?void 0:r.lastElementChild}return n&&(!T(n)||!I(n))?F(n):n},se=e=>{const o=e.target;return q(o)},q=e=>{var o;let n;if(e.nextElementSibling)n=e.nextElementSibling;else{const r=(o=e.parentElement)==null?void 0:o.nextElementSibling;n=r==null?void 0:r.firstElementChild}return n&&(!T(n)||!I(n))?q(n):n},ce=e=>{const o=e.target.parentElement.firstElementChild;return o&&(!T(o)||!I(o))?q(o):o},ie=e=>{const o=e.target.parentElement.lastElementChild;return o&&(!T(o)||!I(o))?F(o):o},N=["alt","control","shift","meta"],Ne={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"},U={"keydown.up":e=>{const o=re(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.down":e=>{const o=le(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.left":e=>{const o=ae(e);e.preventDefault(),e.stopPropagation(),o&&o.focus()},"keydown.right":e=>{const o=se(e);e.preventDefault(),e.stopPropagation(),o&&o.focus()},"keydown.control.up":e=>{const o=ze(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.control.down":e=>{const o=Pe(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.control.left":e=>{const o=ce(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.control.right":e=>{const o=ie(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.end":e=>{const o=ie(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.enter":e=>{if(e.target instanceof HTMLTableCellElement){e.preventDefault(),e.stopPropagation();const o=le(e);o&&o.focus()}},"keydown.shift.enter":e=>{if(e.target instanceof HTMLTableCellElement){e.preventDefault(),e.stopPropagation();const o=re(e);o&&o.focus()}},"keydown.home":e=>{const o=ce(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.tab":e=>{const o=se(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.shift.tab":e=>{const o=ae(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())}};function G(e){const o=l=>{let i=null;return l.parent&&(typeof l.parent=="string"?i=document.querySelector(l.parent):l.parent instanceof HTMLElement?i=l.parent:i=l.parent.value),i},n=l=>{const i=o(l);let s=[];if(typeof l.selectors=="string")s=i?Array.from(i.querySelectorAll(l.selectors)):Array.from(document.querySelectorAll(l.selectors));else if(Array.isArray(l.selectors))for(const d of l.selectors)d instanceof HTMLElement?s.push(d):s.push(d.$el);else if(l.selectors instanceof HTMLElement)s.push(l.selectors);else if(Array.isArray(l.selectors.value))for(const d of l.selectors.value)d instanceof HTMLElement?s.push(d):s.push(d.$el);else s.push(l.selectors.value);return s},r=l=>{const i=o(l);let s=[];return l.selectors?s=n(l):i&&(s=Array.from(i.children).filter(d=>T(d)&&I(d))),s},a=l=>i=>{const s=Ne[i.key]||i.key.toLowerCase();if(N.includes(s))return;const d=l.handlers||U;for(const f of Object.keys(d)){const[p,...u]=f.split(".");if(p==="keydown"&&u.includes(s)){const b=d[f],y=u.filter(g=>N.includes(g)),w=N.some(g=>{const m=g.charAt(0).toUpperCase()+g.slice(1);return i.getModifierState(m)});if(y.length>0){if(w){for(const g of N)if(u.includes(g)){const m=g.charAt(0).toUpperCase()+g.slice(1);i.getModifierState(m)&&b(i)}}}else w||b(i)}}},c=[];t.onMounted(()=>{for(const l of e){const i=o(l),s=r(l),d=a(l),f=i?[i]:s;for(const p of f){const{focused:u}=De(t.ref(p)),b=t.watch(u,y=>{y?p.addEventListener("keydown",d):p.removeEventListener("keydown",d)});c.push(b)}}}),t.onBeforeUnmount(()=>{for(const l of c)l()})}function D(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function S(e){return typeof e=="function"?e():t.unref(e)}const Y=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ve=e=>e!=null,We=Object.prototype.toString,de=e=>We.call(e)==="[object Object]",M=()=>{},X=He();function He(){var e,o;return Y&&((e=window==null?void 0:window.navigator)==null?void 0:e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((o=window==null?void 0:window.navigator)==null?void 0:o.maxTouchPoints)>2&&/iPad|Macintosh/.test(window==null?void 0:window.navigator.userAgent))}function je(e){return t.getCurrentInstance()}function Fe(...e){if(e.length!==1)return t.toRef(...e);const o=e[0];return typeof o=="function"?t.readonly(t.customRef(()=>({get:o,set:M}))):t.ref(o)}function qe(e,o=!0,n){je()?t.onMounted(e,n):o?e():t.nextTick(e)}const J=Y?window:void 0;function $(e){var o;const n=S(e);return(o=n==null?void 0:n.$el)!=null?o:n}function fe(...e){let o,n,r,a;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,r,a]=e,o=J):[o,n,r,a]=e,!o)return M;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);const c=[],l=()=>{c.forEach(f=>f()),c.length=0},i=(f,p,u,b)=>(f.addEventListener(p,u,b),()=>f.removeEventListener(p,u,b)),s=t.watch(()=>[$(o),S(a)],([f,p])=>{if(l(),!f)return;const u=de(p)?{...p}:p;c.push(...n.flatMap(b=>r.map(y=>i(f,b,y,u))))},{immediate:!0,flush:"post"}),d=()=>{s(),l()};return D(d),d}function Ue(){const e=t.ref(!1),o=t.getCurrentInstance();return o&&t.onMounted(()=>{e.value=!0},o),e}function ue(e){const o=Ue();return t.computed(()=>(o.value,!!e()))}function pe(e,o,n={}){const{window:r=J,...a}=n;let c;const l=ue(()=>r&&"MutationObserver"in r),i=()=>{c&&(c.disconnect(),c=void 0)},s=t.computed(()=>{const u=S(e),b=(Array.isArray(u)?u:[u]).map($).filter(Ve);return new Set(b)}),d=t.watch(()=>s.value,u=>{i(),l.value&&u.size&&(c=new MutationObserver(o),u.forEach(b=>c.observe(b,a)))},{immediate:!0,flush:"post"}),f=()=>c==null?void 0:c.takeRecords(),p=()=>{d(),i()};return D(p),{isSupported:l,stop:p,takeRecords:f}}function Ge(e,o,n={}){const{window:r=J,...a}=n;let c;const l=ue(()=>r&&"ResizeObserver"in r),i=()=>{c&&(c.disconnect(),c=void 0)},s=t.computed(()=>{const p=S(e);return Array.isArray(p)?p.map(u=>$(u)):[$(p)]}),d=t.watch(s,p=>{if(i(),l.value&&r){c=new ResizeObserver(o);for(const u of p)u&&c.observe(u,a)}},{immediate:!0,flush:"post"}),f=()=>{i(),d()};return D(f),{isSupported:l,stop:f}}function Ye(e,o={}){const{reset:n=!0,windowResize:r=!0,windowScroll:a=!0,immediate:c=!0,updateTiming:l="sync"}=o,i=t.ref(0),s=t.ref(0),d=t.ref(0),f=t.ref(0),p=t.ref(0),u=t.ref(0),b=t.ref(0),y=t.ref(0);function w(){const m=$(e);if(!m){n&&(i.value=0,s.value=0,d.value=0,f.value=0,p.value=0,u.value=0,b.value=0,y.value=0);return}const v=m.getBoundingClientRect();i.value=v.height,s.value=v.bottom,d.value=v.left,f.value=v.right,p.value=v.top,u.value=v.width,b.value=v.x,y.value=v.y}function g(){l==="sync"?w():l==="next-frame"&&requestAnimationFrame(()=>w())}return Ge(e,g),t.watch(()=>$(e),m=>!m&&g()),pe(e,g,{attributeFilter:["style","class"]}),a&&fe("scroll",g,{capture:!0,passive:!0}),r&&fe("resize",g,{passive:!0}),qe(()=>{c&&g()}),{height:i,bottom:s,left:d,right:f,top:p,width:u,x:b,y,update:g}}const Xe=e=>{const o=new DOMParser().parseFromString(e,"text/html");return Array.from(o.body.childNodes).some(n=>n.nodeType===1)},Je=["data-colindex","data-rowindex","data-editable","contenteditable","tabindex"],Qe=["innerHTML"],Ze={key:2},Q=t.defineComponent({__name:"ACell",props:{colIndex:{},rowIndex:{},store:{},addNavigation:{type:[Boolean,Object],default:!0},tabIndex:{default:0},pinned:{type:Boolean}},setup(e){const o=t.useTemplateRef("cell"),{bottom:n,left:r}=Ye(o),a=e.store.getCellData(e.colIndex,e.rowIndex),c=t.ref(e.store.getCellDisplayValue(e.colIndex,e.rowIndex)),l=t.ref(""),i=t.ref(!1),s=e.store.columns[e.colIndex],d=e.store.rows[e.rowIndex],f=s.align||"center",p=s.width||"40ch";t.watch(()=>e.store.getCellData(e.colIndex,e.rowIndex),m=>{c.value=e.store.getFormattedValue(e.colIndex,e.rowIndex,m)});const u=t.computed(()=>typeof c.value=="string"?Xe(c.value):!1),b=t.computed(()=>{var m;return{textAlign:f,width:p,backgroundColor:i.value?"var(--sc-cell-changed-color)":"inherit",fontWeight:i.value?"bold":"inherit",paddingLeft:e.store.getIndent(e.colIndex,(m=e.store.display[e.rowIndex])==null?void 0:m.indent)}}),y=()=>{s.mask,s.modalComponent&&e.store.$patch(m=>{m.modal.visible=!0,m.modal.colIndex=e.colIndex,m.modal.rowIndex=e.rowIndex,m.modal.parent=o.value,m.modal.top=n.value,m.modal.left=r.value,m.modal.width=p,typeof s.modalComponent=="function"?m.modal.component=s.modalComponent({table:m.table,row:d,column:s}):m.modal.component=s.modalComponent,m.modal.componentProps=s.modalComponentExtraProps})};if(e.addNavigation){let m={...U,"keydown.f2":y,"keydown.alt.up":y,"keydown.alt.down":y,"keydown.alt.left":y,"keydown.alt.right":y};typeof e.addNavigation=="object"&&(m={...m,...e.addNavigation}),G([{selectors:o,handlers:m}])}const w=()=>{o.value&&(l.value=o.value.textContent)},g=()=>{o.value&&(s.format?i.value=o.value.textContent!==e.store.getFormattedValue(e.colIndex,e.rowIndex,a):i.value=o.value.textContent!==a,o.value.textContent!==l.value&&(l.value=o.value.textContent,o.value.dispatchEvent(new Event("change")),s.format||e.store.setCellData(e.colIndex,e.rowIndex,l.value)))};return(m,v)=>(t.openBlock(),t.createElementBlock("td",{ref:"cell","data-colindex":m.colIndex,"data-rowindex":m.rowIndex,"data-editable":t.unref(s).edit,contenteditable:t.unref(s).edit,tabindex:m.tabIndex,spellcheck:!1,style:t.normalizeStyle(b.value),onFocus:w,onPaste:g,onBlur:g,onInput:g,onClick:y,class:t.normalizeClass(["atable-cell",m.pinned?"sticky-column":""])},[t.unref(s).cellComponent?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(s).cellComponent),t.mergeProps({key:0,value:c.value},t.unref(s).cellComponentProps),null,16,["value"])):u.value?(t.openBlock(),t.createElementBlock("span",{key:1,innerHTML:c.value},null,8,Qe)):(t.openBlock(),t.createElementBlock("span",Ze,t.toDisplayString(c.value),1))],46,Je))}}),Ke=["tabindex"],_e=["tabindex"],et=["colspan"],me=t.defineComponent({__name:"AExpansionRow",props:{rowIndex:{},store:{},tabIndex:{default:()=>-1},addNavigation:{type:[Boolean,Object]}},setup(e){const o=t.useTemplateRef("rowEl"),n=t.computed(()=>e.store.display[e.rowIndex].expanded?"▼":"►");if(e.addNavigation){const r={"keydown.control.g":a=>{a.stopPropagation(),a.preventDefault(),e.store.toggleRowExpand(e.rowIndex)}};typeof e.addNavigation=="object"&&Object.assign(r,e.addNavigation),G([{selectors:o,handlers:r}])}return(r,a)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createElementVNode("tr",t.mergeProps(r.$attrs,{ref:"rowEl",tabindex:r.tabIndex,class:"expandable-row"}),[t.createElementVNode("td",{tabIndex:-1,onClick:a[0]||(a[0]=c=>r.store.toggleRowExpand(r.rowIndex)),class:"row-index"},t.toDisplayString(n.value),1),t.renderSlot(r.$slots,"row")],16,Ke),r.store.display[r.rowIndex].expanded?(t.openBlock(),t.createElementBlock("tr",{key:0,ref:"rowExpanded",tabindex:r.tabIndex,class:"expanded-row"},[t.createElementVNode("td",{tabIndex:-1,colspan:r.store.columns.length+1,class:"expanded-row-content"},[t.renderSlot(r.$slots,"content")],8,et)],8,_e)):t.createCommentVNode("",!0)],64))}}),tt=["tabindex"],Z=t.defineComponent({__name:"ARow",props:{rowIndex:{},store:{},tabIndex:{default:()=>-1},addNavigation:{type:[Boolean,Object],default:!1}},setup(e){const o=t.useTemplateRef("rowEl"),n=e.store.isRowVisible(e.rowIndex),r=e.store.getRowExpandSymbol(e.rowIndex);if(e.addNavigation){let a=U;typeof e.addNavigation=="object"&&(a={...a,...e.addNavigation}),G([{selectors:o,handlers:a}])}return(a,c)=>t.withDirectives((t.openBlock(),t.createElementBlock("tr",{ref:"rowEl",tabindex:a.tabIndex,class:"table-row"},[a.store.config.view!=="uncounted"?t.renderSlot(a.$slots,"index",{key:0},()=>[a.store.config.view==="list"?(t.openBlock(),t.createElementBlock("td",{key:0,tabIndex:-1,class:t.normalizeClass(["list-index",a.store.hasPinnedColumns?"sticky-index":""])},t.toDisplayString(a.rowIndex+1),3)):a.store.config.view==="tree"?(t.openBlock(),t.createElementBlock("td",{key:1,tabIndex:-1,class:t.normalizeClass(["tree-index",a.store.hasPinnedColumns?"sticky-index":""]),onClick:c[0]||(c[0]=l=>a.store.toggleRowExpand(a.rowIndex))},t.toDisplayString(t.unref(r)),3)):t.createCommentVNode("",!0)]):t.createCommentVNode("",!0),t.renderSlot(a.$slots,"default")],8,tt)),[[t.vShow,t.unref(n)]])}}),be=Y?window:void 0;function L(e){var o;const n=S(e);return(o=n==null?void 0:n.$el)!=null?o:n}function V(...e){let o,n,r,a;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,r,a]=e,o=be):[o,n,r,a]=e,!o)return M;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);const c=[],l=()=>{c.forEach(f=>f()),c.length=0},i=(f,p,u,b)=>(f.addEventListener(p,u,b),()=>f.removeEventListener(p,u,b)),s=t.watch(()=>[L(o),S(a)],([f,p])=>{if(l(),!f)return;const u=de(p)?{...p}:p;c.push(...n.flatMap(b=>r.map(y=>i(f,b,y,u))))},{immediate:!0,flush:"post"}),d=()=>{s(),l()};return D(d),d}let we=!1;function ge(e,o,n={}){const{window:r=be,ignore:a=[],capture:c=!0,detectIframe:l=!1}=n;if(!r)return M;X&&!we&&(we=!0,Array.from(r.document.body.children).forEach(w=>w.addEventListener("click",M)),r.document.documentElement.addEventListener("click",M));let i=!0;const s=w=>S(a).some(g=>{if(typeof g=="string")return Array.from(r.document.querySelectorAll(g)).some(m=>m===w.target||w.composedPath().includes(m));{const m=L(g);return m&&(w.target===m||w.composedPath().includes(m))}});function d(w){const g=S(w);return g&&g.$.subTree.shapeFlag===16}function f(w,g){const m=S(w),v=m.$.subTree&&m.$.subTree.children;return v==null||!Array.isArray(v)?!1:v.some(z=>z.el===g.target||g.composedPath().includes(z.el))}const p=w=>{const g=L(e);if(w.target!=null&&!(!(g instanceof Element)&&d(e)&&f(e,w))&&!(!g||g===w.target||w.composedPath().includes(g))){if(w.detail===0&&(i=!s(w)),!i){i=!0;return}o(w)}};let u=!1;const b=[V(r,"click",w=>{u||(u=!0,setTimeout(()=>{u=!1},0),p(w))},{passive:!0,capture:c}),V(r,"pointerdown",w=>{const g=L(e);i=!s(w)&&!!(g&&!w.composedPath().includes(g))},{passive:!0}),l&&V(r,"blur",w=>{setTimeout(()=>{var g;const m=L(e);((g=r.document.activeElement)==null?void 0:g.tagName)==="IFRAME"&&!(m!=null&&m.contains(r.document.activeElement))&&o(w)},0)})].filter(Boolean);return()=>b.forEach(w=>w())}const ot={mounted(e,o){const n=!o.modifiers.bubble;if(typeof o.value=="function")e.__onClickOutside_stop=ge(e,o.value,{capture:n});else{const[r,a]=o.value;e.__onClickOutside_stop=ge(e,r,Object.assign({capture:n},a))}},unmounted(e){e.__onClickOutside_stop()}};function K(e){return typeof Window<"u"&&e instanceof Window?e.document.documentElement:typeof Document<"u"&&e instanceof Document?e.documentElement:e}function he(e){const o=window.getComputedStyle(e);if(o.overflowX==="scroll"||o.overflowY==="scroll"||o.overflowX==="auto"&&e.clientWidth<e.scrollWidth||o.overflowY==="auto"&&e.clientHeight<e.scrollHeight)return!0;{const n=e.parentNode;return!n||n.tagName==="BODY"?!1:he(n)}}function nt(e){const o=e||window.event,n=o.target;return he(n)?!1:o.touches.length>1?!0:(o.preventDefault&&o.preventDefault(),!1)}const _=new WeakMap;function rt(e,o=!1){const n=t.ref(o);let r=null,a="";t.watch(Fe(e),i=>{const s=K(S(i));if(s){const d=s;if(_.get(d)||_.set(d,d.style.overflow),d.style.overflow!=="hidden"&&(a=d.style.overflow),d.style.overflow==="hidden")return n.value=!0;if(n.value)return d.style.overflow="hidden"}},{immediate:!0});const c=()=>{const i=K(S(e));!i||n.value||(X&&(r=V(i,"touchmove",s=>{nt(s)},{passive:!1})),i.style.overflow="hidden",n.value=!0)},l=()=>{const i=K(S(e));!i||!n.value||(X&&(r==null||r()),i.style.overflow=a,_.delete(i),n.value=!1)};return D(l),t.computed({get(){return n.value},set(i){i?c():l()}})}function lt(){let e=!1;const o=t.ref(!1);return(n,r)=>{if(o.value=r.value,e)return;e=!0;const a=rt(n,r.value);t.watch(o,c=>a.value=c)}}lt();const at={key:0,id:"resizable"},st={class:"atable-header-row",tabindex:"-1"},ee=t.defineComponent({__name:"ATableHeader",props:{columns:{},store:{}},setup(e){return(o,n)=>o.columns.length?(t.openBlock(),t.createElementBlock("thead",at,[t.createElementVNode("tr",st,[o.store.zeroColumn?(t.openBlock(),t.createElementBlock("th",{key:0,id:"header-index",class:t.normalizeClass([[o.store.hasPinnedColumns?"sticky-index":"",o.store.config.view==="tree"?"tree-index":"",o.store.config.view==="list-expansion"?"list-expansion-index":""],"list-index"])},null,2)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.columns,(r,a)=>(t.openBlock(),t.createElementBlock("th",{key:r.name,tabindex:"-1",style:t.normalizeStyle(o.store.getHeaderCellStyle(r)),class:t.normalizeClass(r.pinned?"sticky-column":"")},[t.renderSlot(o.$slots,"default",{},()=>[t.createTextVNode(t.toDisplayString(r.label||String.fromCharCode(a+97).toUpperCase()),1)])],6))),128))])])):t.createCommentVNode("",!0)}}),te=t.defineComponent({__name:"ATableModal",props:{colIndex:{},rowIndex:{},store:{}},setup(e){const o=n=>{n.stopPropagation()};return(n,r)=>(t.openBlock(),t.createElementBlock("div",{class:"amodal",tabindex:"-1",onClick:o,onInput:o},[t.renderSlot(n.$slots,"default")],32))}}),ye=e=>{const o=e.id||crypto.randomUUID();return ve.defineStore(`table-${o}`,()=>{const r=()=>{const h={};for(const[x,E]of c.value.entries())for(const[A,C]of l.value.entries())h[`${x}:${A}`]=C[E.name];return h},a=h=>{const x=[Object.assign({},{rowModified:!1})];if(h&&"0:0"in h)return h;const E=new Set;for(let A=l.value.length-1;A>=0;A--){const C=l.value[A];C.parent&&E.add(C.parent),x[A]={childrenOpen:!1,expanded:!1,indent:C.indent||null,isParent:E.has(A),isRoot:C.parent===null||C.parent===void 0,rowModified:!1,open:C.parent===null||C.parent===void 0,parent:C.parent}}return x},c=t.ref(e.columns),l=t.ref(e.rows),i=t.ref(e.config||{}),s=t.ref(e.table||r()),d=t.ref(a(e.display)),f=t.ref(e.modal||{visible:!1}),p=t.computed(()=>c.value.some(h=>h.pinned)),u=t.computed(()=>`${Math.ceil(l.value.length/100+1)}ch`),b=t.computed(()=>["list","tree","list-expansion"].includes(i.value.view)),y=(h,x)=>s.value[`${h}:${x}`],w=(h,x,E)=>{const A=`${h}:${x}`,C=c.value[h];s.value[A]!==E&&(d.value[x].rowModified=!0),s.value[A]=E,l.value[x][C.name]=E},g=h=>({minWidth:h.width||"40ch",textAlign:h.align||"center",width:i.value.fullWidth?"auto":null}),m=h=>i.value.view!=="tree"||d.value[h].isRoot||d.value[h].open,v=h=>i.value.view!=="tree"?"":d.value[h].isRoot||d.value[h].isParent?d.value[h].childrenOpen?"-":"+":"",z=h=>{if(i.value.view==="tree"){d.value[h].childrenOpen=!d.value[h].childrenOpen;for(let x=l.value.length-1;x>=0;x--)d.value[x].parent===h&&(d.value[x].open=!d.value[x].open,d.value[x].childrenOpen&&z(x))}else i.value.view==="list-expansion"&&(d.value[h].expanded=!d.value[h].expanded)},it=(h,x)=>{const E=y(h,x);return ke(h,x,E)},ke=(h,x,E)=>{const A=c.value[h],C=l.value[x],P=A.format;return P?typeof P=="function"?P(E,{table:s.value,row:C,column:A}):typeof P=="string"?Function(`"use strict";return (${P})`)()(E,{table:s.value,row:C,column:A}):E:E};return{columns:c,rows:l,config:i,table:s,display:d,modal:f,hasPinnedColumns:p,numberedRowWidth:u,zeroColumn:b,closeModal:h=>{var x;h.target instanceof Node&&(x=f.value.parent)!=null&&x.contains(h.target)||f.value.visible&&(f.value.visible=!1)},getCellData:y,getCellDisplayValue:it,getFormattedValue:ke,getHeaderCellStyle:g,getIndent:(h,x)=>x&&h===0&&x>0?`${x}ch`:"inherit",getRowExpandSymbol:v,isRowVisible:m,setCellData:w,toggleRowExpand:z}})()},xe=((e,o)=>{const n=e.__vccOpts||e;for(const[r,a]of o)n[r]=a;return n})(t.defineComponent({__name:"ATable",props:{id:{},modelValue:{},columns:{},rows:{default:()=>[]},config:{default:()=>new Object}},emits:["update:modelValue","cellUpdate"],setup(e,{expose:o,emit:n}){const r=n,a=t.useTemplateRef("table"),c=e.modelValue?e.modelValue:e.rows,l=ye({columns:e.columns,rows:c,id:e.id,config:e.config});l.$onAction(({name:s,store:d,args:f})=>{if(s==="setCellData"){const[p,u,b]=f,y=d.getCellData(p,u);r("cellUpdate",[p,u,b,y])}}),t.watch(()=>l.rows,s=>{r("update:modelValue",s)},{deep:!0}),t.onMounted(()=>{e.columns.some(s=>s.pinned)&&(i(),l.config.view==="tree"&&pe(a,i,{childList:!0,subtree:!0}))});const i=()=>{const s=a.value,d=s.rows[0],f=s.rows[1],p=d?Array.from(d.cells):[];for(const[u,b]of p.entries()){const y=f==null?void 0:f.cells[u];y&&(b.style.width=`${y.offsetWidth}px`)}for(const u of s.rows){let b=0;const y=[];for(const w of u.cells)(w.classList.contains("sticky-column")||w.classList.contains("sticky-index"))&&(w.style.left=`${b}px`,b+=w.offsetWidth,y.push(w));y.length>0&&y[y.length-1].classList.add("sticky-column-edge")}};return window.addEventListener("keydown",s=>{if(s.key==="Escape"&&l.modal.visible){l.modal.visible=!1;const d=l.modal.parent;d&&t.nextTick().then(()=>{d.focus()})}}),o({store:l}),(s,d)=>t.withDirectives((t.openBlock(),t.createElementBlock("table",{ref:"table",class:"atable",style:t.normalizeStyle({width:t.unref(l).config.fullWidth?"100%":"auto"})},[t.renderSlot(s.$slots,"header",{data:t.unref(l)},()=>[t.createVNode(ee,{columns:t.unref(l).columns,store:t.unref(l)},null,8,["columns","store"])],!0),t.createElementVNode("tbody",null,[t.renderSlot(s.$slots,"body",{data:t.unref(l)},()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(l).rows,(f,p)=>(t.openBlock(),t.createBlock(Z,{key:f.id,row:f,rowIndex:p,store:t.unref(l)},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(l).columns,(u,b)=>(t.openBlock(),t.createBlock(Q,{key:u.name,store:t.unref(l),col:u,spellcheck:"false",pinned:u.pinned,rowIndex:p,colIndex:b,component:u.cellComponent,style:t.normalizeStyle({textAlign:(u==null?void 0:u.align)||"center",minWidth:(u==null?void 0:u.width)||"40ch",width:t.unref(l).config.fullWidth?"auto":null})},null,8,["store","col","pinned","rowIndex","colIndex","component","style"]))),128))]),_:2},1032,["row","rowIndex","store"]))),128))],!0)]),t.renderSlot(s.$slots,"footer",{data:t.unref(l)},void 0,!0),t.renderSlot(s.$slots,"modal",{data:t.unref(l)},()=>[t.withDirectives(t.createVNode(te,{colIndex:t.unref(l).modal.colIndex,rowIndex:t.unref(l).modal.rowIndex,store:t.unref(l),style:t.normalizeStyle({left:t.unref(l).modal.left+"px",top:t.unref(l).modal.top+"px",maxWidth:t.unref(l).modal.width+"px"})},{default:t.withCtx(()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(l).modal.component),t.mergeProps({key:`${t.unref(l).modal.rowIndex}:${t.unref(l).modal.colIndex}`,colIndex:t.unref(l).modal.colIndex,rowIndex:t.unref(l).modal.rowIndex,store:t.unref(l)},t.unref(l).modal.componentProps),null,16,["colIndex","rowIndex","store"]))]),_:1},8,["colIndex","rowIndex","store","style"]),[[t.vShow,t.unref(l).modal.visible]])],!0)],4)),[[t.unref(ot),t.unref(l).closeModal]])}}),[["__scopeId","data-v-a7848db7"]]);function ct(e){e.component("ACell",Q),e.component("AExpansionRow",me),e.component("ARow",Z),e.component("ATable",xe),e.component("ATableHeader",ee),e.component("ATableModal",te)}k.ACell=Q,k.AExpansionRow=me,k.ARow=Z,k.ATable=xe,k.ATableHeader=ee,k.ATableModal=te,k.createTableStore=ye,k.install=ct,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(k,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],t):(k=typeof globalThis<"u"?globalThis:k||self,t(k["@stonecrop/atable"]={},k.Vue,k.pinia))})(this,function(k,t,Ee){"use strict";var oe=document.createElement("style");oe.textContent=`@import"https://fonts.googleapis.com/css2?family=Arimo:ital,wght@0,400..700;1,400..700&display=swap";.atable-cell{border-radius:0;box-sizing:border-box;margin:0;outline:none;box-shadow:none;color:var(--sc-cell-text-color);padding-left:.5ch!important;padding-right:.5ch;padding-top:var(--sc-atable-row-padding);padding-bottom:var(--sc-atable-row-padding);border-spacing:0px;border-collapse:collapse;overflow:hidden;text-overflow:ellipsis;order:1;white-space:nowrap;max-width:40ch}.atable-cell a{color:var(--sc-cell-text-color);text-decoration:none}.atable-cell:focus,.atable-cell:focus-within{background-color:var(--sc-focus-cell-background);outline-width:var(--sc-atable-cell-border-width);outline-style:solid;outline-offset:calc(var(--sc-atable-cell-border-width) * -1);outline-color:var(--sc-focus-cell-outline);box-shadow:none;overflow:hidden;text-wrap:nowrap;box-sizing:border-box}.row-index{color:var(--sc-header-text-color);font-weight:700;text-align:center;-webkit-user-select:none;user-select:none;width:2ch;display:flex;align-items:center;justify-content:center}.expandable-row{border-top:1px solid var(--sc-row-border-color);height:var(--sc-atable-row-height);display:flex}.expandable-row>td:first-child{border-left:4px solid var(--sc-row-border-color)}.expanded-row{display:flex;border-left:2px solid var(--sc-row-border-color)}.expandable-row:last-child{border-bottom:1px solid var(--sc-row-border-color)}.expanded-row-content{border-top:1px solid var(--sc-row-border-color);padding:1.5rem}.table-row{border-top:1px solid var(--sc-row-border-color);display:flex;background-color:#fff}.table-row>td:first-child{border-left:4px solid var(--sc-row-border-color)}.list-index{color:var(--sc-header-text-color);font-weight:700;padding-left:var(--sc-atable-row-padding);padding-right:.5em;text-align:left;-webkit-user-select:none;user-select:none;width:7ch;text-overflow:ellipsis;overflow:hidden;box-sizing:border-box;padding-top:var(--sc-atable-row-padding);padding-bottom:var(--sc-atable-row-padding)}.tree-index{color:var(--sc-header-text-color);font-weight:700;text-align:center;-webkit-user-select:none;user-select:none;width:2ch;box-sizing:border-box;padding-top:var(--sc-atable-row-padding);padding-bottom:var(--sc-atable-row-padding)}.atable-header-row{display:flex}.atable-header-row th{padding-left:.5ch!important;font-weight:700;padding-top:var(--sc-atable-row-padding);padding-bottom:var(--sc-atable-row-padding);box-sizing:border-box;color:var(--sc-header-text-color)}#header-index{padding-left:var(--sc-atable-row-padding);box-sizing:border-box}.tree-index{padding-right:0}th{order:1}.list-expansion-index{width:2ch;margin-left:5px}:root{--sc-primary-color: #0098c9;--sc-primary-text-color: #ffffff;--sc-brand-color: #202a44;--sc-gray-5: #f2f2f2;--sc-gray-10: #e6e6e6;--sc-gray-20: #cccccc;--sc-gray-50: #808080;--sc-gray-60: #666666;--sc-gray-80: #333333;--sc-brand-danger: #e63c28;--sc-brand-success: #155724;--sc-brand-warning: #b99d3e;--sc-active-cell-background: #ffffff;--sc-active-cell-outline: #e6a92d;--sc-cell-border-color: #ffffff;--sc-cell-text-color: #3a3c41;--sc-focus-cell-background: #ffffff;--sc-focus-cell-outline: #000000;--sc-header-border-color: #ffffff;--sc-header-text-color: var(--sc-gray-20);--sc-row-border-color: var(--sc-gray-20);--sc-row-color-zebra-dark: #dddddd;--sc-row-color-zebra-light: #eeeeee;--sc-row-number-background-color: #ffffff;--sc-input-active-border-color: #000000;--sc-input-active-label-color: #000000;--sc-input-border-color: var(--sc-gray-20);--sc-input-label-color: var(--sc-gray-60);--sc-required-border: #e63c28;--sc-cell-changed-color: #d8edff;--sc-form-border: var(--sc-gray-20);--sc-form-background: #ffffff;--sc-input-field-background: #ffffff;--sc-input-field-disabled-background: var(--sc-gray-5);--sc-font-size: 10px;--sc-font-family: Arimo, Arial, sans-serif;--sc-table-font-size: 16px;--sc-atable-font-family: "Arimo", sans-serif;--sc-atable-row-padding: .125rem;--sc-atable-row-height: 1.5em;--sc-atable-cell-border-width: 2px;--sc-btn-border: #cccccc;--sc-btn-color: white;--sc-btn-hover: #f2f2f2;--sc-btn-label-color: black}.amodal{position:absolute;background-color:var(--sc-row-color-zebra-dark);z-index:100}.sticky-index{position:sticky;left:0;z-index:1;order:0}.sticky-column,th.sticky-column,td.sticky-column,th.sticky-index,td.sticky-index{position:sticky;z-index:1;order:0;background:#fff}.sticky-column-edge,.atable th.sticky-column-edge{border-right:1px solid var(--sc-row-border-color);border-right-width:1px}[data-v-7a1c014a]:root{--sc-primary-color: #0098c9;--sc-primary-text-color: #ffffff;--sc-brand-color: #202a44;--sc-gray-5: #f2f2f2;--sc-gray-10: #e6e6e6;--sc-gray-20: #cccccc;--sc-gray-50: #808080;--sc-gray-60: #666666;--sc-gray-80: #333333;--sc-brand-danger: #e63c28;--sc-brand-success: #155724;--sc-brand-warning: #b99d3e;--sc-active-cell-background: #ffffff;--sc-active-cell-outline: #e6a92d;--sc-cell-border-color: #ffffff;--sc-cell-text-color: #3a3c41;--sc-focus-cell-background: #ffffff;--sc-focus-cell-outline: #000000;--sc-header-border-color: #ffffff;--sc-header-text-color: var(--sc-gray-20);--sc-row-border-color: var(--sc-gray-20);--sc-row-color-zebra-dark: #dddddd;--sc-row-color-zebra-light: #eeeeee;--sc-row-number-background-color: #ffffff;--sc-input-active-border-color: #000000;--sc-input-active-label-color: #000000;--sc-input-border-color: var(--sc-gray-20);--sc-input-label-color: var(--sc-gray-60);--sc-required-border: #e63c28;--sc-cell-changed-color: #d8edff;--sc-form-border: var(--sc-gray-20);--sc-form-background: #ffffff;--sc-input-field-background: #ffffff;--sc-input-field-disabled-background: var(--sc-gray-5);--sc-font-size: 10px;--sc-font-family: Arimo, Arial, sans-serif;--sc-table-font-size: 16px;--sc-atable-font-family: "Arimo", sans-serif;--sc-atable-row-padding: .125rem;--sc-atable-row-height: 1.5em;--sc-atable-cell-border-width: 2px;--sc-btn-border: #cccccc;--sc-btn-color: white;--sc-btn-hover: #f2f2f2;--sc-btn-label-color: black}.atable[data-v-7a1c014a]{position:relative;font-family:var(--sc-atable-font-family);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:var(--sc-table-font-size);border-collapse:collapse;box-sizing:border-box;table-layout:auto;width:auto}.atable th[data-v-7a1c014a]{border-width:0px;border-style:solid;border-radius:0;padding-left:.5ch;padding-right:.5ch;padding-top:var(--sc-atable-row-padding);padding-bottom:var(--sc-atable-row-padding);color:var(--sc-gray-60);height:var(--sc-atable-row-height);font-weight:300;letter-spacing:.05rem;order:1;box-sizing:border-box}.atable th[data-v-7a1c014a]:focus{outline:none}
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(oe);function ne(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function H(e){return typeof e=="function"?e():t.unref(e)}const Ce=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Se=e=>e!=null,Ae=Object.prototype.toString,Ie=e=>Ae.call(e)==="[object Object]",Te=()=>{},R=Ce?window:void 0;function B(e){var o;const n=H(e);return(o=n==null?void 0:n.$el)!=null?o:n}function O(...e){let o,n,r,a;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,r,a]=e,o=R):[o,n,r,a]=e,!o)return Te;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);const c=[],l=()=>{c.forEach(f=>f()),c.length=0},i=(f,m,u,b)=>(f.addEventListener(m,u,b),()=>f.removeEventListener(m,u,b)),s=t.watch(()=>[B(o),H(a)],([f,m])=>{if(l(),!f)return;const u=Ie(m)?{...m}:m;c.push(...n.flatMap(b=>r.map(y=>i(f,b,y,u))))},{immediate:!0,flush:"post"}),d=()=>{s(),l()};return ne(d),d}function $e(){const e=t.ref(!1),o=t.getCurrentInstance();return o&&t.onMounted(()=>{e.value=!0},o),e}function Me(e){const o=$e();return t.computed(()=>(o.value,!!e()))}function Re(e,o,n={}){const{window:r=R,...a}=n;let c;const l=Me(()=>r&&"MutationObserver"in r),i=()=>{c&&(c.disconnect(),c=void 0)},s=t.computed(()=>{const u=H(e),b=(Array.isArray(u)?u:[u]).map(B).filter(Se);return new Set(b)}),d=t.watch(()=>s.value,u=>{i(),l.value&&u.size&&(c=new MutationObserver(o),u.forEach(b=>c.observe(b,a)))},{immediate:!0,flush:"post"}),f=()=>c==null?void 0:c.takeRecords(),m=()=>{d(),i()};return ne(m),{isSupported:l,stop:m,takeRecords:f}}function Be(e={}){var o;const{window:n=R,deep:r=!0,triggerOnRemoval:a=!1}=e,c=(o=e.document)!=null?o:n==null?void 0:n.document,l=()=>{var d;let f=c==null?void 0:c.activeElement;if(r)for(;f!=null&&f.shadowRoot;)f=(d=f==null?void 0:f.shadowRoot)==null?void 0:d.activeElement;return f},i=t.ref(),s=()=>{i.value=l()};return n&&(O(n,"blur",d=>{d.relatedTarget===null&&s()},!0),O(n,"focus",s,!0)),a&&Re(c,d=>{d.filter(f=>f.removedNodes.length).map(f=>Array.from(f.removedNodes)).flat().forEach(f=>{f===i.value&&s()})},{childList:!0,subtree:!0}),s(),i}const Oe="focusin",Le="focusout";function De(e,o={}){const{window:n=R}=o,r=t.computed(()=>B(e)),a=t.ref(!1),c=t.computed(()=>a.value),l=Be(o);return!n||!l.value?{focused:c}:(O(r,Oe,()=>a.value=!0),O(r,Le,()=>a.value=!1),{focused:c})}function ze(e,{window:o=R,scrollTarget:n}={}){const r=t.ref(!1),a=()=>{if(!o)return;const c=o.document,l=B(e);if(!l)r.value=!1;else{const i=l.getBoundingClientRect();r.value=i.top<=(o.innerHeight||c.documentElement.clientHeight)&&i.left<=(o.innerWidth||c.documentElement.clientWidth)&&i.bottom>=0&&i.right>=0}};return t.watch(()=>B(e),()=>a(),{immediate:!0,flush:"post"}),o&&O(n||o,"scroll",a,{capture:!1,passive:!0}),r}const I=e=>{let o=ze(e).value;return o=o&&e.offsetHeight>0,o},T=e=>e.tabIndex>=0,re=e=>{const o=e.target;return W(o)},W=e=>{var o;let n;if(e instanceof HTMLTableCellElement){const r=(o=e.parentElement)==null?void 0:o.previousElementSibling;if(r){const a=Array.from(r.children)[e.cellIndex];a&&(n=a)}}else if(e instanceof HTMLTableRowElement){const r=e.previousElementSibling;r&&(n=r)}return n&&(!T(n)||!I(n))?W(n):n},Pe=e=>{var o;const n=e.target;let r;if(n instanceof HTMLTableCellElement){const a=(o=n.parentElement)==null?void 0:o.parentElement;if(a){const c=a.firstElementChild.children[n.cellIndex];c&&(r=c)}}else if(n instanceof HTMLTableRowElement){const a=n.parentElement;if(a){const c=a.firstElementChild;c&&(r=c)}}return r&&(!T(r)||!I(r))?j(r):r},le=e=>{const o=e.target;return j(o)},j=e=>{var o;let n;if(e instanceof HTMLTableCellElement){const r=(o=e.parentElement)==null?void 0:o.nextElementSibling;if(r){const a=Array.from(r.children)[e.cellIndex];a&&(n=a)}}else if(e instanceof HTMLTableRowElement){const r=e.nextElementSibling;r&&(n=r)}return n&&(!T(n)||!I(n))?j(n):n},Ne=e=>{var o;const n=e.target;let r;if(n instanceof HTMLTableCellElement){const a=(o=n.parentElement)==null?void 0:o.parentElement;if(a){const c=a.lastElementChild.children[n.cellIndex];c&&(r=c)}}else if(n instanceof HTMLTableRowElement){const a=n.parentElement;if(a){const c=a.lastElementChild;c&&(r=c)}}return r&&(!T(r)||!I(r))?W(r):r},ae=e=>{const o=e.target;return F(o)},F=e=>{var o;let n;if(e.previousElementSibling)n=e.previousElementSibling;else{const r=(o=e.parentElement)==null?void 0:o.previousElementSibling;n=r==null?void 0:r.lastElementChild}return n&&(!T(n)||!I(n))?F(n):n},se=e=>{const o=e.target;return q(o)},q=e=>{var o;let n;if(e.nextElementSibling)n=e.nextElementSibling;else{const r=(o=e.parentElement)==null?void 0:o.nextElementSibling;n=r==null?void 0:r.firstElementChild}return n&&(!T(n)||!I(n))?q(n):n},ce=e=>{const o=e.target.parentElement.firstElementChild;return o&&(!T(o)||!I(o))?q(o):o},ie=e=>{const o=e.target.parentElement.lastElementChild;return o&&(!T(o)||!I(o))?F(o):o},N=["alt","control","shift","meta"],Ve={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"},U={"keydown.up":e=>{const o=re(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.down":e=>{const o=le(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.left":e=>{const o=ae(e);e.preventDefault(),e.stopPropagation(),o&&o.focus()},"keydown.right":e=>{const o=se(e);e.preventDefault(),e.stopPropagation(),o&&o.focus()},"keydown.control.up":e=>{const o=Pe(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.control.down":e=>{const o=Ne(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.control.left":e=>{const o=ce(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.control.right":e=>{const o=ie(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.end":e=>{const o=ie(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.enter":e=>{if(e.target instanceof HTMLTableCellElement){e.preventDefault(),e.stopPropagation();const o=le(e);o&&o.focus()}},"keydown.shift.enter":e=>{if(e.target instanceof HTMLTableCellElement){e.preventDefault(),e.stopPropagation();const o=re(e);o&&o.focus()}},"keydown.home":e=>{const o=ce(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.tab":e=>{const o=se(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())},"keydown.shift.tab":e=>{const o=ae(e);o&&(e.preventDefault(),e.stopPropagation(),o.focus())}};function G(e){const o=l=>{let i=null;return l.parent&&(typeof l.parent=="string"?i=document.querySelector(l.parent):l.parent instanceof HTMLElement?i=l.parent:i=l.parent.value),i},n=l=>{const i=o(l);let s=[];if(typeof l.selectors=="string")s=i?Array.from(i.querySelectorAll(l.selectors)):Array.from(document.querySelectorAll(l.selectors));else if(Array.isArray(l.selectors))for(const d of l.selectors)d instanceof HTMLElement?s.push(d):s.push(d.$el);else if(l.selectors instanceof HTMLElement)s.push(l.selectors);else if(Array.isArray(l.selectors.value))for(const d of l.selectors.value)d instanceof HTMLElement?s.push(d):s.push(d.$el);else s.push(l.selectors.value);return s},r=l=>{const i=o(l);let s=[];return l.selectors?s=n(l):i&&(s=Array.from(i.children).filter(d=>T(d)&&I(d))),s},a=l=>i=>{const s=Ve[i.key]||i.key.toLowerCase();if(N.includes(s))return;const d=l.handlers||U;for(const f of Object.keys(d)){const[m,...u]=f.split(".");if(m==="keydown"&&u.includes(s)){const b=d[f],y=u.filter(g=>N.includes(g)),w=N.some(g=>{const p=g.charAt(0).toUpperCase()+g.slice(1);return i.getModifierState(p)});if(y.length>0){if(w){for(const g of N)if(u.includes(g)){const p=g.charAt(0).toUpperCase()+g.slice(1);i.getModifierState(p)&&b(i)}}}else w||b(i)}}},c=[];t.onMounted(()=>{for(const l of e){const i=o(l),s=r(l),d=a(l),f=i?[i]:s;for(const m of f){const{focused:u}=De(t.ref(m)),b=t.watch(u,y=>{y?m.addEventListener("keydown",d):m.removeEventListener("keydown",d)});c.push(b)}}}),t.onBeforeUnmount(()=>{for(const l of c)l()})}function L(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function A(e){return typeof e=="function"?e():t.unref(e)}const Y=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const He=e=>e!=null,We=Object.prototype.toString,de=e=>We.call(e)==="[object Object]",$=()=>{},X=je();function je(){var e,o;return Y&&((e=window==null?void 0:window.navigator)==null?void 0:e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((o=window==null?void 0:window.navigator)==null?void 0:o.maxTouchPoints)>2&&/iPad|Macintosh/.test(window==null?void 0:window.navigator.userAgent))}function Fe(e){return t.getCurrentInstance()}function qe(...e){if(e.length!==1)return t.toRef(...e);const o=e[0];return typeof o=="function"?t.readonly(t.customRef(()=>({get:o,set:$}))):t.ref(o)}function Ue(e,o=!0,n){Fe()?t.onMounted(e,n):o?e():t.nextTick(e)}const J=Y?window:void 0;function M(e){var o;const n=A(e);return(o=n==null?void 0:n.$el)!=null?o:n}function fe(...e){let o,n,r,a;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,r,a]=e,o=J):[o,n,r,a]=e,!o)return $;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);const c=[],l=()=>{c.forEach(f=>f()),c.length=0},i=(f,m,u,b)=>(f.addEventListener(m,u,b),()=>f.removeEventListener(m,u,b)),s=t.watch(()=>[M(o),A(a)],([f,m])=>{if(l(),!f)return;const u=de(m)?{...m}:m;c.push(...n.flatMap(b=>r.map(y=>i(f,b,y,u))))},{immediate:!0,flush:"post"}),d=()=>{s(),l()};return L(d),d}function Ge(){const e=t.ref(!1),o=t.getCurrentInstance();return o&&t.onMounted(()=>{e.value=!0},o),e}function ue(e){const o=Ge();return t.computed(()=>(o.value,!!e()))}function me(e,o,n={}){const{window:r=J,...a}=n;let c;const l=ue(()=>r&&"MutationObserver"in r),i=()=>{c&&(c.disconnect(),c=void 0)},s=t.computed(()=>{const u=A(e),b=(Array.isArray(u)?u:[u]).map(M).filter(He);return new Set(b)}),d=t.watch(()=>s.value,u=>{i(),l.value&&u.size&&(c=new MutationObserver(o),u.forEach(b=>c.observe(b,a)))},{immediate:!0,flush:"post"}),f=()=>c==null?void 0:c.takeRecords(),m=()=>{d(),i()};return L(m),{isSupported:l,stop:m,takeRecords:f}}function Ye(e,o,n={}){const{window:r=J,...a}=n;let c;const l=ue(()=>r&&"ResizeObserver"in r),i=()=>{c&&(c.disconnect(),c=void 0)},s=t.computed(()=>{const m=A(e);return Array.isArray(m)?m.map(u=>M(u)):[M(m)]}),d=t.watch(s,m=>{if(i(),l.value&&r){c=new ResizeObserver(o);for(const u of m)u&&c.observe(u,a)}},{immediate:!0,flush:"post"}),f=()=>{i(),d()};return L(f),{isSupported:l,stop:f}}function pe(e,o={}){const{reset:n=!0,windowResize:r=!0,windowScroll:a=!0,immediate:c=!0,updateTiming:l="sync"}=o,i=t.ref(0),s=t.ref(0),d=t.ref(0),f=t.ref(0),m=t.ref(0),u=t.ref(0),b=t.ref(0),y=t.ref(0);function w(){const p=M(e);if(!p){n&&(i.value=0,s.value=0,d.value=0,f.value=0,m.value=0,u.value=0,b.value=0,y.value=0);return}const v=p.getBoundingClientRect();i.value=v.height,s.value=v.bottom,d.value=v.left,f.value=v.right,m.value=v.top,u.value=v.width,b.value=v.x,y.value=v.y}function g(){l==="sync"?w():l==="next-frame"&&requestAnimationFrame(()=>w())}return Ye(e,g),t.watch(()=>M(e),p=>!p&&g()),me(e,g,{attributeFilter:["style","class"]}),a&&fe("scroll",g,{capture:!0,passive:!0}),r&&fe("resize",g,{passive:!0}),Ue(()=>{c&&g()}),{height:i,bottom:s,left:d,right:f,top:m,width:u,x:b,y,update:g}}const Xe=e=>{const o=new DOMParser().parseFromString(e,"text/html");return Array.from(o.body.childNodes).some(n=>n.nodeType===1)},Je=["data-colindex","data-rowindex","data-editable","contenteditable","tabindex"],Qe=["innerHTML"],Ze={key:2},Q=t.defineComponent({__name:"ACell",props:{colIndex:{},rowIndex:{},store:{},addNavigation:{type:[Boolean,Object],default:!0},tabIndex:{default:0},pinned:{type:Boolean}},setup(e){const o=t.useTemplateRef("cell"),{width:n,height:r}=pe(o),a=e.store.getCellData(e.colIndex,e.rowIndex),c=t.ref(e.store.getCellDisplayValue(e.colIndex,e.rowIndex)),l=t.ref(""),i=t.ref(!1),s=e.store.columns[e.colIndex],d=e.store.rows[e.rowIndex],f=s.align||"center",m=s.width||"40ch";t.watch(()=>e.store.getCellData(e.colIndex,e.rowIndex),p=>{c.value=e.store.getFormattedValue(e.colIndex,e.rowIndex,p)});const u=t.computed(()=>typeof c.value=="string"?Xe(c.value):!1),b=t.computed(()=>{var p;return{textAlign:f,width:m,backgroundColor:i.value?"var(--sc-cell-changed-color)":"inherit",fontWeight:i.value?"bold":"inherit",paddingLeft:e.store.getIndent(e.colIndex,(p=e.store.display[e.rowIndex])==null?void 0:p.indent)}}),y=()=>{s.mask,s.modalComponent&&e.store.$patch(p=>{p.modal.visible=!0,p.modal.colIndex=e.colIndex,p.modal.rowIndex=e.rowIndex,p.modal.parent=o.value,p.modal.top=o.value.offsetTop+o.value.offsetHeight,p.modal.left=o.value.offsetLeft,p.modal.width=n.value,p.modal.height=r.value,typeof s.modalComponent=="function"?p.modal.component=s.modalComponent({table:p.table,row:d,column:s}):p.modal.component=s.modalComponent,p.modal.componentProps=s.modalComponentExtraProps})};if(e.addNavigation){let p={...U,"keydown.f2":y,"keydown.alt.up":y,"keydown.alt.down":y,"keydown.alt.left":y,"keydown.alt.right":y};typeof e.addNavigation=="object"&&(p={...p,...e.addNavigation}),G([{selectors:o,handlers:p}])}const w=()=>{o.value&&(l.value=o.value.textContent)},g=()=>{o.value&&(s.format?i.value=o.value.textContent!==e.store.getFormattedValue(e.colIndex,e.rowIndex,a):i.value=o.value.textContent!==a,o.value.textContent!==l.value&&(l.value=o.value.textContent,o.value.dispatchEvent(new Event("change")),s.format||e.store.setCellData(e.colIndex,e.rowIndex,l.value)))};return(p,v)=>(t.openBlock(),t.createElementBlock("td",{ref:"cell","data-colindex":p.colIndex,"data-rowindex":p.rowIndex,"data-editable":t.unref(s).edit,contenteditable:t.unref(s).edit,tabindex:p.tabIndex,spellcheck:!1,style:t.normalizeStyle(b.value),onFocus:w,onPaste:g,onBlur:g,onInput:g,onClick:y,class:t.normalizeClass(["atable-cell",p.pinned?"sticky-column":""])},[t.unref(s).cellComponent?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(s).cellComponent),t.mergeProps({key:0,value:c.value},t.unref(s).cellComponentProps),null,16,["value"])):u.value?(t.openBlock(),t.createElementBlock("span",{key:1,innerHTML:c.value},null,8,Qe)):(t.openBlock(),t.createElementBlock("span",Ze,t.toDisplayString(c.value),1))],46,Je))}}),Ke=["tabindex"],_e=["tabindex"],et=["colspan"],be=t.defineComponent({__name:"AExpansionRow",props:{rowIndex:{},store:{},tabIndex:{default:()=>-1},addNavigation:{type:[Boolean,Object]}},setup(e){const o=t.useTemplateRef("rowEl"),n=t.computed(()=>e.store.display[e.rowIndex].expanded?"▼":"►");if(e.addNavigation){const r={"keydown.control.g":a=>{a.stopPropagation(),a.preventDefault(),e.store.toggleRowExpand(e.rowIndex)}};typeof e.addNavigation=="object"&&Object.assign(r,e.addNavigation),G([{selectors:o,handlers:r}])}return(r,a)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createElementVNode("tr",t.mergeProps(r.$attrs,{ref:"rowEl",tabindex:r.tabIndex,class:"expandable-row"}),[t.createElementVNode("td",{tabIndex:-1,onClick:a[0]||(a[0]=c=>r.store.toggleRowExpand(r.rowIndex)),class:"row-index"},t.toDisplayString(n.value),1),t.renderSlot(r.$slots,"row")],16,Ke),r.store.display[r.rowIndex].expanded?(t.openBlock(),t.createElementBlock("tr",{key:0,ref:"rowExpanded",tabindex:r.tabIndex,class:"expanded-row"},[t.createElementVNode("td",{tabIndex:-1,colspan:r.store.columns.length+1,class:"expanded-row-content"},[t.renderSlot(r.$slots,"content")],8,et)],8,_e)):t.createCommentVNode("",!0)],64))}}),tt=["tabindex"],Z=t.defineComponent({__name:"ARow",props:{rowIndex:{},store:{},tabIndex:{default:()=>-1},addNavigation:{type:[Boolean,Object],default:!1}},setup(e){const o=t.useTemplateRef("rowEl"),n=e.store.isRowVisible(e.rowIndex),r=e.store.getRowExpandSymbol(e.rowIndex);if(e.addNavigation){let a=U;typeof e.addNavigation=="object"&&(a={...a,...e.addNavigation}),G([{selectors:o,handlers:a}])}return(a,c)=>t.withDirectives((t.openBlock(),t.createElementBlock("tr",{ref:"rowEl",tabindex:a.tabIndex,class:"table-row"},[a.store.config.view!=="uncounted"?t.renderSlot(a.$slots,"index",{key:0},()=>[a.store.config.view==="list"?(t.openBlock(),t.createElementBlock("td",{key:0,tabIndex:-1,class:t.normalizeClass(["list-index",a.store.hasPinnedColumns?"sticky-index":""])},t.toDisplayString(a.rowIndex+1),3)):a.store.config.view==="tree"?(t.openBlock(),t.createElementBlock("td",{key:1,tabIndex:-1,class:t.normalizeClass(["tree-index",a.store.hasPinnedColumns?"sticky-index":""]),onClick:c[0]||(c[0]=l=>a.store.toggleRowExpand(a.rowIndex))},t.toDisplayString(t.unref(r)),3)):t.createCommentVNode("",!0)]):t.createCommentVNode("",!0),t.renderSlot(a.$slots,"default")],8,tt)),[[t.vShow,t.unref(n)]])}}),we=Y?window:void 0;function D(e){var o;const n=A(e);return(o=n==null?void 0:n.$el)!=null?o:n}function V(...e){let o,n,r,a;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,r,a]=e,o=we):[o,n,r,a]=e,!o)return $;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);const c=[],l=()=>{c.forEach(f=>f()),c.length=0},i=(f,m,u,b)=>(f.addEventListener(m,u,b),()=>f.removeEventListener(m,u,b)),s=t.watch(()=>[D(o),A(a)],([f,m])=>{if(l(),!f)return;const u=de(m)?{...m}:m;c.push(...n.flatMap(b=>r.map(y=>i(f,b,y,u))))},{immediate:!0,flush:"post"}),d=()=>{s(),l()};return L(d),d}let ge=!1;function he(e,o,n={}){const{window:r=we,ignore:a=[],capture:c=!0,detectIframe:l=!1}=n;if(!r)return $;X&&!ge&&(ge=!0,Array.from(r.document.body.children).forEach(w=>w.addEventListener("click",$)),r.document.documentElement.addEventListener("click",$));let i=!0;const s=w=>A(a).some(g=>{if(typeof g=="string")return Array.from(r.document.querySelectorAll(g)).some(p=>p===w.target||w.composedPath().includes(p));{const p=D(g);return p&&(w.target===p||w.composedPath().includes(p))}});function d(w){const g=A(w);return g&&g.$.subTree.shapeFlag===16}function f(w,g){const p=A(w),v=p.$.subTree&&p.$.subTree.children;return v==null||!Array.isArray(v)?!1:v.some(z=>z.el===g.target||g.composedPath().includes(z.el))}const m=w=>{const g=D(e);if(w.target!=null&&!(!(g instanceof Element)&&d(e)&&f(e,w))&&!(!g||g===w.target||w.composedPath().includes(g))){if(w.detail===0&&(i=!s(w)),!i){i=!0;return}o(w)}};let u=!1;const b=[V(r,"click",w=>{u||(u=!0,setTimeout(()=>{u=!1},0),m(w))},{passive:!0,capture:c}),V(r,"pointerdown",w=>{const g=D(e);i=!s(w)&&!!(g&&!w.composedPath().includes(g))},{passive:!0}),l&&V(r,"blur",w=>{setTimeout(()=>{var g;const p=D(e);((g=r.document.activeElement)==null?void 0:g.tagName)==="IFRAME"&&!(p!=null&&p.contains(r.document.activeElement))&&o(w)},0)})].filter(Boolean);return()=>b.forEach(w=>w())}const ot={mounted(e,o){const n=!o.modifiers.bubble;if(typeof o.value=="function")e.__onClickOutside_stop=he(e,o.value,{capture:n});else{const[r,a]=o.value;e.__onClickOutside_stop=he(e,r,Object.assign({capture:n},a))}},unmounted(e){e.__onClickOutside_stop()}};function K(e){return typeof Window<"u"&&e instanceof Window?e.document.documentElement:typeof Document<"u"&&e instanceof Document?e.documentElement:e}function ye(e){const o=window.getComputedStyle(e);if(o.overflowX==="scroll"||o.overflowY==="scroll"||o.overflowX==="auto"&&e.clientWidth<e.scrollWidth||o.overflowY==="auto"&&e.clientHeight<e.scrollHeight)return!0;{const n=e.parentNode;return!n||n.tagName==="BODY"?!1:ye(n)}}function nt(e){const o=e||window.event,n=o.target;return ye(n)?!1:o.touches.length>1?!0:(o.preventDefault&&o.preventDefault(),!1)}const _=new WeakMap;function rt(e,o=!1){const n=t.ref(o);let r=null,a="";t.watch(qe(e),i=>{const s=K(A(i));if(s){const d=s;if(_.get(d)||_.set(d,d.style.overflow),d.style.overflow!=="hidden"&&(a=d.style.overflow),d.style.overflow==="hidden")return n.value=!0;if(n.value)return d.style.overflow="hidden"}},{immediate:!0});const c=()=>{const i=K(A(e));!i||n.value||(X&&(r=V(i,"touchmove",s=>{nt(s)},{passive:!1})),i.style.overflow="hidden",n.value=!0)},l=()=>{const i=K(A(e));!i||!n.value||(X&&(r==null||r()),i.style.overflow=a,_.delete(i),n.value=!1)};return L(l),t.computed({get(){return n.value},set(i){i?c():l()}})}function lt(){let e=!1;const o=t.ref(!1);return(n,r)=>{if(o.value=r.value,e)return;e=!0;const a=rt(n,r.value);t.watch(o,c=>a.value=c)}}lt();const at={key:0,id:"resizable"},st={class:"atable-header-row",tabindex:"-1"},ee=t.defineComponent({__name:"ATableHeader",props:{columns:{},store:{}},setup(e){return(o,n)=>o.columns.length?(t.openBlock(),t.createElementBlock("thead",at,[t.createElementVNode("tr",st,[o.store.zeroColumn?(t.openBlock(),t.createElementBlock("th",{key:0,id:"header-index",class:t.normalizeClass([[o.store.hasPinnedColumns?"sticky-index":"",o.store.config.view==="tree"?"tree-index":"",o.store.config.view==="list-expansion"?"list-expansion-index":""],"list-index"])},null,2)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.columns,(r,a)=>(t.openBlock(),t.createElementBlock("th",{key:r.name,tabindex:"-1",style:t.normalizeStyle(o.store.getHeaderCellStyle(r)),class:t.normalizeClass(r.pinned?"sticky-column":"")},[t.renderSlot(o.$slots,"default",{},()=>[t.createTextVNode(t.toDisplayString(r.label||String.fromCharCode(a+97).toUpperCase()),1)])],6))),128))])])):t.createCommentVNode("",!0)}}),te=t.defineComponent({__name:"ATableModal",props:{colIndex:{},rowIndex:{},store:{},container:{}},setup(e){const o=t.useTemplateRef("amodal"),{width:n,height:r}=pe(o),a=t.computed(()=>{var f,m;const l=((f=e.container)==null?void 0:f.offsetWidth)||0,i=((m=e.container)==null?void 0:m.offsetHeight)||0,s=e.store.modal.left+n.value>l?e.store.modal.left-(n.value-e.store.modal.width):e.store.modal.left,d=e.store.modal.top+r.value>i?e.store.modal.top-r.value-e.store.modal.height:e.store.modal.top;return{left:`${s}px`,top:`${d}px`}}),c=l=>{l.stopPropagation()};return(l,i)=>(t.openBlock(),t.createElementBlock("div",{class:"amodal",ref:"amodal",tabindex:"-1",onClick:c,onInput:c,style:t.normalizeStyle(a.value)},[t.renderSlot(l.$slots,"default")],36))}}),xe=e=>{const o=e.id||crypto.randomUUID();return Ee.defineStore(`table-${o}`,()=>{const r=()=>{const h={};for(const[x,E]of c.value.entries())for(const[S,C]of l.value.entries())h[`${x}:${S}`]=C[E.name];return h},a=h=>{const x=[Object.assign({},{rowModified:!1})];if(h&&"0:0"in h)return h;const E=new Set;for(let S=l.value.length-1;S>=0;S--){const C=l.value[S];C.parent&&E.add(C.parent),x[S]={childrenOpen:!1,expanded:!1,indent:C.indent||null,isParent:E.has(S),isRoot:C.parent===null||C.parent===void 0,rowModified:!1,open:C.parent===null||C.parent===void 0,parent:C.parent}}return x},c=t.ref(e.columns),l=t.ref(e.rows),i=t.ref(e.config||{}),s=t.ref(e.table||r()),d=t.ref(a(e.display)),f=t.ref(e.modal||{visible:!1}),m=t.computed(()=>c.value.some(h=>h.pinned)),u=t.computed(()=>`${Math.ceil(l.value.length/100+1)}ch`),b=t.computed(()=>["list","tree","list-expansion"].includes(i.value.view)),y=(h,x)=>s.value[`${h}:${x}`],w=(h,x,E)=>{const S=`${h}:${x}`,C=c.value[h];s.value[S]!==E&&(d.value[x].rowModified=!0),s.value[S]=E,l.value[x][C.name]=E},g=h=>({minWidth:h.width||"40ch",textAlign:h.align||"center",width:i.value.fullWidth?"auto":null}),p=h=>i.value.view!=="tree"||d.value[h].isRoot||d.value[h].open,v=h=>i.value.view!=="tree"?"":d.value[h].isRoot||d.value[h].isParent?d.value[h].childrenOpen?"-":"+":"",z=h=>{if(i.value.view==="tree"){d.value[h].childrenOpen=!d.value[h].childrenOpen;for(let x=l.value.length-1;x>=0;x--)d.value[x].parent===h&&(d.value[x].open=!d.value[x].open,d.value[x].childrenOpen&&z(x))}else i.value.view==="list-expansion"&&(d.value[h].expanded=!d.value[h].expanded)},it=(h,x)=>{const E=y(h,x);return ve(h,x,E)},ve=(h,x,E)=>{const S=c.value[h],C=l.value[x],P=S.format;return P?typeof P=="function"?P(E,{table:s.value,row:C,column:S}):typeof P=="string"?Function(`"use strict";return (${P})`)()(E,{table:s.value,row:C,column:S}):E:E};return{columns:c,rows:l,config:i,table:s,display:d,modal:f,hasPinnedColumns:m,numberedRowWidth:u,zeroColumn:b,closeModal:h=>{var x;h.target instanceof Node&&(x=f.value.parent)!=null&&x.contains(h.target)||f.value.visible&&(f.value.visible=!1)},getCellData:y,getCellDisplayValue:it,getFormattedValue:ve,getHeaderCellStyle:g,getIndent:(h,x)=>x&&h===0&&x>0?`${x}ch`:"inherit",getRowExpandSymbol:v,isRowVisible:p,setCellData:w,toggleRowExpand:z}})()},ke=((e,o)=>{const n=e.__vccOpts||e;for(const[r,a]of o)n[r]=a;return n})(t.defineComponent({__name:"ATable",props:{id:{},modelValue:{},columns:{},rows:{default:()=>[]},config:{default:()=>new Object}},emits:["update:modelValue","cellUpdate"],setup(e,{expose:o,emit:n}){const r=n,a=t.useTemplateRef("table"),c=e.modelValue?e.modelValue:e.rows,l=xe({columns:e.columns,rows:c,id:e.id,config:e.config});l.$onAction(({name:s,store:d,args:f})=>{if(s==="setCellData"){const[m,u,b]=f,y=d.getCellData(m,u);r("cellUpdate",[m,u,b,y])}}),t.watch(()=>l.rows,s=>{r("update:modelValue",s)},{deep:!0}),t.onMounted(()=>{e.columns.some(s=>s.pinned)&&(i(),l.config.view==="tree"&&me(a,i,{childList:!0,subtree:!0}))});const i=()=>{const s=a.value,d=s.rows[0],f=s.rows[1],m=d?Array.from(d.cells):[];for(const[u,b]of m.entries()){const y=f==null?void 0:f.cells[u];y&&(b.style.width=`${y.offsetWidth}px`)}for(const u of s.rows){let b=0;const y=[];for(const w of u.cells)(w.classList.contains("sticky-column")||w.classList.contains("sticky-index"))&&(w.style.left=`${b}px`,b+=w.offsetWidth,y.push(w));y.length>0&&y[y.length-1].classList.add("sticky-column-edge")}};return window.addEventListener("keydown",s=>{if(s.key==="Escape"&&l.modal.visible){l.modal.visible=!1;const d=l.modal.parent;d&&t.nextTick().then(()=>{d.focus()})}}),o({store:l}),(s,d)=>t.withDirectives((t.openBlock(),t.createElementBlock("table",{ref:"table",class:"atable",style:t.normalizeStyle({width:t.unref(l).config.fullWidth?"100%":"auto"})},[t.renderSlot(s.$slots,"header",{data:t.unref(l)},()=>[t.createVNode(ee,{columns:t.unref(l).columns,store:t.unref(l)},null,8,["columns","store"])],!0),t.createElementVNode("tbody",null,[t.renderSlot(s.$slots,"body",{data:t.unref(l)},()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(l).rows,(f,m)=>(t.openBlock(),t.createBlock(Z,{key:f.id,row:f,rowIndex:m,store:t.unref(l)},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(l).columns,(u,b)=>(t.openBlock(),t.createBlock(Q,{key:u.name,store:t.unref(l),col:u,spellcheck:"false",pinned:u.pinned,rowIndex:m,colIndex:b,component:u.cellComponent,style:t.normalizeStyle({textAlign:(u==null?void 0:u.align)||"center",minWidth:(u==null?void 0:u.width)||"40ch",width:t.unref(l).config.fullWidth?"auto":null})},null,8,["store","col","pinned","rowIndex","colIndex","component","style"]))),128))]),_:2},1032,["row","rowIndex","store"]))),128))],!0)]),t.renderSlot(s.$slots,"footer",{data:t.unref(l)},void 0,!0),t.renderSlot(s.$slots,"modal",{data:t.unref(l)},()=>[t.withDirectives(t.createVNode(te,{colIndex:t.unref(l).modal.colIndex,rowIndex:t.unref(l).modal.rowIndex,store:t.unref(l),container:t.unref(a)},{default:t.withCtx(()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(l).modal.component),t.mergeProps({key:`${t.unref(l).modal.rowIndex}:${t.unref(l).modal.colIndex}`,colIndex:t.unref(l).modal.colIndex,rowIndex:t.unref(l).modal.rowIndex,store:t.unref(l)},t.unref(l).modal.componentProps),null,16,["colIndex","rowIndex","store"]))]),_:1},8,["colIndex","rowIndex","store","container"]),[[t.vShow,t.unref(l).modal.visible]])],!0)],4)),[[t.unref(ot),t.unref(l).closeModal]])}}),[["__scopeId","data-v-7a1c014a"]]);function ct(e){e.component("ACell",Q),e.component("AExpansionRow",be),e.component("ARow",Z),e.component("ATable",ke),e.component("ATableHeader",ee),e.component("ATableModal",te)}k.ACell=Q,k.AExpansionRow=be,k.ARow=Z,k.ATable=ke,k.ATableHeader=ee,k.ATableModal=te,k.createTableStore=xe,k.install=ct,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
|
|
3
3
|
//# sourceMappingURL=atable.umd.cjs.map
|