@eviljs/reactx
Version:
Awesome React UI Widgets
78 lines (77 loc) • 3.91 kB
TypeScript
import type { Props, VoidProps } from '@eviljs/react/props';
import type { Io } from '@eviljs/std/fn-type';
import type { Prettify } from '@eviljs/std/type-types';
import type { SelectOptionGeneric, SelectPlacement } from './select.api.js';
import { type SelectContextValue, type SelectContextValueGeneric, type SelectProviderOptions } from './select.hook.js';
export * from './select.api.js';
export declare function Select<I extends SelectOptionGeneric<any>, S extends undefined | I | Array<I>>(props: Props<SelectProps<I, S>>): React.JSX.Element;
export declare function SelectOne<I extends SelectOptionGeneric<any>>(props: Props<SelectOneProps<I>>): React.JSX.Element;
export declare function SelectMany<I extends SelectOptionGeneric<any>>(props: Props<SelectManyProps<I>>): React.JSX.Element;
export interface SelectGenericProps<I extends SelectOptionGeneric<any>, S extends undefined | I | Array<I>> extends Prettify<Omit<VoidProps<React.JSX.IntrinsicElements['div']>, 'ref' | 'onSelectedChange'> & React.RefAttributes<SelectContextValue<I, S>>> {
disabled?: undefined | boolean;
mounted?: undefined | boolean;
placement?: undefined | SelectPlacement;
readonly?: undefined | boolean;
required?: undefined | boolean;
valid?: undefined | boolean;
initialOpen?: undefined | boolean;
open?: undefined | boolean;
onOpenChange?: undefined | ((value: boolean) => void);
options: undefined | Array<I>;
initialSelected?: undefined | S;
selected?: undefined | S;
onSelectedChange(option: S): void;
controlProps?: undefined | SelectProviderOptions<I, S>['controlProps'];
optionsRootProps?: undefined | SelectProviderOptions<I, S>['optionsRootProps'];
optionsListProps?: undefined | SelectProviderOptions<I, S>['optionsListProps'];
optionProps?: undefined | SelectProviderOptions<I, S>['optionProps'];
control?: undefined | Io<SelectControlProps<I, S>, React.ReactNode>;
option?: undefined | Io<SelectOptionProps<I, S>, React.ReactNode>;
portal?: undefined | boolean | Io<SelectPortalProps, React.ReactNode>;
components?: undefined | {
Control?: undefined | React.ComponentType<SelectControlProps<I, S>>;
Option?: undefined | React.ComponentType<SelectOptionProps<I, S>>;
Portal?: undefined | React.ComponentType<SelectPortalProps>;
};
}
export interface SelectProps<I extends SelectOptionGeneric<any>, S extends undefined | I | Array<I>> extends React.RefAttributes<SelectContextValue<I, S>> {
className?: undefined | string;
context: SelectContextValue<I, S>;
options: SelectGenericProps<I, S>['options'];
control: SelectGenericProps<I, S>['control'];
option: SelectGenericProps<I, S>['option'];
portal: SelectGenericProps<I, S>['portal'];
components: SelectGenericProps<I, S>['components'];
}
export interface SelectOneProps<I extends SelectOptionGeneric<any>> extends SelectGenericProps<I, undefined | I> {
}
export interface SelectManyProps<I extends SelectOptionGeneric<any>> extends SelectGenericProps<I, Array<I>> {
}
export interface SelectControlProps<I extends SelectOptionGeneric<any>, S extends undefined | I | Array<I>> {
disabled: boolean;
mounted: boolean;
readonly: boolean;
required: boolean;
valid: boolean;
open: boolean;
selected: S;
onClick(event: React.MouseEvent<HTMLElement>): void;
onClearSelected(): void;
onSelected(selected: S): void;
}
export interface SelectOptionProps<I extends SelectOptionGeneric<any>, S extends undefined | I | Array<I>> {
disabled: boolean;
mounted: boolean;
readonly: boolean;
required: boolean;
valid: boolean;
option: I;
optionIdx: number;
selected: S;
onClick(event: React.MouseEvent<HTMLElement>): void;
}
export interface SelectPortalProps {
children: React.ReactNode;
open: boolean;
refs: SelectContextValueGeneric['refs'];
}