UNPKG

@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.3 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";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"}]},a=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})),d="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)=>{const o=g(e.operators);let r=e.operator;switch(e.filterType){case"numeric":(!r||a(r))&&(r=o),t===null&&r===o&&(r="");break;case"date":(!r||a(r))&&(r=o),t===null&&r===o&&(r="");break;case"text":(!r||a(r))&&(r=o),!t&&r===o&&(r="");break;default:return}e.onChange({value:t,operator:r,syntheticEvent:i})},g=(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===""?"":d,syntheticEvent:t.syntheticEvent})},v=(t,i,e)=>{let o=i;const r=t.target.value;t.target.state.opened&&(a(r.operator)&&(o=null),i===null&&!a(r.operator)&&(o=void 0),e({value:o,operator:r.operator,syntheticEvent:t.syntheticEvent}))},n=(t,i)=>{const e=i||new O.IntlService("en-US");if(t.value){const o=e.parseDate(t.value);o&&(t.value=o)}t.filters&&(t.filters=t.filters.map(o=>{if(o.value){const r=e.parseDate(o.value);r&&(o.value=r)}return o}))},b=(t,i)=>{var o;let e=t;if(e&&Object.keys(e).length===0&&(e=null),e!=null&&e.filters&&Array.isArray(e.filters)){const r=i||{filters:[],logic:"and"},u=r.filters.map(l=>l.field||l.filters[0].field),p=e.filters.every(l=>l.field===(e==null?void 0:e.filters[0]).field),s=p?[{filters:e.filters.map(l=>(n(l),l)),logic:e.logic}]:e.filters.map(l=>{const c=l.filters?l:{logic:t.logic,filters:[l]};return n(c),c}),f=p&&u.includes(s[0].filters[0].field);if(f){const l=r.filters[0];l.filters&&((o=l.filters)==null||o.push(...s[0].filters),l.logic=t.logic)}e={...r,filters:f?r.filters:[...r.filters,...s]}}return e};exports.IsUnaryFilter=a;exports.booleanFilterValues=q;exports.cellBoolDropdownChange=F;exports.cellInputChange=E;exports.cellOperatorChange=v;exports.combineSmartFilters=b;exports.defaultBooleanOperator=d;exports.defaultHideSecondFilter=I;exports.filterLogicList=m;exports.getDefaultOperator=g;exports.getFilterType=N;exports.operatorMap=h;exports.operators=y;exports.parseFilterDates=n;