@progress/kendo-react-pivotgrid
Version:
React PivotGrid (also called Pivot Table) can be data-bound to an OLAP service and customized extensively. KendoReact PivotGrid package
9 lines (8 loc) • 4.7 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 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 W=require("react"),Y=require("@progress/kendo-react-treeview"),P=require("@progress/kendo-react-buttons"),Z=require("@progress/kendo-react-indicators"),ee=require("@progress/kendo-react-intl"),N=require("@progress/kendo-react-data-tools"),i=require("@progress/kendo-react-common"),te=require("@progress/kendo-svg-icons"),C=require("../utils/index.js"),s=require("../messages/index.js"),ne=require("../shared/PivotGridConfiguratorEditorEventsContext.js"),oe=require("../shared/PivotGridConfiguratorEditorStateContext.js"),O=require("../hooks/useExpansion.js"),g=require("../hooks/usePivotConfiguratorEditor.js");function ae(n){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const l in n)if(l!=="default"){const d=Object.getOwnPropertyDescriptor(n,l);Object.defineProperty(u,l,d.get?d:{enumerable:!0,get:()=>n[l]})}}return u.default=n,Object.freeze(u)}const t=ae(W),S=t.forwardRef((n,u)=>{const{data:l,dataItem:d,defaultFilter:I}={...r,...n},F=t.useRef(null),m=t.useRef(null),y=ee.useLocalization(),[q,A]=i.useCustomComponent(n.columnMenuItem||r.columnMenuItem),[T,w]=i.useCustomComponent(n.columnMenuForm||r.columnMenuForm),[B,b]=i.useCustomComponent(n.resetButton||r.resetButton),[_,G]=i.useCustomComponent(n.applyButton||r.applyButton),[V,D]=i.useCustomComponent(n.treeView||r.treeView),[j,L]=i.useCustomComponent(n.noData||r.noData);t.useImperativeHandle(m,()=>({props:n,element:F.current})),t.useImperativeHandle(u,()=>m.current);const[h,f]=t.useState(!1),{onAxisFilterFieldsExpandChange:v,onAxisFilterFieldExpand:k}=t.useContext(ne.PivotGridConfiguratorEditorEventsContext),[,E]=t.useContext(oe.PivotGridConfiguratorEditorStateContext),[c,z]=t.useState(I),x=c?c.value.split(","):[],[H,U]=O.useExpansion([],void 0,m,C.compareFields),R={caption:e=>e.dataItem.caption,id:e=>e.dataItem.uniqueName,parent:(e,a)=>a&&a.value,value:e=>e.dataItem.defaultHierarchy||e.dataItem.uniqueName,expanded:e=>H.some(a=>a.uniqueName===e.id),checked:e=>!x.length||(x||[]).some(a=>a===e.dataItem.uniqueName),hasChildren:e=>parseInt(e.dataItem.childrenCardinality,10)>0,children:e=>C.recursiveMap(e.dataItem.children,R,e),checkIndeterminate:e=>{const a=(e.children||[]).length&&e.children.every(o=>o.checked);return a&&(e.checked=!0),(e.children||[]).some(o=>o.checked)&&!a}},p=C.recursiveMap(l,R),M=C.flatMap(p),K=e=>{f(!h),v&&v({value:!h,target:m.current,syntheticEvent:e})},X=e=>{U({type:O.EXPANSION_ACTION.toggle,payload:e.item.dataItem},e.syntheticEvent),k&&k({value:e.item.dataItem,target:m.current,syntheticEvent:e.syntheticEvent})},$=e=>{let a;e.item.checked?a={field:String(d.name),operator:"in",value:M.filter(o=>o.checked).map(o=>String(o.value)).filter(o=>o!==e.item.value&&o!==e.item.parent).join(",")}:a={field:String(d.name),operator:"in",value:M.filter(o=>o.checked).map(o=>String(o.value)).concat([e.item.value]).join(",")},z(a)},J=e=>{f(!1),c&&E({type:g.PIVOT_CONFIGURATOR_ACTION.removeFilter,payload:c},e)},Q=e=>{f(!1),c&&E({type:I?g.PIVOT_CONFIGURATOR_ACTION.changeFilter:g.PIVOT_CONFIGURATOR_ACTION.addFilter,payload:c},e)};return t.createElement("div",{ref:F,id:n.id,tabIndex:n.tabIndex,style:n.style,className:i.classNames("k-columnmenu-item-wrapper",n.className)},t.createElement(q,{...A,title:"Include Fields",iconClass:"k-i-grid-layout",svgIcon:te.gridLayoutIcon,onClick:K}),t.createElement(T,{show:h,actions:t.createElement(t.Fragment,null,t.createElement(B,{type:"reset",onClick:J,...b},y.toLanguageString(s.fieldMenuReset,s.messages[s.fieldMenuReset])),t.createElement(_,{themeColor:"primary",onClick:Q,...G},y.toLanguageString(s.fieldMenuApply,s.messages[s.fieldMenuApply]))),...w},p&&p.length?t.createElement(V,{data:p,checkboxes:!0,onExpandChange:X,onCheckChange:$,textField:"caption",expandIcons:!0,hasChildrenField:"hasChildren",checkIndeterminateField:"checkIndeterminate",childrenField:"children",...D}):t.createElement(j,{...L})))}),r={data:[],resetButton:P.Button,applyButton:P.Button,treeView:Y.TreeView,noData:()=>t.createElement(Z.Skeleton,{shape:"rectangle",style:{height:"20px",width:"calc(100% - 16px)",margin:8}}),columnMenuItem:N.ColumnMenuItem,columnMenuForm:N.ColumnMenuForm};S.displayName="KendoReactPivotGridAxisFilterFieldsEditor";exports.PivotGridAxisFilterFieldsEditor=S;