import { EnhancedState, StateRuntimeJobConfigInterface } from '../../state'; import type { Item } from '../item'; import type { Collection, DefaultItem, ItemKey } from '../collection'; export declare class Selector extends EnhancedState { collection: () => Collection; static rebuildSelectorSideEffectKey: string; static rebuildItemSideEffectKey: string; _item: Item | null; _itemKey: ItemKey | null; /** * A Selector represents an Item from a Collection in the long term. * It can be mutated dynamically and remains in sync with the Collection. * * Components that need one piece of data from a Collection such as the "current user" * would benefit from using Selectors. * * [Learn more..](https://agile-ts.org/docs/core/collection/selector) * * @public * @param collection - Collection to which the Selector belongs. * @param itemKey - Key/Name identifier of the Item to be represented by the Selector. * @param config - Configuration object */ constructor(collection: Collection, itemKey: ItemKey | null, config?: SelectorConfigInterface); /** * Returns the `itemKey` currently selected by the Selector. * * [Learn more..](https://agile-ts.org/docs/core/collection/selector/properties#itemkey) * * @public */ get itemKey(): ItemKey | null; /** * Updates the currently selected Item of the Selector * based on the specified `itemKey`. * * [Learn more..](https://agile-ts.org/docs/core/collection/selector/properties#itemkey) * * @public * @param value - New key/name identifier of the Item to be represented by the Selector. */ set itemKey(value: ItemKey | null); /** * Retrieves the Item currently selected by the Selector. * * [Learn more..](https://agile-ts.org/docs/core/collection/selector/properties#item) * * @public */ get item(): Item | null; /** * Updates the currently selected Item of the Selector * based on the specified Item. * * [Learn more..](https://agile-ts.org/docs/core/collection/selector/properties#item) * * @public * @param value - New Item to be represented by the Selector. */ set item(value: Item | null); /** * Updates the currently selected Item of the Selector. * * [Learn more..](https://agile-ts.org/docs/core/collection/selector/methods#select) * * @public * @param itemKey - New key/name identifier of the Item to be represented by the Selector. * @param config - Configuration object */ select(itemKey: ItemKey | null, config?: StateRuntimeJobConfigInterface): this; /** * Reselects the currently selected Item. * * This might be helpful if the Selector failed to select the Item correctly before * and therefore should try to select it again. * * You can use the 'hasSelected()' method to check * whether the 'selected' Item is selected correctly. * * [Learn more..](https://agile-ts.org/docs/core/collection/selector/methods#reselect) * * @public * @param config - Configuration object */ reselect(config?: StateRuntimeJobConfigInterface): this; /** * Unselects the currently selected Item. * * Therefore, it sets the `itemKey` and `item` property to `undefined`, * since the Selector no longer represents any Item. * * [Learn more..](https://agile-ts.org/docs/core/collection/selector/methods#unselect) * * @public * @param config - Configuration object */ unselect(config?: StateRuntimeJobConfigInterface): this; /** * Returns a boolean indicating whether an Item with the specified `itemKey` * is selected by the Selector or not. * * [Learn more..](https://agile-ts.org/docs/core/collection/selector/methods#hasselected) * * @public * @param itemKey - Key/Name identifier of the Item. * @param correctlySelected - Whether the Item has to be selected correctly. */ hasSelected(itemKey: ItemKey | null, correctlySelected?: boolean): boolean; /** * Rebuilds the Selector. * During this process, it updates the Selector `value` based on the Item `value`. * * [Learn more..](https://agile-ts.org/docs/core/collection/selector/methods#rebuild) * * @public * @param config - Configuration object */ rebuildSelector(config?: StateRuntimeJobConfigInterface): this; } export declare type SelectorKey = string | number; export interface SelectorConfigInterface { /** * Key/Name identifier of the Selector. * @default undefined */ key?: SelectorKey; /** * Whether the Selector should be a placeholder * and therefore should only exist in the background. * @default false */ isPlaceholder?: boolean; }