UNPKG

4.88 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 * You can also provide a callback, which is called in a React layout effect.
34 * This lets you set the container from a ref, and also makes server-side rendering possible.
35 *
36 * By default, it uses the body of the top-level document object,
37 * so it's simply `document.body` most of the time.
38 */
39 container?: PortalProps['container'];
40 /**
41 * Direction of the text.
42 * @default 'ltr'
43 */
44 direction?: 'ltr' | 'rtl';
45 /**
46 * The `children` will be under the DOM hierarchy of the parent component.
47 * @default false
48 */
49 disablePortal?: PortalProps['disablePortal'];
50 /**
51 * Always keep the children in the DOM.
52 * This prop can be useful in SEO situation or
53 * when you want to maximize the responsiveness of the Popper.
54 * @default false
55 */
56 keepMounted?: boolean;
57 /**
58 * Popper.js is based on a "plugin-like" architecture,
59 * most of its features are fully encapsulated "modifiers".
60 *
61 * A modifier is a function that is called each time Popper.js needs to
62 * compute the position of the popper.
63 * For this reason, modifiers should be very performant to avoid bottlenecks.
64 * To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
65 */
66 modifiers?: Options['modifiers'];
67 /**
68 * If `true`, the component is shown.
69 */
70 open: boolean;
71 /**
72 * Popper placement.
73 * @default 'bottom'
74 */
75 placement?: PopperPlacementType;
76 /**
77 * Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance.
78 * @default {}
79 */
80 popperOptions?: Partial<OptionsGeneric<any>>;
81 /**
82 * A ref that points to the used popper instance.
83 */
84 popperRef?: React.Ref<Instance>;
85 /**
86 * The props used for each slot inside the Popper.
87 * @default {}
88 */
89 slotProps?: {
90 root?: SlotComponentProps<'div', PopperRootSlotPropsOverrides, PopperOwnerState>;
91 };
92 /**
93 * The components used for each slot inside the Popper.
94 * Either a string to use a HTML element or a component.
95 * @default {}
96 */
97 slots?: PopperSlots;
98 /**
99 * Help supporting a react-transition-group/Transition component.
100 * @default false
101 */
102 transition?: boolean;
103}
104export interface PopperSlots {
105 /**
106 * The component that renders the root.
107 * @default 'div'
108 */
109 root?: React.ElementType;
110}
111export type PopperOwnerState = PopperOwnProps;
112export interface PopperTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'div'> {
113 props: PopperOwnProps & AdditionalProps;
114 defaultComponent: RootComponentType;
115}
116export type PopperProps<RootComponentType extends React.ElementType = PopperTypeMap['defaultComponent']> = PolymorphicProps<PopperTypeMap<{}, RootComponentType>, RootComponentType>;
117export type PopperTooltipOwnProps = Omit<PopperOwnProps, 'container' | 'keepMounted' | 'transition'> & {
118 TransitionProps?: PopperTransitionProps;
119};
120export interface PopperTooltipTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'div'> {
121 props: PopperTooltipOwnProps & AdditionalProps;
122 defaultComponent: RootComponentType;
123}
124export type PopperTooltipProps<RootComponentType extends React.ElementType = PopperTooltipTypeMap['defaultComponent']> = PolymorphicProps<PopperTooltipTypeMap<{}, RootComponentType>, RootComponentType>;
125export interface PopperRootSlotProps {
126 className?: string;
127 ref: React.Ref<any>;
128 ownerState: PopperOwnerState;
129}
130
\No newline at end of file