@progress/kendo-vue-grid
Version:
9 lines (8 loc) • 8.27 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2026 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@progress/kendo-vue-data-tools"),S=require("@progress/kendo-vue-common"),D=require("../GridColumn.js"),b="string";function E(e,t){const r=e.split(".");let n=t;return r.forEach(o=>{n=n?n[o]:void 0}),n}function F(e,t,r,n,o,d,a,i,s,f,g=0,l){let c=g;for(let p=0;p<t.length;p++){let h;if(!o||t[p].value===void 0||t[p].items===void 0){const u=s?!!(d!=null&&d[S.getter(s)(t[p])]):!1;e[e.length]={dataIndex:n.index,dataItem:t[p],rowType:"data",level:g,group:l,expanded:f!==void 0?E(f,t[p]):u!=null?u:!1},n.index++;continue}else{let u;l!=null&&l.parents?u=[{field:l.field,value:l.value},...l.parents]:l?u=[l]:u=[],h={field:t[p].field,value:t[p].value,parents:u}}c=Math.max(c,g+1);let x=!1;const I=y.findGroupExpand(a||[],h);f?x=f===void 0||E(f,t[p])===void 0||E(f,t[p]):x=I?I.expanded!==!1:i!==!1,e[e.length]={dataIndex:-1,dataItem:t[p],level:g,group:h,rowType:"groupHeader",expanded:x},x&&(h.expanded=x,c=Math.max(F(e,t[p].items,r,n,o,d,a,i,s,f,g+1,h),c)),(r==="always"||x&&r==="visible")&&(e[e.length]={dataIndex:-1,dataItem:t[p],rowType:"groupFooter",level:g,expanded:x})}return c}function k(e){return e&&getComputedStyle(e).direction==="rtl"||!1}function N(e,t){if(!t||!e||!e.originalEvent||!S.canUseDOM)return-1;let r=document.elementFromPoint(e.clientX,e.originalEvent.clientY);for(;r&&r.parentElement!==t;)r=r.parentElement;const n=t.children;for(let o=0;o<n.length;o++)if(n[o]===r)return o;return-1}const A=["sortChange","filterChange","groupChange","pageChange","expandChange","selectionChange","headerSelectionChange","rowClick","itemChange","dataStateChange","columnResize","columnReorder"],L=(e,t)=>`The ${e} event handler property is deprecated, use https://www.telerik.com/kendo-vue-ui/components/grid/api/GridProps/#toc-${t} instead`;function P(e){for(let t=0;t<A.length;t++){const r=A[t];if(e[r]!==void 0){const n="on"+r.charAt(0).toUpperCase()+r.slice(1);console.warn(L(r,n))}}}function V(e,t){const r=[[]];let n=0;for(let a=e.length-1;a>=0;a--)n=Math.max(n,e[a].depth),e[a].headerColSpan=e[a].headerColSpan||1,e[a].children.length>0&&(e[a].headerColSpan=e[a].children.reduce((i,s)=>s.hidden?i:i+s.headerColSpan,0));const o=[];let d=1;return e.forEach((a,i)=>{r[a.depth]=r[a.depth]||[];let s=!1;r[a.depth].length===0&&(d<=1?d=1+(a.children.length>0?0:n-a.depth):(d--,s=!0)),a.rowSpan=1+(a.children.length>0?0:n-a.depth),a.kFirst=s,a.index=r[a.depth].length,a.ariaColumnIndex=o[a.depth]?o[a.depth]+1:1;let f=0;const g=[],l=new Set;let c=a.parentIndex;for(;c>=0&&!l.has(c);)l.add(c),g.unshift(c),c=e[c].parentIndex;for(let h=0;h<g.length;h++){const x=g[h],I=e[x],u=r[I.depth],v=u.indexOf(x);for(let C=0;C<v;C++){const w=u[C];f+=e[w].headerColSpan}}for(let h=0;h<a.depth;h++){const x=r[h]||[],u=(r[a.depth]||[]).indexOf(i);let v=0;for(const C of x){const w=e[C];v<u&&w.depth+w.rowSpan-1>=a.depth&&(g.includes(C)||(f+=w.headerColSpan)),v+=w.headerColSpan}}const p=r[a.depth];for(const h of p){const x=e[h];x.parentIndex===a.parentIndex&&(f+=x.headerColSpan)}a.virtualColumnOffset=f,r[a.depth].push(i);for(let h=a.depth;h<a.depth+a.rowSpan;h++)o[h]=(o[h]||0)+a.headerColSpan}),y.updateLeft(r,e,t),y.updateRight(r,e,t),r}function M(e,t,r,n=0,o=!1){const d=[];if(!e)return[];e&&e.length===void 0&&(e=[e]),e.forEach((i,s)=>{i=i;const f=i.id?i.id:y.tableKeyboardNavigationTools.generateNavigatableId(`${r.prevId++}`,r.idPrefix,"column"),g=S.canUseDOM&&i.media&&window.matchMedia?!window.matchMedia(i.media).matches:!1,l=o||g||i.hidden,c=t==null?void 0:t.find(h=>h.id===f),p=M(i.children,(c==null?void 0:c.children)||[],r,n+1,l);d.push({depth:n,...D.gridDefaultProps,...p.length?{cell:()=>null,filterCell:()=>null}:{},...i,id:f,declarationIndex:d.length,children:p,headerColSpan:0,rowSpan:0,columnType:i.columnType||"data",colSpan:i.colSpan||1,isAccessible:!0,hidden:l,left:null,right:null,rowSpannable:i.rowSpannable,...c?{width:c.width,orderIndex:c.orderIndex}:{}})});const a=(i,s)=>i.orderIndex===s.orderIndex?i.declarationIndex-s.declarationIndex:(i.orderIndex||0)-(s.orderIndex||0);if(d.sort(a),n===0){const i=[],s=(f,g)=>f.forEach(l=>{l.parentIndex=g,s(l.children,i.push(l)-1)});return s(d,-1),i}return d}const T=e=>Array.isArray(e)?e:e?e.data:[];function j(e,t,r,n){const o=T(e),d=[];if(o.length>0){let a=o[0];if(t)for(let s=0;s<t.length;s++)a=a.items&&a.items[0];Object.getOwnPropertyNames(a).forEach(s=>{s!==r.column&&d.push({id:y.tableKeyboardNavigationTools.generateNavigatableId(`${n.prevId++}`,n.idPrefix,"column"),declarationIndex:-1,parentIndex:-1,depth:0,colSpan:0,headerColSpan:0,rowSpan:0,index:0,columnType:"data",left:0,right:0,rightBorder:!1,children:[],ariaColumnIndex:0,isAccessible:!0,...D.gridDefaultProps,field:s})})}return d}const K=(e,t)=>{var n;let r=e[t.parentIndex];for(;r;){if(r.footerCell||(n=r.cells)!=null&&n.footerCell)return!0;r=e[r.parentIndex]}return!1},$=e=>e.filter(t=>{var r;return K(e,t)?!1:!!(t.footerCell||(r=t.cells)!=null&&r.footerCell)||!(t.children&&t.children.length>0)}),z={number:function(e,t,r){return typeof e===b&&e.toLowerCase()==="null"?null:t.parseNumber(e,r)},date:function(e,t,r){return typeof e===b&&e.toLowerCase()==="null"?null:t.parseDate(e,r)},boolean:function(e){return typeof e===b?e.toLowerCase()==="null"?null:e.toLowerCase()==="true":e!=null?!!e:e},string:function(e){return typeof e===b&&e.toLowerCase()==="null"?null:e!=null?e+"":e},default:function(e){return e}};function H(e,t,r,n){return e.forEach(o=>{o.expanded=t[n]&&!t[n].includes(R(o,r)),o.items&&o.items.length&&(o.items=H(o.items,t,r,n+1))}),e}function B(e,t,r){return t&&t.length&&e.data.forEach(n=>{n.expanded=n.expanded!==void 0?n.expanded:t[0]&&!t[0].includes(R(n,r)),n.items&&n.items.length&&(n.items=H(n.items,t,r,1))}),e}function R(e,t){let r=e;for(;r.items&&r.items.length;)r=r.items[0];return t?r[t]:e.value}const U=e=>{const t=[],r=n=>n==null?void 0:n.forEach(o=>{t.push(o),r(o.children)});return r(e),t},q=typeof window!="undefined"&&/Firefox/.test(window.navigator.userAgent),W=17895697,X=e=>e.width!==void 0?Math.floor(parseFloat(e.width.toString()))+"px":void 0,Y=(e,t)=>t&&t.filter(r=>r.field===e).length>0,O=e=>(e.sort((t,r)=>t.declarationIndex-r.declarationIndex),e.map(t=>{const{declarationIndex:r,parentIndex:n,depth:o,headerColSpan:d,rowSpan:a,index:i,kFirst:s,children:f,...g}=t;return f.length?{children:O(f),...g}:g})),J=(e,t)=>typeof e.colSpan=="function"?e.colSpan({dataItem:t,column:e}):e.colSpan||1,Q=e=>{var n,o;const t=typeof e=="object"?(n=e.enabled)!=null?n:!0:e!=null?e:!1,r=typeof e=="object"?(o=e.valueGetter)!=null?o:((d,a)=>S.getter(a)(d)):(d,a)=>S.getter(a)(d);return{enabled:t,valueGetter:r}},Z=e=>{let t=0;if(e){const r=e.insertRow(0),n=r.insertCell(0);n.textContent=" ",t=r.getBoundingClientRect().height,e.deleteRow(0)}return t},_=(e,t)=>{var r,n,o,d,a,i;if(!(!e&&!t))return t?e?{headerCell:(r=t.headerCell)!=null?r:e.headerCell,filterCell:(n=t.filterCell)!=null?n:e.filterCell,footerCell:(o=t.footerCell)!=null?o:e.footerCell,groupHeader:(d=t.groupHeader)!=null?d:e.groupHeader,data:(a=t.data)!=null?a:e.data,groupFooter:(i=t.groupFooter)!=null?i:e.groupFooter,select:{...e.select||{},...t.select||{}},hierarchy:{...e.hierarchy||{},...t.hierarchy||{}},group:{...e.group||{},...t.group||{}},edit:{...e.edit||{},...t.edit||{}},pin:{...e.pin||{},...t.pin||{}}}:t:e};exports.applyExpandedState=B;exports.autoGenerateColumns=j;exports.calcRowHeight=Z;exports.checkPropCompatibility=P;exports.firefox=q;exports.firefoxMaxHeight=W;exports.flatData=F;exports.footerColumns=$;exports.getColSpan=J;exports.getColumnWidth=X;exports.getDataAsArray=T;exports.getFlatColumnsState=U;exports.getIndex=N;exports.getNestedValue=E;exports.getRowSpanOptions=Q;exports.groupedFirstItemValue=R;exports.isRtl=k;exports.isSorted=Y;exports.mapColumns=V;exports.parsers=z;exports.readColumns=M;exports.resolveCells=_;exports.sanitizeColumns=O;