@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
36 lines (35 loc) • 2.11 kB
TypeScript
import { HTMLAttributes } from 'react';
import { GroupBase, OptionsOrGroups } from 'react-select';
import { SelectProps } from './Select';
type ValidationProps = Pick<SelectProps, 'id' | 'label' | 'options' | 'hideLabel' | 'popoverContent'>;
export interface SelectOption extends HTMLAttributes<HTMLOptionElement> {
label: string;
value: string | number;
isDisabled?: boolean;
}
export type SelectOptionsGroup = GroupBase<SelectOption>;
export type SelectOptionsOrOptGroups = OptionsOrGroups<SelectOption, SelectOptionsGroup>;
export declare const SELECT_SIZE: readonly ["medium", "small"];
export type SelectSize = (typeof SELECT_SIZE)[number];
/**
* Validates the given properties of the DSSelect component for common configuration errors.
* This function is intended to be used in development mode to provide developers with
* warnings about potential misuse of the component.
*
* @param validationProps - The subset of DSSelect properties to validate. This includes
* id and label.
*/
export declare const validateSelectProps: ({ id, label, options, hideLabel, popoverContent, }: ValidationProps) => void;
/**
* Determines the initial visibility of the placeholder based on the `placeholder` string and
* the values of `defaultValue` and `value` from the props.
* The function will return true to indicate the placeholder should be selected in the following conditions:
* - The `placeholder` is not an empty string, and neither `defaultValue` nor `value` are provided.
* - Both `defaultValue` and `value` are either undefined or explicitly set to an empty string.
* Otherwise, it returns false, indicating the placeholder is not selected.
*
* This ensures that the placeholder is only selected when no initial or current value is set
* and a placeholder string is provided, enforcing a more deliberate selection by the user when necessary.
*/
export declare const getIsPlaceholderSelected: (placeholder: string, defaultValue: string | number | readonly string[] | undefined, value: string | number | readonly string[] | undefined) => boolean;
export {};