UNPKG

@porsche-design-system/components-react

Version:

Porsche Design System is a component library designed to help developers create the best experience for software or services distributed by Dr. Ing. h.c. F. Porsche AG.

149 lines (148 loc) 6.93 kB
import type { BaseProps } from '../../BaseProps'; import type { MultiSelectDropdownDirection, BreakpointCustomizable, MultiSelectChangeEventDetail, MultiSelectToggleEventDetail, MultiSelectState } from '../types'; export type PMultiSelectProps = BaseProps & { /** * Reduces the control height and padding for a more compact layout. * @default false */ compact?: boolean; /** * Sets a supplementary description displayed below the label to provide additional context. * @default '' */ description?: string; /** * Disables the multi-select, preventing all interaction. Selected values are not submitted with the form. * @default false */ disabled?: boolean; /** * Controls whether the dropdown opens upward (`up`) or downward (`down`), or decides automatically (`auto`). * @default 'auto' */ dropdownDirection?: MultiSelectDropdownDirection; /** * Associates the multi-select with a form element by its ID when not directly nested inside it. */ form?: string; /** * Hides the visible label while keeping it accessible to screen readers. Supports responsive breakpoint values. * @default false */ hideLabel?: BreakpointCustomizable<boolean>; /** * Sets the visible label text displayed above the multi-select control. * @default '' */ label?: string; /** * Sets the validation feedback message displayed below the control when `state` is `success` or `error`. * @default '' */ message?: string; /** * Sets the name submitted with the form data to identify the selected values on the server. */ name: string; /** * Emitted when the multi-select loses focus. */ onBlur?: (event: CustomEvent<void>) => void; /** * Emitted when the user selects or deselects an option, with the updated array of values in the event detail. */ onChange?: (event: CustomEvent<MultiSelectChangeEventDetail>) => void; /** * Emitted when the dropdown opens or closes, with the new open state in the event detail. */ onToggle?: (event: CustomEvent<MultiSelectToggleEventDetail>) => void; /** * Marks the multi-select as required — form submission is blocked unless at least one option is selected. * @default false */ required?: boolean; /** * Sets the validation state, controlling the visual appearance and style of the feedback message (`none`, `success`, `error`). * @default 'none' */ state?: MultiSelectState; /** * The selected values. Matches options strictly by type and value, meaning a string value only matches options whose value is the same string, a number value only matches options whose value is the same number. Pass null or [] to clear the selection. Please note that FormData always serializes values as strings, so when participating in a native (uncontrolled) form a number[] value is restored as string[] via formStateRestoreCallback and will no longer strictly match number-typed options. This limitation only applies to native form state restoration; in controlled forms (where the consumer manages value directly via the change event), number[] types are preserved end-to-end. * @default [] */ value?: string[] | number[] | null; }; export declare const PMultiSelect: import("react").ForwardRefExoticComponent<Omit<import("react").DOMAttributes<{}>, "onChange" | "onInput" | "onToggle"> & Pick<import("react").HTMLAttributes<{}>, "suppressHydrationWarning" | "autoFocus" | "className" | "dir" | "hidden" | "id" | "inert" | "inputMode" | "lang" | "slot" | "style" | "tabIndex" | "title" | "translate" | "role"> & { /** * Reduces the control height and padding for a more compact layout. * @default false */ compact?: boolean; /** * Sets a supplementary description displayed below the label to provide additional context. * @default '' */ description?: string; /** * Disables the multi-select, preventing all interaction. Selected values are not submitted with the form. * @default false */ disabled?: boolean; /** * Controls whether the dropdown opens upward (`up`) or downward (`down`), or decides automatically (`auto`). * @default 'auto' */ dropdownDirection?: MultiSelectDropdownDirection; /** * Associates the multi-select with a form element by its ID when not directly nested inside it. */ form?: string; /** * Hides the visible label while keeping it accessible to screen readers. Supports responsive breakpoint values. * @default false */ hideLabel?: BreakpointCustomizable<boolean>; /** * Sets the visible label text displayed above the multi-select control. * @default '' */ label?: string; /** * Sets the validation feedback message displayed below the control when `state` is `success` or `error`. * @default '' */ message?: string; /** * Sets the name submitted with the form data to identify the selected values on the server. */ name: string; /** * Emitted when the multi-select loses focus. */ onBlur?: (event: CustomEvent<void>) => void; /** * Emitted when the user selects or deselects an option, with the updated array of values in the event detail. */ onChange?: (event: CustomEvent<MultiSelectChangeEventDetail>) => void; /** * Emitted when the dropdown opens or closes, with the new open state in the event detail. */ onToggle?: (event: CustomEvent<MultiSelectToggleEventDetail>) => void; /** * Marks the multi-select as required — form submission is blocked unless at least one option is selected. * @default false */ required?: boolean; /** * Sets the validation state, controlling the visual appearance and style of the feedback message (`none`, `success`, `error`). * @default 'none' */ state?: MultiSelectState; /** * The selected values. Matches options strictly by type and value, meaning a string value only matches options whose value is the same string, a number value only matches options whose value is the same number. Pass null or [] to clear the selection. Please note that FormData always serializes values as strings, so when participating in a native (uncontrolled) form a number[] value is restored as string[] via formStateRestoreCallback and will no longer strictly match number-typed options. This limitation only applies to native form state restoration; in controlled forms (where the consumer manages value directly via the change event), number[] types are preserved end-to-end. * @default [] */ value?: string[] | number[] | null; } & { children?: import("react").ReactNode | undefined; } & import("react").RefAttributes<HTMLElement>>;