@ag-grid-enterprise/set-filter
Advanced tools
Comparing version 27.0.0 to 27.1.0
/** | ||
* @ag-grid-enterprise/set-filter - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v27.0.0 | ||
* @link http://www.ag-grid.com/ | ||
' * @license Commercial | ||
*/ | ||
* @ag-grid-enterprise/set-filter - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v27.1.0 | ||
* @link http://www.ag-grid.com/ | ||
* @license Commercial | ||
*/ | ||
'use strict'; | ||
@@ -8,0 +7,0 @@ |
/** | ||
* @ag-grid-enterprise/set-filter - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v27.0.0 | ||
* @link http://www.ag-grid.com/ | ||
' * @license Commercial | ||
*/ | ||
* @ag-grid-enterprise/set-filter - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v27.1.0 | ||
* @link http://www.ag-grid.com/ | ||
* @license Commercial | ||
*/ | ||
/** | ||
* @ag-grid-enterprise/set-filter - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v27.0.0 | ||
* @link http://www.ag-grid.com/ | ||
' * @license Commercial | ||
*/ | ||
* @ag-grid-enterprise/set-filter - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v27.1.0 | ||
* @link http://www.ag-grid.com/ | ||
* @license Commercial | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("@ag-grid-community/core"),i=require("@ag-grid-enterprise/core"),r=function(){function e(e,t,i){this.rowModel=e,this.filterParams=t,this.caseFormat=i}return e.prototype.extractUniqueValues=function(e){var i=this,r={},l=this.filterParams.colDef.keyCreator,o=function(e){var t=null!=e?i.caseFormat(e):"__<ag-grid-pseudo-null>__";t&&null==r[t]&&(r[t]=e)};return this.rowModel.forEachLeafNode((function(r){if(r.data&&e(r)){var n=i.filterParams,s=n.api,a=n.colDef,u=n.column,c=n.columnApi,h=n.context,d=i.filterParams.valueGetter({api:s,colDef:a,column:u,columnApi:c,context:h,data:r.data,getValue:function(e){return r.data[e]},node:r});if(l){var p={value:d,colDef:i.filterParams.colDef,column:i.filterParams.column,node:r,data:r.data,api:i.filterParams.api,columnApi:i.filterParams.columnApi,context:i.filterParams.context};d=l(p)}null!=(d=t._.makeNull(d))&&Array.isArray(d)?d.forEach((function(e){var i=t._.toStringOrNull(t._.makeNull(e));o(i)})):o(t._.toStringOrNull(d))}})),t._.values(r)},e}();!function(e){e[e.PROVIDED_LIST=0]="PROVIDED_LIST",e[e.PROVIDED_CALLBACK=1]="PROVIDED_CALLBACK",e[e.TAKEN_FROM_GRID_VALUES=2]="TAKEN_FROM_GRID_VALUES"}(e||(e={}));var l,o=function(){function i(i,l,o,n,s){var a=this;this.filterParams=i,this.setIsLoading=l,this.valueFormatterService=o,this.translate=n,this.caseFormat=s,this.localEventService=new t.EventService,this.miniFilterText=null,this.providedValues=null,this.allValues=[],this.availableValues=new Set,this.displayedValues=[],this.selectedValues=new Set,this.initialised=!1;var u=i.column,c=i.colDef,h=i.textFormatter,d=i.doesRowPassOtherFilter,p=i.suppressSorting,f=i.comparator,v=i.rowModel,y=i.values;i.caseSensitive;this.column=u,this.formatter=h||t.TextFilter.DEFAULT_FORMATTER,this.doesRowPassOtherFilters=d,this.suppressSorting=p||!1,this.comparator=f||c.comparator||t._.defaultComparator,v.getType()===t.Constants.ROW_MODEL_TYPE_CLIENT_SIDE&&(this.clientSideValuesExtractor=new r(v,this.filterParams,this.caseFormat)),null==y?this.valuesType=e.TAKEN_FROM_GRID_VALUES:(this.valuesType=Array.isArray(y)?e.PROVIDED_LIST:e.PROVIDED_CALLBACK,this.providedValues=y),this.updateAllValues().then((function(e){return a.resetSelectionState(e||[])}))}return i.prototype.addEventListener=function(e,t,i){this.localEventService.addEventListener(e,t,i)},i.prototype.removeEventListener=function(e,t,i){this.localEventService.removeEventListener(e,t,i)},i.prototype.refreshValues=function(){var e=this.getModel();return this.updateAllValues(),this.setModel(e)},i.prototype.overrideValues=function(i){var r=this;return new t.AgPromise((function(t){r.allValuesPromise.then((function(){r.valuesType=e.PROVIDED_LIST,r.providedValues=i,r.refreshValues().then((function(){return t()}))}))}))},i.prototype.refreshAfterAnyFilterChanged=function(){var e=this;return this.showAvailableOnly()?this.allValuesPromise.then((function(t){return e.updateAvailableValues(t||[])})):t.AgPromise.resolve()},i.prototype.isInitialised=function(){return this.initialised},i.prototype.updateAllValues=function(){var i=this;return this.allValuesPromise=new t.AgPromise((function(r){switch(i.valuesType){case e.TAKEN_FROM_GRID_VALUES:case e.PROVIDED_LIST:var l=i.valuesType===e.TAKEN_FROM_GRID_VALUES?i.getValuesFromRows(!1):t._.values(i.uniqueValues(t._.toStrings(i.providedValues)||[])),o=i.sortValues(l||[]);i.allValues=o,r(o);break;case e.PROVIDED_CALLBACK:i.setIsLoading(!0);var n=i.providedValues,s=i.filterParams,a=s.columnApi,u=s.api,c=s.context,h=s.column,d={success:function(e){var l=t._.values(i.uniqueValues(t._.toStrings(e)||[]));i.setIsLoading(!1);var o=i.sortValues(l||[]);i.allValues=o,r(o)},colDef:s.colDef,column:h,columnApi:a,api:u,context:c};window.setTimeout((function(){return n(d)}),0);break;default:throw new Error("Unrecognised valuesType")}})),this.allValuesPromise.then((function(e){return i.updateAvailableValues(e||[])})).then((function(){return i.initialised=!0})),this.allValuesPromise},i.prototype.setValuesType=function(e){this.valuesType=e},i.prototype.getValuesType=function(){return this.valuesType},i.prototype.isValueAvailable=function(e){return this.availableValues.has(e)},i.prototype.showAvailableOnly=function(){return this.valuesType===e.TAKEN_FROM_GRID_VALUES},i.prototype.updateAvailableValues=function(e){var r=this.showAvailableOnly()?this.sortValues(this.getValuesFromRows(!0)):e;this.availableValues=t._.convertToSet(r),this.localEventService.dispatchEvent({type:i.EVENT_AVAILABLE_VALUES_CHANGED}),this.updateDisplayedValues()},i.prototype.sortValues=function(e){return this.suppressSorting?e:!this.filterParams.excelMode||e.indexOf(null)<0?e.sort(this.comparator):e.filter((function(e){return null!=e})).sort(this.comparator).concat(null)},i.prototype.getValuesFromRows=function(e){var t=this;if(void 0===e&&(e=!1),!this.clientSideValuesExtractor)return console.error("AG Grid: Set Filter cannot initialise because you are using a row model that does not contain all rows in the browser. Either use a different filter type, or configure Set Filter such that you provide it with values"),[];return this.clientSideValuesExtractor.extractUniqueValues((function(i){return!e||t.doesRowPassOtherFilters(i)}))},i.prototype.setMiniFilter=function(e){return e=t._.makeNull(e),this.miniFilterText!==e&&(this.miniFilterText=e,this.updateDisplayedValues(),!0)},i.prototype.getMiniFilter=function(){return this.miniFilterText},i.prototype.updateDisplayedValues=function(){var e=this;if(null!=this.miniFilterText){this.displayedValues=[];var i=this.caseFormat(this.formatter(this.miniFilterText)||""),r=function(t){return null!=t&&e.caseFormat(t).indexOf(i)>=0};this.availableValues.forEach((function(t){if(null==t)e.filterParams.excelMode&&r(e.translate("blanks"))&&e.displayedValues.push(t);else{var i=e.formatter(t),l=e.valueFormatterService.formatValue(e.column,null,null,i,e.filterParams.valueFormatter,!1);(r(i)||r(l))&&e.displayedValues.push(t)}}))}else this.displayedValues=t._.values(this.availableValues)},i.prototype.getDisplayedValueCount=function(){return this.displayedValues.length},i.prototype.getDisplayedValue=function(e){return this.displayedValues[e]},i.prototype.hasSelections=function(){return this.filterParams.defaultToNothingSelected?this.selectedValues.size>0:this.allValues.length!==this.selectedValues.size},i.prototype.getValues=function(){return this.allValues.slice()},i.prototype.selectAllMatchingMiniFilter=function(e){var i=this;void 0===e&&(e=!1),null==this.miniFilterText?this.selectedValues=t._.convertToSet(this.allValues):(e&&this.selectedValues.clear(),this.displayedValues.forEach((function(e){return i.selectedValues.add(e)})))},i.prototype.deselectAllMatchingMiniFilter=function(){var e=this;null==this.miniFilterText?this.selectedValues.clear():this.displayedValues.forEach((function(t){return e.selectedValues.delete(t)}))},i.prototype.selectValue=function(e){this.selectedValues.add(e)},i.prototype.deselectValue=function(e){this.filterParams.excelMode&&this.isEverythingVisibleSelected()&&this.resetSelectionState(this.displayedValues),this.selectedValues.delete(e)},i.prototype.isValueSelected=function(e){return this.selectedValues.has(e)},i.prototype.isEverythingVisibleSelected=function(){var e=this;return this.displayedValues.filter((function(t){return e.isValueSelected(t)})).length===this.displayedValues.length},i.prototype.isNothingVisibleSelected=function(){var e=this;return 0===this.displayedValues.filter((function(t){return e.isValueSelected(t)})).length},i.prototype.getModel=function(){return this.hasSelections()?t._.values(this.selectedValues):null},i.prototype.setModel=function(e){var t=this;return this.allValuesPromise.then((function(i){if(null==e)t.resetSelectionState(i||[]);else{t.selectedValues.clear();var r=t.uniqueValues(i||[]);e.forEach((function(e){var i=r[t.uniqueKey(e)];void 0!==i&&t.selectedValues.add(i)}))}}))},i.prototype.uniqueValues=function(e){var i=this,r={};return(e||[]).forEach((function(e){var l=t._.makeNull(e),o=i.uniqueKey(l);void 0===r[o]&&(r[o]=l)})),r},i.prototype.uniqueKey=function(e){return null==e?"__<ag-grid-pseudo-null>__":this.caseFormat(e)},i.prototype.resetSelectionState=function(e){this.filterParams.defaultToNothingSelected?this.selectedValues.clear():this.selectedValues=t._.convertToSet(e||[])},i.EVENT_AVAILABLE_VALUES_CHANGED="availableValuesChanged",i}(),n=(l=function(e,t){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),s=function(e,t,i,r){var l,o=arguments.length,n=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var s=e.length-1;s>=0;s--)(l=e[s])&&(n=(o<3?l(n):o>3?l(t,i,n):l(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n},a=function(e){function i(t,r,l,o){var n=e.call(this,i.TEMPLATE)||this;return n.value=t,n.params=r,n.translate=l,n.isSelected=o,n}return n(i,e),i.prototype.init=function(){var e=this;this.render(),this.eCheckbox.setValue(this.isSelected,!0),this.eCheckbox.setDisabled(!!this.params.readOnly),this.params.readOnly||this.eCheckbox.onValueChange((function(t){var r=t||!1;e.isSelected=r;var l={type:i.EVENT_SELECTION_CHANGED,isSelected:r};e.dispatchEvent(l)}))},i.prototype.toggleSelected=function(){this.params.readOnly||(this.isSelected=!this.isSelected,this.eCheckbox.setValue(this.isSelected))},i.prototype.render=function(){var e=this.params.column,t=this.value,i=null;if("function"==typeof t?t=t():i=this.getFormattedValue(this.params,e,t),this.params.showTooltips){var r=null!=i?i:t;this.setTooltip(r)}var l={value:t,valueFormatted:i,api:this.gridOptionsWrapper.getApi(),columnApi:this.gridOptionsWrapper.getColumnApi(),context:this.gridOptionsWrapper.getContext(),colDef:this.params.colDef,column:this.params.column};this.renderCell(l)},i.prototype.getTooltipParams=function(){var t=e.prototype.getTooltipParams.call(this);return t.location="setFilterValue",t.colDef=this.getComponentHolder(),t},i.prototype.getFormattedValue=function(e,t,i){var r=e&&e.valueFormatter;return this.valueFormatterService.formatValue(t,null,null,i,r,!1)},i.prototype.renderCell=function(e){var t=this,i=this.userComponentFactory.getSetFilterCellRendererDetails(this.params,e),r=i?i.newAgStackInstance():void 0;if(null!=r)r.then((function(e){e&&(t.eCheckbox.setLabel(e.getGui()),t.addDestroyFunc((function(){return t.destroyBean(e)})))}));else{var l=null==e.valueFormatted?e.value:e.valueFormatted;this.eCheckbox.setLabel(null==l?this.translate("blanks"):l)}},i.prototype.getComponentHolder=function(){return this.params.column.getColDef()},i.EVENT_SELECTION_CHANGED="selectionChanged",i.TEMPLATE='\n <div class="ag-set-filter-item">\n <ag-checkbox ref="eCheckbox" class="ag-set-filter-item-checkbox"></ag-checkbox>\n </div>',s([t.Autowired("valueFormatterService")],i.prototype,"valueFormatterService",void 0),s([t.Autowired("userComponentFactory")],i.prototype,"userComponentFactory",void 0),s([t.RefSelector("eCheckbox")],i.prototype,"eCheckbox",void 0),s([t.PostConstruct],i.prototype,"init",null),i}(t.Component),u={loadingOoo:"Loading...",blanks:"(Blanks)",searchOoo:"Search...",selectAll:"(Select All)",selectAllSearchResults:"(Select All Search Results)",noMatches:"No matches."},c=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 r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}}(),h=function(e,t,i,r){var l,o=arguments.length,n=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var s=e.length-1;s>=0;s--)(l=e[s])&&(n=(o<3?l(n):o>3?l(t,i,n):l(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n},d=function(i){function r(){var e=i.call(this,"setFilter")||this;return e.valueModel=null,e.setFilterParams=null,e.virtualList=null,e.caseSensitive=!1,e.appliedModelValues=null,e}return c(r,i),r.prototype.postConstruct=function(){i.prototype.postConstruct.call(this),this.positionableFeature=new t.PositionableFeature(this.eSetFilterList,{forcePopupParentAsOffsetParent:!0}),this.createBean(this.positionableFeature)},r.prototype.updateUiVisibility=function(){},r.prototype.createBodyTemplate=function(){return'\n <div class="ag-set-filter">\n <div ref="eFilterLoading" class="ag-filter-loading ag-hidden">'+this.translateForSetFilter("loadingOoo")+'</div>\n <ag-input-text-field class="ag-mini-filter" ref="eMiniFilter"></ag-input-text-field>\n <div ref="eFilterNoMatches" class="ag-filter-no-matches ag-hidden">'+this.translateForSetFilter("noMatches")+'</div>\n <div ref="eSetFilterList" class="ag-set-filter-list" role="presentation"></div>\n </div>'},r.prototype.handleKeyDown=function(e){if(i.prototype.handleKeyDown.call(this,e),!e.defaultPrevented)switch(e.key){case t.KeyCode.SPACE:this.handleKeySpace(e);break;case t.KeyCode.ENTER:this.handleKeyEnter(e)}},r.prototype.handleKeySpace=function(e){var t=this.gridOptionsWrapper.getDocument();if(this.eSetFilterList.contains(t.activeElement)&&this.virtualList){var i=this.virtualList.getLastFocusedRow();if(null!=i){var r=this.virtualList.getComponentAt(i);if(null!=r)e.preventDefault(),(this.setFilterParams||{}).readOnly||r.toggleSelected()}}},r.prototype.handleKeyEnter=function(e){if(this.setFilterParams){var t=this.setFilterParams||{},i=t.excelMode,r=t.readOnly;i&&!r&&(e.preventDefault(),this.onBtApply(!1,!1,e),"mac"===this.setFilterParams.excelMode&&this.eMiniFilter.getInputElement().select())}},r.prototype.getCssIdentifier=function(){return"set-filter"},r.prototype.setModelAndRefresh=function(e){var i=this;return this.valueModel?this.valueModel.setModel(e).then((function(){return i.refresh()})):t.AgPromise.resolve()},r.prototype.resetUiToDefaults=function(){return this.setMiniFilter(null),this.setModelAndRefresh(null)},r.prototype.setModelIntoUi=function(e){this.setMiniFilter(null);var t=null==e?null:e.values;return this.setModelAndRefresh(t)},r.prototype.getModelFromUi=function(){if(!this.valueModel)throw new Error("Value model has not been created.");var e=this.valueModel.getModel();return e?{values:e,filterType:this.getFilterType()}:null},r.prototype.getFilterType=function(){return"set"},r.prototype.getValueModel=function(){return this.valueModel},r.prototype.areModelsEqual=function(e,i){return null==e&&null==i||null!=e&&null!=i&&t._.areEqual(e.values,i.values)},r.prototype.setParams=function(e){var r=this;this.applyExcelModeOptions(e),i.prototype.setParams.call(this,e),this.setFilterParams=e,this.caseSensitive=e.caseSensitive||!1,this.valueModel=new o(e,(function(e){return r.showOrHideLoadingScreen(e)}),this.valueFormatterService,(function(e){return r.translateForSetFilter(e)}),(function(e){return r.caseFormat(e)})),this.initialiseFilterBodyUi(),e.rowModel.getType()!==t.Constants.ROW_MODEL_TYPE_CLIENT_SIDE||e.values||this.addEventListenersForDataChanges()},r.prototype.applyExcelModeOptions=function(e){"windows"===e.excelMode?(e.buttons||(e.buttons=["apply","cancel"]),null==e.closeOnApply&&(e.closeOnApply=!0)):"mac"===e.excelMode&&(e.buttons||(e.buttons=["reset"]),null==e.applyMiniFilterWhileTyping&&(e.applyMiniFilterWhileTyping=!0),null==e.debounceMs&&(e.debounceMs=500))},r.prototype.addEventListenersForDataChanges=function(){var e=this;this.addManagedListener(this.eventService,t.Events.EVENT_ROW_DATA_UPDATED,(function(){return e.syncAfterDataChange()})),this.addManagedListener(this.eventService,t.Events.EVENT_CELL_VALUE_CHANGED,(function(t){e.setFilterParams&&t.column===e.setFilterParams.column&&e.syncAfterDataChange()}))},r.prototype.syncAfterDataChange=function(e){var i=this;if(void 0===e&&(e=!0),!this.valueModel)throw new Error("Value model has not been created.");var r=t.AgPromise.resolve();return e&&(r=this.valueModel.refreshValues()),r.then((function(){i.refresh(),i.onBtApply(!1,!0)}))},r.prototype.showOrHideLoadingScreen=function(e){t._.setDisplayed(this.eFilterLoading,e)},r.prototype.initialiseFilterBodyUi=function(){this.initVirtualList(),this.initMiniFilter()},r.prototype.initVirtualList=function(){var e=this;if(!this.setFilterParams)throw new Error("Set filter params have not been provided.");if(!this.valueModel)throw new Error("Value model has not been created.");var i=this.gridOptionsWrapper.getLocaleTextFunc()("ariaFilterList","Filter List"),r=this.virtualList=this.createBean(new t.VirtualList("filter","listbox",i)),l=this.getRefElement("eSetFilterList");l&&l.appendChild(r.getGui());var o,n=this.setFilterParams.cellHeight;null!=n&&r.setRowHeight(n),r.setComponentCreator((function(t){return e.createSetListItem(t)})),o=this.setFilterParams.suppressSelectAll?new p(this.valueModel):new f(this.valueModel,(function(){return e.isSelectAllSelected()})),r.setModel(o)},r.prototype.getSelectAllLabel=function(){if(!this.setFilterParams)throw new Error("Set filter params have not been provided.");if(!this.valueModel)throw new Error("Value model has not been created.");var e=null!=this.valueModel.getMiniFilter()&&this.setFilterParams.excelMode?"selectAllSearchResults":"selectAll";return this.translateForSetFilter(e)},r.prototype.createSetListItem=function(e){var t,i=this;if(!this.setFilterParams)throw new Error("Set filter params have not been provided.");if(!this.valueModel)throw new Error("Value model has not been created.");return e===r.SELECT_ALL_VALUE?((t=this.createBean(new a((function(){return i.getSelectAllLabel()}),this.setFilterParams,(function(e){return i.translateForSetFilter(e)}),this.isSelectAllSelected()))).addEventListener(a.EVENT_SELECTION_CHANGED,(function(e){return i.onSelectAll(e.isSelected)})),t):((t=this.createBean(new a(e,this.setFilterParams,(function(e){return i.translateForSetFilter(e)}),this.valueModel.isValueSelected(e)))).addEventListener(a.EVENT_SELECTION_CHANGED,(function(t){return i.onItemSelected(e,t.isSelected)})),t)},r.prototype.initMiniFilter=function(){var e=this;if(!this.setFilterParams)throw new Error("Set filter params have not been provided.");if(!this.valueModel)throw new Error("Value model has not been created.");var t=this.eMiniFilter,i=this.gridOptionsWrapper.getLocaleTextFunc();t.setDisplayed(!this.setFilterParams.suppressMiniFilter),t.setValue(this.valueModel.getMiniFilter()),t.onValueChange((function(){return e.onMiniFilterInput()})),t.setInputAriaLabel(i("ariaSearchFilterValues","Search filter values")),this.addManagedListener(t.getInputElement(),"keypress",(function(t){return e.onMiniFilterKeyPress(t)}))},r.prototype.afterGuiAttached=function(e){if(!this.setFilterParams)throw new Error("Set filter params have not been provided.");i.prototype.afterGuiAttached.call(this,e),this.refreshVirtualList(),this.setFilterParams.excelMode&&this.resetUiToActiveModel();var t=this.eMiniFilter;t.setInputPlaceholder(this.translateForSetFilter("searchOoo")),e&&e.suppressFocus||t.getFocusableElement().focus();var r,l=!(!e||"floatingFilter"!==e.container);r=this.gridOptionsWrapper.isEnableRtl()?{bottom:!0,bottomLeft:!0,left:!0}:{bottom:!0,bottomRight:!0,right:!0},l?(this.positionableFeature.restoreLastSize(),this.positionableFeature.setResizable(r)):(this.positionableFeature.removeSizeFromEl(),this.positionableFeature.setResizable(!1))},r.prototype.applyModel=function(){var e=this;if(!this.setFilterParams)throw new Error("Set filter params have not been provided.");if(!this.valueModel)throw new Error("Value model has not been created.");this.setFilterParams.excelMode&&this.valueModel.isEverythingVisibleSelected()&&this.valueModel.selectAllMatchingMiniFilter();var t=i.prototype.applyModel.call(this),r=this.getModel();return this.appliedModelValues=r?r.values.reduce((function(t,i){return t[e.caseFormat(String(i))]=!0,t}),{}):null,t},r.prototype.isModelValid=function(e){return!this.setFilterParams||!this.setFilterParams.excelMode||(null==e||e.values.length>0)},r.prototype.doesFilterPass=function(e){var i=this;if(!this.setFilterParams||!this.valueModel||!this.appliedModelValues)return!0;var r=e.node,l=e.data,o=this.setFilterParams,n=o.valueGetter,s=o.colDef.keyCreator,a=o.api,u=o.colDef,c=o.column,h=o.columnApi,d=o.context,p=n({api:a,colDef:u,column:c,columnApi:h,context:d,data:l,getValue:function(e){return l[e]},node:r});s&&(p=s({value:p,colDef:u,column:c,node:r,data:l,api:a,columnApi:h,context:d}));return p=t._.makeNull(p),Array.isArray(p)?p.some((function(e){return!0===i.appliedModelValues[i.caseFormat(String(t._.makeNull(e)))]})):!0===this.appliedModelValues[this.caseFormat(String(p))]},r.prototype.onNewRowsLoaded=function(){if(!this.valueModel)throw new Error("Value model has not been created.");var t=this.valueModel.getValuesType();this.syncAfterDataChange(t===e.TAKEN_FROM_GRID_VALUES)},r.prototype.setFilterValues=function(e){var t=this;if(!this.valueModel)throw new Error("Value model has not been created.");this.valueModel.overrideValues(e).then((function(){t.refresh(),t.onUiChanged()}))},r.prototype.resetFilterValues=function(){if(!this.valueModel)throw new Error("Value model has not been created.");this.valueModel.setValuesType(e.TAKEN_FROM_GRID_VALUES),this.syncAfterDataChange(!0)},r.prototype.refreshFilterValues=function(){var e=this;if(!this.valueModel)throw new Error("Value model has not been created.");this.valueModel.isInitialised()&&this.valueModel.refreshValues().then((function(){e.refresh(),e.onUiChanged()}))},r.prototype.onAnyFilterChanged=function(){var e=this;setTimeout((function(){if(e.isAlive()){if(!e.valueModel)throw new Error("Value model has not been created.");e.valueModel.refreshAfterAnyFilterChanged().then((function(){return e.refresh()}))}}),0)},r.prototype.onMiniFilterInput=function(){if(!this.setFilterParams)throw new Error("Set filter params have not been provided.");if(!this.valueModel)throw new Error("Value model has not been created.");if(this.valueModel.setMiniFilter(this.eMiniFilter.getValue())){var e=this.setFilterParams||{},t=e.applyMiniFilterWhileTyping;!e.readOnly&&t?this.filterOnAllVisibleValues(!1):this.updateUiAfterMiniFilterChange()}},r.prototype.updateUiAfterMiniFilterChange=function(){if(!this.setFilterParams)throw new Error("Set filter params have not been provided.");if(!this.valueModel)throw new Error("Value model has not been created.");var e=this.setFilterParams||{},t=e.excelMode,i=e.readOnly;null==t||i?this.refresh():null==this.valueModel.getMiniFilter()?this.resetUiToActiveModel():(this.valueModel.selectAllMatchingMiniFilter(!0),this.refresh(),this.onUiChanged()),this.showOrHideResults()},r.prototype.showOrHideResults=function(){if(!this.valueModel)throw new Error("Value model has not been created.");var e=null!=this.valueModel.getMiniFilter()&&this.valueModel.getDisplayedValueCount()<1;t._.setDisplayed(this.eNoMatches,e),t._.setDisplayed(this.eSetFilterList,!e)},r.prototype.resetUiToActiveModel=function(){var e=this;if(!this.valueModel)throw new Error("Value model has not been created.");this.eMiniFilter.setValue(null,!0),this.valueModel.setMiniFilter(null),this.setModelIntoUi(this.getModel()).then((function(){return e.onUiChanged(!1,"prevent")}))},r.prototype.onMiniFilterKeyPress=function(e){var i=this.setFilterParams||{},r=i.excelMode,l=i.readOnly;e.key!==t.KeyCode.ENTER||r||l||this.filterOnAllVisibleValues()},r.prototype.filterOnAllVisibleValues=function(e){void 0===e&&(e=!0);var t=(this.setFilterParams||{}).readOnly;if(!this.valueModel)throw new Error("Value model has not been created.");if(t)throw new Error("Unable to filter in readOnly mode.");this.valueModel.selectAllMatchingMiniFilter(!0),this.refresh(),this.onUiChanged(!1,e?"immediately":"debounce"),this.showOrHideResults()},r.prototype.focusRowIfAlive=function(e){var t=this;null!=e&&window.setTimeout((function(){if(!t.virtualList)throw new Error("Virtual list has not been created.");t.isAlive()&&t.virtualList.focusRow(e)}),0)},r.prototype.onSelectAll=function(e){if(!this.valueModel)throw new Error("Value model has not been created.");if(!this.virtualList)throw new Error("Virtual list has not been created.");e?this.valueModel.selectAllMatchingMiniFilter():this.valueModel.deselectAllMatchingMiniFilter();var t=this.virtualList.getLastFocusedRow();this.refresh(),this.onUiChanged(),this.focusRowIfAlive(t)},r.prototype.onItemSelected=function(e,t){if(!this.valueModel)throw new Error("Value model has not been created.");if(!this.virtualList)throw new Error("Virtual list has not been created.");t?this.valueModel.selectValue(e):this.valueModel.deselectValue(e);var i=this.virtualList.getLastFocusedRow();this.refresh(),this.onUiChanged(),this.focusRowIfAlive(i)},r.prototype.setMiniFilter=function(e){this.eMiniFilter.setValue(e),this.onMiniFilterInput()},r.prototype.getMiniFilter=function(){return this.valueModel?this.valueModel.getMiniFilter():null},r.prototype.refresh=function(){if(!this.virtualList)throw new Error("Virtual list has not been created.");this.virtualList.refresh()},r.prototype.getValues=function(){return this.valueModel?this.valueModel.getValues():[]},r.prototype.refreshVirtualList=function(){this.setFilterParams&&this.setFilterParams.refreshValuesOnOpen?this.refreshFilterValues():this.refresh()},r.prototype.translateForSetFilter=function(e){return this.gridOptionsWrapper.getLocaleTextFunc()(e,u[e])},r.prototype.isSelectAllSelected=function(){if(!this.setFilterParams||!this.valueModel)return!1;if(this.setFilterParams.defaultToNothingSelected){if(this.valueModel.hasSelections()&&this.valueModel.isEverythingVisibleSelected())return!0;if(this.valueModel.isNothingVisibleSelected())return!1}else{if(this.valueModel.hasSelections()&&this.valueModel.isNothingVisibleSelected())return!1;if(this.valueModel.isEverythingVisibleSelected())return!0}},r.prototype.destroy=function(){null!=this.virtualList&&(this.virtualList.destroy(),this.virtualList=null),i.prototype.destroy.call(this)},r.prototype.caseFormat=function(e){return null==e||"string"!=typeof e||this.caseSensitive?e:e.toUpperCase()},r.SELECT_ALL_VALUE="__AG_SELECT_ALL__",h([t.RefSelector("eMiniFilter")],r.prototype,"eMiniFilter",void 0),h([t.RefSelector("eFilterLoading")],r.prototype,"eFilterLoading",void 0),h([t.RefSelector("eSetFilterList")],r.prototype,"eSetFilterList",void 0),h([t.RefSelector("eFilterNoMatches")],r.prototype,"eNoMatches",void 0),h([t.Autowired("valueFormatterService")],r.prototype,"valueFormatterService",void 0),r}(t.ProvidedFilter),p=function(){function e(e){this.model=e}return e.prototype.getRowCount=function(){return this.model.getDisplayedValueCount()},e.prototype.getRow=function(e){return this.model.getDisplayedValue(e)},e.prototype.isRowSelected=function(e){return this.model.isValueSelected(this.getRow(e))},e}(),f=function(){function e(e,t){this.model=e,this.isSelectAllSelected=t}return e.prototype.getRowCount=function(){return this.model.getDisplayedValueCount()+1},e.prototype.getRow=function(e){return 0===e?d.SELECT_ALL_VALUE:this.model.getDisplayedValue(e-1)},e.prototype.isRowSelected=function(e){return 0===e?this.isSelectAllSelected():this.model.isValueSelected(this.getRow(e))},e}(),v=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 r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}}(),y=function(e,t,i,r){var l,o=arguments.length,n=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var s=e.length-1;s>=0;s--)(l=e[s])&&(n=(o<3?l(n):o>3?l(t,i,n):l(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n},m=function(e){function i(){var t=e.call(this,'\n <div class="ag-floating-filter-input" role="presentation">\n <ag-input-text-field ref="eFloatingFilterText"></ag-input-text-field>\n </div>')||this;return t.availableValuesListenerAdded=!1,t}return v(i,e),i.prototype.destroy=function(){e.prototype.destroy.call(this)},i.prototype.init=function(e){var t=this.columnModel.getDisplayNameForColumn(e.column,"header",!0),i=this.gridOptionsWrapper.getLocaleTextFunc();this.eFloatingFilterText.setDisabled(!0).setInputAriaLabel(t+" "+i("ariaFilterInput","Filter Input")).addGuiEventListener("click",(function(){return e.showParentFilter()})),this.params=e},i.prototype.onParentModelChanged=function(e){this.updateFloatingFilterText(e)},i.prototype.parentSetFilterInstance=function(e){this.params.parentFilterInstance((function(t){if(!(t instanceof d))throw new Error("AG Grid - SetFloatingFilter expects SetFilter as it's parent");e(t)}))},i.prototype.addAvailableValuesListener=function(){var e=this;this.parentSetFilterInstance((function(t){var i=t.getValueModel();i&&e.addManagedListener(i,o.EVENT_AVAILABLE_VALUES_CHANGED,(function(){return e.updateFloatingFilterText()}))})),this.availableValuesListenerAdded=!0},i.prototype.updateFloatingFilterText=function(e){var t=this;this.availableValuesListenerAdded||this.addAvailableValuesListener(),this.parentSetFilterInstance((function(i){var r=(e||i.getModel()||{}).values,l=i.getValueModel();if(null!=r&&null!=l){var o=t.gridOptionsWrapper.getLocaleTextFunc(),n=r.filter((function(e){return l.isValueAvailable(e)})).map((function(e){var i=t.params,r=i.column,l=i.filterParams,n=t.valueFormatterService.formatValue(r,null,null,e,l.valueFormatter,!1),s=null!=n?n:e;return null==s?o("blanks",u.blanks):s})),s=n.length>10?n.slice(0,10).concat("..."):n,a="("+n.length+") "+s.join(",");t.eFloatingFilterText.setValue(a)}else t.eFloatingFilterText.setValue("")}))},y([t.RefSelector("eFloatingFilterText")],i.prototype,"eFloatingFilterText",void 0),y([t.Autowired("valueFormatterService")],i.prototype,"valueFormatterService",void 0),y([t.Autowired("columnModel")],i.prototype,"columnModel",void 0),i}(t.Component),F={moduleName:t.ModuleNames.SetFilterModule,beans:[],userComponents:[{componentName:"agSetColumnFilter",componentClass:d},{componentName:"agSetColumnFloatingFilter",componentClass:m}],dependantModules:[i.EnterpriseCoreModule]};exports.SetFilter=d,exports.SetFilterModule=F; |
{ | ||
"name": "@ag-grid-enterprise/set-filter", | ||
"version": "27.0.0", | ||
"version": "27.1.0", | ||
"description": "Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue", | ||
@@ -47,4 +47,4 @@ "main": "./dist/cjs/es5/main.js", | ||
"dependencies": { | ||
"@ag-grid-community/core": "~27.0.0", | ||
"@ag-grid-enterprise/core": "~27.0.0" | ||
"@ag-grid-community/core": "~27.1.0", | ||
"@ag-grid-enterprise/core": "~27.1.0" | ||
}, | ||
@@ -51,0 +51,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
743749
9125
1
+ Added@ag-grid-community/core@27.1.0(transitive)
+ Added@ag-grid-enterprise/core@27.1.0(transitive)
- Removed@ag-grid-community/core@27.0.1(transitive)
- Removed@ag-grid-enterprise/core@27.0.1(transitive)