UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

78 lines (77 loc) 3.12 kB
import React from 'react'; type SelectItemType = { label: React.ReactNode; value: any; disabled?: boolean; /** * Explicit accessible name for the item. Use when `label` is a React node * (so a readable string can't be derived) and the `value` is not meaningful * to assistive technologies. */ ariaLabel?: string; /** * Tooltip content shown on hover when `showItemTooltip` is enabled. Takes * precedence over the label-derived text. */ tooltip?: React.ReactNode; }; type SelectGroupType<T extends SelectItemType> = { label: React.ReactNode; items: T[]; }; type NewSelectBaseProps<T extends SelectItemType> = { chevronIcon?: React.ReactNode; 'data-name'?: string; open?: boolean; onOpenChange?: (open: boolean) => void; showClear?: boolean; extraWidthChars?: number; multiple?: boolean; disabled?: boolean; value?: T['value'] | T['value'][]; defaultValue?: T['value'] | T['value'][]; ariaLabel?: string; size?: 'small' | 'normal'; onValueChange?: (value: T['value'] | T['value'][]) => void; container?: HTMLElement | null; placeholder?: string; invalid?: boolean | string; className?: string; /** * When `true`, stops the native `mousedown` from bubbling beyond the popup. * Use this when the trigger lives inside an outside-click-detecting overlay * (e.g. ag-grid's column menu) that would otherwise close itself on * mousedowns happening inside the portaled popup. */ stopMouseDownPropagation?: boolean; /** Single mode: the matching item. Multi mode: items for each selected value (unknown values omitted). */ renderValue?: (selected: T | T[]) => React.ReactNode; /** * When true, each item is wrapped in a `Tooltip` showing its plain-text label * on hover. Useful when labels can be truncated. Defaults to `false`. */ showItemTooltip?: boolean; }; type SelectDataProps<T extends SelectItemType> = { items: T[]; groups?: never; } | { groups: SelectGroupType<T>[]; items?: never; }; export type NewSelectProps<T extends SelectItemType> = NewSelectBaseProps<T> & SelectDataProps<T>; export type SingleSelectProps<T extends SelectItemType> = Omit<NewSelectBaseProps<T>, 'multiple' | 'value' | 'defaultValue' | 'onValueChange' | 'renderValue'> & { value?: T['value']; defaultValue?: T['value']; onValueChange?: (value: T['value']) => void; renderValue?: (item: T) => React.ReactNode; } & SelectDataProps<T>; export declare const SingleSelect: <T extends SelectItemType>(props: SingleSelectProps<T>) => React.JSX.Element; export type MultiSelectProps<T extends SelectItemType> = Omit<NewSelectBaseProps<T>, 'multiple' | 'value' | 'defaultValue' | 'onValueChange' | 'renderValue'> & { value?: T['value'][]; defaultValue?: T['value'][]; onValueChange?: (value: T['value'][]) => void; renderValue?: (items: T[]) => React.ReactNode; } & SelectDataProps<T>; export declare const MultiSelect: <T extends SelectItemType>(props: MultiSelectProps<T>) => React.JSX.Element; export {};