useMultiSelect (Custom)
Manage multiple selected values with dynamic ALL and custom condition-based derived selection sets.
Concept & Overview
The useMultiSelect custom hook provides state management for lists with checkbox selections, including support for:
- Indeterminate Checked States: Automatically resolves checklist headers and derived category options to three distinct states (
"none" | "partial" | "checked"). - Dynamic Derived Selections: Options that evaluate condition functions dynamically against raw items (e.g. index position or attribute matching).
- Custom Collapsing Rules: Groups automatically collapse into custom identifiers (like
"ALL_FRUITS"or"ACTIVE_DEVELOPERS") if fully checked, keeping payloads clean. - Unified Toggle Function: Handles checking raw items, derived groups, or header checkboxes in one method without requiring separate handlers.