UNPKG

@devopness/ui-react

Version:

Devopness Design System React Components - Painless essential DevOps to everyone

44 lines (43 loc) 1.92 kB
import { default as React } from 'react'; import { Props as SelectPropsBase, GroupBase } from 'react-select'; import { ErrorMessage } from '../../Primitives'; import { Icon } from '../../../icons'; /** Option type for the Select component. */ type OptionProps<T = unknown> = { icon?: Icon | Omit<string, Icon>; iconSize?: number; value: T; label: string; isCreateLink?: boolean; }; /** * Props for the Select component. */ type SelectProps<TOption> = Omit<SelectPropsBase<OptionProps<TOption>, boolean, GroupBase<OptionProps<TOption>>>, 'noOptionsMessage'> & Pick<Parameters<typeof ErrorMessage>[0], 'error'> & { /** Ref to the underlying input element (may be callback inputRef or object ref) */ inputRef?: React.RefObject<HTMLSelectElement>; /** Options available in the dropdown */ options: OptionProps<TOption>[]; /** Public style overrides for placeholder and value */ publicStyle?: { fontStyleValue?: string; fontStylePlaceholder?: string; }; /** If true, disables interactions and search */ isReadOnly?: boolean; /** Whether the user can add custom options */ isCreatable?: boolean; /** Text to display when there are no options */ noOptionsMessage?: string | ((obj: { inputValue: string; }) => React.ReactNode); /** Format the label for create option */ formatCreateLabel?: (inputValue: string) => string; /** Handle create option */ onCreateOption?: (inputValue: string) => void; /** Class name to be applied to the select container */ className?: string; }; declare const memoizedSelect: <TOption>({ inputRef, error, isReadOnly, defaultValue, options, menuIsOpen, placeholder, isCreatable, noOptionsMessage, className, ...restProps }: SelectProps<TOption>) => import("react/jsx-runtime").JSX.Element; export { memoizedSelect as Select }; export type { OptionProps, SelectProps };