@progress/kendo-react-grid
Version:
React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package
9 lines (8 loc) • 4.26 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 x=require("./messages/index.js"),O=require("@progress/kendo-react-intl"),m=[{text:"grid.filterAndLogic",operator:"and"},{text:"grid.filterOrLogic",operator:"or"}],y={text:[{text:"grid.filterContainsOperator",operator:"contains"},{text:"grid.filterNotContainsOperator",operator:"doesnotcontain"},{text:"grid.filterEqOperator",operator:"eq"},{text:"grid.filterNotEqOperator",operator:"neq"},{text:"grid.filterStartsWithOperator",operator:"startswith"},{text:"grid.filterEndsWithOperator",operator:"endswith"},{text:"grid.filterIsNullOperator",operator:"isnull"},{text:"grid.filterIsNotNullOperator",operator:"isnotnull"},{text:"grid.filterIsEmptyOperator",operator:"isempty"},{text:"grid.filterIsNotEmptyOperator",operator:"isnotempty"}],numeric:[{text:"grid.filterEqOperator",operator:"eq"},{text:"grid.filterNotEqOperator",operator:"neq"},{text:"grid.filterGteOperator",operator:"gte"},{text:"grid.filterGtOperator",operator:"gt"},{text:"grid.filterLteOperator",operator:"lte"},{text:"grid.filterLtOperator",operator:"lt"},{text:"grid.filterIsNullOperator",operator:"isnull"},{text:"grid.filterIsNotNullOperator",operator:"isnotnull"}],date:[{text:"grid.filterEqOperator",operator:"eq"},{text:"grid.filterNotEqOperator",operator:"neq"},{text:"grid.filterAfterOrEqualOperator",operator:"gte"},{text:"grid.filterAfterOperator",operator:"gt"},{text:"grid.filterBeforeOperator",operator:"lt"},{text:"grid.filterBeforeOrEqualOperator",operator:"lte"},{text:"grid.filterIsNullOperator",operator:"isnull"},{text:"grid.filterIsNotNullOperator",operator:"isnotnull"}],boolean:[{text:"grid.filterEqOperator",operator:"eq"}]},s=t=>t==="isnull"||t==="isnotnull"||t==="isempty"||t==="isnotempty",h=(t,i)=>t.map(e=>({text:i.toLanguageString(e.text,x.messages[e.text]),operator:e.operator})),g="eq",q=[{text:"grid.filterBooleanAll",operator:""},{text:"grid.filterIsTrue",operator:!0},{text:"grid.filterIsFalse",operator:!1}],I={text:!1,numeric:!1,date:!1,boolean:!0},E=(t,i,e,r=!0)=>{const o=u(e.operators);let a=e.operator;switch(e.filterType){case"numeric":case"date":(!a||s(a))&&(a=o),r&&t===null&&a===o&&(a="");break;case"text":(!a||s(a))&&(a=o),r&&!t&&a===o&&(a="");break;default:return}e.onChange({value:t,operator:a,syntheticEvent:i})},u=(t,i)=>i?t[i][0].operator:t[0].operator,N=t=>t||"text",F=(t,i)=>{const e=t.target.value;i({value:e.operator,operator:e.operator===""?"":g,syntheticEvent:t.syntheticEvent})},v=(t,i,e)=>{let r=i;const o=t.target.value;t.target.state.opened&&(s(o.operator)&&(r=null),i===null&&!s(o.operator)&&(r=void 0),e({value:r,operator:o.operator,syntheticEvent:t.syntheticEvent}))},p=(t,i)=>{const e=i||new O.IntlService("en-US");if(t.value){const r=e.parseDate(t.value);r&&(t.value=r)}t.filters&&(t.filters=t.filters.map(r=>{if(r.value){const o=e.parseDate(r.value);o&&(r.value=o)}return r}))},b=(t,i)=>{var r;let e=t;if(e&&Object.keys(e).length===0&&(e=null),e!=null&&e.filters&&Array.isArray(e.filters)){const o=i||{filters:[],logic:"and"},a=o.filters.map(l=>l.field||l.filters[0].field),f=e.filters.every(l=>l.field===(e==null?void 0:e.filters[0]).field),n=f?[{filters:e.filters.map(l=>(p(l),l)),logic:e.logic}]:e.filters.map(l=>{const c=l.filters?l:{logic:t.logic,filters:[l]};return p(c),c}),d=f&&a.includes(n[0].filters[0].field);if(d){const l=o.filters[0];l.filters&&((r=l.filters)==null||r.push(...n[0].filters),l.logic=t.logic)}e={...o,filters:d?o.filters:[...o.filters,...n]}}return e};exports.IsUnaryFilter=s;exports.booleanFilterValues=q;exports.cellBoolDropdownChange=F;exports.cellInputChange=E;exports.cellOperatorChange=v;exports.combineSmartFilters=b;exports.defaultBooleanOperator=g;exports.defaultHideSecondFilter=I;exports.filterLogicList=m;exports.getDefaultOperator=u;exports.getFilterType=N;exports.operatorMap=h;exports.operators=y;exports.parseFilterDates=p;