UNPKG

2.24 kBTypeScriptView Raw
1import * as React from 'react';
2import { AppendOwnerStateReturnType } from './appendOwnerState';
3import { MergeSlotPropsParameters, MergeSlotPropsResult, WithCommonProps } from './mergeSlotProps';
4export type UseSlotPropsParameters<ElementType extends React.ElementType, SlotProps, ExternalForwardedProps, ExternalSlotProps, AdditionalProps, OwnerState> = Omit<MergeSlotPropsParameters<SlotProps, ExternalForwardedProps, ExternalSlotProps, AdditionalProps>, 'externalSlotProps'> & {
5 /**
6 * The type of the component used in the slot.
7 */
8 elementType: ElementType | undefined;
9 /**
10 * The `slotProps.*` of the Base UI component.
11 */
12 externalSlotProps: ExternalSlotProps | ((ownerState: OwnerState) => ExternalSlotProps) | undefined;
13 /**
14 * The ownerState of the Base UI component.
15 */
16 ownerState: OwnerState;
17};
18export type UseSlotPropsResult<ElementType extends React.ElementType, SlotProps, AdditionalProps, OwnerState> = AppendOwnerStateReturnType<ElementType, MergeSlotPropsResult<SlotProps, object, object, AdditionalProps>['props'] & {
19 ref: ((instance: any | null) => void) | null;
20}, OwnerState>;
21/**
22 * @ignore - do not document.
23 * Builds the props to be passed into the slot of an unstyled component.
24 * It merges the internal props of the component with the ones supplied by the user, allowing to customize the behavior.
25 * If the slot component is not a host component, it also merges in the `ownerState`.
26 *
27 * @param parameters.getSlotProps - A function that returns the props to be passed to the slot component.
28 */
29export default function useSlotProps<ElementType extends React.ElementType, SlotProps, AdditionalProps, OwnerState>(parameters: UseSlotPropsParameters<ElementType, SlotProps, object, WithCommonProps<Record<string, any>>, AdditionalProps, OwnerState>): import("@mui/types").Simplify<import("@mui/types").Simplify<SlotProps & object & AdditionalProps & {
30 className?: string | undefined;
31 style?: React.CSSProperties | undefined;
32}> & {
33 ref: ((instance: any) => void) | null;
34} & {
35 ownerState: ElementType extends React.ComponentType<any> ? OwnerState : ElementType extends keyof JSX.IntrinsicElements ? undefined : OwnerState | undefined;
36}>;
37
\No newline at end of file