import { IndeterminateCheckboxStatus } from '../IndeterminateCheckbox'; import { TreeViewItemInterface } from './TreeViewContext'; /** * TreeView State Shape * Consolidates all state managed by the TreeView component */ export interface TreeViewState { /** Array of all tree items with their metadata */ items: TreeViewItemInterface[]; /** Set of expanded item IDs for O(1) lookup */ expandedSet: Set; /** Flag indicating if items need to be updated (for showAll functionality) */ itemsNeedUpdate: boolean | null; } /** * TreeView Action Types * Defines all possible state mutations */ export declare type TreeViewAction = { type: 'SELECT_ITEM'; payload: { itemId: string; checkedStatus?: IndeterminateCheckboxStatus; selectable: string; checkChildren: boolean; checkParents: boolean; isTopLevelSelectable: boolean; }; } | { type: 'SELECT_ALL'; payload: { checkChildren: boolean; checkParents: boolean; isTopLevelSelectable: boolean; }; } | { type: 'CLEAR_ALL'; payload: { checkChildren: boolean; checkParents: boolean; isTopLevelSelectable: boolean; }; } | { type: 'TOGGLE_EXPAND'; payload: { itemId: string | string[]; }; } | { type: 'EXPAND_ALL'; payload: { expandableIds: string[]; }; } | { type: 'COLLAPSE_ALL'; } | { type: 'SET_ITEMS'; payload: { items: TreeViewItemInterface[]; }; } | { type: 'ADD_ITEM'; payload: { newItem: TreeViewItemInterface; checkParents: boolean; selectable: string; }; } | { type: 'UPDATE_ITEMS_DISABLED_STATE'; payload: { updatedItems: TreeViewItemInterface[]; }; } | { type: 'TRIGGER_ITEMS_UPDATE'; } | { type: 'COMPLETE_ITEMS_UPDATE'; }; /** * TreeView Reducer * Pure function that handles all state transitions * * State Transitions: * - SELECT_ITEM: Updates item selection based on selectable mode (single/multi) * - SELECT_ALL: Selects all items in multi-select mode * - CLEAR_ALL: Clears all selections * - TOGGLE_EXPAND: Toggles expansion state of one or more items * - EXPAND_ALL: Expands all expandable items * - COLLAPSE_ALL: Collapses all items * - SET_ITEMS: Replaces entire items array (used for initialization and updates) * - ADD_ITEM: Adds a new item to the tree * - UPDATE_ITEMS_DISABLED_STATE: Updates disabled state of items * - TRIGGER_ITEMS_UPDATE: Flags that items need updating (for showAll) * - COMPLETE_ITEMS_UPDATE: Clears the update flag */ export declare function treeViewReducer(state: TreeViewState, action: TreeViewAction): TreeViewState;