import { ReactNode } from '../../../node_modules/react'; import { SxProps, Theme } from '@mui/material/styles'; export interface AdvancedSearchOption { /** Unique identifier for the option. */ id: string; /** Text shown in the trigger and the dropdown list. */ label: string; /** * Optional value forwarded on `onAdvanceSearch`. Falls back to `id` when * omitted — useful when the option identifier is the same as the field key. */ value?: string; /** * Optional placeholder shown in the search input while this option is * active. Overridden by the component-level `placeholder` prop when set. */ placeholder?: string; /** Disables this option in the dropdown. */ disabled?: boolean; } export interface AdvancedSearchPayload { /** The dropdown option that was active at dispatch time. */ option: AdvancedSearchOption; /** The trimmed search string entered by the user. */ searchValue: string; } export interface AdvancedSearchProps { /** * Selectable dropdown options. Must contain at least one option — the first * one is used as the fallback when no default / controlled option is set. */ options: AdvancedSearchOption[]; /** Uncontrolled default option id. */ defaultOptionId?: string; /** Controlled selected option id. Pair with `onOptionChange`. */ optionId?: string; /** Fired whenever the dropdown option changes. */ onOptionChange?: (option: AdvancedSearchOption) => void; /** Uncontrolled default value for the search input. */ defaultSearchValue?: string; /** Controlled value for the search input. Pair with `onSearchChange`. */ searchValue?: string; /** Fired on every keystroke in the search input. */ onSearchChange?: (value: string) => void; /** * Dispatched when the user commits the search — either by pressing Enter in * the input or clicking the submit icon (if enabled). Receives the selected * dropdown option and the current search string. */ onAdvanceSearch: (payload: AdvancedSearchPayload) => void; /** * Placeholder for the search input. Falls back to the active option's * `placeholder`, then to `"Search"`. */ placeholder?: string; /** Component size — controls height and typography. */ size?: 'small' | 'medium' | 'large'; /** Disables both the dropdown trigger and the search input. */ disabled?: boolean; /** * Fixed width for the dropdown trigger. Also acts as the minimum width for * the dropdown popup — the popup itself sizes to fit its longest option. * @default 132 */ dropdownWidth?: number | string; /** * Show a submit icon at the end of the search input. The icon is a * clickable shortcut to `onAdvanceSearch` — Enter always submits regardless * of this flag. * @default false */ showEndIcon?: boolean; /** * Custom node rendered inside the end-icon button when `showEndIcon` is * true. Defaults to an `arrow-right` icon. */ endIcon?: ReactNode; /** aria-label for the search input. Defaults to `"Advanced search"`. */ 'aria-label'?: string; /** Forwarded to the underlying search input element. */ id?: string; /** Forwarded to the underlying search input element. */ name?: string; /** MUI `sx` overrides applied to the outer container. */ sx?: SxProps; }