@grapecity/wijmo.grid.filter
Advanced tools
Comparing version 5.20191.599-nightly.d20190408.t120542 to 5.20191.599-nightly.d20190408.t162215
/*! | ||
* | ||
* Wijmo Library 5.20191.599-nightly.d20190408.t120542 | ||
* Wijmo Library 5.20191.599-nightly.d20190408.t162215 | ||
* http://wijmo.com/ | ||
@@ -14,2 +14,2 @@ * | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_grid_1=require("@grapecity/wijmo.grid"),wijmo_1=require("@grapecity/wijmo"),input=require("@grapecity/wijmo.input"),selfModule=require("@grapecity/wijmo.grid.filter");class FilterCondition{constructor(t){this._op=null,this._filter=t}get operator(){return this._op}set operator(t){this._op=wijmo_1.asEnum(t,Operator,!0)}get value(){return this._val}set value(t){if(this._val=t,this._strVal=wijmo_1.isString(t)?t.toString().toLowerCase():null,this._mapVal=null,this._filter){let e=this._filter.dataMap||this._filter.column.dataMap;e&&(this._mapVal=e.getDisplayValue(t),wijmo_1.isString(this._mapVal)&&(this._strVal=this._mapVal=this._mapVal.toLowerCase()))}}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(t,e,i){let l=this._mapVal||this._strVal||this._val;wijmo_1.isString(t)&&(t=t.toLowerCase()),wijmo_1.isString(l)&&null==t&&(t=""),wijmo_1.isDate(l)&&(e?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!=t&&null!=l?t.valueOf()==l.valueOf():t==l;case s.NE:return null!=t&&null!=l?t.valueOf()!=l.valueOf():t!=l;case s.GT:return t>l;case s.GE:return t>=l;case s.LT:return t<l;case s.LE:return t<=l;case s.BW:return!(null==this._strVal||!wijmo_1.isString(t))&&0==t.indexOf(this._strVal);case s.EW:return!!(null!=this._strVal&&wijmo_1.isString(t)&&t.length>=this._strVal.length)&&t.substr(t.length-this._strVal.length)==l;case s.CT:return!(null==this._strVal||!wijmo_1.isString(t))&&t.indexOf(this._strVal)>-1;case s.NC:return!(null==this._strVal||!wijmo_1.isString(t))&&t.indexOf(this._strVal)<0}throw"Unknown operator"}}var Operator,FilterType;FilterCondition._refDateTime=new Date(2e3,0,1,0,0,0),exports.FilterCondition=FilterCondition,function(t){t[t.EQ=0]="EQ",t[t.NE=1]="NE",t[t.GT=2]="GT",t[t.GE=3]="GE",t[t.LT=4]="LT",t[t.LE=5]="LE",t[t.BW=6]="BW",t[t.EW=7]="EW",t[t.CT=8]="CT",t[t.NC=9]="NC"}(Operator=exports.Operator||(exports.Operator={}));class ConditionFilter{constructor(t){this._c1=new FilterCondition(this),this._c2=new FilterCondition(this),this._and=!0,this._col=t}get condition1(){return this._c1}get condition2(){return this._c2}get and(){return this._and}set and(t){this._and=wijmo_1.asBoolean(t)}get dataMap(){return this._map}set dataMap(t){this._map=wijmo_1.asType(t,wijmo_grid_1.DataMap,!0)}get column(){return this._col}get isActive(){return this._c1.isActive||this._c2.isActive}apply(t){let e=this._col,i=this._c1,l=this._c2,s=!1,a=!1;if(!e||!e._binding||!this.isActive)return!0;if(t=e._binding.getValue(t),this.dataMap)t=this.dataMap.getDisplayValue(t);else if(e.dataMap)t=e.dataMap.getDisplayValue(t);else if(wijmo_1.isDate(t))if(s=!this._hasTimePart(),a=!this._hasDatePart(),wijmo_1.assert(!s||!a,"Filter should have either date or time."),s){Date();t=wijmo_1.DateTime.fromDateTime(t,FilterCondition._refDateTime)}else a&&(t=wijmo_1.DateTime.fromDateTime(FilterCondition._refDateTime,t));else wijmo_1.isNumber(t)&&(t=wijmo_1.Globalize.parseFloat(wijmo_1.Globalize.format(t,e.format)));let r=i.apply(t,s,a),n=l.apply(t,s,a);return i.isActive&&l.isActive?this._and?r&&n:r||n:i.isActive?r:!l.isActive||n}clear(){this._c1.clear(),this._c2.clear(),this.and=!0}_hasDatePart(){let t=this._col.format;return!t||(t=wijmo_1.culture.Globalize.calendar.patterns[t]||t,/[yMd]+/.test(t))}_hasTimePart(){let t=this._col.format;return!!t&&(t=wijmo_1.culture.Globalize.calendar.patterns[t]||t,/[Hmst]+/.test(t))}implementsInterface(t){return"IColumnFilter"==t}}exports.ConditionFilter=ConditionFilter;class ConditionFilterEditor extends wijmo_1.Control{constructor(t,e){super(t),this._filter=wijmo_1.asType(e,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),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((t,e)=>{this._val1.isDisabled=null==t.selectedValue}),this._val2.isDisabled=!0,this._cmb2.selectedIndexChanged.addHandler((t,e)=>{this._val2.isDisabled=null==t.selectedValue});let a=this.hostElement;this.addEventListener(a,"change",this._btnAndOrChanged.bind(this)),this.addEventListener(a,"keydown",this._keydown.bind(this)),this.updateEditor()}get filter(){return this._filter}updateEditor(){let t=this._filter.condition1,e=this._filter.condition2;this._cmb1.selectedValue=t.operator,this._cmb2.selectedValue=e.operator,this._val1 instanceof input.ComboBox&&!(this._val1 instanceof input.InputTime)?(this._val1.text=wijmo_1.changeType(t.value,wijmo_1.DataType.String),this._val2.text=wijmo_1.changeType(e.value,wijmo_1.DataType.String)):(this._val1.value=t.value,this._val2.value=e.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 t=this._filter.condition1,e=this._filter.condition2;t.operator=this._cmb1.selectedValue,e.operator=this._cmb2.selectedValue,"value"in this._val1?(t.value=this._val1.value,e.value=this._val2.value):(t.value=this._val1.selectedValue,e.value=this._val2.selectedValue),this._filter.and=this._btnAnd.checked}_createOperatorCombo(t,e){let i=this._filter.column,l=wijmo_1.culture.FlexGridFilter,s=l.stringOperators,a=this._filter.dataMap||i.dataMap,r=wijmo_1.DataType;i.dataType==r.Date?s=l.dateOperators:i.dataType!=r.Number||a?i.dataType!=r.Boolean||a||(s=l.booleanOperators):s=l.numberOperators;let n=new input.ComboBox(t,{itemsSource:s,displayMemberPath:"name",selectedValuePath:"op"});return wijmo_1.setAriaLabel(n.inputElement,e),n}_createValueInput(t,e){let i=this._filter,l=i.column,s=i.dataMap||l.dataMap,a=null,r=wijmo_1.DataType;return l.dataType==r.Date?(a=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(t):new input.InputDate(t):new input.InputTime(t)).format=l.format:l.dataType!=r.Number||s?(a=new input.ComboBox(t),s?(a.itemsSource=s.getDisplayValues(),a.isEditable=!0):l.dataType==r.Boolean&&(a.itemsSource=[!0,!1])):(a=new input.InputNumber(t)).format=l.format,a.isRequired=!1,wijmo_1.setAriaLabel(a.inputElement,e),a}_btnAndOrChanged(t){let e=t.target==this._btnAnd,i=t.target==this._btnOr;(e||i)&&(this._checkRadio(this._btnAnd,e),this._checkRadio(this._btnOr,i))}_checkRadio(t,e){t.checked=e,t.setAttribute("aria-checked",e.toString()),t.setAttribute("tabindex",e?"1":"-1")}_keydown(t){let e=t.target==this._btnAnd,i=t.target==this._btnOr;if(e||i)switch(t.keyCode){case wijmo_1.Key.Left:case wijmo_1.Key.Right:case wijmo_1.Key.Up:case wijmo_1.Key.Down:let i=e?this._btnOr:this._btnAnd;i.click(),i.focus(),t.preventDefault()}}}ConditionFilterEditor.controlTemplate='<div><div wj-part="div-hdr"></div><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> <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 ValueFilter{constructor(t){this._xValueSearch=!0,this._maxValues=250,this._sortValues=!0,this._col=t}get showValues(){return this._values}set showValues(t){this._values=t}get filterText(){return this._filterText}set filterText(t){this._filterText=wijmo_1.asString(t)}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(t){this._xValueSearch=wijmo_1.asBoolean(t)}get maxValues(){return this._maxValues}set maxValues(t){this._maxValues=wijmo_1.asNumber(t,!1,!0)}get uniqueValues(){return this._uniqueValues}set uniqueValues(t){this._uniqueValues=wijmo_1.asArray(t)}get sortValues(){return this._sortValues}set sortValues(t){this._sortValues=wijmo_1.asBoolean(t)}get dataMap(){return this._map}set dataMap(t){this._map=wijmo_1.asType(t,wijmo_grid_1.DataMap,!0)}get column(){return this._col}get isActive(){return null!=this._values&&Object.keys(this._values).length>0}apply(t){let e=this.column;return!(e&&e._binding&&this._values&&Object.keys(this._values).length)||(t=e._binding.getValue(t),t=this.dataMap?this.dataMap.getDisplayValue(t):e.dataMap?e.dataMap.getDisplayValue(t):wijmo_1.Globalize.format(t,e.format),void 0!=this._values[t])}clear(){this.showValues=null,this.filterText=null}implementsInterface(t){return"IColumnFilter"==t}_getUniqueValues(t,e){let i=[];if(this.uniqueValues){let t=this.uniqueValues;for(let e=0;e<t.length;e++){let l=t[e];i.push({value:l,text:l.toString()})}return i}let l={},s=t.collectionView,a=s?s.sourceCollection:[];if(e&&s&&s.sourceCollection&&s.filter){let t=this.showValues;this.showValues=null;let e=[];for(let t=0;t<a.length;t++)s.filter(a[t])&&e.push(a[t]);a=e,this.showValues=t}for(let e=0;e<a.length;e++){let s=t._binding.getValue(a[e]),r=this.dataMap?this.dataMap.getDisplayValue(s):t.dataMap?t.dataMap.getDisplayValue(s):wijmo_1.Globalize.format(s,t.format);l[r]||(l[r]=!0,i.push({value:s,text:r}))}return i}}exports.ValueFilter=ValueFilter;class ValueFilterEditor extends wijmo_1.Control{constructor(t,e){super(t),this._filter=wijmo_1.asType(e,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;if(s.sortNullsFirst=!0,e.sortValues){let t=e.column.dataMap||e.dataMap?"text":"value",i=e.column.dataType!=wijmo_1.DataType.Boolean;s.sortDescriptions.push(new wijmo_1.SortDescription(t,i))}s.filter=this._filterValues.bind(this),s.collectionChanged.addHandler(this._updateSelectAllCheck,this),this._filterText="",this._cmbFilter=new input.ComboBox(this._divFilter,{placeholder:l.search}),this._lbValues=new input.ListBox(this._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:this._view,itemFormatter:(t,e)=>e||l.null}),wijmo_1.setAriaLabel(this._cmbFilter.inputElement,l.ariaLabels.search),this._cmbFilter.textChanged.addHandler(this._filterTextChanged,this),this._cbSelectAll.addEventListener("click",this._cbSelectAllClicked.bind(this)),this.updateEditor()}get filter(){return this._filter}updateEditor(){let t=this._filter.column,e=this._filter._getUniqueValues(t,!0);this._lbValues.isContentHtml=t.isContentHtml;let i=this._filter.showValues;if(i&&0!=Object.keys(i).length){for(let t in i)for(let i=0;i<e.length;i++)if(e[i].text==t){e[i].show=!0;break}}else for(let t=0;t<e.length;t++)e[t].show=!0;this._view.pageSize=20,this._view.sourceCollection=e,setTimeout(()=>{this._view.pageSize=this._filter.maxValues,this._cmbFilter.text=this._filter.filterText||"",this._filterText=this._cmbFilter.text.toLowerCase()})}clearEditor(t=!0){this._cmbFilter.text="",this._filterText="",this._view.pageSize=0,this._view.refresh(),this._view.items.forEach(e=>{e.show=t}),this._view.pageSize=this._filter.maxValues}get isEditorClear(){return!this._filterText&&!this._cbSelectAll.indeterminate}updateFilter(){let t=null,e=this._getItems();if(this._filterText||this._cbSelectAll.indeterminate){t={};for(let i=0;i<e.length;i++){let l=e[i];l.show&&(t[l.text]=!0)}}let i=this._filter;i.showValues=t,i.filterText=""}_getItems(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection}_filterTextChanged(){this._toText&&clearTimeout(this._toText),this._toText=setTimeout(()=>{let t=this._cmbFilter.text.toLowerCase(),e=t!=this._filterText;this._filterText=t,this._view.refresh(),e&&(this._filter.exclusiveValueSearch?(this._cbSelectAll.checked=!0,this._cbSelectAllClicked()):this._updateSelectAllCheck())},300)}_filterValues(t){return!this._filterText||!(!t||!t.text)&&t.text.toLowerCase().indexOf(this._filterText)>-1}_cbSelectAllClicked(){let t=this._cbSelectAll.checked,e=this._divValues.scrollTop,i=this._getItems();for(let e=0;e<i.length;e++)i[e].show=t;this._view.refresh(),this._divValues.scrollTop=e}_updateSelectAllCheck(){let t=0,e=this._getItems();for(let i=0;i<e.length;i++)e[i].show&&t++;let i=this._cbSelectAll;0==t?(i.checked=!1,i.indeterminate=!1):t==e.length?(i.checked=!0,i.indeterminate=!1):i.indeterminate=!0}}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(t,e){this._owner=t,this._col=e,this._valueFilter=new ValueFilter(e),this._valueFilter.exclusiveValueSearch=t.exclusiveValueSearch,this._conditionFilter=new ConditionFilter(e)}get filterType(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType}set filterType(t){if((t=wijmo_1.asEnum(t,FilterType,!0))!=this._filterType){let e=this.isActive;this.clear(),this._filterType=t,e?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}}get dataMap(){return this.conditionFilter.dataMap||this.valueFilter.dataMap}set dataMap(t){this.conditionFilter.dataMap=t,this.valueFilter.dataMap=t}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(t){return this._conditionFilter.apply(t)&&this._valueFilter.apply(t)}clear(){this._valueFilter.clear(),this._conditionFilter.clear()}implementsInterface(t){return"IColumnFilter"==t}}exports.ColumnFilter=ColumnFilter,function(t){t[t.None=0]="None",t[t.Condition=1]="Condition",t[t.Value=2]="Value",t[t.Both=3]="Both"}(FilterType=exports.FilterType||(exports.FilterType={}));class FlexGridFilter{constructor(t,e){this._showIcons=!0,this._showSort=!0,this._defFilterType=FilterType.Both,this._xValueSearch=!0,this.filterApplied=new wijmo_1.Event,this.filterChanging=new wijmo_1.Event,this.filterChanged=new wijmo_1.Event,this._filters=[],this._g=wijmo_1.asType(t,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;t.addEventListener(i,"mousedown",this._mousedown.bind(this),!0),t.addEventListener(i,"click",this._click.bind(this),!0),t.addEventListener(i,"keydown",this._keydown.bind(this),!0),this._g.invalidate(),e&&wijmo_1.copy(this,e)}get grid(){return this._g}get filterColumns(){return this._filterColumns}set filterColumns(t){this._filterColumns=wijmo_1.asArray(t),this.clear()}get showFilterIcons(){return this._showIcons}set showFilterIcons(t){t!=this.showFilterIcons&&(this._showIcons=wijmo_1.asBoolean(t),this._g&&this._g.invalidate())}get showSortButtons(){return this._showSort}set showSortButtons(t){this._showSort=wijmo_1.asBoolean(t)}getColumnFilter(t,e=!0){t=this._asColumn(t);for(let e=0;e<this._filters.length;e++)if(this._filters[e].column==t)return this._filters[e];if(e&&t.binding){let e=new ColumnFilter(this,t);return this._filters.push(e),e}return null}get defaultFilterType(){return this._defFilterType}set defaultFilterType(t){(t=wijmo_1.asEnum(t,FilterType,!1))!=this.defaultFilterType&&(this._defFilterType=t,this._g.invalidate(),this.clear())}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(t){this._xValueSearch=wijmo_1.asBoolean(t)}get filterDefinition(){let t={defaultFilterType:this.defaultFilterType,filters:[]};return this._filters.forEach(e=>{let i=e.conditionFilter,l=e.valueFilter,s=l.uniqueValues&&l.uniqueValues.length;if(e&&e.column&&e.column.binding&&(e.isActive||s||e.filterType!=this.defaultFilterType)){let a={binding:e.column.binding};if(i.isActive){let t=i.condition1,l=i.condition2;a={binding:e.column.binding,type:"condition",condition1:{operator:t.operator,value:t.value},and:i.and,condition2:{operator:l.operator,value:l.value}}}else(l.isActive||s)&&(a={binding:e.column.binding,type:"value",uniqueValues:l.uniqueValues,sortValues:l.sortValues,maxValues:l.maxValues,exclusiveValueSearch:l.exclusiveValueSearch,showValues:l.showValues});e.filterType!=this.defaultFilterType&&(a.filterType=e.filterType),t.filters.push(a)}}),JSON.stringify(t)}set filterDefinition(t){if(t=wijmo_1.asString(t),this.clear(),t){let e=JSON.parse(t);this.defaultFilterType=e.defaultFilterType;for(let t=0;t<e.filters.length;t++){let i=e.filters[t],l=this._g.getColumn(i.binding),s=this.getColumnFilter(l,!0);if(s)switch(null!=i.filterType&&(s.filterType=wijmo_1.asEnum(i.filterType,FilterType)),i.type){case"condition":let t=s.conditionFilter;t.condition1.value=l.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(i.condition1.value,l.dataType,null):i.condition1.value,t.condition1.operator=i.condition1.operator,t.and=i.and,t.condition2.value=l.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(i.condition2.value,l.dataType,null):i.condition2.value,t.condition2.operator=i.condition2.operator;break;case"value":let e=s.valueFilter;e.uniqueValues=i.uniqueValues,["sortValues","maxValues","exclusiveValueSearch"].forEach(t=>{null!=i[t]&&(e[t]=i[t])}),e.showValues=i.showValues}}}this.apply()}get activeEditor(){return wijmo_1.Control.getControl(this._divEdt)}editColumnFilter(t,e,i){this.closeEditor(),t=this._asColumn(t);let l=this._g,s=new wijmo_grid_1.CellRangeEventArgs(l.cells,new wijmo_grid_1.CellRange(-1,t.index));if(!this.onFilterChanging(s))return void(this._divEdt=this._edtCol=null);s.cancel=!0;let a=wijmo_1.createElement('<div class="wj-dropdown-panel"></div>'),r=this.getColumnFilter(t),n=new ColumnFilterEditor(a,r,this.showSortButtons);this._divEdt=a,this._edtCol=t,l.rightToLeft&&(a.dir="rtl"),n.filterChanged.addHandler(()=>{s.cancel=!1,setTimeout(()=>{s.cancel||this.apply()})}),n.buttonClicked.addHandler(()=>{this.closeEditor(),l.focus(),this.onFilterChanged(s)}),n.lostFocus.addHandler(()=>{setTimeout(()=>{let t=wijmo_1.Control.getControl(this._divEdt);t&&!t.containsFocus()&&this.closeEditor()},10)});let o=e?e.col:t.index;e||l.columns[o].binding==t.binding||(o=l.selection.leftCol),l._edtHdl._commitRowEdits(),l.scrollIntoView(-1,o,!0);let d=l.columnHeaders,h=e&&e.panel==d?e.row:d.rows.length-1,u=o,_=d.getCellBoundingRect(h,u),c=i||d.getCellElement(h,u);c?wijmo_1.showPopup(a,c,!1,!1,!1):wijmo_1.showPopup(a,_),this._setAriaExpanded(c,!0),this._setAriaExpanded(l.cells.getCellElement(-1,u),!0);let p=n.hostElement.querySelectorAll("input");for(let t=0;t<p.length;t++){let e=p[t];if(e.offsetHeight>0&&e.tabIndex>-1&&!e.disabled){e.focus();break}}n.containsFocus()||n.focus()}_setAriaExpanded(t,e){if(t){var i=t.querySelector("."+FlexGridFilter._WJC_FILTER);wijmo_1.setAttribute(i,"aria-expanded",e)}}closeEditor(){let t=this._g,e=wijmo_1.Control.getControl(this._divEdt),i=this._edtCol;if(e&&wijmo_1.hidePopup(e.hostElement,()=>{e.dispose()}),i){let e=t.columnHeaders,l=e.rows.length?e.getCellElement(e.rows.length-1,i.index):null;this._setAriaExpanded(l,!1),l=t.cells.getCellElement(-1,i.index),this._setAriaExpanded(l,!1)}this._divEdt=null,this._edtCol=null}apply(){let t=this._g.collectionView;if(t){let e=this._g.editableCollectionView;e&&(e.commitEdit(),e.commitNew()),t.filter=this._filter.bind(this)}let e=t?t.updateFilterDefinition:null;wijmo_1.isFunction(e)&&e.call(t,this),this.onFilterApplied()}clear(){this._filters.length&&(this._filters=[],this.apply())}onFilterApplied(t){this.filterApplied.raise(this,t)}onFilterChanging(t){return this.filterChanging.raise(this,t),!t.cancel}onFilterChanged(t){this.filterChanged.raise(this,t)}_asColumn(t){return wijmo_1.isString(t)?this._g.getColumn(t):wijmo_1.isNumber(t)?this._g.columns[t]:wijmo_1.asType(t,wijmo_grid_1.Column,!1)}_filter(t){for(let e=0;e<this._filters.length;e++)if(!this._filters[e].apply(t))return!1;return!0}_formatItem(t,e){if(e.panel==t.columnHeaders){let t=this._g,i=t.getMergedRange(e.panel,e.row,e.col)||new wijmo_grid_1.CellRange(e.row,e.col),l=t.columns[i.col],s=t._getBindingColumn(e.panel,e.row,l),a=e.cell;if(i.row2==e.panel.rows.length-1||l!=s){let i=this.getColumnFilter(s,this.defaultFilterType!=FilterType.None);this._filterColumns&&this._filterColumns.indexOf(s.binding)<0&&(i=null),i?(wijmo_1.toggleClass(a,"wj-filter-on",i.isActive),wijmo_1.toggleClass(a,"wj-filter-off",!i.isActive)):(wijmo_1.removeClass(a,"wj-filter-on"),wijmo_1.removeClass(a,"wj-filter-off")),i&&i.filterType!=FilterType.None&&(this._showIcons&&this._addFilterButton(s,i,a),0==e.row&&(a=t.cells.getCellElement(-1,e.col))&&this._addFilterButton(l,i,a))}}}_addFilterButton(t,e,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+" "+t.header),wijmo_1.setAttribute(s,"aria-haspopup","dialog"),wijmo_1.setAttribute(s,"aria-expanded",!1),wijmo_1.setAttribute(s,"aria-describedby",t.describedById),wijmo_1.setAttribute(s,"aria-pressed",e.isActive),i.querySelector("."+l)||(1==i.children.length&&(i=i.querySelector("div")||i),i.appendChild(s))}_mousedown(t){this._toggleEditor(t)&&(this._tmd=!0,t.stopPropagation(),t.preventDefault())}_click(t){(this._tmd||this._toggleEditor(t))&&(t.stopPropagation(),t.preventDefault()),this._tmd=!1}_toggleEditor(t){if(this._tmd=!1,!t.defaultPrevented&&0==t.button)if(wijmo_1.closestClass(t.target,FlexGridFilter._WJC_FILTER)){let e=this._g,i=e.hitTest(t.target);if(i.panel||(i=e.hitTest(t)),i.panel==e.columnHeaders||i.panel==e.cells&&-1==i.row){let t=e.columns[i.col],l=e._getBindingColumn(i.panel,i.row,t);return this._divEdt&&this._edtCol==l?(this.closeEditor(),e.focus()):setTimeout(()=>{this.editColumnFilter(l,i)},this._divEdt?100:0),!0}}else this.closeEditor();return!1}_keydown(t){if(!t.defaultPrevented&&!t.ctrlKey&&t.altKey&&(t.keyCode==wijmo_1.Key.Down||t.keyCode==wijmo_1.Key.Up)){let e=this.grid,i=e.selection,l=i.col>-1?e.columns[i.col]:null,s=l?e._getBindingColumn(e.cells,i.row,l):null;s&&!s.dataMap&&this.getColumnFilter(s,!0)&&(this.editColumnFilter(s),t.preventDefault(),t.stopPropagation())}}}FlexGridFilter._WJC_FILTER="wj-elem-filter",exports.FlexGridFilter=FlexGridFilter,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(t,e,i=!0){super(t,null,!0),this.filterChanged=new wijmo_1.Event,this.buttonClicked=new wijmo_1.Event,this._filter=wijmo_1.asType(e,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==(e.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;this._showFilter(d),i&&o&&o.canSort||(this._divSort.style.display="none");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),r.addEventListener("keydown",t=>{if(!t.defaultPrevented){let e=t.target.tagName.match(/^(a|button)$/i);switch(t.keyCode){case wijmo_1.Key.Space:e&&(this._btnClicked(t),t.preventDefault());break;case wijmo_1.Key.Enter:e?this._btnClicked(t):(this.updateFilter(),this.onFilterChanged(),this.onButtonClicked()),t.preventDefault();break;case wijmo_1.Key.Escape:this.onButtonClicked(),t.preventDefault();break;case wijmo_1.Key.Tab:wijmo_1.moveFocus(this.hostElement,t.shiftKey?-1:1),t.preventDefault()}}})}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(t){this.filterChanged.raise(this,t)}onButtonClicked(t){this.buttonClicked.raise(this,t)}_handleResize(){this.isTouching||this._wasTouching||this.onButtonClicked()}_showFilter(t){this._wasTouching=this.isTouching,t==FilterType.Value&&null==this._edtVal&&(this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter)),t==FilterType.Condition&&null==this._edtCnd&&(this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter)),0!=(t&this.filter.filterType)&&(t==FilterType.Value?(this._divEdtVal.style.display="",this._divEdtCnd.style.display="none",this._enableLink(this._aVal,!1),this._enableLink(this._aCnd,!0),this._edtVal.focus()):(this._divEdtVal.style.display="none",this._divEdtCnd.style.display="",this._enableLink(this._aVal,!0),this._enableLink(this._aCnd,!1),this._edtCnd.focus()));let e=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:e.display="none";break;default:e.display=""}}_enableLink(t,e){wijmo_1.toggleClass(t,"wj-state-disabled",!e),wijmo_1.setAttribute(t,"href",e?"":null),wijmo_1.setAttribute(t,"disabled",e?null:"disabled")}_getFilterType(){let t=FilterType;return"none"!=this._divEdtVal.style.display?t.Value:t.Condition}_btnClicked(t){let e=t.target;if(t.preventDefault(),t.stopPropagation(),!wijmo_1.hasClass(e,"wj-state-disabled")){if(e==this._aVal)return this._showFilter(FilterType.Value),void wijmo_1.moveFocus(this._edtVal.hostElement,0);if(e==this._aCnd)return this._showFilter(FilterType.Condition),void wijmo_1.moveFocus(this._edtCnd.hostElement,0);if(e==this._btnAsc||e==this._btnDsc){let e=this.filter.column,i=e.sortMemberPath?e.sortMemberPath:e.binding,l=e.grid.collectionView,s=new wijmo_1.SortDescription(i,t.target==this._btnAsc);l.sortDescriptions.deferUpdate(()=>{l.sortDescriptions.clear(),l.sortDescriptions.push(s)})}e==this._btnApply?(this.updateFilter(),this.onFilterChanged()):e==this._btnClear?this.filter.isActive&&(this.filter.clear(),this.onFilterChanged()):this.updateEditor(),this.onButtonClicked()}}}ColumnFilterEditor.controlTemplate='<div><div wj-part="div-sort"><button wj-part="btn-asc" class="wj-btn" style="min-width:95px"></button> <button wj-part="btn-dsc" class="wj-btn" style="min-width:95px"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a> | <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> <button wj-part="btn-cancel" class="wj-btn"></button> <button wj-part="btn-clear" class="wj-btn"></button></div>',exports.ColumnFilterEditor=ColumnFilterEditor,wijmo_1._registerModule("wijmo.grid.filter",selfModule); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_grid_1=require("@grapecity/wijmo.grid"),wijmo_1=require("@grapecity/wijmo"),input=require("@grapecity/wijmo.input"),selfModule=require("@grapecity/wijmo.grid.filter");class FilterCondition{constructor(t){this._op=null,this._filter=t}get operator(){return this._op}set operator(t){this._op=wijmo_1.asEnum(t,Operator,!0)}get value(){return this._val}set value(t){if(this._val=t,this._strVal=wijmo_1.isString(t)?t.toString().toLowerCase():null,this._mapVal=null,this._filter){let e=this._filter.dataMap||this._filter.column.dataMap;e&&(this._mapVal=e.getDisplayValue(t),wijmo_1.isString(this._mapVal)&&(this._strVal=this._mapVal=this._mapVal.toLowerCase()))}}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(t,e,i){let l=this._mapVal||this._strVal||this._val;wijmo_1.isString(t)&&(t=t.toLowerCase()),wijmo_1.isString(l)&&null==t&&(t=""),wijmo_1.isDate(l)&&(e?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!=t&&null!=l?t.valueOf()==l.valueOf():t==l;case s.NE:return null!=t&&null!=l?t.valueOf()!=l.valueOf():t!=l;case s.GT:return t>l;case s.GE:return t>=l;case s.LT:return t<l;case s.LE:return t<=l;case s.BW:return!(null==this._strVal||!wijmo_1.isString(t))&&0==t.indexOf(this._strVal);case s.EW:return!!(null!=this._strVal&&wijmo_1.isString(t)&&t.length>=this._strVal.length)&&t.substr(t.length-this._strVal.length)==l;case s.CT:return!(null==this._strVal||!wijmo_1.isString(t))&&t.indexOf(this._strVal)>-1;case s.NC:return!(null==this._strVal||!wijmo_1.isString(t))&&t.indexOf(this._strVal)<0}throw"Unknown operator"}}var Operator,FilterType;FilterCondition._refDateTime=new Date(2e3,0,1,0,0,0),exports.FilterCondition=FilterCondition,function(t){t[t.EQ=0]="EQ",t[t.NE=1]="NE",t[t.GT=2]="GT",t[t.GE=3]="GE",t[t.LT=4]="LT",t[t.LE=5]="LE",t[t.BW=6]="BW",t[t.EW=7]="EW",t[t.CT=8]="CT",t[t.NC=9]="NC"}(Operator=exports.Operator||(exports.Operator={}));class ConditionFilter{constructor(t){this._c1=new FilterCondition(this),this._c2=new FilterCondition(this),this._and=!0,this._col=t}get condition1(){return this._c1}get condition2(){return this._c2}get and(){return this._and}set and(t){this._and=wijmo_1.asBoolean(t)}get dataMap(){return this._map}set dataMap(t){this._map=wijmo_1.asType(t,wijmo_grid_1.DataMap,!0)}get column(){return this._col}get isActive(){return this._c1.isActive||this._c2.isActive}apply(t){let e=this._col,i=this._c1,l=this._c2,s=!1,a=!1;if(!e||!e._binding||!this.isActive)return!0;if(t=e._binding.getValue(t),this.dataMap)t=this.dataMap.getDisplayValue(t);else if(e.dataMap)t=e.dataMap.getDisplayValue(t);else if(wijmo_1.isDate(t))if(s=!this._hasTimePart(),a=!this._hasDatePart(),wijmo_1.assert(!s||!a,"Filter should have either date or time."),s){Date();t=wijmo_1.DateTime.fromDateTime(t,FilterCondition._refDateTime)}else a&&(t=wijmo_1.DateTime.fromDateTime(FilterCondition._refDateTime,t));else wijmo_1.isNumber(t)&&(t=wijmo_1.Globalize.parseFloat(wijmo_1.Globalize.format(t,e.format)));let r=i.apply(t,s,a),n=l.apply(t,s,a);return i.isActive&&l.isActive?this._and?r&&n:r||n:i.isActive?r:!l.isActive||n}clear(){this._c1.clear(),this._c2.clear(),this.and=!0}_hasDatePart(){let t=this._col.format;return!t||(t=wijmo_1.culture.Globalize.calendar.patterns[t]||t,/[yMd]+/.test(t))}_hasTimePart(){let t=this._col.format;return!!t&&(t=wijmo_1.culture.Globalize.calendar.patterns[t]||t,/[Hmst]+/.test(t))}implementsInterface(t){return"IColumnFilter"==t}}exports.ConditionFilter=ConditionFilter;class ConditionFilterEditor extends wijmo_1.Control{constructor(t,e){super(t),this._filter=wijmo_1.asType(e,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),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((t,e)=>{this._val1.isDisabled=null==t.selectedValue}),this._val2.isDisabled=!0,this._cmb2.selectedIndexChanged.addHandler((t,e)=>{this._val2.isDisabled=null==t.selectedValue});let a=this.hostElement;this.addEventListener(a,"change",this._btnAndOrChanged.bind(this)),this.addEventListener(a,"keydown",this._keydown.bind(this)),this.updateEditor()}get filter(){return this._filter}updateEditor(){let t=this._filter.condition1,e=this._filter.condition2;this._cmb1.selectedValue=t.operator,this._cmb2.selectedValue=e.operator,this._val1 instanceof input.ComboBox&&!(this._val1 instanceof input.InputTime)?(this._val1.text=wijmo_1.changeType(t.value,wijmo_1.DataType.String),this._val2.text=wijmo_1.changeType(e.value,wijmo_1.DataType.String)):(this._val1.value=t.value,this._val2.value=e.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 t=this._filter.condition1,e=this._filter.condition2;t.operator=this._cmb1.selectedValue,e.operator=this._cmb2.selectedValue,"value"in this._val1?(t.value=this._val1.value,e.value=this._val2.value):(t.value=this._val1.selectedValue,e.value=this._val2.selectedValue),this._filter.and=this._btnAnd.checked}_createOperatorCombo(t,e){let i=this._filter.column,l=wijmo_1.culture.FlexGridFilter,s=l.stringOperators,a=this._filter.dataMap||i.dataMap,r=wijmo_1.DataType;i.dataType==r.Date?s=l.dateOperators:i.dataType!=r.Number||a?i.dataType!=r.Boolean||a||(s=l.booleanOperators):s=l.numberOperators;let n=new input.ComboBox(t,{itemsSource:s,displayMemberPath:"name",selectedValuePath:"op"});return wijmo_1.setAriaLabel(n.inputElement,e),n}_createValueInput(t,e){let i=this._filter,l=i.column,s=i.dataMap||l.dataMap,a=null,r=wijmo_1.DataType;return l.dataType==r.Date?(a=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(t):new input.InputDate(t):new input.InputTime(t)).format=l.format:l.dataType!=r.Number||s?(a=new input.ComboBox(t),s?(a.itemsSource=s.getDisplayValues(),a.isEditable=!0):l.dataType==r.Boolean&&(a.itemsSource=[!0,!1])):(a=new input.InputNumber(t)).format=l.format,a.isRequired=!1,wijmo_1.setAriaLabel(a.inputElement,e),a}_btnAndOrChanged(t){let e=t.target==this._btnAnd,i=t.target==this._btnOr;(e||i)&&(this._checkRadio(this._btnAnd,e),this._checkRadio(this._btnOr,i))}_checkRadio(t,e){t.checked=e,t.setAttribute("aria-checked",e.toString()),t.setAttribute("tabindex",e?"1":"-1")}_keydown(t){let e=t.target==this._btnAnd,i=t.target==this._btnOr;if(e||i)switch(t.keyCode){case wijmo_1.Key.Left:case wijmo_1.Key.Right:case wijmo_1.Key.Up:case wijmo_1.Key.Down:let i=e?this._btnOr:this._btnAnd;i.click(),i.focus(),t.preventDefault()}}}ConditionFilterEditor.controlTemplate='<div><div wj-part="div-hdr"></div><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> <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 ValueFilter{constructor(t){this._xValueSearch=!0,this._maxValues=250,this._sortValues=!0,this._col=t}get showValues(){return this._values}set showValues(t){this._values=t}get filterText(){return this._filterText}set filterText(t){this._filterText=wijmo_1.asString(t)}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(t){this._xValueSearch=wijmo_1.asBoolean(t)}get maxValues(){return this._maxValues}set maxValues(t){this._maxValues=wijmo_1.asNumber(t,!1,!0)}get uniqueValues(){return this._uniqueValues}set uniqueValues(t){this._uniqueValues=wijmo_1.asArray(t)}get sortValues(){return this._sortValues}set sortValues(t){this._sortValues=wijmo_1.asBoolean(t)}get dataMap(){return this._map}set dataMap(t){this._map=wijmo_1.asType(t,wijmo_grid_1.DataMap,!0)}get column(){return this._col}get isActive(){return null!=this._values&&Object.keys(this._values).length>0}apply(t){let e=this.column;return!(e&&e._binding&&this._values&&Object.keys(this._values).length)||(t=e._binding.getValue(t),t=this.dataMap?this.dataMap.getDisplayValue(t):e.dataMap?e.dataMap.getDisplayValue(t):wijmo_1.Globalize.format(t,e.format),void 0!=this._values[t])}clear(){this.showValues=null,this.filterText=null}implementsInterface(t){return"IColumnFilter"==t}_getUniqueValues(t,e){let i=[];if(this.uniqueValues){let t=this.uniqueValues;for(let e=0;e<t.length;e++){let l=t[e];i.push({value:l,text:l.toString()})}return i}let l={},s=t.collectionView,a=s?s.sourceCollection:[];if(e&&s&&s.sourceCollection&&s.filter){let t=this.showValues;this.showValues=null;let e=[];for(let t=0;t<a.length;t++)s.filter(a[t])&&e.push(a[t]);a=e,this.showValues=t}for(let e=0;e<a.length;e++){let s=t._binding.getValue(a[e]),r=this.dataMap?this.dataMap.getDisplayValue(s):t.dataMap?t.dataMap.getDisplayValue(s):wijmo_1.Globalize.format(s,t.format);l[r]||(l[r]=!0,i.push({value:s,text:r}))}return i}}exports.ValueFilter=ValueFilter;class ValueFilterEditor extends wijmo_1.Control{constructor(t,e){super(t),this._filter=wijmo_1.asType(e,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;if(s.sortNullsFirst=!0,e.sortValues){let t=e.column.dataMap||e.dataMap?"text":"value",i=e.column.dataType!=wijmo_1.DataType.Boolean;s.sortDescriptions.push(new wijmo_1.SortDescription(t,i))}s.filter=this._filterValues.bind(this),s.collectionChanged.addHandler(this._updateSelectAllCheck,this),this._filterText="",this._cmbFilter=new input.ComboBox(this._divFilter,{placeholder:l.search}),this._lbValues=new input.ListBox(this._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:this._view,itemFormatter:(t,e)=>e||l.null}),wijmo_1.setAriaLabel(this._cmbFilter.inputElement,l.ariaLabels.search),this._cmbFilter.textChanged.addHandler(this._filterTextChanged,this),this._cbSelectAll.addEventListener("click",this._cbSelectAllClicked.bind(this)),this.updateEditor()}get filter(){return this._filter}updateEditor(){let t=this._filter.column,e=this._filter._getUniqueValues(t,!0);this._lbValues.isContentHtml=t.isContentHtml;let i=this._filter.showValues;if(i&&0!=Object.keys(i).length){for(let t in i)for(let i=0;i<e.length;i++)if(e[i].text==t){e[i].show=!0;break}}else for(let t=0;t<e.length;t++)e[t].show=!0;this._view.pageSize=20,this._view.sourceCollection=e,setTimeout(()=>{this._view.pageSize=this._filter.maxValues,this._cmbFilter.text=this._filter.filterText||"",this._filterText=this._cmbFilter.text.toLowerCase()})}clearEditor(t=!0){this._cmbFilter.text="",this._filterText="",this._view.pageSize=0,this._view.refresh(),this._view.items.forEach(e=>{e.show=t}),this._view.pageSize=this._filter.maxValues}get isEditorClear(){return!this._filterText&&!this._cbSelectAll.indeterminate}updateFilter(){let t=null,e=this._getItems();if(this._filterText||this._cbSelectAll.indeterminate){t={};for(let i=0;i<e.length;i++){let l=e[i];l.show&&(t[l.text]=!0)}}let i=this._filter;i.showValues=t,i.filterText=""}_getItems(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection}_filterTextChanged(){this._toText&&clearTimeout(this._toText),this._toText=setTimeout(()=>{let t=this._cmbFilter.text.toLowerCase(),e=t!=this._filterText;this._filterText=t,this._view.refresh(),e&&(this._filter.exclusiveValueSearch?(this._cbSelectAll.checked=!0,this._cbSelectAllClicked()):this._updateSelectAllCheck())},300)}_filterValues(t){return!this._filterText||!(!t||!t.text)&&t.text.toLowerCase().indexOf(this._filterText)>-1}_cbSelectAllClicked(){let t=this._cbSelectAll.checked,e=this._divValues.scrollTop,i=this._getItems();for(let e=0;e<i.length;e++)i[e].show=t;this._view.refresh(),this._divValues.scrollTop=e}_updateSelectAllCheck(){let t=0,e=this._getItems();for(let i=0;i<e.length;i++)e[i].show&&t++;let i=this._cbSelectAll;0==t?(i.checked=!1,i.indeterminate=!1):t==e.length?(i.checked=!0,i.indeterminate=!1):i.indeterminate=!0}}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(t,e){this._owner=t,this._col=e,this._valueFilter=new ValueFilter(e),this._valueFilter.exclusiveValueSearch=t.exclusiveValueSearch,this._conditionFilter=new ConditionFilter(e)}get filterType(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType}set filterType(t){if((t=wijmo_1.asEnum(t,FilterType,!0))!=this._filterType){let e=this.isActive;this.clear(),this._filterType=t,e?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}}get dataMap(){return this.conditionFilter.dataMap||this.valueFilter.dataMap}set dataMap(t){this.conditionFilter.dataMap=t,this.valueFilter.dataMap=t}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(t){return this._conditionFilter.apply(t)&&this._valueFilter.apply(t)}clear(){this._valueFilter.clear(),this._conditionFilter.clear()}implementsInterface(t){return"IColumnFilter"==t}}exports.ColumnFilter=ColumnFilter,function(t){t[t.None=0]="None",t[t.Condition=1]="Condition",t[t.Value=2]="Value",t[t.Both=3]="Both"}(FilterType=exports.FilterType||(exports.FilterType={}));class FlexGridFilter{constructor(t,e){this._showIcons=!0,this._showSort=!0,this._defFilterType=FilterType.Both,this._xValueSearch=!0,this.filterApplied=new wijmo_1.Event,this.filterChanging=new wijmo_1.Event,this.filterChanged=new wijmo_1.Event,this._filters=[],this._g=wijmo_1.asType(t,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;t.addEventListener(i,"mousedown",this._mousedown.bind(this),!0),t.addEventListener(i,"click",this._click.bind(this),!0),t.addEventListener(i,"keydown",this._keydown.bind(this),!0),this._g.invalidate(),e&&wijmo_1.copy(this,e)}get grid(){return this._g}get filterColumns(){return this._filterColumns}set filterColumns(t){this._filterColumns=wijmo_1.asArray(t),this.clear()}get showFilterIcons(){return this._showIcons}set showFilterIcons(t){t!=this.showFilterIcons&&(this._showIcons=wijmo_1.asBoolean(t),this._g&&this._g.invalidate())}get showSortButtons(){return this._showSort}set showSortButtons(t){this._showSort=wijmo_1.asBoolean(t)}getColumnFilter(t,e=!0){t=this._asColumn(t);for(let e=0;e<this._filters.length;e++)if(this._filters[e].column==t)return this._filters[e];if(e&&t.binding){let e=new ColumnFilter(this,t);return this._filters.push(e),e}return null}get defaultFilterType(){return this._defFilterType}set defaultFilterType(t){(t=wijmo_1.asEnum(t,FilterType,!1))!=this.defaultFilterType&&(this._defFilterType=t,this._g.invalidate(),this.clear())}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(t){this._xValueSearch=wijmo_1.asBoolean(t)}get filterDefinition(){let t={defaultFilterType:this.defaultFilterType,filters:[]};return this._filters.forEach(e=>{let i=e.conditionFilter,l=e.valueFilter,s=l.uniqueValues&&l.uniqueValues.length;if(e&&e.column&&e.column.binding&&(e.isActive||s||e.filterType!=this.defaultFilterType)){let a={binding:e.column.binding};if(i.isActive){let t=i.condition1,l=i.condition2;a={binding:e.column.binding,type:"condition",condition1:{operator:t.operator,value:t.value},and:i.and,condition2:{operator:l.operator,value:l.value}}}else(l.isActive||s)&&(a={binding:e.column.binding,type:"value",uniqueValues:l.uniqueValues,sortValues:l.sortValues,maxValues:l.maxValues,exclusiveValueSearch:l.exclusiveValueSearch,showValues:l.showValues});e.filterType!=this.defaultFilterType&&(a.filterType=e.filterType),t.filters.push(a)}}),JSON.stringify(t)}set filterDefinition(t){if(t=wijmo_1.asString(t),this.clear(),t){let e=JSON.parse(t);this.defaultFilterType=e.defaultFilterType;for(let t=0;t<e.filters.length;t++){let i=e.filters[t],l=this._g.getColumn(i.binding),s=this.getColumnFilter(l,!0);if(s)switch(null!=i.filterType&&(s.filterType=wijmo_1.asEnum(i.filterType,FilterType)),i.type){case"condition":let t=s.conditionFilter;t.condition1.value=l.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(i.condition1.value,l.dataType,null):i.condition1.value,t.condition1.operator=i.condition1.operator,t.and=i.and,t.condition2.value=l.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(i.condition2.value,l.dataType,null):i.condition2.value,t.condition2.operator=i.condition2.operator;break;case"value":let e=s.valueFilter;e.uniqueValues=i.uniqueValues,["sortValues","maxValues","exclusiveValueSearch"].forEach(t=>{null!=i[t]&&(e[t]=i[t])}),e.showValues=i.showValues}}}this.apply()}get activeEditor(){return wijmo_1.Control.getControl(this._divEdt)}editColumnFilter(t,e,i){this.closeEditor(),t=this._asColumn(t);let l=this._g,s=new wijmo_grid_1.CellRangeEventArgs(l.cells,new wijmo_grid_1.CellRange(-1,t.index));if(!this.onFilterChanging(s))return void(this._divEdt=this._edtCol=null);s.cancel=!0;let a=wijmo_1.createElement('<div class="wj-dropdown-panel"></div>'),r=this.getColumnFilter(t),n=new ColumnFilterEditor(a,r,this.showSortButtons);this._divEdt=a,this._edtCol=t,l.rightToLeft&&(a.dir="rtl"),n.filterChanged.addHandler(()=>{s.cancel=!1,setTimeout(()=>{s.cancel||this.apply()})}),n.buttonClicked.addHandler(()=>{this.closeEditor(),l.focus(),this.onFilterChanged(s)}),n.lostFocus.addHandler(()=>{setTimeout(()=>{let t=wijmo_1.Control.getControl(this._divEdt);t&&!t.containsFocus()&&this.closeEditor()},10)});let o=e?e.col:t.index;e||l.columns[o].binding==t.binding||(o=l.selection.leftCol),l._edtHdl._commitRowEdits(),l.scrollIntoView(-1,o,!0);let d=l.columnHeaders,h=e&&e.panel==d?e.row:d.rows.length-1,u=o,_=d.getCellBoundingRect(h,u),c=i||d.getCellElement(h,u);c?wijmo_1.showPopup(a,c,!1,!1,!1):wijmo_1.showPopup(a,_),this._setAriaExpanded(c,!0),this._setAriaExpanded(l.cells.getCellElement(-1,u),!0);let p=n.hostElement.querySelectorAll("input");for(let t=0;t<p.length;t++){let e=p[t];if(e.offsetHeight>0&&e.tabIndex>-1&&!e.disabled){e.focus();break}}n.containsFocus()||n.focus()}_setAriaExpanded(t,e){if(t){var i=t.querySelector("."+FlexGridFilter._WJC_FILTER);wijmo_1.setAttribute(i,"aria-expanded",e)}}closeEditor(){let t=this._g,e=wijmo_1.Control.getControl(this._divEdt),i=this._edtCol;if(e&&wijmo_1.hidePopup(e.hostElement,()=>{e.dispose()}),i){let e=t.columnHeaders,l=e.rows.length?e.getCellElement(e.rows.length-1,i.index):null;this._setAriaExpanded(l,!1),l=t.cells.getCellElement(-1,i.index),this._setAriaExpanded(l,!1)}this._divEdt=null,this._edtCol=null}apply(){let t=this._g.collectionView;if(t){let e=this._g.editableCollectionView;e&&(e.commitEdit(),e.commitNew()),t.filter=this._filter.bind(this)}let e=t?t.updateFilterDefinition:null;wijmo_1.isFunction(e)&&e.call(t,this),this.onFilterApplied()}clear(){this._filters.length&&(this._filters=[],this.apply())}onFilterApplied(t){this.filterApplied.raise(this,t)}onFilterChanging(t){return this.filterChanging.raise(this,t),!t.cancel}onFilterChanged(t){this.filterChanged.raise(this,t)}_asColumn(t){return wijmo_1.isString(t)?this._g.getColumn(t):wijmo_1.isNumber(t)?this._g.columns[t]:wijmo_1.asType(t,wijmo_grid_1.Column,!1)}_filter(t){for(let e=0;e<this._filters.length;e++)if(!this._filters[e].apply(t))return!1;return!0}_formatItem(t,e){if(e.panel==t.columnHeaders){let t=this._g,i=t.getMergedRange(e.panel,e.row,e.col)||new wijmo_grid_1.CellRange(e.row,e.col),l=t.columns[i.col],s=t._getBindingColumn(e.panel,e.row,l),a=e.cell;if(i.row2==e.panel.rows.length-1||l!=s){let i=this.getColumnFilter(s,this.defaultFilterType!=FilterType.None);this._filterColumns&&this._filterColumns.indexOf(s.binding)<0&&(i=null),i?(wijmo_1.toggleClass(a,"wj-filter-on",i.isActive),wijmo_1.toggleClass(a,"wj-filter-off",!i.isActive)):(wijmo_1.removeClass(a,"wj-filter-on"),wijmo_1.removeClass(a,"wj-filter-off")),i&&i.filterType!=FilterType.None&&(this._showIcons&&this._addFilterButton(s,i,a),0==e.row&&(a=t.cells.getCellElement(-1,e.col))&&this._addFilterButton(l,i,a))}}}_addFilterButton(t,e,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+" "+t.header),wijmo_1.setAttribute(s,"aria-haspopup","dialog"),wijmo_1.setAttribute(s,"aria-expanded",!1),wijmo_1.setAttribute(s,"aria-describedby",t.describedById),wijmo_1.setAttribute(s,"aria-pressed",e.isActive),i.querySelector("."+l)||(1==i.children.length&&(i=i.querySelector("div")||i),i.appendChild(s))}_mousedown(t){this._toggleEditor(t)&&(this._tmd=!0,t.stopPropagation(),t.preventDefault())}_click(t){(this._tmd||this._toggleEditor(t))&&(t.stopPropagation(),t.preventDefault()),this._tmd=!1}_toggleEditor(t){if(this._tmd=!1,!t.defaultPrevented&&0==t.button)if(wijmo_1.closestClass(t.target,FlexGridFilter._WJC_FILTER)){let e=this._g,i=e.hitTest(t.target);if(i.panel||(i=e.hitTest(t)),i.panel==e.columnHeaders||i.panel==e.cells&&-1==i.row){let t=e.columns[i.col],l=e._getBindingColumn(i.panel,i.row,t);return this._divEdt&&this._edtCol==l?(this.closeEditor(),e.focus()):setTimeout(()=>{this.editColumnFilter(l,i)},this._divEdt?100:0),!0}}else this.closeEditor();return!1}_keydown(t){if(!t.defaultPrevented&&!t.ctrlKey&&t.altKey&&(t.keyCode==wijmo_1.Key.Down||t.keyCode==wijmo_1.Key.Up)){let e=this.grid,i=e.selection,l=i.col>-1?e.columns[i.col]:null,s=l?e._getBindingColumn(e.cells,i.row,l):null;s&&!s.dataMap&&this.getColumnFilter(s,!0)&&(this.editColumnFilter(s),t.preventDefault(),t.stopPropagation())}}}FlexGridFilter._WJC_FILTER="wj-elem-filter",exports.FlexGridFilter=FlexGridFilter,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(t,e,i=!0){super(t,null,!0),this.filterChanged=new wijmo_1.Event,this.buttonClicked=new wijmo_1.Event,this._filter=wijmo_1.asType(e,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==(e.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;this._showFilter(d),i&&o&&o.canSort||(this._divSort.style.display="none");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",t=>{if(!t.defaultPrevented){let e=t.target.tagName.match(/^(a|button)$/i);switch(t.keyCode){case wijmo_1.Key.Space:e&&(this._btnClicked(t),t.preventDefault());break;case wijmo_1.Key.Enter:e?this._btnClicked(t):(this.updateFilter(),this.onFilterChanged(),this.onButtonClicked()),t.preventDefault();break;case wijmo_1.Key.Escape:this.onButtonClicked(),t.preventDefault();break;case wijmo_1.Key.Tab:wijmo_1.moveFocus(this.hostElement,t.shiftKey?-1:1),t.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(t){this.filterChanged.raise(this,t)}onButtonClicked(t){this.buttonClicked.raise(this,t)}_showFilter(t){this._wasTouching=this.isTouching,t==FilterType.Value&&null==this._edtVal&&(this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter)),t==FilterType.Condition&&null==this._edtCnd&&(this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter)),0!=(t&this.filter.filterType)&&(t==FilterType.Value?(this._divEdtVal.style.display="",this._divEdtCnd.style.display="none",this._enableLink(this._aVal,!1),this._enableLink(this._aCnd,!0),this._edtVal.focus()):(this._divEdtVal.style.display="none",this._divEdtCnd.style.display="",this._enableLink(this._aVal,!0),this._enableLink(this._aCnd,!1),this._edtCnd.focus()));let e=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:e.display="none";break;default:e.display=""}}_enableLink(t,e){wijmo_1.toggleClass(t,"wj-state-disabled",!e),wijmo_1.setAttribute(t,"href",e?"":null),wijmo_1.setAttribute(t,"disabled",e?null:"disabled")}_getFilterType(){let t=FilterType;return"none"!=this._divEdtVal.style.display?t.Value:t.Condition}_btnClicked(t){let e=t.target;if(t.preventDefault(),t.stopPropagation(),!wijmo_1.hasClass(e,"wj-state-disabled")){if(e==this._aVal)return this._showFilter(FilterType.Value),void wijmo_1.moveFocus(this._edtVal.hostElement,0);if(e==this._aCnd)return this._showFilter(FilterType.Condition),void wijmo_1.moveFocus(this._edtCnd.hostElement,0);if(e==this._btnAsc||e==this._btnDsc){let e=this.filter.column,i=e.sortMemberPath?e.sortMemberPath:e.binding,l=e.grid.collectionView,s=new wijmo_1.SortDescription(i,t.target==this._btnAsc);l.sortDescriptions.deferUpdate(()=>{l.sortDescriptions.clear(),l.sortDescriptions.push(s)})}e==this._btnApply?(this.updateFilter(),this.onFilterChanged()):e==this._btnClear?this.filter.isActive&&(this.filter.clear(),this.onFilterChanged()):this.updateEditor(),this.onButtonClicked()}}}ColumnFilterEditor.controlTemplate='<div><div wj-part="div-sort"><button wj-part="btn-asc" class="wj-btn" style="min-width:95px"></button> <button wj-part="btn-dsc" class="wj-btn" style="min-width:95px"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a> | <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> <button wj-part="btn-cancel" class="wj-btn"></button> <button wj-part="btn-clear" class="wj-btn"></button></div>',exports.ColumnFilterEditor=ColumnFilterEditor,wijmo_1._registerModule("wijmo.grid.filter",selfModule); |
/*! | ||
* | ||
* Wijmo Library 5.20191.599-nightly.d20190408.t120542 | ||
* Wijmo Library 5.20191.599-nightly.d20190408.t162215 | ||
* http://wijmo.com/ | ||
@@ -14,2 +14,2 @@ * | ||
import{Column,DataMap,FlexGrid,CellRange,CellRangeEventArgs}from"@grapecity/wijmo.grid";import{Globalize,asString,asNumber,asArray,asBoolean,asType,asEnum,isString,isDate,DateTime,culture,assert,isNumber,Control,Event,DataType,Key,copy,changeType,createElement,setAttribute,showPopup,hidePopup,isFunction,toggleClass,removeClass,closestClass,setAriaLabel,setText,CollectionView,SortDescription,_addCultureInfo,moveFocus,hasClass,_registerModule}from"@grapecity/wijmo";import*as input from"@grapecity/wijmo.input";import*as selfModule from"@grapecity/wijmo.grid.filter";export class FilterCondition{constructor(t){this._op=null,this._filter=t}get operator(){return this._op}set operator(t){this._op=asEnum(t,Operator,!0)}get value(){return this._val}set value(t){if(this._val=t,this._strVal=isString(t)?t.toString().toLowerCase():null,this._mapVal=null,this._filter){let e=this._filter.dataMap||this._filter.column.dataMap;e&&(this._mapVal=e.getDisplayValue(t),isString(this._mapVal)&&(this._strVal=this._mapVal=this._mapVal.toLowerCase()))}}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(t,e,i){let l=this._mapVal||this._strVal||this._val;isString(t)&&(t=t.toLowerCase()),isString(l)&&null==t&&(t=""),isDate(l)&&(e?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!=t&&null!=l?t.valueOf()==l.valueOf():t==l;case s.NE:return null!=t&&null!=l?t.valueOf()!=l.valueOf():t!=l;case s.GT:return t>l;case s.GE:return t>=l;case s.LT:return t<l;case s.LE:return t<=l;case s.BW:return!(null==this._strVal||!isString(t))&&0==t.indexOf(this._strVal);case s.EW:return!!(null!=this._strVal&&isString(t)&&t.length>=this._strVal.length)&&t.substr(t.length-this._strVal.length)==l;case s.CT:return!(null==this._strVal||!isString(t))&&t.indexOf(this._strVal)>-1;case s.NC:return!(null==this._strVal||!isString(t))&&t.indexOf(this._strVal)<0}throw"Unknown operator"}};FilterCondition._refDateTime=new Date(2e3,0,1,0,0,0);export var Operator;!function(t){t[t.EQ=0]="EQ",t[t.NE=1]="NE",t[t.GT=2]="GT",t[t.GE=3]="GE",t[t.LT=4]="LT",t[t.LE=5]="LE",t[t.BW=6]="BW",t[t.EW=7]="EW",t[t.CT=8]="CT",t[t.NC=9]="NC"}(Operator||(Operator={}));export class ConditionFilter{constructor(t){this._c1=new FilterCondition(this),this._c2=new FilterCondition(this),this._and=!0,this._col=t}get condition1(){return this._c1}get condition2(){return this._c2}get and(){return this._and}set and(t){this._and=asBoolean(t)}get dataMap(){return this._map}set dataMap(t){this._map=asType(t,DataMap,!0)}get column(){return this._col}get isActive(){return this._c1.isActive||this._c2.isActive}apply(t){let e=this._col,i=this._c1,l=this._c2,s=!1,a=!1;if(!e||!e._binding||!this.isActive)return!0;if(t=e._binding.getValue(t),this.dataMap)t=this.dataMap.getDisplayValue(t);else if(e.dataMap)t=e.dataMap.getDisplayValue(t);else if(isDate(t))if(s=!this._hasTimePart(),a=!this._hasDatePart(),assert(!s||!a,"Filter should have either date or time."),s){Date();t=DateTime.fromDateTime(t,FilterCondition._refDateTime)}else a&&(t=DateTime.fromDateTime(FilterCondition._refDateTime,t));else isNumber(t)&&(t=Globalize.parseFloat(Globalize.format(t,e.format)));let r=i.apply(t,s,a),n=l.apply(t,s,a);return i.isActive&&l.isActive?this._and?r&&n:r||n:i.isActive?r:!l.isActive||n}clear(){this._c1.clear(),this._c2.clear(),this.and=!0}_hasDatePart(){let t=this._col.format;return!t||(t=culture.Globalize.calendar.patterns[t]||t,/[yMd]+/.test(t))}_hasTimePart(){let t=this._col.format;return!!t&&(t=culture.Globalize.calendar.patterns[t]||t,/[Hmst]+/.test(t))}implementsInterface(t){return"IColumnFilter"==t}};export class ConditionFilterEditor extends Control{constructor(t,e){super(t),this._filter=asType(e,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),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((t,e)=>{this._val1.isDisabled=null==t.selectedValue}),this._val2.isDisabled=!0,this._cmb2.selectedIndexChanged.addHandler((t,e)=>{this._val2.isDisabled=null==t.selectedValue});let a=this.hostElement;this.addEventListener(a,"change",this._btnAndOrChanged.bind(this)),this.addEventListener(a,"keydown",this._keydown.bind(this)),this.updateEditor()}get filter(){return this._filter}updateEditor(){let t=this._filter.condition1,e=this._filter.condition2;this._cmb1.selectedValue=t.operator,this._cmb2.selectedValue=e.operator,this._val1 instanceof input.ComboBox&&!(this._val1 instanceof input.InputTime)?(this._val1.text=changeType(t.value,DataType.String),this._val2.text=changeType(e.value,DataType.String)):(this._val1.value=t.value,this._val2.value=e.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 t=this._filter.condition1,e=this._filter.condition2;t.operator=this._cmb1.selectedValue,e.operator=this._cmb2.selectedValue,"value"in this._val1?(t.value=this._val1.value,e.value=this._val2.value):(t.value=this._val1.selectedValue,e.value=this._val2.selectedValue),this._filter.and=this._btnAnd.checked}_createOperatorCombo(t,e){let i=this._filter.column,l=culture.FlexGridFilter,s=l.stringOperators,a=this._filter.dataMap||i.dataMap,r=DataType;i.dataType==r.Date?s=l.dateOperators:i.dataType!=r.Number||a?i.dataType!=r.Boolean||a||(s=l.booleanOperators):s=l.numberOperators;let n=new input.ComboBox(t,{itemsSource:s,displayMemberPath:"name",selectedValuePath:"op"});return setAriaLabel(n.inputElement,e),n}_createValueInput(t,e){let i=this._filter,l=i.column,s=i.dataMap||l.dataMap,a=null,r=DataType;return l.dataType==r.Date?(a=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(t):new input.InputDate(t):new input.InputTime(t)).format=l.format:l.dataType!=r.Number||s?(a=new input.ComboBox(t),s?(a.itemsSource=s.getDisplayValues(),a.isEditable=!0):l.dataType==r.Boolean&&(a.itemsSource=[!0,!1])):(a=new input.InputNumber(t)).format=l.format,a.isRequired=!1,setAriaLabel(a.inputElement,e),a}_btnAndOrChanged(t){let e=t.target==this._btnAnd,i=t.target==this._btnOr;(e||i)&&(this._checkRadio(this._btnAnd,e),this._checkRadio(this._btnOr,i))}_checkRadio(t,e){t.checked=e,t.setAttribute("aria-checked",e.toString()),t.setAttribute("tabindex",e?"1":"-1")}_keydown(t){let e=t.target==this._btnAnd,i=t.target==this._btnOr;if(e||i)switch(t.keyCode){case Key.Left:case Key.Right:case Key.Up:case Key.Down:let i=e?this._btnOr:this._btnAnd;i.click(),i.focus(),t.preventDefault()}}};ConditionFilterEditor.controlTemplate='<div><div wj-part="div-hdr"></div><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> <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 ValueFilter{constructor(t){this._xValueSearch=!0,this._maxValues=250,this._sortValues=!0,this._col=t}get showValues(){return this._values}set showValues(t){this._values=t}get filterText(){return this._filterText}set filterText(t){this._filterText=asString(t)}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(t){this._xValueSearch=asBoolean(t)}get maxValues(){return this._maxValues}set maxValues(t){this._maxValues=asNumber(t,!1,!0)}get uniqueValues(){return this._uniqueValues}set uniqueValues(t){this._uniqueValues=asArray(t)}get sortValues(){return this._sortValues}set sortValues(t){this._sortValues=asBoolean(t)}get dataMap(){return this._map}set dataMap(t){this._map=asType(t,DataMap,!0)}get column(){return this._col}get isActive(){return null!=this._values&&Object.keys(this._values).length>0}apply(t){let e=this.column;return!(e&&e._binding&&this._values&&Object.keys(this._values).length)||(t=e._binding.getValue(t),t=this.dataMap?this.dataMap.getDisplayValue(t):e.dataMap?e.dataMap.getDisplayValue(t):Globalize.format(t,e.format),void 0!=this._values[t])}clear(){this.showValues=null,this.filterText=null}implementsInterface(t){return"IColumnFilter"==t}_getUniqueValues(t,e){let i=[];if(this.uniqueValues){let t=this.uniqueValues;for(let e=0;e<t.length;e++){let l=t[e];i.push({value:l,text:l.toString()})}return i}let l={},s=t.collectionView,a=s?s.sourceCollection:[];if(e&&s&&s.sourceCollection&&s.filter){let t=this.showValues;this.showValues=null;let e=[];for(let t=0;t<a.length;t++)s.filter(a[t])&&e.push(a[t]);a=e,this.showValues=t}for(let e=0;e<a.length;e++){let s=t._binding.getValue(a[e]),r=this.dataMap?this.dataMap.getDisplayValue(s):t.dataMap?t.dataMap.getDisplayValue(s):Globalize.format(s,t.format);l[r]||(l[r]=!0,i.push({value:s,text:r}))}return i}};export class ValueFilterEditor extends Control{constructor(t,e){super(t),this._filter=asType(e,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;if(s.sortNullsFirst=!0,e.sortValues){let t=e.column.dataMap||e.dataMap?"text":"value",i=e.column.dataType!=DataType.Boolean;s.sortDescriptions.push(new SortDescription(t,i))}s.filter=this._filterValues.bind(this),s.collectionChanged.addHandler(this._updateSelectAllCheck,this),this._filterText="",this._cmbFilter=new input.ComboBox(this._divFilter,{placeholder:l.search}),this._lbValues=new input.ListBox(this._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:this._view,itemFormatter:(t,e)=>e||l.null}),setAriaLabel(this._cmbFilter.inputElement,l.ariaLabels.search),this._cmbFilter.textChanged.addHandler(this._filterTextChanged,this),this._cbSelectAll.addEventListener("click",this._cbSelectAllClicked.bind(this)),this.updateEditor()}get filter(){return this._filter}updateEditor(){let t=this._filter.column,e=this._filter._getUniqueValues(t,!0);this._lbValues.isContentHtml=t.isContentHtml;let i=this._filter.showValues;if(i&&0!=Object.keys(i).length){for(let t in i)for(let i=0;i<e.length;i++)if(e[i].text==t){e[i].show=!0;break}}else for(let t=0;t<e.length;t++)e[t].show=!0;this._view.pageSize=20,this._view.sourceCollection=e,setTimeout(()=>{this._view.pageSize=this._filter.maxValues,this._cmbFilter.text=this._filter.filterText||"",this._filterText=this._cmbFilter.text.toLowerCase()})}clearEditor(t=!0){this._cmbFilter.text="",this._filterText="",this._view.pageSize=0,this._view.refresh(),this._view.items.forEach(e=>{e.show=t}),this._view.pageSize=this._filter.maxValues}get isEditorClear(){return!this._filterText&&!this._cbSelectAll.indeterminate}updateFilter(){let t=null,e=this._getItems();if(this._filterText||this._cbSelectAll.indeterminate){t={};for(let i=0;i<e.length;i++){let l=e[i];l.show&&(t[l.text]=!0)}}let i=this._filter;i.showValues=t,i.filterText=""}_getItems(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection}_filterTextChanged(){this._toText&&clearTimeout(this._toText),this._toText=setTimeout(()=>{let t=this._cmbFilter.text.toLowerCase(),e=t!=this._filterText;this._filterText=t,this._view.refresh(),e&&(this._filter.exclusiveValueSearch?(this._cbSelectAll.checked=!0,this._cbSelectAllClicked()):this._updateSelectAllCheck())},300)}_filterValues(t){return!this._filterText||!(!t||!t.text)&&t.text.toLowerCase().indexOf(this._filterText)>-1}_cbSelectAllClicked(){let t=this._cbSelectAll.checked,e=this._divValues.scrollTop,i=this._getItems();for(let e=0;e<i.length;e++)i[e].show=t;this._view.refresh(),this._divValues.scrollTop=e}_updateSelectAllCheck(){let t=0,e=this._getItems();for(let i=0;i<e.length;i++)e[i].show&&t++;let i=this._cbSelectAll;0==t?(i.checked=!1,i.indeterminate=!1):t==e.length?(i.checked=!0,i.indeterminate=!1):i.indeterminate=!0}};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(t,e){this._owner=t,this._col=e,this._valueFilter=new ValueFilter(e),this._valueFilter.exclusiveValueSearch=t.exclusiveValueSearch,this._conditionFilter=new ConditionFilter(e)}get filterType(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType}set filterType(t){if((t=asEnum(t,FilterType,!0))!=this._filterType){let e=this.isActive;this.clear(),this._filterType=t,e?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}}get dataMap(){return this.conditionFilter.dataMap||this.valueFilter.dataMap}set dataMap(t){this.conditionFilter.dataMap=t,this.valueFilter.dataMap=t}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(t){return this._conditionFilter.apply(t)&&this._valueFilter.apply(t)}clear(){this._valueFilter.clear(),this._conditionFilter.clear()}implementsInterface(t){return"IColumnFilter"==t}};export var FilterType;!function(t){t[t.None=0]="None",t[t.Condition=1]="Condition",t[t.Value=2]="Value",t[t.Both=3]="Both"}(FilterType||(FilterType={}));export class FlexGridFilter{constructor(t,e){this._showIcons=!0,this._showSort=!0,this._defFilterType=FilterType.Both,this._xValueSearch=!0,this.filterApplied=new Event,this.filterChanging=new Event,this.filterChanged=new Event,this._filters=[],this._g=asType(t,FlexGrid,!1),this._g.formatItem.addHandler(this._formatItem.bind(this)),this._g.itemsSourceChanged.addHandler(this.clear.bind(this));let i=this._g.hostElement;t.addEventListener(i,"mousedown",this._mousedown.bind(this),!0),t.addEventListener(i,"click",this._click.bind(this),!0),t.addEventListener(i,"keydown",this._keydown.bind(this),!0),this._g.invalidate(),e&©(this,e)}get grid(){return this._g}get filterColumns(){return this._filterColumns}set filterColumns(t){this._filterColumns=asArray(t),this.clear()}get showFilterIcons(){return this._showIcons}set showFilterIcons(t){t!=this.showFilterIcons&&(this._showIcons=asBoolean(t),this._g&&this._g.invalidate())}get showSortButtons(){return this._showSort}set showSortButtons(t){this._showSort=asBoolean(t)}getColumnFilter(t,e=!0){t=this._asColumn(t);for(let e=0;e<this._filters.length;e++)if(this._filters[e].column==t)return this._filters[e];if(e&&t.binding){let e=new ColumnFilter(this,t);return this._filters.push(e),e}return null}get defaultFilterType(){return this._defFilterType}set defaultFilterType(t){(t=asEnum(t,FilterType,!1))!=this.defaultFilterType&&(this._defFilterType=t,this._g.invalidate(),this.clear())}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(t){this._xValueSearch=asBoolean(t)}get filterDefinition(){let t={defaultFilterType:this.defaultFilterType,filters:[]};return this._filters.forEach(e=>{let i=e.conditionFilter,l=e.valueFilter,s=l.uniqueValues&&l.uniqueValues.length;if(e&&e.column&&e.column.binding&&(e.isActive||s||e.filterType!=this.defaultFilterType)){let a={binding:e.column.binding};if(i.isActive){let t=i.condition1,l=i.condition2;a={binding:e.column.binding,type:"condition",condition1:{operator:t.operator,value:t.value},and:i.and,condition2:{operator:l.operator,value:l.value}}}else(l.isActive||s)&&(a={binding:e.column.binding,type:"value",uniqueValues:l.uniqueValues,sortValues:l.sortValues,maxValues:l.maxValues,exclusiveValueSearch:l.exclusiveValueSearch,showValues:l.showValues});e.filterType!=this.defaultFilterType&&(a.filterType=e.filterType),t.filters.push(a)}}),JSON.stringify(t)}set filterDefinition(t){if(t=asString(t),this.clear(),t){let e=JSON.parse(t);this.defaultFilterType=e.defaultFilterType;for(let t=0;t<e.filters.length;t++){let i=e.filters[t],l=this._g.getColumn(i.binding),s=this.getColumnFilter(l,!0);if(s)switch(null!=i.filterType&&(s.filterType=asEnum(i.filterType,FilterType)),i.type){case"condition":let t=s.conditionFilter;t.condition1.value=l.dataType==DataType.Date?changeType(i.condition1.value,l.dataType,null):i.condition1.value,t.condition1.operator=i.condition1.operator,t.and=i.and,t.condition2.value=l.dataType==DataType.Date?changeType(i.condition2.value,l.dataType,null):i.condition2.value,t.condition2.operator=i.condition2.operator;break;case"value":let e=s.valueFilter;e.uniqueValues=i.uniqueValues,["sortValues","maxValues","exclusiveValueSearch"].forEach(t=>{null!=i[t]&&(e[t]=i[t])}),e.showValues=i.showValues}}}this.apply()}get activeEditor(){return Control.getControl(this._divEdt)}editColumnFilter(t,e,i){this.closeEditor(),t=this._asColumn(t);let l=this._g,s=new CellRangeEventArgs(l.cells,new CellRange(-1,t.index));if(!this.onFilterChanging(s))return void(this._divEdt=this._edtCol=null);s.cancel=!0;let a=createElement('<div class="wj-dropdown-panel"></div>'),r=this.getColumnFilter(t),n=new ColumnFilterEditor(a,r,this.showSortButtons);this._divEdt=a,this._edtCol=t,l.rightToLeft&&(a.dir="rtl"),n.filterChanged.addHandler(()=>{s.cancel=!1,setTimeout(()=>{s.cancel||this.apply()})}),n.buttonClicked.addHandler(()=>{this.closeEditor(),l.focus(),this.onFilterChanged(s)}),n.lostFocus.addHandler(()=>{setTimeout(()=>{let t=Control.getControl(this._divEdt);t&&!t.containsFocus()&&this.closeEditor()},10)});let o=e?e.col:t.index;e||l.columns[o].binding==t.binding||(o=l.selection.leftCol),l._edtHdl._commitRowEdits(),l.scrollIntoView(-1,o,!0);let d=l.columnHeaders,h=e&&e.panel==d?e.row:d.rows.length-1,u=o,c=d.getCellBoundingRect(h,u),p=i||d.getCellElement(h,u);p?showPopup(a,p,!1,!1,!1):showPopup(a,c),this._setAriaExpanded(p,!0),this._setAriaExpanded(l.cells.getCellElement(-1,u),!0);let _=n.hostElement.querySelectorAll("input");for(let t=0;t<_.length;t++){let e=_[t];if(e.offsetHeight>0&&e.tabIndex>-1&&!e.disabled){e.focus();break}}n.containsFocus()||n.focus()}_setAriaExpanded(t,e){if(t){var i=t.querySelector("."+FlexGridFilter._WJC_FILTER);setAttribute(i,"aria-expanded",e)}}closeEditor(){let t=this._g,e=Control.getControl(this._divEdt),i=this._edtCol;if(e&&hidePopup(e.hostElement,()=>{e.dispose()}),i){let e=t.columnHeaders,l=e.rows.length?e.getCellElement(e.rows.length-1,i.index):null;this._setAriaExpanded(l,!1),l=t.cells.getCellElement(-1,i.index),this._setAriaExpanded(l,!1)}this._divEdt=null,this._edtCol=null}apply(){let t=this._g.collectionView;if(t){let e=this._g.editableCollectionView;e&&(e.commitEdit(),e.commitNew()),t.filter=this._filter.bind(this)}let e=t?t.updateFilterDefinition:null;isFunction(e)&&e.call(t,this),this.onFilterApplied()}clear(){this._filters.length&&(this._filters=[],this.apply())}onFilterApplied(t){this.filterApplied.raise(this,t)}onFilterChanging(t){return this.filterChanging.raise(this,t),!t.cancel}onFilterChanged(t){this.filterChanged.raise(this,t)}_asColumn(t){return isString(t)?this._g.getColumn(t):isNumber(t)?this._g.columns[t]:asType(t,Column,!1)}_filter(t){for(let e=0;e<this._filters.length;e++)if(!this._filters[e].apply(t))return!1;return!0}_formatItem(t,e){if(e.panel==t.columnHeaders){let t=this._g,i=t.getMergedRange(e.panel,e.row,e.col)||new CellRange(e.row,e.col),l=t.columns[i.col],s=t._getBindingColumn(e.panel,e.row,l),a=e.cell;if(i.row2==e.panel.rows.length-1||l!=s){let i=this.getColumnFilter(s,this.defaultFilterType!=FilterType.None);this._filterColumns&&this._filterColumns.indexOf(s.binding)<0&&(i=null),i?(toggleClass(a,"wj-filter-on",i.isActive),toggleClass(a,"wj-filter-off",!i.isActive)):(removeClass(a,"wj-filter-on"),removeClass(a,"wj-filter-off")),i&&i.filterType!=FilterType.None&&(this._showIcons&&this._addFilterButton(s,i,a),0==e.row&&(a=t.cells.getCellElement(-1,e.col))&&this._addFilterButton(l,i,a))}}}_addFilterButton(t,e,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+" "+t.header),setAttribute(s,"aria-haspopup","dialog"),setAttribute(s,"aria-expanded",!1),setAttribute(s,"aria-describedby",t.describedById),setAttribute(s,"aria-pressed",e.isActive),i.querySelector("."+l)||(1==i.children.length&&(i=i.querySelector("div")||i),i.appendChild(s))}_mousedown(t){this._toggleEditor(t)&&(this._tmd=!0,t.stopPropagation(),t.preventDefault())}_click(t){(this._tmd||this._toggleEditor(t))&&(t.stopPropagation(),t.preventDefault()),this._tmd=!1}_toggleEditor(t){if(this._tmd=!1,!t.defaultPrevented&&0==t.button)if(closestClass(t.target,FlexGridFilter._WJC_FILTER)){let e=this._g,i=e.hitTest(t.target);if(i.panel||(i=e.hitTest(t)),i.panel==e.columnHeaders||i.panel==e.cells&&-1==i.row){let t=e.columns[i.col],l=e._getBindingColumn(i.panel,i.row,t);return this._divEdt&&this._edtCol==l?(this.closeEditor(),e.focus()):setTimeout(()=>{this.editColumnFilter(l,i)},this._divEdt?100:0),!0}}else this.closeEditor();return!1}_keydown(t){if(!t.defaultPrevented&&!t.ctrlKey&&t.altKey&&(t.keyCode==Key.Down||t.keyCode==Key.Up)){let e=this.grid,i=e.selection,l=i.col>-1?e.columns[i.col]:null,s=l?e._getBindingColumn(e.cells,i.row,l):null;s&&!s.dataMap&&this.getColumnFilter(s,!0)&&(this.editColumnFilter(s),t.preventDefault(),t.stopPropagation())}}};FlexGridFilter._WJC_FILTER="wj-elem-filter",_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(t,e,i=!0){super(t,null,!0),this.filterChanged=new Event,this.buttonClicked=new Event,this._filter=asType(e,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==(e.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;this._showFilter(d),i&&o&&o.canSort||(this._divSort.style.display="none");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),r.addEventListener("keydown",t=>{if(!t.defaultPrevented){let e=t.target.tagName.match(/^(a|button)$/i);switch(t.keyCode){case Key.Space:e&&(this._btnClicked(t),t.preventDefault());break;case Key.Enter:e?this._btnClicked(t):(this.updateFilter(),this.onFilterChanged(),this.onButtonClicked()),t.preventDefault();break;case Key.Escape:this.onButtonClicked(),t.preventDefault();break;case Key.Tab:moveFocus(this.hostElement,t.shiftKey?-1:1),t.preventDefault()}}})}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(t){this.filterChanged.raise(this,t)}onButtonClicked(t){this.buttonClicked.raise(this,t)}_handleResize(){this.isTouching||this._wasTouching||this.onButtonClicked()}_showFilter(t){this._wasTouching=this.isTouching,t==FilterType.Value&&null==this._edtVal&&(this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter)),t==FilterType.Condition&&null==this._edtCnd&&(this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter)),0!=(t&this.filter.filterType)&&(t==FilterType.Value?(this._divEdtVal.style.display="",this._divEdtCnd.style.display="none",this._enableLink(this._aVal,!1),this._enableLink(this._aCnd,!0),this._edtVal.focus()):(this._divEdtVal.style.display="none",this._divEdtCnd.style.display="",this._enableLink(this._aVal,!0),this._enableLink(this._aCnd,!1),this._edtCnd.focus()));let e=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:e.display="none";break;default:e.display=""}}_enableLink(t,e){toggleClass(t,"wj-state-disabled",!e),setAttribute(t,"href",e?"":null),setAttribute(t,"disabled",e?null:"disabled")}_getFilterType(){let t=FilterType;return"none"!=this._divEdtVal.style.display?t.Value:t.Condition}_btnClicked(t){let e=t.target;if(t.preventDefault(),t.stopPropagation(),!hasClass(e,"wj-state-disabled")){if(e==this._aVal)return this._showFilter(FilterType.Value),void moveFocus(this._edtVal.hostElement,0);if(e==this._aCnd)return this._showFilter(FilterType.Condition),void moveFocus(this._edtCnd.hostElement,0);if(e==this._btnAsc||e==this._btnDsc){let e=this.filter.column,i=e.sortMemberPath?e.sortMemberPath:e.binding,l=e.grid.collectionView,s=new SortDescription(i,t.target==this._btnAsc);l.sortDescriptions.deferUpdate(()=>{l.sortDescriptions.clear(),l.sortDescriptions.push(s)})}e==this._btnApply?(this.updateFilter(),this.onFilterChanged()):e==this._btnClear?this.filter.isActive&&(this.filter.clear(),this.onFilterChanged()):this.updateEditor(),this.onButtonClicked()}}};ColumnFilterEditor.controlTemplate='<div><div wj-part="div-sort"><button wj-part="btn-asc" class="wj-btn" style="min-width:95px"></button> <button wj-part="btn-dsc" class="wj-btn" style="min-width:95px"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a> | <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> <button wj-part="btn-cancel" class="wj-btn"></button> <button wj-part="btn-clear" class="wj-btn"></button></div>',_registerModule("wijmo.grid.filter",selfModule); | ||
import{Column,DataMap,FlexGrid,CellRange,CellRangeEventArgs}from"@grapecity/wijmo.grid";import{Globalize,asString,asNumber,asArray,asBoolean,asType,asEnum,isString,isDate,DateTime,culture,assert,isNumber,Control,Event,DataType,Key,copy,changeType,createElement,setAttribute,showPopup,hidePopup,isFunction,toggleClass,removeClass,closestClass,setAriaLabel,setText,CollectionView,SortDescription,_addCultureInfo,moveFocus,hasClass,_registerModule}from"@grapecity/wijmo";import*as input from"@grapecity/wijmo.input";import*as selfModule from"@grapecity/wijmo.grid.filter";export class FilterCondition{constructor(t){this._op=null,this._filter=t}get operator(){return this._op}set operator(t){this._op=asEnum(t,Operator,!0)}get value(){return this._val}set value(t){if(this._val=t,this._strVal=isString(t)?t.toString().toLowerCase():null,this._mapVal=null,this._filter){let e=this._filter.dataMap||this._filter.column.dataMap;e&&(this._mapVal=e.getDisplayValue(t),isString(this._mapVal)&&(this._strVal=this._mapVal=this._mapVal.toLowerCase()))}}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(t,e,i){let l=this._mapVal||this._strVal||this._val;isString(t)&&(t=t.toLowerCase()),isString(l)&&null==t&&(t=""),isDate(l)&&(e?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!=t&&null!=l?t.valueOf()==l.valueOf():t==l;case s.NE:return null!=t&&null!=l?t.valueOf()!=l.valueOf():t!=l;case s.GT:return t>l;case s.GE:return t>=l;case s.LT:return t<l;case s.LE:return t<=l;case s.BW:return!(null==this._strVal||!isString(t))&&0==t.indexOf(this._strVal);case s.EW:return!!(null!=this._strVal&&isString(t)&&t.length>=this._strVal.length)&&t.substr(t.length-this._strVal.length)==l;case s.CT:return!(null==this._strVal||!isString(t))&&t.indexOf(this._strVal)>-1;case s.NC:return!(null==this._strVal||!isString(t))&&t.indexOf(this._strVal)<0}throw"Unknown operator"}};FilterCondition._refDateTime=new Date(2e3,0,1,0,0,0);export var Operator;!function(t){t[t.EQ=0]="EQ",t[t.NE=1]="NE",t[t.GT=2]="GT",t[t.GE=3]="GE",t[t.LT=4]="LT",t[t.LE=5]="LE",t[t.BW=6]="BW",t[t.EW=7]="EW",t[t.CT=8]="CT",t[t.NC=9]="NC"}(Operator||(Operator={}));export class ConditionFilter{constructor(t){this._c1=new FilterCondition(this),this._c2=new FilterCondition(this),this._and=!0,this._col=t}get condition1(){return this._c1}get condition2(){return this._c2}get and(){return this._and}set and(t){this._and=asBoolean(t)}get dataMap(){return this._map}set dataMap(t){this._map=asType(t,DataMap,!0)}get column(){return this._col}get isActive(){return this._c1.isActive||this._c2.isActive}apply(t){let e=this._col,i=this._c1,l=this._c2,s=!1,a=!1;if(!e||!e._binding||!this.isActive)return!0;if(t=e._binding.getValue(t),this.dataMap)t=this.dataMap.getDisplayValue(t);else if(e.dataMap)t=e.dataMap.getDisplayValue(t);else if(isDate(t))if(s=!this._hasTimePart(),a=!this._hasDatePart(),assert(!s||!a,"Filter should have either date or time."),s){Date();t=DateTime.fromDateTime(t,FilterCondition._refDateTime)}else a&&(t=DateTime.fromDateTime(FilterCondition._refDateTime,t));else isNumber(t)&&(t=Globalize.parseFloat(Globalize.format(t,e.format)));let r=i.apply(t,s,a),n=l.apply(t,s,a);return i.isActive&&l.isActive?this._and?r&&n:r||n:i.isActive?r:!l.isActive||n}clear(){this._c1.clear(),this._c2.clear(),this.and=!0}_hasDatePart(){let t=this._col.format;return!t||(t=culture.Globalize.calendar.patterns[t]||t,/[yMd]+/.test(t))}_hasTimePart(){let t=this._col.format;return!!t&&(t=culture.Globalize.calendar.patterns[t]||t,/[Hmst]+/.test(t))}implementsInterface(t){return"IColumnFilter"==t}};export class ConditionFilterEditor extends Control{constructor(t,e){super(t),this._filter=asType(e,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),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((t,e)=>{this._val1.isDisabled=null==t.selectedValue}),this._val2.isDisabled=!0,this._cmb2.selectedIndexChanged.addHandler((t,e)=>{this._val2.isDisabled=null==t.selectedValue});let a=this.hostElement;this.addEventListener(a,"change",this._btnAndOrChanged.bind(this)),this.addEventListener(a,"keydown",this._keydown.bind(this)),this.updateEditor()}get filter(){return this._filter}updateEditor(){let t=this._filter.condition1,e=this._filter.condition2;this._cmb1.selectedValue=t.operator,this._cmb2.selectedValue=e.operator,this._val1 instanceof input.ComboBox&&!(this._val1 instanceof input.InputTime)?(this._val1.text=changeType(t.value,DataType.String),this._val2.text=changeType(e.value,DataType.String)):(this._val1.value=t.value,this._val2.value=e.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 t=this._filter.condition1,e=this._filter.condition2;t.operator=this._cmb1.selectedValue,e.operator=this._cmb2.selectedValue,"value"in this._val1?(t.value=this._val1.value,e.value=this._val2.value):(t.value=this._val1.selectedValue,e.value=this._val2.selectedValue),this._filter.and=this._btnAnd.checked}_createOperatorCombo(t,e){let i=this._filter.column,l=culture.FlexGridFilter,s=l.stringOperators,a=this._filter.dataMap||i.dataMap,r=DataType;i.dataType==r.Date?s=l.dateOperators:i.dataType!=r.Number||a?i.dataType!=r.Boolean||a||(s=l.booleanOperators):s=l.numberOperators;let n=new input.ComboBox(t,{itemsSource:s,displayMemberPath:"name",selectedValuePath:"op"});return setAriaLabel(n.inputElement,e),n}_createValueInput(t,e){let i=this._filter,l=i.column,s=i.dataMap||l.dataMap,a=null,r=DataType;return l.dataType==r.Date?(a=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(t):new input.InputDate(t):new input.InputTime(t)).format=l.format:l.dataType!=r.Number||s?(a=new input.ComboBox(t),s?(a.itemsSource=s.getDisplayValues(),a.isEditable=!0):l.dataType==r.Boolean&&(a.itemsSource=[!0,!1])):(a=new input.InputNumber(t)).format=l.format,a.isRequired=!1,setAriaLabel(a.inputElement,e),a}_btnAndOrChanged(t){let e=t.target==this._btnAnd,i=t.target==this._btnOr;(e||i)&&(this._checkRadio(this._btnAnd,e),this._checkRadio(this._btnOr,i))}_checkRadio(t,e){t.checked=e,t.setAttribute("aria-checked",e.toString()),t.setAttribute("tabindex",e?"1":"-1")}_keydown(t){let e=t.target==this._btnAnd,i=t.target==this._btnOr;if(e||i)switch(t.keyCode){case Key.Left:case Key.Right:case Key.Up:case Key.Down:let i=e?this._btnOr:this._btnAnd;i.click(),i.focus(),t.preventDefault()}}};ConditionFilterEditor.controlTemplate='<div><div wj-part="div-hdr"></div><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> <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 ValueFilter{constructor(t){this._xValueSearch=!0,this._maxValues=250,this._sortValues=!0,this._col=t}get showValues(){return this._values}set showValues(t){this._values=t}get filterText(){return this._filterText}set filterText(t){this._filterText=asString(t)}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(t){this._xValueSearch=asBoolean(t)}get maxValues(){return this._maxValues}set maxValues(t){this._maxValues=asNumber(t,!1,!0)}get uniqueValues(){return this._uniqueValues}set uniqueValues(t){this._uniqueValues=asArray(t)}get sortValues(){return this._sortValues}set sortValues(t){this._sortValues=asBoolean(t)}get dataMap(){return this._map}set dataMap(t){this._map=asType(t,DataMap,!0)}get column(){return this._col}get isActive(){return null!=this._values&&Object.keys(this._values).length>0}apply(t){let e=this.column;return!(e&&e._binding&&this._values&&Object.keys(this._values).length)||(t=e._binding.getValue(t),t=this.dataMap?this.dataMap.getDisplayValue(t):e.dataMap?e.dataMap.getDisplayValue(t):Globalize.format(t,e.format),void 0!=this._values[t])}clear(){this.showValues=null,this.filterText=null}implementsInterface(t){return"IColumnFilter"==t}_getUniqueValues(t,e){let i=[];if(this.uniqueValues){let t=this.uniqueValues;for(let e=0;e<t.length;e++){let l=t[e];i.push({value:l,text:l.toString()})}return i}let l={},s=t.collectionView,a=s?s.sourceCollection:[];if(e&&s&&s.sourceCollection&&s.filter){let t=this.showValues;this.showValues=null;let e=[];for(let t=0;t<a.length;t++)s.filter(a[t])&&e.push(a[t]);a=e,this.showValues=t}for(let e=0;e<a.length;e++){let s=t._binding.getValue(a[e]),r=this.dataMap?this.dataMap.getDisplayValue(s):t.dataMap?t.dataMap.getDisplayValue(s):Globalize.format(s,t.format);l[r]||(l[r]=!0,i.push({value:s,text:r}))}return i}};export class ValueFilterEditor extends Control{constructor(t,e){super(t),this._filter=asType(e,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;if(s.sortNullsFirst=!0,e.sortValues){let t=e.column.dataMap||e.dataMap?"text":"value",i=e.column.dataType!=DataType.Boolean;s.sortDescriptions.push(new SortDescription(t,i))}s.filter=this._filterValues.bind(this),s.collectionChanged.addHandler(this._updateSelectAllCheck,this),this._filterText="",this._cmbFilter=new input.ComboBox(this._divFilter,{placeholder:l.search}),this._lbValues=new input.ListBox(this._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:this._view,itemFormatter:(t,e)=>e||l.null}),setAriaLabel(this._cmbFilter.inputElement,l.ariaLabels.search),this._cmbFilter.textChanged.addHandler(this._filterTextChanged,this),this._cbSelectAll.addEventListener("click",this._cbSelectAllClicked.bind(this)),this.updateEditor()}get filter(){return this._filter}updateEditor(){let t=this._filter.column,e=this._filter._getUniqueValues(t,!0);this._lbValues.isContentHtml=t.isContentHtml;let i=this._filter.showValues;if(i&&0!=Object.keys(i).length){for(let t in i)for(let i=0;i<e.length;i++)if(e[i].text==t){e[i].show=!0;break}}else for(let t=0;t<e.length;t++)e[t].show=!0;this._view.pageSize=20,this._view.sourceCollection=e,setTimeout(()=>{this._view.pageSize=this._filter.maxValues,this._cmbFilter.text=this._filter.filterText||"",this._filterText=this._cmbFilter.text.toLowerCase()})}clearEditor(t=!0){this._cmbFilter.text="",this._filterText="",this._view.pageSize=0,this._view.refresh(),this._view.items.forEach(e=>{e.show=t}),this._view.pageSize=this._filter.maxValues}get isEditorClear(){return!this._filterText&&!this._cbSelectAll.indeterminate}updateFilter(){let t=null,e=this._getItems();if(this._filterText||this._cbSelectAll.indeterminate){t={};for(let i=0;i<e.length;i++){let l=e[i];l.show&&(t[l.text]=!0)}}let i=this._filter;i.showValues=t,i.filterText=""}_getItems(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection}_filterTextChanged(){this._toText&&clearTimeout(this._toText),this._toText=setTimeout(()=>{let t=this._cmbFilter.text.toLowerCase(),e=t!=this._filterText;this._filterText=t,this._view.refresh(),e&&(this._filter.exclusiveValueSearch?(this._cbSelectAll.checked=!0,this._cbSelectAllClicked()):this._updateSelectAllCheck())},300)}_filterValues(t){return!this._filterText||!(!t||!t.text)&&t.text.toLowerCase().indexOf(this._filterText)>-1}_cbSelectAllClicked(){let t=this._cbSelectAll.checked,e=this._divValues.scrollTop,i=this._getItems();for(let e=0;e<i.length;e++)i[e].show=t;this._view.refresh(),this._divValues.scrollTop=e}_updateSelectAllCheck(){let t=0,e=this._getItems();for(let i=0;i<e.length;i++)e[i].show&&t++;let i=this._cbSelectAll;0==t?(i.checked=!1,i.indeterminate=!1):t==e.length?(i.checked=!0,i.indeterminate=!1):i.indeterminate=!0}};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(t,e){this._owner=t,this._col=e,this._valueFilter=new ValueFilter(e),this._valueFilter.exclusiveValueSearch=t.exclusiveValueSearch,this._conditionFilter=new ConditionFilter(e)}get filterType(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType}set filterType(t){if((t=asEnum(t,FilterType,!0))!=this._filterType){let e=this.isActive;this.clear(),this._filterType=t,e?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}}get dataMap(){return this.conditionFilter.dataMap||this.valueFilter.dataMap}set dataMap(t){this.conditionFilter.dataMap=t,this.valueFilter.dataMap=t}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(t){return this._conditionFilter.apply(t)&&this._valueFilter.apply(t)}clear(){this._valueFilter.clear(),this._conditionFilter.clear()}implementsInterface(t){return"IColumnFilter"==t}};export var FilterType;!function(t){t[t.None=0]="None",t[t.Condition=1]="Condition",t[t.Value=2]="Value",t[t.Both=3]="Both"}(FilterType||(FilterType={}));export class FlexGridFilter{constructor(t,e){this._showIcons=!0,this._showSort=!0,this._defFilterType=FilterType.Both,this._xValueSearch=!0,this.filterApplied=new Event,this.filterChanging=new Event,this.filterChanged=new Event,this._filters=[],this._g=asType(t,FlexGrid,!1),this._g.formatItem.addHandler(this._formatItem.bind(this)),this._g.itemsSourceChanged.addHandler(this.clear.bind(this));let i=this._g.hostElement;t.addEventListener(i,"mousedown",this._mousedown.bind(this),!0),t.addEventListener(i,"click",this._click.bind(this),!0),t.addEventListener(i,"keydown",this._keydown.bind(this),!0),this._g.invalidate(),e&©(this,e)}get grid(){return this._g}get filterColumns(){return this._filterColumns}set filterColumns(t){this._filterColumns=asArray(t),this.clear()}get showFilterIcons(){return this._showIcons}set showFilterIcons(t){t!=this.showFilterIcons&&(this._showIcons=asBoolean(t),this._g&&this._g.invalidate())}get showSortButtons(){return this._showSort}set showSortButtons(t){this._showSort=asBoolean(t)}getColumnFilter(t,e=!0){t=this._asColumn(t);for(let e=0;e<this._filters.length;e++)if(this._filters[e].column==t)return this._filters[e];if(e&&t.binding){let e=new ColumnFilter(this,t);return this._filters.push(e),e}return null}get defaultFilterType(){return this._defFilterType}set defaultFilterType(t){(t=asEnum(t,FilterType,!1))!=this.defaultFilterType&&(this._defFilterType=t,this._g.invalidate(),this.clear())}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(t){this._xValueSearch=asBoolean(t)}get filterDefinition(){let t={defaultFilterType:this.defaultFilterType,filters:[]};return this._filters.forEach(e=>{let i=e.conditionFilter,l=e.valueFilter,s=l.uniqueValues&&l.uniqueValues.length;if(e&&e.column&&e.column.binding&&(e.isActive||s||e.filterType!=this.defaultFilterType)){let a={binding:e.column.binding};if(i.isActive){let t=i.condition1,l=i.condition2;a={binding:e.column.binding,type:"condition",condition1:{operator:t.operator,value:t.value},and:i.and,condition2:{operator:l.operator,value:l.value}}}else(l.isActive||s)&&(a={binding:e.column.binding,type:"value",uniqueValues:l.uniqueValues,sortValues:l.sortValues,maxValues:l.maxValues,exclusiveValueSearch:l.exclusiveValueSearch,showValues:l.showValues});e.filterType!=this.defaultFilterType&&(a.filterType=e.filterType),t.filters.push(a)}}),JSON.stringify(t)}set filterDefinition(t){if(t=asString(t),this.clear(),t){let e=JSON.parse(t);this.defaultFilterType=e.defaultFilterType;for(let t=0;t<e.filters.length;t++){let i=e.filters[t],l=this._g.getColumn(i.binding),s=this.getColumnFilter(l,!0);if(s)switch(null!=i.filterType&&(s.filterType=asEnum(i.filterType,FilterType)),i.type){case"condition":let t=s.conditionFilter;t.condition1.value=l.dataType==DataType.Date?changeType(i.condition1.value,l.dataType,null):i.condition1.value,t.condition1.operator=i.condition1.operator,t.and=i.and,t.condition2.value=l.dataType==DataType.Date?changeType(i.condition2.value,l.dataType,null):i.condition2.value,t.condition2.operator=i.condition2.operator;break;case"value":let e=s.valueFilter;e.uniqueValues=i.uniqueValues,["sortValues","maxValues","exclusiveValueSearch"].forEach(t=>{null!=i[t]&&(e[t]=i[t])}),e.showValues=i.showValues}}}this.apply()}get activeEditor(){return Control.getControl(this._divEdt)}editColumnFilter(t,e,i){this.closeEditor(),t=this._asColumn(t);let l=this._g,s=new CellRangeEventArgs(l.cells,new CellRange(-1,t.index));if(!this.onFilterChanging(s))return void(this._divEdt=this._edtCol=null);s.cancel=!0;let a=createElement('<div class="wj-dropdown-panel"></div>'),r=this.getColumnFilter(t),n=new ColumnFilterEditor(a,r,this.showSortButtons);this._divEdt=a,this._edtCol=t,l.rightToLeft&&(a.dir="rtl"),n.filterChanged.addHandler(()=>{s.cancel=!1,setTimeout(()=>{s.cancel||this.apply()})}),n.buttonClicked.addHandler(()=>{this.closeEditor(),l.focus(),this.onFilterChanged(s)}),n.lostFocus.addHandler(()=>{setTimeout(()=>{let t=Control.getControl(this._divEdt);t&&!t.containsFocus()&&this.closeEditor()},10)});let o=e?e.col:t.index;e||l.columns[o].binding==t.binding||(o=l.selection.leftCol),l._edtHdl._commitRowEdits(),l.scrollIntoView(-1,o,!0);let d=l.columnHeaders,h=e&&e.panel==d?e.row:d.rows.length-1,u=o,c=d.getCellBoundingRect(h,u),p=i||d.getCellElement(h,u);p?showPopup(a,p,!1,!1,!1):showPopup(a,c),this._setAriaExpanded(p,!0),this._setAriaExpanded(l.cells.getCellElement(-1,u),!0);let _=n.hostElement.querySelectorAll("input");for(let t=0;t<_.length;t++){let e=_[t];if(e.offsetHeight>0&&e.tabIndex>-1&&!e.disabled){e.focus();break}}n.containsFocus()||n.focus()}_setAriaExpanded(t,e){if(t){var i=t.querySelector("."+FlexGridFilter._WJC_FILTER);setAttribute(i,"aria-expanded",e)}}closeEditor(){let t=this._g,e=Control.getControl(this._divEdt),i=this._edtCol;if(e&&hidePopup(e.hostElement,()=>{e.dispose()}),i){let e=t.columnHeaders,l=e.rows.length?e.getCellElement(e.rows.length-1,i.index):null;this._setAriaExpanded(l,!1),l=t.cells.getCellElement(-1,i.index),this._setAriaExpanded(l,!1)}this._divEdt=null,this._edtCol=null}apply(){let t=this._g.collectionView;if(t){let e=this._g.editableCollectionView;e&&(e.commitEdit(),e.commitNew()),t.filter=this._filter.bind(this)}let e=t?t.updateFilterDefinition:null;isFunction(e)&&e.call(t,this),this.onFilterApplied()}clear(){this._filters.length&&(this._filters=[],this.apply())}onFilterApplied(t){this.filterApplied.raise(this,t)}onFilterChanging(t){return this.filterChanging.raise(this,t),!t.cancel}onFilterChanged(t){this.filterChanged.raise(this,t)}_asColumn(t){return isString(t)?this._g.getColumn(t):isNumber(t)?this._g.columns[t]:asType(t,Column,!1)}_filter(t){for(let e=0;e<this._filters.length;e++)if(!this._filters[e].apply(t))return!1;return!0}_formatItem(t,e){if(e.panel==t.columnHeaders){let t=this._g,i=t.getMergedRange(e.panel,e.row,e.col)||new CellRange(e.row,e.col),l=t.columns[i.col],s=t._getBindingColumn(e.panel,e.row,l),a=e.cell;if(i.row2==e.panel.rows.length-1||l!=s){let i=this.getColumnFilter(s,this.defaultFilterType!=FilterType.None);this._filterColumns&&this._filterColumns.indexOf(s.binding)<0&&(i=null),i?(toggleClass(a,"wj-filter-on",i.isActive),toggleClass(a,"wj-filter-off",!i.isActive)):(removeClass(a,"wj-filter-on"),removeClass(a,"wj-filter-off")),i&&i.filterType!=FilterType.None&&(this._showIcons&&this._addFilterButton(s,i,a),0==e.row&&(a=t.cells.getCellElement(-1,e.col))&&this._addFilterButton(l,i,a))}}}_addFilterButton(t,e,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+" "+t.header),setAttribute(s,"aria-haspopup","dialog"),setAttribute(s,"aria-expanded",!1),setAttribute(s,"aria-describedby",t.describedById),setAttribute(s,"aria-pressed",e.isActive),i.querySelector("."+l)||(1==i.children.length&&(i=i.querySelector("div")||i),i.appendChild(s))}_mousedown(t){this._toggleEditor(t)&&(this._tmd=!0,t.stopPropagation(),t.preventDefault())}_click(t){(this._tmd||this._toggleEditor(t))&&(t.stopPropagation(),t.preventDefault()),this._tmd=!1}_toggleEditor(t){if(this._tmd=!1,!t.defaultPrevented&&0==t.button)if(closestClass(t.target,FlexGridFilter._WJC_FILTER)){let e=this._g,i=e.hitTest(t.target);if(i.panel||(i=e.hitTest(t)),i.panel==e.columnHeaders||i.panel==e.cells&&-1==i.row){let t=e.columns[i.col],l=e._getBindingColumn(i.panel,i.row,t);return this._divEdt&&this._edtCol==l?(this.closeEditor(),e.focus()):setTimeout(()=>{this.editColumnFilter(l,i)},this._divEdt?100:0),!0}}else this.closeEditor();return!1}_keydown(t){if(!t.defaultPrevented&&!t.ctrlKey&&t.altKey&&(t.keyCode==Key.Down||t.keyCode==Key.Up)){let e=this.grid,i=e.selection,l=i.col>-1?e.columns[i.col]:null,s=l?e._getBindingColumn(e.cells,i.row,l):null;s&&!s.dataMap&&this.getColumnFilter(s,!0)&&(this.editColumnFilter(s),t.preventDefault(),t.stopPropagation())}}};FlexGridFilter._WJC_FILTER="wj-elem-filter",_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(t,e,i=!0){super(t,null,!0),this.filterChanged=new Event,this.buttonClicked=new Event,this._filter=asType(e,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==(e.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;this._showFilter(d),i&&o&&o.canSort||(this._divSort.style.display="none");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",t=>{if(!t.defaultPrevented){let e=t.target.tagName.match(/^(a|button)$/i);switch(t.keyCode){case Key.Space:e&&(this._btnClicked(t),t.preventDefault());break;case Key.Enter:e?this._btnClicked(t):(this.updateFilter(),this.onFilterChanged(),this.onButtonClicked()),t.preventDefault();break;case Key.Escape:this.onButtonClicked(),t.preventDefault();break;case Key.Tab:moveFocus(this.hostElement,t.shiftKey?-1:1),t.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(t){this.filterChanged.raise(this,t)}onButtonClicked(t){this.buttonClicked.raise(this,t)}_showFilter(t){this._wasTouching=this.isTouching,t==FilterType.Value&&null==this._edtVal&&(this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter)),t==FilterType.Condition&&null==this._edtCnd&&(this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter)),0!=(t&this.filter.filterType)&&(t==FilterType.Value?(this._divEdtVal.style.display="",this._divEdtCnd.style.display="none",this._enableLink(this._aVal,!1),this._enableLink(this._aCnd,!0),this._edtVal.focus()):(this._divEdtVal.style.display="none",this._divEdtCnd.style.display="",this._enableLink(this._aVal,!0),this._enableLink(this._aCnd,!1),this._edtCnd.focus()));let e=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:e.display="none";break;default:e.display=""}}_enableLink(t,e){toggleClass(t,"wj-state-disabled",!e),setAttribute(t,"href",e?"":null),setAttribute(t,"disabled",e?null:"disabled")}_getFilterType(){let t=FilterType;return"none"!=this._divEdtVal.style.display?t.Value:t.Condition}_btnClicked(t){let e=t.target;if(t.preventDefault(),t.stopPropagation(),!hasClass(e,"wj-state-disabled")){if(e==this._aVal)return this._showFilter(FilterType.Value),void moveFocus(this._edtVal.hostElement,0);if(e==this._aCnd)return this._showFilter(FilterType.Condition),void moveFocus(this._edtCnd.hostElement,0);if(e==this._btnAsc||e==this._btnDsc){let e=this.filter.column,i=e.sortMemberPath?e.sortMemberPath:e.binding,l=e.grid.collectionView,s=new SortDescription(i,t.target==this._btnAsc);l.sortDescriptions.deferUpdate(()=>{l.sortDescriptions.clear(),l.sortDescriptions.push(s)})}e==this._btnApply?(this.updateFilter(),this.onFilterChanged()):e==this._btnClear?this.filter.isActive&&(this.filter.clear(),this.onFilterChanged()):this.updateEditor(),this.onButtonClicked()}}};ColumnFilterEditor.controlTemplate='<div><div wj-part="div-sort"><button wj-part="btn-asc" class="wj-btn" style="min-width:95px"></button> <button wj-part="btn-dsc" class="wj-btn" style="min-width:95px"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a> | <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> <button wj-part="btn-cancel" class="wj-btn"></button> <button wj-part="btn-clear" class="wj-btn"></button></div>',_registerModule("wijmo.grid.filter",selfModule); |
/*! | ||
* | ||
* Wijmo Library 5.20191.599-nightly.d20190408.t120542 | ||
* Wijmo Library 5.20191.599-nightly.d20190408.t162215 | ||
* http://wijmo.com/ | ||
@@ -14,2 +14,2 @@ * | ||
var __extends=this&&this.__extends||function(){var e=function(t,i){return(e=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])})(t,i)};return function(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();import{Column,DataMap,FlexGrid,CellRange,CellRangeEventArgs}from"@grapecity/wijmo.grid";import{Globalize,asString,asNumber,asArray,asBoolean,asType,asEnum,isString,isDate,DateTime,culture,assert,isNumber,Control,Event,DataType,Key,copy,changeType,createElement,setAttribute,showPopup,hidePopup,isFunction,toggleClass,removeClass,closestClass,setAriaLabel,setText,CollectionView,SortDescription,_addCultureInfo,moveFocus,hasClass,_registerModule}from"@grapecity/wijmo";import*as input from"@grapecity/wijmo.input";import*as selfModule from"@grapecity/wijmo.grid.filter";var FilterCondition=function(){function e(e){this._op=null,this._filter=e}return Object.defineProperty(e.prototype,"operator",{get:function(){return this._op},set:function(e){this._op=asEnum(e,Operator,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._val},set:function(e){if(this._val=e,this._strVal=isString(e)?e.toString().toLowerCase():null,this._mapVal=null,this._filter){var t=this._filter.dataMap||this._filter.column.dataMap;t&&(this._mapVal=t.getDisplayValue(e),isString(this._mapVal)&&(this._strVal=this._mapVal=this._mapVal.toLowerCase()))}},enumerable:!0,configurable:!0}),Object.defineProperty(e.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}),e.prototype.clear=function(){this.operator=null,this.value=null},e.prototype.apply=function(t,i,n){var r=this._mapVal||this._strVal||this._val;isString(t)&&(t=t.toLowerCase()),isString(r)&&null==t&&(t=""),isDate(r)&&(i?r=DateTime.fromDateTime(r,e._refDateTime):n&&(r=DateTime.fromDateTime(e._refDateTime,r)));var l=Operator;switch(this._op){case null:return!0;case l.EQ:return null!=t&&null!=r?t.valueOf()==r.valueOf():t==r;case l.NE:return null!=t&&null!=r?t.valueOf()!=r.valueOf():t!=r;case l.GT:return t>r;case l.GE:return t>=r;case l.LT:return t<r;case l.LE:return t<=r;case l.BW:return!(null==this._strVal||!isString(t))&&0==t.indexOf(this._strVal);case l.EW:return!!(null!=this._strVal&&isString(t)&&t.length>=this._strVal.length)&&t.substr(t.length-this._strVal.length)==r;case l.CT:return!(null==this._strVal||!isString(t))&&t.indexOf(this._strVal)>-1;case l.NC:return!(null==this._strVal||!isString(t))&&t.indexOf(this._strVal)<0}throw"Unknown operator"},e._refDateTime=new Date(2e3,0,1,0,0,0),e}();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={}));var ConditionFilter=function(){function e(e){this._c1=new FilterCondition(this),this._c2=new FilterCondition(this),this._and=!0,this._col=e}return Object.defineProperty(e.prototype,"condition1",{get:function(){return this._c1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"condition2",{get:function(){return this._c2},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"and",{get:function(){return this._and},set:function(e){this._and=asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map=asType(e,DataMap,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return this._c1.isActive||this._c2.isActive},enumerable:!0,configurable:!0}),e.prototype.apply=function(e){var t=this._col,i=this._c1,n=this._c2,r=!1,l=!1;if(!t||!t._binding||!this.isActive)return!0;if(e=t._binding.getValue(e),this.dataMap)e=this.dataMap.getDisplayValue(e);else if(t.dataMap)e=t.dataMap.getDisplayValue(e);else if(isDate(e))if(r=!this._hasTimePart(),l=!this._hasDatePart(),assert(!r||!l,"Filter should have either date or time."),r){Date();e=DateTime.fromDateTime(e,FilterCondition._refDateTime)}else l&&(e=DateTime.fromDateTime(FilterCondition._refDateTime,e));else isNumber(e)&&(e=Globalize.parseFloat(Globalize.format(e,t.format)));var a=i.apply(e,r,l),o=n.apply(e,r,l);return i.isActive&&n.isActive?this._and?a&&o:a||o:i.isActive?a:!n.isActive||o},e.prototype.clear=function(){this._c1.clear(),this._c2.clear(),this.and=!0},e.prototype._hasDatePart=function(){var e=this._col.format;return!e||(e=culture.Globalize.calendar.patterns[e]||e,/[yMd]+/.test(e))},e.prototype._hasTimePart=function(){var e=this._col.format;return!!e&&(e=culture.Globalize.calendar.patterns[e]||e,/[Hmst]+/.test(e))},e.prototype.implementsInterface=function(e){return"IColumnFilter"==e},e}();export{ConditionFilter};var ConditionFilterEditor=function(e){function t(t,i){var n=e.call(this,t)||this;n._filter=asType(i,ConditionFilter,!1);var r=n.getTemplate();n.applyTemplate("wj-control wj-conditionfilter-editor",r,{_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(n._btnAnd,a.and),setAriaLabel(n._btnOr,a.or),setText(n._divHdr,l.header),setText(n._spAnd,l.and),setText(n._spOr,l.or),n._cmb1=n._createOperatorCombo(n._divCmb1,a.op1),n._cmb2=n._createOperatorCombo(n._divCmb2,a.op2),n._val1=n._createValueInput(n._divVal1,a.val1),n._val2=n._createValueInput(n._divVal2,a.val2),n._val1.isDisabled=!0,n._cmb1.selectedIndexChanged.addHandler(function(e,t){n._val1.isDisabled=null==e.selectedValue}),n._val2.isDisabled=!0,n._cmb2.selectedIndexChanged.addHandler(function(e,t){n._val2.isDisabled=null==e.selectedValue});var o=n.hostElement;return n.addEventListener(o,"change",n._btnAndOrChanged.bind(n)),n.addEventListener(o,"keydown",n._keydown.bind(n)),n.updateEditor(),n}return __extends(t,e),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),t.prototype.updateEditor=function(){var e=this._filter.condition1,t=this._filter.condition2;this._cmb1.selectedValue=e.operator,this._cmb2.selectedValue=t.operator,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)):(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)},t.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(t.prototype,"isEditorClear",{get:function(){return null==this._cmb1.selectedValue&&!this._val1.text&&null==this._cmb2.selectedValue&&!this._val2.text},enumerable:!0,configurable:!0}),t.prototype.updateFilter=function(){var e=this._filter.condition1,t=this._filter.condition2;e.operator=this._cmb1.selectedValue,t.operator=this._cmb2.selectedValue,"value"in this._val1?(e.value=this._val1.value,t.value=this._val2.value):(e.value=this._val1.selectedValue,t.value=this._val2.selectedValue),this._filter.and=this._btnAnd.checked},t.prototype._createOperatorCombo=function(e,t){var i=this._filter.column,n=culture.FlexGridFilter,r=n.stringOperators,l=this._filter.dataMap||i.dataMap,a=DataType;i.dataType==a.Date?r=n.dateOperators:i.dataType!=a.Number||l?i.dataType!=a.Boolean||l||(r=n.booleanOperators):r=n.numberOperators;var o=new input.ComboBox(e,{itemsSource:r,displayMemberPath:"name",selectedValuePath:"op"});return setAriaLabel(o.inputElement,t),o},t.prototype._createValueInput=function(e,t){var i=this._filter,n=i.column,r=i.dataMap||n.dataMap,l=null,a=DataType;return n.dataType==a.Date?(l=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(e):new input.InputDate(e):new input.InputTime(e)).format=n.format:n.dataType!=a.Number||r?(l=new input.ComboBox(e),r?(l.itemsSource=r.getDisplayValues(),l.isEditable=!0):n.dataType==a.Boolean&&(l.itemsSource=[!0,!1])):(l=new input.InputNumber(e)).format=n.format,l.isRequired=!1,setAriaLabel(l.inputElement,t),l},t.prototype._btnAndOrChanged=function(e){var t=e.target==this._btnAnd,i=e.target==this._btnOr;(t||i)&&(this._checkRadio(this._btnAnd,t),this._checkRadio(this._btnOr,i))},t.prototype._checkRadio=function(e,t){e.checked=t,e.setAttribute("aria-checked",t.toString()),e.setAttribute("tabindex",t?"1":"-1")},t.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 n=t?this._btnOr:this._btnAnd;n.click(),n.focus(),e.preventDefault()}},t.controlTemplate='<div><div wj-part="div-hdr"></div><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> <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>',t}(Control);export{ConditionFilterEditor};var ValueFilter=function(){function e(e){this._xValueSearch=!0,this._maxValues=250,this._sortValues=!0,this._col=e}return Object.defineProperty(e.prototype,"showValues",{get:function(){return this._values},set:function(e){this._values=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filterText",{get:function(){return this._filterText},set:function(e){this._filterText=asString(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){this._xValueSearch=asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxValues",{get:function(){return this._maxValues},set:function(e){this._maxValues=asNumber(e,!1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"uniqueValues",{get:function(){return this._uniqueValues},set:function(e){this._uniqueValues=asArray(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sortValues",{get:function(){return this._sortValues},set:function(e){this._sortValues=asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map=asType(e,DataMap,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return null!=this._values&&Object.keys(this._values).length>0},enumerable:!0,configurable:!0}),e.prototype.apply=function(e){var t=this.column;return!(t&&t._binding&&this._values&&Object.keys(this._values).length)||(e=t._binding.getValue(e),e=this.dataMap?this.dataMap.getDisplayValue(e):t.dataMap?t.dataMap.getDisplayValue(e):Globalize.format(e,t.format),void 0!=this._values[e])},e.prototype.clear=function(){this.showValues=null,this.filterText=null},e.prototype.implementsInterface=function(e){return"IColumnFilter"==e},e.prototype._getUniqueValues=function(e,t){var i=[];if(this.uniqueValues){for(var n=this.uniqueValues,r=0;r<n.length;r++){var l=n[r];i.push({value:l,text:l.toString()})}return i}var a={},o=e.collectionView,s=o?o.sourceCollection:[];if(t&&o&&o.sourceCollection&&o.filter){var u=this.showValues;this.showValues=null;var c=[];for(r=0;r<s.length;r++)o.filter(s[r])&&c.push(s[r]);s=c,this.showValues=u}for(r=0;r<s.length;r++){l=e._binding.getValue(s[r]);var d=this.dataMap?this.dataMap.getDisplayValue(l):e.dataMap?e.dataMap.getDisplayValue(l):Globalize.format(l,e.format);a[d]||(a[d]=!0,i.push({value:l,text:d}))}return i},e}();export{ValueFilter};var ValueFilterEditor=function(e){function t(t,i){var n=e.call(this,t)||this;n._filter=asType(i,ValueFilter,!1);var r=n.getTemplate();n.applyTemplate("wj-control wj-valuefilter-editor",r,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values"}),n._cbSelectAll.tabIndex=0;var l=culture.FlexGridFilter;setText(n._spSelectAll,l.selectAll);var a=n._view=new CollectionView;if(a.sortNullsFirst=!0,i.sortValues){var o=i.column.dataMap||i.dataMap?"text":"value",s=i.column.dataType!=DataType.Boolean;a.sortDescriptions.push(new SortDescription(o,s))}return a.filter=n._filterValues.bind(n),a.collectionChanged.addHandler(n._updateSelectAllCheck,n),n._filterText="",n._cmbFilter=new input.ComboBox(n._divFilter,{placeholder:l.search}),n._lbValues=new input.ListBox(n._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:n._view,itemFormatter:function(e,t){return t||l.null}}),setAriaLabel(n._cmbFilter.inputElement,l.ariaLabels.search),n._cmbFilter.textChanged.addHandler(n._filterTextChanged,n),n._cbSelectAll.addEventListener("click",n._cbSelectAllClicked.bind(n)),n.updateEditor(),n}return __extends(t,e),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),t.prototype.updateEditor=function(){var e=this,t=this._filter.column,i=this._filter._getUniqueValues(t,!0);this._lbValues.isContentHtml=t.isContentHtml;var n=this._filter.showValues;if(n&&0!=Object.keys(n).length){for(var r in n)for(l=0;l<i.length;l++)if(i[l].text==r){i[l].show=!0;break}}else for(var l=0;l<i.length;l++)i[l].show=!0;this._view.pageSize=20,this._view.sourceCollection=i,setTimeout(function(){e._view.pageSize=e._filter.maxValues,e._cmbFilter.text=e._filter.filterText||"",e._filterText=e._cmbFilter.text.toLowerCase()})},t.prototype.clearEditor=function(e){void 0===e&&(e=!0),this._cmbFilter.text="",this._filterText="",this._view.pageSize=0,this._view.refresh(),this._view.items.forEach(function(t){t.show=e}),this._view.pageSize=this._filter.maxValues},Object.defineProperty(t.prototype,"isEditorClear",{get:function(){return!this._filterText&&!this._cbSelectAll.indeterminate},enumerable:!0,configurable:!0}),t.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 n=t[i];n.show&&(e[n.text]=!0)}}var r=this._filter;r.showValues=e,r.filterText=""},t.prototype._getItems=function(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection},t.prototype._filterTextChanged=function(){var e=this;this._toText&&clearTimeout(this._toText),this._toText=setTimeout(function(){var t=e._cmbFilter.text.toLowerCase(),i=t!=e._filterText;e._filterText=t,e._view.refresh(),i&&(e._filter.exclusiveValueSearch?(e._cbSelectAll.checked=!0,e._cbSelectAllClicked()):e._updateSelectAllCheck())},300)},t.prototype._filterValues=function(e){return!this._filterText||!(!e||!e.text)&&e.text.toLowerCase().indexOf(this._filterText)>-1},t.prototype._cbSelectAllClicked=function(){for(var e=this._cbSelectAll.checked,t=this._divValues.scrollTop,i=this._getItems(),n=0;n<i.length;n++)i[n].show=e;this._view.refresh(),this._divValues.scrollTop=t},t.prototype._updateSelectAllCheck=function(){for(var e=0,t=this._getItems(),i=0;i<t.length;i++)t[i].show&&e++;var n=this._cbSelectAll;0==e?(n.checked=!1,n.indeterminate=!1):e==t.length?(n.checked=!0,n.indeterminate=!1):n.indeterminate=!0},t.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>',t}(Control);export{ValueFilterEditor};var ColumnFilter=function(){function e(e,t){this._owner=e,this._col=t,this._valueFilter=new ValueFilter(t),this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch,this._conditionFilter=new ConditionFilter(t)}return Object.defineProperty(e.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(e.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(e.prototype,"valueFilter",{get:function(){return this._valueFilter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"conditionFilter",{get:function(){return this._conditionFilter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return this._conditionFilter.isActive||this._valueFilter.isActive},enumerable:!0,configurable:!0}),e.prototype.apply=function(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)},e.prototype.clear=function(){this._valueFilter.clear(),this._conditionFilter.clear()},e.prototype.implementsInterface=function(e){return"IColumnFilter"==e},e}();export{ColumnFilter};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 e(e,t){this._showIcons=!0,this._showSort=!0,this._defFilterType=FilterType.Both,this._xValueSearch=!0,this.filterApplied=new Event,this.filterChanging=new Event,this.filterChanged=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(),t&©(this,t)}return Object.defineProperty(e.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filterColumns",{get:function(){return this._filterColumns},set:function(e){this._filterColumns=asArray(e),this.clear()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showFilterIcons",{get:function(){return this._showIcons},set:function(e){e!=this.showFilterIcons&&(this._showIcons=asBoolean(e),this._g&&this._g.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showSortButtons",{get:function(){return this._showSort},set:function(e){this._showSort=asBoolean(e)},enumerable:!0,configurable:!0}),e.prototype.getColumnFilter=function(e,t){void 0===t&&(t=!0),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 n=new ColumnFilter(this,e);return this._filters.push(n),n}return null},Object.defineProperty(e.prototype,"defaultFilterType",{get:function(){return this._defFilterType},set:function(e){(e=asEnum(e,FilterType,!1))!=this.defaultFilterType&&(this._defFilterType=e,this._g.invalidate(),this.clear())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){this._xValueSearch=asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filterDefinition",{get:function(){var e=this,t={defaultFilterType:this.defaultFilterType,filters:[]};return this._filters.forEach(function(i){var n=i.conditionFilter,r=i.valueFilter,l=r.uniqueValues&&r.uniqueValues.length;if(i&&i.column&&i.column.binding&&(i.isActive||l||i.filterType!=e.defaultFilterType)){var a={binding:i.column.binding};if(n.isActive){var o=n.condition1,s=n.condition2;a={binding:i.column.binding,type:"condition",condition1:{operator:o.operator,value:o.value},and:n.and,condition2:{operator:s.operator,value:s.value}}}else(r.isActive||l)&&(a={binding:i.column.binding,type:"value",uniqueValues:r.uniqueValues,sortValues:r.sortValues,maxValues:r.maxValues,exclusiveValueSearch:r.exclusiveValueSearch,showValues:r.showValues});i.filterType!=e.defaultFilterType&&(a.filterType=i.filterType),t.filters.push(a)}}),JSON.stringify(t)},set:function(e){if(e=asString(e),this.clear(),e){var t=JSON.parse(e);this.defaultFilterType=t.defaultFilterType;for(var i=function(e){var i=t.filters[e],r=n._g.getColumn(i.binding),l=n.getColumnFilter(r,!0);if(l)switch(null!=i.filterType&&(l.filterType=asEnum(i.filterType,FilterType)),i.type){case"condition":var a=l.conditionFilter;a.condition1.value=r.dataType==DataType.Date?changeType(i.condition1.value,r.dataType,null):i.condition1.value,a.condition1.operator=i.condition1.operator,a.and=i.and,a.condition2.value=r.dataType==DataType.Date?changeType(i.condition2.value,r.dataType,null):i.condition2.value,a.condition2.operator=i.condition2.operator;break;case"value":var o=l.valueFilter;o.uniqueValues=i.uniqueValues,["sortValues","maxValues","exclusiveValueSearch"].forEach(function(e){null!=i[e]&&(o[e]=i[e])}),o.showValues=i.showValues}},n=this,r=0;r<t.filters.length;r++)i(r)}this.apply()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activeEditor",{get:function(){return Control.getControl(this._divEdt)},enumerable:!0,configurable:!0}),e.prototype.editColumnFilter=function(e,t,i){var n=this;this.closeEditor(),e=this._asColumn(e);var r=this._g,l=new CellRangeEventArgs(r.cells,new CellRange(-1,e.index));if(this.onFilterChanging(l)){l.cancel=!0;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,r.rightToLeft&&(a.dir="rtl"),s.filterChanged.addHandler(function(){l.cancel=!1,setTimeout(function(){l.cancel||n.apply()})}),s.buttonClicked.addHandler(function(){n.closeEditor(),r.focus(),n.onFilterChanged(l)}),s.lostFocus.addHandler(function(){setTimeout(function(){var e=Control.getControl(n._divEdt);e&&!e.containsFocus()&&n.closeEditor()},10)});var u=t?t.col:e.index;t||r.columns[u].binding==e.binding||(u=r.selection.leftCol),r._edtHdl._commitRowEdits(),r.scrollIntoView(-1,u,!0);var c=r.columnHeaders,d=t&&t.panel==c?t.row:c.rows.length-1,p=u,h=c.getCellBoundingRect(d,p),f=i||c.getCellElement(d,p);f?showPopup(a,f,!1,!1,!1):showPopup(a,h),this._setAriaExpanded(f,!0),this._setAriaExpanded(r.cells.getCellElement(-1,p),!0);for(var _=s.hostElement.querySelectorAll("input"),v=0;v<_.length;v++){var b=_[v];if(b.offsetHeight>0&&b.tabIndex>-1&&!b.disabled){b.focus();break}}s.containsFocus()||s.focus()}else this._divEdt=this._edtCol=null},e.prototype._setAriaExpanded=function(t,i){if(t){var n=t.querySelector("."+e._WJC_FILTER);setAttribute(n,"aria-expanded",i)}},e.prototype.closeEditor=function(){var e=this._g,t=Control.getControl(this._divEdt),i=this._edtCol;if(t&&hidePopup(t.hostElement,function(){t.dispose()}),i){var n=e.columnHeaders,r=n.rows.length?n.getCellElement(n.rows.length-1,i.index):null;this._setAriaExpanded(r,!1),r=e.cells.getCellElement(-1,i.index),this._setAriaExpanded(r,!1)}this._divEdt=null,this._edtCol=null},e.prototype.apply=function(){var e=this._g.collectionView;if(e){var t=this._g.editableCollectionView;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()},e.prototype.clear=function(){this._filters.length&&(this._filters=[],this.apply())},e.prototype.onFilterApplied=function(e){this.filterApplied.raise(this,e)},e.prototype.onFilterChanging=function(e){return this.filterChanging.raise(this,e),!e.cancel},e.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)},e.prototype._asColumn=function(e){return isString(e)?this._g.getColumn(e):isNumber(e)?this._g.columns[e]:asType(e,Column,!1)},e.prototype._filter=function(e){for(var t=0;t<this._filters.length;t++)if(!this._filters[t].apply(e))return!1;return!0},e.prototype._formatItem=function(e,t){if(t.panel==e.columnHeaders){var i=this._g,n=i.getMergedRange(t.panel,t.row,t.col)||new CellRange(t.row,t.col),r=i.columns[n.col],l=i._getBindingColumn(t.panel,t.row,r),a=t.cell;if(n.row2==t.panel.rows.length-1||r!=l){var o=this.getColumnFilter(l,this.defaultFilterType!=FilterType.None);this._filterColumns&&this._filterColumns.indexOf(l.binding)<0&&(o=null),o?(toggleClass(a,"wj-filter-on",o.isActive),toggleClass(a,"wj-filter-off",!o.isActive)):(removeClass(a,"wj-filter-on"),removeClass(a,"wj-filter-off")),o&&o.filterType!=FilterType.None&&(this._showIcons&&this._addFilterButton(l,o,a),0==t.row&&(a=i.cells.getCellElement(-1,t.col))&&this._addFilterButton(r,o,a))}}},e.prototype._addFilterButton=function(t,i,n){var r=e._WJC_FILTER,l=createElement('<button class="wj-btn wj-btn-glyph wj-right '+r+'" type="button" tabindex="-1"><span class="wj-glyph-filter"></span></button>');setAriaLabel(l,culture.FlexGridFilter.ariaLabels.edit+" "+t.header),setAttribute(l,"aria-haspopup","dialog"),setAttribute(l,"aria-expanded",!1),setAttribute(l,"aria-describedby",t.describedById),setAttribute(l,"aria-pressed",i.isActive),n.querySelector("."+r)||(1==n.children.length&&(n=n.querySelector("div")||n),n.appendChild(l))},e.prototype._mousedown=function(e){this._toggleEditor(e)&&(this._tmd=!0,e.stopPropagation(),e.preventDefault())},e.prototype._click=function(e){(this._tmd||this._toggleEditor(e))&&(e.stopPropagation(),e.preventDefault()),this._tmd=!1},e.prototype._toggleEditor=function(t){var i=this;if(this._tmd=!1,!t.defaultPrevented&&0==t.button)if(closestClass(t.target,e._WJC_FILTER)){var n=this._g,r=n.hitTest(t.target);if(r.panel||(r=n.hitTest(t)),r.panel==n.columnHeaders||r.panel==n.cells&&-1==r.row){var l=n.columns[r.col],a=n._getBindingColumn(r.panel,r.row,l);return this._divEdt&&this._edtCol==a?(this.closeEditor(),n.focus()):setTimeout(function(){i.editColumnFilter(a,r)},this._divEdt?100:0),!0}}else this.closeEditor();return!1},e.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,n=i.col>-1?t.columns[i.col]:null,r=n?t._getBindingColumn(t.cells,i.row,n):null;r&&!r.dataMap&&this.getColumnFilter(r,!0)&&(this.editColumnFilter(r),e.preventDefault(),e.stopPropagation())}},e._WJC_FILTER="wj-elem-filter",e}();export{FlexGridFilter};_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){function t(t,i,n){void 0===n&&(n=!0);var r=e.call(this,t,null,!0)||this;r.filterChanged=new Event,r.buttonClicked=new Event,r._filter=asType(i,ColumnFilter);var l=r.getTemplate();r.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=r.hostElement,u=r.filter.column,c=u.grid.collectionView;setAttribute(s,"role","dialog"),setAriaLabel(s,o.dialog+" "+u.header),setAriaLabel(r._btnAsc,o.asc),setAriaLabel(r._btnDsc,o.dsc),setText(r._btnAsc,a.ascending),setText(r._btnDsc,a.descending),setText(r._aVal,a.values),setText(r._aCnd,a.conditions),setText(r._btnApply,a.apply),setText(r._btnCancel,a.cancel),setText(r._btnClear,a.clear);var d=r.filter.conditionFilter.isActive||0==(i.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;r._showFilter(d),n&&c&&c.canSort||(r._divSort.style.display="none");var p=r._btnClicked.bind(r);return r._btnApply.addEventListener("click",p),r._btnCancel.addEventListener("click",p),r._btnClear.addEventListener("click",p),r._btnAsc.addEventListener("click",p),r._btnDsc.addEventListener("click",p),r._aVal.addEventListener("click",p),r._aCnd.addEventListener("click",p),s.addEventListener("keydown",function(e){if(!e.defaultPrevented){var t=e.target.tagName.match(/^(a|button)$/i);switch(e.keyCode){case Key.Space:t&&(r._btnClicked(e),e.preventDefault());break;case Key.Enter:t?r._btnClicked(e):(r.updateFilter(),r.onFilterChanged(),r.onButtonClicked()),e.preventDefault();break;case Key.Escape:r.onButtonClicked(),e.preventDefault();break;case Key.Tab:moveFocus(r.hostElement,e.shiftKey?-1:1),e.preventDefault()}}}),r}return __extends(t,e),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),t.prototype.updateEditor=function(){this._edtVal&&this._edtVal.updateEditor(),this._edtCnd&&this._edtCnd.updateEditor()},t.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()}},t.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)},t.prototype.onButtonClicked=function(e){this.buttonClicked.raise(this,e)},t.prototype._handleResize=function(){this.isTouching||this._wasTouching||this.onButtonClicked()},t.prototype._showFilter=function(e){this._wasTouching=this.isTouching,e==FilterType.Value&&null==this._edtVal&&(this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter)),e==FilterType.Condition&&null==this._edtCnd&&(this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter)),0!=(e&this.filter.filterType)&&(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()):(this._divEdtVal.style.display="none",this._divEdtCnd.style.display="",this._enableLink(this._aVal,!0),this._enableLink(this._aCnd,!1),this._edtCnd.focus()));var t=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:t.display="none";break;default:t.display=""}},t.prototype._enableLink=function(e,t){toggleClass(e,"wj-state-disabled",!t),setAttribute(e,"href",t?"":null),setAttribute(e,"disabled",t?null:"disabled")},t.prototype._getFilterType=function(){var e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition},t.prototype._btnClicked=function(e){var t=e.target;if(e.preventDefault(),e.stopPropagation(),!hasClass(t,"wj-state-disabled")){if(t==this._aVal)return this._showFilter(FilterType.Value),void moveFocus(this._edtVal.hostElement,0);if(t==this._aCnd)return this._showFilter(FilterType.Condition),void moveFocus(this._edtCnd.hostElement,0);if(t==this._btnAsc||t==this._btnDsc){var i=this.filter.column,n=i.sortMemberPath?i.sortMemberPath:i.binding,r=i.grid.collectionView,l=new SortDescription(n,e.target==this._btnAsc);r.sortDescriptions.deferUpdate(function(){r.sortDescriptions.clear(),r.sortDescriptions.push(l)})}t==this._btnApply?(this.updateFilter(),this.onFilterChanged()):t==this._btnClear?this.filter.isActive&&(this.filter.clear(),this.onFilterChanged()):this.updateEditor(),this.onButtonClicked()}},t.controlTemplate='<div><div wj-part="div-sort"><button wj-part="btn-asc" class="wj-btn" style="min-width:95px"></button> <button wj-part="btn-dsc" class="wj-btn" style="min-width:95px"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a> | <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> <button wj-part="btn-cancel" class="wj-btn"></button> <button wj-part="btn-clear" class="wj-btn"></button></div>',t}(Control);export{ColumnFilterEditor};_registerModule("wijmo.grid.filter",selfModule); | ||
var __extends=this&&this.__extends||function(){var e=function(t,i){return(e=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])})(t,i)};return function(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();import{Column,DataMap,FlexGrid,CellRange,CellRangeEventArgs}from"@grapecity/wijmo.grid";import{Globalize,asString,asNumber,asArray,asBoolean,asType,asEnum,isString,isDate,DateTime,culture,assert,isNumber,Control,Event,DataType,Key,copy,changeType,createElement,setAttribute,showPopup,hidePopup,isFunction,toggleClass,removeClass,closestClass,setAriaLabel,setText,CollectionView,SortDescription,_addCultureInfo,moveFocus,hasClass,_registerModule}from"@grapecity/wijmo";import*as input from"@grapecity/wijmo.input";import*as selfModule from"@grapecity/wijmo.grid.filter";var FilterCondition=function(){function e(e){this._op=null,this._filter=e}return Object.defineProperty(e.prototype,"operator",{get:function(){return this._op},set:function(e){this._op=asEnum(e,Operator,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._val},set:function(e){if(this._val=e,this._strVal=isString(e)?e.toString().toLowerCase():null,this._mapVal=null,this._filter){var t=this._filter.dataMap||this._filter.column.dataMap;t&&(this._mapVal=t.getDisplayValue(e),isString(this._mapVal)&&(this._strVal=this._mapVal=this._mapVal.toLowerCase()))}},enumerable:!0,configurable:!0}),Object.defineProperty(e.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}),e.prototype.clear=function(){this.operator=null,this.value=null},e.prototype.apply=function(t,i,n){var r=this._mapVal||this._strVal||this._val;isString(t)&&(t=t.toLowerCase()),isString(r)&&null==t&&(t=""),isDate(r)&&(i?r=DateTime.fromDateTime(r,e._refDateTime):n&&(r=DateTime.fromDateTime(e._refDateTime,r)));var l=Operator;switch(this._op){case null:return!0;case l.EQ:return null!=t&&null!=r?t.valueOf()==r.valueOf():t==r;case l.NE:return null!=t&&null!=r?t.valueOf()!=r.valueOf():t!=r;case l.GT:return t>r;case l.GE:return t>=r;case l.LT:return t<r;case l.LE:return t<=r;case l.BW:return!(null==this._strVal||!isString(t))&&0==t.indexOf(this._strVal);case l.EW:return!!(null!=this._strVal&&isString(t)&&t.length>=this._strVal.length)&&t.substr(t.length-this._strVal.length)==r;case l.CT:return!(null==this._strVal||!isString(t))&&t.indexOf(this._strVal)>-1;case l.NC:return!(null==this._strVal||!isString(t))&&t.indexOf(this._strVal)<0}throw"Unknown operator"},e._refDateTime=new Date(2e3,0,1,0,0,0),e}();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={}));var ConditionFilter=function(){function e(e){this._c1=new FilterCondition(this),this._c2=new FilterCondition(this),this._and=!0,this._col=e}return Object.defineProperty(e.prototype,"condition1",{get:function(){return this._c1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"condition2",{get:function(){return this._c2},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"and",{get:function(){return this._and},set:function(e){this._and=asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map=asType(e,DataMap,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return this._c1.isActive||this._c2.isActive},enumerable:!0,configurable:!0}),e.prototype.apply=function(e){var t=this._col,i=this._c1,n=this._c2,r=!1,l=!1;if(!t||!t._binding||!this.isActive)return!0;if(e=t._binding.getValue(e),this.dataMap)e=this.dataMap.getDisplayValue(e);else if(t.dataMap)e=t.dataMap.getDisplayValue(e);else if(isDate(e))if(r=!this._hasTimePart(),l=!this._hasDatePart(),assert(!r||!l,"Filter should have either date or time."),r){Date();e=DateTime.fromDateTime(e,FilterCondition._refDateTime)}else l&&(e=DateTime.fromDateTime(FilterCondition._refDateTime,e));else isNumber(e)&&(e=Globalize.parseFloat(Globalize.format(e,t.format)));var a=i.apply(e,r,l),o=n.apply(e,r,l);return i.isActive&&n.isActive?this._and?a&&o:a||o:i.isActive?a:!n.isActive||o},e.prototype.clear=function(){this._c1.clear(),this._c2.clear(),this.and=!0},e.prototype._hasDatePart=function(){var e=this._col.format;return!e||(e=culture.Globalize.calendar.patterns[e]||e,/[yMd]+/.test(e))},e.prototype._hasTimePart=function(){var e=this._col.format;return!!e&&(e=culture.Globalize.calendar.patterns[e]||e,/[Hmst]+/.test(e))},e.prototype.implementsInterface=function(e){return"IColumnFilter"==e},e}();export{ConditionFilter};var ConditionFilterEditor=function(e){function t(t,i){var n=e.call(this,t)||this;n._filter=asType(i,ConditionFilter,!1);var r=n.getTemplate();n.applyTemplate("wj-control wj-conditionfilter-editor",r,{_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(n._btnAnd,a.and),setAriaLabel(n._btnOr,a.or),setText(n._divHdr,l.header),setText(n._spAnd,l.and),setText(n._spOr,l.or),n._cmb1=n._createOperatorCombo(n._divCmb1,a.op1),n._cmb2=n._createOperatorCombo(n._divCmb2,a.op2),n._val1=n._createValueInput(n._divVal1,a.val1),n._val2=n._createValueInput(n._divVal2,a.val2),n._val1.isDisabled=!0,n._cmb1.selectedIndexChanged.addHandler(function(e,t){n._val1.isDisabled=null==e.selectedValue}),n._val2.isDisabled=!0,n._cmb2.selectedIndexChanged.addHandler(function(e,t){n._val2.isDisabled=null==e.selectedValue});var o=n.hostElement;return n.addEventListener(o,"change",n._btnAndOrChanged.bind(n)),n.addEventListener(o,"keydown",n._keydown.bind(n)),n.updateEditor(),n}return __extends(t,e),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),t.prototype.updateEditor=function(){var e=this._filter.condition1,t=this._filter.condition2;this._cmb1.selectedValue=e.operator,this._cmb2.selectedValue=t.operator,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)):(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)},t.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(t.prototype,"isEditorClear",{get:function(){return null==this._cmb1.selectedValue&&!this._val1.text&&null==this._cmb2.selectedValue&&!this._val2.text},enumerable:!0,configurable:!0}),t.prototype.updateFilter=function(){var e=this._filter.condition1,t=this._filter.condition2;e.operator=this._cmb1.selectedValue,t.operator=this._cmb2.selectedValue,"value"in this._val1?(e.value=this._val1.value,t.value=this._val2.value):(e.value=this._val1.selectedValue,t.value=this._val2.selectedValue),this._filter.and=this._btnAnd.checked},t.prototype._createOperatorCombo=function(e,t){var i=this._filter.column,n=culture.FlexGridFilter,r=n.stringOperators,l=this._filter.dataMap||i.dataMap,a=DataType;i.dataType==a.Date?r=n.dateOperators:i.dataType!=a.Number||l?i.dataType!=a.Boolean||l||(r=n.booleanOperators):r=n.numberOperators;var o=new input.ComboBox(e,{itemsSource:r,displayMemberPath:"name",selectedValuePath:"op"});return setAriaLabel(o.inputElement,t),o},t.prototype._createValueInput=function(e,t){var i=this._filter,n=i.column,r=i.dataMap||n.dataMap,l=null,a=DataType;return n.dataType==a.Date?(l=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(e):new input.InputDate(e):new input.InputTime(e)).format=n.format:n.dataType!=a.Number||r?(l=new input.ComboBox(e),r?(l.itemsSource=r.getDisplayValues(),l.isEditable=!0):n.dataType==a.Boolean&&(l.itemsSource=[!0,!1])):(l=new input.InputNumber(e)).format=n.format,l.isRequired=!1,setAriaLabel(l.inputElement,t),l},t.prototype._btnAndOrChanged=function(e){var t=e.target==this._btnAnd,i=e.target==this._btnOr;(t||i)&&(this._checkRadio(this._btnAnd,t),this._checkRadio(this._btnOr,i))},t.prototype._checkRadio=function(e,t){e.checked=t,e.setAttribute("aria-checked",t.toString()),e.setAttribute("tabindex",t?"1":"-1")},t.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 n=t?this._btnOr:this._btnAnd;n.click(),n.focus(),e.preventDefault()}},t.controlTemplate='<div><div wj-part="div-hdr"></div><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> <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>',t}(Control);export{ConditionFilterEditor};var ValueFilter=function(){function e(e){this._xValueSearch=!0,this._maxValues=250,this._sortValues=!0,this._col=e}return Object.defineProperty(e.prototype,"showValues",{get:function(){return this._values},set:function(e){this._values=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filterText",{get:function(){return this._filterText},set:function(e){this._filterText=asString(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){this._xValueSearch=asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxValues",{get:function(){return this._maxValues},set:function(e){this._maxValues=asNumber(e,!1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"uniqueValues",{get:function(){return this._uniqueValues},set:function(e){this._uniqueValues=asArray(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sortValues",{get:function(){return this._sortValues},set:function(e){this._sortValues=asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map=asType(e,DataMap,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return null!=this._values&&Object.keys(this._values).length>0},enumerable:!0,configurable:!0}),e.prototype.apply=function(e){var t=this.column;return!(t&&t._binding&&this._values&&Object.keys(this._values).length)||(e=t._binding.getValue(e),e=this.dataMap?this.dataMap.getDisplayValue(e):t.dataMap?t.dataMap.getDisplayValue(e):Globalize.format(e,t.format),void 0!=this._values[e])},e.prototype.clear=function(){this.showValues=null,this.filterText=null},e.prototype.implementsInterface=function(e){return"IColumnFilter"==e},e.prototype._getUniqueValues=function(e,t){var i=[];if(this.uniqueValues){for(var n=this.uniqueValues,r=0;r<n.length;r++){var l=n[r];i.push({value:l,text:l.toString()})}return i}var a={},o=e.collectionView,s=o?o.sourceCollection:[];if(t&&o&&o.sourceCollection&&o.filter){var u=this.showValues;this.showValues=null;var c=[];for(r=0;r<s.length;r++)o.filter(s[r])&&c.push(s[r]);s=c,this.showValues=u}for(r=0;r<s.length;r++){l=e._binding.getValue(s[r]);var d=this.dataMap?this.dataMap.getDisplayValue(l):e.dataMap?e.dataMap.getDisplayValue(l):Globalize.format(l,e.format);a[d]||(a[d]=!0,i.push({value:l,text:d}))}return i},e}();export{ValueFilter};var ValueFilterEditor=function(e){function t(t,i){var n=e.call(this,t)||this;n._filter=asType(i,ValueFilter,!1);var r=n.getTemplate();n.applyTemplate("wj-control wj-valuefilter-editor",r,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values"}),n._cbSelectAll.tabIndex=0;var l=culture.FlexGridFilter;setText(n._spSelectAll,l.selectAll);var a=n._view=new CollectionView;if(a.sortNullsFirst=!0,i.sortValues){var o=i.column.dataMap||i.dataMap?"text":"value",s=i.column.dataType!=DataType.Boolean;a.sortDescriptions.push(new SortDescription(o,s))}return a.filter=n._filterValues.bind(n),a.collectionChanged.addHandler(n._updateSelectAllCheck,n),n._filterText="",n._cmbFilter=new input.ComboBox(n._divFilter,{placeholder:l.search}),n._lbValues=new input.ListBox(n._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:n._view,itemFormatter:function(e,t){return t||l.null}}),setAriaLabel(n._cmbFilter.inputElement,l.ariaLabels.search),n._cmbFilter.textChanged.addHandler(n._filterTextChanged,n),n._cbSelectAll.addEventListener("click",n._cbSelectAllClicked.bind(n)),n.updateEditor(),n}return __extends(t,e),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),t.prototype.updateEditor=function(){var e=this,t=this._filter.column,i=this._filter._getUniqueValues(t,!0);this._lbValues.isContentHtml=t.isContentHtml;var n=this._filter.showValues;if(n&&0!=Object.keys(n).length){for(var r in n)for(l=0;l<i.length;l++)if(i[l].text==r){i[l].show=!0;break}}else for(var l=0;l<i.length;l++)i[l].show=!0;this._view.pageSize=20,this._view.sourceCollection=i,setTimeout(function(){e._view.pageSize=e._filter.maxValues,e._cmbFilter.text=e._filter.filterText||"",e._filterText=e._cmbFilter.text.toLowerCase()})},t.prototype.clearEditor=function(e){void 0===e&&(e=!0),this._cmbFilter.text="",this._filterText="",this._view.pageSize=0,this._view.refresh(),this._view.items.forEach(function(t){t.show=e}),this._view.pageSize=this._filter.maxValues},Object.defineProperty(t.prototype,"isEditorClear",{get:function(){return!this._filterText&&!this._cbSelectAll.indeterminate},enumerable:!0,configurable:!0}),t.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 n=t[i];n.show&&(e[n.text]=!0)}}var r=this._filter;r.showValues=e,r.filterText=""},t.prototype._getItems=function(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection},t.prototype._filterTextChanged=function(){var e=this;this._toText&&clearTimeout(this._toText),this._toText=setTimeout(function(){var t=e._cmbFilter.text.toLowerCase(),i=t!=e._filterText;e._filterText=t,e._view.refresh(),i&&(e._filter.exclusiveValueSearch?(e._cbSelectAll.checked=!0,e._cbSelectAllClicked()):e._updateSelectAllCheck())},300)},t.prototype._filterValues=function(e){return!this._filterText||!(!e||!e.text)&&e.text.toLowerCase().indexOf(this._filterText)>-1},t.prototype._cbSelectAllClicked=function(){for(var e=this._cbSelectAll.checked,t=this._divValues.scrollTop,i=this._getItems(),n=0;n<i.length;n++)i[n].show=e;this._view.refresh(),this._divValues.scrollTop=t},t.prototype._updateSelectAllCheck=function(){for(var e=0,t=this._getItems(),i=0;i<t.length;i++)t[i].show&&e++;var n=this._cbSelectAll;0==e?(n.checked=!1,n.indeterminate=!1):e==t.length?(n.checked=!0,n.indeterminate=!1):n.indeterminate=!0},t.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>',t}(Control);export{ValueFilterEditor};var ColumnFilter=function(){function e(e,t){this._owner=e,this._col=t,this._valueFilter=new ValueFilter(t),this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch,this._conditionFilter=new ConditionFilter(t)}return Object.defineProperty(e.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(e.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(e.prototype,"valueFilter",{get:function(){return this._valueFilter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"conditionFilter",{get:function(){return this._conditionFilter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return this._conditionFilter.isActive||this._valueFilter.isActive},enumerable:!0,configurable:!0}),e.prototype.apply=function(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)},e.prototype.clear=function(){this._valueFilter.clear(),this._conditionFilter.clear()},e.prototype.implementsInterface=function(e){return"IColumnFilter"==e},e}();export{ColumnFilter};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 e(e,t){this._showIcons=!0,this._showSort=!0,this._defFilterType=FilterType.Both,this._xValueSearch=!0,this.filterApplied=new Event,this.filterChanging=new Event,this.filterChanged=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(),t&©(this,t)}return Object.defineProperty(e.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filterColumns",{get:function(){return this._filterColumns},set:function(e){this._filterColumns=asArray(e),this.clear()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showFilterIcons",{get:function(){return this._showIcons},set:function(e){e!=this.showFilterIcons&&(this._showIcons=asBoolean(e),this._g&&this._g.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showSortButtons",{get:function(){return this._showSort},set:function(e){this._showSort=asBoolean(e)},enumerable:!0,configurable:!0}),e.prototype.getColumnFilter=function(e,t){void 0===t&&(t=!0),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 n=new ColumnFilter(this,e);return this._filters.push(n),n}return null},Object.defineProperty(e.prototype,"defaultFilterType",{get:function(){return this._defFilterType},set:function(e){(e=asEnum(e,FilterType,!1))!=this.defaultFilterType&&(this._defFilterType=e,this._g.invalidate(),this.clear())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){this._xValueSearch=asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filterDefinition",{get:function(){var e=this,t={defaultFilterType:this.defaultFilterType,filters:[]};return this._filters.forEach(function(i){var n=i.conditionFilter,r=i.valueFilter,l=r.uniqueValues&&r.uniqueValues.length;if(i&&i.column&&i.column.binding&&(i.isActive||l||i.filterType!=e.defaultFilterType)){var a={binding:i.column.binding};if(n.isActive){var o=n.condition1,s=n.condition2;a={binding:i.column.binding,type:"condition",condition1:{operator:o.operator,value:o.value},and:n.and,condition2:{operator:s.operator,value:s.value}}}else(r.isActive||l)&&(a={binding:i.column.binding,type:"value",uniqueValues:r.uniqueValues,sortValues:r.sortValues,maxValues:r.maxValues,exclusiveValueSearch:r.exclusiveValueSearch,showValues:r.showValues});i.filterType!=e.defaultFilterType&&(a.filterType=i.filterType),t.filters.push(a)}}),JSON.stringify(t)},set:function(e){if(e=asString(e),this.clear(),e){var t=JSON.parse(e);this.defaultFilterType=t.defaultFilterType;for(var i=function(e){var i=t.filters[e],r=n._g.getColumn(i.binding),l=n.getColumnFilter(r,!0);if(l)switch(null!=i.filterType&&(l.filterType=asEnum(i.filterType,FilterType)),i.type){case"condition":var a=l.conditionFilter;a.condition1.value=r.dataType==DataType.Date?changeType(i.condition1.value,r.dataType,null):i.condition1.value,a.condition1.operator=i.condition1.operator,a.and=i.and,a.condition2.value=r.dataType==DataType.Date?changeType(i.condition2.value,r.dataType,null):i.condition2.value,a.condition2.operator=i.condition2.operator;break;case"value":var o=l.valueFilter;o.uniqueValues=i.uniqueValues,["sortValues","maxValues","exclusiveValueSearch"].forEach(function(e){null!=i[e]&&(o[e]=i[e])}),o.showValues=i.showValues}},n=this,r=0;r<t.filters.length;r++)i(r)}this.apply()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activeEditor",{get:function(){return Control.getControl(this._divEdt)},enumerable:!0,configurable:!0}),e.prototype.editColumnFilter=function(e,t,i){var n=this;this.closeEditor(),e=this._asColumn(e);var r=this._g,l=new CellRangeEventArgs(r.cells,new CellRange(-1,e.index));if(this.onFilterChanging(l)){l.cancel=!0;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,r.rightToLeft&&(a.dir="rtl"),s.filterChanged.addHandler(function(){l.cancel=!1,setTimeout(function(){l.cancel||n.apply()})}),s.buttonClicked.addHandler(function(){n.closeEditor(),r.focus(),n.onFilterChanged(l)}),s.lostFocus.addHandler(function(){setTimeout(function(){var e=Control.getControl(n._divEdt);e&&!e.containsFocus()&&n.closeEditor()},10)});var u=t?t.col:e.index;t||r.columns[u].binding==e.binding||(u=r.selection.leftCol),r._edtHdl._commitRowEdits(),r.scrollIntoView(-1,u,!0);var c=r.columnHeaders,d=t&&t.panel==c?t.row:c.rows.length-1,p=u,h=c.getCellBoundingRect(d,p),f=i||c.getCellElement(d,p);f?showPopup(a,f,!1,!1,!1):showPopup(a,h),this._setAriaExpanded(f,!0),this._setAriaExpanded(r.cells.getCellElement(-1,p),!0);for(var _=s.hostElement.querySelectorAll("input"),v=0;v<_.length;v++){var b=_[v];if(b.offsetHeight>0&&b.tabIndex>-1&&!b.disabled){b.focus();break}}s.containsFocus()||s.focus()}else this._divEdt=this._edtCol=null},e.prototype._setAriaExpanded=function(t,i){if(t){var n=t.querySelector("."+e._WJC_FILTER);setAttribute(n,"aria-expanded",i)}},e.prototype.closeEditor=function(){var e=this._g,t=Control.getControl(this._divEdt),i=this._edtCol;if(t&&hidePopup(t.hostElement,function(){t.dispose()}),i){var n=e.columnHeaders,r=n.rows.length?n.getCellElement(n.rows.length-1,i.index):null;this._setAriaExpanded(r,!1),r=e.cells.getCellElement(-1,i.index),this._setAriaExpanded(r,!1)}this._divEdt=null,this._edtCol=null},e.prototype.apply=function(){var e=this._g.collectionView;if(e){var t=this._g.editableCollectionView;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()},e.prototype.clear=function(){this._filters.length&&(this._filters=[],this.apply())},e.prototype.onFilterApplied=function(e){this.filterApplied.raise(this,e)},e.prototype.onFilterChanging=function(e){return this.filterChanging.raise(this,e),!e.cancel},e.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)},e.prototype._asColumn=function(e){return isString(e)?this._g.getColumn(e):isNumber(e)?this._g.columns[e]:asType(e,Column,!1)},e.prototype._filter=function(e){for(var t=0;t<this._filters.length;t++)if(!this._filters[t].apply(e))return!1;return!0},e.prototype._formatItem=function(e,t){if(t.panel==e.columnHeaders){var i=this._g,n=i.getMergedRange(t.panel,t.row,t.col)||new CellRange(t.row,t.col),r=i.columns[n.col],l=i._getBindingColumn(t.panel,t.row,r),a=t.cell;if(n.row2==t.panel.rows.length-1||r!=l){var o=this.getColumnFilter(l,this.defaultFilterType!=FilterType.None);this._filterColumns&&this._filterColumns.indexOf(l.binding)<0&&(o=null),o?(toggleClass(a,"wj-filter-on",o.isActive),toggleClass(a,"wj-filter-off",!o.isActive)):(removeClass(a,"wj-filter-on"),removeClass(a,"wj-filter-off")),o&&o.filterType!=FilterType.None&&(this._showIcons&&this._addFilterButton(l,o,a),0==t.row&&(a=i.cells.getCellElement(-1,t.col))&&this._addFilterButton(r,o,a))}}},e.prototype._addFilterButton=function(t,i,n){var r=e._WJC_FILTER,l=createElement('<button class="wj-btn wj-btn-glyph wj-right '+r+'" type="button" tabindex="-1"><span class="wj-glyph-filter"></span></button>');setAriaLabel(l,culture.FlexGridFilter.ariaLabels.edit+" "+t.header),setAttribute(l,"aria-haspopup","dialog"),setAttribute(l,"aria-expanded",!1),setAttribute(l,"aria-describedby",t.describedById),setAttribute(l,"aria-pressed",i.isActive),n.querySelector("."+r)||(1==n.children.length&&(n=n.querySelector("div")||n),n.appendChild(l))},e.prototype._mousedown=function(e){this._toggleEditor(e)&&(this._tmd=!0,e.stopPropagation(),e.preventDefault())},e.prototype._click=function(e){(this._tmd||this._toggleEditor(e))&&(e.stopPropagation(),e.preventDefault()),this._tmd=!1},e.prototype._toggleEditor=function(t){var i=this;if(this._tmd=!1,!t.defaultPrevented&&0==t.button)if(closestClass(t.target,e._WJC_FILTER)){var n=this._g,r=n.hitTest(t.target);if(r.panel||(r=n.hitTest(t)),r.panel==n.columnHeaders||r.panel==n.cells&&-1==r.row){var l=n.columns[r.col],a=n._getBindingColumn(r.panel,r.row,l);return this._divEdt&&this._edtCol==a?(this.closeEditor(),n.focus()):setTimeout(function(){i.editColumnFilter(a,r)},this._divEdt?100:0),!0}}else this.closeEditor();return!1},e.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,n=i.col>-1?t.columns[i.col]:null,r=n?t._getBindingColumn(t.cells,i.row,n):null;r&&!r.dataMap&&this.getColumnFilter(r,!0)&&(this.editColumnFilter(r),e.preventDefault(),e.stopPropagation())}},e._WJC_FILTER="wj-elem-filter",e}();export{FlexGridFilter};_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){function t(t,i,n){void 0===n&&(n=!0);var r=e.call(this,t,null,!0)||this;r.filterChanged=new Event,r.buttonClicked=new Event,r._filter=asType(i,ColumnFilter);var l=r.getTemplate();r.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=r.hostElement,u=r.filter.column,c=u.grid.collectionView;setAttribute(s,"role","dialog"),setAriaLabel(s,o.dialog+" "+u.header),setAriaLabel(r._btnAsc,o.asc),setAriaLabel(r._btnDsc,o.dsc),setText(r._btnAsc,a.ascending),setText(r._btnDsc,a.descending),setText(r._aVal,a.values),setText(r._aCnd,a.conditions),setText(r._btnApply,a.apply),setText(r._btnCancel,a.cancel),setText(r._btnClear,a.clear);var d=r.filter.conditionFilter.isActive||0==(i.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;r._showFilter(d),n&&c&&c.canSort||(r._divSort.style.display="none");var p=r._btnClicked.bind(r);return r._btnApply.addEventListener("click",p),r._btnCancel.addEventListener("click",p),r._btnClear.addEventListener("click",p),r._btnAsc.addEventListener("click",p),r._btnDsc.addEventListener("click",p),r._aVal.addEventListener("click",p),r._aCnd.addEventListener("click",p),r.addEventListener(s,"keydown",function(e){if(!e.defaultPrevented){var t=e.target.tagName.match(/^(a|button)$/i);switch(e.keyCode){case Key.Space:t&&(r._btnClicked(e),e.preventDefault());break;case Key.Enter:t?r._btnClicked(e):(r.updateFilter(),r.onFilterChanged(),r.onButtonClicked()),e.preventDefault();break;case Key.Escape:r.onButtonClicked(),e.preventDefault();break;case Key.Tab:moveFocus(r.hostElement,e.shiftKey?-1:1),e.preventDefault()}}}),r.addEventListener(window,"resize",function(){r.isTouching||r._wasTouching||r.onButtonClicked()}),r}return __extends(t,e),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),t.prototype.updateEditor=function(){this._edtVal&&this._edtVal.updateEditor(),this._edtCnd&&this._edtCnd.updateEditor()},t.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()}},t.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)},t.prototype.onButtonClicked=function(e){this.buttonClicked.raise(this,e)},t.prototype._showFilter=function(e){this._wasTouching=this.isTouching,e==FilterType.Value&&null==this._edtVal&&(this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter)),e==FilterType.Condition&&null==this._edtCnd&&(this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter)),0!=(e&this.filter.filterType)&&(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()):(this._divEdtVal.style.display="none",this._divEdtCnd.style.display="",this._enableLink(this._aVal,!0),this._enableLink(this._aCnd,!1),this._edtCnd.focus()));var t=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:t.display="none";break;default:t.display=""}},t.prototype._enableLink=function(e,t){toggleClass(e,"wj-state-disabled",!t),setAttribute(e,"href",t?"":null),setAttribute(e,"disabled",t?null:"disabled")},t.prototype._getFilterType=function(){var e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition},t.prototype._btnClicked=function(e){var t=e.target;if(e.preventDefault(),e.stopPropagation(),!hasClass(t,"wj-state-disabled")){if(t==this._aVal)return this._showFilter(FilterType.Value),void moveFocus(this._edtVal.hostElement,0);if(t==this._aCnd)return this._showFilter(FilterType.Condition),void moveFocus(this._edtCnd.hostElement,0);if(t==this._btnAsc||t==this._btnDsc){var i=this.filter.column,n=i.sortMemberPath?i.sortMemberPath:i.binding,r=i.grid.collectionView,l=new SortDescription(n,e.target==this._btnAsc);r.sortDescriptions.deferUpdate(function(){r.sortDescriptions.clear(),r.sortDescriptions.push(l)})}t==this._btnApply?(this.updateFilter(),this.onFilterChanged()):t==this._btnClear?this.filter.isActive&&(this.filter.clear(),this.onFilterChanged()):this.updateEditor(),this.onButtonClicked()}},t.controlTemplate='<div><div wj-part="div-sort"><button wj-part="btn-asc" class="wj-btn" style="min-width:95px"></button> <button wj-part="btn-dsc" class="wj-btn" style="min-width:95px"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a> | <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> <button wj-part="btn-cancel" class="wj-btn"></button> <button wj-part="btn-clear" class="wj-btn"></button></div>',t}(Control);export{ColumnFilterEditor};_registerModule("wijmo.grid.filter",selfModule); |
/*! | ||
* | ||
* Wijmo Library 5.20191.599-nightly.d20190408.t120542 | ||
* Wijmo Library 5.20191.599-nightly.d20190408.t162215 | ||
* http://wijmo.com/ | ||
@@ -785,3 +785,2 @@ * | ||
onButtonClicked(e?: EventArgs): void; | ||
protected _handleResize(): void; | ||
_showFilter(filterType: FilterType): void; | ||
@@ -788,0 +787,0 @@ _enableLink(a: HTMLLinkElement, enable: boolean): void; |
/*! | ||
* | ||
* Wijmo Library 5.20191.599-nightly.d20190408.t120542 | ||
* Wijmo Library 5.20191.599-nightly.d20190408.t162215 | ||
* http://wijmo.com/ | ||
@@ -14,2 +14,2 @@ * | ||
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,i){return(e=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])})(t,i)};return function(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();Object.defineProperty(exports,"__esModule",{value:!0});var Operator,wijmo_grid_1=require("@grapecity/wijmo.grid"),wijmo_1=require("@grapecity/wijmo"),input=require("@grapecity/wijmo.input"),selfModule=require("@grapecity/wijmo.grid.filter"),FilterCondition=function(){function e(e){this._op=null,this._filter=e}return Object.defineProperty(e.prototype,"operator",{get:function(){return this._op},set:function(e){this._op=wijmo_1.asEnum(e,Operator,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._val},set:function(e){if(this._val=e,this._strVal=wijmo_1.isString(e)?e.toString().toLowerCase():null,this._mapVal=null,this._filter){var t=this._filter.dataMap||this._filter.column.dataMap;t&&(this._mapVal=t.getDisplayValue(e),wijmo_1.isString(this._mapVal)&&(this._strVal=this._mapVal=this._mapVal.toLowerCase()))}},enumerable:!0,configurable:!0}),Object.defineProperty(e.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}),e.prototype.clear=function(){this.operator=null,this.value=null},e.prototype.apply=function(t,i,n){var r=this._mapVal||this._strVal||this._val;wijmo_1.isString(t)&&(t=t.toLowerCase()),wijmo_1.isString(r)&&null==t&&(t=""),wijmo_1.isDate(r)&&(i?r=wijmo_1.DateTime.fromDateTime(r,e._refDateTime):n&&(r=wijmo_1.DateTime.fromDateTime(e._refDateTime,r)));var o=Operator;switch(this._op){case null:return!0;case o.EQ:return null!=t&&null!=r?t.valueOf()==r.valueOf():t==r;case o.NE:return null!=t&&null!=r?t.valueOf()!=r.valueOf():t!=r;case o.GT:return t>r;case o.GE:return t>=r;case o.LT:return t<r;case o.LE:return t<=r;case o.BW:return!(null==this._strVal||!wijmo_1.isString(t))&&0==t.indexOf(this._strVal);case o.EW:return!!(null!=this._strVal&&wijmo_1.isString(t)&&t.length>=this._strVal.length)&&t.substr(t.length-this._strVal.length)==r;case o.CT:return!(null==this._strVal||!wijmo_1.isString(t))&&t.indexOf(this._strVal)>-1;case o.NC:return!(null==this._strVal||!wijmo_1.isString(t))&&t.indexOf(this._strVal)<0}throw"Unknown operator"},e._refDateTime=new Date(2e3,0,1,0,0,0),e}();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={}));var ConditionFilter=function(){function e(e){this._c1=new FilterCondition(this),this._c2=new FilterCondition(this),this._and=!0,this._col=e}return Object.defineProperty(e.prototype,"condition1",{get:function(){return this._c1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"condition2",{get:function(){return this._c2},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"and",{get:function(){return this._and},set:function(e){this._and=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.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(e.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return this._c1.isActive||this._c2.isActive},enumerable:!0,configurable:!0}),e.prototype.apply=function(e){var t=this._col,i=this._c1,n=this._c2,r=!1,o=!1;if(!t||!t._binding||!this.isActive)return!0;if(e=t._binding.getValue(e),this.dataMap)e=this.dataMap.getDisplayValue(e);else if(t.dataMap)e=t.dataMap.getDisplayValue(e);else if(wijmo_1.isDate(e))if(r=!this._hasTimePart(),o=!this._hasDatePart(),wijmo_1.assert(!r||!o,"Filter should have either date or time."),r){Date();e=wijmo_1.DateTime.fromDateTime(e,FilterCondition._refDateTime)}else o&&(e=wijmo_1.DateTime.fromDateTime(FilterCondition._refDateTime,e));else wijmo_1.isNumber(e)&&(e=wijmo_1.Globalize.parseFloat(wijmo_1.Globalize.format(e,t.format)));var l=i.apply(e,r,o),a=n.apply(e,r,o);return i.isActive&&n.isActive?this._and?l&&a:l||a:i.isActive?l:!n.isActive||a},e.prototype.clear=function(){this._c1.clear(),this._c2.clear(),this.and=!0},e.prototype._hasDatePart=function(){var e=this._col.format;return!e||(e=wijmo_1.culture.Globalize.calendar.patterns[e]||e,/[yMd]+/.test(e))},e.prototype._hasTimePart=function(){var e=this._col.format;return!!e&&(e=wijmo_1.culture.Globalize.calendar.patterns[e]||e,/[Hmst]+/.test(e))},e.prototype.implementsInterface=function(e){return"IColumnFilter"==e},e}();exports.ConditionFilter=ConditionFilter;var ConditionFilterEditor=function(e){function t(t,i){var n=e.call(this,t)||this;n._filter=wijmo_1.asType(i,ConditionFilter,!1);var r=n.getTemplate();n.applyTemplate("wj-control wj-conditionfilter-editor",r,{_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 o=wijmo_1.culture.FlexGridFilter,l=o.ariaLabels;wijmo_1.setAriaLabel(n._btnAnd,l.and),wijmo_1.setAriaLabel(n._btnOr,l.or),wijmo_1.setText(n._divHdr,o.header),wijmo_1.setText(n._spAnd,o.and),wijmo_1.setText(n._spOr,o.or),n._cmb1=n._createOperatorCombo(n._divCmb1,l.op1),n._cmb2=n._createOperatorCombo(n._divCmb2,l.op2),n._val1=n._createValueInput(n._divVal1,l.val1),n._val2=n._createValueInput(n._divVal2,l.val2),n._val1.isDisabled=!0,n._cmb1.selectedIndexChanged.addHandler(function(e,t){n._val1.isDisabled=null==e.selectedValue}),n._val2.isDisabled=!0,n._cmb2.selectedIndexChanged.addHandler(function(e,t){n._val2.isDisabled=null==e.selectedValue});var a=n.hostElement;return n.addEventListener(a,"change",n._btnAndOrChanged.bind(n)),n.addEventListener(a,"keydown",n._keydown.bind(n)),n.updateEditor(),n}return __extends(t,e),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),t.prototype.updateEditor=function(){var e=this._filter.condition1,t=this._filter.condition2;this._cmb1.selectedValue=e.operator,this._cmb2.selectedValue=t.operator,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)):(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)},t.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(t.prototype,"isEditorClear",{get:function(){return null==this._cmb1.selectedValue&&!this._val1.text&&null==this._cmb2.selectedValue&&!this._val2.text},enumerable:!0,configurable:!0}),t.prototype.updateFilter=function(){var e=this._filter.condition1,t=this._filter.condition2;e.operator=this._cmb1.selectedValue,t.operator=this._cmb2.selectedValue,"value"in this._val1?(e.value=this._val1.value,t.value=this._val2.value):(e.value=this._val1.selectedValue,t.value=this._val2.selectedValue),this._filter.and=this._btnAnd.checked},t.prototype._createOperatorCombo=function(e,t){var i=this._filter.column,n=wijmo_1.culture.FlexGridFilter,r=n.stringOperators,o=this._filter.dataMap||i.dataMap,l=wijmo_1.DataType;i.dataType==l.Date?r=n.dateOperators:i.dataType!=l.Number||o?i.dataType!=l.Boolean||o||(r=n.booleanOperators):r=n.numberOperators;var a=new input.ComboBox(e,{itemsSource:r,displayMemberPath:"name",selectedValuePath:"op"});return wijmo_1.setAriaLabel(a.inputElement,t),a},t.prototype._createValueInput=function(e,t){var i=this._filter,n=i.column,r=i.dataMap||n.dataMap,o=null,l=wijmo_1.DataType;return n.dataType==l.Date?(o=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(e):new input.InputDate(e):new input.InputTime(e)).format=n.format:n.dataType!=l.Number||r?(o=new input.ComboBox(e),r?(o.itemsSource=r.getDisplayValues(),o.isEditable=!0):n.dataType==l.Boolean&&(o.itemsSource=[!0,!1])):(o=new input.InputNumber(e)).format=n.format,o.isRequired=!1,wijmo_1.setAriaLabel(o.inputElement,t),o},t.prototype._btnAndOrChanged=function(e){var t=e.target==this._btnAnd,i=e.target==this._btnOr;(t||i)&&(this._checkRadio(this._btnAnd,t),this._checkRadio(this._btnOr,i))},t.prototype._checkRadio=function(e,t){e.checked=t,e.setAttribute("aria-checked",t.toString()),e.setAttribute("tabindex",t?"1":"-1")},t.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 n=t?this._btnOr:this._btnAnd;n.click(),n.focus(),e.preventDefault()}},t.controlTemplate='<div><div wj-part="div-hdr"></div><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> <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>',t}(wijmo_1.Control);exports.ConditionFilterEditor=ConditionFilterEditor;var ValueFilter=function(){function e(e){this._xValueSearch=!0,this._maxValues=250,this._sortValues=!0,this._col=e}return Object.defineProperty(e.prototype,"showValues",{get:function(){return this._values},set:function(e){this._values=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filterText",{get:function(){return this._filterText},set:function(e){this._filterText=wijmo_1.asString(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){this._xValueSearch=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxValues",{get:function(){return this._maxValues},set:function(e){this._maxValues=wijmo_1.asNumber(e,!1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"uniqueValues",{get:function(){return this._uniqueValues},set:function(e){this._uniqueValues=wijmo_1.asArray(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sortValues",{get:function(){return this._sortValues},set:function(e){this._sortValues=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.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(e.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return null!=this._values&&Object.keys(this._values).length>0},enumerable:!0,configurable:!0}),e.prototype.apply=function(e){var t=this.column;return!(t&&t._binding&&this._values&&Object.keys(this._values).length)||(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),void 0!=this._values[e])},e.prototype.clear=function(){this.showValues=null,this.filterText=null},e.prototype.implementsInterface=function(e){return"IColumnFilter"==e},e.prototype._getUniqueValues=function(e,t){var i=[];if(this.uniqueValues){for(var n=this.uniqueValues,r=0;r<n.length;r++){var o=n[r];i.push({value:o,text:o.toString()})}return i}var l={},a=e.collectionView,s=a?a.sourceCollection:[];if(t&&a&&a.sourceCollection&&a.filter){var u=this.showValues;this.showValues=null;var c=[];for(r=0;r<s.length;r++)a.filter(s[r])&&c.push(s[r]);s=c,this.showValues=u}for(r=0;r<s.length;r++){o=e._binding.getValue(s[r]);var d=this.dataMap?this.dataMap.getDisplayValue(o):e.dataMap?e.dataMap.getDisplayValue(o):wijmo_1.Globalize.format(o,e.format);l[d]||(l[d]=!0,i.push({value:o,text:d}))}return i},e}();exports.ValueFilter=ValueFilter;var ValueFilterEditor=function(e){function t(t,i){var n=e.call(this,t)||this;n._filter=wijmo_1.asType(i,ValueFilter,!1);var r=n.getTemplate();n.applyTemplate("wj-control wj-valuefilter-editor",r,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values"}),n._cbSelectAll.tabIndex=0;var o=wijmo_1.culture.FlexGridFilter;wijmo_1.setText(n._spSelectAll,o.selectAll);var l=n._view=new wijmo_1.CollectionView;if(l.sortNullsFirst=!0,i.sortValues){var a=i.column.dataMap||i.dataMap?"text":"value",s=i.column.dataType!=wijmo_1.DataType.Boolean;l.sortDescriptions.push(new wijmo_1.SortDescription(a,s))}return l.filter=n._filterValues.bind(n),l.collectionChanged.addHandler(n._updateSelectAllCheck,n),n._filterText="",n._cmbFilter=new input.ComboBox(n._divFilter,{placeholder:o.search}),n._lbValues=new input.ListBox(n._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:n._view,itemFormatter:function(e,t){return t||o.null}}),wijmo_1.setAriaLabel(n._cmbFilter.inputElement,o.ariaLabels.search),n._cmbFilter.textChanged.addHandler(n._filterTextChanged,n),n._cbSelectAll.addEventListener("click",n._cbSelectAllClicked.bind(n)),n.updateEditor(),n}return __extends(t,e),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),t.prototype.updateEditor=function(){var e=this,t=this._filter.column,i=this._filter._getUniqueValues(t,!0);this._lbValues.isContentHtml=t.isContentHtml;var n=this._filter.showValues;if(n&&0!=Object.keys(n).length){for(var r in n)for(o=0;o<i.length;o++)if(i[o].text==r){i[o].show=!0;break}}else for(var o=0;o<i.length;o++)i[o].show=!0;this._view.pageSize=20,this._view.sourceCollection=i,setTimeout(function(){e._view.pageSize=e._filter.maxValues,e._cmbFilter.text=e._filter.filterText||"",e._filterText=e._cmbFilter.text.toLowerCase()})},t.prototype.clearEditor=function(e){void 0===e&&(e=!0),this._cmbFilter.text="",this._filterText="",this._view.pageSize=0,this._view.refresh(),this._view.items.forEach(function(t){t.show=e}),this._view.pageSize=this._filter.maxValues},Object.defineProperty(t.prototype,"isEditorClear",{get:function(){return!this._filterText&&!this._cbSelectAll.indeterminate},enumerable:!0,configurable:!0}),t.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 n=t[i];n.show&&(e[n.text]=!0)}}var r=this._filter;r.showValues=e,r.filterText=""},t.prototype._getItems=function(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection},t.prototype._filterTextChanged=function(){var e=this;this._toText&&clearTimeout(this._toText),this._toText=setTimeout(function(){var t=e._cmbFilter.text.toLowerCase(),i=t!=e._filterText;e._filterText=t,e._view.refresh(),i&&(e._filter.exclusiveValueSearch?(e._cbSelectAll.checked=!0,e._cbSelectAllClicked()):e._updateSelectAllCheck())},300)},t.prototype._filterValues=function(e){return!this._filterText||!(!e||!e.text)&&e.text.toLowerCase().indexOf(this._filterText)>-1},t.prototype._cbSelectAllClicked=function(){for(var e=this._cbSelectAll.checked,t=this._divValues.scrollTop,i=this._getItems(),n=0;n<i.length;n++)i[n].show=e;this._view.refresh(),this._divValues.scrollTop=t},t.prototype._updateSelectAllCheck=function(){for(var e=0,t=this._getItems(),i=0;i<t.length;i++)t[i].show&&e++;var n=this._cbSelectAll;0==e?(n.checked=!1,n.indeterminate=!1):e==t.length?(n.checked=!0,n.indeterminate=!1):n.indeterminate=!0},t.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>',t}(wijmo_1.Control);exports.ValueFilterEditor=ValueFilterEditor;var FilterType,ColumnFilter=function(){function e(e,t){this._owner=e,this._col=t,this._valueFilter=new ValueFilter(t),this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch,this._conditionFilter=new ConditionFilter(t)}return Object.defineProperty(e.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(e.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(e.prototype,"valueFilter",{get:function(){return this._valueFilter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"conditionFilter",{get:function(){return this._conditionFilter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return this._conditionFilter.isActive||this._valueFilter.isActive},enumerable:!0,configurable:!0}),e.prototype.apply=function(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)},e.prototype.clear=function(){this._valueFilter.clear(),this._conditionFilter.clear()},e.prototype.implementsInterface=function(e){return"IColumnFilter"==e},e}();exports.ColumnFilter=ColumnFilter,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 e(e,t){this._showIcons=!0,this._showSort=!0,this._defFilterType=FilterType.Both,this._xValueSearch=!0,this.filterApplied=new wijmo_1.Event,this.filterChanging=new wijmo_1.Event,this.filterChanged=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(),t&&wijmo_1.copy(this,t)}return Object.defineProperty(e.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filterColumns",{get:function(){return this._filterColumns},set:function(e){this._filterColumns=wijmo_1.asArray(e),this.clear()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showFilterIcons",{get:function(){return this._showIcons},set:function(e){e!=this.showFilterIcons&&(this._showIcons=wijmo_1.asBoolean(e),this._g&&this._g.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showSortButtons",{get:function(){return this._showSort},set:function(e){this._showSort=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0}),e.prototype.getColumnFilter=function(e,t){void 0===t&&(t=!0),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 n=new ColumnFilter(this,e);return this._filters.push(n),n}return null},Object.defineProperty(e.prototype,"defaultFilterType",{get:function(){return this._defFilterType},set:function(e){(e=wijmo_1.asEnum(e,FilterType,!1))!=this.defaultFilterType&&(this._defFilterType=e,this._g.invalidate(),this.clear())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){this._xValueSearch=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filterDefinition",{get:function(){var e=this,t={defaultFilterType:this.defaultFilterType,filters:[]};return this._filters.forEach(function(i){var n=i.conditionFilter,r=i.valueFilter,o=r.uniqueValues&&r.uniqueValues.length;if(i&&i.column&&i.column.binding&&(i.isActive||o||i.filterType!=e.defaultFilterType)){var l={binding:i.column.binding};if(n.isActive){var a=n.condition1,s=n.condition2;l={binding:i.column.binding,type:"condition",condition1:{operator:a.operator,value:a.value},and:n.and,condition2:{operator:s.operator,value:s.value}}}else(r.isActive||o)&&(l={binding:i.column.binding,type:"value",uniqueValues:r.uniqueValues,sortValues:r.sortValues,maxValues:r.maxValues,exclusiveValueSearch:r.exclusiveValueSearch,showValues:r.showValues});i.filterType!=e.defaultFilterType&&(l.filterType=i.filterType),t.filters.push(l)}}),JSON.stringify(t)},set:function(e){if(e=wijmo_1.asString(e),this.clear(),e){var t=JSON.parse(e);this.defaultFilterType=t.defaultFilterType;for(var i=function(e){var i=t.filters[e],r=n._g.getColumn(i.binding),o=n.getColumnFilter(r,!0);if(o)switch(null!=i.filterType&&(o.filterType=wijmo_1.asEnum(i.filterType,FilterType)),i.type){case"condition":var l=o.conditionFilter;l.condition1.value=r.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(i.condition1.value,r.dataType,null):i.condition1.value,l.condition1.operator=i.condition1.operator,l.and=i.and,l.condition2.value=r.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(i.condition2.value,r.dataType,null):i.condition2.value,l.condition2.operator=i.condition2.operator;break;case"value":var a=o.valueFilter;a.uniqueValues=i.uniqueValues,["sortValues","maxValues","exclusiveValueSearch"].forEach(function(e){null!=i[e]&&(a[e]=i[e])}),a.showValues=i.showValues}},n=this,r=0;r<t.filters.length;r++)i(r)}this.apply()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activeEditor",{get:function(){return wijmo_1.Control.getControl(this._divEdt)},enumerable:!0,configurable:!0}),e.prototype.editColumnFilter=function(e,t,i){var n=this;this.closeEditor(),e=this._asColumn(e);var r=this._g,o=new wijmo_grid_1.CellRangeEventArgs(r.cells,new wijmo_grid_1.CellRange(-1,e.index));if(this.onFilterChanging(o)){o.cancel=!0;var l=wijmo_1.createElement('<div class="wj-dropdown-panel"></div>'),a=this.getColumnFilter(e),s=new ColumnFilterEditor(l,a,this.showSortButtons);this._divEdt=l,this._edtCol=e,r.rightToLeft&&(l.dir="rtl"),s.filterChanged.addHandler(function(){o.cancel=!1,setTimeout(function(){o.cancel||n.apply()})}),s.buttonClicked.addHandler(function(){n.closeEditor(),r.focus(),n.onFilterChanged(o)}),s.lostFocus.addHandler(function(){setTimeout(function(){var e=wijmo_1.Control.getControl(n._divEdt);e&&!e.containsFocus()&&n.closeEditor()},10)});var u=t?t.col:e.index;t||r.columns[u].binding==e.binding||(u=r.selection.leftCol),r._edtHdl._commitRowEdits(),r.scrollIntoView(-1,u,!0);var c=r.columnHeaders,d=t&&t.panel==c?t.row:c.rows.length-1,p=u,_=c.getCellBoundingRect(d,p),h=i||c.getCellElement(d,p);h?wijmo_1.showPopup(l,h,!1,!1,!1):wijmo_1.showPopup(l,_),this._setAriaExpanded(h,!0),this._setAriaExpanded(r.cells.getCellElement(-1,p),!0);for(var f=s.hostElement.querySelectorAll("input"),m=0;m<f.length;m++){var b=f[m];if(b.offsetHeight>0&&b.tabIndex>-1&&!b.disabled){b.focus();break}}s.containsFocus()||s.focus()}else this._divEdt=this._edtCol=null},e.prototype._setAriaExpanded=function(t,i){if(t){var n=t.querySelector("."+e._WJC_FILTER);wijmo_1.setAttribute(n,"aria-expanded",i)}},e.prototype.closeEditor=function(){var e=this._g,t=wijmo_1.Control.getControl(this._divEdt),i=this._edtCol;if(t&&wijmo_1.hidePopup(t.hostElement,function(){t.dispose()}),i){var n=e.columnHeaders,r=n.rows.length?n.getCellElement(n.rows.length-1,i.index):null;this._setAriaExpanded(r,!1),r=e.cells.getCellElement(-1,i.index),this._setAriaExpanded(r,!1)}this._divEdt=null,this._edtCol=null},e.prototype.apply=function(){var e=this._g.collectionView;if(e){var t=this._g.editableCollectionView;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()},e.prototype.clear=function(){this._filters.length&&(this._filters=[],this.apply())},e.prototype.onFilterApplied=function(e){this.filterApplied.raise(this,e)},e.prototype.onFilterChanging=function(e){return this.filterChanging.raise(this,e),!e.cancel},e.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)},e.prototype._asColumn=function(e){return wijmo_1.isString(e)?this._g.getColumn(e):wijmo_1.isNumber(e)?this._g.columns[e]:wijmo_1.asType(e,wijmo_grid_1.Column,!1)},e.prototype._filter=function(e){for(var t=0;t<this._filters.length;t++)if(!this._filters[t].apply(e))return!1;return!0},e.prototype._formatItem=function(e,t){if(t.panel==e.columnHeaders){var i=this._g,n=i.getMergedRange(t.panel,t.row,t.col)||new wijmo_grid_1.CellRange(t.row,t.col),r=i.columns[n.col],o=i._getBindingColumn(t.panel,t.row,r),l=t.cell;if(n.row2==t.panel.rows.length-1||r!=o){var a=this.getColumnFilter(o,this.defaultFilterType!=FilterType.None);this._filterColumns&&this._filterColumns.indexOf(o.binding)<0&&(a=null),a?(wijmo_1.toggleClass(l,"wj-filter-on",a.isActive),wijmo_1.toggleClass(l,"wj-filter-off",!a.isActive)):(wijmo_1.removeClass(l,"wj-filter-on"),wijmo_1.removeClass(l,"wj-filter-off")),a&&a.filterType!=FilterType.None&&(this._showIcons&&this._addFilterButton(o,a,l),0==t.row&&(l=i.cells.getCellElement(-1,t.col))&&this._addFilterButton(r,a,l))}}},e.prototype._addFilterButton=function(t,i,n){var r=e._WJC_FILTER,o=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(o,wijmo_1.culture.FlexGridFilter.ariaLabels.edit+" "+t.header),wijmo_1.setAttribute(o,"aria-haspopup","dialog"),wijmo_1.setAttribute(o,"aria-expanded",!1),wijmo_1.setAttribute(o,"aria-describedby",t.describedById),wijmo_1.setAttribute(o,"aria-pressed",i.isActive),n.querySelector("."+r)||(1==n.children.length&&(n=n.querySelector("div")||n),n.appendChild(o))},e.prototype._mousedown=function(e){this._toggleEditor(e)&&(this._tmd=!0,e.stopPropagation(),e.preventDefault())},e.prototype._click=function(e){(this._tmd||this._toggleEditor(e))&&(e.stopPropagation(),e.preventDefault()),this._tmd=!1},e.prototype._toggleEditor=function(t){var i=this;if(this._tmd=!1,!t.defaultPrevented&&0==t.button)if(wijmo_1.closestClass(t.target,e._WJC_FILTER)){var n=this._g,r=n.hitTest(t.target);if(r.panel||(r=n.hitTest(t)),r.panel==n.columnHeaders||r.panel==n.cells&&-1==r.row){var o=n.columns[r.col],l=n._getBindingColumn(r.panel,r.row,o);return this._divEdt&&this._edtCol==l?(this.closeEditor(),n.focus()):setTimeout(function(){i.editColumnFilter(l,r)},this._divEdt?100:0),!0}}else this.closeEditor();return!1},e.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,n=i.col>-1?t.columns[i.col]:null,r=n?t._getBindingColumn(t.cells,i.row,n):null;r&&!r.dataMap&&this.getColumnFilter(r,!0)&&(this.editColumnFilter(r),e.preventDefault(),e.stopPropagation())}},e._WJC_FILTER="wj-elem-filter",e}();exports.FlexGridFilter=FlexGridFilter,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){function t(t,i,n){void 0===n&&(n=!0);var r=e.call(this,t,null,!0)||this;r.filterChanged=new wijmo_1.Event,r.buttonClicked=new wijmo_1.Event,r._filter=wijmo_1.asType(i,ColumnFilter);var o=r.getTemplate();r.applyTemplate("wj-control wj-content wj-columnfiltereditor",o,{_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 l=wijmo_1.culture.FlexGridFilter,a=l.ariaLabels,s=r.hostElement,u=r.filter.column,c=u.grid.collectionView;wijmo_1.setAttribute(s,"role","dialog"),wijmo_1.setAriaLabel(s,a.dialog+" "+u.header),wijmo_1.setAriaLabel(r._btnAsc,a.asc),wijmo_1.setAriaLabel(r._btnDsc,a.dsc),wijmo_1.setText(r._btnAsc,l.ascending),wijmo_1.setText(r._btnDsc,l.descending),wijmo_1.setText(r._aVal,l.values),wijmo_1.setText(r._aCnd,l.conditions),wijmo_1.setText(r._btnApply,l.apply),wijmo_1.setText(r._btnCancel,l.cancel),wijmo_1.setText(r._btnClear,l.clear);var d=r.filter.conditionFilter.isActive||0==(i.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;r._showFilter(d),n&&c&&c.canSort||(r._divSort.style.display="none");var p=r._btnClicked.bind(r);return r._btnApply.addEventListener("click",p),r._btnCancel.addEventListener("click",p),r._btnClear.addEventListener("click",p),r._btnAsc.addEventListener("click",p),r._btnDsc.addEventListener("click",p),r._aVal.addEventListener("click",p),r._aCnd.addEventListener("click",p),s.addEventListener("keydown",function(e){if(!e.defaultPrevented){var t=e.target.tagName.match(/^(a|button)$/i);switch(e.keyCode){case wijmo_1.Key.Space:t&&(r._btnClicked(e),e.preventDefault());break;case wijmo_1.Key.Enter:t?r._btnClicked(e):(r.updateFilter(),r.onFilterChanged(),r.onButtonClicked()),e.preventDefault();break;case wijmo_1.Key.Escape:r.onButtonClicked(),e.preventDefault();break;case wijmo_1.Key.Tab:wijmo_1.moveFocus(r.hostElement,e.shiftKey?-1:1),e.preventDefault()}}}),r}return __extends(t,e),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),t.prototype.updateEditor=function(){this._edtVal&&this._edtVal.updateEditor(),this._edtCnd&&this._edtCnd.updateEditor()},t.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()}},t.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)},t.prototype.onButtonClicked=function(e){this.buttonClicked.raise(this,e)},t.prototype._handleResize=function(){this.isTouching||this._wasTouching||this.onButtonClicked()},t.prototype._showFilter=function(e){this._wasTouching=this.isTouching,e==FilterType.Value&&null==this._edtVal&&(this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter)),e==FilterType.Condition&&null==this._edtCnd&&(this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter)),0!=(e&this.filter.filterType)&&(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()):(this._divEdtVal.style.display="none",this._divEdtCnd.style.display="",this._enableLink(this._aVal,!0),this._enableLink(this._aCnd,!1),this._edtCnd.focus()));var t=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:t.display="none";break;default:t.display=""}},t.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")},t.prototype._getFilterType=function(){var e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition},t.prototype._btnClicked=function(e){var t=e.target;if(e.preventDefault(),e.stopPropagation(),!wijmo_1.hasClass(t,"wj-state-disabled")){if(t==this._aVal)return this._showFilter(FilterType.Value),void wijmo_1.moveFocus(this._edtVal.hostElement,0);if(t==this._aCnd)return this._showFilter(FilterType.Condition),void wijmo_1.moveFocus(this._edtCnd.hostElement,0);if(t==this._btnAsc||t==this._btnDsc){var i=this.filter.column,n=i.sortMemberPath?i.sortMemberPath:i.binding,r=i.grid.collectionView,o=new wijmo_1.SortDescription(n,e.target==this._btnAsc);r.sortDescriptions.deferUpdate(function(){r.sortDescriptions.clear(),r.sortDescriptions.push(o)})}t==this._btnApply?(this.updateFilter(),this.onFilterChanged()):t==this._btnClear?this.filter.isActive&&(this.filter.clear(),this.onFilterChanged()):this.updateEditor(),this.onButtonClicked()}},t.controlTemplate='<div><div wj-part="div-sort"><button wj-part="btn-asc" class="wj-btn" style="min-width:95px"></button> <button wj-part="btn-dsc" class="wj-btn" style="min-width:95px"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a> | <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> <button wj-part="btn-cancel" class="wj-btn"></button> <button wj-part="btn-clear" class="wj-btn"></button></div>',t}(wijmo_1.Control);exports.ColumnFilterEditor=ColumnFilterEditor,wijmo_1._registerModule("wijmo.grid.filter",selfModule); | ||
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,i){return(e=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])})(t,i)};return function(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();Object.defineProperty(exports,"__esModule",{value:!0});var Operator,wijmo_grid_1=require("@grapecity/wijmo.grid"),wijmo_1=require("@grapecity/wijmo"),input=require("@grapecity/wijmo.input"),selfModule=require("@grapecity/wijmo.grid.filter"),FilterCondition=function(){function e(e){this._op=null,this._filter=e}return Object.defineProperty(e.prototype,"operator",{get:function(){return this._op},set:function(e){this._op=wijmo_1.asEnum(e,Operator,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._val},set:function(e){if(this._val=e,this._strVal=wijmo_1.isString(e)?e.toString().toLowerCase():null,this._mapVal=null,this._filter){var t=this._filter.dataMap||this._filter.column.dataMap;t&&(this._mapVal=t.getDisplayValue(e),wijmo_1.isString(this._mapVal)&&(this._strVal=this._mapVal=this._mapVal.toLowerCase()))}},enumerable:!0,configurable:!0}),Object.defineProperty(e.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}),e.prototype.clear=function(){this.operator=null,this.value=null},e.prototype.apply=function(t,i,n){var r=this._mapVal||this._strVal||this._val;wijmo_1.isString(t)&&(t=t.toLowerCase()),wijmo_1.isString(r)&&null==t&&(t=""),wijmo_1.isDate(r)&&(i?r=wijmo_1.DateTime.fromDateTime(r,e._refDateTime):n&&(r=wijmo_1.DateTime.fromDateTime(e._refDateTime,r)));var o=Operator;switch(this._op){case null:return!0;case o.EQ:return null!=t&&null!=r?t.valueOf()==r.valueOf():t==r;case o.NE:return null!=t&&null!=r?t.valueOf()!=r.valueOf():t!=r;case o.GT:return t>r;case o.GE:return t>=r;case o.LT:return t<r;case o.LE:return t<=r;case o.BW:return!(null==this._strVal||!wijmo_1.isString(t))&&0==t.indexOf(this._strVal);case o.EW:return!!(null!=this._strVal&&wijmo_1.isString(t)&&t.length>=this._strVal.length)&&t.substr(t.length-this._strVal.length)==r;case o.CT:return!(null==this._strVal||!wijmo_1.isString(t))&&t.indexOf(this._strVal)>-1;case o.NC:return!(null==this._strVal||!wijmo_1.isString(t))&&t.indexOf(this._strVal)<0}throw"Unknown operator"},e._refDateTime=new Date(2e3,0,1,0,0,0),e}();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={}));var ConditionFilter=function(){function e(e){this._c1=new FilterCondition(this),this._c2=new FilterCondition(this),this._and=!0,this._col=e}return Object.defineProperty(e.prototype,"condition1",{get:function(){return this._c1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"condition2",{get:function(){return this._c2},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"and",{get:function(){return this._and},set:function(e){this._and=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.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(e.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return this._c1.isActive||this._c2.isActive},enumerable:!0,configurable:!0}),e.prototype.apply=function(e){var t=this._col,i=this._c1,n=this._c2,r=!1,o=!1;if(!t||!t._binding||!this.isActive)return!0;if(e=t._binding.getValue(e),this.dataMap)e=this.dataMap.getDisplayValue(e);else if(t.dataMap)e=t.dataMap.getDisplayValue(e);else if(wijmo_1.isDate(e))if(r=!this._hasTimePart(),o=!this._hasDatePart(),wijmo_1.assert(!r||!o,"Filter should have either date or time."),r){Date();e=wijmo_1.DateTime.fromDateTime(e,FilterCondition._refDateTime)}else o&&(e=wijmo_1.DateTime.fromDateTime(FilterCondition._refDateTime,e));else wijmo_1.isNumber(e)&&(e=wijmo_1.Globalize.parseFloat(wijmo_1.Globalize.format(e,t.format)));var l=i.apply(e,r,o),a=n.apply(e,r,o);return i.isActive&&n.isActive?this._and?l&&a:l||a:i.isActive?l:!n.isActive||a},e.prototype.clear=function(){this._c1.clear(),this._c2.clear(),this.and=!0},e.prototype._hasDatePart=function(){var e=this._col.format;return!e||(e=wijmo_1.culture.Globalize.calendar.patterns[e]||e,/[yMd]+/.test(e))},e.prototype._hasTimePart=function(){var e=this._col.format;return!!e&&(e=wijmo_1.culture.Globalize.calendar.patterns[e]||e,/[Hmst]+/.test(e))},e.prototype.implementsInterface=function(e){return"IColumnFilter"==e},e}();exports.ConditionFilter=ConditionFilter;var ConditionFilterEditor=function(e){function t(t,i){var n=e.call(this,t)||this;n._filter=wijmo_1.asType(i,ConditionFilter,!1);var r=n.getTemplate();n.applyTemplate("wj-control wj-conditionfilter-editor",r,{_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 o=wijmo_1.culture.FlexGridFilter,l=o.ariaLabels;wijmo_1.setAriaLabel(n._btnAnd,l.and),wijmo_1.setAriaLabel(n._btnOr,l.or),wijmo_1.setText(n._divHdr,o.header),wijmo_1.setText(n._spAnd,o.and),wijmo_1.setText(n._spOr,o.or),n._cmb1=n._createOperatorCombo(n._divCmb1,l.op1),n._cmb2=n._createOperatorCombo(n._divCmb2,l.op2),n._val1=n._createValueInput(n._divVal1,l.val1),n._val2=n._createValueInput(n._divVal2,l.val2),n._val1.isDisabled=!0,n._cmb1.selectedIndexChanged.addHandler(function(e,t){n._val1.isDisabled=null==e.selectedValue}),n._val2.isDisabled=!0,n._cmb2.selectedIndexChanged.addHandler(function(e,t){n._val2.isDisabled=null==e.selectedValue});var a=n.hostElement;return n.addEventListener(a,"change",n._btnAndOrChanged.bind(n)),n.addEventListener(a,"keydown",n._keydown.bind(n)),n.updateEditor(),n}return __extends(t,e),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),t.prototype.updateEditor=function(){var e=this._filter.condition1,t=this._filter.condition2;this._cmb1.selectedValue=e.operator,this._cmb2.selectedValue=t.operator,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)):(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)},t.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(t.prototype,"isEditorClear",{get:function(){return null==this._cmb1.selectedValue&&!this._val1.text&&null==this._cmb2.selectedValue&&!this._val2.text},enumerable:!0,configurable:!0}),t.prototype.updateFilter=function(){var e=this._filter.condition1,t=this._filter.condition2;e.operator=this._cmb1.selectedValue,t.operator=this._cmb2.selectedValue,"value"in this._val1?(e.value=this._val1.value,t.value=this._val2.value):(e.value=this._val1.selectedValue,t.value=this._val2.selectedValue),this._filter.and=this._btnAnd.checked},t.prototype._createOperatorCombo=function(e,t){var i=this._filter.column,n=wijmo_1.culture.FlexGridFilter,r=n.stringOperators,o=this._filter.dataMap||i.dataMap,l=wijmo_1.DataType;i.dataType==l.Date?r=n.dateOperators:i.dataType!=l.Number||o?i.dataType!=l.Boolean||o||(r=n.booleanOperators):r=n.numberOperators;var a=new input.ComboBox(e,{itemsSource:r,displayMemberPath:"name",selectedValuePath:"op"});return wijmo_1.setAriaLabel(a.inputElement,t),a},t.prototype._createValueInput=function(e,t){var i=this._filter,n=i.column,r=i.dataMap||n.dataMap,o=null,l=wijmo_1.DataType;return n.dataType==l.Date?(o=i._hasDatePart()?i._hasTimePart()?new input.InputDateTime(e):new input.InputDate(e):new input.InputTime(e)).format=n.format:n.dataType!=l.Number||r?(o=new input.ComboBox(e),r?(o.itemsSource=r.getDisplayValues(),o.isEditable=!0):n.dataType==l.Boolean&&(o.itemsSource=[!0,!1])):(o=new input.InputNumber(e)).format=n.format,o.isRequired=!1,wijmo_1.setAriaLabel(o.inputElement,t),o},t.prototype._btnAndOrChanged=function(e){var t=e.target==this._btnAnd,i=e.target==this._btnOr;(t||i)&&(this._checkRadio(this._btnAnd,t),this._checkRadio(this._btnOr,i))},t.prototype._checkRadio=function(e,t){e.checked=t,e.setAttribute("aria-checked",t.toString()),e.setAttribute("tabindex",t?"1":"-1")},t.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 n=t?this._btnOr:this._btnAnd;n.click(),n.focus(),e.preventDefault()}},t.controlTemplate='<div><div wj-part="div-hdr"></div><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> <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>',t}(wijmo_1.Control);exports.ConditionFilterEditor=ConditionFilterEditor;var ValueFilter=function(){function e(e){this._xValueSearch=!0,this._maxValues=250,this._sortValues=!0,this._col=e}return Object.defineProperty(e.prototype,"showValues",{get:function(){return this._values},set:function(e){this._values=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filterText",{get:function(){return this._filterText},set:function(e){this._filterText=wijmo_1.asString(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){this._xValueSearch=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxValues",{get:function(){return this._maxValues},set:function(e){this._maxValues=wijmo_1.asNumber(e,!1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"uniqueValues",{get:function(){return this._uniqueValues},set:function(e){this._uniqueValues=wijmo_1.asArray(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sortValues",{get:function(){return this._sortValues},set:function(e){this._sortValues=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.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(e.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return null!=this._values&&Object.keys(this._values).length>0},enumerable:!0,configurable:!0}),e.prototype.apply=function(e){var t=this.column;return!(t&&t._binding&&this._values&&Object.keys(this._values).length)||(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),void 0!=this._values[e])},e.prototype.clear=function(){this.showValues=null,this.filterText=null},e.prototype.implementsInterface=function(e){return"IColumnFilter"==e},e.prototype._getUniqueValues=function(e,t){var i=[];if(this.uniqueValues){for(var n=this.uniqueValues,r=0;r<n.length;r++){var o=n[r];i.push({value:o,text:o.toString()})}return i}var l={},a=e.collectionView,s=a?a.sourceCollection:[];if(t&&a&&a.sourceCollection&&a.filter){var u=this.showValues;this.showValues=null;var c=[];for(r=0;r<s.length;r++)a.filter(s[r])&&c.push(s[r]);s=c,this.showValues=u}for(r=0;r<s.length;r++){o=e._binding.getValue(s[r]);var d=this.dataMap?this.dataMap.getDisplayValue(o):e.dataMap?e.dataMap.getDisplayValue(o):wijmo_1.Globalize.format(o,e.format);l[d]||(l[d]=!0,i.push({value:o,text:d}))}return i},e}();exports.ValueFilter=ValueFilter;var ValueFilterEditor=function(e){function t(t,i){var n=e.call(this,t)||this;n._filter=wijmo_1.asType(i,ValueFilter,!1);var r=n.getTemplate();n.applyTemplate("wj-control wj-valuefilter-editor",r,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values"}),n._cbSelectAll.tabIndex=0;var o=wijmo_1.culture.FlexGridFilter;wijmo_1.setText(n._spSelectAll,o.selectAll);var l=n._view=new wijmo_1.CollectionView;if(l.sortNullsFirst=!0,i.sortValues){var a=i.column.dataMap||i.dataMap?"text":"value",s=i.column.dataType!=wijmo_1.DataType.Boolean;l.sortDescriptions.push(new wijmo_1.SortDescription(a,s))}return l.filter=n._filterValues.bind(n),l.collectionChanged.addHandler(n._updateSelectAllCheck,n),n._filterText="",n._cmbFilter=new input.ComboBox(n._divFilter,{placeholder:o.search}),n._lbValues=new input.ListBox(n._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:n._view,itemFormatter:function(e,t){return t||o.null}}),wijmo_1.setAriaLabel(n._cmbFilter.inputElement,o.ariaLabels.search),n._cmbFilter.textChanged.addHandler(n._filterTextChanged,n),n._cbSelectAll.addEventListener("click",n._cbSelectAllClicked.bind(n)),n.updateEditor(),n}return __extends(t,e),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),t.prototype.updateEditor=function(){var e=this,t=this._filter.column,i=this._filter._getUniqueValues(t,!0);this._lbValues.isContentHtml=t.isContentHtml;var n=this._filter.showValues;if(n&&0!=Object.keys(n).length){for(var r in n)for(o=0;o<i.length;o++)if(i[o].text==r){i[o].show=!0;break}}else for(var o=0;o<i.length;o++)i[o].show=!0;this._view.pageSize=20,this._view.sourceCollection=i,setTimeout(function(){e._view.pageSize=e._filter.maxValues,e._cmbFilter.text=e._filter.filterText||"",e._filterText=e._cmbFilter.text.toLowerCase()})},t.prototype.clearEditor=function(e){void 0===e&&(e=!0),this._cmbFilter.text="",this._filterText="",this._view.pageSize=0,this._view.refresh(),this._view.items.forEach(function(t){t.show=e}),this._view.pageSize=this._filter.maxValues},Object.defineProperty(t.prototype,"isEditorClear",{get:function(){return!this._filterText&&!this._cbSelectAll.indeterminate},enumerable:!0,configurable:!0}),t.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 n=t[i];n.show&&(e[n.text]=!0)}}var r=this._filter;r.showValues=e,r.filterText=""},t.prototype._getItems=function(){return this._filter.exclusiveValueSearch?this._view.items:this._view.sourceCollection},t.prototype._filterTextChanged=function(){var e=this;this._toText&&clearTimeout(this._toText),this._toText=setTimeout(function(){var t=e._cmbFilter.text.toLowerCase(),i=t!=e._filterText;e._filterText=t,e._view.refresh(),i&&(e._filter.exclusiveValueSearch?(e._cbSelectAll.checked=!0,e._cbSelectAllClicked()):e._updateSelectAllCheck())},300)},t.prototype._filterValues=function(e){return!this._filterText||!(!e||!e.text)&&e.text.toLowerCase().indexOf(this._filterText)>-1},t.prototype._cbSelectAllClicked=function(){for(var e=this._cbSelectAll.checked,t=this._divValues.scrollTop,i=this._getItems(),n=0;n<i.length;n++)i[n].show=e;this._view.refresh(),this._divValues.scrollTop=t},t.prototype._updateSelectAllCheck=function(){for(var e=0,t=this._getItems(),i=0;i<t.length;i++)t[i].show&&e++;var n=this._cbSelectAll;0==e?(n.checked=!1,n.indeterminate=!1):e==t.length?(n.checked=!0,n.indeterminate=!1):n.indeterminate=!0},t.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>',t}(wijmo_1.Control);exports.ValueFilterEditor=ValueFilterEditor;var FilterType,ColumnFilter=function(){function e(e,t){this._owner=e,this._col=t,this._valueFilter=new ValueFilter(t),this._valueFilter.exclusiveValueSearch=e.exclusiveValueSearch,this._conditionFilter=new ConditionFilter(t)}return Object.defineProperty(e.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(e.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(e.prototype,"valueFilter",{get:function(){return this._valueFilter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"conditionFilter",{get:function(){return this._conditionFilter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return this._conditionFilter.isActive||this._valueFilter.isActive},enumerable:!0,configurable:!0}),e.prototype.apply=function(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)},e.prototype.clear=function(){this._valueFilter.clear(),this._conditionFilter.clear()},e.prototype.implementsInterface=function(e){return"IColumnFilter"==e},e}();exports.ColumnFilter=ColumnFilter,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 e(e,t){this._showIcons=!0,this._showSort=!0,this._defFilterType=FilterType.Both,this._xValueSearch=!0,this.filterApplied=new wijmo_1.Event,this.filterChanging=new wijmo_1.Event,this.filterChanged=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(),t&&wijmo_1.copy(this,t)}return Object.defineProperty(e.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filterColumns",{get:function(){return this._filterColumns},set:function(e){this._filterColumns=wijmo_1.asArray(e),this.clear()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showFilterIcons",{get:function(){return this._showIcons},set:function(e){e!=this.showFilterIcons&&(this._showIcons=wijmo_1.asBoolean(e),this._g&&this._g.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showSortButtons",{get:function(){return this._showSort},set:function(e){this._showSort=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0}),e.prototype.getColumnFilter=function(e,t){void 0===t&&(t=!0),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 n=new ColumnFilter(this,e);return this._filters.push(n),n}return null},Object.defineProperty(e.prototype,"defaultFilterType",{get:function(){return this._defFilterType},set:function(e){(e=wijmo_1.asEnum(e,FilterType,!1))!=this.defaultFilterType&&(this._defFilterType=e,this._g.invalidate(),this.clear())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){this._xValueSearch=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filterDefinition",{get:function(){var e=this,t={defaultFilterType:this.defaultFilterType,filters:[]};return this._filters.forEach(function(i){var n=i.conditionFilter,r=i.valueFilter,o=r.uniqueValues&&r.uniqueValues.length;if(i&&i.column&&i.column.binding&&(i.isActive||o||i.filterType!=e.defaultFilterType)){var l={binding:i.column.binding};if(n.isActive){var a=n.condition1,s=n.condition2;l={binding:i.column.binding,type:"condition",condition1:{operator:a.operator,value:a.value},and:n.and,condition2:{operator:s.operator,value:s.value}}}else(r.isActive||o)&&(l={binding:i.column.binding,type:"value",uniqueValues:r.uniqueValues,sortValues:r.sortValues,maxValues:r.maxValues,exclusiveValueSearch:r.exclusiveValueSearch,showValues:r.showValues});i.filterType!=e.defaultFilterType&&(l.filterType=i.filterType),t.filters.push(l)}}),JSON.stringify(t)},set:function(e){if(e=wijmo_1.asString(e),this.clear(),e){var t=JSON.parse(e);this.defaultFilterType=t.defaultFilterType;for(var i=function(e){var i=t.filters[e],r=n._g.getColumn(i.binding),o=n.getColumnFilter(r,!0);if(o)switch(null!=i.filterType&&(o.filterType=wijmo_1.asEnum(i.filterType,FilterType)),i.type){case"condition":var l=o.conditionFilter;l.condition1.value=r.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(i.condition1.value,r.dataType,null):i.condition1.value,l.condition1.operator=i.condition1.operator,l.and=i.and,l.condition2.value=r.dataType==wijmo_1.DataType.Date?wijmo_1.changeType(i.condition2.value,r.dataType,null):i.condition2.value,l.condition2.operator=i.condition2.operator;break;case"value":var a=o.valueFilter;a.uniqueValues=i.uniqueValues,["sortValues","maxValues","exclusiveValueSearch"].forEach(function(e){null!=i[e]&&(a[e]=i[e])}),a.showValues=i.showValues}},n=this,r=0;r<t.filters.length;r++)i(r)}this.apply()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activeEditor",{get:function(){return wijmo_1.Control.getControl(this._divEdt)},enumerable:!0,configurable:!0}),e.prototype.editColumnFilter=function(e,t,i){var n=this;this.closeEditor(),e=this._asColumn(e);var r=this._g,o=new wijmo_grid_1.CellRangeEventArgs(r.cells,new wijmo_grid_1.CellRange(-1,e.index));if(this.onFilterChanging(o)){o.cancel=!0;var l=wijmo_1.createElement('<div class="wj-dropdown-panel"></div>'),a=this.getColumnFilter(e),s=new ColumnFilterEditor(l,a,this.showSortButtons);this._divEdt=l,this._edtCol=e,r.rightToLeft&&(l.dir="rtl"),s.filterChanged.addHandler(function(){o.cancel=!1,setTimeout(function(){o.cancel||n.apply()})}),s.buttonClicked.addHandler(function(){n.closeEditor(),r.focus(),n.onFilterChanged(o)}),s.lostFocus.addHandler(function(){setTimeout(function(){var e=wijmo_1.Control.getControl(n._divEdt);e&&!e.containsFocus()&&n.closeEditor()},10)});var u=t?t.col:e.index;t||r.columns[u].binding==e.binding||(u=r.selection.leftCol),r._edtHdl._commitRowEdits(),r.scrollIntoView(-1,u,!0);var c=r.columnHeaders,d=t&&t.panel==c?t.row:c.rows.length-1,p=u,_=c.getCellBoundingRect(d,p),h=i||c.getCellElement(d,p);h?wijmo_1.showPopup(l,h,!1,!1,!1):wijmo_1.showPopup(l,_),this._setAriaExpanded(h,!0),this._setAriaExpanded(r.cells.getCellElement(-1,p),!0);for(var f=s.hostElement.querySelectorAll("input"),m=0;m<f.length;m++){var v=f[m];if(v.offsetHeight>0&&v.tabIndex>-1&&!v.disabled){v.focus();break}}s.containsFocus()||s.focus()}else this._divEdt=this._edtCol=null},e.prototype._setAriaExpanded=function(t,i){if(t){var n=t.querySelector("."+e._WJC_FILTER);wijmo_1.setAttribute(n,"aria-expanded",i)}},e.prototype.closeEditor=function(){var e=this._g,t=wijmo_1.Control.getControl(this._divEdt),i=this._edtCol;if(t&&wijmo_1.hidePopup(t.hostElement,function(){t.dispose()}),i){var n=e.columnHeaders,r=n.rows.length?n.getCellElement(n.rows.length-1,i.index):null;this._setAriaExpanded(r,!1),r=e.cells.getCellElement(-1,i.index),this._setAriaExpanded(r,!1)}this._divEdt=null,this._edtCol=null},e.prototype.apply=function(){var e=this._g.collectionView;if(e){var t=this._g.editableCollectionView;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()},e.prototype.clear=function(){this._filters.length&&(this._filters=[],this.apply())},e.prototype.onFilterApplied=function(e){this.filterApplied.raise(this,e)},e.prototype.onFilterChanging=function(e){return this.filterChanging.raise(this,e),!e.cancel},e.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)},e.prototype._asColumn=function(e){return wijmo_1.isString(e)?this._g.getColumn(e):wijmo_1.isNumber(e)?this._g.columns[e]:wijmo_1.asType(e,wijmo_grid_1.Column,!1)},e.prototype._filter=function(e){for(var t=0;t<this._filters.length;t++)if(!this._filters[t].apply(e))return!1;return!0},e.prototype._formatItem=function(e,t){if(t.panel==e.columnHeaders){var i=this._g,n=i.getMergedRange(t.panel,t.row,t.col)||new wijmo_grid_1.CellRange(t.row,t.col),r=i.columns[n.col],o=i._getBindingColumn(t.panel,t.row,r),l=t.cell;if(n.row2==t.panel.rows.length-1||r!=o){var a=this.getColumnFilter(o,this.defaultFilterType!=FilterType.None);this._filterColumns&&this._filterColumns.indexOf(o.binding)<0&&(a=null),a?(wijmo_1.toggleClass(l,"wj-filter-on",a.isActive),wijmo_1.toggleClass(l,"wj-filter-off",!a.isActive)):(wijmo_1.removeClass(l,"wj-filter-on"),wijmo_1.removeClass(l,"wj-filter-off")),a&&a.filterType!=FilterType.None&&(this._showIcons&&this._addFilterButton(o,a,l),0==t.row&&(l=i.cells.getCellElement(-1,t.col))&&this._addFilterButton(r,a,l))}}},e.prototype._addFilterButton=function(t,i,n){var r=e._WJC_FILTER,o=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(o,wijmo_1.culture.FlexGridFilter.ariaLabels.edit+" "+t.header),wijmo_1.setAttribute(o,"aria-haspopup","dialog"),wijmo_1.setAttribute(o,"aria-expanded",!1),wijmo_1.setAttribute(o,"aria-describedby",t.describedById),wijmo_1.setAttribute(o,"aria-pressed",i.isActive),n.querySelector("."+r)||(1==n.children.length&&(n=n.querySelector("div")||n),n.appendChild(o))},e.prototype._mousedown=function(e){this._toggleEditor(e)&&(this._tmd=!0,e.stopPropagation(),e.preventDefault())},e.prototype._click=function(e){(this._tmd||this._toggleEditor(e))&&(e.stopPropagation(),e.preventDefault()),this._tmd=!1},e.prototype._toggleEditor=function(t){var i=this;if(this._tmd=!1,!t.defaultPrevented&&0==t.button)if(wijmo_1.closestClass(t.target,e._WJC_FILTER)){var n=this._g,r=n.hitTest(t.target);if(r.panel||(r=n.hitTest(t)),r.panel==n.columnHeaders||r.panel==n.cells&&-1==r.row){var o=n.columns[r.col],l=n._getBindingColumn(r.panel,r.row,o);return this._divEdt&&this._edtCol==l?(this.closeEditor(),n.focus()):setTimeout(function(){i.editColumnFilter(l,r)},this._divEdt?100:0),!0}}else this.closeEditor();return!1},e.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,n=i.col>-1?t.columns[i.col]:null,r=n?t._getBindingColumn(t.cells,i.row,n):null;r&&!r.dataMap&&this.getColumnFilter(r,!0)&&(this.editColumnFilter(r),e.preventDefault(),e.stopPropagation())}},e._WJC_FILTER="wj-elem-filter",e}();exports.FlexGridFilter=FlexGridFilter,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){function t(t,i,n){void 0===n&&(n=!0);var r=e.call(this,t,null,!0)||this;r.filterChanged=new wijmo_1.Event,r.buttonClicked=new wijmo_1.Event,r._filter=wijmo_1.asType(i,ColumnFilter);var o=r.getTemplate();r.applyTemplate("wj-control wj-content wj-columnfiltereditor",o,{_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 l=wijmo_1.culture.FlexGridFilter,a=l.ariaLabels,s=r.hostElement,u=r.filter.column,c=u.grid.collectionView;wijmo_1.setAttribute(s,"role","dialog"),wijmo_1.setAriaLabel(s,a.dialog+" "+u.header),wijmo_1.setAriaLabel(r._btnAsc,a.asc),wijmo_1.setAriaLabel(r._btnDsc,a.dsc),wijmo_1.setText(r._btnAsc,l.ascending),wijmo_1.setText(r._btnDsc,l.descending),wijmo_1.setText(r._aVal,l.values),wijmo_1.setText(r._aCnd,l.conditions),wijmo_1.setText(r._btnApply,l.apply),wijmo_1.setText(r._btnCancel,l.cancel),wijmo_1.setText(r._btnClear,l.clear);var d=r.filter.conditionFilter.isActive||0==(i.filterType&FilterType.Value)?FilterType.Condition:FilterType.Value;r._showFilter(d),n&&c&&c.canSort||(r._divSort.style.display="none");var p=r._btnClicked.bind(r);return r._btnApply.addEventListener("click",p),r._btnCancel.addEventListener("click",p),r._btnClear.addEventListener("click",p),r._btnAsc.addEventListener("click",p),r._btnDsc.addEventListener("click",p),r._aVal.addEventListener("click",p),r._aCnd.addEventListener("click",p),r.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:t&&(r._btnClicked(e),e.preventDefault());break;case wijmo_1.Key.Enter:t?r._btnClicked(e):(r.updateFilter(),r.onFilterChanged(),r.onButtonClicked()),e.preventDefault();break;case wijmo_1.Key.Escape:r.onButtonClicked(),e.preventDefault();break;case wijmo_1.Key.Tab:wijmo_1.moveFocus(r.hostElement,e.shiftKey?-1:1),e.preventDefault()}}}),r.addEventListener(window,"resize",function(){r.isTouching||r._wasTouching||r.onButtonClicked()}),r}return __extends(t,e),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),t.prototype.updateEditor=function(){this._edtVal&&this._edtVal.updateEditor(),this._edtCnd&&this._edtCnd.updateEditor()},t.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()}},t.prototype.onFilterChanged=function(e){this.filterChanged.raise(this,e)},t.prototype.onButtonClicked=function(e){this.buttonClicked.raise(this,e)},t.prototype._showFilter=function(e){this._wasTouching=this.isTouching,e==FilterType.Value&&null==this._edtVal&&(this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter)),e==FilterType.Condition&&null==this._edtCnd&&(this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter)),0!=(e&this.filter.filterType)&&(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()):(this._divEdtVal.style.display="none",this._divEdtCnd.style.display="",this._enableLink(this._aVal,!0),this._enableLink(this._aCnd,!1),this._edtCnd.focus()));var t=this._divType.style;switch(this.filter.filterType){case FilterType.None:case FilterType.Condition:case FilterType.Value:t.display="none";break;default:t.display=""}},t.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")},t.prototype._getFilterType=function(){var e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition},t.prototype._btnClicked=function(e){var t=e.target;if(e.preventDefault(),e.stopPropagation(),!wijmo_1.hasClass(t,"wj-state-disabled")){if(t==this._aVal)return this._showFilter(FilterType.Value),void wijmo_1.moveFocus(this._edtVal.hostElement,0);if(t==this._aCnd)return this._showFilter(FilterType.Condition),void wijmo_1.moveFocus(this._edtCnd.hostElement,0);if(t==this._btnAsc||t==this._btnDsc){var i=this.filter.column,n=i.sortMemberPath?i.sortMemberPath:i.binding,r=i.grid.collectionView,o=new wijmo_1.SortDescription(n,e.target==this._btnAsc);r.sortDescriptions.deferUpdate(function(){r.sortDescriptions.clear(),r.sortDescriptions.push(o)})}t==this._btnApply?(this.updateFilter(),this.onFilterChanged()):t==this._btnClear?this.filter.isActive&&(this.filter.clear(),this.onFilterChanged()):this.updateEditor(),this.onButtonClicked()}},t.controlTemplate='<div><div wj-part="div-sort"><button wj-part="btn-asc" class="wj-btn" style="min-width:95px"></button> <button wj-part="btn-dsc" class="wj-btn" style="min-width:95px"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a> | <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> <button wj-part="btn-cancel" class="wj-btn"></button> <button wj-part="btn-clear" class="wj-btn"></button></div>',t}(wijmo_1.Control);exports.ColumnFilterEditor=ColumnFilterEditor,wijmo_1._registerModule("wijmo.grid.filter",selfModule); |
{ | ||
"name": "@grapecity/wijmo.grid.filter", | ||
"version": "5.20191.599-nightly.d20190408.t120542", | ||
"version": "5.20191.599-nightly.d20190408.t162215", | ||
"description": "UI library for pure JS, Angular, React, Vue and more...", | ||
@@ -10,5 +10,5 @@ "author": "GrapeCity, Inc", | ||
"dependencies": { | ||
"@grapecity/wijmo": "5.20191.599-nightly.d20190408.t120542", | ||
"@grapecity/wijmo.input": "5.20191.599-nightly.d20190408.t120542", | ||
"@grapecity/wijmo.grid": "5.20191.599-nightly.d20190408.t120542" | ||
"@grapecity/wijmo": "5.20191.599-nightly.d20190408.t162215", | ||
"@grapecity/wijmo.input": "5.20191.599-nightly.d20190408.t162215", | ||
"@grapecity/wijmo.grid": "5.20191.599-nightly.d20190408.t162215" | ||
}, | ||
@@ -15,0 +15,0 @@ "module": "./es5-esm.js", |
/*! | ||
* | ||
* Wijmo Library 5.20191.599-nightly.d20190408.t120542 | ||
* Wijmo Library 5.20191.599-nightly.d20190408.t162215 | ||
* http://wijmo.com/ | ||
@@ -785,3 +785,2 @@ * | ||
onButtonClicked(e?: EventArgs): void; | ||
protected _handleResize(): void; | ||
_showFilter(filterType: FilterType): void; | ||
@@ -788,0 +787,0 @@ _enableLink(a: HTMLLinkElement, enable: boolean): void; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1626
+ Added@grapecity/wijmo@5.20191.599-nightly.d20190408.t162215(transitive)
+ Added@grapecity/wijmo.grid@5.20191.599-nightly.d20190408.t162215(transitive)
+ Added@grapecity/wijmo.input@5.20191.599-nightly.d20190408.t162215(transitive)
+ Added@grapecity/wijmo.styles@5.20191.599-nightly.d20190408.t162215(transitive)
- Removed@grapecity/wijmo@5.20191.599-nightly.d20190408.t120542(transitive)
- Removed@grapecity/wijmo.grid@5.20191.599-nightly.d20190408.t120542(transitive)
- Removed@grapecity/wijmo.input@5.20191.599-nightly.d20190408.t120542(transitive)
- Removed@grapecity/wijmo.styles@5.20191.599-nightly.d20190408.t120542(transitive)
Updated@grapecity/wijmo@5.20191.599-nightly.d20190408.t162215
Updated@grapecity/wijmo.grid@5.20191.599-nightly.d20190408.t162215
Updated@grapecity/wijmo.input@5.20191.599-nightly.d20190408.t162215