Blame view

天文台pc/tianwentai-ui/node_modules/@mui/utils/mergeSlotProps/mergeSlotProps.d.ts 2.63 KB
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  import * as React from 'react';
  import { ClassValue } from 'clsx';
  import { Simplify } from '@mui/types';
  import { EventHandlers } from "../types/index.js";
  export type WithCommonProps<OtherProps> = OtherProps & {
    className?: string | undefined;
    style?: React.CSSProperties | undefined;
    ref?: React.Ref<any> | undefined;
  };
  export interface MergeSlotPropsParameters<SlotProps, ExternalForwardedProps, ExternalSlotProps, AdditionalProps> {
    /**
     * A function that returns the internal props of the component.
     * It accepts the event handlers passed into the component by the user
     * and is responsible for calling them where appropriate.
     */
    getSlotProps?: ((other: EventHandlers) => WithCommonProps<SlotProps>) | undefined;
    /**
     * Props provided to the `slotProps.*` of the Base UI component.
     */
    externalSlotProps?: WithCommonProps<ExternalSlotProps> | undefined;
    /**
     * Extra props placed on the Base UI component that should be forwarded to the slot.
     * This should usually be used only for the root slot.
     */
    externalForwardedProps?: WithCommonProps<ExternalForwardedProps> | undefined;
    /**
     * Additional props to be placed on the slot.
     */
    additionalProps?: WithCommonProps<AdditionalProps> | undefined;
    /**
     * Extra class name(s) to be placed on the slot.
     */
    className?: ClassValue | ClassValue[] | undefined;
  }
  export type MergeSlotPropsResult<SlotProps, ExternalForwardedProps, ExternalSlotProps, AdditionalProps> = {
    props: Simplify<SlotProps & ExternalForwardedProps & ExternalSlotProps & AdditionalProps & {
      className?: string | undefined;
      style?: React.CSSProperties | undefined;
    }>;
    internalRef: React.Ref<any> | undefined;
  };
  /**
   * Merges the slot component internal props (usually coming from a hook)
   * with the externally provided ones.
   *
   * The merge order is (the latter overrides the former):
   * 1. The internal props (specified as a getter function to work with get*Props hook result)
   * 2. Additional props (specified internally on a Base UI component)
   * 3. External props specified on the owner component. These should only be used on a root slot.
   * 4. External props specified in the `slotProps.*` prop.
   * 5. The `className` prop - combined from all the above.
   * @param parameters
   * @returns
   */
  declare function mergeSlotProps<SlotProps, ExternalForwardedProps extends Record<string, unknown>, ExternalSlotProps extends Record<string, unknown>, AdditionalProps>(parameters: MergeSlotPropsParameters<SlotProps, ExternalForwardedProps, ExternalSlotProps, AdditionalProps>): MergeSlotPropsResult<SlotProps, ExternalForwardedProps, ExternalSlotProps, AdditionalProps>;
  export default mergeSlotProps;