import { Label, type ListboxProps, ListboxButton, ListboxOption, ListboxOptions } from '@headlessui/react'; import React, { type ReactNode, type MouseEventHandler, type ElementType } from 'react'; import type { ExtractProps } from '../../util/utility-types'; import type { Status } from '../../util/variant-types'; import type { PopoverListItemProps } from '../PopoverListItem/PopoverListItem'; type SelectProps = ListboxProps & { /** * Screen-reader text for the select's label. * * When possible, use a visible label by passing a into `children`. * In rare cases where there's no visible label, you must provide an `aria-label` for screen readers. * The trigger reads it the way it reads a visible label, followed by the selected value. */ 'aria-label'?: string; /** * Optional className for additional styling. */ className?: string; /** * Name of the form element, which triggers the generation of hidden key/value form fields (e.g. `name=$name[$key]`). * * See: https://headlessui.com/react/listbox#using-with-html-forms */ name?: string; /** * Optional className for additional options menu styling. * * When not using the compact variant, if optionsClassName is provided please * include the width property to define the options menu width. */ optionsClassName?: string; /** * Indicates that field is required for form to be successfully submitted */ required?: boolean; /** * Text under the textarea used to provide validation hints or error message to describe the input error. */ fieldNote?: ReactNode; /** * Visible text label for the component. */ label?: string; /** * Whether the label is adjacent to the field (horizontal) or above the field (vertical) * * **Default is `"vertical"`**. */ labelLayout?: 'vertical' | 'horizontal'; /** * Whether it should show the field hint or not * * **Default is `"false"`**. */ showHint?: boolean; /** * Status for the field state * * **Default is `"default"`**. */ status?: 'default' | Extract; /** * Add additional descriptive text for the field name */ subLabel?: ReactNode; }; type SelectLabelProps = ExtractProps & { disabled?: boolean; required?: boolean; showHint?: boolean; /** * Add additional descriptive text for the field name */ subLabel?: ReactNode; }; type SelectOptionsProps = ExtractProps; type SelectOptionProps = ExtractProps & Pick & { optionClassName?: string; }; type SelectButtonProps = ExtractProps & { /** * Indicates state of the select, used to style the button. */ isOpen?: boolean; }; type SelectButtonWrapperProps = { /** * Text placed inside the button to describe the field. */ children?: ReactNode; /** * Optional className for additional styling. */ className?: string; /** * Indicates state of the select, used to style the button. */ isOpen?: boolean; /** * custom click handler for the built-in or wrapper button */ onClick?: MouseEventHandler; /** * Whether we should truncate the text displayed in the select field */ shouldTruncate?: boolean; /** * Status for the field state * * **Default is `"default"`**. */ status?: 'default' | Extract; }; /** * ## Usage * * Supports controlled and uncontrolled behavior, using a render prop in the latter case. * * | Type/Use | Description | Example | * |----------|-------------|---------| * | Standard | A dropdown list that reveals a set of options; one can be selected. | Country selector. Sort order. Single-choice forms. | * | Searchable | Includes a text input for filtering options in real time. | Long lists (e.g., cities, tags). Large datasets. | * | Multi-select | Allows multiple options to be selected from the list. | Filter panels. Role or permission assignments. | * | Disabled | Non-interactive; used to show unavailable or inactive states. | Feature-gated selections. Incomplete forms. | * | Preselected | Default selection appears before user interacts. | Recommended settings. "Most common" default. | * | Inline | Embedded within table rows or compact UIs. | Editable data tables. Quick action cells. | * * ### Best Practices * * * Select can be used in forms and is meant to pick a value from a list of values, whereas Menus can be used for things like commands. * * Order the menu options logically to make it easier for users to find the option they want. Default to alphabetical order. * * Use a Select input for longer lists of options. A Select should never have only 2 options; 3 selections can be acceptable, but consider a Checkbox group or Radio button group instead so users can see all options at once. * * Keep the select menu the same width as the select field that triggered it. * * ## Interaction * * In single-select mode, only one selection can be made. In multi-select mode, one or more selections can be made from the list. * * ## Content & Accessibility * * ### Do's * * * Use short, precise labels whenever possible. * * Avoid truncated items. * * In short lists, order from most common to least common choices. * * In longer lists use alphabetical order, but if there are 2 or 3 very common selections, consider repeating them at the top of the list. * * Use sentence case. * * Place the most common choices at the top of the list to assist visually impaired users. * * ### Don'ts * * * Use periods at the end of labels. * * Place placeholder text within the field; it can cause accessibility issues with color contrast, inconsistent screen-reader behavior, and text disappearing as users type. * * ## Resources * * * https://headlessui.com/react/menu */ export declare function Select({ 'aria-label': ariaLabel, children, className, disabled, fieldNote, id, label, labelLayout, name, optionsClassName, required, showHint, status, onChange: theirOnChange, subLabel, ...other }: SelectProps): React.JSX.Element; export declare namespace Select { var displayName: string; var Button: { (props: SelectButtonProps): React.JSX.Element; displayName: string; }; var ButtonWrapper: React.ForwardRefExoticComponent>; var Label: { ({ children: label, required, className, disabled, showHint, subLabel, }: SelectLabelProps): React.JSX.Element; displayName: string; }; var Option: { (props: SelectOptionProps): React.JSX.Element; displayName: string; }; var Options: { (props: SelectOptionsProps): React.JSX.Element; displayName: string; }; } /** * The component functioning as a styling for the trigger, selection arrow, and space to * show the current value. */ export declare const SelectButtonWrapper: React.ForwardRefExoticComponent>; export {};