Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@grapecity/wijmo.grid.filter

Package Overview
Dependencies
Maintainers
2
Versions
1293
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@grapecity/wijmo.grid.filter - npm Package Compare versions

Comparing version 5.20241.1-nightly.d20240116.t020147 to 5.20241.1-nightly.d20240117.t020138

4

es2015-commonjs.js
/*!
*
* Wijmo Library 5.20241.001-nightly.d20240116.t020147
* Wijmo Library 5.20241.001-nightly.d20240117.t020138
* https://developer.mescius.com/wijmo

@@ -14,2 +14,2 @@ *

"use strict";var __importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_grid_1=require("@grapecity/wijmo.grid"),wijmo_1=require("@grapecity/wijmo"),wijmo_input_1=require("@grapecity/wijmo.input"),input=__importStar(require("@grapecity/wijmo.input")),selfModule=__importStar(require("@grapecity/wijmo.grid.filter"));var FilterType,Operator,ValueFilterSearchKind;!function(e){e[e.None=0]="None";e[e.Condition=1]="Condition";e[e.Value=2]="Value";e[e.Both=3]="Both"}(FilterType=exports.FilterType||(exports.FilterType={}));class FlexGridFilter{constructor(e,t){this._showIcons=!0;this._showSort=!0;this._defFilterType=FilterType.Both;this._xValueSearch=!0;this._includeUpdatedRowsInFilter=!1;this.filterApplied=new wijmo_1.Event;this.editingFilter=new wijmo_1.Event;this.filterChanging=new wijmo_1.Event;this.filterChanged=new wijmo_1.Event;this.exclusiveValueSearchChanged=new wijmo_1.Event;this._filters=[];this._g=wijmo_1.asType(e,wijmo_grid_1.FlexGrid,!1);this._g.formatItem.addHandler(this._formatItem.bind(this));this._g.itemsSourceChanged.addHandler(this.clear.bind(this));let i=this._g.hostElement;e.addEventListener(i,"mousedown",this._mousedown.bind(this),!0);e.addEventListener(i,"click",this._click.bind(this),!0);e.addEventListener(i,"keydown",this._keydown.bind(this),!0);this._g.invalidate();wijmo_1.copy(this,t);this._init()}_init(){const e=this.grid,_excludeRowFromFilter=e=>{let t=this.grid;const i=this.excludedRowsSet;t.itemsSource?t.rows[e]instanceof wijmo_grid_1._NewRowTemplate?i.add(t.editableCollectionView.currentAddItem||t.rows[e].dataItem):i.add(t.rows[e].dataItem):i.add(t.rows[e])};e.rowChanged&&e.rowChanged.addHandler((e,t)=>{t.added&&_excludeRowFromFilter(t.index)});e.rowEditEnding.addHandler((e,t)=>{_excludeRowFromFilter(t.row)});e.cellEditEnded.addHandler((e,t)=>{_excludeRowFromFilter(t.row)})}get excludedRowsSet(){let e=this.grid;e.selectedSheet&&(e=e.selectedSheet);e._newAddedRowsSet||(e._newAddedRowsSet=new WeakSet);return e._newAddedRowsSet}set excludedRowsSet(e){let t=this.grid;t.selectedSheet&&(t=t.selectedSheet);t._newAddedRowsSet=e}get grid(){return this._g}get filterColumns(){return this._filterColumns}set filterColumns(e){this._filterColumns=wijmo_1.asArray(e);this.clear()}get showFilterIcons(){return this._showIcons}set showFilterIcons(e){if(e!=this.showFilterIcons){this._showIcons=wijmo_1.asBoolean(e);this._g&&this._g.invalidate()}}get showSortButtons(){return this._showSort}set showSortButtons(e){this._showSort=wijmo_1.asBoolean(e)}get reApplyFilterOnUpdate(){return this._includeUpdatedRowsInFilter}set reApplyFilterOnUpdate(e){e!==this._includeUpdatedRowsInFilter&&(this._includeUpdatedRowsInFilter=wijmo_1.asBoolean(e))}getColumnFilter(e,t=!0){if(e=this._asColumn(e)){for(let t=0;t<this._filters.length;t++)if(this._filters[t].column==e)return this._filters[t];if(t&&e.binding){let t=new ColumnFilter(this,e);this._filters.push(t);return t}}return null}get defaultFilterType(){return this._defFilterType}set defaultFilterType(e){if((e=wijmo_1.asEnum(e,FilterType,!1))!=this.defaultFilterType){this._defFilterType=e;this._g.invalidate();this.clear()}}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(e){if((e=wijmo_1.asBoolean(e))!==this._xValueSearch){this._xValueSearch=e;this.onExclusiveValueSearchChanged()}}get filterDefinition(){let e={defaultFilterType:this.defaultFilterType,filters:[]};this._filters.forEach(t=>{let i=t.conditionFilter,l=t.valueFilter,s=l.uniqueValues&&l.uniqueValues.length;if(t&&t.column&&t.column.binding&&(t.isActive||s||t.filterType!=this.defaultFilterType)){let a={binding:t.column.binding};if(i.isActive){let e=i.condition1,l=i.condition2;a={binding:t.column.binding,type:"condition",condition1:{operator:e.operator,value:e.value},and:i.and,condition2:{operator:l.operator,value:l.value}}}else(l.isActive||s)&&(a={binding:t.column.binding,type:"value",uniqueValues:l.uniqueValues,sortValues:l.sortValues,maxValues:l.maxValues,exclusiveValueSearch:l.exclusiveValueSearch,showValues:l.showValues});t.filterType!=this.defaultFilterType&&(a.filterType=t.filterType);e.filters.push(a)}});return JSON.stringify(e)}set filterDefinition(e){e=wijmo_1.asString(e);this.clear();if(e){let t=JSON.parse(e);this.defaultFilterType=t.defaultFilterType;for(let e=0;e<t.filters.length;e++){let i=t.filters[e],l=this._asColumn(i.binding);l||(l=new wijmo_grid_1.Column({binding:i.binding}));let s=this.getColumnFilter(l,!0);if(s){null!=i.filterType&&(s.filterType=wijmo_1.asEnum(i.filterType,FilterType));switch(i.type){case"condition":let e=s.conditionFilter;e.condition1.value=l.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(i.condition1.value,l.dataType,null):i.condition1.value;e.condition1.operator=i.condition1.operator;e.and=i.and;e.condition2.value=l.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(i.condition2.value,l.dataType,null):i.condition2.value;e.condition2.operator=i.condition2.operator;break;case"value":let t=s.valueFilter;t.uniqueValues=i.uniqueValues;["sortValues","maxValues","exclusiveValueSearch"].forEach(e=>{null!=i[e]&&(t[e]=i[e])});t.showValues=i.showValues}}}}this.apply()}get activeEditor(){return wijmo_1.Control.getControl(this._divEdt)}editColumnFilter(e,t,i){let l=this._g;this.closeEditor();e=this._asColumn(e);let s=new wijmo_grid_1.CellRangeEventArgs(l.cells,new wijmo_grid_1.CellRange(-1,e.index));if(!this.onEditingFilter(s))return;let a=wijmo_1.createElement('<div class="wj-dropdown-panel"></div>'),r=this.getColumnFilter(e),n=new ColumnFilterEditor(a,r,this.showSortButtons);this._divEdt=a;this._edtCol=e;l.rightToLeft&&(a.dir="rtl");if(!this.onFilterChanging(s)){this._divEdt=this._edtCol=null;return}s.cancel=!0;n.filterChanged.addHandler(()=>{s.cancel=!1;setTimeout(()=>{if(!s.cancel){this.excludedRowsSet=null;this.apply()}},n._edtVal&&n._edtVal._isFiltering?wijmo_1.Control._SEARCH_DELAY+200:0)});n.buttonClicked.addHandler(()=>{this.closeEditor();l.focus();this.onFilterChanged(s)});n.lostFocus.addHandler(()=>{setTimeout(()=>{let e=wijmo_1.Control.getControl(this._divEdt);e&&!e.containsFocus()&&this.closeEditor()},10)});let o=t?t.col:e.index,d=l.columns[o];t||d&&d.binding==e.binding||(o=l.selection.leftCol);l._edtHdl._commitRowEdits();l.scrollIntoView(-1,o,!0);let h=l.columnHeaders,u=t&&t.panel&&h&&t.panel._uid==h._uid?t.row:h.rows.length-1,_=o,c=i||h.getCellElement(u,_),p=c?null:h.getCellBoundingRect(u,_);c?wijmo_1.showPopup(a,c,!1,!1,!1):wijmo_1.showPopup(a,p);this._setAriaExpanded(c,!0);this._setAriaExpanded(l.cells.getCellElement(-1,_),!0);let m=n.hostElement.querySelectorAll("input");for(let e=0;e<m.length;e++){let t=m[e];if(t.offsetHeight>0&&t.tabIndex>-1&&!t.disabled){t.focus();break}}n.containsFocus()||n.focus()}_setAriaExpanded(e,t){if(e){var i=e.querySelector("."+FlexGridFilter._WJC_FILTER);wijmo_1.setAttribute(i,"aria-expanded",t)}}closeEditor(){let e=this._g,t=wijmo_1.Control.getControl(this._divEdt),i=this._edtCol;t&&wijmo_1.hidePopup(t.hostElement,()=>{t.dispose()});if(i){let t=e.columnHeaders,l=t.rows.length?t.getCellElement(t.rows.length-1,i.index):null;this._setAriaExpanded(l,!1);l=e.cells.getCellElement(-1,i.index);this._setAriaExpanded(l,!1)}this._divEdt=null;this._edtCol=null}apply(){let e=this._g.collectionView;if(e){let t=this._g.editableCollectionView;if(t){t.commitEdit();t.commitNew()}e.filter=this._filter.bind(this)}let t=e?e.updateFilterDefinition:null;wijmo_1.isFunction(t)&&t.call(e,this);this.onFilterApplied()}clear(){if(this._filters.length){this._filters=[];this.apply()}}onFilterApplied(e){this.filterApplied.raise(this,e)}onEditingFilter(e){this.editingFilter.raise(this,e);return!e.cancel}onFilterChanging(e){this.filterChanging.raise(this,e);return!e.cancel}onFilterChanged(e){this.filterChanged.raise(this,e)}onExclusiveValueSearchChanged(e){this.exclusiveValueSearchChanged.raise(this,e)}_asColumn(e){return wijmo_1.isString(e)?this._g.getColumn(e,!0):wijmo_1.isNumber(e)?this._g.columns[e]:wijmo_1.asType(e,wijmo_grid_1.Column,!1)}_filter(e){const t=this.excludedRowsSet;if(!this.reApplyFilterOnUpdate&&t.has(e))return!0;let i=this._filters;for(let t=0;t<i.length;t++){let l=i[t];if(l.column!=FlexGridFilter._skipColumn&&!l.apply(e))return!1}return!0}_formatItem(e,t){if(t.panel==e.columnHeaders){let e=this._g,i=e.getMergedRange(t.panel,t.row,t.col)||new wijmo_grid_1.CellRange(t.row,t.col),l=e.columns[i.col],s=e._getBindingColumn(t.panel,t.row,l),a=t.cell;if(i.row2==t.panel.rows.length-1||l!=s){let i=this.getColumnFilter(s,this.defaultFilterType!=FilterType.None),r=this._filterColumns;r&&r.length&&r.indexOf(s.binding)<0&&r.indexOf(s.name)<0&&(i=null);if(i){wijmo_1.toggleClass(a,"wj-filter-on",i.isActive);wijmo_1.toggleClass(a,"wj-filter-off",!i.isActive)}else{wijmo_1.removeClass(a,"wj-filter-on");wijmo_1.removeClass(a,"wj-filter-off")}if(i&&i.filterType!=FilterType.None){this._showIcons&&this._addFilterButton(s,i,a);0==t.row&&(a=e.cells.getCellElement(-1,t.col))&&this._addFilterButton(l,i,a)}}}}_addFilterButton(e,t,i){let l=FlexGridFilter._WJC_FILTER,s=wijmo_1.createElement('<button class="wj-btn wj-btn-glyph wj-right '+l+'" type="button" tabindex="-1"><span class="wj-glyph-filter"></span></button>');wijmo_1.setAriaLabel(s,wijmo_1.culture.FlexGridFilter.ariaLabels.edit+" "+e.header);wijmo_1.setAttribute(s,"aria-haspopup","dialog");wijmo_1.setAttribute(s,"aria-expanded",!1);wijmo_1.setAttribute(s,"aria-describedby",e.describedById);wijmo_1.setAttribute(s,"aria-pressed",t.isActive);if(!i.querySelector("."+l)){1==i.children.length&&(i=i.querySelector("div")||i);i.insertBefore(s,i.firstChild)}}_mousedown(e){this._edtColPrev=this._edtCol}_click(e){if(this._toggleEditor(e)){e.stopPropagation();e.preventDefault()}}_toggleEditor(e){if(!e.defaultPrevented&&0==e.button)if(wijmo_1.closestClass(e.target,FlexGridFilter._WJC_FILTER)){let t=this._g,i=t.hitTest(e.target);i.panel||(i=t.hitTest(e));if(i.panel&&t.columnHeaders&&t.cells&&(i.panel._uid==t.columnHeaders._uid||i.panel._uid==t.cells._uid&&-1==i.row)){let e=t.getMergedRange(i.panel,i.row,i.col)||new wijmo_grid_1.CellRange(i.row,i.col),l=t.columns[e.col],s=t._getBindingColumn(i.panel,i.row,l);if(this._divEdt&&this._edtCol==s){this.closeEditor();t.focus()}else s!=this._edtColPrev&&setTimeout(()=>{this.editColumnFilter(s,i)},this._divEdt?100:0);return!0}}else this.closeEditor();return!1}_keydown(e){if(!e.defaultPrevented&&!e.ctrlKey&&e.altKey&&(e.keyCode==wijmo_1.Key.Down||e.keyCode==wijmo_1.Key.Up)){let t=this.grid,i=t.selection,l=i.col>-1?t.columns[i.col]:null,s=l?t._getBindingColumn(t.cells,i.row,l):null,a=s&&s.dataMap&&s.dataMapEditor==wijmo_grid_1.DataMapEditor.DropDownList;if(this.filterColumns&&this.filterColumns.length>0&&!this.filterColumns.includes(s._binding._path)){e.preventDefault();return!1}s&&s.editor instanceof wijmo_input_1.DropDown&&(a=!0);if(s&&!a){let t=this.getColumnFilter(s,!1);if(t&&t.filterType!=FilterType.None){this.editColumnFilter(s);e.preventDefault();e.stopPropagation()}}}}}FlexGridFilter._WJC_FILTER="wj-elem-filter";exports.FlexGridFilter=FlexGridFilter;exports.empty={};class ConditionFilter{constructor(e){this._c1=new FilterCondition(this);this._c2=new FilterCondition(this);this._and=!0;this._col=e}get condition1(){return this._c1}get condition2(){return this._c2}get and(){return this._and}set and(e){this._and=wijmo_1.asBoolean(e)}get dataMap(){return this._map}set dataMap(e){this._map=wijmo_1.asType(e,wijmo_grid_1.DataMap,!0)}get column(){return this._col}get isActive(){return this._c1.isActive||this._c2.isActive}apply(e){let t=this._col,i=this._c1,l=this._c2,s=!1,a=!1;if(!t||!t._binding||!this.isActive)return!0;e=t._binding.getValue(e);let r=this.dataMap||t.dataMap;if(r)e=r.getDisplayValue(e);else if(wijmo_1.isDate(e)){s=!this._hasTimePart();a=!this._hasDatePart();let t=FilterCondition._refDateTime;s?e=wijmo_1.DateTime.fromDateTime(e,t):a&&(e=wijmo_1.DateTime.fromDateTime(t,e))}else if(wijmo_1.isNumber(e)){let i=wijmo_1.Globalize,l=t.format,s=i.formatNumber(e,l);e=i.parseFloat(s,l)}let n=i.apply(e,s,a),o=l.apply(e,s,a);return i.isActive&&l.isActive?this._and?n&&o:n||o:i.isActive?n:!l.isActive||o}clear(){this._c1.clear();this._c2.clear();this.and=!0}_hasDatePart(){let e=this._col.format;if(!e)return!0;e=wijmo_1.culture.Globalize.calendar.patterns[e]||e;return/[yMd]+/.test(e)}_hasTimePart(){let e=this._col.format;if(!e)return!1;e=wijmo_1.culture.Globalize.calendar.patterns[e]||e;return/[Hmst]+/.test(e)}implementsInterface(e){return"IColumnFilter"==e}}exports.ConditionFilter=ConditionFilter;class ConditionFilterEditor extends wijmo_1.Control{constructor(e,t){super(e);this._canApply=!1;this.canApplyChanged=new wijmo_1.Event;this._filter=wijmo_1.asType(t,ConditionFilter,!1);let i=this.getTemplate();this.applyTemplate("wj-control wj-conditionfilter-editor",i,{_divHdr:"div-hdr",_divCmb1:"div-cmb1",_divVal1:"div-val1",_btnAnd:"btn-and",_btnOr:"btn-or",_spAnd:"sp-and",_spOr:"sp-or",_divCmb2:"div-cmb2",_divVal2:"div-val2"});let l=wijmo_1.culture.FlexGridFilter,s=l.ariaLabels;wijmo_1.setAriaLabel(this._btnAnd,s.and);wijmo_1.setAriaLabel(this._btnOr,s.or);wijmo_1.setText(this._divHdr,l.header);wijmo_1.setText(this._spAnd,l.and);wijmo_1.setText(this._spOr,l.or);const a=wijmo_1.getUniqueId("cmb1");this._divHdr.htmlFor=a;this._divCmb1.id=a;this._cmb1=this._createOperatorCombo(this._divCmb1,s.op1);this._cmb2=this._createOperatorCombo(this._divCmb2,s.op2);this._val1=this._createValueInput(this._divVal1,s.val1);this._val2=this._createValueInput(this._divVal2,s.val2);this._val1.isDisabled=!0;this._cmb1.selectedIndexChanged.addHandler((e,t)=>{this._val1.isDisabled=null==e.selectedValue;this.canApply=!this._val1.isDisabled||!this._val2.isDisabled});this._val2.isDisabled=!0;this._cmb2.selectedIndexChanged.addHandler((e,t)=>{this._val2.isDisabled=null==e.selectedValue;this.canApply=!this._val1.isDisabled||!this._val2.isDisabled});let r=this.hostElement;this.addEventListener(r,"change",this._btnAndOrChanged.bind(this));this.addEventListener(r,"keydown",this._keydown.bind(this));setTimeout(()=>{this.updateEditor()})}get filter(){return this._filter}get canApply(){return this._canApply}set canApply(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}}updateEditor(){let e=this._filter.condition1,t=this._filter.condition2;this._cmb1.selectedValue=e.operator;this._cmb2.selectedValue=t.operator;if(this._val1 instanceof input.ComboBox&&!(this._val1 instanceof input.InputTime)){this._val1.text=wijmo_1.changeType(e.value,wijmo_1.DataType.String);this._val2.text=wijmo_1.changeType(t.value,wijmo_1.DataType.String)}else{this._val1.value=e.value;this._val2.value=t.value}let i=this._filter.and;this._checkRadio(this._btnAnd,i);this._checkRadio(this._btnOr,!i)}clearEditor(){this._cmb1.selectedValue=this._cmb2.selectedValue=null;this._val1.text=this._val2.text=null;this._checkRadio(this._btnAnd,!0);this._checkRadio(this._btnOr,!1)}get isEditorClear(){return null==this._cmb1.selectedValue&&!this._val1.text&&null==this._cmb2.selectedValue&&!this._val2.text}updateFilter(){let e=this._filter.condition1,t=this._filter.condition2;e.operator=this._cmb1.selectedValue;t.operator=this._cmb2.selectedValue;if("value"in this._val1){e.value=this._val1.value;t.value=this._val2.value}else{e.value=this._getComboValue(this._val1);t.value=this._getComboValue(this._val2)}this._filter.and=this._btnAnd.checked}onCanApplyChanged(e){this.canApplyChanged.raise(this,e)}_getComboValue(e){return e.selectedIndex>-1?e.selectedValue:e.text}_createOperatorCombo(e,t){let i=this._filter.column,l=wijmo_1.culture.FlexGridFilter,s=l.stringOperators,a=wijmo_1.DataType;this._filter.dataMap||i.dataMap||(i.dataType==a.Date?s=l.dateOperators:i.dataType==a.Number?s=l.numberOperators:i.dataType==a.Boolean&&(s=l.booleanOperators));let r=new input.ComboBox(e,{itemsSource:s,displayMemberPath:"name",selectedValuePath:"op"});wijmo_1.setAriaLabel(r.inputElement,t);return r}_createValueInput(e,t){let i=this._filter,l=i.column,s=i.dataMap||l.dataMap,a=null,r=wijmo_1.DataType;if(l.dataType==r.Date)(a=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(e):new input.InputDate(e):new input.InputTime(e)).format=l.format;else if(l.dataType!=r.Number||s){(a=new input.ComboBox(e)).isEditable=!0;if(s){a.itemsSource=s.getDisplayValues();a.caseSensitiveSearch=!!l.grid&&l.grid.caseSensitiveSearch}else l.dataType==r.Boolean&&(a.itemsSource=[!0,!1])}else(a=new input.InputNumber(e)).format=l.format;a.isRequired=!1;wijmo_1.setAriaLabel(a.inputElement,t);return a}_btnAndOrChanged(e){let t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i){this._checkRadio(this._btnAnd,t);this._checkRadio(this._btnOr,i)}}_checkRadio(e,t){e.checked=t;wijmo_1.setAttribute(e,"aria-checked",t.toString());wijmo_1.setAttribute(e,"tabindex",t?null:"-1")}_keydown(e){let t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i)switch(e.keyCode){case wijmo_1.Key.Left:case wijmo_1.Key.Right:case wijmo_1.Key.Up:case wijmo_1.Key.Down:let i=t?this._btnOr:this._btnAnd;i.click();i.focus();e.preventDefault()}}}ConditionFilterEditor.controlTemplate='<div><label wj-part="div-hdr"></label><div wj-part="div-cmb1"></div><br/><div wj-part="div-val1"></div><br/><div role="radiogroup" style="text-align:center"><label><input wj-part="btn-and" type="radio" role="radio"> <span wj-part="sp-and"></span> </label>&nbsp;&nbsp;&nbsp;<label><input wj-part="btn-or" type="radio" role="radio"> <span wj-part="sp-or"></span> </label></div><div wj-part="div-cmb2"></div><br/><div wj-part="div-val2"></div><br/></div>';exports.ConditionFilterEditor=ConditionFilterEditor;class FilterCondition{constructor(e){this._op=null;this._filter=e}get operator(){return this._op}set operator(e){this._op=wijmo_1.asEnum(e,Operator,!0)}get value(){return this._val}set value(e){this._val=e;this._strVal=wijmo_1.isString(e)?this._getCaseString(e):null}get isActive(){switch(this._op){case null:return!1;case Operator.EQ:case Operator.NE:return!0;default:return null!=this._val||null!=this._strVal}}clear(){this.operator=null;this.value=null}apply(e,t,i){let l=this._strVal||this._val;wijmo_1.isString(e)&&(e=this._getCaseString(e));wijmo_1.isString(l)&&null==e&&(e="");wijmo_1.isDate(l)&&(t?l=wijmo_1.DateTime.fromDateTime(l,FilterCondition._refDateTime):i&&(l=wijmo_1.DateTime.fromDateTime(FilterCondition._refDateTime,l)));let s=Operator;switch(this._op){case null:return!0;case s.EQ:return null!=e&&null!=l?e.valueOf()==l.valueOf():e==l;case s.NE:return null!=e&&null!=l?e.valueOf()!=l.valueOf():e!=l;case s.GT:return e>l;case s.GE:return e>=l;case s.LT:return e<l;case s.LE:return e<=l;case s.BW:return!(null==this._strVal||!wijmo_1.isString(e))&&0==e.indexOf(this._strVal);case s.EW:return!!(null!=this._strVal&&wijmo_1.isString(e)&&e.length>=this._strVal.length)&&e.substr(e.length-this._strVal.length)==l;case s.CT:return!(null==this._strVal||!wijmo_1.isString(e))&&e.indexOf(this._strVal)>-1;case s.NC:return!(null==this._strVal||!wijmo_1.isString(e))&&e.indexOf(this._strVal)<0}throw"Unknown operator"}_getCaseString(e){let t=this._filter.column,i=t?t.grid:null;return i&&i.caseSensitiveSearch?e:e.toLowerCase()}}FilterCondition._refDateTime=new Date(2e3,0,1,0,0,0);exports.FilterCondition=FilterCondition;!function(e){e[e.EQ=0]="EQ";e[e.NE=1]="NE";e[e.GT=2]="GT";e[e.GE=3]="GE";e[e.LT=4]="LT";e[e.LE=5]="LE";e[e.BW=6]="BW";e[e.EW=7]="EW";e[e.CT=8]="CT";e[e.NC=9]="NC"}(Operator=exports.Operator||(exports.Operator={}));!function(e){e[e.Text=0]="Text";e[e.Regex=1]="Regex";e[e.Excel=2]="Excel"}(ValueFilterSearchKind=exports.ValueFilterSearchKind||(exports.ValueFilterSearchKind={}));class ValueFilter{constructor(e){this._values=null;this._filterText=null;this._xValueSearch=!0;this._maxValues=250;this._uniqueValues=null;this._sortValues=!0;this._searchType=ValueFilterSearchKind.Excel;this._col=e}get searchType(){return this._searchType}set searchType(e){this._searchType=wijmo_1.asEnum(e,ValueFilterSearchKind)}get showValues(){return this._values}set showValues(e){this._values=e}get filterText(){return this._filterText}set filterText(e){this._filterText=wijmo_1.asString(e)}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(e){if((e=wijmo_1.asBoolean(e))!==this._xValueSearch){this._xValueSearch=wijmo_1.asBoolean(e);e&&(this._filterText="")}}get maxValues(){return this._maxValues}set maxValues(e){this._maxValues=wijmo_1.asNumber(e,!1,!0)}get uniqueValues(){return this._uniqueValues}set uniqueValues(e){this._uniqueValues=wijmo_1.asArray(e)}get sortValues(){return this._sortValues}set sortValues(e){this._sortValues=wijmo_1.asBoolean(e)}get dataMap(){return this._map}set dataMap(e){this._map=wijmo_1.asType(e,wijmo_grid_1.DataMap,!0)}get column(){return this._col}get isActive(){return null!=this._values&&Object.keys(this._values).length>0}apply(e){let t=this.column;if(!(t&&t._binding&&this._values&&Object.keys(this._values).length))return!0;e=t._binding.getValue(e);e=this.dataMap?this.dataMap.getDisplayValue(e)||"":t.dataMap?t.dataMap.getDisplayValue(e)||"":wijmo_1.Globalize.format(e,t.format);return null!=this._values[e]}clear(){this.showValues=null;this.filterText=null}getUniqueValues(e=!0){let t=[],i=this.column,l=wijmo_1.Globalize.format;if(this.uniqueValues){this.uniqueValues.forEach(e=>{t.push({value:e,text:l(e,i.format)})});return t}let s={},a=i.collectionView,r=a?a.sourceCollection:[];if(e&&a&&a.sourceCollection&&a.filter)try{FlexGridFilter._skipColumn=this._col;let e=[];for(let t=0;t<r.length;t++)a.filter(r[t])&&e.push(r[t]);r=e}finally{FlexGridFilter._skipColumn=null}for(let e=0;e<r.length;e++){let a=i._binding.getValue(r[e]),n=this.dataMap?this.dataMap.getDisplayValue(a)||"":i.dataMap?i.dataMap.getDisplayValue(a)||"":l(a,i.format);if(!s[n]){s[n]=!0;t.push({value:a,text:n})}}return t}implementsInterface(e){return"IColumnFilter"==e}}exports.ValueFilter=ValueFilter;class ValueFilterEditor extends wijmo_1.Control{constructor(e,t){super(e);this._canApply=!1;this._isFiltering=!1;this.canApplyChanged=new wijmo_1.Event;this._filter=wijmo_1.asType(t,ValueFilter,!1);let i=this.getTemplate();this.applyTemplate("wj-control wj-valuefilter-editor",i,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values"});this._cbSelectAll.tabIndex=0;let l=wijmo_1.culture.FlexGridFilter;wijmo_1.setText(this._spSelectAll,l.selectAll);let s=this._view=new wijmo_1.CollectionView(null,{sortNulls:wijmo_1.SortNulls.First,filter:this._filterValues.bind(this)});if(t.sortValues){let e=t.column.dataMap||t.dataMap?"text":"value",i=t.column.dataType!=wijmo_1.DataType.Boolean;s.sortDescriptions.push(new wijmo_1.SortDescription(e,i))}s.collectionChanged.addHandler(this._updateSelectAllCheck,this);this._filterText="";this._rxFilter=null;this._cmbFilter=new input.ComboBox(this._divFilter,{isRequired:!1,placeholder:l.search});this._cmbFilter.isEditable=!0;this._lbValues=new input.ListBox(this._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:this._view,itemFormatter:(e,t)=>t||l.null,checkedItemsChanged:e=>this._updateSelectAllCheck()});wijmo_1.setAriaLabel(this._cmbFilter.inputElement,l.ariaLabels.search);wijmo_1.setAttribute(this._lbValues.hostElement,"aria-multiselectable",!0);this._cmbFilter.inputElement.addEventListener("input",this._filterTextChanged.bind(this));this._cbSelectAll.addEventListener("click",this._cbSelectAllClicked.bind(this));this.updateEditor();this._initialItems=this._lbValues.checkedItems}get filter(){return this._filter}get canApply(){return this._canApply}set canApply(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}}updateEditor(){let e=this._filter.column,t=this._filter.getUniqueValues(!0);this._lbValues.isContentHtml=e.isContentHtml;let i=this._filter.showValues;if(i&&0!=Object.keys(i).length){for(let e in i)for(let i=0;i<t.length;i++)if(t[i].text==e){t[i].show=!0;break}}else t.forEach(e=>e.show=!0);let l=this._filter.filterText||"",s=this._getCaseSensitive();this._cmbFilter.text=l;this._filterText=s?l:l.toLowerCase();this._rxFilter=this._getSearchExp(l,s);let a=this._view;a.pageSize=this._filter.maxValues;a.sourceCollection=t;setTimeout(()=>{this._adjustWidths()},0)}clearEditor(e=!0){this._cmbFilter.text="";this._filterText="";this._rxFilter=null;let t=this._view;t.pageSize=0;t.items.forEach(t=>{t.show=e});t.moveCurrentTo(-1);t.refresh();t.pageSize=this._filter.maxValues}get isEditorClear(){return!this._filterText&&!this._cbSelectAll.indeterminate}_updateFilter(){let e=null,t=this._getItems();if(this._filterText||this._cbSelectAll.indeterminate){e={};for(let i=0;i<t.length;i++){let l=t[i];l.show&&(e[l.text]=!0)}}let i=this._filter;i.showValues=e;i.filterText=this._filterText}updateFilter(){this._isFiltering?setTimeout(()=>{this._updateFilter()},wijmo_1.Control._SEARCH_DELAY+100):this._updateFilter()}onCanApplyChanged(e){this.canApplyChanged.raise(this,e)}_getCaseSensitive(){let e=this._filter.column,t=e?e.grid:null;return t&&t.caseSensitiveSearch}_getItems(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection}_filterTextChanged(){""===this._filterText&&this._cbSelectAll.checked||this._filter.exclusiveValueSearch?this._lbValues._addMode=!1:this._lbValues._addMode=!0;this._toFilter&&clearTimeout(this._toFilter);this._isFiltering=!0;this._toFilter=setTimeout(()=>{let e=this._cmbFilter.text,t=this._getCaseSensitive();t||(e=e.toLowerCase());if(e!=this._filterText){this._filterText=e;this._rxFilter=this._getSearchExp(e,t);this._view.refresh();if(!e){let e=this._initialItems;if(e.length&&this._view.sourceCollection.indexOf(e[0])>-1){this._lbValues.checkedItems=this._initialItems;this._updateSelectAllCheck();this._isFiltering=!1;return}}if(this._filter.exclusiveValueSearch){this._cbSelectAll.checked=!0;this._cbSelectAllClicked()}else this._updateSelectAllCheck()}this._isFiltering=!1},wijmo_1.Control._SEARCH_DELAY)}_getSearchExp(e,t){if(!e)return null;switch(this._filter.searchType){case ValueFilterSearchKind.Text:return this._getTextSearchExp(e,t);case ValueFilterSearchKind.Regex:return this._getRegexSearchExp(e,t);case ValueFilterSearchKind.Excel:return this._getExcelSearchExp(e,t)}}_getTextSearchExp(e,t){return new RegExp(wijmo_1.escapeRegExp(e),t?"":"i")}_getRegexSearchExp(e,t){try{return new RegExp(e,t?"s":"is")}catch(e){return new RegExp("(?!)",t?"s":"is")}}_getExcelSearchExp(e,t){let i=e;i=(i=(i=(i=(i=i.replace(/([.+^$[\]\\(){}|-])/g,"\\$1")).replace(/(?<!~)(\?+)/g,(function(e,t){return Array.from(t).map(e=>".").join("")}))).replace(/(?<!~)(\*+)/g,(function(e,t){return Array.from(t).map(e=>".*").join("")}))).replace(/~~/g,"~")).replace(/~([?*])/g,"\\$1");/(?<!~)[?*]/g.test(e)&&(i="^"+i+"$");return new RegExp(i,t?"s":"is")}_filterValues(e){let t=this._rxFilter;return null==t||null==e||t.test(e.text)}_cbSelectAllClicked(){let e=this._cbSelectAll.checked,t=this._divValues.scrollTop,i=this._getItems();for(let t=0;t<i.length;t++)i[t].show=e;this._view.refresh();this._divValues.scrollTop=t;setTimeout(()=>{this._adjustWidths()},0)}_updateSelectAllCheck(){let e=this._getItems(),t=0,i=0;for(let l=0;l<e.length;l++){e[l].show?t++:i++;if(t&&i)break}wijmo_1.setChecked(this._cbSelectAll,t&&i?null:t>0);this.canApply=t>0}_adjustWidths(){let e=this._lbValues.hostElement;if(e&&e.offsetHeight>0){let t=0,i=e.querySelectorAll(".wj-listbox-item label");if(i.length){for(let e=0;e<i.length;e++)t=Math.max(t,i[e].scrollWidth);if(t){let i=e.querySelectorAll(".wj-listbox-item");if(i.length){let e=i[0],l=getComputedStyle(e),s=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight);for(let e=0;e<i.length;e++)i[e].style.width=t+s+"px"}}}}}}ValueFilterEditor.controlTemplate='<div><div wj-part="div-filter"></div><div class="wj-listbox-item"><label><input wj-part="cb-select-all" type="checkbox"> <span wj-part="sp-select-all"></span></label></div><div wj-part="div-values"></div></div>';exports.ValueFilterEditor=ValueFilterEditor;class ColumnFilter{constructor(e,t){this._owner=e;this._col=t;this._valueFilter=new ValueFilter(t);this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch;this._conditionFilter=new ConditionFilter(t);e.exclusiveValueSearchChanged.addHandler(e=>{this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch})}get filterType(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType}set filterType(e){if((e=wijmo_1.asEnum(e,FilterType,!0))!=this._filterType){let t=this.isActive;this.clear();this._filterType=e;t?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}}get dataMap(){return this.conditionFilter.dataMap||this.valueFilter.dataMap}set dataMap(e){this.conditionFilter.dataMap=e;this.valueFilter.dataMap=e}get valueFilter(){return this._valueFilter}get conditionFilter(){return this._conditionFilter}get column(){return this._col}get isActive(){return this._conditionFilter.isActive||this._valueFilter.isActive}apply(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)}clear(){this._valueFilter.clear();this._conditionFilter.clear()}implementsInterface(e){return"IColumnFilter"==e}}exports.ColumnFilter=ColumnFilter;wijmo_1._addCultureInfo("FlexGridFilter",{ariaLabels:{edit:"Edit Filter for Column",dialog:"Filter Editor for Column",asc:"Sort Column in Ascending Order",dsc:"Sort Column in Descending Order",search:"Search Item List",op1:"First Condition Operator",val1:"First Condition Value",and:"Require both Conditions",or:"Require either Condition",op2:"Second Condition Operator",val2:"Second Condition Value"},ascending:"↑ Ascending",descending:"↓ Descending",apply:"Apply",cancel:"Cancel",clear:"Clear",conditions:"Filter by Condition",values:"Filter by Value",search:"Search",selectAll:"Select All",null:"(nothing)",header:"Show items where the value",and:"And",or:"Or",stringOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Begins with",op:Operator.BW},{name:"Ends with",op:Operator.EW},{name:"Contains",op:Operator.CT},{name:"Does not contain",op:Operator.NC}],numberOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Is Greater than",op:Operator.GT},{name:"Is Greater than or equal to",op:Operator.GE},{name:"Is Less than",op:Operator.LT},{name:"Is Less than or equal to",op:Operator.LE}],dateOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Is Before",op:Operator.LT},{name:"Is After",op:Operator.GT}],booleanOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE}]});class ColumnFilterEditor extends wijmo_1.Control{constructor(e,t,i=!0){super(e,null,!0);this.filterChanged=new wijmo_1.Event;this.buttonClicked=new wijmo_1.Event;this._filter=wijmo_1.asType(t,ColumnFilter);let l=this.getTemplate();this.applyTemplate("wj-control wj-content wj-columnfiltereditor",l,{_divSort:"div-sort",_btnAsc:"btn-asc",_btnDsc:"btn-dsc",_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnApply:"btn-apply",_btnCancel:"btn-cancel",_btnClear:"btn-clear"});let s=wijmo_1.culture.FlexGridFilter,a=s.ariaLabels,r=this.hostElement,n=this.filter.column,o=n.grid.collectionView;wijmo_1.setAttribute(r,"role","dialog");wijmo_1.setAriaLabel(r,a.dialog+" "+n.header);wijmo_1.setAriaLabel(this._btnAsc,a.asc);wijmo_1.setAriaLabel(this._btnDsc,a.dsc);wijmo_1.setText(this._btnAsc,s.ascending);wijmo_1.setText(this._btnDsc,s.descending);wijmo_1.setText(this._aVal,s.values);wijmo_1.setText(this._aCnd,s.conditions);wijmo_1.setText(this._btnApply,s.apply);wijmo_1.setText(this._btnCancel,s.cancel);wijmo_1.setText(this._btnClear,s.clear);let d=this.filter.conditionFilter.isActive||0==(t.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;this._showFilter(d);i&&o&&o.canSort||(this._divSort.style.display="none");this._updateSortButtonState();let h=this._btnClicked.bind(this);this._btnApply.addEventListener("click",h);this._btnCancel.addEventListener("click",h);this._btnClear.addEventListener("click",h);this._btnAsc.addEventListener("click",h);this._btnDsc.addEventListener("click",h);this._aVal.addEventListener("click",h);this._aCnd.addEventListener("click",h);this.addEventListener(r,"keydown",e=>{if(!e.defaultPrevented){let t=e.target.tagName.match(/^(a|button)$/i);switch(e.keyCode){case wijmo_1.Key.Space:if(t){this._btnClicked(e);e.preventDefault()}break;case wijmo_1.Key.Enter:if(t)this._btnClicked(e);else{this.updateFilter();this.onFilterChanged();this.onButtonClicked()}e.preventDefault();break;case wijmo_1.Key.Escape:this.onButtonClicked();e.preventDefault();break;case wijmo_1.Key.Tab:wijmo_1.moveFocus(this.hostElement,e.shiftKey?-1:1);e.preventDefault()}}});this.addEventListener(window,"resize",()=>{this.isTouching||this._wasTouching||this.onButtonClicked()})}get filter(){return this._filter}updateEditor(){this._edtVal&&this._edtVal.updateEditor();this._edtCnd&&this._edtCnd.updateEditor()}updateFilter(){switch(this._getFilterType()){case FilterType.Value:this._edtVal.updateFilter();this.filter.conditionFilter.clear();break;case FilterType.Condition:this._edtCnd.updateFilter();this.filter.valueFilter.clear()}}onFilterChanged(e){this.filterChanged.raise(this,e)}onButtonClicked(e){this.buttonClicked.raise(this,e)}_showFilter(e){this._wasTouching=this.isTouching;if(e==FilterType.Value&&null==this._edtVal){this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter);this._edtVal.canApplyChanged.addHandler(e=>{wijmo_1.enable(this._btnApply,this._edtVal.canApply)})}if(e==FilterType.Condition&&null==this._edtCnd){this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter);this._edtCnd.canApplyChanged.addHandler(e=>{wijmo_1.enable(this._btnApply,this._edtCnd.canApply)})}if(0!=(e&this.filter.filterType))if(e==FilterType.Value){this._divEdtVal.style.display="";this._divEdtCnd.style.display="none";this._enableLink(this._aVal,!1);this._enableLink(this._aCnd,!0);this._edtVal.focus();wijmo_1.enable(this._btnApply,this._edtVal.canApply)}else{this._divEdtVal.style.display="none";this._divEdtCnd.style.display="";this._enableLink(this._aVal,!0);this._enableLink(this._aCnd,!1);this._edtCnd.focus();wijmo_1.enable(this._btnApply,this._edtCnd.canApply)}let t=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:t.display="none";break;default:t.display=""}}_enableLink(e,t){wijmo_1.toggleClass(e,"wj-state-disabled",!t);wijmo_1.setAttribute(e,"href",t?"":null);wijmo_1.setAttribute(e,"disabled",t?null:"disabled")}_updateSortButtonState(){let e=this.filter.column,t=e?e.currentSort:"",i="wj-state-active";wijmo_1.toggleClass(this._btnAsc,i,"+"==t);wijmo_1.toggleClass(this._btnDsc,i,"-"==t)}_getFilterType(){let e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition}_btnClicked(e){let t=e.target;e.preventDefault();e.stopPropagation();if(!wijmo_1.hasClass(t,"wj-state-disabled"))if(t!=this._aVal)if(t!=this._aCnd){if(t==this._btnAsc||t==this._btnDsc){let t=this.filter.column,i=t.sortMemberPath||t.binding,l=t.grid.collectionView.sortDescriptions;l.deferUpdate(()=>{l.clear();l.push(new wijmo_1.SortDescription(i,e.target==this._btnAsc))});this._updateSortButtonState()}if(t==this._btnApply){this.updateFilter();this.onFilterChanged()}else if(t==this._btnClear){if(this.filter.isActive){this.filter.clear();this.onFilterChanged()}}else this.updateEditor();this.onButtonClicked()}else{this._showFilter(FilterType.Condition);wijmo_1.moveFocus(this._edtCnd.hostElement,0)}else{this._showFilter(FilterType.Value);wijmo_1.moveFocus(this._edtVal.hostElement,0)}}}ColumnFilterEditor.controlTemplate='<div><div wj-part="div-sort" class="wj-sort-buttons"><button wj-part="btn-asc" class="wj-btn"></button>&nbsp;&nbsp;&nbsp;<button wj-part="btn-dsc" class="wj-btn"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a>&nbsp;|&nbsp;<a wj-part="a-val" href="" draggable="false"></a></div><div wj-part="div-edt-val" tabindex="-1"></div><div wj-part="div-edt-cnd" tabindex="-1"></div><div style="text-align:right;margin-top:10px"><button wj-part="btn-apply" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-cancel" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-clear" class="wj-btn"></button></div></div>';exports.ColumnFilterEditor=ColumnFilterEditor;wijmo_1._registerModule("wijmo.grid.filter",selfModule);
"use strict";var __importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_grid_1=require("@grapecity/wijmo.grid"),wijmo_1=require("@grapecity/wijmo"),wijmo_input_1=require("@grapecity/wijmo.input"),input=__importStar(require("@grapecity/wijmo.input")),selfModule=__importStar(require("@grapecity/wijmo.grid.filter"));var FilterType,Operator,ValueFilterSearchKind;!function(e){e[e.None=0]="None";e[e.Condition=1]="Condition";e[e.Value=2]="Value";e[e.Both=3]="Both"}(FilterType=exports.FilterType||(exports.FilterType={}));class FlexGridFilter{constructor(e,t){this._showIcons=!0;this._showSort=!0;this._defFilterType=FilterType.Both;this._xValueSearch=!0;this._includeUpdatedRowsInFilter=!1;this.filterApplied=new wijmo_1.Event;this.editingFilter=new wijmo_1.Event;this.filterChanging=new wijmo_1.Event;this.filterChanged=new wijmo_1.Event;this.exclusiveValueSearchChanged=new wijmo_1.Event;this._filters=[];this._g=wijmo_1.asType(e,wijmo_grid_1.FlexGrid,!1);this._g.formatItem.addHandler(this._formatItem.bind(this));this._g.itemsSourceChanged.addHandler(this.clear.bind(this));let i=this._g.hostElement;e.addEventListener(i,"mousedown",this._mousedown.bind(this),!0);e.addEventListener(i,"click",this._click.bind(this),!0);e.addEventListener(i,"keydown",this._keydown.bind(this),!0);this._g.invalidate();wijmo_1.copy(this,t);this._init()}_init(){const e=this.grid,_excludeRowFromFilter=e=>{let t=this.grid;const i=this.excludedRowsSet;t.itemsSource?t.rows[e]instanceof wijmo_grid_1._NewRowTemplate?i.add(t.editableCollectionView.currentAddItem||t.rows[e].dataItem):i.add(t.rows[e].dataItem):i.add(t.rows[e])};e.rowChanged&&e.rowChanged.addHandler((e,t)=>{t.added&&_excludeRowFromFilter(t.index)});e.rowEditEnding.addHandler((e,t)=>{_excludeRowFromFilter(t.row)});e.cellEditEnded.addHandler((e,t)=>{_excludeRowFromFilter(t.row)})}get excludedRowsSet(){let e=this.grid;e.selectedSheet&&(e=e.selectedSheet);e._newAddedRowsSet||(e._newAddedRowsSet=new WeakSet);return e._newAddedRowsSet}set excludedRowsSet(e){let t=this.grid;t.selectedSheet&&(t=t.selectedSheet);t._newAddedRowsSet=e}get grid(){return this._g}get filterColumns(){return this._filterColumns}set filterColumns(e){this._filterColumns=wijmo_1.asArray(e);this.clear()}get showFilterIcons(){return this._showIcons}set showFilterIcons(e){if(e!=this.showFilterIcons){this._showIcons=wijmo_1.asBoolean(e);this._g&&this._g.invalidate()}}get showSortButtons(){return this._showSort}set showSortButtons(e){this._showSort=wijmo_1.asBoolean(e)}get reApplyFilterOnUpdate(){return this._includeUpdatedRowsInFilter}set reApplyFilterOnUpdate(e){e!==this._includeUpdatedRowsInFilter&&(this._includeUpdatedRowsInFilter=wijmo_1.asBoolean(e))}getColumnFilter(e,t=!0){if(e=this._asColumn(e)){for(let t=0;t<this._filters.length;t++)if(this._filters[t].column==e)return this._filters[t];if(t&&e.binding){let t=new ColumnFilter(this,e);this._filters.push(t);return t}}return null}get defaultFilterType(){return this._defFilterType}set defaultFilterType(e){if((e=wijmo_1.asEnum(e,FilterType,!1))!=this.defaultFilterType){this._defFilterType=e;this._g.invalidate();this.clear()}}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(e){if((e=wijmo_1.asBoolean(e))!==this._xValueSearch){this._xValueSearch=e;this.onExclusiveValueSearchChanged()}}get filterDefinition(){let e={defaultFilterType:this.defaultFilterType,filters:[]};this._filters.forEach(t=>{let i=t.conditionFilter,l=t.valueFilter,s=l.uniqueValues&&l.uniqueValues.length;if(t&&t.column&&t.column.binding&&(t.isActive||s||t.filterType!=this.defaultFilterType)){let a={binding:t.column.binding};if(i.isActive){let e=i.condition1,l=i.condition2;a={binding:t.column.binding,type:"condition",condition1:{operator:e.operator,value:e.value},and:i.and,condition2:{operator:l.operator,value:l.value}}}else(l.isActive||s)&&(a={binding:t.column.binding,type:"value",uniqueValues:l.uniqueValues,sortValues:l.sortValues,maxValues:l.maxValues,exclusiveValueSearch:l.exclusiveValueSearch,showValues:l.showValues});t.filterType!=this.defaultFilterType&&(a.filterType=t.filterType);e.filters.push(a)}});return JSON.stringify(e)}set filterDefinition(e){e=wijmo_1.asString(e);this.clear();if(e){let t=JSON.parse(e);this.defaultFilterType=t.defaultFilterType;for(let e=0;e<t.filters.length;e++){let i=t.filters[e],l=this._asColumn(i.binding);l||(l=new wijmo_grid_1.Column({binding:i.binding}));let s=this.getColumnFilter(l,!0);if(s){null!=i.filterType&&(s.filterType=wijmo_1.asEnum(i.filterType,FilterType));switch(i.type){case"condition":let e=s.conditionFilter;e.condition1.value=l.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(i.condition1.value,l.dataType,null):i.condition1.value;e.condition1.operator=i.condition1.operator;e.and=i.and;e.condition2.value=l.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(i.condition2.value,l.dataType,null):i.condition2.value;e.condition2.operator=i.condition2.operator;break;case"value":let t=s.valueFilter;t.uniqueValues=i.uniqueValues;["sortValues","maxValues","exclusiveValueSearch"].forEach(e=>{null!=i[e]&&(t[e]=i[e])});t.showValues=i.showValues}}}}this.apply()}get activeEditor(){return wijmo_1.Control.getControl(this._divEdt)}editColumnFilter(e,t,i){let l=this._g;this.closeEditor();e=this._asColumn(e);let s=new wijmo_grid_1.CellRangeEventArgs(l.cells,new wijmo_grid_1.CellRange(-1,e.index));if(!this.onEditingFilter(s))return;let a=wijmo_1.createElement('<div class="wj-dropdown-panel"></div>'),r=this.getColumnFilter(e),n=new ColumnFilterEditor(a,r,this.showSortButtons);this._divEdt=a;this._edtCol=e;l.rightToLeft&&(a.dir="rtl");if(!this.onFilterChanging(s)){this._divEdt=this._edtCol=null;return}s.cancel=!0;n.filterChanged.addHandler(()=>{s.cancel=!1;setTimeout(()=>{if(!s.cancel){this.excludedRowsSet=null;this.apply()}},n._edtVal&&n._edtVal._isFiltering?wijmo_1.Control._SEARCH_DELAY+200:0)});n.buttonClicked.addHandler(()=>{this.closeEditor();l.focus();this.onFilterChanged(s)});n.lostFocus.addHandler(()=>{setTimeout(()=>{let e=wijmo_1.Control.getControl(this._divEdt);e&&!e.containsFocus()&&this.closeEditor()},10)});let o=t?t.col:e.index,d=l.columns[o];t||d&&d.binding==e.binding||(o=l.selection.leftCol);l._edtHdl._commitRowEdits();l.scrollIntoView(-1,o,!0);let h=l.columnHeaders,u=t&&t.panel&&h&&t.panel._uid==h._uid?t.row:h.rows.length-1,c=o,_=i||h.getCellElement(u,c),p=_?null:h.getCellBoundingRect(u,c);_?wijmo_1.showPopup(a,_,!1,!1,!1):wijmo_1.showPopup(a,p);this._setAriaExpanded(_,!0);this._setAriaExpanded(l.cells.getCellElement(-1,c),!0);let m=n.hostElement.querySelectorAll("input");for(let e=0;e<m.length;e++){let t=m[e];if(t.offsetHeight>0&&t.tabIndex>-1&&!t.disabled){t.focus();break}}n.containsFocus()||n.focus()}_setAriaExpanded(e,t){if(e){var i=e.querySelector("."+FlexGridFilter._WJC_FILTER);wijmo_1.setAttribute(i,"aria-expanded",t)}}closeEditor(){let e=this._g,t=wijmo_1.Control.getControl(this._divEdt),i=this._edtCol;t&&wijmo_1.hidePopup(t.hostElement,()=>{t.dispose()});if(i){let t=e.columnHeaders,l=t.rows.length?t.getCellElement(t.rows.length-1,i.index):null;this._setAriaExpanded(l,!1);l=e.cells.getCellElement(-1,i.index);this._setAriaExpanded(l,!1)}this._divEdt=null;this._edtCol=null}apply(){let e=this._g.collectionView;if(e){let t=this._g.editableCollectionView;if(t){t.commitEdit();t.commitNew()}e.filter=this._filter.bind(this)}let t=e?e.updateFilterDefinition:null;wijmo_1.isFunction(t)&&t.call(e,this);this.onFilterApplied()}clear(){if(this._filters.length){this._filters=[];this.apply()}}onFilterApplied(e){this.filterApplied.raise(this,e)}onEditingFilter(e){this.editingFilter.raise(this,e);return!e.cancel}onFilterChanging(e){this.filterChanging.raise(this,e);return!e.cancel}onFilterChanged(e){this.filterChanged.raise(this,e)}onExclusiveValueSearchChanged(e){this.exclusiveValueSearchChanged.raise(this,e)}_asColumn(e){return wijmo_1.isString(e)?this._g.getColumn(e,!0):wijmo_1.isNumber(e)?this._g.columns[e]:wijmo_1.asType(e,wijmo_grid_1.Column,!1)}_filter(e){const t=this.excludedRowsSet;if(!this.reApplyFilterOnUpdate&&t.has(e))return!0;let i=this._filters;for(let t=0;t<i.length;t++){let l=i[t];if(l.column!=FlexGridFilter._skipColumn&&!l.apply(e))return!1}return!0}_formatItem(e,t){if(t.panel==e.columnHeaders){let e=this._g,i=e.getMergedRange(t.panel,t.row,t.col)||new wijmo_grid_1.CellRange(t.row,t.col),l=e.columns[i.col],s=e._getBindingColumn(t.panel,t.row,l),a=t.cell;if(i.row2==t.panel.rows.length-1||l!=s){let i=this.getColumnFilter(s,this.defaultFilterType!=FilterType.None),r=this._filterColumns;r&&r.length&&r.indexOf(s.binding)<0&&r.indexOf(s.name)<0&&(i=null);if(i){wijmo_1.toggleClass(a,"wj-filter-on",i.isActive);wijmo_1.toggleClass(a,"wj-filter-off",!i.isActive)}else{wijmo_1.removeClass(a,"wj-filter-on");wijmo_1.removeClass(a,"wj-filter-off")}if(i&&i.filterType!=FilterType.None){this._showIcons&&this._addFilterButton(s,i,a);0==t.row&&(a=e.cells.getCellElement(-1,t.col))&&this._addFilterButton(l,i,a)}}}}_addFilterButton(e,t,i){let l=FlexGridFilter._WJC_FILTER,s=wijmo_1.createElement('<button class="wj-btn wj-btn-glyph wj-right '+l+'" type="button" tabindex="-1"><span class="wj-glyph-filter"></span></button>');wijmo_1.setAriaLabel(s,wijmo_1.culture.FlexGridFilter.ariaLabels.edit+" "+e.header);wijmo_1.setAttribute(s,"aria-haspopup","dialog");wijmo_1.setAttribute(s,"aria-expanded",!1);wijmo_1.setAttribute(s,"aria-describedby",e.describedById);wijmo_1.setAttribute(s,"aria-pressed",t.isActive);if(!i.querySelector("."+l)){1==i.children.length&&(i=i.querySelector("div")||i);i.insertBefore(s,i.firstChild)}}_mousedown(e){this._edtColPrev=this._edtCol}_click(e){if(this._toggleEditor(e)){e.stopPropagation();e.preventDefault()}}_toggleEditor(e){if(!e.defaultPrevented&&0==e.button)if(wijmo_1.closestClass(e.target,FlexGridFilter._WJC_FILTER)){let t=this._g,i=t.hitTest(e.target);i.panel||(i=t.hitTest(e));if(i.panel&&t.columnHeaders&&t.cells&&(i.panel._uid==t.columnHeaders._uid||i.panel._uid==t.cells._uid&&-1==i.row)){let e=t.getMergedRange(i.panel,i.row,i.col)||new wijmo_grid_1.CellRange(i.row,i.col),l=t.columns[e.col],s=t._getBindingColumn(i.panel,i.row,l);if(this._divEdt&&this._edtCol==s){this.closeEditor();t.focus()}else s!=this._edtColPrev&&setTimeout(()=>{this.editColumnFilter(s,i)},this._divEdt?100:0);return!0}}else this.closeEditor();return!1}_keydown(e){if(!e.defaultPrevented&&!e.ctrlKey&&e.altKey&&(e.keyCode==wijmo_1.Key.Down||e.keyCode==wijmo_1.Key.Up)){let t=this.grid,i=t.selection,l=i.col>-1?t.columns[i.col]:null,s=l?t._getBindingColumn(t.cells,i.row,l):null,a=s&&s.dataMap&&s.dataMapEditor==wijmo_grid_1.DataMapEditor.DropDownList;if(this.filterColumns&&this.filterColumns.length>0&&!this.filterColumns.includes(s._binding._path)){e.preventDefault();return!1}s&&s.editor instanceof wijmo_input_1.DropDown&&(a=!0);if(s&&!a){let t=this.getColumnFilter(s,!1);if(t&&t.filterType!=FilterType.None){this.editColumnFilter(s);e.preventDefault();e.stopPropagation()}}}}}FlexGridFilter._WJC_FILTER="wj-elem-filter";exports.FlexGridFilter=FlexGridFilter;exports.empty={};class ConditionFilter{constructor(e){this._c1=new FilterCondition(this);this._c2=new FilterCondition(this);this._and=!0;this._col=e}get condition1(){return this._c1}get condition2(){return this._c2}get and(){return this._and}set and(e){this._and=wijmo_1.asBoolean(e)}get dataMap(){return this._map}set dataMap(e){this._map=wijmo_1.asType(e,wijmo_grid_1.DataMap,!0)}get column(){return this._col}get isActive(){return this._c1.isActive||this._c2.isActive}apply(e){let t=this._col,i=this._c1,l=this._c2,s=!1,a=!1;if(!t||!t._binding||!this.isActive)return!0;e=t._binding.getValue(e);let r=this.dataMap||t.dataMap;if(r)e=r.getDisplayValue(e);else if(wijmo_1.isDate(e)){s=!this._hasTimePart();a=!this._hasDatePart();let t=FilterCondition._refDateTime;s?e=wijmo_1.DateTime.fromDateTime(e,t):a&&(e=wijmo_1.DateTime.fromDateTime(t,e))}else if(wijmo_1.isNumber(e)){let i=wijmo_1.Globalize,l=t.format,s=i.formatNumber(e,l);e=i.parseFloat(s,l)}let n=i.apply(e,s,a),o=l.apply(e,s,a);return i.isActive&&l.isActive?this._and?n&&o:n||o:i.isActive?n:!l.isActive||o}clear(){this._c1.clear();this._c2.clear();this.and=!0}_hasDatePart(){let e=this._col.format;if(!e)return!0;e=wijmo_1.culture.Globalize.calendar.patterns[e]||e;return/[yMd]+/.test(e)}_hasTimePart(){let e=this._col.format;if(!e)return!1;e=wijmo_1.culture.Globalize.calendar.patterns[e]||e;return/[Hmst]+/.test(e)}implementsInterface(e){return"IColumnFilter"==e}}exports.ConditionFilter=ConditionFilter;class ConditionFilterEditor extends wijmo_1.Control{constructor(e,t){super(e);this._canApply=!1;this.canApplyChanged=new wijmo_1.Event;this._filter=wijmo_1.asType(t,ConditionFilter,!1);let i=this.getTemplate();this.applyTemplate("wj-control wj-conditionfilter-editor",i,{_divHdr:"div-hdr",_divCmb1:"div-cmb1",_divVal1:"div-val1",_btnAnd:"btn-and",_btnOr:"btn-or",_spAnd:"sp-and",_spOr:"sp-or",_divCmb2:"div-cmb2",_divVal2:"div-val2"});let l=wijmo_1.culture.FlexGridFilter,s=l.ariaLabels;wijmo_1.setAriaLabel(this._btnAnd,s.and);wijmo_1.setAriaLabel(this._btnOr,s.or);wijmo_1.setText(this._divHdr,l.header);wijmo_1.setText(this._spAnd,l.and);wijmo_1.setText(this._spOr,l.or);const a=wijmo_1.getUniqueId("cmb1");this._divHdr.htmlFor=a;this._divCmb1.id=a;this._cmb1=this._createOperatorCombo(this._divCmb1,s.op1);this._cmb2=this._createOperatorCombo(this._divCmb2,s.op2);this._val1=this._createValueInput(this._divVal1,s.val1);this._val2=this._createValueInput(this._divVal2,s.val2);this._val1.isDisabled=!0;this._cmb1.selectedIndexChanged.addHandler((e,t)=>{this._val1.isDisabled=null==e.selectedValue;this.canApply=!this._val1.isDisabled||!this._val2.isDisabled});this._val2.isDisabled=!0;this._cmb2.selectedIndexChanged.addHandler((e,t)=>{this._val2.isDisabled=null==e.selectedValue;this.canApply=!this._val1.isDisabled||!this._val2.isDisabled});let r=this.hostElement;this.addEventListener(r,"change",this._btnAndOrChanged.bind(this));this.addEventListener(r,"keydown",this._keydown.bind(this));setTimeout(()=>{this.updateEditor()})}get filter(){return this._filter}get canApply(){return this._canApply}set canApply(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}}updateEditor(){let e=this._filter.condition1,t=this._filter.condition2;this._cmb1.selectedValue=e.operator;this._cmb2.selectedValue=t.operator;if(this._val1 instanceof input.ComboBox&&!(this._val1 instanceof input.InputTime)){this._val1.text=wijmo_1.changeType(e.value,wijmo_1.DataType.String);this._val2.text=wijmo_1.changeType(t.value,wijmo_1.DataType.String)}else{this._val1.value=e.value;this._val2.value=t.value}let i=this._filter.and;this._checkRadio(this._btnAnd,i);this._checkRadio(this._btnOr,!i)}clearEditor(){this._cmb1.selectedValue=this._cmb2.selectedValue=null;this._val1.text=this._val2.text=null;this._checkRadio(this._btnAnd,!0);this._checkRadio(this._btnOr,!1)}get isEditorClear(){return null==this._cmb1.selectedValue&&!this._val1.text&&null==this._cmb2.selectedValue&&!this._val2.text}updateFilter(){let e=this._filter.condition1,t=this._filter.condition2;e.operator=this._cmb1.selectedValue;t.operator=this._cmb2.selectedValue;if("value"in this._val1){e.value=this._val1.value;t.value=this._val2.value}else{e.value=this._getComboValue(this._val1);t.value=this._getComboValue(this._val2)}this._filter.and=this._btnAnd.checked}onCanApplyChanged(e){this.canApplyChanged.raise(this,e)}_getComboValue(e){return e.selectedIndex>-1?e.selectedValue:e.text}_createOperatorCombo(e,t){let i=this._filter.column,l=wijmo_1.culture.FlexGridFilter,s=l.stringOperators,a=wijmo_1.DataType;this._filter.dataMap||i.dataMap||(i.dataType==a.Date?s=l.dateOperators:i.dataType==a.Number?s=l.numberOperators:i.dataType==a.Boolean&&(s=l.booleanOperators));let r=new input.ComboBox(e,{itemsSource:s,displayMemberPath:"name",selectedValuePath:"op"});wijmo_1.setAriaLabel(r.inputElement,t);return r}_createValueInput(e,t){let i=this._filter,l=i.column,s=i.dataMap||l.dataMap,a=null,r=wijmo_1.DataType;if(l.dataType==r.Date)(a=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(e):new input.InputDate(e):new input.InputTime(e)).format=l.format;else if(l.dataType!=r.Number||s){(a=new input.ComboBox(e)).isEditable=!0;if(s){a.itemsSource=s.getDisplayValues();a.caseSensitiveSearch=!!l.grid&&l.grid.caseSensitiveSearch}else l.dataType==r.Boolean&&(a.itemsSource=[!0,!1])}else(a=new input.InputNumber(e)).format=l.format;a.isRequired=!1;wijmo_1.setAriaLabel(a.inputElement,t);return a}_btnAndOrChanged(e){let t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i){this._checkRadio(this._btnAnd,t);this._checkRadio(this._btnOr,i)}}_checkRadio(e,t){e.checked=t;wijmo_1.setAttribute(e,"aria-checked",t.toString());wijmo_1.setAttribute(e,"tabindex",t?null:"-1")}_keydown(e){let t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i)switch(e.keyCode){case wijmo_1.Key.Left:case wijmo_1.Key.Right:case wijmo_1.Key.Up:case wijmo_1.Key.Down:let i=t?this._btnOr:this._btnAnd;i.click();i.focus();e.preventDefault()}}}ConditionFilterEditor.controlTemplate='<div><label wj-part="div-hdr"></label><div wj-part="div-cmb1"></div><br/><div wj-part="div-val1"></div><br/><div role="radiogroup" style="text-align:center"><label><input wj-part="btn-and" type="radio" role="radio"> <span wj-part="sp-and"></span> </label>&nbsp;&nbsp;&nbsp;<label><input wj-part="btn-or" type="radio" role="radio"> <span wj-part="sp-or"></span> </label></div><div wj-part="div-cmb2"></div><br/><div wj-part="div-val2"></div><br/></div>';exports.ConditionFilterEditor=ConditionFilterEditor;class FilterCondition{constructor(e){this._op=null;this._filter=e}get operator(){return this._op}set operator(e){this._op=wijmo_1.asEnum(e,Operator,!0)}get value(){return this._val}set value(e){this._val=e;this._strVal=wijmo_1.isString(e)?this._getCaseString(e):null}get isActive(){switch(this._op){case null:return!1;case Operator.EQ:case Operator.NE:return!0;default:return null!=this._val||null!=this._strVal}}clear(){this.operator=null;this.value=null}apply(e,t,i){let l=this._strVal||this._val;wijmo_1.isString(e)&&(e=this._getCaseString(e));wijmo_1.isString(l)&&null==e&&(e="");wijmo_1.isDate(l)&&(t?l=wijmo_1.DateTime.fromDateTime(l,FilterCondition._refDateTime):i&&(l=wijmo_1.DateTime.fromDateTime(FilterCondition._refDateTime,l)));let s=Operator;switch(this._op){case null:return!0;case s.EQ:return null!=e&&null!=l?e.valueOf()==l.valueOf():e==l;case s.NE:return null!=e&&null!=l?e.valueOf()!=l.valueOf():e!=l;case s.GT:return e>l;case s.GE:return e>=l;case s.LT:return e<l;case s.LE:return e<=l;case s.BW:return!(null==this._strVal||!wijmo_1.isString(e))&&0==e.indexOf(this._strVal);case s.EW:return!!(null!=this._strVal&&wijmo_1.isString(e)&&e.length>=this._strVal.length)&&e.substr(e.length-this._strVal.length)==l;case s.CT:return!(null==this._strVal||!wijmo_1.isString(e))&&e.indexOf(this._strVal)>-1;case s.NC:return!(null==this._strVal||!wijmo_1.isString(e))&&e.indexOf(this._strVal)<0}throw"Unknown operator"}_getCaseString(e){let t=this._filter.column,i=t?t.grid:null;return i&&i.caseSensitiveSearch?e:e.toLowerCase()}}FilterCondition._refDateTime=new Date(2e3,0,1,0,0,0);exports.FilterCondition=FilterCondition;!function(e){e[e.EQ=0]="EQ";e[e.NE=1]="NE";e[e.GT=2]="GT";e[e.GE=3]="GE";e[e.LT=4]="LT";e[e.LE=5]="LE";e[e.BW=6]="BW";e[e.EW=7]="EW";e[e.CT=8]="CT";e[e.NC=9]="NC"}(Operator=exports.Operator||(exports.Operator={}));!function(e){e[e.Text=0]="Text";e[e.Regex=1]="Regex";e[e.Excel=2]="Excel"}(ValueFilterSearchKind=exports.ValueFilterSearchKind||(exports.ValueFilterSearchKind={}));class ValueFilter{constructor(e){this._values=null;this._filterText=null;this._xValueSearch=!0;this._maxValues=250;this._uniqueValues=null;this._sortValues=!0;this._searchType=ValueFilterSearchKind.Excel;this._exceedsMaxValues=!1;this._col=e}get searchType(){return this._searchType}set searchType(e){this._searchType=wijmo_1.asEnum(e,ValueFilterSearchKind)}get showValues(){return this._values}set showValues(e){this._values=e}get filterText(){return this._filterText}set filterText(e){this._filterText=wijmo_1.asString(e)}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(e){if((e=wijmo_1.asBoolean(e))!==this._xValueSearch){this._xValueSearch=wijmo_1.asBoolean(e);e&&(this._filterText="")}}get maxValues(){return this._maxValues}set maxValues(e){this._maxValues=wijmo_1.asNumber(e,!1,!0)}get uniqueValues(){return this._uniqueValues}set uniqueValues(e){this._uniqueValues=wijmo_1.asArray(e)}get sortValues(){return this._sortValues}set sortValues(e){this._sortValues=wijmo_1.asBoolean(e)}get dataMap(){return this._map}set dataMap(e){this._map=wijmo_1.asType(e,wijmo_grid_1.DataMap,!0)}get column(){return this._col}get isActive(){return null!=this._values&&Object.keys(this._values).length>0}apply(e){let t=this.column;if(!(t&&t._binding&&this._values&&Object.keys(this._values).length))return!0;e=t._binding.getValue(e);e=this.dataMap?this.dataMap.getDisplayValue(e)||"":t.dataMap?t.dataMap.getDisplayValue(e)||"":wijmo_1.Globalize.format(e,t.format);return null!=this._values[e]}clear(){this.showValues=null;this.filterText=null}getUniqueValues(e=!0){let t=[],i=this.column,l=wijmo_1.Globalize.format;if(this.uniqueValues){this.uniqueValues.forEach(e=>{t.push({value:e,text:l(e,i.format)})});return t}let s={},a=i.collectionView,r=a?a.sourceCollection:[];if(e&&a&&a.sourceCollection&&a.filter)try{FlexGridFilter._skipColumn=this._col;let e=[];for(let t=0;t<r.length;t++)a.filter(r[t])&&e.push(r[t]);r=e}finally{FlexGridFilter._skipColumn=null}for(let e=0;e<r.length;e++){let a=i._binding.getValue(r[e]),n=this.dataMap?this.dataMap.getDisplayValue(a)||"":i.dataMap?i.dataMap.getDisplayValue(a)||"":l(a,i.format);if(!s[n]){s[n]=!0;t.push({value:a,text:n})}}this._exceedsMaxValues=t.length>this._maxValues;return t}get exceedsMaxValues(){return this._exceedsMaxValues}implementsInterface(e){return"IColumnFilter"==e}}exports.ValueFilter=ValueFilter;class ValueFilterEditor extends wijmo_1.Control{constructor(e,t){super(e);this._canApply=!1;this._isFiltering=!1;this.canApplyChanged=new wijmo_1.Event;this._filter=wijmo_1.asType(t,ValueFilter,!1);let i=this.getTemplate();this.applyTemplate("wj-control wj-valuefilter-editor",i,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values",_warning:"warning-message"});this._cbSelectAll.tabIndex=0;let l=wijmo_1.culture.FlexGridFilter;wijmo_1.setText(this._spSelectAll,l.selectAll);let s=this._view=new wijmo_1.CollectionView(null,{sortNulls:wijmo_1.SortNulls.First,filter:this._filterValues.bind(this)});if(t.sortValues){let e=t.column.dataMap||t.dataMap?"text":"value",i=t.column.dataType!=wijmo_1.DataType.Boolean;s.sortDescriptions.push(new wijmo_1.SortDescription(e,i))}s.collectionChanged.addHandler(this._updateSelectAllCheck,this);this._filterText="";this._rxFilter=null;this._cmbFilter=new input.ComboBox(this._divFilter,{isRequired:!1,placeholder:l.search});this._cmbFilter.isEditable=!0;this._lbValues=new input.ListBox(this._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:this._view,itemFormatter:(e,t)=>t||l.null,checkedItemsChanged:e=>this._updateSelectAllCheck()});wijmo_1.setAriaLabel(this._cmbFilter.inputElement,l.ariaLabels.search);wijmo_1.setAttribute(this._lbValues.hostElement,"aria-multiselectable",!0);this._cmbFilter.inputElement.addEventListener("input",this._filterTextChanged.bind(this));this._cbSelectAll.addEventListener("click",this._cbSelectAllClicked.bind(this));this._warning.addEventListener("click",()=>this._showModal());this._modal=this._createModal();document.body.appendChild(this._modal);this.updateEditor();this._initialItems=this._lbValues.checkedItems}get filter(){return this._filter}get canApply(){return this._canApply}set canApply(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}}updateEditor(){let e=this._filter.column,t=this._filter.getUniqueValues(!0);this._lbValues.isContentHtml=e.isContentHtml;let i=this._filter.showValues;if(i&&0!=Object.keys(i).length){for(let e in i)for(let i=0;i<t.length;i++)if(t[i].text==e){t[i].show=!0;break}}else t.forEach(e=>e.show=!0);this._warning.style.display=this._filter.exceedsMaxValues?"block":"none";let l=this._filter.filterText||"",s=this._getCaseSensitive();this._cmbFilter.text=l;this._filterText=s?l:l.toLowerCase();this._rxFilter=this._getSearchExp(l,s);let a=this._view;a.pageSize=this._filter.maxValues;a.sourceCollection=t;setTimeout(()=>{this._adjustWidths()},0)}clearEditor(e=!0){this._cmbFilter.text="";this._filterText="";this._rxFilter=null;let t=this._view;t.pageSize=0;t.items.forEach(t=>{t.show=e});t.moveCurrentTo(-1);t.refresh();t.pageSize=this._filter.maxValues}get isEditorClear(){return!this._filterText&&!this._cbSelectAll.indeterminate}_updateFilter(){let e=null,t=this._getItems();if(this._filterText||this._cbSelectAll.indeterminate){e={};for(let i=0;i<t.length;i++){let l=t[i];l.show&&(e[l.text]=!0)}}let i=this._filter;i.showValues=e;i.filterText=this._filterText}updateFilter(){this._isFiltering?setTimeout(()=>{this._updateFilter()},wijmo_1.Control._SEARCH_DELAY+100):this._updateFilter()}onCanApplyChanged(e){this.canApplyChanged.raise(this,e)}_getCaseSensitive(){let e=this._filter.column,t=e?e.grid:null;return t&&t.caseSensitiveSearch}_getItems(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection}_filterTextChanged(){""===this._filterText&&this._cbSelectAll.checked||this._filter.exclusiveValueSearch?this._lbValues._addMode=!1:this._lbValues._addMode=!0;this._toFilter&&clearTimeout(this._toFilter);this._isFiltering=!0;this._toFilter=setTimeout(()=>{let e=this._cmbFilter.text,t=this._getCaseSensitive();t||(e=e.toLowerCase());if(e!=this._filterText){this._filterText=e;this._rxFilter=this._getSearchExp(e,t);this._view.refresh();if(!e){let e=this._initialItems;if(e.length&&this._view.sourceCollection.indexOf(e[0])>-1){this._lbValues.checkedItems=this._initialItems;this._updateSelectAllCheck();this._isFiltering=!1;return}}if(this._filter.exclusiveValueSearch){this._cbSelectAll.checked=!0;this._cbSelectAllClicked()}else this._updateSelectAllCheck()}this._isFiltering=!1},wijmo_1.Control._SEARCH_DELAY)}_getSearchExp(e,t){if(!e)return null;switch(this._filter.searchType){case ValueFilterSearchKind.Text:return this._getTextSearchExp(e,t);case ValueFilterSearchKind.Regex:return this._getRegexSearchExp(e,t);case ValueFilterSearchKind.Excel:return this._getExcelSearchExp(e,t)}}_getTextSearchExp(e,t){return new RegExp(wijmo_1.escapeRegExp(e),t?"":"i")}_getRegexSearchExp(e,t){try{return new RegExp(e,t?"s":"is")}catch(e){return new RegExp("(?!)",t?"s":"is")}}_getExcelSearchExp(e,t){let i=e;i=(i=(i=(i=(i=i.replace(/([.+^$[\]\\(){}|-])/g,"\\$1")).replace(/(?<!~)(\?+)/g,(function(e,t){return Array.from(t).map(e=>".").join("")}))).replace(/(?<!~)(\*+)/g,(function(e,t){return Array.from(t).map(e=>".*").join("")}))).replace(/~~/g,"~")).replace(/~([?*])/g,"\\$1");/(?<!~)[?*]/g.test(e)&&(i="^"+i+"$");return new RegExp(i,t?"s":"is")}_filterValues(e){let t=this._rxFilter;return null==t||null==e||t.test(e.text)}_cbSelectAllClicked(){let e=this._cbSelectAll.checked,t=this._divValues.scrollTop,i=this._getItems();for(let t=0;t<i.length;t++)i[t].show=e;this._view.refresh();this._divValues.scrollTop=t;setTimeout(()=>{this._adjustWidths()},0)}_updateSelectAllCheck(){let e=this._getItems(),t=0,i=0;for(let l=0;l<e.length;l++){e[l].show?t++:i++;if(t&&i)break}wijmo_1.setChecked(this._cbSelectAll,t&&i?null:t>0);this.canApply=t>0}_adjustWidths(){let e=this._lbValues.hostElement;if(e&&e.offsetHeight>0){let t=0,i=e.querySelectorAll(".wj-listbox-item label");if(i.length){for(let e=0;e<i.length;e++)t=Math.max(t,i[e].scrollWidth);if(t){let i=e.querySelectorAll(".wj-listbox-item");if(i.length){let e=i[0],l=getComputedStyle(e),s=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight);for(let e=0;e<i.length;e++)i[e].style.width=t+s+"px"}}}}}_createModal(){const e=this._filter.maxValues,t=document.createElement("div");t.className="modal";t.innerHTML='<div class="modal-content"><span class="close">&times;</span><p>This column has more than '+e+" unique items. Only the first "+e+" unique items are displayed. Please set the maxValues property of the ValueFilter to see all the values on the list.</p></div>";t.querySelector(".close").addEventListener("click",()=>this._modal.style.display="none");return t}_showModal(){this._modal.style.display="block";this.hostElement.style.display="none"}}ValueFilterEditor.controlTemplate='<div><div wj-part="div-filter"></div><div class="wj-listbox-item"><label><input wj-part="cb-select-all" type="checkbox"> <span wj-part="sp-select-all"></span></label></div><div wj-part="div-values"></div><div wj-part="warning-message" style="display: none;">Not all items are shown</div></div>';exports.ValueFilterEditor=ValueFilterEditor;class ColumnFilter{constructor(e,t){this._owner=e;this._col=t;this._valueFilter=new ValueFilter(t);this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch;this._conditionFilter=new ConditionFilter(t);e.exclusiveValueSearchChanged.addHandler(e=>{this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch})}get filterType(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType}set filterType(e){if((e=wijmo_1.asEnum(e,FilterType,!0))!=this._filterType){let t=this.isActive;this.clear();this._filterType=e;t?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}}get dataMap(){return this.conditionFilter.dataMap||this.valueFilter.dataMap}set dataMap(e){this.conditionFilter.dataMap=e;this.valueFilter.dataMap=e}get valueFilter(){return this._valueFilter}get conditionFilter(){return this._conditionFilter}get column(){return this._col}get isActive(){return this._conditionFilter.isActive||this._valueFilter.isActive}apply(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)}clear(){this._valueFilter.clear();this._conditionFilter.clear()}implementsInterface(e){return"IColumnFilter"==e}}exports.ColumnFilter=ColumnFilter;wijmo_1._addCultureInfo("FlexGridFilter",{ariaLabels:{edit:"Edit Filter for Column",dialog:"Filter Editor for Column",asc:"Sort Column in Ascending Order",dsc:"Sort Column in Descending Order",search:"Search Item List",op1:"First Condition Operator",val1:"First Condition Value",and:"Require both Conditions",or:"Require either Condition",op2:"Second Condition Operator",val2:"Second Condition Value"},ascending:"↑ Ascending",descending:"↓ Descending",apply:"Apply",cancel:"Cancel",clear:"Clear",conditions:"Filter by Condition",values:"Filter by Value",search:"Search",selectAll:"Select All",null:"(nothing)",header:"Show items where the value",and:"And",or:"Or",stringOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Begins with",op:Operator.BW},{name:"Ends with",op:Operator.EW},{name:"Contains",op:Operator.CT},{name:"Does not contain",op:Operator.NC}],numberOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Is Greater than",op:Operator.GT},{name:"Is Greater than or equal to",op:Operator.GE},{name:"Is Less than",op:Operator.LT},{name:"Is Less than or equal to",op:Operator.LE}],dateOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Is Before",op:Operator.LT},{name:"Is After",op:Operator.GT}],booleanOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE}]});class ColumnFilterEditor extends wijmo_1.Control{constructor(e,t,i=!0){super(e,null,!0);this.filterChanged=new wijmo_1.Event;this.buttonClicked=new wijmo_1.Event;this._filter=wijmo_1.asType(t,ColumnFilter);let l=this.getTemplate();this.applyTemplate("wj-control wj-content wj-columnfiltereditor",l,{_divSort:"div-sort",_btnAsc:"btn-asc",_btnDsc:"btn-dsc",_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnApply:"btn-apply",_btnCancel:"btn-cancel",_btnClear:"btn-clear"});let s=wijmo_1.culture.FlexGridFilter,a=s.ariaLabels,r=this.hostElement,n=this.filter.column,o=n.grid.collectionView;wijmo_1.setAttribute(r,"role","dialog");wijmo_1.setAriaLabel(r,a.dialog+" "+n.header);wijmo_1.setAriaLabel(this._btnAsc,a.asc);wijmo_1.setAriaLabel(this._btnDsc,a.dsc);wijmo_1.setText(this._btnAsc,s.ascending);wijmo_1.setText(this._btnDsc,s.descending);wijmo_1.setText(this._aVal,s.values);wijmo_1.setText(this._aCnd,s.conditions);wijmo_1.setText(this._btnApply,s.apply);wijmo_1.setText(this._btnCancel,s.cancel);wijmo_1.setText(this._btnClear,s.clear);let d=this.filter.conditionFilter.isActive||0==(t.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;this._showFilter(d);i&&o&&o.canSort||(this._divSort.style.display="none");this._updateSortButtonState();let h=this._btnClicked.bind(this);this._btnApply.addEventListener("click",h);this._btnCancel.addEventListener("click",h);this._btnClear.addEventListener("click",h);this._btnAsc.addEventListener("click",h);this._btnDsc.addEventListener("click",h);this._aVal.addEventListener("click",h);this._aCnd.addEventListener("click",h);this.addEventListener(r,"keydown",e=>{if(!e.defaultPrevented){let t=e.target.tagName.match(/^(a|button)$/i);switch(e.keyCode){case wijmo_1.Key.Space:if(t){this._btnClicked(e);e.preventDefault()}break;case wijmo_1.Key.Enter:if(t)this._btnClicked(e);else{this.updateFilter();this.onFilterChanged();this.onButtonClicked()}e.preventDefault();break;case wijmo_1.Key.Escape:this.onButtonClicked();e.preventDefault();break;case wijmo_1.Key.Tab:wijmo_1.moveFocus(this.hostElement,e.shiftKey?-1:1);e.preventDefault()}}});this.addEventListener(window,"resize",()=>{this.isTouching||this._wasTouching||this.onButtonClicked()})}get filter(){return this._filter}updateEditor(){this._edtVal&&this._edtVal.updateEditor();this._edtCnd&&this._edtCnd.updateEditor()}updateFilter(){switch(this._getFilterType()){case FilterType.Value:this._edtVal.updateFilter();this.filter.conditionFilter.clear();break;case FilterType.Condition:this._edtCnd.updateFilter();this.filter.valueFilter.clear()}}onFilterChanged(e){this.filterChanged.raise(this,e)}onButtonClicked(e){this.buttonClicked.raise(this,e)}_showFilter(e){this._wasTouching=this.isTouching;if(e==FilterType.Value&&null==this._edtVal){this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter);this._edtVal.canApplyChanged.addHandler(e=>{wijmo_1.enable(this._btnApply,this._edtVal.canApply)})}if(e==FilterType.Condition&&null==this._edtCnd){this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter);this._edtCnd.canApplyChanged.addHandler(e=>{wijmo_1.enable(this._btnApply,this._edtCnd.canApply)})}if(0!=(e&this.filter.filterType))if(e==FilterType.Value){this._divEdtVal.style.display="";this._divEdtCnd.style.display="none";this._enableLink(this._aVal,!1);this._enableLink(this._aCnd,!0);this._edtVal.focus();wijmo_1.enable(this._btnApply,this._edtVal.canApply)}else{this._divEdtVal.style.display="none";this._divEdtCnd.style.display="";this._enableLink(this._aVal,!0);this._enableLink(this._aCnd,!1);this._edtCnd.focus();wijmo_1.enable(this._btnApply,this._edtCnd.canApply)}let t=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:t.display="none";break;default:t.display=""}}_enableLink(e,t){wijmo_1.toggleClass(e,"wj-state-disabled",!t);wijmo_1.setAttribute(e,"href",t?"":null);wijmo_1.setAttribute(e,"disabled",t?null:"disabled")}_updateSortButtonState(){let e=this.filter.column,t=e?e.currentSort:"",i="wj-state-active";wijmo_1.toggleClass(this._btnAsc,i,"+"==t);wijmo_1.toggleClass(this._btnDsc,i,"-"==t)}_getFilterType(){let e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition}_btnClicked(e){let t=e.target;e.preventDefault();e.stopPropagation();if(!wijmo_1.hasClass(t,"wj-state-disabled"))if(t!=this._aVal)if(t!=this._aCnd){if(t==this._btnAsc||t==this._btnDsc){let t=this.filter.column,i=t.sortMemberPath||t.binding,l=t.grid.collectionView.sortDescriptions;l.deferUpdate(()=>{l.clear();l.push(new wijmo_1.SortDescription(i,e.target==this._btnAsc))});this._updateSortButtonState()}if(t==this._btnApply){this.updateFilter();this.onFilterChanged()}else if(t==this._btnClear){if(this.filter.isActive){this.filter.clear();this.onFilterChanged()}}else this.updateEditor();this.onButtonClicked()}else{this._showFilter(FilterType.Condition);wijmo_1.moveFocus(this._edtCnd.hostElement,0)}else{this._showFilter(FilterType.Value);wijmo_1.moveFocus(this._edtVal.hostElement,0)}}}ColumnFilterEditor.controlTemplate='<div><div wj-part="div-sort" class="wj-sort-buttons"><button wj-part="btn-asc" class="wj-btn"></button>&nbsp;&nbsp;&nbsp;<button wj-part="btn-dsc" class="wj-btn"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a>&nbsp;|&nbsp;<a wj-part="a-val" href="" draggable="false"></a></div><div wj-part="div-edt-val" tabindex="-1"></div><div wj-part="div-edt-cnd" tabindex="-1"></div><div style="text-align:right;margin-top:10px"><button wj-part="btn-apply" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-cancel" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-clear" class="wj-btn"></button></div></div>';exports.ColumnFilterEditor=ColumnFilterEditor;wijmo_1._registerModule("wijmo.grid.filter",selfModule);
/*!
*
* Wijmo Library 5.20241.001-nightly.d20240116.t020147
* Wijmo Library 5.20241.001-nightly.d20240117.t020138
* https://developer.mescius.com/wijmo

@@ -14,2 +14,2 @@ *

import{Column,DataMap,FlexGrid,DataMapEditor,CellRange,CellRangeEventArgs,_NewRowTemplate}from"@grapecity/wijmo.grid";import{Globalize,asString,asNumber,asArray,asBoolean,asType,asEnum,isString,isDate,DateTime,culture,isNumber,copy,changeType,setAttribute,showPopup,hidePopup,isFunction,createElement,toggleClass,removeClass,closestClass,setAriaLabel,Control,Event,DataType,Key,CollectionView,setText,escapeRegExp,setChecked,SortDescription,SortNulls,getUniqueId,_addCultureInfo,enable,moveFocus,hasClass,_registerModule}from"@grapecity/wijmo";import{DropDown}from"@grapecity/wijmo.input";import*as input from"@grapecity/wijmo.input";import*as selfModule from"@grapecity/wijmo.grid.filter";export var FilterType;!function(e){e[e.None=0]="None";e[e.Condition=1]="Condition";e[e.Value=2]="Value";e[e.Both=3]="Both"}(FilterType||(FilterType={}));export class FlexGridFilter{constructor(e,t){this._showIcons=!0;this._showSort=!0;this._defFilterType=FilterType.Both;this._xValueSearch=!0;this._includeUpdatedRowsInFilter=!1;this.filterApplied=new Event;this.editingFilter=new Event;this.filterChanging=new Event;this.filterChanged=new Event;this.exclusiveValueSearchChanged=new Event;this._filters=[];this._g=asType(e,FlexGrid,!1);this._g.formatItem.addHandler(this._formatItem.bind(this));this._g.itemsSourceChanged.addHandler(this.clear.bind(this));let i=this._g.hostElement;e.addEventListener(i,"mousedown",this._mousedown.bind(this),!0);e.addEventListener(i,"click",this._click.bind(this),!0);e.addEventListener(i,"keydown",this._keydown.bind(this),!0);this._g.invalidate();copy(this,t);this._init()}_init(){const e=this.grid,_excludeRowFromFilter=e=>{let t=this.grid;const i=this.excludedRowsSet;t.itemsSource?t.rows[e]instanceof _NewRowTemplate?i.add(t.editableCollectionView.currentAddItem||t.rows[e].dataItem):i.add(t.rows[e].dataItem):i.add(t.rows[e])};e.rowChanged&&e.rowChanged.addHandler((e,t)=>{t.added&&_excludeRowFromFilter(t.index)});e.rowEditEnding.addHandler((e,t)=>{_excludeRowFromFilter(t.row)});e.cellEditEnded.addHandler((e,t)=>{_excludeRowFromFilter(t.row)})}get excludedRowsSet(){let e=this.grid;e.selectedSheet&&(e=e.selectedSheet);e._newAddedRowsSet||(e._newAddedRowsSet=new WeakSet);return e._newAddedRowsSet}set excludedRowsSet(e){let t=this.grid;t.selectedSheet&&(t=t.selectedSheet);t._newAddedRowsSet=e}get grid(){return this._g}get filterColumns(){return this._filterColumns}set filterColumns(e){this._filterColumns=asArray(e);this.clear()}get showFilterIcons(){return this._showIcons}set showFilterIcons(e){if(e!=this.showFilterIcons){this._showIcons=asBoolean(e);this._g&&this._g.invalidate()}}get showSortButtons(){return this._showSort}set showSortButtons(e){this._showSort=asBoolean(e)}get reApplyFilterOnUpdate(){return this._includeUpdatedRowsInFilter}set reApplyFilterOnUpdate(e){e!==this._includeUpdatedRowsInFilter&&(this._includeUpdatedRowsInFilter=asBoolean(e))}getColumnFilter(e,t=!0){if(e=this._asColumn(e)){for(let t=0;t<this._filters.length;t++)if(this._filters[t].column==e)return this._filters[t];if(t&&e.binding){let t=new ColumnFilter(this,e);this._filters.push(t);return t}}return null}get defaultFilterType(){return this._defFilterType}set defaultFilterType(e){if((e=asEnum(e,FilterType,!1))!=this.defaultFilterType){this._defFilterType=e;this._g.invalidate();this.clear()}}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(e){if((e=asBoolean(e))!==this._xValueSearch){this._xValueSearch=e;this.onExclusiveValueSearchChanged()}}get filterDefinition(){let e={defaultFilterType:this.defaultFilterType,filters:[]};this._filters.forEach(t=>{let i=t.conditionFilter,l=t.valueFilter,s=l.uniqueValues&&l.uniqueValues.length;if(t&&t.column&&t.column.binding&&(t.isActive||s||t.filterType!=this.defaultFilterType)){let a={binding:t.column.binding};if(i.isActive){let e=i.condition1,l=i.condition2;a={binding:t.column.binding,type:"condition",condition1:{operator:e.operator,value:e.value},and:i.and,condition2:{operator:l.operator,value:l.value}}}else(l.isActive||s)&&(a={binding:t.column.binding,type:"value",uniqueValues:l.uniqueValues,sortValues:l.sortValues,maxValues:l.maxValues,exclusiveValueSearch:l.exclusiveValueSearch,showValues:l.showValues});t.filterType!=this.defaultFilterType&&(a.filterType=t.filterType);e.filters.push(a)}});return JSON.stringify(e)}set filterDefinition(e){e=asString(e);this.clear();if(e){let t=JSON.parse(e);this.defaultFilterType=t.defaultFilterType;for(let e=0;e<t.filters.length;e++){let i=t.filters[e],l=this._asColumn(i.binding);l||(l=new Column({binding:i.binding}));let s=this.getColumnFilter(l,!0);if(s){null!=i.filterType&&(s.filterType=asEnum(i.filterType,FilterType));switch(i.type){case"condition":let e=s.conditionFilter;e.condition1.value=l.dataType==DataType.Date?changeType(i.condition1.value,l.dataType,null):i.condition1.value;e.condition1.operator=i.condition1.operator;e.and=i.and;e.condition2.value=l.dataType==DataType.Date?changeType(i.condition2.value,l.dataType,null):i.condition2.value;e.condition2.operator=i.condition2.operator;break;case"value":let t=s.valueFilter;t.uniqueValues=i.uniqueValues;["sortValues","maxValues","exclusiveValueSearch"].forEach(e=>{null!=i[e]&&(t[e]=i[e])});t.showValues=i.showValues}}}}this.apply()}get activeEditor(){return Control.getControl(this._divEdt)}editColumnFilter(e,t,i){let l=this._g;this.closeEditor();e=this._asColumn(e);let s=new CellRangeEventArgs(l.cells,new CellRange(-1,e.index));if(!this.onEditingFilter(s))return;let a=createElement('<div class="wj-dropdown-panel"></div>'),r=this.getColumnFilter(e),n=new ColumnFilterEditor(a,r,this.showSortButtons);this._divEdt=a;this._edtCol=e;l.rightToLeft&&(a.dir="rtl");if(!this.onFilterChanging(s)){this._divEdt=this._edtCol=null;return}s.cancel=!0;n.filterChanged.addHandler(()=>{s.cancel=!1;setTimeout(()=>{if(!s.cancel){this.excludedRowsSet=null;this.apply()}},n._edtVal&&n._edtVal._isFiltering?Control._SEARCH_DELAY+200:0)});n.buttonClicked.addHandler(()=>{this.closeEditor();l.focus();this.onFilterChanged(s)});n.lostFocus.addHandler(()=>{setTimeout(()=>{let e=Control.getControl(this._divEdt);e&&!e.containsFocus()&&this.closeEditor()},10)});let o=t?t.col:e.index,d=l.columns[o];t||d&&d.binding==e.binding||(o=l.selection.leftCol);l._edtHdl._commitRowEdits();l.scrollIntoView(-1,o,!0);let h=l.columnHeaders,u=t&&t.panel&&h&&t.panel._uid==h._uid?t.row:h.rows.length-1,c=o,p=i||h.getCellElement(u,c),_=p?null:h.getCellBoundingRect(u,c);p?showPopup(a,p,!1,!1,!1):showPopup(a,_);this._setAriaExpanded(p,!0);this._setAriaExpanded(l.cells.getCellElement(-1,c),!0);let g=n.hostElement.querySelectorAll("input");for(let e=0;e<g.length;e++){let t=g[e];if(t.offsetHeight>0&&t.tabIndex>-1&&!t.disabled){t.focus();break}}n.containsFocus()||n.focus()}_setAriaExpanded(e,t){if(e){var i=e.querySelector("."+FlexGridFilter._WJC_FILTER);setAttribute(i,"aria-expanded",t)}}closeEditor(){let e=this._g,t=Control.getControl(this._divEdt),i=this._edtCol;t&&hidePopup(t.hostElement,()=>{t.dispose()});if(i){let t=e.columnHeaders,l=t.rows.length?t.getCellElement(t.rows.length-1,i.index):null;this._setAriaExpanded(l,!1);l=e.cells.getCellElement(-1,i.index);this._setAriaExpanded(l,!1)}this._divEdt=null;this._edtCol=null}apply(){let e=this._g.collectionView;if(e){let t=this._g.editableCollectionView;if(t){t.commitEdit();t.commitNew()}e.filter=this._filter.bind(this)}let t=e?e.updateFilterDefinition:null;isFunction(t)&&t.call(e,this);this.onFilterApplied()}clear(){if(this._filters.length){this._filters=[];this.apply()}}onFilterApplied(e){this.filterApplied.raise(this,e)}onEditingFilter(e){this.editingFilter.raise(this,e);return!e.cancel}onFilterChanging(e){this.filterChanging.raise(this,e);return!e.cancel}onFilterChanged(e){this.filterChanged.raise(this,e)}onExclusiveValueSearchChanged(e){this.exclusiveValueSearchChanged.raise(this,e)}_asColumn(e){return isString(e)?this._g.getColumn(e,!0):isNumber(e)?this._g.columns[e]:asType(e,Column,!1)}_filter(e){const t=this.excludedRowsSet;if(!this.reApplyFilterOnUpdate&&t.has(e))return!0;let i=this._filters;for(let t=0;t<i.length;t++){let l=i[t];if(l.column!=FlexGridFilter._skipColumn&&!l.apply(e))return!1}return!0}_formatItem(e,t){if(t.panel==e.columnHeaders){let e=this._g,i=e.getMergedRange(t.panel,t.row,t.col)||new CellRange(t.row,t.col),l=e.columns[i.col],s=e._getBindingColumn(t.panel,t.row,l),a=t.cell;if(i.row2==t.panel.rows.length-1||l!=s){let i=this.getColumnFilter(s,this.defaultFilterType!=FilterType.None),r=this._filterColumns;r&&r.length&&r.indexOf(s.binding)<0&&r.indexOf(s.name)<0&&(i=null);if(i){toggleClass(a,"wj-filter-on",i.isActive);toggleClass(a,"wj-filter-off",!i.isActive)}else{removeClass(a,"wj-filter-on");removeClass(a,"wj-filter-off")}if(i&&i.filterType!=FilterType.None){this._showIcons&&this._addFilterButton(s,i,a);0==t.row&&(a=e.cells.getCellElement(-1,t.col))&&this._addFilterButton(l,i,a)}}}}_addFilterButton(e,t,i){let l=FlexGridFilter._WJC_FILTER,s=createElement('<button class="wj-btn wj-btn-glyph wj-right '+l+'" type="button" tabindex="-1"><span class="wj-glyph-filter"></span></button>');setAriaLabel(s,culture.FlexGridFilter.ariaLabels.edit+" "+e.header);setAttribute(s,"aria-haspopup","dialog");setAttribute(s,"aria-expanded",!1);setAttribute(s,"aria-describedby",e.describedById);setAttribute(s,"aria-pressed",t.isActive);if(!i.querySelector("."+l)){1==i.children.length&&(i=i.querySelector("div")||i);i.insertBefore(s,i.firstChild)}}_mousedown(e){this._edtColPrev=this._edtCol}_click(e){if(this._toggleEditor(e)){e.stopPropagation();e.preventDefault()}}_toggleEditor(e){if(!e.defaultPrevented&&0==e.button)if(closestClass(e.target,FlexGridFilter._WJC_FILTER)){let t=this._g,i=t.hitTest(e.target);i.panel||(i=t.hitTest(e));if(i.panel&&t.columnHeaders&&t.cells&&(i.panel._uid==t.columnHeaders._uid||i.panel._uid==t.cells._uid&&-1==i.row)){let e=t.getMergedRange(i.panel,i.row,i.col)||new CellRange(i.row,i.col),l=t.columns[e.col],s=t._getBindingColumn(i.panel,i.row,l);if(this._divEdt&&this._edtCol==s){this.closeEditor();t.focus()}else s!=this._edtColPrev&&setTimeout(()=>{this.editColumnFilter(s,i)},this._divEdt?100:0);return!0}}else this.closeEditor();return!1}_keydown(e){if(!e.defaultPrevented&&!e.ctrlKey&&e.altKey&&(e.keyCode==Key.Down||e.keyCode==Key.Up)){let t=this.grid,i=t.selection,l=i.col>-1?t.columns[i.col]:null,s=l?t._getBindingColumn(t.cells,i.row,l):null,a=s&&s.dataMap&&s.dataMapEditor==DataMapEditor.DropDownList;if(this.filterColumns&&this.filterColumns.length>0&&!this.filterColumns.includes(s._binding._path)){e.preventDefault();return!1}s&&s.editor instanceof DropDown&&(a=!0);if(s&&!a){let t=this.getColumnFilter(s,!1);if(t&&t.filterType!=FilterType.None){this.editColumnFilter(s);e.preventDefault();e.stopPropagation()}}}}}FlexGridFilter._WJC_FILTER="wj-elem-filter";export const empty={};export class ConditionFilter{constructor(e){this._c1=new FilterCondition(this);this._c2=new FilterCondition(this);this._and=!0;this._col=e}get condition1(){return this._c1}get condition2(){return this._c2}get and(){return this._and}set and(e){this._and=asBoolean(e)}get dataMap(){return this._map}set dataMap(e){this._map=asType(e,DataMap,!0)}get column(){return this._col}get isActive(){return this._c1.isActive||this._c2.isActive}apply(e){let t=this._col,i=this._c1,l=this._c2,s=!1,a=!1;if(!t||!t._binding||!this.isActive)return!0;e=t._binding.getValue(e);let r=this.dataMap||t.dataMap;if(r)e=r.getDisplayValue(e);else if(isDate(e)){s=!this._hasTimePart();a=!this._hasDatePart();let t=FilterCondition._refDateTime;s?e=DateTime.fromDateTime(e,t):a&&(e=DateTime.fromDateTime(t,e))}else if(isNumber(e)){let i=Globalize,l=t.format,s=i.formatNumber(e,l);e=i.parseFloat(s,l)}let n=i.apply(e,s,a),o=l.apply(e,s,a);return i.isActive&&l.isActive?this._and?n&&o:n||o:i.isActive?n:!l.isActive||o}clear(){this._c1.clear();this._c2.clear();this.and=!0}_hasDatePart(){let e=this._col.format;if(!e)return!0;e=culture.Globalize.calendar.patterns[e]||e;return/[yMd]+/.test(e)}_hasTimePart(){let e=this._col.format;if(!e)return!1;e=culture.Globalize.calendar.patterns[e]||e;return/[Hmst]+/.test(e)}implementsInterface(e){return"IColumnFilter"==e}}export class ConditionFilterEditor extends Control{constructor(e,t){super(e);this._canApply=!1;this.canApplyChanged=new Event;this._filter=asType(t,ConditionFilter,!1);let i=this.getTemplate();this.applyTemplate("wj-control wj-conditionfilter-editor",i,{_divHdr:"div-hdr",_divCmb1:"div-cmb1",_divVal1:"div-val1",_btnAnd:"btn-and",_btnOr:"btn-or",_spAnd:"sp-and",_spOr:"sp-or",_divCmb2:"div-cmb2",_divVal2:"div-val2"});let l=culture.FlexGridFilter,s=l.ariaLabels;setAriaLabel(this._btnAnd,s.and);setAriaLabel(this._btnOr,s.or);setText(this._divHdr,l.header);setText(this._spAnd,l.and);setText(this._spOr,l.or);const a=getUniqueId("cmb1");this._divHdr.htmlFor=a;this._divCmb1.id=a;this._cmb1=this._createOperatorCombo(this._divCmb1,s.op1);this._cmb2=this._createOperatorCombo(this._divCmb2,s.op2);this._val1=this._createValueInput(this._divVal1,s.val1);this._val2=this._createValueInput(this._divVal2,s.val2);this._val1.isDisabled=!0;this._cmb1.selectedIndexChanged.addHandler((e,t)=>{this._val1.isDisabled=null==e.selectedValue;this.canApply=!this._val1.isDisabled||!this._val2.isDisabled});this._val2.isDisabled=!0;this._cmb2.selectedIndexChanged.addHandler((e,t)=>{this._val2.isDisabled=null==e.selectedValue;this.canApply=!this._val1.isDisabled||!this._val2.isDisabled});let r=this.hostElement;this.addEventListener(r,"change",this._btnAndOrChanged.bind(this));this.addEventListener(r,"keydown",this._keydown.bind(this));setTimeout(()=>{this.updateEditor()})}get filter(){return this._filter}get canApply(){return this._canApply}set canApply(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}}updateEditor(){let e=this._filter.condition1,t=this._filter.condition2;this._cmb1.selectedValue=e.operator;this._cmb2.selectedValue=t.operator;if(this._val1 instanceof input.ComboBox&&!(this._val1 instanceof input.InputTime)){this._val1.text=changeType(e.value,DataType.String);this._val2.text=changeType(t.value,DataType.String)}else{this._val1.value=e.value;this._val2.value=t.value}let i=this._filter.and;this._checkRadio(this._btnAnd,i);this._checkRadio(this._btnOr,!i)}clearEditor(){this._cmb1.selectedValue=this._cmb2.selectedValue=null;this._val1.text=this._val2.text=null;this._checkRadio(this._btnAnd,!0);this._checkRadio(this._btnOr,!1)}get isEditorClear(){return null==this._cmb1.selectedValue&&!this._val1.text&&null==this._cmb2.selectedValue&&!this._val2.text}updateFilter(){let e=this._filter.condition1,t=this._filter.condition2;e.operator=this._cmb1.selectedValue;t.operator=this._cmb2.selectedValue;if("value"in this._val1){e.value=this._val1.value;t.value=this._val2.value}else{e.value=this._getComboValue(this._val1);t.value=this._getComboValue(this._val2)}this._filter.and=this._btnAnd.checked}onCanApplyChanged(e){this.canApplyChanged.raise(this,e)}_getComboValue(e){return e.selectedIndex>-1?e.selectedValue:e.text}_createOperatorCombo(e,t){let i=this._filter.column,l=culture.FlexGridFilter,s=l.stringOperators,a=DataType;this._filter.dataMap||i.dataMap||(i.dataType==a.Date?s=l.dateOperators:i.dataType==a.Number?s=l.numberOperators:i.dataType==a.Boolean&&(s=l.booleanOperators));let r=new input.ComboBox(e,{itemsSource:s,displayMemberPath:"name",selectedValuePath:"op"});setAriaLabel(r.inputElement,t);return r}_createValueInput(e,t){let i=this._filter,l=i.column,s=i.dataMap||l.dataMap,a=null,r=DataType;if(l.dataType==r.Date)(a=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(e):new input.InputDate(e):new input.InputTime(e)).format=l.format;else if(l.dataType!=r.Number||s){(a=new input.ComboBox(e)).isEditable=!0;if(s){a.itemsSource=s.getDisplayValues();a.caseSensitiveSearch=!!l.grid&&l.grid.caseSensitiveSearch}else l.dataType==r.Boolean&&(a.itemsSource=[!0,!1])}else(a=new input.InputNumber(e)).format=l.format;a.isRequired=!1;setAriaLabel(a.inputElement,t);return a}_btnAndOrChanged(e){let t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i){this._checkRadio(this._btnAnd,t);this._checkRadio(this._btnOr,i)}}_checkRadio(e,t){e.checked=t;setAttribute(e,"aria-checked",t.toString());setAttribute(e,"tabindex",t?null:"-1")}_keydown(e){let t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i)switch(e.keyCode){case Key.Left:case Key.Right:case Key.Up:case Key.Down:let i=t?this._btnOr:this._btnAnd;i.click();i.focus();e.preventDefault()}}}ConditionFilterEditor.controlTemplate='<div><label wj-part="div-hdr"></label><div wj-part="div-cmb1"></div><br/><div wj-part="div-val1"></div><br/><div role="radiogroup" style="text-align:center"><label><input wj-part="btn-and" type="radio" role="radio"> <span wj-part="sp-and"></span> </label>&nbsp;&nbsp;&nbsp;<label><input wj-part="btn-or" type="radio" role="radio"> <span wj-part="sp-or"></span> </label></div><div wj-part="div-cmb2"></div><br/><div wj-part="div-val2"></div><br/></div>';export class FilterCondition{constructor(e){this._op=null;this._filter=e}get operator(){return this._op}set operator(e){this._op=asEnum(e,Operator,!0)}get value(){return this._val}set value(e){this._val=e;this._strVal=isString(e)?this._getCaseString(e):null}get isActive(){switch(this._op){case null:return!1;case Operator.EQ:case Operator.NE:return!0;default:return null!=this._val||null!=this._strVal}}clear(){this.operator=null;this.value=null}apply(e,t,i){let l=this._strVal||this._val;isString(e)&&(e=this._getCaseString(e));isString(l)&&null==e&&(e="");isDate(l)&&(t?l=DateTime.fromDateTime(l,FilterCondition._refDateTime):i&&(l=DateTime.fromDateTime(FilterCondition._refDateTime,l)));let s=Operator;switch(this._op){case null:return!0;case s.EQ:return null!=e&&null!=l?e.valueOf()==l.valueOf():e==l;case s.NE:return null!=e&&null!=l?e.valueOf()!=l.valueOf():e!=l;case s.GT:return e>l;case s.GE:return e>=l;case s.LT:return e<l;case s.LE:return e<=l;case s.BW:return!(null==this._strVal||!isString(e))&&0==e.indexOf(this._strVal);case s.EW:return!!(null!=this._strVal&&isString(e)&&e.length>=this._strVal.length)&&e.substr(e.length-this._strVal.length)==l;case s.CT:return!(null==this._strVal||!isString(e))&&e.indexOf(this._strVal)>-1;case s.NC:return!(null==this._strVal||!isString(e))&&e.indexOf(this._strVal)<0}throw"Unknown operator"}_getCaseString(e){let t=this._filter.column,i=t?t.grid:null;return i&&i.caseSensitiveSearch?e:e.toLowerCase()}}FilterCondition._refDateTime=new Date(2e3,0,1,0,0,0);export var Operator;!function(e){e[e.EQ=0]="EQ";e[e.NE=1]="NE";e[e.GT=2]="GT";e[e.GE=3]="GE";e[e.LT=4]="LT";e[e.LE=5]="LE";e[e.BW=6]="BW";e[e.EW=7]="EW";e[e.CT=8]="CT";e[e.NC=9]="NC"}(Operator||(Operator={}));export var ValueFilterSearchKind;!function(e){e[e.Text=0]="Text";e[e.Regex=1]="Regex";e[e.Excel=2]="Excel"}(ValueFilterSearchKind||(ValueFilterSearchKind={}));export class ValueFilter{constructor(e){this._values=null;this._filterText=null;this._xValueSearch=!0;this._maxValues=250;this._uniqueValues=null;this._sortValues=!0;this._searchType=ValueFilterSearchKind.Excel;this._col=e}get searchType(){return this._searchType}set searchType(e){this._searchType=asEnum(e,ValueFilterSearchKind)}get showValues(){return this._values}set showValues(e){this._values=e}get filterText(){return this._filterText}set filterText(e){this._filterText=asString(e)}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(e){if((e=asBoolean(e))!==this._xValueSearch){this._xValueSearch=asBoolean(e);e&&(this._filterText="")}}get maxValues(){return this._maxValues}set maxValues(e){this._maxValues=asNumber(e,!1,!0)}get uniqueValues(){return this._uniqueValues}set uniqueValues(e){this._uniqueValues=asArray(e)}get sortValues(){return this._sortValues}set sortValues(e){this._sortValues=asBoolean(e)}get dataMap(){return this._map}set dataMap(e){this._map=asType(e,DataMap,!0)}get column(){return this._col}get isActive(){return null!=this._values&&Object.keys(this._values).length>0}apply(e){let t=this.column;if(!(t&&t._binding&&this._values&&Object.keys(this._values).length))return!0;e=t._binding.getValue(e);e=this.dataMap?this.dataMap.getDisplayValue(e)||"":t.dataMap?t.dataMap.getDisplayValue(e)||"":Globalize.format(e,t.format);return null!=this._values[e]}clear(){this.showValues=null;this.filterText=null}getUniqueValues(e=!0){let t=[],i=this.column,l=Globalize.format;if(this.uniqueValues){this.uniqueValues.forEach(e=>{t.push({value:e,text:l(e,i.format)})});return t}let s={},a=i.collectionView,r=a?a.sourceCollection:[];if(e&&a&&a.sourceCollection&&a.filter)try{FlexGridFilter._skipColumn=this._col;let e=[];for(let t=0;t<r.length;t++)a.filter(r[t])&&e.push(r[t]);r=e}finally{FlexGridFilter._skipColumn=null}for(let e=0;e<r.length;e++){let a=i._binding.getValue(r[e]),n=this.dataMap?this.dataMap.getDisplayValue(a)||"":i.dataMap?i.dataMap.getDisplayValue(a)||"":l(a,i.format);if(!s[n]){s[n]=!0;t.push({value:a,text:n})}}return t}implementsInterface(e){return"IColumnFilter"==e}}export class ValueFilterEditor extends Control{constructor(e,t){super(e);this._canApply=!1;this._isFiltering=!1;this.canApplyChanged=new Event;this._filter=asType(t,ValueFilter,!1);let i=this.getTemplate();this.applyTemplate("wj-control wj-valuefilter-editor",i,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values"});this._cbSelectAll.tabIndex=0;let l=culture.FlexGridFilter;setText(this._spSelectAll,l.selectAll);let s=this._view=new CollectionView(null,{sortNulls:SortNulls.First,filter:this._filterValues.bind(this)});if(t.sortValues){let e=t.column.dataMap||t.dataMap?"text":"value",i=t.column.dataType!=DataType.Boolean;s.sortDescriptions.push(new SortDescription(e,i))}s.collectionChanged.addHandler(this._updateSelectAllCheck,this);this._filterText="";this._rxFilter=null;this._cmbFilter=new input.ComboBox(this._divFilter,{isRequired:!1,placeholder:l.search});this._cmbFilter.isEditable=!0;this._lbValues=new input.ListBox(this._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:this._view,itemFormatter:(e,t)=>t||l.null,checkedItemsChanged:e=>this._updateSelectAllCheck()});setAriaLabel(this._cmbFilter.inputElement,l.ariaLabels.search);setAttribute(this._lbValues.hostElement,"aria-multiselectable",!0);this._cmbFilter.inputElement.addEventListener("input",this._filterTextChanged.bind(this));this._cbSelectAll.addEventListener("click",this._cbSelectAllClicked.bind(this));this.updateEditor();this._initialItems=this._lbValues.checkedItems}get filter(){return this._filter}get canApply(){return this._canApply}set canApply(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}}updateEditor(){let e=this._filter.column,t=this._filter.getUniqueValues(!0);this._lbValues.isContentHtml=e.isContentHtml;let i=this._filter.showValues;if(i&&0!=Object.keys(i).length){for(let e in i)for(let i=0;i<t.length;i++)if(t[i].text==e){t[i].show=!0;break}}else t.forEach(e=>e.show=!0);let l=this._filter.filterText||"",s=this._getCaseSensitive();this._cmbFilter.text=l;this._filterText=s?l:l.toLowerCase();this._rxFilter=this._getSearchExp(l,s);let a=this._view;a.pageSize=this._filter.maxValues;a.sourceCollection=t;setTimeout(()=>{this._adjustWidths()},0)}clearEditor(e=!0){this._cmbFilter.text="";this._filterText="";this._rxFilter=null;let t=this._view;t.pageSize=0;t.items.forEach(t=>{t.show=e});t.moveCurrentTo(-1);t.refresh();t.pageSize=this._filter.maxValues}get isEditorClear(){return!this._filterText&&!this._cbSelectAll.indeterminate}_updateFilter(){let e=null,t=this._getItems();if(this._filterText||this._cbSelectAll.indeterminate){e={};for(let i=0;i<t.length;i++){let l=t[i];l.show&&(e[l.text]=!0)}}let i=this._filter;i.showValues=e;i.filterText=this._filterText}updateFilter(){this._isFiltering?setTimeout(()=>{this._updateFilter()},Control._SEARCH_DELAY+100):this._updateFilter()}onCanApplyChanged(e){this.canApplyChanged.raise(this,e)}_getCaseSensitive(){let e=this._filter.column,t=e?e.grid:null;return t&&t.caseSensitiveSearch}_getItems(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection}_filterTextChanged(){""===this._filterText&&this._cbSelectAll.checked||this._filter.exclusiveValueSearch?this._lbValues._addMode=!1:this._lbValues._addMode=!0;this._toFilter&&clearTimeout(this._toFilter);this._isFiltering=!0;this._toFilter=setTimeout(()=>{let e=this._cmbFilter.text,t=this._getCaseSensitive();t||(e=e.toLowerCase());if(e!=this._filterText){this._filterText=e;this._rxFilter=this._getSearchExp(e,t);this._view.refresh();if(!e){let e=this._initialItems;if(e.length&&this._view.sourceCollection.indexOf(e[0])>-1){this._lbValues.checkedItems=this._initialItems;this._updateSelectAllCheck();this._isFiltering=!1;return}}if(this._filter.exclusiveValueSearch){this._cbSelectAll.checked=!0;this._cbSelectAllClicked()}else this._updateSelectAllCheck()}this._isFiltering=!1},Control._SEARCH_DELAY)}_getSearchExp(e,t){if(!e)return null;switch(this._filter.searchType){case ValueFilterSearchKind.Text:return this._getTextSearchExp(e,t);case ValueFilterSearchKind.Regex:return this._getRegexSearchExp(e,t);case ValueFilterSearchKind.Excel:return this._getExcelSearchExp(e,t)}}_getTextSearchExp(e,t){return new RegExp(escapeRegExp(e),t?"":"i")}_getRegexSearchExp(e,t){try{return new RegExp(e,t?"s":"is")}catch(e){return new RegExp("(?!)",t?"s":"is")}}_getExcelSearchExp(e,t){let i=e;i=(i=(i=(i=(i=i.replace(/([.+^$[\]\\(){}|-])/g,"\\$1")).replace(/(?<!~)(\?+)/g,(function(e,t){return Array.from(t).map(e=>".").join("")}))).replace(/(?<!~)(\*+)/g,(function(e,t){return Array.from(t).map(e=>".*").join("")}))).replace(/~~/g,"~")).replace(/~([?*])/g,"\\$1");/(?<!~)[?*]/g.test(e)&&(i="^"+i+"$");return new RegExp(i,t?"s":"is")}_filterValues(e){let t=this._rxFilter;return null==t||null==e||t.test(e.text)}_cbSelectAllClicked(){let e=this._cbSelectAll.checked,t=this._divValues.scrollTop,i=this._getItems();for(let t=0;t<i.length;t++)i[t].show=e;this._view.refresh();this._divValues.scrollTop=t;setTimeout(()=>{this._adjustWidths()},0)}_updateSelectAllCheck(){let e=this._getItems(),t=0,i=0;for(let l=0;l<e.length;l++){e[l].show?t++:i++;if(t&&i)break}setChecked(this._cbSelectAll,t&&i?null:t>0);this.canApply=t>0}_adjustWidths(){let e=this._lbValues.hostElement;if(e&&e.offsetHeight>0){let t=0,i=e.querySelectorAll(".wj-listbox-item label");if(i.length){for(let e=0;e<i.length;e++)t=Math.max(t,i[e].scrollWidth);if(t){let i=e.querySelectorAll(".wj-listbox-item");if(i.length){let e=i[0],l=getComputedStyle(e),s=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight);for(let e=0;e<i.length;e++)i[e].style.width=t+s+"px"}}}}}}ValueFilterEditor.controlTemplate='<div><div wj-part="div-filter"></div><div class="wj-listbox-item"><label><input wj-part="cb-select-all" type="checkbox"> <span wj-part="sp-select-all"></span></label></div><div wj-part="div-values"></div></div>';export class ColumnFilter{constructor(e,t){this._owner=e;this._col=t;this._valueFilter=new ValueFilter(t);this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch;this._conditionFilter=new ConditionFilter(t);e.exclusiveValueSearchChanged.addHandler(e=>{this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch})}get filterType(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType}set filterType(e){if((e=asEnum(e,FilterType,!0))!=this._filterType){let t=this.isActive;this.clear();this._filterType=e;t?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}}get dataMap(){return this.conditionFilter.dataMap||this.valueFilter.dataMap}set dataMap(e){this.conditionFilter.dataMap=e;this.valueFilter.dataMap=e}get valueFilter(){return this._valueFilter}get conditionFilter(){return this._conditionFilter}get column(){return this._col}get isActive(){return this._conditionFilter.isActive||this._valueFilter.isActive}apply(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)}clear(){this._valueFilter.clear();this._conditionFilter.clear()}implementsInterface(e){return"IColumnFilter"==e}}_addCultureInfo("FlexGridFilter",{ariaLabels:{edit:"Edit Filter for Column",dialog:"Filter Editor for Column",asc:"Sort Column in Ascending Order",dsc:"Sort Column in Descending Order",search:"Search Item List",op1:"First Condition Operator",val1:"First Condition Value",and:"Require both Conditions",or:"Require either Condition",op2:"Second Condition Operator",val2:"Second Condition Value"},ascending:"↑ Ascending",descending:"↓ Descending",apply:"Apply",cancel:"Cancel",clear:"Clear",conditions:"Filter by Condition",values:"Filter by Value",search:"Search",selectAll:"Select All",null:"(nothing)",header:"Show items where the value",and:"And",or:"Or",stringOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Begins with",op:Operator.BW},{name:"Ends with",op:Operator.EW},{name:"Contains",op:Operator.CT},{name:"Does not contain",op:Operator.NC}],numberOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Is Greater than",op:Operator.GT},{name:"Is Greater than or equal to",op:Operator.GE},{name:"Is Less than",op:Operator.LT},{name:"Is Less than or equal to",op:Operator.LE}],dateOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Is Before",op:Operator.LT},{name:"Is After",op:Operator.GT}],booleanOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE}]});export class ColumnFilterEditor extends Control{constructor(e,t,i=!0){super(e,null,!0);this.filterChanged=new Event;this.buttonClicked=new Event;this._filter=asType(t,ColumnFilter);let l=this.getTemplate();this.applyTemplate("wj-control wj-content wj-columnfiltereditor",l,{_divSort:"div-sort",_btnAsc:"btn-asc",_btnDsc:"btn-dsc",_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnApply:"btn-apply",_btnCancel:"btn-cancel",_btnClear:"btn-clear"});let s=culture.FlexGridFilter,a=s.ariaLabels,r=this.hostElement,n=this.filter.column,o=n.grid.collectionView;setAttribute(r,"role","dialog");setAriaLabel(r,a.dialog+" "+n.header);setAriaLabel(this._btnAsc,a.asc);setAriaLabel(this._btnDsc,a.dsc);setText(this._btnAsc,s.ascending);setText(this._btnDsc,s.descending);setText(this._aVal,s.values);setText(this._aCnd,s.conditions);setText(this._btnApply,s.apply);setText(this._btnCancel,s.cancel);setText(this._btnClear,s.clear);let d=this.filter.conditionFilter.isActive||0==(t.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;this._showFilter(d);i&&o&&o.canSort||(this._divSort.style.display="none");this._updateSortButtonState();let h=this._btnClicked.bind(this);this._btnApply.addEventListener("click",h);this._btnCancel.addEventListener("click",h);this._btnClear.addEventListener("click",h);this._btnAsc.addEventListener("click",h);this._btnDsc.addEventListener("click",h);this._aVal.addEventListener("click",h);this._aCnd.addEventListener("click",h);this.addEventListener(r,"keydown",e=>{if(!e.defaultPrevented){let t=e.target.tagName.match(/^(a|button)$/i);switch(e.keyCode){case Key.Space:if(t){this._btnClicked(e);e.preventDefault()}break;case Key.Enter:if(t)this._btnClicked(e);else{this.updateFilter();this.onFilterChanged();this.onButtonClicked()}e.preventDefault();break;case Key.Escape:this.onButtonClicked();e.preventDefault();break;case Key.Tab:moveFocus(this.hostElement,e.shiftKey?-1:1);e.preventDefault()}}});this.addEventListener(window,"resize",()=>{this.isTouching||this._wasTouching||this.onButtonClicked()})}get filter(){return this._filter}updateEditor(){this._edtVal&&this._edtVal.updateEditor();this._edtCnd&&this._edtCnd.updateEditor()}updateFilter(){switch(this._getFilterType()){case FilterType.Value:this._edtVal.updateFilter();this.filter.conditionFilter.clear();break;case FilterType.Condition:this._edtCnd.updateFilter();this.filter.valueFilter.clear()}}onFilterChanged(e){this.filterChanged.raise(this,e)}onButtonClicked(e){this.buttonClicked.raise(this,e)}_showFilter(e){this._wasTouching=this.isTouching;if(e==FilterType.Value&&null==this._edtVal){this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter);this._edtVal.canApplyChanged.addHandler(e=>{enable(this._btnApply,this._edtVal.canApply)})}if(e==FilterType.Condition&&null==this._edtCnd){this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter);this._edtCnd.canApplyChanged.addHandler(e=>{enable(this._btnApply,this._edtCnd.canApply)})}if(0!=(e&this.filter.filterType))if(e==FilterType.Value){this._divEdtVal.style.display="";this._divEdtCnd.style.display="none";this._enableLink(this._aVal,!1);this._enableLink(this._aCnd,!0);this._edtVal.focus();enable(this._btnApply,this._edtVal.canApply)}else{this._divEdtVal.style.display="none";this._divEdtCnd.style.display="";this._enableLink(this._aVal,!0);this._enableLink(this._aCnd,!1);this._edtCnd.focus();enable(this._btnApply,this._edtCnd.canApply)}let t=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:t.display="none";break;default:t.display=""}}_enableLink(e,t){toggleClass(e,"wj-state-disabled",!t);setAttribute(e,"href",t?"":null);setAttribute(e,"disabled",t?null:"disabled")}_updateSortButtonState(){let e=this.filter.column,t=e?e.currentSort:"",i="wj-state-active";toggleClass(this._btnAsc,i,"+"==t);toggleClass(this._btnDsc,i,"-"==t)}_getFilterType(){let e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition}_btnClicked(e){let t=e.target;e.preventDefault();e.stopPropagation();if(!hasClass(t,"wj-state-disabled"))if(t!=this._aVal)if(t!=this._aCnd){if(t==this._btnAsc||t==this._btnDsc){let t=this.filter.column,i=t.sortMemberPath||t.binding,l=t.grid.collectionView.sortDescriptions;l.deferUpdate(()=>{l.clear();l.push(new SortDescription(i,e.target==this._btnAsc))});this._updateSortButtonState()}if(t==this._btnApply){this.updateFilter();this.onFilterChanged()}else if(t==this._btnClear){if(this.filter.isActive){this.filter.clear();this.onFilterChanged()}}else this.updateEditor();this.onButtonClicked()}else{this._showFilter(FilterType.Condition);moveFocus(this._edtCnd.hostElement,0)}else{this._showFilter(FilterType.Value);moveFocus(this._edtVal.hostElement,0)}}}ColumnFilterEditor.controlTemplate='<div><div wj-part="div-sort" class="wj-sort-buttons"><button wj-part="btn-asc" class="wj-btn"></button>&nbsp;&nbsp;&nbsp;<button wj-part="btn-dsc" class="wj-btn"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a>&nbsp;|&nbsp;<a wj-part="a-val" href="" draggable="false"></a></div><div wj-part="div-edt-val" tabindex="-1"></div><div wj-part="div-edt-cnd" tabindex="-1"></div><div style="text-align:right;margin-top:10px"><button wj-part="btn-apply" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-cancel" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-clear" class="wj-btn"></button></div></div>';_registerModule("wijmo.grid.filter",selfModule);
import{Column,DataMap,FlexGrid,DataMapEditor,CellRange,CellRangeEventArgs,_NewRowTemplate}from"@grapecity/wijmo.grid";import{Globalize,asString,asNumber,asArray,asBoolean,asType,asEnum,isString,isDate,DateTime,culture,isNumber,copy,changeType,setAttribute,showPopup,hidePopup,isFunction,createElement,toggleClass,removeClass,closestClass,setAriaLabel,Control,Event,DataType,Key,CollectionView,setText,escapeRegExp,setChecked,SortDescription,SortNulls,getUniqueId,_addCultureInfo,enable,moveFocus,hasClass,_registerModule}from"@grapecity/wijmo";import{DropDown}from"@grapecity/wijmo.input";import*as input from"@grapecity/wijmo.input";import*as selfModule from"@grapecity/wijmo.grid.filter";export var FilterType;!function(e){e[e.None=0]="None";e[e.Condition=1]="Condition";e[e.Value=2]="Value";e[e.Both=3]="Both"}(FilterType||(FilterType={}));export class FlexGridFilter{constructor(e,t){this._showIcons=!0;this._showSort=!0;this._defFilterType=FilterType.Both;this._xValueSearch=!0;this._includeUpdatedRowsInFilter=!1;this.filterApplied=new Event;this.editingFilter=new Event;this.filterChanging=new Event;this.filterChanged=new Event;this.exclusiveValueSearchChanged=new Event;this._filters=[];this._g=asType(e,FlexGrid,!1);this._g.formatItem.addHandler(this._formatItem.bind(this));this._g.itemsSourceChanged.addHandler(this.clear.bind(this));let i=this._g.hostElement;e.addEventListener(i,"mousedown",this._mousedown.bind(this),!0);e.addEventListener(i,"click",this._click.bind(this),!0);e.addEventListener(i,"keydown",this._keydown.bind(this),!0);this._g.invalidate();copy(this,t);this._init()}_init(){const e=this.grid,_excludeRowFromFilter=e=>{let t=this.grid;const i=this.excludedRowsSet;t.itemsSource?t.rows[e]instanceof _NewRowTemplate?i.add(t.editableCollectionView.currentAddItem||t.rows[e].dataItem):i.add(t.rows[e].dataItem):i.add(t.rows[e])};e.rowChanged&&e.rowChanged.addHandler((e,t)=>{t.added&&_excludeRowFromFilter(t.index)});e.rowEditEnding.addHandler((e,t)=>{_excludeRowFromFilter(t.row)});e.cellEditEnded.addHandler((e,t)=>{_excludeRowFromFilter(t.row)})}get excludedRowsSet(){let e=this.grid;e.selectedSheet&&(e=e.selectedSheet);e._newAddedRowsSet||(e._newAddedRowsSet=new WeakSet);return e._newAddedRowsSet}set excludedRowsSet(e){let t=this.grid;t.selectedSheet&&(t=t.selectedSheet);t._newAddedRowsSet=e}get grid(){return this._g}get filterColumns(){return this._filterColumns}set filterColumns(e){this._filterColumns=asArray(e);this.clear()}get showFilterIcons(){return this._showIcons}set showFilterIcons(e){if(e!=this.showFilterIcons){this._showIcons=asBoolean(e);this._g&&this._g.invalidate()}}get showSortButtons(){return this._showSort}set showSortButtons(e){this._showSort=asBoolean(e)}get reApplyFilterOnUpdate(){return this._includeUpdatedRowsInFilter}set reApplyFilterOnUpdate(e){e!==this._includeUpdatedRowsInFilter&&(this._includeUpdatedRowsInFilter=asBoolean(e))}getColumnFilter(e,t=!0){if(e=this._asColumn(e)){for(let t=0;t<this._filters.length;t++)if(this._filters[t].column==e)return this._filters[t];if(t&&e.binding){let t=new ColumnFilter(this,e);this._filters.push(t);return t}}return null}get defaultFilterType(){return this._defFilterType}set defaultFilterType(e){if((e=asEnum(e,FilterType,!1))!=this.defaultFilterType){this._defFilterType=e;this._g.invalidate();this.clear()}}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(e){if((e=asBoolean(e))!==this._xValueSearch){this._xValueSearch=e;this.onExclusiveValueSearchChanged()}}get filterDefinition(){let e={defaultFilterType:this.defaultFilterType,filters:[]};this._filters.forEach(t=>{let i=t.conditionFilter,l=t.valueFilter,s=l.uniqueValues&&l.uniqueValues.length;if(t&&t.column&&t.column.binding&&(t.isActive||s||t.filterType!=this.defaultFilterType)){let a={binding:t.column.binding};if(i.isActive){let e=i.condition1,l=i.condition2;a={binding:t.column.binding,type:"condition",condition1:{operator:e.operator,value:e.value},and:i.and,condition2:{operator:l.operator,value:l.value}}}else(l.isActive||s)&&(a={binding:t.column.binding,type:"value",uniqueValues:l.uniqueValues,sortValues:l.sortValues,maxValues:l.maxValues,exclusiveValueSearch:l.exclusiveValueSearch,showValues:l.showValues});t.filterType!=this.defaultFilterType&&(a.filterType=t.filterType);e.filters.push(a)}});return JSON.stringify(e)}set filterDefinition(e){e=asString(e);this.clear();if(e){let t=JSON.parse(e);this.defaultFilterType=t.defaultFilterType;for(let e=0;e<t.filters.length;e++){let i=t.filters[e],l=this._asColumn(i.binding);l||(l=new Column({binding:i.binding}));let s=this.getColumnFilter(l,!0);if(s){null!=i.filterType&&(s.filterType=asEnum(i.filterType,FilterType));switch(i.type){case"condition":let e=s.conditionFilter;e.condition1.value=l.dataType==DataType.Date?changeType(i.condition1.value,l.dataType,null):i.condition1.value;e.condition1.operator=i.condition1.operator;e.and=i.and;e.condition2.value=l.dataType==DataType.Date?changeType(i.condition2.value,l.dataType,null):i.condition2.value;e.condition2.operator=i.condition2.operator;break;case"value":let t=s.valueFilter;t.uniqueValues=i.uniqueValues;["sortValues","maxValues","exclusiveValueSearch"].forEach(e=>{null!=i[e]&&(t[e]=i[e])});t.showValues=i.showValues}}}}this.apply()}get activeEditor(){return Control.getControl(this._divEdt)}editColumnFilter(e,t,i){let l=this._g;this.closeEditor();e=this._asColumn(e);let s=new CellRangeEventArgs(l.cells,new CellRange(-1,e.index));if(!this.onEditingFilter(s))return;let a=createElement('<div class="wj-dropdown-panel"></div>'),r=this.getColumnFilter(e),n=new ColumnFilterEditor(a,r,this.showSortButtons);this._divEdt=a;this._edtCol=e;l.rightToLeft&&(a.dir="rtl");if(!this.onFilterChanging(s)){this._divEdt=this._edtCol=null;return}s.cancel=!0;n.filterChanged.addHandler(()=>{s.cancel=!1;setTimeout(()=>{if(!s.cancel){this.excludedRowsSet=null;this.apply()}},n._edtVal&&n._edtVal._isFiltering?Control._SEARCH_DELAY+200:0)});n.buttonClicked.addHandler(()=>{this.closeEditor();l.focus();this.onFilterChanged(s)});n.lostFocus.addHandler(()=>{setTimeout(()=>{let e=Control.getControl(this._divEdt);e&&!e.containsFocus()&&this.closeEditor()},10)});let o=t?t.col:e.index,d=l.columns[o];t||d&&d.binding==e.binding||(o=l.selection.leftCol);l._edtHdl._commitRowEdits();l.scrollIntoView(-1,o,!0);let h=l.columnHeaders,u=t&&t.panel&&h&&t.panel._uid==h._uid?t.row:h.rows.length-1,c=o,p=i||h.getCellElement(u,c),_=p?null:h.getCellBoundingRect(u,c);p?showPopup(a,p,!1,!1,!1):showPopup(a,_);this._setAriaExpanded(p,!0);this._setAriaExpanded(l.cells.getCellElement(-1,c),!0);let g=n.hostElement.querySelectorAll("input");for(let e=0;e<g.length;e++){let t=g[e];if(t.offsetHeight>0&&t.tabIndex>-1&&!t.disabled){t.focus();break}}n.containsFocus()||n.focus()}_setAriaExpanded(e,t){if(e){var i=e.querySelector("."+FlexGridFilter._WJC_FILTER);setAttribute(i,"aria-expanded",t)}}closeEditor(){let e=this._g,t=Control.getControl(this._divEdt),i=this._edtCol;t&&hidePopup(t.hostElement,()=>{t.dispose()});if(i){let t=e.columnHeaders,l=t.rows.length?t.getCellElement(t.rows.length-1,i.index):null;this._setAriaExpanded(l,!1);l=e.cells.getCellElement(-1,i.index);this._setAriaExpanded(l,!1)}this._divEdt=null;this._edtCol=null}apply(){let e=this._g.collectionView;if(e){let t=this._g.editableCollectionView;if(t){t.commitEdit();t.commitNew()}e.filter=this._filter.bind(this)}let t=e?e.updateFilterDefinition:null;isFunction(t)&&t.call(e,this);this.onFilterApplied()}clear(){if(this._filters.length){this._filters=[];this.apply()}}onFilterApplied(e){this.filterApplied.raise(this,e)}onEditingFilter(e){this.editingFilter.raise(this,e);return!e.cancel}onFilterChanging(e){this.filterChanging.raise(this,e);return!e.cancel}onFilterChanged(e){this.filterChanged.raise(this,e)}onExclusiveValueSearchChanged(e){this.exclusiveValueSearchChanged.raise(this,e)}_asColumn(e){return isString(e)?this._g.getColumn(e,!0):isNumber(e)?this._g.columns[e]:asType(e,Column,!1)}_filter(e){const t=this.excludedRowsSet;if(!this.reApplyFilterOnUpdate&&t.has(e))return!0;let i=this._filters;for(let t=0;t<i.length;t++){let l=i[t];if(l.column!=FlexGridFilter._skipColumn&&!l.apply(e))return!1}return!0}_formatItem(e,t){if(t.panel==e.columnHeaders){let e=this._g,i=e.getMergedRange(t.panel,t.row,t.col)||new CellRange(t.row,t.col),l=e.columns[i.col],s=e._getBindingColumn(t.panel,t.row,l),a=t.cell;if(i.row2==t.panel.rows.length-1||l!=s){let i=this.getColumnFilter(s,this.defaultFilterType!=FilterType.None),r=this._filterColumns;r&&r.length&&r.indexOf(s.binding)<0&&r.indexOf(s.name)<0&&(i=null);if(i){toggleClass(a,"wj-filter-on",i.isActive);toggleClass(a,"wj-filter-off",!i.isActive)}else{removeClass(a,"wj-filter-on");removeClass(a,"wj-filter-off")}if(i&&i.filterType!=FilterType.None){this._showIcons&&this._addFilterButton(s,i,a);0==t.row&&(a=e.cells.getCellElement(-1,t.col))&&this._addFilterButton(l,i,a)}}}}_addFilterButton(e,t,i){let l=FlexGridFilter._WJC_FILTER,s=createElement('<button class="wj-btn wj-btn-glyph wj-right '+l+'" type="button" tabindex="-1"><span class="wj-glyph-filter"></span></button>');setAriaLabel(s,culture.FlexGridFilter.ariaLabels.edit+" "+e.header);setAttribute(s,"aria-haspopup","dialog");setAttribute(s,"aria-expanded",!1);setAttribute(s,"aria-describedby",e.describedById);setAttribute(s,"aria-pressed",t.isActive);if(!i.querySelector("."+l)){1==i.children.length&&(i=i.querySelector("div")||i);i.insertBefore(s,i.firstChild)}}_mousedown(e){this._edtColPrev=this._edtCol}_click(e){if(this._toggleEditor(e)){e.stopPropagation();e.preventDefault()}}_toggleEditor(e){if(!e.defaultPrevented&&0==e.button)if(closestClass(e.target,FlexGridFilter._WJC_FILTER)){let t=this._g,i=t.hitTest(e.target);i.panel||(i=t.hitTest(e));if(i.panel&&t.columnHeaders&&t.cells&&(i.panel._uid==t.columnHeaders._uid||i.panel._uid==t.cells._uid&&-1==i.row)){let e=t.getMergedRange(i.panel,i.row,i.col)||new CellRange(i.row,i.col),l=t.columns[e.col],s=t._getBindingColumn(i.panel,i.row,l);if(this._divEdt&&this._edtCol==s){this.closeEditor();t.focus()}else s!=this._edtColPrev&&setTimeout(()=>{this.editColumnFilter(s,i)},this._divEdt?100:0);return!0}}else this.closeEditor();return!1}_keydown(e){if(!e.defaultPrevented&&!e.ctrlKey&&e.altKey&&(e.keyCode==Key.Down||e.keyCode==Key.Up)){let t=this.grid,i=t.selection,l=i.col>-1?t.columns[i.col]:null,s=l?t._getBindingColumn(t.cells,i.row,l):null,a=s&&s.dataMap&&s.dataMapEditor==DataMapEditor.DropDownList;if(this.filterColumns&&this.filterColumns.length>0&&!this.filterColumns.includes(s._binding._path)){e.preventDefault();return!1}s&&s.editor instanceof DropDown&&(a=!0);if(s&&!a){let t=this.getColumnFilter(s,!1);if(t&&t.filterType!=FilterType.None){this.editColumnFilter(s);e.preventDefault();e.stopPropagation()}}}}}FlexGridFilter._WJC_FILTER="wj-elem-filter";export const empty={};export class ConditionFilter{constructor(e){this._c1=new FilterCondition(this);this._c2=new FilterCondition(this);this._and=!0;this._col=e}get condition1(){return this._c1}get condition2(){return this._c2}get and(){return this._and}set and(e){this._and=asBoolean(e)}get dataMap(){return this._map}set dataMap(e){this._map=asType(e,DataMap,!0)}get column(){return this._col}get isActive(){return this._c1.isActive||this._c2.isActive}apply(e){let t=this._col,i=this._c1,l=this._c2,s=!1,a=!1;if(!t||!t._binding||!this.isActive)return!0;e=t._binding.getValue(e);let r=this.dataMap||t.dataMap;if(r)e=r.getDisplayValue(e);else if(isDate(e)){s=!this._hasTimePart();a=!this._hasDatePart();let t=FilterCondition._refDateTime;s?e=DateTime.fromDateTime(e,t):a&&(e=DateTime.fromDateTime(t,e))}else if(isNumber(e)){let i=Globalize,l=t.format,s=i.formatNumber(e,l);e=i.parseFloat(s,l)}let n=i.apply(e,s,a),o=l.apply(e,s,a);return i.isActive&&l.isActive?this._and?n&&o:n||o:i.isActive?n:!l.isActive||o}clear(){this._c1.clear();this._c2.clear();this.and=!0}_hasDatePart(){let e=this._col.format;if(!e)return!0;e=culture.Globalize.calendar.patterns[e]||e;return/[yMd]+/.test(e)}_hasTimePart(){let e=this._col.format;if(!e)return!1;e=culture.Globalize.calendar.patterns[e]||e;return/[Hmst]+/.test(e)}implementsInterface(e){return"IColumnFilter"==e}}export class ConditionFilterEditor extends Control{constructor(e,t){super(e);this._canApply=!1;this.canApplyChanged=new Event;this._filter=asType(t,ConditionFilter,!1);let i=this.getTemplate();this.applyTemplate("wj-control wj-conditionfilter-editor",i,{_divHdr:"div-hdr",_divCmb1:"div-cmb1",_divVal1:"div-val1",_btnAnd:"btn-and",_btnOr:"btn-or",_spAnd:"sp-and",_spOr:"sp-or",_divCmb2:"div-cmb2",_divVal2:"div-val2"});let l=culture.FlexGridFilter,s=l.ariaLabels;setAriaLabel(this._btnAnd,s.and);setAriaLabel(this._btnOr,s.or);setText(this._divHdr,l.header);setText(this._spAnd,l.and);setText(this._spOr,l.or);const a=getUniqueId("cmb1");this._divHdr.htmlFor=a;this._divCmb1.id=a;this._cmb1=this._createOperatorCombo(this._divCmb1,s.op1);this._cmb2=this._createOperatorCombo(this._divCmb2,s.op2);this._val1=this._createValueInput(this._divVal1,s.val1);this._val2=this._createValueInput(this._divVal2,s.val2);this._val1.isDisabled=!0;this._cmb1.selectedIndexChanged.addHandler((e,t)=>{this._val1.isDisabled=null==e.selectedValue;this.canApply=!this._val1.isDisabled||!this._val2.isDisabled});this._val2.isDisabled=!0;this._cmb2.selectedIndexChanged.addHandler((e,t)=>{this._val2.isDisabled=null==e.selectedValue;this.canApply=!this._val1.isDisabled||!this._val2.isDisabled});let r=this.hostElement;this.addEventListener(r,"change",this._btnAndOrChanged.bind(this));this.addEventListener(r,"keydown",this._keydown.bind(this));setTimeout(()=>{this.updateEditor()})}get filter(){return this._filter}get canApply(){return this._canApply}set canApply(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}}updateEditor(){let e=this._filter.condition1,t=this._filter.condition2;this._cmb1.selectedValue=e.operator;this._cmb2.selectedValue=t.operator;if(this._val1 instanceof input.ComboBox&&!(this._val1 instanceof input.InputTime)){this._val1.text=changeType(e.value,DataType.String);this._val2.text=changeType(t.value,DataType.String)}else{this._val1.value=e.value;this._val2.value=t.value}let i=this._filter.and;this._checkRadio(this._btnAnd,i);this._checkRadio(this._btnOr,!i)}clearEditor(){this._cmb1.selectedValue=this._cmb2.selectedValue=null;this._val1.text=this._val2.text=null;this._checkRadio(this._btnAnd,!0);this._checkRadio(this._btnOr,!1)}get isEditorClear(){return null==this._cmb1.selectedValue&&!this._val1.text&&null==this._cmb2.selectedValue&&!this._val2.text}updateFilter(){let e=this._filter.condition1,t=this._filter.condition2;e.operator=this._cmb1.selectedValue;t.operator=this._cmb2.selectedValue;if("value"in this._val1){e.value=this._val1.value;t.value=this._val2.value}else{e.value=this._getComboValue(this._val1);t.value=this._getComboValue(this._val2)}this._filter.and=this._btnAnd.checked}onCanApplyChanged(e){this.canApplyChanged.raise(this,e)}_getComboValue(e){return e.selectedIndex>-1?e.selectedValue:e.text}_createOperatorCombo(e,t){let i=this._filter.column,l=culture.FlexGridFilter,s=l.stringOperators,a=DataType;this._filter.dataMap||i.dataMap||(i.dataType==a.Date?s=l.dateOperators:i.dataType==a.Number?s=l.numberOperators:i.dataType==a.Boolean&&(s=l.booleanOperators));let r=new input.ComboBox(e,{itemsSource:s,displayMemberPath:"name",selectedValuePath:"op"});setAriaLabel(r.inputElement,t);return r}_createValueInput(e,t){let i=this._filter,l=i.column,s=i.dataMap||l.dataMap,a=null,r=DataType;if(l.dataType==r.Date)(a=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(e):new input.InputDate(e):new input.InputTime(e)).format=l.format;else if(l.dataType!=r.Number||s){(a=new input.ComboBox(e)).isEditable=!0;if(s){a.itemsSource=s.getDisplayValues();a.caseSensitiveSearch=!!l.grid&&l.grid.caseSensitiveSearch}else l.dataType==r.Boolean&&(a.itemsSource=[!0,!1])}else(a=new input.InputNumber(e)).format=l.format;a.isRequired=!1;setAriaLabel(a.inputElement,t);return a}_btnAndOrChanged(e){let t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i){this._checkRadio(this._btnAnd,t);this._checkRadio(this._btnOr,i)}}_checkRadio(e,t){e.checked=t;setAttribute(e,"aria-checked",t.toString());setAttribute(e,"tabindex",t?null:"-1")}_keydown(e){let t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i)switch(e.keyCode){case Key.Left:case Key.Right:case Key.Up:case Key.Down:let i=t?this._btnOr:this._btnAnd;i.click();i.focus();e.preventDefault()}}}ConditionFilterEditor.controlTemplate='<div><label wj-part="div-hdr"></label><div wj-part="div-cmb1"></div><br/><div wj-part="div-val1"></div><br/><div role="radiogroup" style="text-align:center"><label><input wj-part="btn-and" type="radio" role="radio"> <span wj-part="sp-and"></span> </label>&nbsp;&nbsp;&nbsp;<label><input wj-part="btn-or" type="radio" role="radio"> <span wj-part="sp-or"></span> </label></div><div wj-part="div-cmb2"></div><br/><div wj-part="div-val2"></div><br/></div>';export class FilterCondition{constructor(e){this._op=null;this._filter=e}get operator(){return this._op}set operator(e){this._op=asEnum(e,Operator,!0)}get value(){return this._val}set value(e){this._val=e;this._strVal=isString(e)?this._getCaseString(e):null}get isActive(){switch(this._op){case null:return!1;case Operator.EQ:case Operator.NE:return!0;default:return null!=this._val||null!=this._strVal}}clear(){this.operator=null;this.value=null}apply(e,t,i){let l=this._strVal||this._val;isString(e)&&(e=this._getCaseString(e));isString(l)&&null==e&&(e="");isDate(l)&&(t?l=DateTime.fromDateTime(l,FilterCondition._refDateTime):i&&(l=DateTime.fromDateTime(FilterCondition._refDateTime,l)));let s=Operator;switch(this._op){case null:return!0;case s.EQ:return null!=e&&null!=l?e.valueOf()==l.valueOf():e==l;case s.NE:return null!=e&&null!=l?e.valueOf()!=l.valueOf():e!=l;case s.GT:return e>l;case s.GE:return e>=l;case s.LT:return e<l;case s.LE:return e<=l;case s.BW:return!(null==this._strVal||!isString(e))&&0==e.indexOf(this._strVal);case s.EW:return!!(null!=this._strVal&&isString(e)&&e.length>=this._strVal.length)&&e.substr(e.length-this._strVal.length)==l;case s.CT:return!(null==this._strVal||!isString(e))&&e.indexOf(this._strVal)>-1;case s.NC:return!(null==this._strVal||!isString(e))&&e.indexOf(this._strVal)<0}throw"Unknown operator"}_getCaseString(e){let t=this._filter.column,i=t?t.grid:null;return i&&i.caseSensitiveSearch?e:e.toLowerCase()}}FilterCondition._refDateTime=new Date(2e3,0,1,0,0,0);export var Operator;!function(e){e[e.EQ=0]="EQ";e[e.NE=1]="NE";e[e.GT=2]="GT";e[e.GE=3]="GE";e[e.LT=4]="LT";e[e.LE=5]="LE";e[e.BW=6]="BW";e[e.EW=7]="EW";e[e.CT=8]="CT";e[e.NC=9]="NC"}(Operator||(Operator={}));export var ValueFilterSearchKind;!function(e){e[e.Text=0]="Text";e[e.Regex=1]="Regex";e[e.Excel=2]="Excel"}(ValueFilterSearchKind||(ValueFilterSearchKind={}));export class ValueFilter{constructor(e){this._values=null;this._filterText=null;this._xValueSearch=!0;this._maxValues=250;this._uniqueValues=null;this._sortValues=!0;this._searchType=ValueFilterSearchKind.Excel;this._exceedsMaxValues=!1;this._col=e}get searchType(){return this._searchType}set searchType(e){this._searchType=asEnum(e,ValueFilterSearchKind)}get showValues(){return this._values}set showValues(e){this._values=e}get filterText(){return this._filterText}set filterText(e){this._filterText=asString(e)}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(e){if((e=asBoolean(e))!==this._xValueSearch){this._xValueSearch=asBoolean(e);e&&(this._filterText="")}}get maxValues(){return this._maxValues}set maxValues(e){this._maxValues=asNumber(e,!1,!0)}get uniqueValues(){return this._uniqueValues}set uniqueValues(e){this._uniqueValues=asArray(e)}get sortValues(){return this._sortValues}set sortValues(e){this._sortValues=asBoolean(e)}get dataMap(){return this._map}set dataMap(e){this._map=asType(e,DataMap,!0)}get column(){return this._col}get isActive(){return null!=this._values&&Object.keys(this._values).length>0}apply(e){let t=this.column;if(!(t&&t._binding&&this._values&&Object.keys(this._values).length))return!0;e=t._binding.getValue(e);e=this.dataMap?this.dataMap.getDisplayValue(e)||"":t.dataMap?t.dataMap.getDisplayValue(e)||"":Globalize.format(e,t.format);return null!=this._values[e]}clear(){this.showValues=null;this.filterText=null}getUniqueValues(e=!0){let t=[],i=this.column,l=Globalize.format;if(this.uniqueValues){this.uniqueValues.forEach(e=>{t.push({value:e,text:l(e,i.format)})});return t}let s={},a=i.collectionView,r=a?a.sourceCollection:[];if(e&&a&&a.sourceCollection&&a.filter)try{FlexGridFilter._skipColumn=this._col;let e=[];for(let t=0;t<r.length;t++)a.filter(r[t])&&e.push(r[t]);r=e}finally{FlexGridFilter._skipColumn=null}for(let e=0;e<r.length;e++){let a=i._binding.getValue(r[e]),n=this.dataMap?this.dataMap.getDisplayValue(a)||"":i.dataMap?i.dataMap.getDisplayValue(a)||"":l(a,i.format);if(!s[n]){s[n]=!0;t.push({value:a,text:n})}}this._exceedsMaxValues=t.length>this._maxValues;return t}get exceedsMaxValues(){return this._exceedsMaxValues}implementsInterface(e){return"IColumnFilter"==e}}export class ValueFilterEditor extends Control{constructor(e,t){super(e);this._canApply=!1;this._isFiltering=!1;this.canApplyChanged=new Event;this._filter=asType(t,ValueFilter,!1);let i=this.getTemplate();this.applyTemplate("wj-control wj-valuefilter-editor",i,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values",_warning:"warning-message"});this._cbSelectAll.tabIndex=0;let l=culture.FlexGridFilter;setText(this._spSelectAll,l.selectAll);let s=this._view=new CollectionView(null,{sortNulls:SortNulls.First,filter:this._filterValues.bind(this)});if(t.sortValues){let e=t.column.dataMap||t.dataMap?"text":"value",i=t.column.dataType!=DataType.Boolean;s.sortDescriptions.push(new SortDescription(e,i))}s.collectionChanged.addHandler(this._updateSelectAllCheck,this);this._filterText="";this._rxFilter=null;this._cmbFilter=new input.ComboBox(this._divFilter,{isRequired:!1,placeholder:l.search});this._cmbFilter.isEditable=!0;this._lbValues=new input.ListBox(this._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:this._view,itemFormatter:(e,t)=>t||l.null,checkedItemsChanged:e=>this._updateSelectAllCheck()});setAriaLabel(this._cmbFilter.inputElement,l.ariaLabels.search);setAttribute(this._lbValues.hostElement,"aria-multiselectable",!0);this._cmbFilter.inputElement.addEventListener("input",this._filterTextChanged.bind(this));this._cbSelectAll.addEventListener("click",this._cbSelectAllClicked.bind(this));this._warning.addEventListener("click",()=>this._showModal());this._modal=this._createModal();document.body.appendChild(this._modal);this.updateEditor();this._initialItems=this._lbValues.checkedItems}get filter(){return this._filter}get canApply(){return this._canApply}set canApply(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}}updateEditor(){let e=this._filter.column,t=this._filter.getUniqueValues(!0);this._lbValues.isContentHtml=e.isContentHtml;let i=this._filter.showValues;if(i&&0!=Object.keys(i).length){for(let e in i)for(let i=0;i<t.length;i++)if(t[i].text==e){t[i].show=!0;break}}else t.forEach(e=>e.show=!0);this._warning.style.display=this._filter.exceedsMaxValues?"block":"none";let l=this._filter.filterText||"",s=this._getCaseSensitive();this._cmbFilter.text=l;this._filterText=s?l:l.toLowerCase();this._rxFilter=this._getSearchExp(l,s);let a=this._view;a.pageSize=this._filter.maxValues;a.sourceCollection=t;setTimeout(()=>{this._adjustWidths()},0)}clearEditor(e=!0){this._cmbFilter.text="";this._filterText="";this._rxFilter=null;let t=this._view;t.pageSize=0;t.items.forEach(t=>{t.show=e});t.moveCurrentTo(-1);t.refresh();t.pageSize=this._filter.maxValues}get isEditorClear(){return!this._filterText&&!this._cbSelectAll.indeterminate}_updateFilter(){let e=null,t=this._getItems();if(this._filterText||this._cbSelectAll.indeterminate){e={};for(let i=0;i<t.length;i++){let l=t[i];l.show&&(e[l.text]=!0)}}let i=this._filter;i.showValues=e;i.filterText=this._filterText}updateFilter(){this._isFiltering?setTimeout(()=>{this._updateFilter()},Control._SEARCH_DELAY+100):this._updateFilter()}onCanApplyChanged(e){this.canApplyChanged.raise(this,e)}_getCaseSensitive(){let e=this._filter.column,t=e?e.grid:null;return t&&t.caseSensitiveSearch}_getItems(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection}_filterTextChanged(){""===this._filterText&&this._cbSelectAll.checked||this._filter.exclusiveValueSearch?this._lbValues._addMode=!1:this._lbValues._addMode=!0;this._toFilter&&clearTimeout(this._toFilter);this._isFiltering=!0;this._toFilter=setTimeout(()=>{let e=this._cmbFilter.text,t=this._getCaseSensitive();t||(e=e.toLowerCase());if(e!=this._filterText){this._filterText=e;this._rxFilter=this._getSearchExp(e,t);this._view.refresh();if(!e){let e=this._initialItems;if(e.length&&this._view.sourceCollection.indexOf(e[0])>-1){this._lbValues.checkedItems=this._initialItems;this._updateSelectAllCheck();this._isFiltering=!1;return}}if(this._filter.exclusiveValueSearch){this._cbSelectAll.checked=!0;this._cbSelectAllClicked()}else this._updateSelectAllCheck()}this._isFiltering=!1},Control._SEARCH_DELAY)}_getSearchExp(e,t){if(!e)return null;switch(this._filter.searchType){case ValueFilterSearchKind.Text:return this._getTextSearchExp(e,t);case ValueFilterSearchKind.Regex:return this._getRegexSearchExp(e,t);case ValueFilterSearchKind.Excel:return this._getExcelSearchExp(e,t)}}_getTextSearchExp(e,t){return new RegExp(escapeRegExp(e),t?"":"i")}_getRegexSearchExp(e,t){try{return new RegExp(e,t?"s":"is")}catch(e){return new RegExp("(?!)",t?"s":"is")}}_getExcelSearchExp(e,t){let i=e;i=(i=(i=(i=(i=i.replace(/([.+^$[\]\\(){}|-])/g,"\\$1")).replace(/(?<!~)(\?+)/g,(function(e,t){return Array.from(t).map(e=>".").join("")}))).replace(/(?<!~)(\*+)/g,(function(e,t){return Array.from(t).map(e=>".*").join("")}))).replace(/~~/g,"~")).replace(/~([?*])/g,"\\$1");/(?<!~)[?*]/g.test(e)&&(i="^"+i+"$");return new RegExp(i,t?"s":"is")}_filterValues(e){let t=this._rxFilter;return null==t||null==e||t.test(e.text)}_cbSelectAllClicked(){let e=this._cbSelectAll.checked,t=this._divValues.scrollTop,i=this._getItems();for(let t=0;t<i.length;t++)i[t].show=e;this._view.refresh();this._divValues.scrollTop=t;setTimeout(()=>{this._adjustWidths()},0)}_updateSelectAllCheck(){let e=this._getItems(),t=0,i=0;for(let l=0;l<e.length;l++){e[l].show?t++:i++;if(t&&i)break}setChecked(this._cbSelectAll,t&&i?null:t>0);this.canApply=t>0}_adjustWidths(){let e=this._lbValues.hostElement;if(e&&e.offsetHeight>0){let t=0,i=e.querySelectorAll(".wj-listbox-item label");if(i.length){for(let e=0;e<i.length;e++)t=Math.max(t,i[e].scrollWidth);if(t){let i=e.querySelectorAll(".wj-listbox-item");if(i.length){let e=i[0],l=getComputedStyle(e),s=parseFloat(l.paddingLeft)+parseFloat(l.paddingRight);for(let e=0;e<i.length;e++)i[e].style.width=t+s+"px"}}}}}_createModal(){const e=this._filter.maxValues,t=document.createElement("div");t.className="modal";t.innerHTML='<div class="modal-content"><span class="close">&times;</span><p>This column has more than '+e+" unique items. Only the first "+e+" unique items are displayed. Please set the maxValues property of the ValueFilter to see all the values on the list.</p></div>";t.querySelector(".close").addEventListener("click",()=>this._modal.style.display="none");return t}_showModal(){this._modal.style.display="block";this.hostElement.style.display="none"}}ValueFilterEditor.controlTemplate='<div><div wj-part="div-filter"></div><div class="wj-listbox-item"><label><input wj-part="cb-select-all" type="checkbox"> <span wj-part="sp-select-all"></span></label></div><div wj-part="div-values"></div><div wj-part="warning-message" style="display: none;">Not all items are shown</div></div>';export class ColumnFilter{constructor(e,t){this._owner=e;this._col=t;this._valueFilter=new ValueFilter(t);this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch;this._conditionFilter=new ConditionFilter(t);e.exclusiveValueSearchChanged.addHandler(e=>{this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch})}get filterType(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType}set filterType(e){if((e=asEnum(e,FilterType,!0))!=this._filterType){let t=this.isActive;this.clear();this._filterType=e;t?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}}get dataMap(){return this.conditionFilter.dataMap||this.valueFilter.dataMap}set dataMap(e){this.conditionFilter.dataMap=e;this.valueFilter.dataMap=e}get valueFilter(){return this._valueFilter}get conditionFilter(){return this._conditionFilter}get column(){return this._col}get isActive(){return this._conditionFilter.isActive||this._valueFilter.isActive}apply(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)}clear(){this._valueFilter.clear();this._conditionFilter.clear()}implementsInterface(e){return"IColumnFilter"==e}}_addCultureInfo("FlexGridFilter",{ariaLabels:{edit:"Edit Filter for Column",dialog:"Filter Editor for Column",asc:"Sort Column in Ascending Order",dsc:"Sort Column in Descending Order",search:"Search Item List",op1:"First Condition Operator",val1:"First Condition Value",and:"Require both Conditions",or:"Require either Condition",op2:"Second Condition Operator",val2:"Second Condition Value"},ascending:"↑ Ascending",descending:"↓ Descending",apply:"Apply",cancel:"Cancel",clear:"Clear",conditions:"Filter by Condition",values:"Filter by Value",search:"Search",selectAll:"Select All",null:"(nothing)",header:"Show items where the value",and:"And",or:"Or",stringOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Begins with",op:Operator.BW},{name:"Ends with",op:Operator.EW},{name:"Contains",op:Operator.CT},{name:"Does not contain",op:Operator.NC}],numberOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Is Greater than",op:Operator.GT},{name:"Is Greater than or equal to",op:Operator.GE},{name:"Is Less than",op:Operator.LT},{name:"Is Less than or equal to",op:Operator.LE}],dateOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Is Before",op:Operator.LT},{name:"Is After",op:Operator.GT}],booleanOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE}]});export class ColumnFilterEditor extends Control{constructor(e,t,i=!0){super(e,null,!0);this.filterChanged=new Event;this.buttonClicked=new Event;this._filter=asType(t,ColumnFilter);let l=this.getTemplate();this.applyTemplate("wj-control wj-content wj-columnfiltereditor",l,{_divSort:"div-sort",_btnAsc:"btn-asc",_btnDsc:"btn-dsc",_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnApply:"btn-apply",_btnCancel:"btn-cancel",_btnClear:"btn-clear"});let s=culture.FlexGridFilter,a=s.ariaLabels,r=this.hostElement,n=this.filter.column,o=n.grid.collectionView;setAttribute(r,"role","dialog");setAriaLabel(r,a.dialog+" "+n.header);setAriaLabel(this._btnAsc,a.asc);setAriaLabel(this._btnDsc,a.dsc);setText(this._btnAsc,s.ascending);setText(this._btnDsc,s.descending);setText(this._aVal,s.values);setText(this._aCnd,s.conditions);setText(this._btnApply,s.apply);setText(this._btnCancel,s.cancel);setText(this._btnClear,s.clear);let d=this.filter.conditionFilter.isActive||0==(t.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;this._showFilter(d);i&&o&&o.canSort||(this._divSort.style.display="none");this._updateSortButtonState();let h=this._btnClicked.bind(this);this._btnApply.addEventListener("click",h);this._btnCancel.addEventListener("click",h);this._btnClear.addEventListener("click",h);this._btnAsc.addEventListener("click",h);this._btnDsc.addEventListener("click",h);this._aVal.addEventListener("click",h);this._aCnd.addEventListener("click",h);this.addEventListener(r,"keydown",e=>{if(!e.defaultPrevented){let t=e.target.tagName.match(/^(a|button)$/i);switch(e.keyCode){case Key.Space:if(t){this._btnClicked(e);e.preventDefault()}break;case Key.Enter:if(t)this._btnClicked(e);else{this.updateFilter();this.onFilterChanged();this.onButtonClicked()}e.preventDefault();break;case Key.Escape:this.onButtonClicked();e.preventDefault();break;case Key.Tab:moveFocus(this.hostElement,e.shiftKey?-1:1);e.preventDefault()}}});this.addEventListener(window,"resize",()=>{this.isTouching||this._wasTouching||this.onButtonClicked()})}get filter(){return this._filter}updateEditor(){this._edtVal&&this._edtVal.updateEditor();this._edtCnd&&this._edtCnd.updateEditor()}updateFilter(){switch(this._getFilterType()){case FilterType.Value:this._edtVal.updateFilter();this.filter.conditionFilter.clear();break;case FilterType.Condition:this._edtCnd.updateFilter();this.filter.valueFilter.clear()}}onFilterChanged(e){this.filterChanged.raise(this,e)}onButtonClicked(e){this.buttonClicked.raise(this,e)}_showFilter(e){this._wasTouching=this.isTouching;if(e==FilterType.Value&&null==this._edtVal){this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter);this._edtVal.canApplyChanged.addHandler(e=>{enable(this._btnApply,this._edtVal.canApply)})}if(e==FilterType.Condition&&null==this._edtCnd){this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter);this._edtCnd.canApplyChanged.addHandler(e=>{enable(this._btnApply,this._edtCnd.canApply)})}if(0!=(e&this.filter.filterType))if(e==FilterType.Value){this._divEdtVal.style.display="";this._divEdtCnd.style.display="none";this._enableLink(this._aVal,!1);this._enableLink(this._aCnd,!0);this._edtVal.focus();enable(this._btnApply,this._edtVal.canApply)}else{this._divEdtVal.style.display="none";this._divEdtCnd.style.display="";this._enableLink(this._aVal,!0);this._enableLink(this._aCnd,!1);this._edtCnd.focus();enable(this._btnApply,this._edtCnd.canApply)}let t=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:t.display="none";break;default:t.display=""}}_enableLink(e,t){toggleClass(e,"wj-state-disabled",!t);setAttribute(e,"href",t?"":null);setAttribute(e,"disabled",t?null:"disabled")}_updateSortButtonState(){let e=this.filter.column,t=e?e.currentSort:"",i="wj-state-active";toggleClass(this._btnAsc,i,"+"==t);toggleClass(this._btnDsc,i,"-"==t)}_getFilterType(){let e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition}_btnClicked(e){let t=e.target;e.preventDefault();e.stopPropagation();if(!hasClass(t,"wj-state-disabled"))if(t!=this._aVal)if(t!=this._aCnd){if(t==this._btnAsc||t==this._btnDsc){let t=this.filter.column,i=t.sortMemberPath||t.binding,l=t.grid.collectionView.sortDescriptions;l.deferUpdate(()=>{l.clear();l.push(new SortDescription(i,e.target==this._btnAsc))});this._updateSortButtonState()}if(t==this._btnApply){this.updateFilter();this.onFilterChanged()}else if(t==this._btnClear){if(this.filter.isActive){this.filter.clear();this.onFilterChanged()}}else this.updateEditor();this.onButtonClicked()}else{this._showFilter(FilterType.Condition);moveFocus(this._edtCnd.hostElement,0)}else{this._showFilter(FilterType.Value);moveFocus(this._edtVal.hostElement,0)}}}ColumnFilterEditor.controlTemplate='<div><div wj-part="div-sort" class="wj-sort-buttons"><button wj-part="btn-asc" class="wj-btn"></button>&nbsp;&nbsp;&nbsp;<button wj-part="btn-dsc" class="wj-btn"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a>&nbsp;|&nbsp;<a wj-part="a-val" href="" draggable="false"></a></div><div wj-part="div-edt-val" tabindex="-1"></div><div wj-part="div-edt-cnd" tabindex="-1"></div><div style="text-align:right;margin-top:10px"><button wj-part="btn-apply" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-cancel" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-clear" class="wj-btn"></button></div></div>';_registerModule("wijmo.grid.filter",selfModule);
/*!
*
* Wijmo Library 5.20241.001-nightly.d20240116.t020147
* Wijmo Library 5.20241.001-nightly.d20240117.t020138
* https://developer.mescius.com/wijmo

@@ -14,2 +14,2 @@ *

var __extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}();import{Column,DataMap,FlexGrid,DataMapEditor,CellRange,CellRangeEventArgs,_NewRowTemplate}from"@grapecity/wijmo.grid";import{Globalize,asString,asNumber,asArray,asBoolean,asType,asEnum,isString,isDate,DateTime,culture,isNumber,copy,changeType,setAttribute,showPopup,hidePopup,isFunction,createElement,toggleClass,removeClass,closestClass,setAriaLabel,Control,Event,DataType,Key,CollectionView,setText,escapeRegExp,setChecked,SortDescription,SortNulls,getUniqueId,_addCultureInfo,enable,moveFocus,hasClass,_registerModule}from"@grapecity/wijmo";import{DropDown}from"@grapecity/wijmo.input";import*as input from"@grapecity/wijmo.input";import*as selfModule from"@grapecity/wijmo.grid.filter";export var FilterType;!function(e){e[e.None=0]="None";e[e.Condition=1]="Condition";e[e.Value=2]="Value";e[e.Both=3]="Both"}(FilterType||(FilterType={}));var FlexGridFilter=function(){function FlexGridFilter(e,t){this._showIcons=!0;this._showSort=!0;this._defFilterType=FilterType.Both;this._xValueSearch=!0;this._includeUpdatedRowsInFilter=!1;this.filterApplied=new Event;this.editingFilter=new Event;this.filterChanging=new Event;this.filterChanged=new Event;this.exclusiveValueSearchChanged=new Event;this._filters=[];this._g=asType(e,FlexGrid,!1);this._g.formatItem.addHandler(this._formatItem.bind(this));this._g.itemsSourceChanged.addHandler(this.clear.bind(this));var i=this._g.hostElement;e.addEventListener(i,"mousedown",this._mousedown.bind(this),!0);e.addEventListener(i,"click",this._click.bind(this),!0);e.addEventListener(i,"keydown",this._keydown.bind(this),!0);this._g.invalidate();copy(this,t);this._init()}FlexGridFilter.prototype._init=function(){var e=this,t=this.grid,_excludeRowFromFilter=function(t){var i=e.grid,r=e.excludedRowsSet;i.itemsSource?i.rows[t]instanceof _NewRowTemplate?r.add(i.editableCollectionView.currentAddItem||i.rows[t].dataItem):r.add(i.rows[t].dataItem):r.add(i.rows[t])};t.rowChanged&&t.rowChanged.addHandler((function(e,t){t.added&&_excludeRowFromFilter(t.index)}));t.rowEditEnding.addHandler((function(e,t){_excludeRowFromFilter(t.row)}));t.cellEditEnded.addHandler((function(e,t){_excludeRowFromFilter(t.row)}))};Object.defineProperty(FlexGridFilter.prototype,"excludedRowsSet",{get:function(){var e=this.grid;e.selectedSheet&&(e=e.selectedSheet);e._newAddedRowsSet||(e._newAddedRowsSet=new WeakSet);return e._newAddedRowsSet},set:function(e){var t=this.grid;t.selectedSheet&&(t=t.selectedSheet);t._newAddedRowsSet=e},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"filterColumns",{get:function(){return this._filterColumns},set:function(e){this._filterColumns=asArray(e);this.clear()},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"showFilterIcons",{get:function(){return this._showIcons},set:function(e){if(e!=this.showFilterIcons){this._showIcons=asBoolean(e);this._g&&this._g.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"showSortButtons",{get:function(){return this._showSort},set:function(e){this._showSort=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"reApplyFilterOnUpdate",{get:function(){return this._includeUpdatedRowsInFilter},set:function(e){e!==this._includeUpdatedRowsInFilter&&(this._includeUpdatedRowsInFilter=asBoolean(e))},enumerable:!0,configurable:!0});FlexGridFilter.prototype.getColumnFilter=function(e,t){void 0===t&&(t=!0);if(e=this._asColumn(e)){for(var i=0;i<this._filters.length;i++)if(this._filters[i].column==e)return this._filters[i];if(t&&e.binding){var r=new ColumnFilter(this,e);this._filters.push(r);return r}}return null};Object.defineProperty(FlexGridFilter.prototype,"defaultFilterType",{get:function(){return this._defFilterType},set:function(e){if((e=asEnum(e,FilterType,!1))!=this.defaultFilterType){this._defFilterType=e;this._g.invalidate();this.clear()}},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){if((e=asBoolean(e))!==this._xValueSearch){this._xValueSearch=e;this.onExclusiveValueSearchChanged()}},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"filterDefinition",{get:function(){var e=this,t={defaultFilterType:this.defaultFilterType,filters:[]};this._filters.forEach((function(i){var r=i.conditionFilter,n=i.valueFilter,l=n.uniqueValues&&n.uniqueValues.length;if(i&&i.column&&i.column.binding&&(i.isActive||l||i.filterType!=e.defaultFilterType)){var o={binding:i.column.binding};if(r.isActive){var a=r.condition1,s=r.condition2;o={binding:i.column.binding,type:"condition",condition1:{operator:a.operator,value:a.value},and:r.and,condition2:{operator:s.operator,value:s.value}}}else(n.isActive||l)&&(o={binding:i.column.binding,type:"value",uniqueValues:n.uniqueValues,sortValues:n.sortValues,maxValues:n.maxValues,exclusiveValueSearch:n.exclusiveValueSearch,showValues:n.showValues});i.filterType!=e.defaultFilterType&&(o.filterType=i.filterType);t.filters.push(o)}}));return JSON.stringify(t)},set:function(e){e=asString(e);this.clear();if(e){var t=JSON.parse(e);this.defaultFilterType=t.defaultFilterType;for(var _loop_1=function(e){var r=t.filters[e],n=i._asColumn(r.binding);n||(n=new Column({binding:r.binding}));var l=i.getColumnFilter(n,!0);if(l){null!=r.filterType&&(l.filterType=asEnum(r.filterType,FilterType));switch(r.type){case"condition":var o=l.conditionFilter;o.condition1.value=n.dataType==DataType.Date?changeType(r.condition1.value,n.dataType,null):r.condition1.value;o.condition1.operator=r.condition1.operator;o.and=r.and;o.condition2.value=n.dataType==DataType.Date?changeType(r.condition2.value,n.dataType,null):r.condition2.value;o.condition2.operator=r.condition2.operator;break;case"value":var a=l.valueFilter;a.uniqueValues=r.uniqueValues;["sortValues","maxValues","exclusiveValueSearch"].forEach((function(e){null!=r[e]&&(a[e]=r[e])}));a.showValues=r.showValues}}},i=this,r=0;r<t.filters.length;r++)_loop_1(r)}this.apply()},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"activeEditor",{get:function(){return Control.getControl(this._divEdt)},enumerable:!0,configurable:!0});FlexGridFilter.prototype.editColumnFilter=function(e,t,i){var r=this,n=this._g;this.closeEditor();e=this._asColumn(e);var l=new CellRangeEventArgs(n.cells,new CellRange(-1,e.index));if(this.onEditingFilter(l)){var o=createElement('<div class="wj-dropdown-panel"></div>'),a=this.getColumnFilter(e),s=new ColumnFilterEditor(o,a,this.showSortButtons);this._divEdt=o;this._edtCol=e;n.rightToLeft&&(o.dir="rtl");if(this.onFilterChanging(l)){l.cancel=!0;s.filterChanged.addHandler((function(){l.cancel=!1;setTimeout((function(){if(!l.cancel){r.excludedRowsSet=null;r.apply()}}),s._edtVal&&s._edtVal._isFiltering?Control._SEARCH_DELAY+200:0)}));s.buttonClicked.addHandler((function(){r.closeEditor();n.focus();r.onFilterChanged(l)}));s.lostFocus.addHandler((function(){setTimeout((function(){var e=Control.getControl(r._divEdt);e&&!e.containsFocus()&&r.closeEditor()}),10)}));var u=t?t.col:e.index,d=n.columns[u];t||d&&d.binding==e.binding||(u=n.selection.leftCol);n._edtHdl._commitRowEdits();n.scrollIntoView(-1,u,!0);var c=n.columnHeaders,p=t&&t.panel&&c&&t.panel._uid==c._uid?t.row:c.rows.length-1,h=u,f=i||c.getCellElement(p,h),_=f?null:c.getCellBoundingRect(p,h);f?showPopup(o,f,!1,!1,!1):showPopup(o,_);this._setAriaExpanded(f,!0);this._setAriaExpanded(n.cells.getCellElement(-1,h),!0);for(var b=s.hostElement.querySelectorAll("input"),v=0;v<b.length;v++){var g=b[v];if(g.offsetHeight>0&&g.tabIndex>-1&&!g.disabled){g.focus();break}}s.containsFocus()||s.focus()}else this._divEdt=this._edtCol=null}};FlexGridFilter.prototype._setAriaExpanded=function(e,t){if(e){var i=e.querySelector("."+FlexGridFilter._WJC_FILTER);setAttribute(i,"aria-expanded",t)}};FlexGridFilter.prototype.closeEditor=function(){var e=this._g,t=Control.getControl(this._divEdt),i=this._edtCol;t&&hidePopup(t.hostElement,(function(){t.dispose()}));if(i){var r=e.columnHeaders,n=r.rows.length?r.getCellElement(r.rows.length-1,i.index):null;this._setAriaExpanded(n,!1);n=e.cells.getCellElement(-1,i.index);this._setAriaExpanded(n,!1)}this._divEdt=null;this._edtCol=null};FlexGridFilter.prototype.apply=function(){var e=this._g.collectionView;if(e){var t=this._g.editableCollectionView;if(t){t.commitEdit();t.commitNew()}e.filter=this._filter.bind(this)}var i=e?e.updateFilterDefinition:null;isFunction(i)&&i.call(e,this);this.onFilterApplied()};FlexGridFilter.prototype.clear=function(){if(this._filters.length){this._filters=[];this.apply()}};FlexGridFilter.prototype.onFilterApplied=function(e){this.filterApplied.raise(this,e)};FlexGridFilter.prototype.onEditingFilter=function(e){this.editingFilter.raise(this,e);return!e.cancel};FlexGridFilter.prototype.onFilterChanging=function(e){this.filterChanging.raise(this,e);return!e.cancel};FlexGridFilter.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)};FlexGridFilter.prototype.onExclusiveValueSearchChanged=function(e){this.exclusiveValueSearchChanged.raise(this,e)};FlexGridFilter.prototype._asColumn=function(e){return isString(e)?this._g.getColumn(e,!0):isNumber(e)?this._g.columns[e]:asType(e,Column,!1)};FlexGridFilter.prototype._filter=function(e){var t=this.excludedRowsSet;if(!this.reApplyFilterOnUpdate&&t.has(e))return!0;for(var i=this._filters,r=0;r<i.length;r++){var n=i[r];if(n.column!=FlexGridFilter._skipColumn&&!n.apply(e))return!1}return!0};FlexGridFilter.prototype._formatItem=function(e,t){if(t.panel==e.columnHeaders){var i=this._g,r=i.getMergedRange(t.panel,t.row,t.col)||new CellRange(t.row,t.col),n=i.columns[r.col],l=i._getBindingColumn(t.panel,t.row,n),o=t.cell;if(r.row2==t.panel.rows.length-1||n!=l){var a=this.getColumnFilter(l,this.defaultFilterType!=FilterType.None),s=this._filterColumns;s&&s.length&&s.indexOf(l.binding)<0&&s.indexOf(l.name)<0&&(a=null);if(a){toggleClass(o,"wj-filter-on",a.isActive);toggleClass(o,"wj-filter-off",!a.isActive)}else{removeClass(o,"wj-filter-on");removeClass(o,"wj-filter-off")}if(a&&a.filterType!=FilterType.None){this._showIcons&&this._addFilterButton(l,a,o);0==t.row&&(o=i.cells.getCellElement(-1,t.col))&&this._addFilterButton(n,a,o)}}}};FlexGridFilter.prototype._addFilterButton=function(e,t,i){var r=FlexGridFilter._WJC_FILTER,n=createElement('<button class="wj-btn wj-btn-glyph wj-right '+r+'" type="button" tabindex="-1"><span class="wj-glyph-filter"></span></button>');setAriaLabel(n,culture.FlexGridFilter.ariaLabels.edit+" "+e.header);setAttribute(n,"aria-haspopup","dialog");setAttribute(n,"aria-expanded",!1);setAttribute(n,"aria-describedby",e.describedById);setAttribute(n,"aria-pressed",t.isActive);if(!i.querySelector("."+r)){1==i.children.length&&(i=i.querySelector("div")||i);i.insertBefore(n,i.firstChild)}};FlexGridFilter.prototype._mousedown=function(e){this._edtColPrev=this._edtCol};FlexGridFilter.prototype._click=function(e){if(this._toggleEditor(e)){e.stopPropagation();e.preventDefault()}};FlexGridFilter.prototype._toggleEditor=function(e){var t=this;if(!e.defaultPrevented&&0==e.button)if(closestClass(e.target,FlexGridFilter._WJC_FILTER)){var i=this._g,r=i.hitTest(e.target);r.panel||(r=i.hitTest(e));if(r.panel&&i.columnHeaders&&i.cells&&(r.panel._uid==i.columnHeaders._uid||r.panel._uid==i.cells._uid&&-1==r.row)){var n=i.getMergedRange(r.panel,r.row,r.col)||new CellRange(r.row,r.col),l=i.columns[n.col],o=i._getBindingColumn(r.panel,r.row,l);if(this._divEdt&&this._edtCol==o){this.closeEditor();i.focus()}else o!=this._edtColPrev&&setTimeout((function(){t.editColumnFilter(o,r)}),this._divEdt?100:0);return!0}}else this.closeEditor();return!1};FlexGridFilter.prototype._keydown=function(e){if(!e.defaultPrevented&&!e.ctrlKey&&e.altKey&&(e.keyCode==Key.Down||e.keyCode==Key.Up)){var t=this.grid,i=t.selection,r=i.col>-1?t.columns[i.col]:null,n=r?t._getBindingColumn(t.cells,i.row,r):null,l=n&&n.dataMap&&n.dataMapEditor==DataMapEditor.DropDownList;if(this.filterColumns&&this.filterColumns.length>0&&!this.filterColumns.includes(n._binding._path)){e.preventDefault();return!1}n&&n.editor instanceof DropDown&&(l=!0);if(n&&!l){var o=this.getColumnFilter(n,!1);if(o&&o.filterType!=FilterType.None){this.editColumnFilter(n);e.preventDefault();e.stopPropagation()}}}};FlexGridFilter._WJC_FILTER="wj-elem-filter";return FlexGridFilter}();export{FlexGridFilter};export var empty={};var ConditionFilter=function(){function ConditionFilter(e){this._c1=new FilterCondition(this);this._c2=new FilterCondition(this);this._and=!0;this._col=e}Object.defineProperty(ConditionFilter.prototype,"condition1",{get:function(){return this._c1},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"condition2",{get:function(){return this._c2},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"and",{get:function(){return this._and},set:function(e){this._and=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map=asType(e,DataMap,!0)},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"isActive",{get:function(){return this._c1.isActive||this._c2.isActive},enumerable:!0,configurable:!0});ConditionFilter.prototype.apply=function(e){var t=this._col,i=this._c1,r=this._c2,n=!1,l=!1;if(!t||!t._binding||!this.isActive)return!0;e=t._binding.getValue(e);var o=this.dataMap||t.dataMap;if(o)e=o.getDisplayValue(e);else if(isDate(e)){n=!this._hasTimePart();l=!this._hasDatePart();var a=FilterCondition._refDateTime;n?e=DateTime.fromDateTime(e,a):l&&(e=DateTime.fromDateTime(a,e))}else if(isNumber(e)){var s=Globalize,u=t.format,d=s.formatNumber(e,u);e=s.parseFloat(d,u)}var c=i.apply(e,n,l),p=r.apply(e,n,l);return i.isActive&&r.isActive?this._and?c&&p:c||p:i.isActive?c:!r.isActive||p};ConditionFilter.prototype.clear=function(){this._c1.clear();this._c2.clear();this.and=!0};ConditionFilter.prototype._hasDatePart=function(){var e=this._col.format;if(!e)return!0;e=culture.Globalize.calendar.patterns[e]||e;return/[yMd]+/.test(e)};ConditionFilter.prototype._hasTimePart=function(){var e=this._col.format;if(!e)return!1;e=culture.Globalize.calendar.patterns[e]||e;return/[Hmst]+/.test(e)};ConditionFilter.prototype.implementsInterface=function(e){return"IColumnFilter"==e};return ConditionFilter}();export{ConditionFilter};var ConditionFilterEditor=function(e){__extends(ConditionFilterEditor,e);function ConditionFilterEditor(t,i){var r=e.call(this,t)||this;r._canApply=!1;r.canApplyChanged=new Event;r._filter=asType(i,ConditionFilter,!1);var n=r.getTemplate();r.applyTemplate("wj-control wj-conditionfilter-editor",n,{_divHdr:"div-hdr",_divCmb1:"div-cmb1",_divVal1:"div-val1",_btnAnd:"btn-and",_btnOr:"btn-or",_spAnd:"sp-and",_spOr:"sp-or",_divCmb2:"div-cmb2",_divVal2:"div-val2"});var l=culture.FlexGridFilter,o=l.ariaLabels;setAriaLabel(r._btnAnd,o.and);setAriaLabel(r._btnOr,o.or);setText(r._divHdr,l.header);setText(r._spAnd,l.and);setText(r._spOr,l.or);var a=getUniqueId("cmb1");r._divHdr.htmlFor=a;r._divCmb1.id=a;r._cmb1=r._createOperatorCombo(r._divCmb1,o.op1);r._cmb2=r._createOperatorCombo(r._divCmb2,o.op2);r._val1=r._createValueInput(r._divVal1,o.val1);r._val2=r._createValueInput(r._divVal2,o.val2);r._val1.isDisabled=!0;r._cmb1.selectedIndexChanged.addHandler((function(e,t){r._val1.isDisabled=null==e.selectedValue;r.canApply=!r._val1.isDisabled||!r._val2.isDisabled}));r._val2.isDisabled=!0;r._cmb2.selectedIndexChanged.addHandler((function(e,t){r._val2.isDisabled=null==e.selectedValue;r.canApply=!r._val1.isDisabled||!r._val2.isDisabled}));var s=r.hostElement;r.addEventListener(s,"change",r._btnAndOrChanged.bind(r));r.addEventListener(s,"keydown",r._keydown.bind(r));setTimeout((function(){r.updateEditor()}));return r}Object.defineProperty(ConditionFilterEditor.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilterEditor.prototype,"canApply",{get:function(){return this._canApply},set:function(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}},enumerable:!0,configurable:!0});ConditionFilterEditor.prototype.updateEditor=function(){var e=this._filter.condition1,t=this._filter.condition2;this._cmb1.selectedValue=e.operator;this._cmb2.selectedValue=t.operator;if(this._val1 instanceof input.ComboBox&&!(this._val1 instanceof input.InputTime)){this._val1.text=changeType(e.value,DataType.String);this._val2.text=changeType(t.value,DataType.String)}else{this._val1.value=e.value;this._val2.value=t.value}var i=this._filter.and;this._checkRadio(this._btnAnd,i);this._checkRadio(this._btnOr,!i)};ConditionFilterEditor.prototype.clearEditor=function(){this._cmb1.selectedValue=this._cmb2.selectedValue=null;this._val1.text=this._val2.text=null;this._checkRadio(this._btnAnd,!0);this._checkRadio(this._btnOr,!1)};Object.defineProperty(ConditionFilterEditor.prototype,"isEditorClear",{get:function(){return null==this._cmb1.selectedValue&&!this._val1.text&&null==this._cmb2.selectedValue&&!this._val2.text},enumerable:!0,configurable:!0});ConditionFilterEditor.prototype.updateFilter=function(){var e=this._filter.condition1,t=this._filter.condition2;e.operator=this._cmb1.selectedValue;t.operator=this._cmb2.selectedValue;if("value"in this._val1){e.value=this._val1.value;t.value=this._val2.value}else{e.value=this._getComboValue(this._val1);t.value=this._getComboValue(this._val2)}this._filter.and=this._btnAnd.checked};ConditionFilterEditor.prototype.onCanApplyChanged=function(e){this.canApplyChanged.raise(this,e)};ConditionFilterEditor.prototype._getComboValue=function(e){return e.selectedIndex>-1?e.selectedValue:e.text};ConditionFilterEditor.prototype._createOperatorCombo=function(e,t){var i=this._filter.column,r=culture.FlexGridFilter,n=r.stringOperators,l=DataType;this._filter.dataMap||i.dataMap||(i.dataType==l.Date?n=r.dateOperators:i.dataType==l.Number?n=r.numberOperators:i.dataType==l.Boolean&&(n=r.booleanOperators));var o=new input.ComboBox(e,{itemsSource:n,displayMemberPath:"name",selectedValuePath:"op"});setAriaLabel(o.inputElement,t);return o};ConditionFilterEditor.prototype._createValueInput=function(e,t){var i=this._filter,r=i.column,n=i.dataMap||r.dataMap,l=null,o=DataType;if(r.dataType==o.Date)(l=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(e):new input.InputDate(e):new input.InputTime(e)).format=r.format;else if(r.dataType!=o.Number||n){(l=new input.ComboBox(e)).isEditable=!0;if(n){l.itemsSource=n.getDisplayValues();l.caseSensitiveSearch=!!r.grid&&r.grid.caseSensitiveSearch}else r.dataType==o.Boolean&&(l.itemsSource=[!0,!1])}else(l=new input.InputNumber(e)).format=r.format;l.isRequired=!1;setAriaLabel(l.inputElement,t);return l};ConditionFilterEditor.prototype._btnAndOrChanged=function(e){var t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i){this._checkRadio(this._btnAnd,t);this._checkRadio(this._btnOr,i)}};ConditionFilterEditor.prototype._checkRadio=function(e,t){e.checked=t;setAttribute(e,"aria-checked",t.toString());setAttribute(e,"tabindex",t?null:"-1")};ConditionFilterEditor.prototype._keydown=function(e){var t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i)switch(e.keyCode){case Key.Left:case Key.Right:case Key.Up:case Key.Down:var r=t?this._btnOr:this._btnAnd;r.click();r.focus();e.preventDefault()}};ConditionFilterEditor.controlTemplate='<div><label wj-part="div-hdr"></label><div wj-part="div-cmb1"></div><br/><div wj-part="div-val1"></div><br/><div role="radiogroup" style="text-align:center"><label><input wj-part="btn-and" type="radio" role="radio"> <span wj-part="sp-and"></span> </label>&nbsp;&nbsp;&nbsp;<label><input wj-part="btn-or" type="radio" role="radio"> <span wj-part="sp-or"></span> </label></div><div wj-part="div-cmb2"></div><br/><div wj-part="div-val2"></div><br/></div>';return ConditionFilterEditor}(Control);export{ConditionFilterEditor};var FilterCondition=function(){function FilterCondition(e){this._op=null;this._filter=e}Object.defineProperty(FilterCondition.prototype,"operator",{get:function(){return this._op},set:function(e){this._op=asEnum(e,Operator,!0)},enumerable:!0,configurable:!0});Object.defineProperty(FilterCondition.prototype,"value",{get:function(){return this._val},set:function(e){this._val=e;this._strVal=isString(e)?this._getCaseString(e):null},enumerable:!0,configurable:!0});Object.defineProperty(FilterCondition.prototype,"isActive",{get:function(){switch(this._op){case null:return!1;case Operator.EQ:case Operator.NE:return!0;default:return null!=this._val||null!=this._strVal}},enumerable:!0,configurable:!0});FilterCondition.prototype.clear=function(){this.operator=null;this.value=null};FilterCondition.prototype.apply=function(e,t,i){var r=this._strVal||this._val;isString(e)&&(e=this._getCaseString(e));isString(r)&&null==e&&(e="");isDate(r)&&(t?r=DateTime.fromDateTime(r,FilterCondition._refDateTime):i&&(r=DateTime.fromDateTime(FilterCondition._refDateTime,r)));var n=Operator;switch(this._op){case null:return!0;case n.EQ:return null!=e&&null!=r?e.valueOf()==r.valueOf():e==r;case n.NE:return null!=e&&null!=r?e.valueOf()!=r.valueOf():e!=r;case n.GT:return e>r;case n.GE:return e>=r;case n.LT:return e<r;case n.LE:return e<=r;case n.BW:return!(null==this._strVal||!isString(e))&&0==e.indexOf(this._strVal);case n.EW:return!!(null!=this._strVal&&isString(e)&&e.length>=this._strVal.length)&&e.substr(e.length-this._strVal.length)==r;case n.CT:return!(null==this._strVal||!isString(e))&&e.indexOf(this._strVal)>-1;case n.NC:return!(null==this._strVal||!isString(e))&&e.indexOf(this._strVal)<0}throw"Unknown operator"};FilterCondition.prototype._getCaseString=function(e){var t=this._filter.column,i=t?t.grid:null;return i&&i.caseSensitiveSearch?e:e.toLowerCase()};FilterCondition._refDateTime=new Date(2e3,0,1,0,0,0);return FilterCondition}();export{FilterCondition};export var Operator;!function(e){e[e.EQ=0]="EQ";e[e.NE=1]="NE";e[e.GT=2]="GT";e[e.GE=3]="GE";e[e.LT=4]="LT";e[e.LE=5]="LE";e[e.BW=6]="BW";e[e.EW=7]="EW";e[e.CT=8]="CT";e[e.NC=9]="NC"}(Operator||(Operator={}));export var ValueFilterSearchKind;!function(e){e[e.Text=0]="Text";e[e.Regex=1]="Regex";e[e.Excel=2]="Excel"}(ValueFilterSearchKind||(ValueFilterSearchKind={}));var ValueFilter=function(){function ValueFilter(e){this._values=null;this._filterText=null;this._xValueSearch=!0;this._maxValues=250;this._uniqueValues=null;this._sortValues=!0;this._searchType=ValueFilterSearchKind.Excel;this._col=e}Object.defineProperty(ValueFilter.prototype,"searchType",{get:function(){return this._searchType},set:function(e){this._searchType=asEnum(e,ValueFilterSearchKind)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"showValues",{get:function(){return this._values},set:function(e){this._values=e},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"filterText",{get:function(){return this._filterText},set:function(e){this._filterText=asString(e)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){if((e=asBoolean(e))!==this._xValueSearch){this._xValueSearch=asBoolean(e);e&&(this._filterText="")}},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"maxValues",{get:function(){return this._maxValues},set:function(e){this._maxValues=asNumber(e,!1,!0)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"uniqueValues",{get:function(){return this._uniqueValues},set:function(e){this._uniqueValues=asArray(e)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"sortValues",{get:function(){return this._sortValues},set:function(e){this._sortValues=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map=asType(e,DataMap,!0)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"isActive",{get:function(){return null!=this._values&&Object.keys(this._values).length>0},enumerable:!0,configurable:!0});ValueFilter.prototype.apply=function(e){var t=this.column;if(!(t&&t._binding&&this._values&&Object.keys(this._values).length))return!0;e=t._binding.getValue(e);e=this.dataMap?this.dataMap.getDisplayValue(e)||"":t.dataMap?t.dataMap.getDisplayValue(e)||"":Globalize.format(e,t.format);return null!=this._values[e]};ValueFilter.prototype.clear=function(){this.showValues=null;this.filterText=null};ValueFilter.prototype.getUniqueValues=function(e){void 0===e&&(e=!0);var t=[],i=this.column,r=Globalize.format;if(this.uniqueValues){this.uniqueValues.forEach((function(e){t.push({value:e,text:r(e,i.format)})}));return t}var n={},l=i.collectionView,o=l?l.sourceCollection:[];if(e&&l&&l.sourceCollection&&l.filter)try{FlexGridFilter._skipColumn=this._col;for(var a=[],s=0;s<o.length;s++)l.filter(o[s])&&a.push(o[s]);o=a}finally{FlexGridFilter._skipColumn=null}for(s=0;s<o.length;s++){var u=i._binding.getValue(o[s]),d=this.dataMap?this.dataMap.getDisplayValue(u)||"":i.dataMap?i.dataMap.getDisplayValue(u)||"":r(u,i.format);if(!n[d]){n[d]=!0;t.push({value:u,text:d})}}return t};ValueFilter.prototype.implementsInterface=function(e){return"IColumnFilter"==e};return ValueFilter}();export{ValueFilter};var ValueFilterEditor=function(e){__extends(ValueFilterEditor,e);function ValueFilterEditor(t,i){var r=e.call(this,t)||this;r._canApply=!1;r._isFiltering=!1;r.canApplyChanged=new Event;r._filter=asType(i,ValueFilter,!1);var n=r.getTemplate();r.applyTemplate("wj-control wj-valuefilter-editor",n,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values"});r._cbSelectAll.tabIndex=0;var l=culture.FlexGridFilter;setText(r._spSelectAll,l.selectAll);var o=r._view=new CollectionView(null,{sortNulls:SortNulls.First,filter:r._filterValues.bind(r)});if(i.sortValues){var a=i.column.dataMap||i.dataMap?"text":"value",s=i.column.dataType!=DataType.Boolean;o.sortDescriptions.push(new SortDescription(a,s))}o.collectionChanged.addHandler(r._updateSelectAllCheck,r);r._filterText="";r._rxFilter=null;r._cmbFilter=new input.ComboBox(r._divFilter,{isRequired:!1,placeholder:l.search});r._cmbFilter.isEditable=!0;r._lbValues=new input.ListBox(r._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:r._view,itemFormatter:function(e,t){return t||l.null},checkedItemsChanged:function(e){return r._updateSelectAllCheck()}});setAriaLabel(r._cmbFilter.inputElement,l.ariaLabels.search);setAttribute(r._lbValues.hostElement,"aria-multiselectable",!0);r._cmbFilter.inputElement.addEventListener("input",r._filterTextChanged.bind(r));r._cbSelectAll.addEventListener("click",r._cbSelectAllClicked.bind(r));r.updateEditor();r._initialItems=r._lbValues.checkedItems;return r}Object.defineProperty(ValueFilterEditor.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilterEditor.prototype,"canApply",{get:function(){return this._canApply},set:function(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}},enumerable:!0,configurable:!0});ValueFilterEditor.prototype.updateEditor=function(){var e=this,t=this._filter.column,i=this._filter.getUniqueValues(!0);this._lbValues.isContentHtml=t.isContentHtml;var r=this._filter.showValues;if(r&&0!=Object.keys(r).length){for(var n in r)for(var l=0;l<i.length;l++)if(i[l].text==n){i[l].show=!0;break}}else i.forEach((function(e){return e.show=!0}));var o=this._filter.filterText||"",a=this._getCaseSensitive();this._cmbFilter.text=o;this._filterText=a?o:o.toLowerCase();this._rxFilter=this._getSearchExp(o,a);var s=this._view;s.pageSize=this._filter.maxValues;s.sourceCollection=i;setTimeout((function(){e._adjustWidths()}),0)};ValueFilterEditor.prototype.clearEditor=function(e){void 0===e&&(e=!0);this._cmbFilter.text="";this._filterText="";this._rxFilter=null;var t=this._view;t.pageSize=0;t.items.forEach((function(t){t.show=e}));t.moveCurrentTo(-1);t.refresh();t.pageSize=this._filter.maxValues};Object.defineProperty(ValueFilterEditor.prototype,"isEditorClear",{get:function(){return!this._filterText&&!this._cbSelectAll.indeterminate},enumerable:!0,configurable:!0});ValueFilterEditor.prototype._updateFilter=function(){var e=null,t=this._getItems();if(this._filterText||this._cbSelectAll.indeterminate){e={};for(var i=0;i<t.length;i++){var r=t[i];r.show&&(e[r.text]=!0)}}var n=this._filter;n.showValues=e;n.filterText=this._filterText};ValueFilterEditor.prototype.updateFilter=function(){var e=this;this._isFiltering?setTimeout((function(){e._updateFilter()}),Control._SEARCH_DELAY+100):this._updateFilter()};ValueFilterEditor.prototype.onCanApplyChanged=function(e){this.canApplyChanged.raise(this,e)};ValueFilterEditor.prototype._getCaseSensitive=function(){var e=this._filter.column,t=e?e.grid:null;return t&&t.caseSensitiveSearch};ValueFilterEditor.prototype._getItems=function(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection};ValueFilterEditor.prototype._filterTextChanged=function(){var e=this;""===this._filterText&&this._cbSelectAll.checked||this._filter.exclusiveValueSearch?this._lbValues._addMode=!1:this._lbValues._addMode=!0;this._toFilter&&clearTimeout(this._toFilter);this._isFiltering=!0;this._toFilter=setTimeout((function(){var t=e._cmbFilter.text,i=e._getCaseSensitive();i||(t=t.toLowerCase());if(t!=e._filterText){e._filterText=t;e._rxFilter=e._getSearchExp(t,i);e._view.refresh();if(!t){var r=e._initialItems;if(r.length&&e._view.sourceCollection.indexOf(r[0])>-1){e._lbValues.checkedItems=e._initialItems;e._updateSelectAllCheck();e._isFiltering=!1;return}}if(e._filter.exclusiveValueSearch){e._cbSelectAll.checked=!0;e._cbSelectAllClicked()}else e._updateSelectAllCheck()}e._isFiltering=!1}),Control._SEARCH_DELAY)};ValueFilterEditor.prototype._getSearchExp=function(e,t){if(!e)return null;switch(this._filter.searchType){case ValueFilterSearchKind.Text:return this._getTextSearchExp(e,t);case ValueFilterSearchKind.Regex:return this._getRegexSearchExp(e,t);case ValueFilterSearchKind.Excel:return this._getExcelSearchExp(e,t)}};ValueFilterEditor.prototype._getTextSearchExp=function(e,t){return new RegExp(escapeRegExp(e),t?"":"i")};ValueFilterEditor.prototype._getRegexSearchExp=function(e,t){try{return new RegExp(e,t?"s":"is")}catch(e){return new RegExp("(?!)",t?"s":"is")}};ValueFilterEditor.prototype._getExcelSearchExp=function(e,t){var i=e;i=(i=(i=(i=(i=i.replace(/([.+^$[\]\\(){}|-])/g,"\\$1")).replace(/(?<!~)(\?+)/g,(function(e,t){return Array.from(t).map((function(e){return"."})).join("")}))).replace(/(?<!~)(\*+)/g,(function(e,t){return Array.from(t).map((function(e){return".*"})).join("")}))).replace(/~~/g,"~")).replace(/~([?*])/g,"\\$1");/(?<!~)[?*]/g.test(e)&&(i="^"+i+"$");return new RegExp(i,t?"s":"is")};ValueFilterEditor.prototype._filterValues=function(e){var t=this._rxFilter;return null==t||null==e||t.test(e.text)};ValueFilterEditor.prototype._cbSelectAllClicked=function(){for(var e=this,t=this._cbSelectAll.checked,i=this._divValues.scrollTop,r=this._getItems(),n=0;n<r.length;n++)r[n].show=t;this._view.refresh();this._divValues.scrollTop=i;setTimeout((function(){e._adjustWidths()}),0)};ValueFilterEditor.prototype._updateSelectAllCheck=function(){for(var e=this._getItems(),t=0,i=0,r=0;r<e.length;r++){e[r].show?t++:i++;if(t&&i)break}setChecked(this._cbSelectAll,t&&i?null:t>0);this.canApply=t>0};ValueFilterEditor.prototype._adjustWidths=function(){var e=this._lbValues.hostElement;if(e&&e.offsetHeight>0){var t=0,i=e.querySelectorAll(".wj-listbox-item label");if(i.length){for(var r=0;r<i.length;r++)t=Math.max(t,i[r].scrollWidth);if(t){var n=e.querySelectorAll(".wj-listbox-item");if(n.length){var l=n[0],o=getComputedStyle(l),a=parseFloat(o.paddingLeft)+parseFloat(o.paddingRight);for(r=0;r<n.length;r++)n[r].style.width=t+a+"px"}}}}};ValueFilterEditor.controlTemplate='<div><div wj-part="div-filter"></div><div class="wj-listbox-item"><label><input wj-part="cb-select-all" type="checkbox"> <span wj-part="sp-select-all"></span></label></div><div wj-part="div-values"></div></div>';return ValueFilterEditor}(Control);export{ValueFilterEditor};var ColumnFilter=function(){function ColumnFilter(e,t){var i=this;this._owner=e;this._col=t;this._valueFilter=new ValueFilter(t);this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch;this._conditionFilter=new ConditionFilter(t);e.exclusiveValueSearchChanged.addHandler((function(e){i._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch}))}Object.defineProperty(ColumnFilter.prototype,"filterType",{get:function(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType},set:function(e){if((e=asEnum(e,FilterType,!0))!=this._filterType){var t=this.isActive;this.clear();this._filterType=e;t?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"dataMap",{get:function(){return this.conditionFilter.dataMap||this.valueFilter.dataMap},set:function(e){this.conditionFilter.dataMap=e;this.valueFilter.dataMap=e},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"valueFilter",{get:function(){return this._valueFilter},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"conditionFilter",{get:function(){return this._conditionFilter},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"isActive",{get:function(){return this._conditionFilter.isActive||this._valueFilter.isActive},enumerable:!0,configurable:!0});ColumnFilter.prototype.apply=function(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)};ColumnFilter.prototype.clear=function(){this._valueFilter.clear();this._conditionFilter.clear()};ColumnFilter.prototype.implementsInterface=function(e){return"IColumnFilter"==e};return ColumnFilter}();export{ColumnFilter};_addCultureInfo("FlexGridFilter",{ariaLabels:{edit:"Edit Filter for Column",dialog:"Filter Editor for Column",asc:"Sort Column in Ascending Order",dsc:"Sort Column in Descending Order",search:"Search Item List",op1:"First Condition Operator",val1:"First Condition Value",and:"Require both Conditions",or:"Require either Condition",op2:"Second Condition Operator",val2:"Second Condition Value"},ascending:"↑ Ascending",descending:"↓ Descending",apply:"Apply",cancel:"Cancel",clear:"Clear",conditions:"Filter by Condition",values:"Filter by Value",search:"Search",selectAll:"Select All",null:"(nothing)",header:"Show items where the value",and:"And",or:"Or",stringOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Begins with",op:Operator.BW},{name:"Ends with",op:Operator.EW},{name:"Contains",op:Operator.CT},{name:"Does not contain",op:Operator.NC}],numberOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Is Greater than",op:Operator.GT},{name:"Is Greater than or equal to",op:Operator.GE},{name:"Is Less than",op:Operator.LT},{name:"Is Less than or equal to",op:Operator.LE}],dateOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Is Before",op:Operator.LT},{name:"Is After",op:Operator.GT}],booleanOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE}]});var ColumnFilterEditor=function(e){__extends(ColumnFilterEditor,e);function ColumnFilterEditor(t,i,r){void 0===r&&(r=!0);var n=e.call(this,t,null,!0)||this;n.filterChanged=new Event;n.buttonClicked=new Event;n._filter=asType(i,ColumnFilter);var l=n.getTemplate();n.applyTemplate("wj-control wj-content wj-columnfiltereditor",l,{_divSort:"div-sort",_btnAsc:"btn-asc",_btnDsc:"btn-dsc",_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnApply:"btn-apply",_btnCancel:"btn-cancel",_btnClear:"btn-clear"});var o=culture.FlexGridFilter,a=o.ariaLabels,s=n.hostElement,u=n.filter.column,d=u.grid.collectionView;setAttribute(s,"role","dialog");setAriaLabel(s,a.dialog+" "+u.header);setAriaLabel(n._btnAsc,a.asc);setAriaLabel(n._btnDsc,a.dsc);setText(n._btnAsc,o.ascending);setText(n._btnDsc,o.descending);setText(n._aVal,o.values);setText(n._aCnd,o.conditions);setText(n._btnApply,o.apply);setText(n._btnCancel,o.cancel);setText(n._btnClear,o.clear);var c=n.filter.conditionFilter.isActive||0==(i.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;n._showFilter(c);r&&d&&d.canSort||(n._divSort.style.display="none");n._updateSortButtonState();var p=n._btnClicked.bind(n);n._btnApply.addEventListener("click",p);n._btnCancel.addEventListener("click",p);n._btnClear.addEventListener("click",p);n._btnAsc.addEventListener("click",p);n._btnDsc.addEventListener("click",p);n._aVal.addEventListener("click",p);n._aCnd.addEventListener("click",p);n.addEventListener(s,"keydown",(function(e){if(!e.defaultPrevented){var t=e.target.tagName.match(/^(a|button)$/i);switch(e.keyCode){case Key.Space:if(t){n._btnClicked(e);e.preventDefault()}break;case Key.Enter:if(t)n._btnClicked(e);else{n.updateFilter();n.onFilterChanged();n.onButtonClicked()}e.preventDefault();break;case Key.Escape:n.onButtonClicked();e.preventDefault();break;case Key.Tab:moveFocus(n.hostElement,e.shiftKey?-1:1);e.preventDefault()}}}));n.addEventListener(window,"resize",(function(){n.isTouching||n._wasTouching||n.onButtonClicked()}));return n}Object.defineProperty(ColumnFilterEditor.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});ColumnFilterEditor.prototype.updateEditor=function(){this._edtVal&&this._edtVal.updateEditor();this._edtCnd&&this._edtCnd.updateEditor()};ColumnFilterEditor.prototype.updateFilter=function(){switch(this._getFilterType()){case FilterType.Value:this._edtVal.updateFilter();this.filter.conditionFilter.clear();break;case FilterType.Condition:this._edtCnd.updateFilter();this.filter.valueFilter.clear()}};ColumnFilterEditor.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)};ColumnFilterEditor.prototype.onButtonClicked=function(e){this.buttonClicked.raise(this,e)};ColumnFilterEditor.prototype._showFilter=function(e){var t=this;this._wasTouching=this.isTouching;if(e==FilterType.Value&&null==this._edtVal){this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter);this._edtVal.canApplyChanged.addHandler((function(e){enable(t._btnApply,t._edtVal.canApply)}))}if(e==FilterType.Condition&&null==this._edtCnd){this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter);this._edtCnd.canApplyChanged.addHandler((function(e){enable(t._btnApply,t._edtCnd.canApply)}))}if(0!=(e&this.filter.filterType))if(e==FilterType.Value){this._divEdtVal.style.display="";this._divEdtCnd.style.display="none";this._enableLink(this._aVal,!1);this._enableLink(this._aCnd,!0);this._edtVal.focus();enable(this._btnApply,this._edtVal.canApply)}else{this._divEdtVal.style.display="none";this._divEdtCnd.style.display="";this._enableLink(this._aVal,!0);this._enableLink(this._aCnd,!1);this._edtCnd.focus();enable(this._btnApply,this._edtCnd.canApply)}var i=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:i.display="none";break;default:i.display=""}};ColumnFilterEditor.prototype._enableLink=function(e,t){toggleClass(e,"wj-state-disabled",!t);setAttribute(e,"href",t?"":null);setAttribute(e,"disabled",t?null:"disabled")};ColumnFilterEditor.prototype._updateSortButtonState=function(){var e=this.filter.column,t=e?e.currentSort:"",i="wj-state-active";toggleClass(this._btnAsc,i,"+"==t);toggleClass(this._btnDsc,i,"-"==t)};ColumnFilterEditor.prototype._getFilterType=function(){var e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition};ColumnFilterEditor.prototype._btnClicked=function(e){var t=this,i=e.target;e.preventDefault();e.stopPropagation();if(!hasClass(i,"wj-state-disabled"))if(i!=this._aVal)if(i!=this._aCnd){if(i==this._btnAsc||i==this._btnDsc){var r=this.filter.column,n=r.sortMemberPath||r.binding,l=r.grid.collectionView.sortDescriptions;l.deferUpdate((function(){l.clear();l.push(new SortDescription(n,e.target==t._btnAsc))}));this._updateSortButtonState()}if(i==this._btnApply){this.updateFilter();this.onFilterChanged()}else if(i==this._btnClear){if(this.filter.isActive){this.filter.clear();this.onFilterChanged()}}else this.updateEditor();this.onButtonClicked()}else{this._showFilter(FilterType.Condition);moveFocus(this._edtCnd.hostElement,0)}else{this._showFilter(FilterType.Value);moveFocus(this._edtVal.hostElement,0)}};ColumnFilterEditor.controlTemplate='<div><div wj-part="div-sort" class="wj-sort-buttons"><button wj-part="btn-asc" class="wj-btn"></button>&nbsp;&nbsp;&nbsp;<button wj-part="btn-dsc" class="wj-btn"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a>&nbsp;|&nbsp;<a wj-part="a-val" href="" draggable="false"></a></div><div wj-part="div-edt-val" tabindex="-1"></div><div wj-part="div-edt-cnd" tabindex="-1"></div><div style="text-align:right;margin-top:10px"><button wj-part="btn-apply" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-cancel" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-clear" class="wj-btn"></button></div></div>';return ColumnFilterEditor}(Control);export{ColumnFilterEditor};_registerModule("wijmo.grid.filter",selfModule);
var __extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}();import{Column,DataMap,FlexGrid,DataMapEditor,CellRange,CellRangeEventArgs,_NewRowTemplate}from"@grapecity/wijmo.grid";import{Globalize,asString,asNumber,asArray,asBoolean,asType,asEnum,isString,isDate,DateTime,culture,isNumber,copy,changeType,setAttribute,showPopup,hidePopup,isFunction,createElement,toggleClass,removeClass,closestClass,setAriaLabel,Control,Event,DataType,Key,CollectionView,setText,escapeRegExp,setChecked,SortDescription,SortNulls,getUniqueId,_addCultureInfo,enable,moveFocus,hasClass,_registerModule}from"@grapecity/wijmo";import{DropDown}from"@grapecity/wijmo.input";import*as input from"@grapecity/wijmo.input";import*as selfModule from"@grapecity/wijmo.grid.filter";export var FilterType;!function(e){e[e.None=0]="None";e[e.Condition=1]="Condition";e[e.Value=2]="Value";e[e.Both=3]="Both"}(FilterType||(FilterType={}));var FlexGridFilter=function(){function FlexGridFilter(e,t){this._showIcons=!0;this._showSort=!0;this._defFilterType=FilterType.Both;this._xValueSearch=!0;this._includeUpdatedRowsInFilter=!1;this.filterApplied=new Event;this.editingFilter=new Event;this.filterChanging=new Event;this.filterChanged=new Event;this.exclusiveValueSearchChanged=new Event;this._filters=[];this._g=asType(e,FlexGrid,!1);this._g.formatItem.addHandler(this._formatItem.bind(this));this._g.itemsSourceChanged.addHandler(this.clear.bind(this));var i=this._g.hostElement;e.addEventListener(i,"mousedown",this._mousedown.bind(this),!0);e.addEventListener(i,"click",this._click.bind(this),!0);e.addEventListener(i,"keydown",this._keydown.bind(this),!0);this._g.invalidate();copy(this,t);this._init()}FlexGridFilter.prototype._init=function(){var e=this,t=this.grid,_excludeRowFromFilter=function(t){var i=e.grid,r=e.excludedRowsSet;i.itemsSource?i.rows[t]instanceof _NewRowTemplate?r.add(i.editableCollectionView.currentAddItem||i.rows[t].dataItem):r.add(i.rows[t].dataItem):r.add(i.rows[t])};t.rowChanged&&t.rowChanged.addHandler((function(e,t){t.added&&_excludeRowFromFilter(t.index)}));t.rowEditEnding.addHandler((function(e,t){_excludeRowFromFilter(t.row)}));t.cellEditEnded.addHandler((function(e,t){_excludeRowFromFilter(t.row)}))};Object.defineProperty(FlexGridFilter.prototype,"excludedRowsSet",{get:function(){var e=this.grid;e.selectedSheet&&(e=e.selectedSheet);e._newAddedRowsSet||(e._newAddedRowsSet=new WeakSet);return e._newAddedRowsSet},set:function(e){var t=this.grid;t.selectedSheet&&(t=t.selectedSheet);t._newAddedRowsSet=e},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"filterColumns",{get:function(){return this._filterColumns},set:function(e){this._filterColumns=asArray(e);this.clear()},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"showFilterIcons",{get:function(){return this._showIcons},set:function(e){if(e!=this.showFilterIcons){this._showIcons=asBoolean(e);this._g&&this._g.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"showSortButtons",{get:function(){return this._showSort},set:function(e){this._showSort=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"reApplyFilterOnUpdate",{get:function(){return this._includeUpdatedRowsInFilter},set:function(e){e!==this._includeUpdatedRowsInFilter&&(this._includeUpdatedRowsInFilter=asBoolean(e))},enumerable:!0,configurable:!0});FlexGridFilter.prototype.getColumnFilter=function(e,t){void 0===t&&(t=!0);if(e=this._asColumn(e)){for(var i=0;i<this._filters.length;i++)if(this._filters[i].column==e)return this._filters[i];if(t&&e.binding){var r=new ColumnFilter(this,e);this._filters.push(r);return r}}return null};Object.defineProperty(FlexGridFilter.prototype,"defaultFilterType",{get:function(){return this._defFilterType},set:function(e){if((e=asEnum(e,FilterType,!1))!=this.defaultFilterType){this._defFilterType=e;this._g.invalidate();this.clear()}},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){if((e=asBoolean(e))!==this._xValueSearch){this._xValueSearch=e;this.onExclusiveValueSearchChanged()}},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"filterDefinition",{get:function(){var e=this,t={defaultFilterType:this.defaultFilterType,filters:[]};this._filters.forEach((function(i){var r=i.conditionFilter,n=i.valueFilter,l=n.uniqueValues&&n.uniqueValues.length;if(i&&i.column&&i.column.binding&&(i.isActive||l||i.filterType!=e.defaultFilterType)){var a={binding:i.column.binding};if(r.isActive){var o=r.condition1,s=r.condition2;a={binding:i.column.binding,type:"condition",condition1:{operator:o.operator,value:o.value},and:r.and,condition2:{operator:s.operator,value:s.value}}}else(n.isActive||l)&&(a={binding:i.column.binding,type:"value",uniqueValues:n.uniqueValues,sortValues:n.sortValues,maxValues:n.maxValues,exclusiveValueSearch:n.exclusiveValueSearch,showValues:n.showValues});i.filterType!=e.defaultFilterType&&(a.filterType=i.filterType);t.filters.push(a)}}));return JSON.stringify(t)},set:function(e){e=asString(e);this.clear();if(e){var t=JSON.parse(e);this.defaultFilterType=t.defaultFilterType;for(var _loop_1=function(e){var r=t.filters[e],n=i._asColumn(r.binding);n||(n=new Column({binding:r.binding}));var l=i.getColumnFilter(n,!0);if(l){null!=r.filterType&&(l.filterType=asEnum(r.filterType,FilterType));switch(r.type){case"condition":var a=l.conditionFilter;a.condition1.value=n.dataType==DataType.Date?changeType(r.condition1.value,n.dataType,null):r.condition1.value;a.condition1.operator=r.condition1.operator;a.and=r.and;a.condition2.value=n.dataType==DataType.Date?changeType(r.condition2.value,n.dataType,null):r.condition2.value;a.condition2.operator=r.condition2.operator;break;case"value":var o=l.valueFilter;o.uniqueValues=r.uniqueValues;["sortValues","maxValues","exclusiveValueSearch"].forEach((function(e){null!=r[e]&&(o[e]=r[e])}));o.showValues=r.showValues}}},i=this,r=0;r<t.filters.length;r++)_loop_1(r)}this.apply()},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"activeEditor",{get:function(){return Control.getControl(this._divEdt)},enumerable:!0,configurable:!0});FlexGridFilter.prototype.editColumnFilter=function(e,t,i){var r=this,n=this._g;this.closeEditor();e=this._asColumn(e);var l=new CellRangeEventArgs(n.cells,new CellRange(-1,e.index));if(this.onEditingFilter(l)){var a=createElement('<div class="wj-dropdown-panel"></div>'),o=this.getColumnFilter(e),s=new ColumnFilterEditor(a,o,this.showSortButtons);this._divEdt=a;this._edtCol=e;n.rightToLeft&&(a.dir="rtl");if(this.onFilterChanging(l)){l.cancel=!0;s.filterChanged.addHandler((function(){l.cancel=!1;setTimeout((function(){if(!l.cancel){r.excludedRowsSet=null;r.apply()}}),s._edtVal&&s._edtVal._isFiltering?Control._SEARCH_DELAY+200:0)}));s.buttonClicked.addHandler((function(){r.closeEditor();n.focus();r.onFilterChanged(l)}));s.lostFocus.addHandler((function(){setTimeout((function(){var e=Control.getControl(r._divEdt);e&&!e.containsFocus()&&r.closeEditor()}),10)}));var u=t?t.col:e.index,d=n.columns[u];t||d&&d.binding==e.binding||(u=n.selection.leftCol);n._edtHdl._commitRowEdits();n.scrollIntoView(-1,u,!0);var c=n.columnHeaders,p=t&&t.panel&&c&&t.panel._uid==c._uid?t.row:c.rows.length-1,h=u,f=i||c.getCellElement(p,h),_=f?null:c.getCellBoundingRect(p,h);f?showPopup(a,f,!1,!1,!1):showPopup(a,_);this._setAriaExpanded(f,!0);this._setAriaExpanded(n.cells.getCellElement(-1,h),!0);for(var b=s.hostElement.querySelectorAll("input"),v=0;v<b.length;v++){var g=b[v];if(g.offsetHeight>0&&g.tabIndex>-1&&!g.disabled){g.focus();break}}s.containsFocus()||s.focus()}else this._divEdt=this._edtCol=null}};FlexGridFilter.prototype._setAriaExpanded=function(e,t){if(e){var i=e.querySelector("."+FlexGridFilter._WJC_FILTER);setAttribute(i,"aria-expanded",t)}};FlexGridFilter.prototype.closeEditor=function(){var e=this._g,t=Control.getControl(this._divEdt),i=this._edtCol;t&&hidePopup(t.hostElement,(function(){t.dispose()}));if(i){var r=e.columnHeaders,n=r.rows.length?r.getCellElement(r.rows.length-1,i.index):null;this._setAriaExpanded(n,!1);n=e.cells.getCellElement(-1,i.index);this._setAriaExpanded(n,!1)}this._divEdt=null;this._edtCol=null};FlexGridFilter.prototype.apply=function(){var e=this._g.collectionView;if(e){var t=this._g.editableCollectionView;if(t){t.commitEdit();t.commitNew()}e.filter=this._filter.bind(this)}var i=e?e.updateFilterDefinition:null;isFunction(i)&&i.call(e,this);this.onFilterApplied()};FlexGridFilter.prototype.clear=function(){if(this._filters.length){this._filters=[];this.apply()}};FlexGridFilter.prototype.onFilterApplied=function(e){this.filterApplied.raise(this,e)};FlexGridFilter.prototype.onEditingFilter=function(e){this.editingFilter.raise(this,e);return!e.cancel};FlexGridFilter.prototype.onFilterChanging=function(e){this.filterChanging.raise(this,e);return!e.cancel};FlexGridFilter.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)};FlexGridFilter.prototype.onExclusiveValueSearchChanged=function(e){this.exclusiveValueSearchChanged.raise(this,e)};FlexGridFilter.prototype._asColumn=function(e){return isString(e)?this._g.getColumn(e,!0):isNumber(e)?this._g.columns[e]:asType(e,Column,!1)};FlexGridFilter.prototype._filter=function(e){var t=this.excludedRowsSet;if(!this.reApplyFilterOnUpdate&&t.has(e))return!0;for(var i=this._filters,r=0;r<i.length;r++){var n=i[r];if(n.column!=FlexGridFilter._skipColumn&&!n.apply(e))return!1}return!0};FlexGridFilter.prototype._formatItem=function(e,t){if(t.panel==e.columnHeaders){var i=this._g,r=i.getMergedRange(t.panel,t.row,t.col)||new CellRange(t.row,t.col),n=i.columns[r.col],l=i._getBindingColumn(t.panel,t.row,n),a=t.cell;if(r.row2==t.panel.rows.length-1||n!=l){var o=this.getColumnFilter(l,this.defaultFilterType!=FilterType.None),s=this._filterColumns;s&&s.length&&s.indexOf(l.binding)<0&&s.indexOf(l.name)<0&&(o=null);if(o){toggleClass(a,"wj-filter-on",o.isActive);toggleClass(a,"wj-filter-off",!o.isActive)}else{removeClass(a,"wj-filter-on");removeClass(a,"wj-filter-off")}if(o&&o.filterType!=FilterType.None){this._showIcons&&this._addFilterButton(l,o,a);0==t.row&&(a=i.cells.getCellElement(-1,t.col))&&this._addFilterButton(n,o,a)}}}};FlexGridFilter.prototype._addFilterButton=function(e,t,i){var r=FlexGridFilter._WJC_FILTER,n=createElement('<button class="wj-btn wj-btn-glyph wj-right '+r+'" type="button" tabindex="-1"><span class="wj-glyph-filter"></span></button>');setAriaLabel(n,culture.FlexGridFilter.ariaLabels.edit+" "+e.header);setAttribute(n,"aria-haspopup","dialog");setAttribute(n,"aria-expanded",!1);setAttribute(n,"aria-describedby",e.describedById);setAttribute(n,"aria-pressed",t.isActive);if(!i.querySelector("."+r)){1==i.children.length&&(i=i.querySelector("div")||i);i.insertBefore(n,i.firstChild)}};FlexGridFilter.prototype._mousedown=function(e){this._edtColPrev=this._edtCol};FlexGridFilter.prototype._click=function(e){if(this._toggleEditor(e)){e.stopPropagation();e.preventDefault()}};FlexGridFilter.prototype._toggleEditor=function(e){var t=this;if(!e.defaultPrevented&&0==e.button)if(closestClass(e.target,FlexGridFilter._WJC_FILTER)){var i=this._g,r=i.hitTest(e.target);r.panel||(r=i.hitTest(e));if(r.panel&&i.columnHeaders&&i.cells&&(r.panel._uid==i.columnHeaders._uid||r.panel._uid==i.cells._uid&&-1==r.row)){var n=i.getMergedRange(r.panel,r.row,r.col)||new CellRange(r.row,r.col),l=i.columns[n.col],a=i._getBindingColumn(r.panel,r.row,l);if(this._divEdt&&this._edtCol==a){this.closeEditor();i.focus()}else a!=this._edtColPrev&&setTimeout((function(){t.editColumnFilter(a,r)}),this._divEdt?100:0);return!0}}else this.closeEditor();return!1};FlexGridFilter.prototype._keydown=function(e){if(!e.defaultPrevented&&!e.ctrlKey&&e.altKey&&(e.keyCode==Key.Down||e.keyCode==Key.Up)){var t=this.grid,i=t.selection,r=i.col>-1?t.columns[i.col]:null,n=r?t._getBindingColumn(t.cells,i.row,r):null,l=n&&n.dataMap&&n.dataMapEditor==DataMapEditor.DropDownList;if(this.filterColumns&&this.filterColumns.length>0&&!this.filterColumns.includes(n._binding._path)){e.preventDefault();return!1}n&&n.editor instanceof DropDown&&(l=!0);if(n&&!l){var a=this.getColumnFilter(n,!1);if(a&&a.filterType!=FilterType.None){this.editColumnFilter(n);e.preventDefault();e.stopPropagation()}}}};FlexGridFilter._WJC_FILTER="wj-elem-filter";return FlexGridFilter}();export{FlexGridFilter};export var empty={};var ConditionFilter=function(){function ConditionFilter(e){this._c1=new FilterCondition(this);this._c2=new FilterCondition(this);this._and=!0;this._col=e}Object.defineProperty(ConditionFilter.prototype,"condition1",{get:function(){return this._c1},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"condition2",{get:function(){return this._c2},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"and",{get:function(){return this._and},set:function(e){this._and=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map=asType(e,DataMap,!0)},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"isActive",{get:function(){return this._c1.isActive||this._c2.isActive},enumerable:!0,configurable:!0});ConditionFilter.prototype.apply=function(e){var t=this._col,i=this._c1,r=this._c2,n=!1,l=!1;if(!t||!t._binding||!this.isActive)return!0;e=t._binding.getValue(e);var a=this.dataMap||t.dataMap;if(a)e=a.getDisplayValue(e);else if(isDate(e)){n=!this._hasTimePart();l=!this._hasDatePart();var o=FilterCondition._refDateTime;n?e=DateTime.fromDateTime(e,o):l&&(e=DateTime.fromDateTime(o,e))}else if(isNumber(e)){var s=Globalize,u=t.format,d=s.formatNumber(e,u);e=s.parseFloat(d,u)}var c=i.apply(e,n,l),p=r.apply(e,n,l);return i.isActive&&r.isActive?this._and?c&&p:c||p:i.isActive?c:!r.isActive||p};ConditionFilter.prototype.clear=function(){this._c1.clear();this._c2.clear();this.and=!0};ConditionFilter.prototype._hasDatePart=function(){var e=this._col.format;if(!e)return!0;e=culture.Globalize.calendar.patterns[e]||e;return/[yMd]+/.test(e)};ConditionFilter.prototype._hasTimePart=function(){var e=this._col.format;if(!e)return!1;e=culture.Globalize.calendar.patterns[e]||e;return/[Hmst]+/.test(e)};ConditionFilter.prototype.implementsInterface=function(e){return"IColumnFilter"==e};return ConditionFilter}();export{ConditionFilter};var ConditionFilterEditor=function(e){__extends(ConditionFilterEditor,e);function ConditionFilterEditor(t,i){var r=e.call(this,t)||this;r._canApply=!1;r.canApplyChanged=new Event;r._filter=asType(i,ConditionFilter,!1);var n=r.getTemplate();r.applyTemplate("wj-control wj-conditionfilter-editor",n,{_divHdr:"div-hdr",_divCmb1:"div-cmb1",_divVal1:"div-val1",_btnAnd:"btn-and",_btnOr:"btn-or",_spAnd:"sp-and",_spOr:"sp-or",_divCmb2:"div-cmb2",_divVal2:"div-val2"});var l=culture.FlexGridFilter,a=l.ariaLabels;setAriaLabel(r._btnAnd,a.and);setAriaLabel(r._btnOr,a.or);setText(r._divHdr,l.header);setText(r._spAnd,l.and);setText(r._spOr,l.or);var o=getUniqueId("cmb1");r._divHdr.htmlFor=o;r._divCmb1.id=o;r._cmb1=r._createOperatorCombo(r._divCmb1,a.op1);r._cmb2=r._createOperatorCombo(r._divCmb2,a.op2);r._val1=r._createValueInput(r._divVal1,a.val1);r._val2=r._createValueInput(r._divVal2,a.val2);r._val1.isDisabled=!0;r._cmb1.selectedIndexChanged.addHandler((function(e,t){r._val1.isDisabled=null==e.selectedValue;r.canApply=!r._val1.isDisabled||!r._val2.isDisabled}));r._val2.isDisabled=!0;r._cmb2.selectedIndexChanged.addHandler((function(e,t){r._val2.isDisabled=null==e.selectedValue;r.canApply=!r._val1.isDisabled||!r._val2.isDisabled}));var s=r.hostElement;r.addEventListener(s,"change",r._btnAndOrChanged.bind(r));r.addEventListener(s,"keydown",r._keydown.bind(r));setTimeout((function(){r.updateEditor()}));return r}Object.defineProperty(ConditionFilterEditor.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilterEditor.prototype,"canApply",{get:function(){return this._canApply},set:function(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}},enumerable:!0,configurable:!0});ConditionFilterEditor.prototype.updateEditor=function(){var e=this._filter.condition1,t=this._filter.condition2;this._cmb1.selectedValue=e.operator;this._cmb2.selectedValue=t.operator;if(this._val1 instanceof input.ComboBox&&!(this._val1 instanceof input.InputTime)){this._val1.text=changeType(e.value,DataType.String);this._val2.text=changeType(t.value,DataType.String)}else{this._val1.value=e.value;this._val2.value=t.value}var i=this._filter.and;this._checkRadio(this._btnAnd,i);this._checkRadio(this._btnOr,!i)};ConditionFilterEditor.prototype.clearEditor=function(){this._cmb1.selectedValue=this._cmb2.selectedValue=null;this._val1.text=this._val2.text=null;this._checkRadio(this._btnAnd,!0);this._checkRadio(this._btnOr,!1)};Object.defineProperty(ConditionFilterEditor.prototype,"isEditorClear",{get:function(){return null==this._cmb1.selectedValue&&!this._val1.text&&null==this._cmb2.selectedValue&&!this._val2.text},enumerable:!0,configurable:!0});ConditionFilterEditor.prototype.updateFilter=function(){var e=this._filter.condition1,t=this._filter.condition2;e.operator=this._cmb1.selectedValue;t.operator=this._cmb2.selectedValue;if("value"in this._val1){e.value=this._val1.value;t.value=this._val2.value}else{e.value=this._getComboValue(this._val1);t.value=this._getComboValue(this._val2)}this._filter.and=this._btnAnd.checked};ConditionFilterEditor.prototype.onCanApplyChanged=function(e){this.canApplyChanged.raise(this,e)};ConditionFilterEditor.prototype._getComboValue=function(e){return e.selectedIndex>-1?e.selectedValue:e.text};ConditionFilterEditor.prototype._createOperatorCombo=function(e,t){var i=this._filter.column,r=culture.FlexGridFilter,n=r.stringOperators,l=DataType;this._filter.dataMap||i.dataMap||(i.dataType==l.Date?n=r.dateOperators:i.dataType==l.Number?n=r.numberOperators:i.dataType==l.Boolean&&(n=r.booleanOperators));var a=new input.ComboBox(e,{itemsSource:n,displayMemberPath:"name",selectedValuePath:"op"});setAriaLabel(a.inputElement,t);return a};ConditionFilterEditor.prototype._createValueInput=function(e,t){var i=this._filter,r=i.column,n=i.dataMap||r.dataMap,l=null,a=DataType;if(r.dataType==a.Date)(l=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(e):new input.InputDate(e):new input.InputTime(e)).format=r.format;else if(r.dataType!=a.Number||n){(l=new input.ComboBox(e)).isEditable=!0;if(n){l.itemsSource=n.getDisplayValues();l.caseSensitiveSearch=!!r.grid&&r.grid.caseSensitiveSearch}else r.dataType==a.Boolean&&(l.itemsSource=[!0,!1])}else(l=new input.InputNumber(e)).format=r.format;l.isRequired=!1;setAriaLabel(l.inputElement,t);return l};ConditionFilterEditor.prototype._btnAndOrChanged=function(e){var t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i){this._checkRadio(this._btnAnd,t);this._checkRadio(this._btnOr,i)}};ConditionFilterEditor.prototype._checkRadio=function(e,t){e.checked=t;setAttribute(e,"aria-checked",t.toString());setAttribute(e,"tabindex",t?null:"-1")};ConditionFilterEditor.prototype._keydown=function(e){var t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i)switch(e.keyCode){case Key.Left:case Key.Right:case Key.Up:case Key.Down:var r=t?this._btnOr:this._btnAnd;r.click();r.focus();e.preventDefault()}};ConditionFilterEditor.controlTemplate='<div><label wj-part="div-hdr"></label><div wj-part="div-cmb1"></div><br/><div wj-part="div-val1"></div><br/><div role="radiogroup" style="text-align:center"><label><input wj-part="btn-and" type="radio" role="radio"> <span wj-part="sp-and"></span> </label>&nbsp;&nbsp;&nbsp;<label><input wj-part="btn-or" type="radio" role="radio"> <span wj-part="sp-or"></span> </label></div><div wj-part="div-cmb2"></div><br/><div wj-part="div-val2"></div><br/></div>';return ConditionFilterEditor}(Control);export{ConditionFilterEditor};var FilterCondition=function(){function FilterCondition(e){this._op=null;this._filter=e}Object.defineProperty(FilterCondition.prototype,"operator",{get:function(){return this._op},set:function(e){this._op=asEnum(e,Operator,!0)},enumerable:!0,configurable:!0});Object.defineProperty(FilterCondition.prototype,"value",{get:function(){return this._val},set:function(e){this._val=e;this._strVal=isString(e)?this._getCaseString(e):null},enumerable:!0,configurable:!0});Object.defineProperty(FilterCondition.prototype,"isActive",{get:function(){switch(this._op){case null:return!1;case Operator.EQ:case Operator.NE:return!0;default:return null!=this._val||null!=this._strVal}},enumerable:!0,configurable:!0});FilterCondition.prototype.clear=function(){this.operator=null;this.value=null};FilterCondition.prototype.apply=function(e,t,i){var r=this._strVal||this._val;isString(e)&&(e=this._getCaseString(e));isString(r)&&null==e&&(e="");isDate(r)&&(t?r=DateTime.fromDateTime(r,FilterCondition._refDateTime):i&&(r=DateTime.fromDateTime(FilterCondition._refDateTime,r)));var n=Operator;switch(this._op){case null:return!0;case n.EQ:return null!=e&&null!=r?e.valueOf()==r.valueOf():e==r;case n.NE:return null!=e&&null!=r?e.valueOf()!=r.valueOf():e!=r;case n.GT:return e>r;case n.GE:return e>=r;case n.LT:return e<r;case n.LE:return e<=r;case n.BW:return!(null==this._strVal||!isString(e))&&0==e.indexOf(this._strVal);case n.EW:return!!(null!=this._strVal&&isString(e)&&e.length>=this._strVal.length)&&e.substr(e.length-this._strVal.length)==r;case n.CT:return!(null==this._strVal||!isString(e))&&e.indexOf(this._strVal)>-1;case n.NC:return!(null==this._strVal||!isString(e))&&e.indexOf(this._strVal)<0}throw"Unknown operator"};FilterCondition.prototype._getCaseString=function(e){var t=this._filter.column,i=t?t.grid:null;return i&&i.caseSensitiveSearch?e:e.toLowerCase()};FilterCondition._refDateTime=new Date(2e3,0,1,0,0,0);return FilterCondition}();export{FilterCondition};export var Operator;!function(e){e[e.EQ=0]="EQ";e[e.NE=1]="NE";e[e.GT=2]="GT";e[e.GE=3]="GE";e[e.LT=4]="LT";e[e.LE=5]="LE";e[e.BW=6]="BW";e[e.EW=7]="EW";e[e.CT=8]="CT";e[e.NC=9]="NC"}(Operator||(Operator={}));export var ValueFilterSearchKind;!function(e){e[e.Text=0]="Text";e[e.Regex=1]="Regex";e[e.Excel=2]="Excel"}(ValueFilterSearchKind||(ValueFilterSearchKind={}));var ValueFilter=function(){function ValueFilter(e){this._values=null;this._filterText=null;this._xValueSearch=!0;this._maxValues=250;this._uniqueValues=null;this._sortValues=!0;this._searchType=ValueFilterSearchKind.Excel;this._exceedsMaxValues=!1;this._col=e}Object.defineProperty(ValueFilter.prototype,"searchType",{get:function(){return this._searchType},set:function(e){this._searchType=asEnum(e,ValueFilterSearchKind)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"showValues",{get:function(){return this._values},set:function(e){this._values=e},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"filterText",{get:function(){return this._filterText},set:function(e){this._filterText=asString(e)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){if((e=asBoolean(e))!==this._xValueSearch){this._xValueSearch=asBoolean(e);e&&(this._filterText="")}},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"maxValues",{get:function(){return this._maxValues},set:function(e){this._maxValues=asNumber(e,!1,!0)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"uniqueValues",{get:function(){return this._uniqueValues},set:function(e){this._uniqueValues=asArray(e)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"sortValues",{get:function(){return this._sortValues},set:function(e){this._sortValues=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map=asType(e,DataMap,!0)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"isActive",{get:function(){return null!=this._values&&Object.keys(this._values).length>0},enumerable:!0,configurable:!0});ValueFilter.prototype.apply=function(e){var t=this.column;if(!(t&&t._binding&&this._values&&Object.keys(this._values).length))return!0;e=t._binding.getValue(e);e=this.dataMap?this.dataMap.getDisplayValue(e)||"":t.dataMap?t.dataMap.getDisplayValue(e)||"":Globalize.format(e,t.format);return null!=this._values[e]};ValueFilter.prototype.clear=function(){this.showValues=null;this.filterText=null};ValueFilter.prototype.getUniqueValues=function(e){void 0===e&&(e=!0);var t=[],i=this.column,r=Globalize.format;if(this.uniqueValues){this.uniqueValues.forEach((function(e){t.push({value:e,text:r(e,i.format)})}));return t}var n={},l=i.collectionView,a=l?l.sourceCollection:[];if(e&&l&&l.sourceCollection&&l.filter)try{FlexGridFilter._skipColumn=this._col;for(var o=[],s=0;s<a.length;s++)l.filter(a[s])&&o.push(a[s]);a=o}finally{FlexGridFilter._skipColumn=null}for(s=0;s<a.length;s++){var u=i._binding.getValue(a[s]),d=this.dataMap?this.dataMap.getDisplayValue(u)||"":i.dataMap?i.dataMap.getDisplayValue(u)||"":r(u,i.format);if(!n[d]){n[d]=!0;t.push({value:u,text:d})}}this._exceedsMaxValues=t.length>this._maxValues;return t};Object.defineProperty(ValueFilter.prototype,"exceedsMaxValues",{get:function(){return this._exceedsMaxValues},enumerable:!0,configurable:!0});ValueFilter.prototype.implementsInterface=function(e){return"IColumnFilter"==e};return ValueFilter}();export{ValueFilter};var ValueFilterEditor=function(e){__extends(ValueFilterEditor,e);function ValueFilterEditor(t,i){var r=e.call(this,t)||this;r._canApply=!1;r._isFiltering=!1;r.canApplyChanged=new Event;r._filter=asType(i,ValueFilter,!1);var n=r.getTemplate();r.applyTemplate("wj-control wj-valuefilter-editor",n,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values",_warning:"warning-message"});r._cbSelectAll.tabIndex=0;var l=culture.FlexGridFilter;setText(r._spSelectAll,l.selectAll);var a=r._view=new CollectionView(null,{sortNulls:SortNulls.First,filter:r._filterValues.bind(r)});if(i.sortValues){var o=i.column.dataMap||i.dataMap?"text":"value",s=i.column.dataType!=DataType.Boolean;a.sortDescriptions.push(new SortDescription(o,s))}a.collectionChanged.addHandler(r._updateSelectAllCheck,r);r._filterText="";r._rxFilter=null;r._cmbFilter=new input.ComboBox(r._divFilter,{isRequired:!1,placeholder:l.search});r._cmbFilter.isEditable=!0;r._lbValues=new input.ListBox(r._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:r._view,itemFormatter:function(e,t){return t||l.null},checkedItemsChanged:function(e){return r._updateSelectAllCheck()}});setAriaLabel(r._cmbFilter.inputElement,l.ariaLabels.search);setAttribute(r._lbValues.hostElement,"aria-multiselectable",!0);r._cmbFilter.inputElement.addEventListener("input",r._filterTextChanged.bind(r));r._cbSelectAll.addEventListener("click",r._cbSelectAllClicked.bind(r));r._warning.addEventListener("click",(function(){return r._showModal()}));r._modal=r._createModal();document.body.appendChild(r._modal);r.updateEditor();r._initialItems=r._lbValues.checkedItems;return r}Object.defineProperty(ValueFilterEditor.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilterEditor.prototype,"canApply",{get:function(){return this._canApply},set:function(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}},enumerable:!0,configurable:!0});ValueFilterEditor.prototype.updateEditor=function(){var e=this,t=this._filter.column,i=this._filter.getUniqueValues(!0);this._lbValues.isContentHtml=t.isContentHtml;var r=this._filter.showValues;if(r&&0!=Object.keys(r).length){for(var n in r)for(var l=0;l<i.length;l++)if(i[l].text==n){i[l].show=!0;break}}else i.forEach((function(e){return e.show=!0}));this._warning.style.display=this._filter.exceedsMaxValues?"block":"none";var a=this._filter.filterText||"",o=this._getCaseSensitive();this._cmbFilter.text=a;this._filterText=o?a:a.toLowerCase();this._rxFilter=this._getSearchExp(a,o);var s=this._view;s.pageSize=this._filter.maxValues;s.sourceCollection=i;setTimeout((function(){e._adjustWidths()}),0)};ValueFilterEditor.prototype.clearEditor=function(e){void 0===e&&(e=!0);this._cmbFilter.text="";this._filterText="";this._rxFilter=null;var t=this._view;t.pageSize=0;t.items.forEach((function(t){t.show=e}));t.moveCurrentTo(-1);t.refresh();t.pageSize=this._filter.maxValues};Object.defineProperty(ValueFilterEditor.prototype,"isEditorClear",{get:function(){return!this._filterText&&!this._cbSelectAll.indeterminate},enumerable:!0,configurable:!0});ValueFilterEditor.prototype._updateFilter=function(){var e=null,t=this._getItems();if(this._filterText||this._cbSelectAll.indeterminate){e={};for(var i=0;i<t.length;i++){var r=t[i];r.show&&(e[r.text]=!0)}}var n=this._filter;n.showValues=e;n.filterText=this._filterText};ValueFilterEditor.prototype.updateFilter=function(){var e=this;this._isFiltering?setTimeout((function(){e._updateFilter()}),Control._SEARCH_DELAY+100):this._updateFilter()};ValueFilterEditor.prototype.onCanApplyChanged=function(e){this.canApplyChanged.raise(this,e)};ValueFilterEditor.prototype._getCaseSensitive=function(){var e=this._filter.column,t=e?e.grid:null;return t&&t.caseSensitiveSearch};ValueFilterEditor.prototype._getItems=function(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection};ValueFilterEditor.prototype._filterTextChanged=function(){var e=this;""===this._filterText&&this._cbSelectAll.checked||this._filter.exclusiveValueSearch?this._lbValues._addMode=!1:this._lbValues._addMode=!0;this._toFilter&&clearTimeout(this._toFilter);this._isFiltering=!0;this._toFilter=setTimeout((function(){var t=e._cmbFilter.text,i=e._getCaseSensitive();i||(t=t.toLowerCase());if(t!=e._filterText){e._filterText=t;e._rxFilter=e._getSearchExp(t,i);e._view.refresh();if(!t){var r=e._initialItems;if(r.length&&e._view.sourceCollection.indexOf(r[0])>-1){e._lbValues.checkedItems=e._initialItems;e._updateSelectAllCheck();e._isFiltering=!1;return}}if(e._filter.exclusiveValueSearch){e._cbSelectAll.checked=!0;e._cbSelectAllClicked()}else e._updateSelectAllCheck()}e._isFiltering=!1}),Control._SEARCH_DELAY)};ValueFilterEditor.prototype._getSearchExp=function(e,t){if(!e)return null;switch(this._filter.searchType){case ValueFilterSearchKind.Text:return this._getTextSearchExp(e,t);case ValueFilterSearchKind.Regex:return this._getRegexSearchExp(e,t);case ValueFilterSearchKind.Excel:return this._getExcelSearchExp(e,t)}};ValueFilterEditor.prototype._getTextSearchExp=function(e,t){return new RegExp(escapeRegExp(e),t?"":"i")};ValueFilterEditor.prototype._getRegexSearchExp=function(e,t){try{return new RegExp(e,t?"s":"is")}catch(e){return new RegExp("(?!)",t?"s":"is")}};ValueFilterEditor.prototype._getExcelSearchExp=function(e,t){var i=e;i=(i=(i=(i=(i=i.replace(/([.+^$[\]\\(){}|-])/g,"\\$1")).replace(/(?<!~)(\?+)/g,(function(e,t){return Array.from(t).map((function(e){return"."})).join("")}))).replace(/(?<!~)(\*+)/g,(function(e,t){return Array.from(t).map((function(e){return".*"})).join("")}))).replace(/~~/g,"~")).replace(/~([?*])/g,"\\$1");/(?<!~)[?*]/g.test(e)&&(i="^"+i+"$");return new RegExp(i,t?"s":"is")};ValueFilterEditor.prototype._filterValues=function(e){var t=this._rxFilter;return null==t||null==e||t.test(e.text)};ValueFilterEditor.prototype._cbSelectAllClicked=function(){for(var e=this,t=this._cbSelectAll.checked,i=this._divValues.scrollTop,r=this._getItems(),n=0;n<r.length;n++)r[n].show=t;this._view.refresh();this._divValues.scrollTop=i;setTimeout((function(){e._adjustWidths()}),0)};ValueFilterEditor.prototype._updateSelectAllCheck=function(){for(var e=this._getItems(),t=0,i=0,r=0;r<e.length;r++){e[r].show?t++:i++;if(t&&i)break}setChecked(this._cbSelectAll,t&&i?null:t>0);this.canApply=t>0};ValueFilterEditor.prototype._adjustWidths=function(){var e=this._lbValues.hostElement;if(e&&e.offsetHeight>0){var t=0,i=e.querySelectorAll(".wj-listbox-item label");if(i.length){for(var r=0;r<i.length;r++)t=Math.max(t,i[r].scrollWidth);if(t){var n=e.querySelectorAll(".wj-listbox-item");if(n.length){var l=n[0],a=getComputedStyle(l),o=parseFloat(a.paddingLeft)+parseFloat(a.paddingRight);for(r=0;r<n.length;r++)n[r].style.width=t+o+"px"}}}}};ValueFilterEditor.prototype._createModal=function(){var e=this,t=this._filter.maxValues,i=document.createElement("div");i.className="modal";i.innerHTML='<div class="modal-content"><span class="close">&times;</span><p>This column has more than '+t+" unique items. Only the first "+t+" unique items are displayed. Please set the maxValues property of the ValueFilter to see all the values on the list.</p></div>";i.querySelector(".close").addEventListener("click",(function(){return e._modal.style.display="none"}));return i};ValueFilterEditor.prototype._showModal=function(){this._modal.style.display="block";this.hostElement.style.display="none"};ValueFilterEditor.controlTemplate='<div><div wj-part="div-filter"></div><div class="wj-listbox-item"><label><input wj-part="cb-select-all" type="checkbox"> <span wj-part="sp-select-all"></span></label></div><div wj-part="div-values"></div><div wj-part="warning-message" style="display: none;">Not all items are shown</div></div>';return ValueFilterEditor}(Control);export{ValueFilterEditor};var ColumnFilter=function(){function ColumnFilter(e,t){var i=this;this._owner=e;this._col=t;this._valueFilter=new ValueFilter(t);this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch;this._conditionFilter=new ConditionFilter(t);e.exclusiveValueSearchChanged.addHandler((function(e){i._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch}))}Object.defineProperty(ColumnFilter.prototype,"filterType",{get:function(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType},set:function(e){if((e=asEnum(e,FilterType,!0))!=this._filterType){var t=this.isActive;this.clear();this._filterType=e;t?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"dataMap",{get:function(){return this.conditionFilter.dataMap||this.valueFilter.dataMap},set:function(e){this.conditionFilter.dataMap=e;this.valueFilter.dataMap=e},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"valueFilter",{get:function(){return this._valueFilter},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"conditionFilter",{get:function(){return this._conditionFilter},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"isActive",{get:function(){return this._conditionFilter.isActive||this._valueFilter.isActive},enumerable:!0,configurable:!0});ColumnFilter.prototype.apply=function(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)};ColumnFilter.prototype.clear=function(){this._valueFilter.clear();this._conditionFilter.clear()};ColumnFilter.prototype.implementsInterface=function(e){return"IColumnFilter"==e};return ColumnFilter}();export{ColumnFilter};_addCultureInfo("FlexGridFilter",{ariaLabels:{edit:"Edit Filter for Column",dialog:"Filter Editor for Column",asc:"Sort Column in Ascending Order",dsc:"Sort Column in Descending Order",search:"Search Item List",op1:"First Condition Operator",val1:"First Condition Value",and:"Require both Conditions",or:"Require either Condition",op2:"Second Condition Operator",val2:"Second Condition Value"},ascending:"↑ Ascending",descending:"↓ Descending",apply:"Apply",cancel:"Cancel",clear:"Clear",conditions:"Filter by Condition",values:"Filter by Value",search:"Search",selectAll:"Select All",null:"(nothing)",header:"Show items where the value",and:"And",or:"Or",stringOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Begins with",op:Operator.BW},{name:"Ends with",op:Operator.EW},{name:"Contains",op:Operator.CT},{name:"Does not contain",op:Operator.NC}],numberOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Is Greater than",op:Operator.GT},{name:"Is Greater than or equal to",op:Operator.GE},{name:"Is Less than",op:Operator.LT},{name:"Is Less than or equal to",op:Operator.LE}],dateOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Is Before",op:Operator.LT},{name:"Is After",op:Operator.GT}],booleanOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE}]});var ColumnFilterEditor=function(e){__extends(ColumnFilterEditor,e);function ColumnFilterEditor(t,i,r){void 0===r&&(r=!0);var n=e.call(this,t,null,!0)||this;n.filterChanged=new Event;n.buttonClicked=new Event;n._filter=asType(i,ColumnFilter);var l=n.getTemplate();n.applyTemplate("wj-control wj-content wj-columnfiltereditor",l,{_divSort:"div-sort",_btnAsc:"btn-asc",_btnDsc:"btn-dsc",_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnApply:"btn-apply",_btnCancel:"btn-cancel",_btnClear:"btn-clear"});var a=culture.FlexGridFilter,o=a.ariaLabels,s=n.hostElement,u=n.filter.column,d=u.grid.collectionView;setAttribute(s,"role","dialog");setAriaLabel(s,o.dialog+" "+u.header);setAriaLabel(n._btnAsc,o.asc);setAriaLabel(n._btnDsc,o.dsc);setText(n._btnAsc,a.ascending);setText(n._btnDsc,a.descending);setText(n._aVal,a.values);setText(n._aCnd,a.conditions);setText(n._btnApply,a.apply);setText(n._btnCancel,a.cancel);setText(n._btnClear,a.clear);var c=n.filter.conditionFilter.isActive||0==(i.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;n._showFilter(c);r&&d&&d.canSort||(n._divSort.style.display="none");n._updateSortButtonState();var p=n._btnClicked.bind(n);n._btnApply.addEventListener("click",p);n._btnCancel.addEventListener("click",p);n._btnClear.addEventListener("click",p);n._btnAsc.addEventListener("click",p);n._btnDsc.addEventListener("click",p);n._aVal.addEventListener("click",p);n._aCnd.addEventListener("click",p);n.addEventListener(s,"keydown",(function(e){if(!e.defaultPrevented){var t=e.target.tagName.match(/^(a|button)$/i);switch(e.keyCode){case Key.Space:if(t){n._btnClicked(e);e.preventDefault()}break;case Key.Enter:if(t)n._btnClicked(e);else{n.updateFilter();n.onFilterChanged();n.onButtonClicked()}e.preventDefault();break;case Key.Escape:n.onButtonClicked();e.preventDefault();break;case Key.Tab:moveFocus(n.hostElement,e.shiftKey?-1:1);e.preventDefault()}}}));n.addEventListener(window,"resize",(function(){n.isTouching||n._wasTouching||n.onButtonClicked()}));return n}Object.defineProperty(ColumnFilterEditor.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});ColumnFilterEditor.prototype.updateEditor=function(){this._edtVal&&this._edtVal.updateEditor();this._edtCnd&&this._edtCnd.updateEditor()};ColumnFilterEditor.prototype.updateFilter=function(){switch(this._getFilterType()){case FilterType.Value:this._edtVal.updateFilter();this.filter.conditionFilter.clear();break;case FilterType.Condition:this._edtCnd.updateFilter();this.filter.valueFilter.clear()}};ColumnFilterEditor.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)};ColumnFilterEditor.prototype.onButtonClicked=function(e){this.buttonClicked.raise(this,e)};ColumnFilterEditor.prototype._showFilter=function(e){var t=this;this._wasTouching=this.isTouching;if(e==FilterType.Value&&null==this._edtVal){this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter);this._edtVal.canApplyChanged.addHandler((function(e){enable(t._btnApply,t._edtVal.canApply)}))}if(e==FilterType.Condition&&null==this._edtCnd){this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter);this._edtCnd.canApplyChanged.addHandler((function(e){enable(t._btnApply,t._edtCnd.canApply)}))}if(0!=(e&this.filter.filterType))if(e==FilterType.Value){this._divEdtVal.style.display="";this._divEdtCnd.style.display="none";this._enableLink(this._aVal,!1);this._enableLink(this._aCnd,!0);this._edtVal.focus();enable(this._btnApply,this._edtVal.canApply)}else{this._divEdtVal.style.display="none";this._divEdtCnd.style.display="";this._enableLink(this._aVal,!0);this._enableLink(this._aCnd,!1);this._edtCnd.focus();enable(this._btnApply,this._edtCnd.canApply)}var i=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:i.display="none";break;default:i.display=""}};ColumnFilterEditor.prototype._enableLink=function(e,t){toggleClass(e,"wj-state-disabled",!t);setAttribute(e,"href",t?"":null);setAttribute(e,"disabled",t?null:"disabled")};ColumnFilterEditor.prototype._updateSortButtonState=function(){var e=this.filter.column,t=e?e.currentSort:"",i="wj-state-active";toggleClass(this._btnAsc,i,"+"==t);toggleClass(this._btnDsc,i,"-"==t)};ColumnFilterEditor.prototype._getFilterType=function(){var e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition};ColumnFilterEditor.prototype._btnClicked=function(e){var t=this,i=e.target;e.preventDefault();e.stopPropagation();if(!hasClass(i,"wj-state-disabled"))if(i!=this._aVal)if(i!=this._aCnd){if(i==this._btnAsc||i==this._btnDsc){var r=this.filter.column,n=r.sortMemberPath||r.binding,l=r.grid.collectionView.sortDescriptions;l.deferUpdate((function(){l.clear();l.push(new SortDescription(n,e.target==t._btnAsc))}));this._updateSortButtonState()}if(i==this._btnApply){this.updateFilter();this.onFilterChanged()}else if(i==this._btnClear){if(this.filter.isActive){this.filter.clear();this.onFilterChanged()}}else this.updateEditor();this.onButtonClicked()}else{this._showFilter(FilterType.Condition);moveFocus(this._edtCnd.hostElement,0)}else{this._showFilter(FilterType.Value);moveFocus(this._edtVal.hostElement,0)}};ColumnFilterEditor.controlTemplate='<div><div wj-part="div-sort" class="wj-sort-buttons"><button wj-part="btn-asc" class="wj-btn"></button>&nbsp;&nbsp;&nbsp;<button wj-part="btn-dsc" class="wj-btn"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a>&nbsp;|&nbsp;<a wj-part="a-val" href="" draggable="false"></a></div><div wj-part="div-edt-val" tabindex="-1"></div><div wj-part="div-edt-cnd" tabindex="-1"></div><div style="text-align:right;margin-top:10px"><button wj-part="btn-apply" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-cancel" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-clear" class="wj-btn"></button></div></div>';return ColumnFilterEditor}(Control);export{ColumnFilterEditor};_registerModule("wijmo.grid.filter",selfModule);
/*!
*
* Wijmo Library 5.20241.001-nightly.d20240116.t020147
* Wijmo Library 5.20241.001-nightly.d20240117.t020138
* https://developer.mescius.com/wijmo

@@ -607,2 +607,3 @@ *

private _searchType;
private _exceedsMaxValues;
/**

@@ -772,2 +773,3 @@ * Initializes a new instance of the {@link ValueFilter} class.

getUniqueValues(filtered?: boolean): any[];
readonly exceedsMaxValues: boolean;
/**

@@ -801,2 +803,4 @@ * Returns true if this object supports a given interface.

private _lbValues;
private _warning;
private _modal;
/**

@@ -866,2 +870,4 @@ * Gets or sets the template used to instantiate {@link ColumnFilterEditor} controls.

private _adjustWidths;
private _createModal;
private _showModal;
}

@@ -868,0 +874,0 @@ /**

/*!
*
* Wijmo Library 5.20241.001-nightly.d20240116.t020147
* Wijmo Library 5.20241.001-nightly.d20240117.t020138
* https://developer.mescius.com/wijmo

@@ -14,2 +14,2 @@ *

"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}(),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});var FilterType,wijmo_grid_1=require("@grapecity/wijmo.grid"),wijmo_1=require("@grapecity/wijmo"),wijmo_input_1=require("@grapecity/wijmo.input"),input=__importStar(require("@grapecity/wijmo.input")),selfModule=__importStar(require("@grapecity/wijmo.grid.filter"));!function(e){e[e.None=0]="None";e[e.Condition=1]="Condition";e[e.Value=2]="Value";e[e.Both=3]="Both"}(FilterType=exports.FilterType||(exports.FilterType={}));var FlexGridFilter=function(){function FlexGridFilter(e,t){this._showIcons=!0;this._showSort=!0;this._defFilterType=FilterType.Both;this._xValueSearch=!0;this._includeUpdatedRowsInFilter=!1;this.filterApplied=new wijmo_1.Event;this.editingFilter=new wijmo_1.Event;this.filterChanging=new wijmo_1.Event;this.filterChanged=new wijmo_1.Event;this.exclusiveValueSearchChanged=new wijmo_1.Event;this._filters=[];this._g=wijmo_1.asType(e,wijmo_grid_1.FlexGrid,!1);this._g.formatItem.addHandler(this._formatItem.bind(this));this._g.itemsSourceChanged.addHandler(this.clear.bind(this));var i=this._g.hostElement;e.addEventListener(i,"mousedown",this._mousedown.bind(this),!0);e.addEventListener(i,"click",this._click.bind(this),!0);e.addEventListener(i,"keydown",this._keydown.bind(this),!0);this._g.invalidate();wijmo_1.copy(this,t);this._init()}FlexGridFilter.prototype._init=function(){var e=this,t=this.grid,_excludeRowFromFilter=function(t){var i=e.grid,r=e.excludedRowsSet;i.itemsSource?i.rows[t]instanceof wijmo_grid_1._NewRowTemplate?r.add(i.editableCollectionView.currentAddItem||i.rows[t].dataItem):r.add(i.rows[t].dataItem):r.add(i.rows[t])};t.rowChanged&&t.rowChanged.addHandler((function(e,t){t.added&&_excludeRowFromFilter(t.index)}));t.rowEditEnding.addHandler((function(e,t){_excludeRowFromFilter(t.row)}));t.cellEditEnded.addHandler((function(e,t){_excludeRowFromFilter(t.row)}))};Object.defineProperty(FlexGridFilter.prototype,"excludedRowsSet",{get:function(){var e=this.grid;e.selectedSheet&&(e=e.selectedSheet);e._newAddedRowsSet||(e._newAddedRowsSet=new WeakSet);return e._newAddedRowsSet},set:function(e){var t=this.grid;t.selectedSheet&&(t=t.selectedSheet);t._newAddedRowsSet=e},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"filterColumns",{get:function(){return this._filterColumns},set:function(e){this._filterColumns=wijmo_1.asArray(e);this.clear()},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"showFilterIcons",{get:function(){return this._showIcons},set:function(e){if(e!=this.showFilterIcons){this._showIcons=wijmo_1.asBoolean(e);this._g&&this._g.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"showSortButtons",{get:function(){return this._showSort},set:function(e){this._showSort=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"reApplyFilterOnUpdate",{get:function(){return this._includeUpdatedRowsInFilter},set:function(e){e!==this._includeUpdatedRowsInFilter&&(this._includeUpdatedRowsInFilter=wijmo_1.asBoolean(e))},enumerable:!0,configurable:!0});FlexGridFilter.prototype.getColumnFilter=function(e,t){void 0===t&&(t=!0);if(e=this._asColumn(e)){for(var i=0;i<this._filters.length;i++)if(this._filters[i].column==e)return this._filters[i];if(t&&e.binding){var r=new ColumnFilter(this,e);this._filters.push(r);return r}}return null};Object.defineProperty(FlexGridFilter.prototype,"defaultFilterType",{get:function(){return this._defFilterType},set:function(e){if((e=wijmo_1.asEnum(e,FilterType,!1))!=this.defaultFilterType){this._defFilterType=e;this._g.invalidate();this.clear()}},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){if((e=wijmo_1.asBoolean(e))!==this._xValueSearch){this._xValueSearch=e;this.onExclusiveValueSearchChanged()}},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"filterDefinition",{get:function(){var e=this,t={defaultFilterType:this.defaultFilterType,filters:[]};this._filters.forEach((function(i){var r=i.conditionFilter,n=i.valueFilter,l=n.uniqueValues&&n.uniqueValues.length;if(i&&i.column&&i.column.binding&&(i.isActive||l||i.filterType!=e.defaultFilterType)){var o={binding:i.column.binding};if(r.isActive){var a=r.condition1,s=r.condition2;o={binding:i.column.binding,type:"condition",condition1:{operator:a.operator,value:a.value},and:r.and,condition2:{operator:s.operator,value:s.value}}}else(n.isActive||l)&&(o={binding:i.column.binding,type:"value",uniqueValues:n.uniqueValues,sortValues:n.sortValues,maxValues:n.maxValues,exclusiveValueSearch:n.exclusiveValueSearch,showValues:n.showValues});i.filterType!=e.defaultFilterType&&(o.filterType=i.filterType);t.filters.push(o)}}));return JSON.stringify(t)},set:function(e){e=wijmo_1.asString(e);this.clear();if(e){var t=JSON.parse(e);this.defaultFilterType=t.defaultFilterType;for(var _loop_1=function(e){var r=t.filters[e],n=i._asColumn(r.binding);n||(n=new wijmo_grid_1.Column({binding:r.binding}));var l=i.getColumnFilter(n,!0);if(l){null!=r.filterType&&(l.filterType=wijmo_1.asEnum(r.filterType,FilterType));switch(r.type){case"condition":var o=l.conditionFilter;o.condition1.value=n.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(r.condition1.value,n.dataType,null):r.condition1.value;o.condition1.operator=r.condition1.operator;o.and=r.and;o.condition2.value=n.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(r.condition2.value,n.dataType,null):r.condition2.value;o.condition2.operator=r.condition2.operator;break;case"value":var a=l.valueFilter;a.uniqueValues=r.uniqueValues;["sortValues","maxValues","exclusiveValueSearch"].forEach((function(e){null!=r[e]&&(a[e]=r[e])}));a.showValues=r.showValues}}},i=this,r=0;r<t.filters.length;r++)_loop_1(r)}this.apply()},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"activeEditor",{get:function(){return wijmo_1.Control.getControl(this._divEdt)},enumerable:!0,configurable:!0});FlexGridFilter.prototype.editColumnFilter=function(e,t,i){var r=this,n=this._g;this.closeEditor();e=this._asColumn(e);var l=new wijmo_grid_1.CellRangeEventArgs(n.cells,new wijmo_grid_1.CellRange(-1,e.index));if(this.onEditingFilter(l)){var o=wijmo_1.createElement('<div class="wj-dropdown-panel"></div>'),a=this.getColumnFilter(e),s=new ColumnFilterEditor(o,a,this.showSortButtons);this._divEdt=o;this._edtCol=e;n.rightToLeft&&(o.dir="rtl");if(this.onFilterChanging(l)){l.cancel=!0;s.filterChanged.addHandler((function(){l.cancel=!1;setTimeout((function(){if(!l.cancel){r.excludedRowsSet=null;r.apply()}}),s._edtVal&&s._edtVal._isFiltering?wijmo_1.Control._SEARCH_DELAY+200:0)}));s.buttonClicked.addHandler((function(){r.closeEditor();n.focus();r.onFilterChanged(l)}));s.lostFocus.addHandler((function(){setTimeout((function(){var e=wijmo_1.Control.getControl(r._divEdt);e&&!e.containsFocus()&&r.closeEditor()}),10)}));var u=t?t.col:e.index,d=n.columns[u];t||d&&d.binding==e.binding||(u=n.selection.leftCol);n._edtHdl._commitRowEdits();n.scrollIntoView(-1,u,!0);var c=n.columnHeaders,p=t&&t.panel&&c&&t.panel._uid==c._uid?t.row:c.rows.length-1,_=u,h=i||c.getCellElement(p,_),f=h?null:c.getCellBoundingRect(p,_);h?wijmo_1.showPopup(o,h,!1,!1,!1):wijmo_1.showPopup(o,f);this._setAriaExpanded(h,!0);this._setAriaExpanded(n.cells.getCellElement(-1,_),!0);for(var m=s.hostElement.querySelectorAll("input"),b=0;b<m.length;b++){var v=m[b];if(v.offsetHeight>0&&v.tabIndex>-1&&!v.disabled){v.focus();break}}s.containsFocus()||s.focus()}else this._divEdt=this._edtCol=null}};FlexGridFilter.prototype._setAriaExpanded=function(e,t){if(e){var i=e.querySelector("."+FlexGridFilter._WJC_FILTER);wijmo_1.setAttribute(i,"aria-expanded",t)}};FlexGridFilter.prototype.closeEditor=function(){var e=this._g,t=wijmo_1.Control.getControl(this._divEdt),i=this._edtCol;t&&wijmo_1.hidePopup(t.hostElement,(function(){t.dispose()}));if(i){var r=e.columnHeaders,n=r.rows.length?r.getCellElement(r.rows.length-1,i.index):null;this._setAriaExpanded(n,!1);n=e.cells.getCellElement(-1,i.index);this._setAriaExpanded(n,!1)}this._divEdt=null;this._edtCol=null};FlexGridFilter.prototype.apply=function(){var e=this._g.collectionView;if(e){var t=this._g.editableCollectionView;if(t){t.commitEdit();t.commitNew()}e.filter=this._filter.bind(this)}var i=e?e.updateFilterDefinition:null;wijmo_1.isFunction(i)&&i.call(e,this);this.onFilterApplied()};FlexGridFilter.prototype.clear=function(){if(this._filters.length){this._filters=[];this.apply()}};FlexGridFilter.prototype.onFilterApplied=function(e){this.filterApplied.raise(this,e)};FlexGridFilter.prototype.onEditingFilter=function(e){this.editingFilter.raise(this,e);return!e.cancel};FlexGridFilter.prototype.onFilterChanging=function(e){this.filterChanging.raise(this,e);return!e.cancel};FlexGridFilter.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)};FlexGridFilter.prototype.onExclusiveValueSearchChanged=function(e){this.exclusiveValueSearchChanged.raise(this,e)};FlexGridFilter.prototype._asColumn=function(e){return wijmo_1.isString(e)?this._g.getColumn(e,!0):wijmo_1.isNumber(e)?this._g.columns[e]:wijmo_1.asType(e,wijmo_grid_1.Column,!1)};FlexGridFilter.prototype._filter=function(e){var t=this.excludedRowsSet;if(!this.reApplyFilterOnUpdate&&t.has(e))return!0;for(var i=this._filters,r=0;r<i.length;r++){var n=i[r];if(n.column!=FlexGridFilter._skipColumn&&!n.apply(e))return!1}return!0};FlexGridFilter.prototype._formatItem=function(e,t){if(t.panel==e.columnHeaders){var i=this._g,r=i.getMergedRange(t.panel,t.row,t.col)||new wijmo_grid_1.CellRange(t.row,t.col),n=i.columns[r.col],l=i._getBindingColumn(t.panel,t.row,n),o=t.cell;if(r.row2==t.panel.rows.length-1||n!=l){var a=this.getColumnFilter(l,this.defaultFilterType!=FilterType.None),s=this._filterColumns;s&&s.length&&s.indexOf(l.binding)<0&&s.indexOf(l.name)<0&&(a=null);if(a){wijmo_1.toggleClass(o,"wj-filter-on",a.isActive);wijmo_1.toggleClass(o,"wj-filter-off",!a.isActive)}else{wijmo_1.removeClass(o,"wj-filter-on");wijmo_1.removeClass(o,"wj-filter-off")}if(a&&a.filterType!=FilterType.None){this._showIcons&&this._addFilterButton(l,a,o);0==t.row&&(o=i.cells.getCellElement(-1,t.col))&&this._addFilterButton(n,a,o)}}}};FlexGridFilter.prototype._addFilterButton=function(e,t,i){var r=FlexGridFilter._WJC_FILTER,n=wijmo_1.createElement('<button class="wj-btn wj-btn-glyph wj-right '+r+'" type="button" tabindex="-1"><span class="wj-glyph-filter"></span></button>');wijmo_1.setAriaLabel(n,wijmo_1.culture.FlexGridFilter.ariaLabels.edit+" "+e.header);wijmo_1.setAttribute(n,"aria-haspopup","dialog");wijmo_1.setAttribute(n,"aria-expanded",!1);wijmo_1.setAttribute(n,"aria-describedby",e.describedById);wijmo_1.setAttribute(n,"aria-pressed",t.isActive);if(!i.querySelector("."+r)){1==i.children.length&&(i=i.querySelector("div")||i);i.insertBefore(n,i.firstChild)}};FlexGridFilter.prototype._mousedown=function(e){this._edtColPrev=this._edtCol};FlexGridFilter.prototype._click=function(e){if(this._toggleEditor(e)){e.stopPropagation();e.preventDefault()}};FlexGridFilter.prototype._toggleEditor=function(e){var t=this;if(!e.defaultPrevented&&0==e.button)if(wijmo_1.closestClass(e.target,FlexGridFilter._WJC_FILTER)){var i=this._g,r=i.hitTest(e.target);r.panel||(r=i.hitTest(e));if(r.panel&&i.columnHeaders&&i.cells&&(r.panel._uid==i.columnHeaders._uid||r.panel._uid==i.cells._uid&&-1==r.row)){var n=i.getMergedRange(r.panel,r.row,r.col)||new wijmo_grid_1.CellRange(r.row,r.col),l=i.columns[n.col],o=i._getBindingColumn(r.panel,r.row,l);if(this._divEdt&&this._edtCol==o){this.closeEditor();i.focus()}else o!=this._edtColPrev&&setTimeout((function(){t.editColumnFilter(o,r)}),this._divEdt?100:0);return!0}}else this.closeEditor();return!1};FlexGridFilter.prototype._keydown=function(e){if(!e.defaultPrevented&&!e.ctrlKey&&e.altKey&&(e.keyCode==wijmo_1.Key.Down||e.keyCode==wijmo_1.Key.Up)){var t=this.grid,i=t.selection,r=i.col>-1?t.columns[i.col]:null,n=r?t._getBindingColumn(t.cells,i.row,r):null,l=n&&n.dataMap&&n.dataMapEditor==wijmo_grid_1.DataMapEditor.DropDownList;if(this.filterColumns&&this.filterColumns.length>0&&!this.filterColumns.includes(n._binding._path)){e.preventDefault();return!1}n&&n.editor instanceof wijmo_input_1.DropDown&&(l=!0);if(n&&!l){var o=this.getColumnFilter(n,!1);if(o&&o.filterType!=FilterType.None){this.editColumnFilter(n);e.preventDefault();e.stopPropagation()}}}};FlexGridFilter._WJC_FILTER="wj-elem-filter";return FlexGridFilter}();exports.FlexGridFilter=FlexGridFilter;exports.empty={};var ConditionFilter=function(){function ConditionFilter(e){this._c1=new FilterCondition(this);this._c2=new FilterCondition(this);this._and=!0;this._col=e}Object.defineProperty(ConditionFilter.prototype,"condition1",{get:function(){return this._c1},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"condition2",{get:function(){return this._c2},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"and",{get:function(){return this._and},set:function(e){this._and=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map=wijmo_1.asType(e,wijmo_grid_1.DataMap,!0)},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"isActive",{get:function(){return this._c1.isActive||this._c2.isActive},enumerable:!0,configurable:!0});ConditionFilter.prototype.apply=function(e){var t=this._col,i=this._c1,r=this._c2,n=!1,l=!1;if(!t||!t._binding||!this.isActive)return!0;e=t._binding.getValue(e);var o=this.dataMap||t.dataMap;if(o)e=o.getDisplayValue(e);else if(wijmo_1.isDate(e)){n=!this._hasTimePart();l=!this._hasDatePart();var a=FilterCondition._refDateTime;n?e=wijmo_1.DateTime.fromDateTime(e,a):l&&(e=wijmo_1.DateTime.fromDateTime(a,e))}else if(wijmo_1.isNumber(e)){var s=wijmo_1.Globalize,u=t.format,d=s.formatNumber(e,u);e=s.parseFloat(d,u)}var c=i.apply(e,n,l),p=r.apply(e,n,l);return i.isActive&&r.isActive?this._and?c&&p:c||p:i.isActive?c:!r.isActive||p};ConditionFilter.prototype.clear=function(){this._c1.clear();this._c2.clear();this.and=!0};ConditionFilter.prototype._hasDatePart=function(){var e=this._col.format;if(!e)return!0;e=wijmo_1.culture.Globalize.calendar.patterns[e]||e;return/[yMd]+/.test(e)};ConditionFilter.prototype._hasTimePart=function(){var e=this._col.format;if(!e)return!1;e=wijmo_1.culture.Globalize.calendar.patterns[e]||e;return/[Hmst]+/.test(e)};ConditionFilter.prototype.implementsInterface=function(e){return"IColumnFilter"==e};return ConditionFilter}();exports.ConditionFilter=ConditionFilter;var ConditionFilterEditor=function(e){__extends(ConditionFilterEditor,e);function ConditionFilterEditor(t,i){var r=e.call(this,t)||this;r._canApply=!1;r.canApplyChanged=new wijmo_1.Event;r._filter=wijmo_1.asType(i,ConditionFilter,!1);var n=r.getTemplate();r.applyTemplate("wj-control wj-conditionfilter-editor",n,{_divHdr:"div-hdr",_divCmb1:"div-cmb1",_divVal1:"div-val1",_btnAnd:"btn-and",_btnOr:"btn-or",_spAnd:"sp-and",_spOr:"sp-or",_divCmb2:"div-cmb2",_divVal2:"div-val2"});var l=wijmo_1.culture.FlexGridFilter,o=l.ariaLabels;wijmo_1.setAriaLabel(r._btnAnd,o.and);wijmo_1.setAriaLabel(r._btnOr,o.or);wijmo_1.setText(r._divHdr,l.header);wijmo_1.setText(r._spAnd,l.and);wijmo_1.setText(r._spOr,l.or);var a=wijmo_1.getUniqueId("cmb1");r._divHdr.htmlFor=a;r._divCmb1.id=a;r._cmb1=r._createOperatorCombo(r._divCmb1,o.op1);r._cmb2=r._createOperatorCombo(r._divCmb2,o.op2);r._val1=r._createValueInput(r._divVal1,o.val1);r._val2=r._createValueInput(r._divVal2,o.val2);r._val1.isDisabled=!0;r._cmb1.selectedIndexChanged.addHandler((function(e,t){r._val1.isDisabled=null==e.selectedValue;r.canApply=!r._val1.isDisabled||!r._val2.isDisabled}));r._val2.isDisabled=!0;r._cmb2.selectedIndexChanged.addHandler((function(e,t){r._val2.isDisabled=null==e.selectedValue;r.canApply=!r._val1.isDisabled||!r._val2.isDisabled}));var s=r.hostElement;r.addEventListener(s,"change",r._btnAndOrChanged.bind(r));r.addEventListener(s,"keydown",r._keydown.bind(r));setTimeout((function(){r.updateEditor()}));return r}Object.defineProperty(ConditionFilterEditor.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilterEditor.prototype,"canApply",{get:function(){return this._canApply},set:function(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}},enumerable:!0,configurable:!0});ConditionFilterEditor.prototype.updateEditor=function(){var e=this._filter.condition1,t=this._filter.condition2;this._cmb1.selectedValue=e.operator;this._cmb2.selectedValue=t.operator;if(this._val1 instanceof input.ComboBox&&!(this._val1 instanceof input.InputTime)){this._val1.text=wijmo_1.changeType(e.value,wijmo_1.DataType.String);this._val2.text=wijmo_1.changeType(t.value,wijmo_1.DataType.String)}else{this._val1.value=e.value;this._val2.value=t.value}var i=this._filter.and;this._checkRadio(this._btnAnd,i);this._checkRadio(this._btnOr,!i)};ConditionFilterEditor.prototype.clearEditor=function(){this._cmb1.selectedValue=this._cmb2.selectedValue=null;this._val1.text=this._val2.text=null;this._checkRadio(this._btnAnd,!0);this._checkRadio(this._btnOr,!1)};Object.defineProperty(ConditionFilterEditor.prototype,"isEditorClear",{get:function(){return null==this._cmb1.selectedValue&&!this._val1.text&&null==this._cmb2.selectedValue&&!this._val2.text},enumerable:!0,configurable:!0});ConditionFilterEditor.prototype.updateFilter=function(){var e=this._filter.condition1,t=this._filter.condition2;e.operator=this._cmb1.selectedValue;t.operator=this._cmb2.selectedValue;if("value"in this._val1){e.value=this._val1.value;t.value=this._val2.value}else{e.value=this._getComboValue(this._val1);t.value=this._getComboValue(this._val2)}this._filter.and=this._btnAnd.checked};ConditionFilterEditor.prototype.onCanApplyChanged=function(e){this.canApplyChanged.raise(this,e)};ConditionFilterEditor.prototype._getComboValue=function(e){return e.selectedIndex>-1?e.selectedValue:e.text};ConditionFilterEditor.prototype._createOperatorCombo=function(e,t){var i=this._filter.column,r=wijmo_1.culture.FlexGridFilter,n=r.stringOperators,l=wijmo_1.DataType;this._filter.dataMap||i.dataMap||(i.dataType==l.Date?n=r.dateOperators:i.dataType==l.Number?n=r.numberOperators:i.dataType==l.Boolean&&(n=r.booleanOperators));var o=new input.ComboBox(e,{itemsSource:n,displayMemberPath:"name",selectedValuePath:"op"});wijmo_1.setAriaLabel(o.inputElement,t);return o};ConditionFilterEditor.prototype._createValueInput=function(e,t){var i=this._filter,r=i.column,n=i.dataMap||r.dataMap,l=null,o=wijmo_1.DataType;if(r.dataType==o.Date)(l=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(e):new input.InputDate(e):new input.InputTime(e)).format=r.format;else if(r.dataType!=o.Number||n){(l=new input.ComboBox(e)).isEditable=!0;if(n){l.itemsSource=n.getDisplayValues();l.caseSensitiveSearch=!!r.grid&&r.grid.caseSensitiveSearch}else r.dataType==o.Boolean&&(l.itemsSource=[!0,!1])}else(l=new input.InputNumber(e)).format=r.format;l.isRequired=!1;wijmo_1.setAriaLabel(l.inputElement,t);return l};ConditionFilterEditor.prototype._btnAndOrChanged=function(e){var t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i){this._checkRadio(this._btnAnd,t);this._checkRadio(this._btnOr,i)}};ConditionFilterEditor.prototype._checkRadio=function(e,t){e.checked=t;wijmo_1.setAttribute(e,"aria-checked",t.toString());wijmo_1.setAttribute(e,"tabindex",t?null:"-1")};ConditionFilterEditor.prototype._keydown=function(e){var t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i)switch(e.keyCode){case wijmo_1.Key.Left:case wijmo_1.Key.Right:case wijmo_1.Key.Up:case wijmo_1.Key.Down:var r=t?this._btnOr:this._btnAnd;r.click();r.focus();e.preventDefault()}};ConditionFilterEditor.controlTemplate='<div><label wj-part="div-hdr"></label><div wj-part="div-cmb1"></div><br/><div wj-part="div-val1"></div><br/><div role="radiogroup" style="text-align:center"><label><input wj-part="btn-and" type="radio" role="radio"> <span wj-part="sp-and"></span> </label>&nbsp;&nbsp;&nbsp;<label><input wj-part="btn-or" type="radio" role="radio"> <span wj-part="sp-or"></span> </label></div><div wj-part="div-cmb2"></div><br/><div wj-part="div-val2"></div><br/></div>';return ConditionFilterEditor}(wijmo_1.Control);exports.ConditionFilterEditor=ConditionFilterEditor;var Operator,ValueFilterSearchKind,FilterCondition=function(){function FilterCondition(e){this._op=null;this._filter=e}Object.defineProperty(FilterCondition.prototype,"operator",{get:function(){return this._op},set:function(e){this._op=wijmo_1.asEnum(e,Operator,!0)},enumerable:!0,configurable:!0});Object.defineProperty(FilterCondition.prototype,"value",{get:function(){return this._val},set:function(e){this._val=e;this._strVal=wijmo_1.isString(e)?this._getCaseString(e):null},enumerable:!0,configurable:!0});Object.defineProperty(FilterCondition.prototype,"isActive",{get:function(){switch(this._op){case null:return!1;case Operator.EQ:case Operator.NE:return!0;default:return null!=this._val||null!=this._strVal}},enumerable:!0,configurable:!0});FilterCondition.prototype.clear=function(){this.operator=null;this.value=null};FilterCondition.prototype.apply=function(e,t,i){var r=this._strVal||this._val;wijmo_1.isString(e)&&(e=this._getCaseString(e));wijmo_1.isString(r)&&null==e&&(e="");wijmo_1.isDate(r)&&(t?r=wijmo_1.DateTime.fromDateTime(r,FilterCondition._refDateTime):i&&(r=wijmo_1.DateTime.fromDateTime(FilterCondition._refDateTime,r)));var n=Operator;switch(this._op){case null:return!0;case n.EQ:return null!=e&&null!=r?e.valueOf()==r.valueOf():e==r;case n.NE:return null!=e&&null!=r?e.valueOf()!=r.valueOf():e!=r;case n.GT:return e>r;case n.GE:return e>=r;case n.LT:return e<r;case n.LE:return e<=r;case n.BW:return!(null==this._strVal||!wijmo_1.isString(e))&&0==e.indexOf(this._strVal);case n.EW:return!!(null!=this._strVal&&wijmo_1.isString(e)&&e.length>=this._strVal.length)&&e.substr(e.length-this._strVal.length)==r;case n.CT:return!(null==this._strVal||!wijmo_1.isString(e))&&e.indexOf(this._strVal)>-1;case n.NC:return!(null==this._strVal||!wijmo_1.isString(e))&&e.indexOf(this._strVal)<0}throw"Unknown operator"};FilterCondition.prototype._getCaseString=function(e){var t=this._filter.column,i=t?t.grid:null;return i&&i.caseSensitiveSearch?e:e.toLowerCase()};FilterCondition._refDateTime=new Date(2e3,0,1,0,0,0);return FilterCondition}();exports.FilterCondition=FilterCondition;!function(e){e[e.EQ=0]="EQ";e[e.NE=1]="NE";e[e.GT=2]="GT";e[e.GE=3]="GE";e[e.LT=4]="LT";e[e.LE=5]="LE";e[e.BW=6]="BW";e[e.EW=7]="EW";e[e.CT=8]="CT";e[e.NC=9]="NC"}(Operator=exports.Operator||(exports.Operator={}));!function(e){e[e.Text=0]="Text";e[e.Regex=1]="Regex";e[e.Excel=2]="Excel"}(ValueFilterSearchKind=exports.ValueFilterSearchKind||(exports.ValueFilterSearchKind={}));var ValueFilter=function(){function ValueFilter(e){this._values=null;this._filterText=null;this._xValueSearch=!0;this._maxValues=250;this._uniqueValues=null;this._sortValues=!0;this._searchType=ValueFilterSearchKind.Excel;this._col=e}Object.defineProperty(ValueFilter.prototype,"searchType",{get:function(){return this._searchType},set:function(e){this._searchType=wijmo_1.asEnum(e,ValueFilterSearchKind)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"showValues",{get:function(){return this._values},set:function(e){this._values=e},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"filterText",{get:function(){return this._filterText},set:function(e){this._filterText=wijmo_1.asString(e)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){if((e=wijmo_1.asBoolean(e))!==this._xValueSearch){this._xValueSearch=wijmo_1.asBoolean(e);e&&(this._filterText="")}},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"maxValues",{get:function(){return this._maxValues},set:function(e){this._maxValues=wijmo_1.asNumber(e,!1,!0)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"uniqueValues",{get:function(){return this._uniqueValues},set:function(e){this._uniqueValues=wijmo_1.asArray(e)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"sortValues",{get:function(){return this._sortValues},set:function(e){this._sortValues=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map=wijmo_1.asType(e,wijmo_grid_1.DataMap,!0)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"isActive",{get:function(){return null!=this._values&&Object.keys(this._values).length>0},enumerable:!0,configurable:!0});ValueFilter.prototype.apply=function(e){var t=this.column;if(!(t&&t._binding&&this._values&&Object.keys(this._values).length))return!0;e=t._binding.getValue(e);e=this.dataMap?this.dataMap.getDisplayValue(e)||"":t.dataMap?t.dataMap.getDisplayValue(e)||"":wijmo_1.Globalize.format(e,t.format);return null!=this._values[e]};ValueFilter.prototype.clear=function(){this.showValues=null;this.filterText=null};ValueFilter.prototype.getUniqueValues=function(e){void 0===e&&(e=!0);var t=[],i=this.column,r=wijmo_1.Globalize.format;if(this.uniqueValues){this.uniqueValues.forEach((function(e){t.push({value:e,text:r(e,i.format)})}));return t}var n={},l=i.collectionView,o=l?l.sourceCollection:[];if(e&&l&&l.sourceCollection&&l.filter)try{FlexGridFilter._skipColumn=this._col;for(var a=[],s=0;s<o.length;s++)l.filter(o[s])&&a.push(o[s]);o=a}finally{FlexGridFilter._skipColumn=null}for(s=0;s<o.length;s++){var u=i._binding.getValue(o[s]),d=this.dataMap?this.dataMap.getDisplayValue(u)||"":i.dataMap?i.dataMap.getDisplayValue(u)||"":r(u,i.format);if(!n[d]){n[d]=!0;t.push({value:u,text:d})}}return t};ValueFilter.prototype.implementsInterface=function(e){return"IColumnFilter"==e};return ValueFilter}();exports.ValueFilter=ValueFilter;var ValueFilterEditor=function(e){__extends(ValueFilterEditor,e);function ValueFilterEditor(t,i){var r=e.call(this,t)||this;r._canApply=!1;r._isFiltering=!1;r.canApplyChanged=new wijmo_1.Event;r._filter=wijmo_1.asType(i,ValueFilter,!1);var n=r.getTemplate();r.applyTemplate("wj-control wj-valuefilter-editor",n,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values"});r._cbSelectAll.tabIndex=0;var l=wijmo_1.culture.FlexGridFilter;wijmo_1.setText(r._spSelectAll,l.selectAll);var o=r._view=new wijmo_1.CollectionView(null,{sortNulls:wijmo_1.SortNulls.First,filter:r._filterValues.bind(r)});if(i.sortValues){var a=i.column.dataMap||i.dataMap?"text":"value",s=i.column.dataType!=wijmo_1.DataType.Boolean;o.sortDescriptions.push(new wijmo_1.SortDescription(a,s))}o.collectionChanged.addHandler(r._updateSelectAllCheck,r);r._filterText="";r._rxFilter=null;r._cmbFilter=new input.ComboBox(r._divFilter,{isRequired:!1,placeholder:l.search});r._cmbFilter.isEditable=!0;r._lbValues=new input.ListBox(r._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:r._view,itemFormatter:function(e,t){return t||l.null},checkedItemsChanged:function(e){return r._updateSelectAllCheck()}});wijmo_1.setAriaLabel(r._cmbFilter.inputElement,l.ariaLabels.search);wijmo_1.setAttribute(r._lbValues.hostElement,"aria-multiselectable",!0);r._cmbFilter.inputElement.addEventListener("input",r._filterTextChanged.bind(r));r._cbSelectAll.addEventListener("click",r._cbSelectAllClicked.bind(r));r.updateEditor();r._initialItems=r._lbValues.checkedItems;return r}Object.defineProperty(ValueFilterEditor.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilterEditor.prototype,"canApply",{get:function(){return this._canApply},set:function(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}},enumerable:!0,configurable:!0});ValueFilterEditor.prototype.updateEditor=function(){var e=this,t=this._filter.column,i=this._filter.getUniqueValues(!0);this._lbValues.isContentHtml=t.isContentHtml;var r=this._filter.showValues;if(r&&0!=Object.keys(r).length){for(var n in r)for(var l=0;l<i.length;l++)if(i[l].text==n){i[l].show=!0;break}}else i.forEach((function(e){return e.show=!0}));var o=this._filter.filterText||"",a=this._getCaseSensitive();this._cmbFilter.text=o;this._filterText=a?o:o.toLowerCase();this._rxFilter=this._getSearchExp(o,a);var s=this._view;s.pageSize=this._filter.maxValues;s.sourceCollection=i;setTimeout((function(){e._adjustWidths()}),0)};ValueFilterEditor.prototype.clearEditor=function(e){void 0===e&&(e=!0);this._cmbFilter.text="";this._filterText="";this._rxFilter=null;var t=this._view;t.pageSize=0;t.items.forEach((function(t){t.show=e}));t.moveCurrentTo(-1);t.refresh();t.pageSize=this._filter.maxValues};Object.defineProperty(ValueFilterEditor.prototype,"isEditorClear",{get:function(){return!this._filterText&&!this._cbSelectAll.indeterminate},enumerable:!0,configurable:!0});ValueFilterEditor.prototype._updateFilter=function(){var e=null,t=this._getItems();if(this._filterText||this._cbSelectAll.indeterminate){e={};for(var i=0;i<t.length;i++){var r=t[i];r.show&&(e[r.text]=!0)}}var n=this._filter;n.showValues=e;n.filterText=this._filterText};ValueFilterEditor.prototype.updateFilter=function(){var e=this;this._isFiltering?setTimeout((function(){e._updateFilter()}),wijmo_1.Control._SEARCH_DELAY+100):this._updateFilter()};ValueFilterEditor.prototype.onCanApplyChanged=function(e){this.canApplyChanged.raise(this,e)};ValueFilterEditor.prototype._getCaseSensitive=function(){var e=this._filter.column,t=e?e.grid:null;return t&&t.caseSensitiveSearch};ValueFilterEditor.prototype._getItems=function(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection};ValueFilterEditor.prototype._filterTextChanged=function(){var e=this;""===this._filterText&&this._cbSelectAll.checked||this._filter.exclusiveValueSearch?this._lbValues._addMode=!1:this._lbValues._addMode=!0;this._toFilter&&clearTimeout(this._toFilter);this._isFiltering=!0;this._toFilter=setTimeout((function(){var t=e._cmbFilter.text,i=e._getCaseSensitive();i||(t=t.toLowerCase());if(t!=e._filterText){e._filterText=t;e._rxFilter=e._getSearchExp(t,i);e._view.refresh();if(!t){var r=e._initialItems;if(r.length&&e._view.sourceCollection.indexOf(r[0])>-1){e._lbValues.checkedItems=e._initialItems;e._updateSelectAllCheck();e._isFiltering=!1;return}}if(e._filter.exclusiveValueSearch){e._cbSelectAll.checked=!0;e._cbSelectAllClicked()}else e._updateSelectAllCheck()}e._isFiltering=!1}),wijmo_1.Control._SEARCH_DELAY)};ValueFilterEditor.prototype._getSearchExp=function(e,t){if(!e)return null;switch(this._filter.searchType){case ValueFilterSearchKind.Text:return this._getTextSearchExp(e,t);case ValueFilterSearchKind.Regex:return this._getRegexSearchExp(e,t);case ValueFilterSearchKind.Excel:return this._getExcelSearchExp(e,t)}};ValueFilterEditor.prototype._getTextSearchExp=function(e,t){return new RegExp(wijmo_1.escapeRegExp(e),t?"":"i")};ValueFilterEditor.prototype._getRegexSearchExp=function(e,t){try{return new RegExp(e,t?"s":"is")}catch(e){return new RegExp("(?!)",t?"s":"is")}};ValueFilterEditor.prototype._getExcelSearchExp=function(e,t){var i=e;i=(i=(i=(i=(i=i.replace(/([.+^$[\]\\(){}|-])/g,"\\$1")).replace(/(?<!~)(\?+)/g,(function(e,t){return Array.from(t).map((function(e){return"."})).join("")}))).replace(/(?<!~)(\*+)/g,(function(e,t){return Array.from(t).map((function(e){return".*"})).join("")}))).replace(/~~/g,"~")).replace(/~([?*])/g,"\\$1");/(?<!~)[?*]/g.test(e)&&(i="^"+i+"$");return new RegExp(i,t?"s":"is")};ValueFilterEditor.prototype._filterValues=function(e){var t=this._rxFilter;return null==t||null==e||t.test(e.text)};ValueFilterEditor.prototype._cbSelectAllClicked=function(){for(var e=this,t=this._cbSelectAll.checked,i=this._divValues.scrollTop,r=this._getItems(),n=0;n<r.length;n++)r[n].show=t;this._view.refresh();this._divValues.scrollTop=i;setTimeout((function(){e._adjustWidths()}),0)};ValueFilterEditor.prototype._updateSelectAllCheck=function(){for(var e=this._getItems(),t=0,i=0,r=0;r<e.length;r++){e[r].show?t++:i++;if(t&&i)break}wijmo_1.setChecked(this._cbSelectAll,t&&i?null:t>0);this.canApply=t>0};ValueFilterEditor.prototype._adjustWidths=function(){var e=this._lbValues.hostElement;if(e&&e.offsetHeight>0){var t=0,i=e.querySelectorAll(".wj-listbox-item label");if(i.length){for(var r=0;r<i.length;r++)t=Math.max(t,i[r].scrollWidth);if(t){var n=e.querySelectorAll(".wj-listbox-item");if(n.length){var l=n[0],o=getComputedStyle(l),a=parseFloat(o.paddingLeft)+parseFloat(o.paddingRight);for(r=0;r<n.length;r++)n[r].style.width=t+a+"px"}}}}};ValueFilterEditor.controlTemplate='<div><div wj-part="div-filter"></div><div class="wj-listbox-item"><label><input wj-part="cb-select-all" type="checkbox"> <span wj-part="sp-select-all"></span></label></div><div wj-part="div-values"></div></div>';return ValueFilterEditor}(wijmo_1.Control);exports.ValueFilterEditor=ValueFilterEditor;var ColumnFilter=function(){function ColumnFilter(e,t){var i=this;this._owner=e;this._col=t;this._valueFilter=new ValueFilter(t);this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch;this._conditionFilter=new ConditionFilter(t);e.exclusiveValueSearchChanged.addHandler((function(e){i._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch}))}Object.defineProperty(ColumnFilter.prototype,"filterType",{get:function(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType},set:function(e){if((e=wijmo_1.asEnum(e,FilterType,!0))!=this._filterType){var t=this.isActive;this.clear();this._filterType=e;t?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"dataMap",{get:function(){return this.conditionFilter.dataMap||this.valueFilter.dataMap},set:function(e){this.conditionFilter.dataMap=e;this.valueFilter.dataMap=e},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"valueFilter",{get:function(){return this._valueFilter},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"conditionFilter",{get:function(){return this._conditionFilter},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"isActive",{get:function(){return this._conditionFilter.isActive||this._valueFilter.isActive},enumerable:!0,configurable:!0});ColumnFilter.prototype.apply=function(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)};ColumnFilter.prototype.clear=function(){this._valueFilter.clear();this._conditionFilter.clear()};ColumnFilter.prototype.implementsInterface=function(e){return"IColumnFilter"==e};return ColumnFilter}();exports.ColumnFilter=ColumnFilter;wijmo_1._addCultureInfo("FlexGridFilter",{ariaLabels:{edit:"Edit Filter for Column",dialog:"Filter Editor for Column",asc:"Sort Column in Ascending Order",dsc:"Sort Column in Descending Order",search:"Search Item List",op1:"First Condition Operator",val1:"First Condition Value",and:"Require both Conditions",or:"Require either Condition",op2:"Second Condition Operator",val2:"Second Condition Value"},ascending:"↑ Ascending",descending:"↓ Descending",apply:"Apply",cancel:"Cancel",clear:"Clear",conditions:"Filter by Condition",values:"Filter by Value",search:"Search",selectAll:"Select All",null:"(nothing)",header:"Show items where the value",and:"And",or:"Or",stringOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Begins with",op:Operator.BW},{name:"Ends with",op:Operator.EW},{name:"Contains",op:Operator.CT},{name:"Does not contain",op:Operator.NC}],numberOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Is Greater than",op:Operator.GT},{name:"Is Greater than or equal to",op:Operator.GE},{name:"Is Less than",op:Operator.LT},{name:"Is Less than or equal to",op:Operator.LE}],dateOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Is Before",op:Operator.LT},{name:"Is After",op:Operator.GT}],booleanOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE}]});var ColumnFilterEditor=function(e){__extends(ColumnFilterEditor,e);function ColumnFilterEditor(t,i,r){void 0===r&&(r=!0);var n=e.call(this,t,null,!0)||this;n.filterChanged=new wijmo_1.Event;n.buttonClicked=new wijmo_1.Event;n._filter=wijmo_1.asType(i,ColumnFilter);var l=n.getTemplate();n.applyTemplate("wj-control wj-content wj-columnfiltereditor",l,{_divSort:"div-sort",_btnAsc:"btn-asc",_btnDsc:"btn-dsc",_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnApply:"btn-apply",_btnCancel:"btn-cancel",_btnClear:"btn-clear"});var o=wijmo_1.culture.FlexGridFilter,a=o.ariaLabels,s=n.hostElement,u=n.filter.column,d=u.grid.collectionView;wijmo_1.setAttribute(s,"role","dialog");wijmo_1.setAriaLabel(s,a.dialog+" "+u.header);wijmo_1.setAriaLabel(n._btnAsc,a.asc);wijmo_1.setAriaLabel(n._btnDsc,a.dsc);wijmo_1.setText(n._btnAsc,o.ascending);wijmo_1.setText(n._btnDsc,o.descending);wijmo_1.setText(n._aVal,o.values);wijmo_1.setText(n._aCnd,o.conditions);wijmo_1.setText(n._btnApply,o.apply);wijmo_1.setText(n._btnCancel,o.cancel);wijmo_1.setText(n._btnClear,o.clear);var c=n.filter.conditionFilter.isActive||0==(i.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;n._showFilter(c);r&&d&&d.canSort||(n._divSort.style.display="none");n._updateSortButtonState();var p=n._btnClicked.bind(n);n._btnApply.addEventListener("click",p);n._btnCancel.addEventListener("click",p);n._btnClear.addEventListener("click",p);n._btnAsc.addEventListener("click",p);n._btnDsc.addEventListener("click",p);n._aVal.addEventListener("click",p);n._aCnd.addEventListener("click",p);n.addEventListener(s,"keydown",(function(e){if(!e.defaultPrevented){var t=e.target.tagName.match(/^(a|button)$/i);switch(e.keyCode){case wijmo_1.Key.Space:if(t){n._btnClicked(e);e.preventDefault()}break;case wijmo_1.Key.Enter:if(t)n._btnClicked(e);else{n.updateFilter();n.onFilterChanged();n.onButtonClicked()}e.preventDefault();break;case wijmo_1.Key.Escape:n.onButtonClicked();e.preventDefault();break;case wijmo_1.Key.Tab:wijmo_1.moveFocus(n.hostElement,e.shiftKey?-1:1);e.preventDefault()}}}));n.addEventListener(window,"resize",(function(){n.isTouching||n._wasTouching||n.onButtonClicked()}));return n}Object.defineProperty(ColumnFilterEditor.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});ColumnFilterEditor.prototype.updateEditor=function(){this._edtVal&&this._edtVal.updateEditor();this._edtCnd&&this._edtCnd.updateEditor()};ColumnFilterEditor.prototype.updateFilter=function(){switch(this._getFilterType()){case FilterType.Value:this._edtVal.updateFilter();this.filter.conditionFilter.clear();break;case FilterType.Condition:this._edtCnd.updateFilter();this.filter.valueFilter.clear()}};ColumnFilterEditor.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)};ColumnFilterEditor.prototype.onButtonClicked=function(e){this.buttonClicked.raise(this,e)};ColumnFilterEditor.prototype._showFilter=function(e){var t=this;this._wasTouching=this.isTouching;if(e==FilterType.Value&&null==this._edtVal){this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter);this._edtVal.canApplyChanged.addHandler((function(e){wijmo_1.enable(t._btnApply,t._edtVal.canApply)}))}if(e==FilterType.Condition&&null==this._edtCnd){this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter);this._edtCnd.canApplyChanged.addHandler((function(e){wijmo_1.enable(t._btnApply,t._edtCnd.canApply)}))}if(0!=(e&this.filter.filterType))if(e==FilterType.Value){this._divEdtVal.style.display="";this._divEdtCnd.style.display="none";this._enableLink(this._aVal,!1);this._enableLink(this._aCnd,!0);this._edtVal.focus();wijmo_1.enable(this._btnApply,this._edtVal.canApply)}else{this._divEdtVal.style.display="none";this._divEdtCnd.style.display="";this._enableLink(this._aVal,!0);this._enableLink(this._aCnd,!1);this._edtCnd.focus();wijmo_1.enable(this._btnApply,this._edtCnd.canApply)}var i=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:i.display="none";break;default:i.display=""}};ColumnFilterEditor.prototype._enableLink=function(e,t){wijmo_1.toggleClass(e,"wj-state-disabled",!t);wijmo_1.setAttribute(e,"href",t?"":null);wijmo_1.setAttribute(e,"disabled",t?null:"disabled")};ColumnFilterEditor.prototype._updateSortButtonState=function(){var e=this.filter.column,t=e?e.currentSort:"",i="wj-state-active";wijmo_1.toggleClass(this._btnAsc,i,"+"==t);wijmo_1.toggleClass(this._btnDsc,i,"-"==t)};ColumnFilterEditor.prototype._getFilterType=function(){var e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition};ColumnFilterEditor.prototype._btnClicked=function(e){var t=this,i=e.target;e.preventDefault();e.stopPropagation();if(!wijmo_1.hasClass(i,"wj-state-disabled"))if(i!=this._aVal)if(i!=this._aCnd){if(i==this._btnAsc||i==this._btnDsc){var r=this.filter.column,n=r.sortMemberPath||r.binding,l=r.grid.collectionView.sortDescriptions;l.deferUpdate((function(){l.clear();l.push(new wijmo_1.SortDescription(n,e.target==t._btnAsc))}));this._updateSortButtonState()}if(i==this._btnApply){this.updateFilter();this.onFilterChanged()}else if(i==this._btnClear){if(this.filter.isActive){this.filter.clear();this.onFilterChanged()}}else this.updateEditor();this.onButtonClicked()}else{this._showFilter(FilterType.Condition);wijmo_1.moveFocus(this._edtCnd.hostElement,0)}else{this._showFilter(FilterType.Value);wijmo_1.moveFocus(this._edtVal.hostElement,0)}};ColumnFilterEditor.controlTemplate='<div><div wj-part="div-sort" class="wj-sort-buttons"><button wj-part="btn-asc" class="wj-btn"></button>&nbsp;&nbsp;&nbsp;<button wj-part="btn-dsc" class="wj-btn"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a>&nbsp;|&nbsp;<a wj-part="a-val" href="" draggable="false"></a></div><div wj-part="div-edt-val" tabindex="-1"></div><div wj-part="div-edt-cnd" tabindex="-1"></div><div style="text-align:right;margin-top:10px"><button wj-part="btn-apply" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-cancel" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-clear" class="wj-btn"></button></div></div>';return ColumnFilterEditor}(wijmo_1.Control);exports.ColumnFilterEditor=ColumnFilterEditor;wijmo_1._registerModule("wijmo.grid.filter",selfModule);
"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}(),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});var FilterType,wijmo_grid_1=require("@grapecity/wijmo.grid"),wijmo_1=require("@grapecity/wijmo"),wijmo_input_1=require("@grapecity/wijmo.input"),input=__importStar(require("@grapecity/wijmo.input")),selfModule=__importStar(require("@grapecity/wijmo.grid.filter"));!function(e){e[e.None=0]="None";e[e.Condition=1]="Condition";e[e.Value=2]="Value";e[e.Both=3]="Both"}(FilterType=exports.FilterType||(exports.FilterType={}));var FlexGridFilter=function(){function FlexGridFilter(e,t){this._showIcons=!0;this._showSort=!0;this._defFilterType=FilterType.Both;this._xValueSearch=!0;this._includeUpdatedRowsInFilter=!1;this.filterApplied=new wijmo_1.Event;this.editingFilter=new wijmo_1.Event;this.filterChanging=new wijmo_1.Event;this.filterChanged=new wijmo_1.Event;this.exclusiveValueSearchChanged=new wijmo_1.Event;this._filters=[];this._g=wijmo_1.asType(e,wijmo_grid_1.FlexGrid,!1);this._g.formatItem.addHandler(this._formatItem.bind(this));this._g.itemsSourceChanged.addHandler(this.clear.bind(this));var i=this._g.hostElement;e.addEventListener(i,"mousedown",this._mousedown.bind(this),!0);e.addEventListener(i,"click",this._click.bind(this),!0);e.addEventListener(i,"keydown",this._keydown.bind(this),!0);this._g.invalidate();wijmo_1.copy(this,t);this._init()}FlexGridFilter.prototype._init=function(){var e=this,t=this.grid,_excludeRowFromFilter=function(t){var i=e.grid,r=e.excludedRowsSet;i.itemsSource?i.rows[t]instanceof wijmo_grid_1._NewRowTemplate?r.add(i.editableCollectionView.currentAddItem||i.rows[t].dataItem):r.add(i.rows[t].dataItem):r.add(i.rows[t])};t.rowChanged&&t.rowChanged.addHandler((function(e,t){t.added&&_excludeRowFromFilter(t.index)}));t.rowEditEnding.addHandler((function(e,t){_excludeRowFromFilter(t.row)}));t.cellEditEnded.addHandler((function(e,t){_excludeRowFromFilter(t.row)}))};Object.defineProperty(FlexGridFilter.prototype,"excludedRowsSet",{get:function(){var e=this.grid;e.selectedSheet&&(e=e.selectedSheet);e._newAddedRowsSet||(e._newAddedRowsSet=new WeakSet);return e._newAddedRowsSet},set:function(e){var t=this.grid;t.selectedSheet&&(t=t.selectedSheet);t._newAddedRowsSet=e},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"filterColumns",{get:function(){return this._filterColumns},set:function(e){this._filterColumns=wijmo_1.asArray(e);this.clear()},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"showFilterIcons",{get:function(){return this._showIcons},set:function(e){if(e!=this.showFilterIcons){this._showIcons=wijmo_1.asBoolean(e);this._g&&this._g.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"showSortButtons",{get:function(){return this._showSort},set:function(e){this._showSort=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"reApplyFilterOnUpdate",{get:function(){return this._includeUpdatedRowsInFilter},set:function(e){e!==this._includeUpdatedRowsInFilter&&(this._includeUpdatedRowsInFilter=wijmo_1.asBoolean(e))},enumerable:!0,configurable:!0});FlexGridFilter.prototype.getColumnFilter=function(e,t){void 0===t&&(t=!0);if(e=this._asColumn(e)){for(var i=0;i<this._filters.length;i++)if(this._filters[i].column==e)return this._filters[i];if(t&&e.binding){var r=new ColumnFilter(this,e);this._filters.push(r);return r}}return null};Object.defineProperty(FlexGridFilter.prototype,"defaultFilterType",{get:function(){return this._defFilterType},set:function(e){if((e=wijmo_1.asEnum(e,FilterType,!1))!=this.defaultFilterType){this._defFilterType=e;this._g.invalidate();this.clear()}},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){if((e=wijmo_1.asBoolean(e))!==this._xValueSearch){this._xValueSearch=e;this.onExclusiveValueSearchChanged()}},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"filterDefinition",{get:function(){var e=this,t={defaultFilterType:this.defaultFilterType,filters:[]};this._filters.forEach((function(i){var r=i.conditionFilter,n=i.valueFilter,l=n.uniqueValues&&n.uniqueValues.length;if(i&&i.column&&i.column.binding&&(i.isActive||l||i.filterType!=e.defaultFilterType)){var o={binding:i.column.binding};if(r.isActive){var a=r.condition1,s=r.condition2;o={binding:i.column.binding,type:"condition",condition1:{operator:a.operator,value:a.value},and:r.and,condition2:{operator:s.operator,value:s.value}}}else(n.isActive||l)&&(o={binding:i.column.binding,type:"value",uniqueValues:n.uniqueValues,sortValues:n.sortValues,maxValues:n.maxValues,exclusiveValueSearch:n.exclusiveValueSearch,showValues:n.showValues});i.filterType!=e.defaultFilterType&&(o.filterType=i.filterType);t.filters.push(o)}}));return JSON.stringify(t)},set:function(e){e=wijmo_1.asString(e);this.clear();if(e){var t=JSON.parse(e);this.defaultFilterType=t.defaultFilterType;for(var _loop_1=function(e){var r=t.filters[e],n=i._asColumn(r.binding);n||(n=new wijmo_grid_1.Column({binding:r.binding}));var l=i.getColumnFilter(n,!0);if(l){null!=r.filterType&&(l.filterType=wijmo_1.asEnum(r.filterType,FilterType));switch(r.type){case"condition":var o=l.conditionFilter;o.condition1.value=n.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(r.condition1.value,n.dataType,null):r.condition1.value;o.condition1.operator=r.condition1.operator;o.and=r.and;o.condition2.value=n.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(r.condition2.value,n.dataType,null):r.condition2.value;o.condition2.operator=r.condition2.operator;break;case"value":var a=l.valueFilter;a.uniqueValues=r.uniqueValues;["sortValues","maxValues","exclusiveValueSearch"].forEach((function(e){null!=r[e]&&(a[e]=r[e])}));a.showValues=r.showValues}}},i=this,r=0;r<t.filters.length;r++)_loop_1(r)}this.apply()},enumerable:!0,configurable:!0});Object.defineProperty(FlexGridFilter.prototype,"activeEditor",{get:function(){return wijmo_1.Control.getControl(this._divEdt)},enumerable:!0,configurable:!0});FlexGridFilter.prototype.editColumnFilter=function(e,t,i){var r=this,n=this._g;this.closeEditor();e=this._asColumn(e);var l=new wijmo_grid_1.CellRangeEventArgs(n.cells,new wijmo_grid_1.CellRange(-1,e.index));if(this.onEditingFilter(l)){var o=wijmo_1.createElement('<div class="wj-dropdown-panel"></div>'),a=this.getColumnFilter(e),s=new ColumnFilterEditor(o,a,this.showSortButtons);this._divEdt=o;this._edtCol=e;n.rightToLeft&&(o.dir="rtl");if(this.onFilterChanging(l)){l.cancel=!0;s.filterChanged.addHandler((function(){l.cancel=!1;setTimeout((function(){if(!l.cancel){r.excludedRowsSet=null;r.apply()}}),s._edtVal&&s._edtVal._isFiltering?wijmo_1.Control._SEARCH_DELAY+200:0)}));s.buttonClicked.addHandler((function(){r.closeEditor();n.focus();r.onFilterChanged(l)}));s.lostFocus.addHandler((function(){setTimeout((function(){var e=wijmo_1.Control.getControl(r._divEdt);e&&!e.containsFocus()&&r.closeEditor()}),10)}));var u=t?t.col:e.index,d=n.columns[u];t||d&&d.binding==e.binding||(u=n.selection.leftCol);n._edtHdl._commitRowEdits();n.scrollIntoView(-1,u,!0);var c=n.columnHeaders,p=t&&t.panel&&c&&t.panel._uid==c._uid?t.row:c.rows.length-1,_=u,h=i||c.getCellElement(p,_),f=h?null:c.getCellBoundingRect(p,_);h?wijmo_1.showPopup(o,h,!1,!1,!1):wijmo_1.showPopup(o,f);this._setAriaExpanded(h,!0);this._setAriaExpanded(n.cells.getCellElement(-1,_),!0);for(var m=s.hostElement.querySelectorAll("input"),b=0;b<m.length;b++){var v=m[b];if(v.offsetHeight>0&&v.tabIndex>-1&&!v.disabled){v.focus();break}}s.containsFocus()||s.focus()}else this._divEdt=this._edtCol=null}};FlexGridFilter.prototype._setAriaExpanded=function(e,t){if(e){var i=e.querySelector("."+FlexGridFilter._WJC_FILTER);wijmo_1.setAttribute(i,"aria-expanded",t)}};FlexGridFilter.prototype.closeEditor=function(){var e=this._g,t=wijmo_1.Control.getControl(this._divEdt),i=this._edtCol;t&&wijmo_1.hidePopup(t.hostElement,(function(){t.dispose()}));if(i){var r=e.columnHeaders,n=r.rows.length?r.getCellElement(r.rows.length-1,i.index):null;this._setAriaExpanded(n,!1);n=e.cells.getCellElement(-1,i.index);this._setAriaExpanded(n,!1)}this._divEdt=null;this._edtCol=null};FlexGridFilter.prototype.apply=function(){var e=this._g.collectionView;if(e){var t=this._g.editableCollectionView;if(t){t.commitEdit();t.commitNew()}e.filter=this._filter.bind(this)}var i=e?e.updateFilterDefinition:null;wijmo_1.isFunction(i)&&i.call(e,this);this.onFilterApplied()};FlexGridFilter.prototype.clear=function(){if(this._filters.length){this._filters=[];this.apply()}};FlexGridFilter.prototype.onFilterApplied=function(e){this.filterApplied.raise(this,e)};FlexGridFilter.prototype.onEditingFilter=function(e){this.editingFilter.raise(this,e);return!e.cancel};FlexGridFilter.prototype.onFilterChanging=function(e){this.filterChanging.raise(this,e);return!e.cancel};FlexGridFilter.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)};FlexGridFilter.prototype.onExclusiveValueSearchChanged=function(e){this.exclusiveValueSearchChanged.raise(this,e)};FlexGridFilter.prototype._asColumn=function(e){return wijmo_1.isString(e)?this._g.getColumn(e,!0):wijmo_1.isNumber(e)?this._g.columns[e]:wijmo_1.asType(e,wijmo_grid_1.Column,!1)};FlexGridFilter.prototype._filter=function(e){var t=this.excludedRowsSet;if(!this.reApplyFilterOnUpdate&&t.has(e))return!0;for(var i=this._filters,r=0;r<i.length;r++){var n=i[r];if(n.column!=FlexGridFilter._skipColumn&&!n.apply(e))return!1}return!0};FlexGridFilter.prototype._formatItem=function(e,t){if(t.panel==e.columnHeaders){var i=this._g,r=i.getMergedRange(t.panel,t.row,t.col)||new wijmo_grid_1.CellRange(t.row,t.col),n=i.columns[r.col],l=i._getBindingColumn(t.panel,t.row,n),o=t.cell;if(r.row2==t.panel.rows.length-1||n!=l){var a=this.getColumnFilter(l,this.defaultFilterType!=FilterType.None),s=this._filterColumns;s&&s.length&&s.indexOf(l.binding)<0&&s.indexOf(l.name)<0&&(a=null);if(a){wijmo_1.toggleClass(o,"wj-filter-on",a.isActive);wijmo_1.toggleClass(o,"wj-filter-off",!a.isActive)}else{wijmo_1.removeClass(o,"wj-filter-on");wijmo_1.removeClass(o,"wj-filter-off")}if(a&&a.filterType!=FilterType.None){this._showIcons&&this._addFilterButton(l,a,o);0==t.row&&(o=i.cells.getCellElement(-1,t.col))&&this._addFilterButton(n,a,o)}}}};FlexGridFilter.prototype._addFilterButton=function(e,t,i){var r=FlexGridFilter._WJC_FILTER,n=wijmo_1.createElement('<button class="wj-btn wj-btn-glyph wj-right '+r+'" type="button" tabindex="-1"><span class="wj-glyph-filter"></span></button>');wijmo_1.setAriaLabel(n,wijmo_1.culture.FlexGridFilter.ariaLabels.edit+" "+e.header);wijmo_1.setAttribute(n,"aria-haspopup","dialog");wijmo_1.setAttribute(n,"aria-expanded",!1);wijmo_1.setAttribute(n,"aria-describedby",e.describedById);wijmo_1.setAttribute(n,"aria-pressed",t.isActive);if(!i.querySelector("."+r)){1==i.children.length&&(i=i.querySelector("div")||i);i.insertBefore(n,i.firstChild)}};FlexGridFilter.prototype._mousedown=function(e){this._edtColPrev=this._edtCol};FlexGridFilter.prototype._click=function(e){if(this._toggleEditor(e)){e.stopPropagation();e.preventDefault()}};FlexGridFilter.prototype._toggleEditor=function(e){var t=this;if(!e.defaultPrevented&&0==e.button)if(wijmo_1.closestClass(e.target,FlexGridFilter._WJC_FILTER)){var i=this._g,r=i.hitTest(e.target);r.panel||(r=i.hitTest(e));if(r.panel&&i.columnHeaders&&i.cells&&(r.panel._uid==i.columnHeaders._uid||r.panel._uid==i.cells._uid&&-1==r.row)){var n=i.getMergedRange(r.panel,r.row,r.col)||new wijmo_grid_1.CellRange(r.row,r.col),l=i.columns[n.col],o=i._getBindingColumn(r.panel,r.row,l);if(this._divEdt&&this._edtCol==o){this.closeEditor();i.focus()}else o!=this._edtColPrev&&setTimeout((function(){t.editColumnFilter(o,r)}),this._divEdt?100:0);return!0}}else this.closeEditor();return!1};FlexGridFilter.prototype._keydown=function(e){if(!e.defaultPrevented&&!e.ctrlKey&&e.altKey&&(e.keyCode==wijmo_1.Key.Down||e.keyCode==wijmo_1.Key.Up)){var t=this.grid,i=t.selection,r=i.col>-1?t.columns[i.col]:null,n=r?t._getBindingColumn(t.cells,i.row,r):null,l=n&&n.dataMap&&n.dataMapEditor==wijmo_grid_1.DataMapEditor.DropDownList;if(this.filterColumns&&this.filterColumns.length>0&&!this.filterColumns.includes(n._binding._path)){e.preventDefault();return!1}n&&n.editor instanceof wijmo_input_1.DropDown&&(l=!0);if(n&&!l){var o=this.getColumnFilter(n,!1);if(o&&o.filterType!=FilterType.None){this.editColumnFilter(n);e.preventDefault();e.stopPropagation()}}}};FlexGridFilter._WJC_FILTER="wj-elem-filter";return FlexGridFilter}();exports.FlexGridFilter=FlexGridFilter;exports.empty={};var ConditionFilter=function(){function ConditionFilter(e){this._c1=new FilterCondition(this);this._c2=new FilterCondition(this);this._and=!0;this._col=e}Object.defineProperty(ConditionFilter.prototype,"condition1",{get:function(){return this._c1},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"condition2",{get:function(){return this._c2},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"and",{get:function(){return this._and},set:function(e){this._and=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map=wijmo_1.asType(e,wijmo_grid_1.DataMap,!0)},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilter.prototype,"isActive",{get:function(){return this._c1.isActive||this._c2.isActive},enumerable:!0,configurable:!0});ConditionFilter.prototype.apply=function(e){var t=this._col,i=this._c1,r=this._c2,n=!1,l=!1;if(!t||!t._binding||!this.isActive)return!0;e=t._binding.getValue(e);var o=this.dataMap||t.dataMap;if(o)e=o.getDisplayValue(e);else if(wijmo_1.isDate(e)){n=!this._hasTimePart();l=!this._hasDatePart();var a=FilterCondition._refDateTime;n?e=wijmo_1.DateTime.fromDateTime(e,a):l&&(e=wijmo_1.DateTime.fromDateTime(a,e))}else if(wijmo_1.isNumber(e)){var s=wijmo_1.Globalize,u=t.format,d=s.formatNumber(e,u);e=s.parseFloat(d,u)}var c=i.apply(e,n,l),p=r.apply(e,n,l);return i.isActive&&r.isActive?this._and?c&&p:c||p:i.isActive?c:!r.isActive||p};ConditionFilter.prototype.clear=function(){this._c1.clear();this._c2.clear();this.and=!0};ConditionFilter.prototype._hasDatePart=function(){var e=this._col.format;if(!e)return!0;e=wijmo_1.culture.Globalize.calendar.patterns[e]||e;return/[yMd]+/.test(e)};ConditionFilter.prototype._hasTimePart=function(){var e=this._col.format;if(!e)return!1;e=wijmo_1.culture.Globalize.calendar.patterns[e]||e;return/[Hmst]+/.test(e)};ConditionFilter.prototype.implementsInterface=function(e){return"IColumnFilter"==e};return ConditionFilter}();exports.ConditionFilter=ConditionFilter;var ConditionFilterEditor=function(e){__extends(ConditionFilterEditor,e);function ConditionFilterEditor(t,i){var r=e.call(this,t)||this;r._canApply=!1;r.canApplyChanged=new wijmo_1.Event;r._filter=wijmo_1.asType(i,ConditionFilter,!1);var n=r.getTemplate();r.applyTemplate("wj-control wj-conditionfilter-editor",n,{_divHdr:"div-hdr",_divCmb1:"div-cmb1",_divVal1:"div-val1",_btnAnd:"btn-and",_btnOr:"btn-or",_spAnd:"sp-and",_spOr:"sp-or",_divCmb2:"div-cmb2",_divVal2:"div-val2"});var l=wijmo_1.culture.FlexGridFilter,o=l.ariaLabels;wijmo_1.setAriaLabel(r._btnAnd,o.and);wijmo_1.setAriaLabel(r._btnOr,o.or);wijmo_1.setText(r._divHdr,l.header);wijmo_1.setText(r._spAnd,l.and);wijmo_1.setText(r._spOr,l.or);var a=wijmo_1.getUniqueId("cmb1");r._divHdr.htmlFor=a;r._divCmb1.id=a;r._cmb1=r._createOperatorCombo(r._divCmb1,o.op1);r._cmb2=r._createOperatorCombo(r._divCmb2,o.op2);r._val1=r._createValueInput(r._divVal1,o.val1);r._val2=r._createValueInput(r._divVal2,o.val2);r._val1.isDisabled=!0;r._cmb1.selectedIndexChanged.addHandler((function(e,t){r._val1.isDisabled=null==e.selectedValue;r.canApply=!r._val1.isDisabled||!r._val2.isDisabled}));r._val2.isDisabled=!0;r._cmb2.selectedIndexChanged.addHandler((function(e,t){r._val2.isDisabled=null==e.selectedValue;r.canApply=!r._val1.isDisabled||!r._val2.isDisabled}));var s=r.hostElement;r.addEventListener(s,"change",r._btnAndOrChanged.bind(r));r.addEventListener(s,"keydown",r._keydown.bind(r));setTimeout((function(){r.updateEditor()}));return r}Object.defineProperty(ConditionFilterEditor.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});Object.defineProperty(ConditionFilterEditor.prototype,"canApply",{get:function(){return this._canApply},set:function(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}},enumerable:!0,configurable:!0});ConditionFilterEditor.prototype.updateEditor=function(){var e=this._filter.condition1,t=this._filter.condition2;this._cmb1.selectedValue=e.operator;this._cmb2.selectedValue=t.operator;if(this._val1 instanceof input.ComboBox&&!(this._val1 instanceof input.InputTime)){this._val1.text=wijmo_1.changeType(e.value,wijmo_1.DataType.String);this._val2.text=wijmo_1.changeType(t.value,wijmo_1.DataType.String)}else{this._val1.value=e.value;this._val2.value=t.value}var i=this._filter.and;this._checkRadio(this._btnAnd,i);this._checkRadio(this._btnOr,!i)};ConditionFilterEditor.prototype.clearEditor=function(){this._cmb1.selectedValue=this._cmb2.selectedValue=null;this._val1.text=this._val2.text=null;this._checkRadio(this._btnAnd,!0);this._checkRadio(this._btnOr,!1)};Object.defineProperty(ConditionFilterEditor.prototype,"isEditorClear",{get:function(){return null==this._cmb1.selectedValue&&!this._val1.text&&null==this._cmb2.selectedValue&&!this._val2.text},enumerable:!0,configurable:!0});ConditionFilterEditor.prototype.updateFilter=function(){var e=this._filter.condition1,t=this._filter.condition2;e.operator=this._cmb1.selectedValue;t.operator=this._cmb2.selectedValue;if("value"in this._val1){e.value=this._val1.value;t.value=this._val2.value}else{e.value=this._getComboValue(this._val1);t.value=this._getComboValue(this._val2)}this._filter.and=this._btnAnd.checked};ConditionFilterEditor.prototype.onCanApplyChanged=function(e){this.canApplyChanged.raise(this,e)};ConditionFilterEditor.prototype._getComboValue=function(e){return e.selectedIndex>-1?e.selectedValue:e.text};ConditionFilterEditor.prototype._createOperatorCombo=function(e,t){var i=this._filter.column,r=wijmo_1.culture.FlexGridFilter,n=r.stringOperators,l=wijmo_1.DataType;this._filter.dataMap||i.dataMap||(i.dataType==l.Date?n=r.dateOperators:i.dataType==l.Number?n=r.numberOperators:i.dataType==l.Boolean&&(n=r.booleanOperators));var o=new input.ComboBox(e,{itemsSource:n,displayMemberPath:"name",selectedValuePath:"op"});wijmo_1.setAriaLabel(o.inputElement,t);return o};ConditionFilterEditor.prototype._createValueInput=function(e,t){var i=this._filter,r=i.column,n=i.dataMap||r.dataMap,l=null,o=wijmo_1.DataType;if(r.dataType==o.Date)(l=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(e):new input.InputDate(e):new input.InputTime(e)).format=r.format;else if(r.dataType!=o.Number||n){(l=new input.ComboBox(e)).isEditable=!0;if(n){l.itemsSource=n.getDisplayValues();l.caseSensitiveSearch=!!r.grid&&r.grid.caseSensitiveSearch}else r.dataType==o.Boolean&&(l.itemsSource=[!0,!1])}else(l=new input.InputNumber(e)).format=r.format;l.isRequired=!1;wijmo_1.setAriaLabel(l.inputElement,t);return l};ConditionFilterEditor.prototype._btnAndOrChanged=function(e){var t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i){this._checkRadio(this._btnAnd,t);this._checkRadio(this._btnOr,i)}};ConditionFilterEditor.prototype._checkRadio=function(e,t){e.checked=t;wijmo_1.setAttribute(e,"aria-checked",t.toString());wijmo_1.setAttribute(e,"tabindex",t?null:"-1")};ConditionFilterEditor.prototype._keydown=function(e){var t=e.target==this._btnAnd,i=e.target==this._btnOr;if(t||i)switch(e.keyCode){case wijmo_1.Key.Left:case wijmo_1.Key.Right:case wijmo_1.Key.Up:case wijmo_1.Key.Down:var r=t?this._btnOr:this._btnAnd;r.click();r.focus();e.preventDefault()}};ConditionFilterEditor.controlTemplate='<div><label wj-part="div-hdr"></label><div wj-part="div-cmb1"></div><br/><div wj-part="div-val1"></div><br/><div role="radiogroup" style="text-align:center"><label><input wj-part="btn-and" type="radio" role="radio"> <span wj-part="sp-and"></span> </label>&nbsp;&nbsp;&nbsp;<label><input wj-part="btn-or" type="radio" role="radio"> <span wj-part="sp-or"></span> </label></div><div wj-part="div-cmb2"></div><br/><div wj-part="div-val2"></div><br/></div>';return ConditionFilterEditor}(wijmo_1.Control);exports.ConditionFilterEditor=ConditionFilterEditor;var Operator,ValueFilterSearchKind,FilterCondition=function(){function FilterCondition(e){this._op=null;this._filter=e}Object.defineProperty(FilterCondition.prototype,"operator",{get:function(){return this._op},set:function(e){this._op=wijmo_1.asEnum(e,Operator,!0)},enumerable:!0,configurable:!0});Object.defineProperty(FilterCondition.prototype,"value",{get:function(){return this._val},set:function(e){this._val=e;this._strVal=wijmo_1.isString(e)?this._getCaseString(e):null},enumerable:!0,configurable:!0});Object.defineProperty(FilterCondition.prototype,"isActive",{get:function(){switch(this._op){case null:return!1;case Operator.EQ:case Operator.NE:return!0;default:return null!=this._val||null!=this._strVal}},enumerable:!0,configurable:!0});FilterCondition.prototype.clear=function(){this.operator=null;this.value=null};FilterCondition.prototype.apply=function(e,t,i){var r=this._strVal||this._val;wijmo_1.isString(e)&&(e=this._getCaseString(e));wijmo_1.isString(r)&&null==e&&(e="");wijmo_1.isDate(r)&&(t?r=wijmo_1.DateTime.fromDateTime(r,FilterCondition._refDateTime):i&&(r=wijmo_1.DateTime.fromDateTime(FilterCondition._refDateTime,r)));var n=Operator;switch(this._op){case null:return!0;case n.EQ:return null!=e&&null!=r?e.valueOf()==r.valueOf():e==r;case n.NE:return null!=e&&null!=r?e.valueOf()!=r.valueOf():e!=r;case n.GT:return e>r;case n.GE:return e>=r;case n.LT:return e<r;case n.LE:return e<=r;case n.BW:return!(null==this._strVal||!wijmo_1.isString(e))&&0==e.indexOf(this._strVal);case n.EW:return!!(null!=this._strVal&&wijmo_1.isString(e)&&e.length>=this._strVal.length)&&e.substr(e.length-this._strVal.length)==r;case n.CT:return!(null==this._strVal||!wijmo_1.isString(e))&&e.indexOf(this._strVal)>-1;case n.NC:return!(null==this._strVal||!wijmo_1.isString(e))&&e.indexOf(this._strVal)<0}throw"Unknown operator"};FilterCondition.prototype._getCaseString=function(e){var t=this._filter.column,i=t?t.grid:null;return i&&i.caseSensitiveSearch?e:e.toLowerCase()};FilterCondition._refDateTime=new Date(2e3,0,1,0,0,0);return FilterCondition}();exports.FilterCondition=FilterCondition;!function(e){e[e.EQ=0]="EQ";e[e.NE=1]="NE";e[e.GT=2]="GT";e[e.GE=3]="GE";e[e.LT=4]="LT";e[e.LE=5]="LE";e[e.BW=6]="BW";e[e.EW=7]="EW";e[e.CT=8]="CT";e[e.NC=9]="NC"}(Operator=exports.Operator||(exports.Operator={}));!function(e){e[e.Text=0]="Text";e[e.Regex=1]="Regex";e[e.Excel=2]="Excel"}(ValueFilterSearchKind=exports.ValueFilterSearchKind||(exports.ValueFilterSearchKind={}));var ValueFilter=function(){function ValueFilter(e){this._values=null;this._filterText=null;this._xValueSearch=!0;this._maxValues=250;this._uniqueValues=null;this._sortValues=!0;this._searchType=ValueFilterSearchKind.Excel;this._exceedsMaxValues=!1;this._col=e}Object.defineProperty(ValueFilter.prototype,"searchType",{get:function(){return this._searchType},set:function(e){this._searchType=wijmo_1.asEnum(e,ValueFilterSearchKind)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"showValues",{get:function(){return this._values},set:function(e){this._values=e},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"filterText",{get:function(){return this._filterText},set:function(e){this._filterText=wijmo_1.asString(e)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){if((e=wijmo_1.asBoolean(e))!==this._xValueSearch){this._xValueSearch=wijmo_1.asBoolean(e);e&&(this._filterText="")}},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"maxValues",{get:function(){return this._maxValues},set:function(e){this._maxValues=wijmo_1.asNumber(e,!1,!0)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"uniqueValues",{get:function(){return this._uniqueValues},set:function(e){this._uniqueValues=wijmo_1.asArray(e)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"sortValues",{get:function(){return this._sortValues},set:function(e){this._sortValues=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map=wijmo_1.asType(e,wijmo_grid_1.DataMap,!0)},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilter.prototype,"isActive",{get:function(){return null!=this._values&&Object.keys(this._values).length>0},enumerable:!0,configurable:!0});ValueFilter.prototype.apply=function(e){var t=this.column;if(!(t&&t._binding&&this._values&&Object.keys(this._values).length))return!0;e=t._binding.getValue(e);e=this.dataMap?this.dataMap.getDisplayValue(e)||"":t.dataMap?t.dataMap.getDisplayValue(e)||"":wijmo_1.Globalize.format(e,t.format);return null!=this._values[e]};ValueFilter.prototype.clear=function(){this.showValues=null;this.filterText=null};ValueFilter.prototype.getUniqueValues=function(e){void 0===e&&(e=!0);var t=[],i=this.column,r=wijmo_1.Globalize.format;if(this.uniqueValues){this.uniqueValues.forEach((function(e){t.push({value:e,text:r(e,i.format)})}));return t}var n={},l=i.collectionView,o=l?l.sourceCollection:[];if(e&&l&&l.sourceCollection&&l.filter)try{FlexGridFilter._skipColumn=this._col;for(var a=[],s=0;s<o.length;s++)l.filter(o[s])&&a.push(o[s]);o=a}finally{FlexGridFilter._skipColumn=null}for(s=0;s<o.length;s++){var u=i._binding.getValue(o[s]),d=this.dataMap?this.dataMap.getDisplayValue(u)||"":i.dataMap?i.dataMap.getDisplayValue(u)||"":r(u,i.format);if(!n[d]){n[d]=!0;t.push({value:u,text:d})}}this._exceedsMaxValues=t.length>this._maxValues;return t};Object.defineProperty(ValueFilter.prototype,"exceedsMaxValues",{get:function(){return this._exceedsMaxValues},enumerable:!0,configurable:!0});ValueFilter.prototype.implementsInterface=function(e){return"IColumnFilter"==e};return ValueFilter}();exports.ValueFilter=ValueFilter;var ValueFilterEditor=function(e){__extends(ValueFilterEditor,e);function ValueFilterEditor(t,i){var r=e.call(this,t)||this;r._canApply=!1;r._isFiltering=!1;r.canApplyChanged=new wijmo_1.Event;r._filter=wijmo_1.asType(i,ValueFilter,!1);var n=r.getTemplate();r.applyTemplate("wj-control wj-valuefilter-editor",n,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values",_warning:"warning-message"});r._cbSelectAll.tabIndex=0;var l=wijmo_1.culture.FlexGridFilter;wijmo_1.setText(r._spSelectAll,l.selectAll);var o=r._view=new wijmo_1.CollectionView(null,{sortNulls:wijmo_1.SortNulls.First,filter:r._filterValues.bind(r)});if(i.sortValues){var a=i.column.dataMap||i.dataMap?"text":"value",s=i.column.dataType!=wijmo_1.DataType.Boolean;o.sortDescriptions.push(new wijmo_1.SortDescription(a,s))}o.collectionChanged.addHandler(r._updateSelectAllCheck,r);r._filterText="";r._rxFilter=null;r._cmbFilter=new input.ComboBox(r._divFilter,{isRequired:!1,placeholder:l.search});r._cmbFilter.isEditable=!0;r._lbValues=new input.ListBox(r._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:r._view,itemFormatter:function(e,t){return t||l.null},checkedItemsChanged:function(e){return r._updateSelectAllCheck()}});wijmo_1.setAriaLabel(r._cmbFilter.inputElement,l.ariaLabels.search);wijmo_1.setAttribute(r._lbValues.hostElement,"aria-multiselectable",!0);r._cmbFilter.inputElement.addEventListener("input",r._filterTextChanged.bind(r));r._cbSelectAll.addEventListener("click",r._cbSelectAllClicked.bind(r));r._warning.addEventListener("click",(function(){return r._showModal()}));r._modal=r._createModal();document.body.appendChild(r._modal);r.updateEditor();r._initialItems=r._lbValues.checkedItems;return r}Object.defineProperty(ValueFilterEditor.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});Object.defineProperty(ValueFilterEditor.prototype,"canApply",{get:function(){return this._canApply},set:function(e){if(e!=this._canApply){this._canApply=e;this.onCanApplyChanged()}},enumerable:!0,configurable:!0});ValueFilterEditor.prototype.updateEditor=function(){var e=this,t=this._filter.column,i=this._filter.getUniqueValues(!0);this._lbValues.isContentHtml=t.isContentHtml;var r=this._filter.showValues;if(r&&0!=Object.keys(r).length){for(var n in r)for(var l=0;l<i.length;l++)if(i[l].text==n){i[l].show=!0;break}}else i.forEach((function(e){return e.show=!0}));this._warning.style.display=this._filter.exceedsMaxValues?"block":"none";var o=this._filter.filterText||"",a=this._getCaseSensitive();this._cmbFilter.text=o;this._filterText=a?o:o.toLowerCase();this._rxFilter=this._getSearchExp(o,a);var s=this._view;s.pageSize=this._filter.maxValues;s.sourceCollection=i;setTimeout((function(){e._adjustWidths()}),0)};ValueFilterEditor.prototype.clearEditor=function(e){void 0===e&&(e=!0);this._cmbFilter.text="";this._filterText="";this._rxFilter=null;var t=this._view;t.pageSize=0;t.items.forEach((function(t){t.show=e}));t.moveCurrentTo(-1);t.refresh();t.pageSize=this._filter.maxValues};Object.defineProperty(ValueFilterEditor.prototype,"isEditorClear",{get:function(){return!this._filterText&&!this._cbSelectAll.indeterminate},enumerable:!0,configurable:!0});ValueFilterEditor.prototype._updateFilter=function(){var e=null,t=this._getItems();if(this._filterText||this._cbSelectAll.indeterminate){e={};for(var i=0;i<t.length;i++){var r=t[i];r.show&&(e[r.text]=!0)}}var n=this._filter;n.showValues=e;n.filterText=this._filterText};ValueFilterEditor.prototype.updateFilter=function(){var e=this;this._isFiltering?setTimeout((function(){e._updateFilter()}),wijmo_1.Control._SEARCH_DELAY+100):this._updateFilter()};ValueFilterEditor.prototype.onCanApplyChanged=function(e){this.canApplyChanged.raise(this,e)};ValueFilterEditor.prototype._getCaseSensitive=function(){var e=this._filter.column,t=e?e.grid:null;return t&&t.caseSensitiveSearch};ValueFilterEditor.prototype._getItems=function(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection};ValueFilterEditor.prototype._filterTextChanged=function(){var e=this;""===this._filterText&&this._cbSelectAll.checked||this._filter.exclusiveValueSearch?this._lbValues._addMode=!1:this._lbValues._addMode=!0;this._toFilter&&clearTimeout(this._toFilter);this._isFiltering=!0;this._toFilter=setTimeout((function(){var t=e._cmbFilter.text,i=e._getCaseSensitive();i||(t=t.toLowerCase());if(t!=e._filterText){e._filterText=t;e._rxFilter=e._getSearchExp(t,i);e._view.refresh();if(!t){var r=e._initialItems;if(r.length&&e._view.sourceCollection.indexOf(r[0])>-1){e._lbValues.checkedItems=e._initialItems;e._updateSelectAllCheck();e._isFiltering=!1;return}}if(e._filter.exclusiveValueSearch){e._cbSelectAll.checked=!0;e._cbSelectAllClicked()}else e._updateSelectAllCheck()}e._isFiltering=!1}),wijmo_1.Control._SEARCH_DELAY)};ValueFilterEditor.prototype._getSearchExp=function(e,t){if(!e)return null;switch(this._filter.searchType){case ValueFilterSearchKind.Text:return this._getTextSearchExp(e,t);case ValueFilterSearchKind.Regex:return this._getRegexSearchExp(e,t);case ValueFilterSearchKind.Excel:return this._getExcelSearchExp(e,t)}};ValueFilterEditor.prototype._getTextSearchExp=function(e,t){return new RegExp(wijmo_1.escapeRegExp(e),t?"":"i")};ValueFilterEditor.prototype._getRegexSearchExp=function(e,t){try{return new RegExp(e,t?"s":"is")}catch(e){return new RegExp("(?!)",t?"s":"is")}};ValueFilterEditor.prototype._getExcelSearchExp=function(e,t){var i=e;i=(i=(i=(i=(i=i.replace(/([.+^$[\]\\(){}|-])/g,"\\$1")).replace(/(?<!~)(\?+)/g,(function(e,t){return Array.from(t).map((function(e){return"."})).join("")}))).replace(/(?<!~)(\*+)/g,(function(e,t){return Array.from(t).map((function(e){return".*"})).join("")}))).replace(/~~/g,"~")).replace(/~([?*])/g,"\\$1");/(?<!~)[?*]/g.test(e)&&(i="^"+i+"$");return new RegExp(i,t?"s":"is")};ValueFilterEditor.prototype._filterValues=function(e){var t=this._rxFilter;return null==t||null==e||t.test(e.text)};ValueFilterEditor.prototype._cbSelectAllClicked=function(){for(var e=this,t=this._cbSelectAll.checked,i=this._divValues.scrollTop,r=this._getItems(),n=0;n<r.length;n++)r[n].show=t;this._view.refresh();this._divValues.scrollTop=i;setTimeout((function(){e._adjustWidths()}),0)};ValueFilterEditor.prototype._updateSelectAllCheck=function(){for(var e=this._getItems(),t=0,i=0,r=0;r<e.length;r++){e[r].show?t++:i++;if(t&&i)break}wijmo_1.setChecked(this._cbSelectAll,t&&i?null:t>0);this.canApply=t>0};ValueFilterEditor.prototype._adjustWidths=function(){var e=this._lbValues.hostElement;if(e&&e.offsetHeight>0){var t=0,i=e.querySelectorAll(".wj-listbox-item label");if(i.length){for(var r=0;r<i.length;r++)t=Math.max(t,i[r].scrollWidth);if(t){var n=e.querySelectorAll(".wj-listbox-item");if(n.length){var l=n[0],o=getComputedStyle(l),a=parseFloat(o.paddingLeft)+parseFloat(o.paddingRight);for(r=0;r<n.length;r++)n[r].style.width=t+a+"px"}}}}};ValueFilterEditor.prototype._createModal=function(){var e=this,t=this._filter.maxValues,i=document.createElement("div");i.className="modal";i.innerHTML='<div class="modal-content"><span class="close">&times;</span><p>This column has more than '+t+" unique items. Only the first "+t+" unique items are displayed. Please set the maxValues property of the ValueFilter to see all the values on the list.</p></div>";i.querySelector(".close").addEventListener("click",(function(){return e._modal.style.display="none"}));return i};ValueFilterEditor.prototype._showModal=function(){this._modal.style.display="block";this.hostElement.style.display="none"};ValueFilterEditor.controlTemplate='<div><div wj-part="div-filter"></div><div class="wj-listbox-item"><label><input wj-part="cb-select-all" type="checkbox"> <span wj-part="sp-select-all"></span></label></div><div wj-part="div-values"></div><div wj-part="warning-message" style="display: none;">Not all items are shown</div></div>';return ValueFilterEditor}(wijmo_1.Control);exports.ValueFilterEditor=ValueFilterEditor;var ColumnFilter=function(){function ColumnFilter(e,t){var i=this;this._owner=e;this._col=t;this._valueFilter=new ValueFilter(t);this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch;this._conditionFilter=new ConditionFilter(t);e.exclusiveValueSearchChanged.addHandler((function(e){i._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch}))}Object.defineProperty(ColumnFilter.prototype,"filterType",{get:function(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType},set:function(e){if((e=wijmo_1.asEnum(e,FilterType,!0))!=this._filterType){var t=this.isActive;this.clear();this._filterType=e;t?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"dataMap",{get:function(){return this.conditionFilter.dataMap||this.valueFilter.dataMap},set:function(e){this.conditionFilter.dataMap=e;this.valueFilter.dataMap=e},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"valueFilter",{get:function(){return this._valueFilter},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"conditionFilter",{get:function(){return this._conditionFilter},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0});Object.defineProperty(ColumnFilter.prototype,"isActive",{get:function(){return this._conditionFilter.isActive||this._valueFilter.isActive},enumerable:!0,configurable:!0});ColumnFilter.prototype.apply=function(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)};ColumnFilter.prototype.clear=function(){this._valueFilter.clear();this._conditionFilter.clear()};ColumnFilter.prototype.implementsInterface=function(e){return"IColumnFilter"==e};return ColumnFilter}();exports.ColumnFilter=ColumnFilter;wijmo_1._addCultureInfo("FlexGridFilter",{ariaLabels:{edit:"Edit Filter for Column",dialog:"Filter Editor for Column",asc:"Sort Column in Ascending Order",dsc:"Sort Column in Descending Order",search:"Search Item List",op1:"First Condition Operator",val1:"First Condition Value",and:"Require both Conditions",or:"Require either Condition",op2:"Second Condition Operator",val2:"Second Condition Value"},ascending:"↑ Ascending",descending:"↓ Descending",apply:"Apply",cancel:"Cancel",clear:"Clear",conditions:"Filter by Condition",values:"Filter by Value",search:"Search",selectAll:"Select All",null:"(nothing)",header:"Show items where the value",and:"And",or:"Or",stringOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Begins with",op:Operator.BW},{name:"Ends with",op:Operator.EW},{name:"Contains",op:Operator.CT},{name:"Does not contain",op:Operator.NC}],numberOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE},{name:"Is Greater than",op:Operator.GT},{name:"Is Greater than or equal to",op:Operator.GE},{name:"Is Less than",op:Operator.LT},{name:"Is Less than or equal to",op:Operator.LE}],dateOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Is Before",op:Operator.LT},{name:"Is After",op:Operator.GT}],booleanOperators:[{name:"(not set)",op:null},{name:"Equals",op:Operator.EQ},{name:"Does not equal",op:Operator.NE}]});var ColumnFilterEditor=function(e){__extends(ColumnFilterEditor,e);function ColumnFilterEditor(t,i,r){void 0===r&&(r=!0);var n=e.call(this,t,null,!0)||this;n.filterChanged=new wijmo_1.Event;n.buttonClicked=new wijmo_1.Event;n._filter=wijmo_1.asType(i,ColumnFilter);var l=n.getTemplate();n.applyTemplate("wj-control wj-content wj-columnfiltereditor",l,{_divSort:"div-sort",_btnAsc:"btn-asc",_btnDsc:"btn-dsc",_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnApply:"btn-apply",_btnCancel:"btn-cancel",_btnClear:"btn-clear"});var o=wijmo_1.culture.FlexGridFilter,a=o.ariaLabels,s=n.hostElement,u=n.filter.column,d=u.grid.collectionView;wijmo_1.setAttribute(s,"role","dialog");wijmo_1.setAriaLabel(s,a.dialog+" "+u.header);wijmo_1.setAriaLabel(n._btnAsc,a.asc);wijmo_1.setAriaLabel(n._btnDsc,a.dsc);wijmo_1.setText(n._btnAsc,o.ascending);wijmo_1.setText(n._btnDsc,o.descending);wijmo_1.setText(n._aVal,o.values);wijmo_1.setText(n._aCnd,o.conditions);wijmo_1.setText(n._btnApply,o.apply);wijmo_1.setText(n._btnCancel,o.cancel);wijmo_1.setText(n._btnClear,o.clear);var c=n.filter.conditionFilter.isActive||0==(i.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;n._showFilter(c);r&&d&&d.canSort||(n._divSort.style.display="none");n._updateSortButtonState();var p=n._btnClicked.bind(n);n._btnApply.addEventListener("click",p);n._btnCancel.addEventListener("click",p);n._btnClear.addEventListener("click",p);n._btnAsc.addEventListener("click",p);n._btnDsc.addEventListener("click",p);n._aVal.addEventListener("click",p);n._aCnd.addEventListener("click",p);n.addEventListener(s,"keydown",(function(e){if(!e.defaultPrevented){var t=e.target.tagName.match(/^(a|button)$/i);switch(e.keyCode){case wijmo_1.Key.Space:if(t){n._btnClicked(e);e.preventDefault()}break;case wijmo_1.Key.Enter:if(t)n._btnClicked(e);else{n.updateFilter();n.onFilterChanged();n.onButtonClicked()}e.preventDefault();break;case wijmo_1.Key.Escape:n.onButtonClicked();e.preventDefault();break;case wijmo_1.Key.Tab:wijmo_1.moveFocus(n.hostElement,e.shiftKey?-1:1);e.preventDefault()}}}));n.addEventListener(window,"resize",(function(){n.isTouching||n._wasTouching||n.onButtonClicked()}));return n}Object.defineProperty(ColumnFilterEditor.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});ColumnFilterEditor.prototype.updateEditor=function(){this._edtVal&&this._edtVal.updateEditor();this._edtCnd&&this._edtCnd.updateEditor()};ColumnFilterEditor.prototype.updateFilter=function(){switch(this._getFilterType()){case FilterType.Value:this._edtVal.updateFilter();this.filter.conditionFilter.clear();break;case FilterType.Condition:this._edtCnd.updateFilter();this.filter.valueFilter.clear()}};ColumnFilterEditor.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)};ColumnFilterEditor.prototype.onButtonClicked=function(e){this.buttonClicked.raise(this,e)};ColumnFilterEditor.prototype._showFilter=function(e){var t=this;this._wasTouching=this.isTouching;if(e==FilterType.Value&&null==this._edtVal){this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter);this._edtVal.canApplyChanged.addHandler((function(e){wijmo_1.enable(t._btnApply,t._edtVal.canApply)}))}if(e==FilterType.Condition&&null==this._edtCnd){this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter);this._edtCnd.canApplyChanged.addHandler((function(e){wijmo_1.enable(t._btnApply,t._edtCnd.canApply)}))}if(0!=(e&this.filter.filterType))if(e==FilterType.Value){this._divEdtVal.style.display="";this._divEdtCnd.style.display="none";this._enableLink(this._aVal,!1);this._enableLink(this._aCnd,!0);this._edtVal.focus();wijmo_1.enable(this._btnApply,this._edtVal.canApply)}else{this._divEdtVal.style.display="none";this._divEdtCnd.style.display="";this._enableLink(this._aVal,!0);this._enableLink(this._aCnd,!1);this._edtCnd.focus();wijmo_1.enable(this._btnApply,this._edtCnd.canApply)}var i=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:i.display="none";break;default:i.display=""}};ColumnFilterEditor.prototype._enableLink=function(e,t){wijmo_1.toggleClass(e,"wj-state-disabled",!t);wijmo_1.setAttribute(e,"href",t?"":null);wijmo_1.setAttribute(e,"disabled",t?null:"disabled")};ColumnFilterEditor.prototype._updateSortButtonState=function(){var e=this.filter.column,t=e?e.currentSort:"",i="wj-state-active";wijmo_1.toggleClass(this._btnAsc,i,"+"==t);wijmo_1.toggleClass(this._btnDsc,i,"-"==t)};ColumnFilterEditor.prototype._getFilterType=function(){var e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition};ColumnFilterEditor.prototype._btnClicked=function(e){var t=this,i=e.target;e.preventDefault();e.stopPropagation();if(!wijmo_1.hasClass(i,"wj-state-disabled"))if(i!=this._aVal)if(i!=this._aCnd){if(i==this._btnAsc||i==this._btnDsc){var r=this.filter.column,n=r.sortMemberPath||r.binding,l=r.grid.collectionView.sortDescriptions;l.deferUpdate((function(){l.clear();l.push(new wijmo_1.SortDescription(n,e.target==t._btnAsc))}));this._updateSortButtonState()}if(i==this._btnApply){this.updateFilter();this.onFilterChanged()}else if(i==this._btnClear){if(this.filter.isActive){this.filter.clear();this.onFilterChanged()}}else this.updateEditor();this.onButtonClicked()}else{this._showFilter(FilterType.Condition);wijmo_1.moveFocus(this._edtCnd.hostElement,0)}else{this._showFilter(FilterType.Value);wijmo_1.moveFocus(this._edtVal.hostElement,0)}};ColumnFilterEditor.controlTemplate='<div><div wj-part="div-sort" class="wj-sort-buttons"><button wj-part="btn-asc" class="wj-btn"></button>&nbsp;&nbsp;&nbsp;<button wj-part="btn-dsc" class="wj-btn"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a>&nbsp;|&nbsp;<a wj-part="a-val" href="" draggable="false"></a></div><div wj-part="div-edt-val" tabindex="-1"></div><div wj-part="div-edt-cnd" tabindex="-1"></div><div style="text-align:right;margin-top:10px"><button wj-part="btn-apply" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-cancel" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-clear" class="wj-btn"></button></div></div>';return ColumnFilterEditor}(wijmo_1.Control);exports.ColumnFilterEditor=ColumnFilterEditor;wijmo_1._registerModule("wijmo.grid.filter",selfModule);
{
"name": "@grapecity/wijmo.grid.filter",
"version": "5.20241.001-nightly.d20240116.t020147",
"version": "5.20241.001-nightly.d20240117.t020138",
"description": "UI library for pure JS, Angular, React, Vue and more...",

@@ -10,5 +10,5 @@ "author": "MESCIUS inc",

"dependencies": {
"@grapecity/wijmo": "5.20241.001-nightly.d20240116.t020147",
"@grapecity/wijmo.input": "5.20241.001-nightly.d20240116.t020147",
"@grapecity/wijmo.grid": "5.20241.001-nightly.d20240116.t020147"
"@grapecity/wijmo": "5.20241.001-nightly.d20240117.t020138",
"@grapecity/wijmo.input": "5.20241.001-nightly.d20240117.t020138",
"@grapecity/wijmo.grid": "5.20241.001-nightly.d20240117.t020138"
},

@@ -15,0 +15,0 @@ "homepage": "https://developer.mescius.com/wijmo",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc