UNPKG

carbon-react

Version:

A library of reusable React components for easily building user interfaces.

60 lines (59 loc) 3.13 kB
import React from "react"; import { FormInputPropTypes } from "../__internal__/select-textbox"; import { ListPlacement } from "../__internal__/select-list/select-list.component"; export interface CustomSelectChangeEvent extends React.ChangeEvent<HTMLInputElement> { selectionConfirmed?: boolean; } export interface SimpleSelectProps extends Omit<FormInputPropTypes, "defaultValue" | "value"> { /** Prop to specify the aria-describedby property of the component input */ "aria-describedby"?: string; /** Prop to specify the aria-label attribute of the component input */ "aria-label"?: string; /** Prop to specify the aria-labelledby property of the component input */ "aria-labelledby"?: string; /** Child components (such as Option or OptionRow) for the SelectList */ children: React.ReactNode; /** If true the loader animation is displayed in the option list */ isLoading?: boolean; /** When true component will work in multi column mode. * Children should consist of OptionRow components in this mode */ multiColumn?: boolean; /** A callback that is triggered when a user scrolls to the bottom of the list */ onListScrollBottom?: () => void; /** A custom callback for when the dropdown menu opens */ onOpen?: () => void; /** If true the Component opens on focus */ openOnFocus?: boolean; /** SelectList table header, should consist of multiple th elements. * Works only in multiColumn mode */ tableHeader?: React.ReactNode; /** If true the component input has no border and is transparent */ transparent?: boolean; /** The selected value(s) */ value: string | Record<string, unknown>; /** [Legacy] Overrides the default tooltip position */ tooltipPosition?: "top" | "bottom" | "left" | "right"; /** Maximum list height - defaults to 180 */ listMaxHeight?: number; /** Placement of the select list in relation to the input element */ listPlacement?: ListPlacement; /** Use the opposite list placement if the set placement does not fit */ flipEnabled?: boolean; /** Set this prop to enable a virtualised list of options. If it is not used then all options will be in the * DOM at all times, which may cause performance problems on very large lists */ enableVirtualScroll?: boolean; /** The number of options to render into the DOM at once, either side of the currently-visible ones. * Higher values make for smoother scrolling but may impact performance. * Only used if the `enableVirtualScroll` prop is set. */ virtualScrollOverscan?: number; /** Flag to configure component as mandatory */ isRequired?: boolean; /** Specify a callback triggered on change */ onChange: (ev: CustomSelectChangeEvent | React.ChangeEvent<HTMLInputElement>) => void; /** Override the default width of the list element. Number passed is converted into pixel value */ listWidth?: number; } export declare const SimpleSelect: React.ForwardRefExoticComponent<SimpleSelectProps & React.RefAttributes<HTMLInputElement>>; export default SimpleSelect;