1 | import * as Popper from '@popperjs/core';
|
2 |
|
3 | export type BasePlacement = Popper.BasePlacement;
|
4 |
|
5 | export type Placement = Popper.Placement;
|
6 |
|
7 | export type Content = string | Element | ((ref: Element) => Element | string);
|
8 |
|
9 | export type SingleTarget = Element;
|
10 |
|
11 | export type MultipleTargets = string | Element[] | NodeList;
|
12 |
|
13 | export type Targets = SingleTarget | MultipleTargets;
|
14 |
|
15 | export interface ReferenceElement<TProps = Props> extends Element {
|
16 | _tippy?: Instance<TProps>;
|
17 | }
|
18 |
|
19 | export interface PopperElement<TProps = Props> extends HTMLDivElement {
|
20 | _tippy?: Instance<TProps>;
|
21 | }
|
22 |
|
23 | export interface LifecycleHooks<TProps = Props> {
|
24 | onAfterUpdate(
|
25 | instance: Instance<TProps>,
|
26 | partialProps: Partial<TProps>,
|
27 | ): void;
|
28 | onBeforeUpdate(
|
29 | instance: Instance<TProps>,
|
30 | partialProps: Partial<TProps>,
|
31 | ): void;
|
32 | onCreate(instance: Instance<TProps>): void;
|
33 | onDestroy(instance: Instance<TProps>): void;
|
34 | onHidden(instance: Instance<TProps>): void;
|
35 | onHide(instance: Instance<TProps>): void | false;
|
36 | onMount(instance: Instance<TProps>): void;
|
37 | onShow(instance: Instance<TProps>): void | false;
|
38 | onShown(instance: Instance<TProps>): void;
|
39 | onTrigger(instance: Instance<TProps>, event: Event): void;
|
40 | onUntrigger(instance: Instance<TProps>, event: Event): void;
|
41 | onClickOutside(instance: Instance<TProps>, event: Event): void;
|
42 | }
|
43 |
|
44 | export interface RenderProps {
|
45 | allowHTML: boolean;
|
46 | animation: string | boolean;
|
47 | arrow: boolean | string | SVGElement;
|
48 | content: Content;
|
49 | inertia: boolean;
|
50 | maxWidth: number | string;
|
51 | role: string;
|
52 | theme: string;
|
53 | zIndex: number;
|
54 | }
|
55 |
|
56 | export interface Props extends LifecycleHooks, RenderProps {
|
57 | animateFill: boolean;
|
58 | appendTo: 'parent' | Element | ((ref: Element) => Element);
|
59 | aria: {
|
60 | content?: 'auto' | 'describedby' | 'labelledby' | null;
|
61 | expanded?: 'auto' | boolean;
|
62 | };
|
63 | delay: number | [number | null, number | null];
|
64 | duration: number | [number | null, number | null];
|
65 | followCursor: boolean | 'horizontal' | 'vertical' | 'initial';
|
66 | getReferenceClientRect: null | (() => ClientRect);
|
67 | hideOnClick: boolean | 'toggle';
|
68 | ignoreAttributes: boolean;
|
69 | inlinePositioning: boolean;
|
70 | interactive: boolean;
|
71 | interactiveBorder: number;
|
72 | interactiveDebounce: number;
|
73 | moveTransition: string;
|
74 | offset:
|
75 | | [number, number]
|
76 | | (({
|
77 | placement,
|
78 | popper,
|
79 | reference,
|
80 | }: {
|
81 | placement: Placement;
|
82 | popper: Popper.Rect;
|
83 | reference: Popper.Rect;
|
84 | }) => [number, number]);
|
85 | placement: Placement;
|
86 | plugins: Plugin[];
|
87 | popperOptions: Partial<Popper.Options>;
|
88 | render:
|
89 | | ((
|
90 | instance: Instance,
|
91 | ) => {
|
92 | popper: PopperElement;
|
93 | onUpdate?: (prevProps: Props, nextProps: Props) => void;
|
94 | })
|
95 | | null;
|
96 | showOnCreate: boolean;
|
97 | sticky: boolean | 'reference' | 'popper';
|
98 | touch: boolean | 'hold' | ['hold', number];
|
99 | trigger: string;
|
100 | triggerTarget: Element | Element[] | null;
|
101 | }
|
102 |
|
103 | export interface DefaultProps extends Omit<Props, 'delay' | 'duration'> {
|
104 | delay: number | [number, number];
|
105 | duration: number | [number, number];
|
106 | }
|
107 |
|
108 | export interface Instance<TProps = Props> {
|
109 | clearDelayTimeouts(): void;
|
110 | destroy(): void;
|
111 | disable(): void;
|
112 | enable(): void;
|
113 | hide(): void;
|
114 | id: number;
|
115 | plugins: Plugin<TProps>[];
|
116 | popper: PopperElement<TProps>;
|
117 | popperInstance: Popper.Instance | null;
|
118 | props: TProps;
|
119 | reference: ReferenceElement<TProps>;
|
120 | setContent(content: Content): void;
|
121 | setProps(partialProps: Partial<TProps>): void;
|
122 | show(): void;
|
123 | state: {
|
124 | isEnabled: boolean;
|
125 | isVisible: boolean;
|
126 | isDestroyed: boolean;
|
127 | isMounted: boolean;
|
128 | isShown: boolean;
|
129 | };
|
130 | unmount(): void;
|
131 | }
|
132 |
|
133 | export interface TippyStatics {
|
134 | readonly currentInput: {isTouch: boolean};
|
135 | readonly defaultProps: DefaultProps;
|
136 | setDefaultProps(partialProps: Partial<DefaultProps>): void;
|
137 | }
|
138 |
|
139 | export interface Tippy<TProps = Props> extends TippyStatics {
|
140 | (targets: SingleTarget, optionalProps?: Partial<TProps>): Instance<TProps>;
|
141 | }
|
142 |
|
143 | export interface Tippy<TProps = Props> extends TippyStatics {
|
144 | (targets: MultipleTargets, optionalProps?: Partial<TProps>): Instance<
|
145 | TProps
|
146 | >[];
|
147 | }
|
148 |
|
149 | declare const tippy: Tippy;
|
150 |
|
151 | // =============================================================================
|
152 | // Addon types
|
153 | // =============================================================================
|
154 | export interface DelegateInstance<TProps = Props> extends Instance<TProps> {
|
155 | destroy(shouldDestroyTargetInstances?: boolean): void;
|
156 | }
|
157 |
|
158 | export interface Delegate<TProps = Props> {
|
159 | (
|
160 | targets: SingleTarget,
|
161 | props: Partial<TProps> & {target: string},
|
162 | ): DelegateInstance<TProps>;
|
163 | }
|
164 |
|
165 | export interface Delegate<TProps = Props> {
|
166 | (
|
167 | targets: MultipleTargets,
|
168 | props: Partial<TProps> & {target: string},
|
169 | ): DelegateInstance<TProps>[];
|
170 | }
|
171 |
|
172 | export type CreateSingleton<TProps = Props> = (
|
173 | tippyInstances: Instance<TProps | Props>[],
|
174 | optionalProps?: Partial<TProps> & {overrides?: Array<keyof TProps>},
|
175 | ) => Instance<TProps>;
|
176 |
|
177 | declare const delegate: Delegate;
|
178 | declare const createSingleton: CreateSingleton;
|
179 |
|
180 |
|
181 |
|
182 |
|
183 | export interface Plugin<TProps = Props> {
|
184 | name?: string;
|
185 | defaultValue?: any;
|
186 | fn(instance: Instance<TProps>): Partial<LifecycleHooks<TProps>>;
|
187 | }
|
188 |
|
189 | export interface AnimateFill extends Plugin {
|
190 | name: 'animateFill';
|
191 | defaultValue: false;
|
192 | }
|
193 |
|
194 | export interface FollowCursor extends Plugin {
|
195 | name: 'followCursor';
|
196 | defaultValue: false;
|
197 | }
|
198 |
|
199 | export interface InlinePositioning extends Plugin {
|
200 | name: 'inlinePositioning';
|
201 | defaultValue: false;
|
202 | }
|
203 |
|
204 | export interface Sticky extends Plugin {
|
205 | name: 'sticky';
|
206 | defaultValue: false;
|
207 | }
|
208 |
|
209 | declare const animateFill: AnimateFill;
|
210 | declare const followCursor: FollowCursor;
|
211 | declare const inlinePositioning: InlinePositioning;
|
212 | declare const sticky: Sticky;
|
213 |
|
214 |
|
215 |
|
216 |
|
217 | export interface HideAllOptions {
|
218 | duration?: number;
|
219 | exclude?: Instance | ReferenceElement;
|
220 | }
|
221 |
|
222 | export type HideAll = (options?: HideAllOptions) => void;
|
223 |
|
224 | declare const hideAll: HideAll;
|
225 | declare const roundArrow: string;
|
226 |
|
227 | export default tippy;
|
228 | export {
|
229 | hideAll,
|
230 | delegate,
|
231 | createSingleton,
|
232 | animateFill,
|
233 | followCursor,
|
234 | inlinePositioning,
|
235 | sticky,
|
236 | roundArrow,
|
237 | };
|