import { HoistModel } from '@xh/hoist/core'; import { Store } from './Store'; import { StoreRecord, StoreRecordId, StoreRecordOrId } from './StoreRecord'; /** * Configuration for a {@link StoreSelectionModel}. Typically passed via the `selModel` config * on {@link GridConfig} rather than constructed directly. * * @see StoreSelectionModel */ export interface StoreSelectionConfig { store?: Store; mode?: 'single' | 'multiple' | 'disabled'; /** @internal */ xhImpl?: boolean; } /** * Model for managing record selection within a {@link Store}. Supports `single`, `multiple`, * and `disabled` modes. * * Typically accessed via `gridModel.selModel` rather than created directly - configure via * the `selModel` property on {@link GridConfig}. * * Key observables for reacting to selection state: `selectedRecord` / `selectedRecords` * (reactive to both identity and data changes), `selectedId` / `selectedIds` (identity only), * `isEmpty`, `count`. Use `select()` and `clear()` for programmatic control. * * @see StoreSelectionConfig * * @mcpHint selection state manager for Store, used by grids */ export declare class StoreSelectionModel extends HoistModel { readonly store: Store; mode: 'single' | 'multiple' | 'disabled'; private _ids; get isEnabled(): boolean; constructor({ store, mode, xhImpl }: StoreSelectionConfig); get selectedRecords(): StoreRecord[]; get selectedIds(): StoreRecordId[]; /** * Single selected record, or null if multiple/no records selected. * * Note that this getter will also change if just the data of selected record is changed * due to store loading or editing. Applications only interested in the *identity* * of the selection should use {@link selectedId} instead. */ get selectedRecord(): StoreRecord; /** * ID of selected record, or null if multiple/no records selected. * * Note that this getter will *not* change if just the data of selected record is changed * due to store loading or editing. Applications also interested in the *contents* of the * selection should use the {@link selectedRecord} getter instead. */ get selectedId(): StoreRecordId; /** @returns true if selection is empty. */ get isEmpty(): boolean; /** @returns count of currently selected records. */ get count(): number; /** * Set the selection. * @param records - single record/ID or array of records/IDs to select. * @param clearSelection - true to clear previous selection (rather than add to it). */ select(records: StoreRecordOrId | StoreRecordOrId[], clearSelection?: boolean): void; /** Select all filtered records. */ selectAll(): void; /** Clear the selection. */ clear(): void; private cullSelectionReaction; }