import * as React from 'react'; import type { BackyardBaseProps } from '../utils/typings/BackyardProps'; import type { BDSForwardRef } from '../utils/typings/BDSComponentProps'; import type { OptionGroupProps } from './OptionGroup'; import type { OptionProps } from './Option'; /** * Backyard React Select * * Select component that uses native option selection; see `Dropdown` for a custom selector... * * ``` * * ``` * * Can group options via `OptionGroup` and allow native selection to handle visuals * * ``` * * ``` * * To include helper text, wrap in `FormControl` and use `FormHelperText` to sync visual states * * ``` * * * Helper Text * * ``` */ declare const Select: BDSForwardRef; declare type SelectRef = HTMLSelectElement; declare type SelectOptionInfo = { index: number; value: OptionProps['value']; text: OptionProps['children']; disabled: OptionProps['disabled']; label: OptionProps['children']; }; interface SelectOption { label?: string; value?: string | number; disabled?: boolean; options?: SelectOption[]; [key: string]: any; } declare type SelectOverrideProps = 'onChange' | 'onClick' | 'onKeyDown' | 'onFocus' | 'onBlur' | 'size' | 'label'; interface SelectProps extends BackyardBaseProps { /** * List of options in declarative `Option` or `OptionGroup` elements * * Is required if `options` is not defined, * Will be overridden by `options` if both defined. */ children?: React.ReactElement[] | React.ReactElement[]; /** * DOM Class Name */ className?: string; /** * Whether or not input is disabled */ disabled?: boolean; /** * Default value of input */ defaultValue?: string | number; /** * Icon displayed when opened */ iconOpened?: React.ReactElement; /** * Icon displayed when closed */ iconClosed?: React.ReactElement; /** * Initial interaction given to component */ interaction?: boolean | string; /** * Label of the `Select` component */ label?: string | React.ReactElement; /** * Visual shape of text input */ shape?: 'rounded' | 'squared'; /** * Size of component */ size?: 'jumbo' | 'large' | 'medium' | 'small'; /** * Visual state of component */ state?: 'default' | 'error' | 'success'; /** * Type of text input */ type?: string; stacked?: boolean; /** * `onChange` trigger event * @param {React.ChangeEvent} event - DOM Event * @param {SelectOptionInfo} option - option info object */ onChange?: (event: React.ChangeEvent, option: SelectOptionInfo) => void; /** * `onClick` trigger event * @param {React.ChangeEvent} event - DOM Event * @param {SelectOptionInfo} option - option info object */ onClick?: (event: React.MouseEvent, option: SelectOptionInfo) => void; /** * `onKeyDown` trigger event * @param {React.ChangeEvent} event - DOM Event * @param {SelectOptionInfo} option - option info object */ onKeyDown?: (event: React.KeyboardEvent, option: SelectOptionInfo) => void; /** * `onFocus` trigger event * @param {React.ChangeEvent} event - DOM Event * @param {SelectOptionInfo} option - option info object */ onFocus?: (event: React.FocusEvent, option: SelectOptionInfo) => void; /** * `onBlur` trigger event * @param {React.ChangeEvent} event - DOM Event * @param {SelectOptionInfo} option - option info object */ onBlur?: (event: React.FocusEvent, option: SelectOptionInfo) => void; /** * Data-driven list of options to provide to select * * Is required if `children` not defined, * Will override `children` if both defined. */ options?: SelectOption[]; /** * Controlled value of the select input */ value?: string | number; /** * Wrapper props object for text input. * Useful for setting the style of text input * visual container instead of input directly */ wrapperProps?: BackyardBaseProps; itemBefore?: React.ReactElement; } export { Select }; export type { SelectProps, SelectRef, SelectOptionInfo, SelectOption }; export default Select;