import { ListBoxItemProps } from "../ListBox/ListBoxItem.cjs"; import { SectionProps } from "../ListBox/ListBoxSection.cjs"; import { ListBoxProps } from "../ListBox/ListBox.cjs"; import { WidthProp } from "@marigold/system"; import { ReactNode, Ref } from "react"; import RAC from "react-aria-components"; export type SelectionMode = 'single' | 'multiple'; /** * Details about the current selection, passed as the second argument to * `renderValue`. Useful for summarising a multi-select trigger, e.g. * `renderValue={(items, { count }) => \`${count} selected\`}`. */ export interface SelectValueDetails { /** * The number of selected items. Reflects the real selection even when the * options are static `` children (whose value is `null`). */ count: number; } type RemovedProps = 'children' | 'isInvalid' | 'isDisabled' | 'isOpen' | 'isRequired' | 'style' | 'className'; export interface SelectProps extends Omit, RemovedProps> { /** * Visual variant of the component. Which values exist is defined by the theme * and listed in the "Appearance" section of the component's documentation. */ variant?: string; /** * Size of the component. Which values exist is defined by the theme and listed * in the "Appearance" section of the component's documentation. */ size?: string; /** * Sets the width of the field. You can see allowed tokens here: https://tailwindcss.com/docs/width * Note: `"fit"` is not supported because the virtualizer controls item sizing. * * Numeric/scale values are spacing-scale tokens, not pixels: `width={64}` * resolves to `calc(var(--spacing) * 64)` ~= 16rem (256px), not 64px. * @remarks `WidthProp` */ width?: Exclude; /** * Children of the select. */ children?: ReactNode | ((item: T) => ReactNode); /** * Set a label for the select. */ label?: ReactNode; /** * Content after the label, such as a `` or ``. Keeps * the label row's height, and a badge is read as the field's description. */ addon?: ReactNode; /** * Set a description for the select. */ description?: string; /** * Set a error message for the select. */ errorMessage?: string | ((validation: RAC.ValidationResult) => string); /** * Items of the select. */ items?: Iterable; /** * Values that invalidate the cached items, like a hook's dependency array. * Only needed for `items` plus a render function: rendered items are cached * per item object, so anything the function reads from outside the item — * state, a lookup, a prop — has to be listed here or it renders stale. */ dependencies?: ListBoxProps['dependencies']; /** * If the select should be required. * * @default false */ required?: boolean; /** * If the select should be disabled. * * @default false */ disabled?: boolean; /** * If the select list should be open. * * @default false */ open?: boolean; /** * If the select should throw an error. * * @default false */ error?: boolean; /** * Render the trigger value when one or more options are selected. Replaces * the default trigger render (which lists the selected values). The * placeholder still shows when nothing is selected. Receives the selected * items and a `details` object ({@link SelectValueDetails}) — use * `details.count` to summarise a multi-select, e.g. * `renderValue={(items, { count }) => \`${count} selected\`}`. Must not * contain focusable or interactive elements, since the trigger is itself a * button. */ renderValue?: (selectedItems: T[], details: SelectValueDetails) => ReactNode; } declare function SelectBase({ disabled, required, items, dependencies, variant, size, error, open, label, addon, children, selectionMode, onChange, renderValue, ref, ...rest }: SelectProps & { ref?: Ref; }): import("react").JSX.Element; export declare const Select: typeof SelectBase & { Option: (props: ListBoxItemProps) => import("react").JSX.Element; Section: ({ header, children, ...props }: SectionProps) => import("react").JSX.Element; }; export {};