import React from 'react'; import { ISearchInput } from '../Input/types'; import { IDropdownButton, IDropdownMenu, IDropdown } from '../Dropdown/types'; import { IMenuHeading, IMenuItem } from '../Menu/types'; import { IRow } from '../Row/types'; import { IApplicationStatus } from '../ApplicationStatus/types'; import { ISelectReorder } from './Reorder'; /** * Represents the main Select component with its subcomponents. * * @interface ISelectComponent * @extends React.FC */ export interface ISelectComponent extends React.FC> { /** * The Button subcomponent used as the trigger for the dropdown. */ Button: React.FC; /** * The Options subcomponent that contains the list of selectable options. */ Options: React.FC; /** * The Option subcomponent representing an individual selectable option. */ Option: React.FC>; /** * The SearchInput subcomponent for search functionality. */ Search: React.FC; /** * Label used in Option and to display selected Option(s). */ Label: React.FC; /** * Label used in Option and to display selected Option(s). */ Group: React.FC; /** * Footer used in Options to display a footer. */ Footer: React.FC; /** * EmptyState used to display when no options are found after filtering. */ EmptyState: React.FC; /** * Sort subcomponent for sorting options. */ Sort: React.FC; /** * Reorder subcomponent for reordering options. */ Reorder: React.FC; } /** * Props for the SelectFooter component. */ export interface ISelectFooter extends IMenuItem { children: React.ReactNode; } /** * Props for the SelectGroup component. */ export interface ISelectGroup extends IMenuHeading { /** * Show divider below the group */ withDivider?: boolean; } /** * Base props shared between single and multiple selection modes. */ export declare type SelectBaseProps = IDropdown & { /** * The child elements, typically the subcomponents Button, Options, and Option. */ children: React.ReactNode; /** * Placeholder for the clear all button. * @default 'Clear selection' */ clearPlaceholder?: string; }; export declare type SingleSelectOnChange = (value: T) => void; export declare type MultiSelectOnChange = (value: T[]) => void; /** * Props for the Select component in multiple selection mode. */ export interface IMultipleSelect extends SelectBaseProps { multiple: true; onChange?: MultiSelectOnChange; value?: T[]; } /** * Props for the Select component in single selection mode. */ export interface ISingleSelect extends SelectBaseProps { multiple?: false; onChange?: SingleSelectOnChange; value?: T; } /** * Interface for Select props, automatically resolved by TypeScript based on `multiple`. */ export interface ISelect extends SelectBaseProps { multiple?: boolean; onChange?: SingleSelectOnChange | MultiSelectOnChange; value?: T | T[]; } /** * Represents an option entity in the Select component. */ export interface OptionEntity { value: T; labels: string[]; label?: string; } /** * Context properties for managing select state. */ export interface SelectContextProps { /** * The array of selected options. For single selection, this array will contain at most one element. */ selectedOptions: OptionEntity[]; /** * The array of filtered options. */ filteredOptions: OptionEntity[]; /** * Toggles the selection state of a given option. Adds the option if it's not selected, or removes it if it is. */ toggleOption: (option: OptionEntity) => void; /** * Checks if a given option is currently selected. */ isSelected: (option: OptionEntity) => boolean; /** * Indicates whether multiple selections are enabled. */ multiple: boolean; /** * Clears all selected options. */ clearAll: () => void; /** * Search input value inside the Select component. */ searchQuery: string; /** * Callback for when the user updates the search query. */ onSearch: (searchQuery: string) => void; /** * Function to determine if an option matches the search query. Defaults to true if no search query. */ isOptionFound: (option: OptionEntity) => boolean; /** * Ephemeral array of options; resets on each mount. */ options?: OptionEntity[]; /** * Handler to register an option into the Select state. */ registerOption: (option: OptionEntity) => void; /** * Handler to unregister an option from the Select state. */ unregisterOption: (option: OptionEntity) => void; } /** * Type representing a generic Select option. * * */ export declare type SelectOption = { value: T; isDisabled?: boolean; label: string; }; /** * Props for the SelectOption component. * * @interface ISelectOption * @extends IRow */ export interface ISelectOption extends IRow { /** * The value associated with the option. This value is used in selection and callbacks. */ value?: T; /** * Indicates whether the option is disabled and cannot be selected. */ isDisabled?: boolean; /** * The content to be rendered inside the option. Can be any React node. */ children: React.ReactNode; /** * Optional label for the option, used for tag rendering in multi-select. */ label?: string; } /** * Props for the SelectLabel component. */ export interface ISelectLabel { children: string; } /** * Props for the SelectOptions component. */ export interface ISelectOptions extends IDropdownMenu { /** * The child elements, typically multiple SelectOption components. */ children: React.ReactNode; /** * Displays a 'clear all' option at the bottom of the list. */ withClear?: boolean; } declare type SelectButtonMode = 'full' | 'compact'; /** * Props for the SelectButton component. * * @interface ISelectButton */ export interface ISelectButton extends IDropdownButton { /** * Custom rendering for the button. Overrides default rendering logic. */ children?: React.ReactNode; /** * Defines the type of button to render. */ mode?: SelectButtonMode; /** * Placeholder for the button when no option is selected. */ placeholder?: string; /** * Toggles the "clear all" icon when options are selected. */ withClear?: boolean; /** * Single select only: optionally keeps the placeholder when a selection is made */ showPlaceholder?: boolean; } /** * Props for the SelectSearch component. */ export interface ISelectSearch extends ISearchInput { /** * Toggles the "clear all" icon when options are selected. */ withClear?: boolean; } export interface ISort { /** * Children to be sorted */ children: React.ReactNode; /** * Whether the sort is currently selected (default: true) */ selected?: boolean; /** * Optional function to sort or transform the children before rendering */ fn?: (children: React.ReactNode[]) => React.ReactNode[]; } export {};