@empathyco/x-components
Version:
Empathy X Components
36 lines (33 loc) • 1.07 kB
JavaScript
import { BaseFilterEntityModifier } from './types.js';
/**
* Allows to persist a filter between different queries.
*
* @remarks when using this modifier along with others, make sure this is the first one defined.
*
* @internal
*/
class StickyModifier extends BaseFilterEntityModifier {
/**
* Deselects the passed filter unless the metadata has the `keepSticky` flag enabled.
*
* @param filter - The filter to deselect.
* @param metadata - Additional information to prevent a filter from being deselected.
*/
deselect(filter, metadata) {
if (!metadata?.keepSticky) {
super.deselect(filter, metadata);
this.store.commit('x/facets/removeStickyFilter', filter);
}
}
/**
* Selects the passed filter and stores it as sticky.
*
* @param filter - The filter to select.
*/
select(filter) {
super.select(filter);
this.store.commit('x/facets/setStickyFilter', filter);
}
}
export { StickyModifier };
//# sourceMappingURL=sticky.modifier.js.map