/** * Select Component Type Definitions * Shared types used across all select components */ /** * Value type for select component * - Single-select: string | number * - Multi-select: (string | number)[] */ export type SelectValue = string | number | (string | number)[]; /** * Option data structure */ export interface SelectOption { /** Unique identifier for the option */ value: string | number; /** Display text for the option */ label: string; /** Whether the option is disabled */ disabled?: boolean; /** Whether the option is selected */ selected?: boolean; } /** * Event detail for selection change */ export interface SelectChangeEventDetail { /** Current value (single or array) */ value: SelectValue; /** Selected option (single-select only) */ option?: SelectOption; /** Selected options (multi-select only) */ options?: SelectOption[]; } /** * Event detail for validation state */ export interface SelectValidateEventDetail { /** Whether the value is valid */ valid: boolean; /** Error message if invalid */ errorMessage?: string; } /** * Dropdown placement options */ export type SelectPlacement = 'top' | 'bottom' | 'left' | 'right'; /** * Context shared between select components * Provided by seki-select, consumed by child components */ export interface SelectContext { /** Current selected value(s) */ value: SelectValue; /** Whether multi-select mode is enabled */ multiple: boolean; /** Whether dropdown is open */ open: boolean; /** Whether select is disabled */ disabled: boolean; /** Whether select is required */ required: boolean; /** Currently focused option value */ focusedOptionValue: string | number | null; /** Unique ID for the content element (for aria-controls) */ contentId: string; /** Unique ID for the trigger element */ triggerId: string; /** Accessible label for screen readers */ ariaLabel?: string; /** ID of element that labels this select */ ariaLabelledby?: string; /** ID of element that describes this select */ ariaDescribedby?: string; /** Text that describes this select (set by seki-field; ids can't cross the trigger's shadow root) */ ariaDescription?: string; /** 'true' when the select is invalid (set by seki-field) */ ariaInvalid?: string; /** Handler for value changes */ onValueChange: (value: SelectValue) => void; /** Handler for open state changes */ onOpenChange: (open: boolean) => void; /** Handler for option focus changes */ onOptionFocus: (value: string | number) => void; /** Handler for option selection */ onOptionSelect: (value: string | number) => void; /** Check if a value is selected */ isValueSelected: (value: string | number) => boolean; /** Get all selected options */ getSelectedOptions: () => SelectOption[]; /** Register an option with the context */ registerOption: (option: SelectOption) => void; /** Unregister an option from the context */ unregisterOption: (value: string | number) => void; } /** * Type-ahead search state */ export interface TypeAheadState { /** Accumulated search string */ buffer: string; /** Timeout ID for buffer reset */ timeoutId: number | null; /** Debounce duration in milliseconds */ debounce: number; }