UNPKG

4.69 kBTypeScriptView Raw
1import * as React from 'react';
2import { Instance, Options, OptionsGeneric, VirtualElement } from '@popperjs/core';
3import { PortalProps } from '../Portal';
4import { PolymorphicProps, SlotComponentProps } from '../utils';
5export type PopperPlacementType = Options['placement'];
6export interface PopperRootSlotPropsOverrides {
7}
8export interface PopperTransitionProps {
9 in: boolean;
10 onEnter: () => void;
11 onExited: () => void;
12}
13export interface PopperChildrenProps {
14 placement: PopperPlacementType;
15 TransitionProps?: PopperTransitionProps;
16}
17export interface PopperOwnProps {
18 /**
19 * An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
20 * or a function that returns either.
21 * It's used to set the position of the popper.
22 * The return value will passed as the reference object of the Popper instance.
23 */
24 anchorEl?: null | VirtualElement | HTMLElement | (() => HTMLElement) | (() => VirtualElement);
25 /**
26 * Popper render function or node.
27 */
28 children?: React.ReactNode | ((props: PopperChildrenProps) => React.ReactNode);
29 /**
30 * An HTML element or function that returns one.
31 * The `container` will have the portal children appended to it.
32 *
33 * By default, it uses the body of the top-level document object,
34 * so it's simply `document.body` most of the time.
35 */
36 container?: PortalProps['container'];
37 /**
38 * Direction of the text.
39 * @default 'ltr'
40 */
41 direction?: 'ltr' | 'rtl';
42 /**
43 * The `children` will be under the DOM hierarchy of the parent component.
44 * @default false
45 */
46 disablePortal?: PortalProps['disablePortal'];
47 /**
48 * Always keep the children in the DOM.
49 * This prop can be useful in SEO situation or
50 * when you want to maximize the responsiveness of the Popper.
51 * @default false
52 */
53 keepMounted?: boolean;
54 /**
55 * Popper.js is based on a "plugin-like" architecture,
56 * most of its features are fully encapsulated "modifiers".
57 *
58 * A modifier is a function that is called each time Popper.js needs to
59 * compute the position of the popper.
60 * For this reason, modifiers should be very performant to avoid bottlenecks.
61 * To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
62 */
63 modifiers?: Options['modifiers'];
64 /**
65 * If `true`, the component is shown.
66 */
67 open: boolean;
68 /**
69 * Popper placement.
70 * @default 'bottom'
71 */
72 placement?: PopperPlacementType;
73 /**
74 * Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance.
75 * @default {}
76 */
77 popperOptions?: Partial<OptionsGeneric<any>>;
78 /**
79 * A ref that points to the used popper instance.
80 */
81 popperRef?: React.Ref<Instance>;
82 /**
83 * The props used for each slot inside the Popper.
84 * @default {}
85 */
86 slotProps?: {
87 root?: SlotComponentProps<'div', PopperRootSlotPropsOverrides, PopperOwnerState>;
88 };
89 /**
90 * The components used for each slot inside the Popper.
91 * Either a string to use a HTML element or a component.
92 * @default {}
93 */
94 slots?: PopperSlots;
95 /**
96 * Help supporting a react-transition-group/Transition component.
97 * @default false
98 */
99 transition?: boolean;
100}
101export interface PopperSlots {
102 /**
103 * The component that renders the root.
104 * @default 'div'
105 */
106 root?: React.ElementType;
107}
108export type PopperOwnerState = PopperOwnProps;
109export interface PopperTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'div'> {
110 props: PopperOwnProps & AdditionalProps;
111 defaultComponent: RootComponentType;
112}
113export type PopperProps<RootComponentType extends React.ElementType = PopperTypeMap['defaultComponent']> = PolymorphicProps<PopperTypeMap<{}, RootComponentType>, RootComponentType>;
114export type PopperTooltipOwnProps = Omit<PopperOwnProps, 'container' | 'keepMounted' | 'transition'> & {
115 TransitionProps?: PopperTransitionProps;
116};
117export interface PopperTooltipTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'div'> {
118 props: PopperTooltipOwnProps & AdditionalProps;
119 defaultComponent: RootComponentType;
120}
121export type PopperTooltipProps<RootComponentType extends React.ElementType = PopperTooltipTypeMap['defaultComponent']> = PolymorphicProps<PopperTooltipTypeMap<{}, RootComponentType>, RootComponentType>;
122export interface PopperRootSlotProps {
123 className?: string;
124 ref: React.Ref<any>;
125 ownerState: PopperOwnerState;
126}
127
\No newline at end of file