@empathyco/x-components
Version:
Empathy X Components
66 lines • 2.27 kB
TypeScript
import type { Filter } from '@empathyco/x-types';
import type { Dictionary } from '@empathyco/x-utils';
import type { Store } from 'vuex';
import type { RootXStoreState } from '../../../store/store.types';
/**
* Contains business logic to select or deselect a filter of a certain type.
*
* @internal
*/
export interface FilterEntity<Metadata extends Dictionary = Dictionary<unknown>> {
/** Selects the filter. */
select: (filter: Filter) => void;
/** Deselects the filter. */
deselect: (filter: Filter, metadata?: Metadata) => void;
}
/**
* Constructor of a {@link FilterEntity}.
*
* @internal
*/
export interface FilterEntityConstructor {
new (store: Store<RootXStoreState>): FilterEntity;
/**
* Checks if this class can create an instance with the passed filter DTO.
*
* @param filter - The filter to check if this class can create an instance with it.
* @returns True if this class can create an instance with it. False otherwise.
*/
accepts: (filter: Filter) => boolean;
}
/**
* The FilterEntityModifier constructor.
*
* @param store - The {@link https://vuex.vuejs.org/api/#vuex-store | Vuex Store} that modifier
* uses.
* @param entity - The {@link FilterEntity } that the modifier modifies.
*
* @internal
*/
export interface FilterEntityModifier<Metadata extends Dictionary = Dictionary> {
new (store: Store<RootXStoreState>, entity: FilterEntity<Metadata>): FilterEntity<Metadata>;
}
/**
* The base class for any Modifier. It delegates to the `entity` methods by default.
*
* @internal
*/
export declare abstract class BaseFilterEntityModifier<Metadata extends Dictionary = Dictionary> implements FilterEntity<Metadata> {
protected store: Store<RootXStoreState>;
protected entity: FilterEntity;
constructor(store: Store<RootXStoreState>, entity: FilterEntity);
/**
* Selects the filter passed by parameter.
*
* @param filter - The filter to select.
*/
select(filter: Filter): void;
/**
* Deselects the filter passed by parameter.
*
* @param filter - The filter to deselect.
* @param metadata - The event metadata.
*/
deselect(filter: Filter, metadata?: Metadata): void;
}
//# sourceMappingURL=types.d.ts.map