UNPKG

2.33 kBTypeScriptView Raw
1import * as React from 'react';
2import { Simplify } from '@mui/types';
3import { UseOptionRootSlotProps } from '../useOption';
4import { PolymorphicProps, SlotComponentProps } from '../utils';
5export interface OptionRootSlotPropsOverrides {
6}
7export interface OptionOwnProps<OptionValue> {
8 /**
9 * The value of the option.
10 */
11 value: OptionValue;
12 children?: React.ReactNode;
13 /**
14 * If `true`, the option will be disabled.
15 * @default false
16 */
17 disabled?: boolean;
18 className?: string;
19 /**
20 * The props used for each slot inside the Option.
21 * @default {}
22 */
23 slotProps?: {
24 root?: SlotComponentProps<'li', OptionRootSlotPropsOverrides, OptionOwnerState<OptionValue>>;
25 };
26 /**
27 * The components used for each slot inside the Option.
28 * Either a string to use a HTML element or a component.
29 * @default {}
30 */
31 slots?: OptionSlots;
32 /**
33 * A text representation of the option's content.
34 * Used for keyboard text navigation matching.
35 */
36 label?: string;
37}
38export interface OptionSlots {
39 /**
40 * The component that renders the root.
41 * @default 'li'
42 */
43 root?: React.ElementType;
44}
45export interface OptionTypeMap<OptionValue, AdditionalProps = {}, RootComponentType extends React.ElementType = 'li'> {
46 props: OptionOwnProps<OptionValue> & AdditionalProps;
47 defaultComponent: RootComponentType;
48}
49export type OptionProps<OptionValue, RootComponentType extends React.ElementType = OptionTypeMap<OptionValue>['defaultComponent']> = PolymorphicProps<OptionTypeMap<OptionValue, {}, RootComponentType>, RootComponentType>;
50export interface OptionType {
51 <OptionValue, RootComponentType extends React.ElementType = OptionTypeMap<OptionValue>['defaultComponent']>(props: PolymorphicProps<OptionTypeMap<OptionValue>, RootComponentType>): JSX.Element | null;
52 propTypes?: any;
53 displayName?: string | undefined;
54}
55export type OptionOwnerState<OptionValue> = Simplify<OptionOwnProps<OptionValue> & {
56 selected: boolean;
57 highlighted: boolean;
58 index: number;
59}>;
60export type OptionRootSlotProps<OptionValue> = Simplify<UseOptionRootSlotProps & {
61 children?: React.ReactNode;
62 className: string;
63 ref: React.Ref<HTMLLIElement>;
64 ownerState: OptionOwnerState<OptionValue>;
65}>;