@loadsmart/miranda-wc
Version:
Miranda Web Components component library
43 lines (42 loc) • 1.58 kB
TypeScript
import type { ReactiveControllerHost, ReactiveController } from 'lit';
import type { AcceptedType, SelectionState, SelectionStrategy, SelectionType } from '../../utils/selection';
import type { SelectionControl } from './selection-control';
export type SelectionControllerOptions = {
getSelectionType: (host: SelectionControl) => SelectionType;
};
/**
* Manage selection through the SelectionStrategy.
* `host` is expected to have a `selection` and a `type` (`SelectionType`) properties/state.
*/
export declare class SelectionController implements ReactiveController {
host: ReactiveControllerHost & SelectionControl;
strategy: SelectionStrategy | null;
getSelectionType: SelectionControllerOptions['getSelectionType'];
selection: SelectionState;
constructor(host: SelectionControl, options: SelectionControllerOptions);
hostConnected(): void;
hostUpdate(): void;
init: (values: AcceptedType[]) => string[];
/**
* Select the given `values`.
*/
select: (values?: AcceptedType | AcceptedType[] | null) => string[];
/**
* Unselect the given `values`.
*/
unselect: (values?: AcceptedType | AcceptedType[] | null) => string[];
/**
* Toggle the given `values`.
*/
toggle: (values?: AcceptedType | AcceptedType[] | null) => string[];
/**
* Unselect all values.
*/
unselectAll: () => string[];
/**
* Check if the given `value` is selected.
*/
has: (value: AcceptedType) => boolean;
value: () => string | string[] | null;
}
export default SelectionController;