@akinon/ui-tooltip 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/types.d.ts +966 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +11 -0
- package/dist/esm/types.d.ts +966 -0
- package/package.json +6 -6
|
@@ -0,0 +1,966 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for the Tooltip component, excluding specific attributes from AntTooltipProps.
|
|
3
|
+
*/
|
|
4
|
+
export type TooltipProps = Omit<
|
|
5
|
+
AntTooltipProps,
|
|
6
|
+
| 'prefixCls'
|
|
7
|
+
| 'style'
|
|
8
|
+
| 'styles'
|
|
9
|
+
| 'id'
|
|
10
|
+
| 'builtinPlacements'
|
|
11
|
+
| 'showArrow'
|
|
12
|
+
| 'onPopupAlign'
|
|
13
|
+
| 'overlay'
|
|
14
|
+
| 'getTooltipContainer'
|
|
15
|
+
| 'arrowContent'
|
|
16
|
+
| 'motion'
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for overflow adjustments in tooltip placement.
|
|
21
|
+
*/
|
|
22
|
+
interface AdjustOverflow {
|
|
23
|
+
/**
|
|
24
|
+
* Adjust the X position of the tooltip if it overflows.
|
|
25
|
+
*/
|
|
26
|
+
adjustX?: 0 | 1;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Adjust the Y position of the tooltip if it overflows.
|
|
30
|
+
*/
|
|
31
|
+
adjustY?: 0 | 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for tooltip placements.
|
|
36
|
+
*/
|
|
37
|
+
interface PlacementsConfig {
|
|
38
|
+
/**
|
|
39
|
+
* The width of the tooltip arrow in pixels.
|
|
40
|
+
*/
|
|
41
|
+
arrowWidth: number;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Whether the arrow should point at the center of the target element.
|
|
45
|
+
*/
|
|
46
|
+
arrowPointAtCenter?: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Whether to adjust the placement automatically when the tooltip overflows.
|
|
50
|
+
*/
|
|
51
|
+
autoAdjustOverflow?: boolean | AdjustOverflow;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Offset of the tooltip relative to the target element.
|
|
55
|
+
*/
|
|
56
|
+
offset: number;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The border radius of the tooltip in pixels.
|
|
60
|
+
*/
|
|
61
|
+
borderRadius: number;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Whether to prioritize visibility when multiple placements are possible.
|
|
65
|
+
*/
|
|
66
|
+
visibleFirst?: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Literal union type supporting both predefined and custom string values.
|
|
71
|
+
*/
|
|
72
|
+
type LiteralUnion<T extends string> = T | (string & {});
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Function that renders the tooltip content.
|
|
76
|
+
*/
|
|
77
|
+
type RenderFunction = () => React.ReactNode;
|
|
78
|
+
|
|
79
|
+
interface TooltipPropsWithOverlay extends AbstractTooltipProps {
|
|
80
|
+
/**
|
|
81
|
+
* The text shown in the tooltip
|
|
82
|
+
*/
|
|
83
|
+
title?: React.ReactNode | RenderFunction;
|
|
84
|
+
|
|
85
|
+
//overlay?: React.ReactNode | RenderFunction;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface TooltipPropsWithTitle extends AbstractTooltipProps {
|
|
89
|
+
/**
|
|
90
|
+
* The text shown in the tooltip
|
|
91
|
+
*/
|
|
92
|
+
title: React.ReactNode | RenderFunction;
|
|
93
|
+
|
|
94
|
+
//overlay?: React.ReactNode | RenderFunction;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export declare type AntTooltipProps =
|
|
98
|
+
| TooltipPropsWithTitle
|
|
99
|
+
| TooltipPropsWithOverlay;
|
|
100
|
+
|
|
101
|
+
type PurePanelProps = Omit<TooltipProps, 'children'>;
|
|
102
|
+
|
|
103
|
+
declare const PurePanel: React.FC<PurePanelProps>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Colors available for the tooltip's background.
|
|
107
|
+
*/
|
|
108
|
+
declare const PresetColors: readonly [
|
|
109
|
+
'blue',
|
|
110
|
+
'purple',
|
|
111
|
+
'cyan',
|
|
112
|
+
'green',
|
|
113
|
+
'magenta',
|
|
114
|
+
'pink',
|
|
115
|
+
'red',
|
|
116
|
+
'orange',
|
|
117
|
+
'yellow',
|
|
118
|
+
'volcano',
|
|
119
|
+
'geekblue',
|
|
120
|
+
'lime',
|
|
121
|
+
'gold'
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Key type for predefined tooltip colors.
|
|
126
|
+
*/
|
|
127
|
+
type PresetColorKey = (typeof PresetColors)[number];
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Extended color type with inverse options.
|
|
131
|
+
*/
|
|
132
|
+
type InverseColor = `${PresetColorKey}-inverse`;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Available tooltip color types, including inverse options.
|
|
136
|
+
*/
|
|
137
|
+
type PresetColorType = PresetColorKey | InverseColor;
|
|
138
|
+
|
|
139
|
+
export type { AdjustOverflow, PlacementsConfig };
|
|
140
|
+
|
|
141
|
+
export interface TooltipRef {
|
|
142
|
+
forceAlign: VoidFunction;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Positions where the tooltip can appear relative to the target element.
|
|
147
|
+
*/
|
|
148
|
+
export type TooltipPlacement =
|
|
149
|
+
| 'top'
|
|
150
|
+
| 'left'
|
|
151
|
+
| 'right'
|
|
152
|
+
| 'bottom'
|
|
153
|
+
| 'topLeft'
|
|
154
|
+
| 'topRight'
|
|
155
|
+
| 'bottomLeft'
|
|
156
|
+
| 'bottomRight'
|
|
157
|
+
| 'leftTop'
|
|
158
|
+
| 'leftBottom'
|
|
159
|
+
| 'rightTop'
|
|
160
|
+
| 'rightBottom';
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Configuration options for aligning the tooltip.
|
|
164
|
+
*/
|
|
165
|
+
export interface TooltipAlignConfig {
|
|
166
|
+
/**
|
|
167
|
+
* Points defining the source and target alignment.
|
|
168
|
+
*/
|
|
169
|
+
points?: [string, string];
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Offset values for positioning the tooltip.
|
|
173
|
+
*/
|
|
174
|
+
offset?: [number | string, number | string];
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Offset values for the target element.
|
|
178
|
+
*/
|
|
179
|
+
targetOffset?: [number | string, number | string];
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Overflow adjustment configuration.
|
|
183
|
+
*/
|
|
184
|
+
overflow?: {
|
|
185
|
+
adjustX: boolean;
|
|
186
|
+
adjustY: boolean;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Whether to use CSS right instead of left for positioning.
|
|
191
|
+
*/
|
|
192
|
+
useCssRight?: boolean;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Whether to use CSS bottom instead of top for positioning.
|
|
196
|
+
*/
|
|
197
|
+
useCssBottom?: boolean;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Whether to use CSS transform for positioning if supported.
|
|
201
|
+
*/
|
|
202
|
+
useCssTransform?: boolean;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
interface LegacyTooltipProps
|
|
206
|
+
extends Partial<
|
|
207
|
+
Omit<
|
|
208
|
+
RcTooltipProps,
|
|
209
|
+
| 'children'
|
|
210
|
+
| 'visible'
|
|
211
|
+
| 'defaultVisible'
|
|
212
|
+
| 'onVisibleChange'
|
|
213
|
+
| 'afterVisibleChange'
|
|
214
|
+
| 'destroyTooltipOnHide'
|
|
215
|
+
>
|
|
216
|
+
> {
|
|
217
|
+
/**
|
|
218
|
+
* Whether the floating tooltip card is open or not
|
|
219
|
+
*/
|
|
220
|
+
open?: RcTooltipProps['visible'];
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Whether the floating tooltip card is open by default
|
|
224
|
+
*/
|
|
225
|
+
defaultOpen?: boolean;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Callback executed when visibility of the tooltip card is changed
|
|
229
|
+
*/
|
|
230
|
+
onOpenChange?: (open: boolean) => void;
|
|
231
|
+
|
|
232
|
+
//afterOpenChange?: RcTooltipProps['afterVisibleChange'];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Abstract properties for the Tooltip component.
|
|
237
|
+
*/
|
|
238
|
+
export interface AbstractTooltipProps extends LegacyTooltipProps {
|
|
239
|
+
/**
|
|
240
|
+
* Inline styles for the tooltip container.
|
|
241
|
+
*/
|
|
242
|
+
style?: React.CSSProperties;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The additional css class
|
|
246
|
+
*/
|
|
247
|
+
className?: string;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* ClassName on the root element
|
|
251
|
+
*/
|
|
252
|
+
rootClassName?: string;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* The background color
|
|
256
|
+
*/
|
|
257
|
+
color?: string;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* The position of the tooltip relative to the target
|
|
261
|
+
*/
|
|
262
|
+
placement?: TooltipPlacement;
|
|
263
|
+
|
|
264
|
+
//builtinPlacements?: typeof Placements;
|
|
265
|
+
//openClassName?: string;
|
|
266
|
+
/**
|
|
267
|
+
* Change arrow's visible state and change whether the arrow is pointed at the center of target
|
|
268
|
+
*/
|
|
269
|
+
arrow?: boolean;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Whether to adjust popup placement automatically when popup is off screen
|
|
273
|
+
*/
|
|
274
|
+
autoAdjustOverflow?: boolean;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* The DOM container of the tip, the default behavior is to create a div element in body
|
|
278
|
+
*/
|
|
279
|
+
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* The content of the tooltip.
|
|
283
|
+
*/
|
|
284
|
+
children?: React.ReactNode;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Whether destroy tooltip when hidden
|
|
288
|
+
*/
|
|
289
|
+
destroyTooltipOnHide?: boolean;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Properties for a tooltip component that supports both a title and an overlay.
|
|
294
|
+
*/
|
|
295
|
+
export interface TooltipPropsWithOverlay extends AbstractTooltipProps {
|
|
296
|
+
/**
|
|
297
|
+
* The main content of the tooltip. Can be a React node or a function that returns one.
|
|
298
|
+
*/
|
|
299
|
+
title?: React.ReactNode | RenderFunction;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Custom overlay content for the tooltip. Overrides the `title` if provided.
|
|
303
|
+
*/
|
|
304
|
+
overlay?: React.ReactNode | RenderFunction;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Properties for a tooltip component that requires a title and optionally supports an overlay.
|
|
309
|
+
*/
|
|
310
|
+
export interface TooltipPropsWithTitle extends AbstractTooltipProps {
|
|
311
|
+
/**
|
|
312
|
+
* The required main content of the tooltip. Can be a React node or a function that returns one.
|
|
313
|
+
*/
|
|
314
|
+
title: React.ReactNode | RenderFunction;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Custom overlay content for the tooltip. Overrides the `title` if provided.
|
|
318
|
+
*/
|
|
319
|
+
overlay?: React.ReactNode | RenderFunction;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export declare type TooltipProps =
|
|
323
|
+
| TooltipPropsWithTitle
|
|
324
|
+
| TooltipPropsWithOverlay;
|
|
325
|
+
|
|
326
|
+
declare const InternalTooltip: React.ForwardRefExoticComponent<
|
|
327
|
+
TooltipProps & React.RefAttributes<TooltipRef>
|
|
328
|
+
>;
|
|
329
|
+
|
|
330
|
+
type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Properties for configuring the core behavior and appearance of a tooltip.
|
|
334
|
+
*/
|
|
335
|
+
interface RcTooltipProps
|
|
336
|
+
extends Pick<
|
|
337
|
+
TriggerProps,
|
|
338
|
+
| 'onPopupAlign'
|
|
339
|
+
| 'builtinPlacements'
|
|
340
|
+
| 'fresh'
|
|
341
|
+
| 'children'
|
|
342
|
+
| 'mouseLeaveDelay'
|
|
343
|
+
| 'mouseEnterDelay'
|
|
344
|
+
| 'prefixCls'
|
|
345
|
+
| 'forceRender'
|
|
346
|
+
> {
|
|
347
|
+
/**
|
|
348
|
+
* Tooltip trigger mode. Could be multiple by passing an array
|
|
349
|
+
*/
|
|
350
|
+
trigger?: ActionType | ActionType[];
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Whether the tooltip is visible by default.
|
|
354
|
+
*/
|
|
355
|
+
defaultVisible?: boolean;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Whether the tooltip is currently visible.
|
|
359
|
+
*/
|
|
360
|
+
visible?: boolean;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* The placement of the tooltip relative to its target.
|
|
364
|
+
*/
|
|
365
|
+
placement?: string;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Motion configuration for animating the tooltip. Inherits from `popupMotion` in TriggerProps.
|
|
369
|
+
*/
|
|
370
|
+
motion?: TriggerProps['popupMotion'];
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Callback function executed when the tooltip's visibility changes.
|
|
374
|
+
*
|
|
375
|
+
* @param visible - Whether the tooltip is now visible.
|
|
376
|
+
*/
|
|
377
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Callback function executed after the tooltip's visibility has changed.
|
|
381
|
+
*
|
|
382
|
+
* @param visible - Whether the tooltip is now visible.
|
|
383
|
+
*/
|
|
384
|
+
afterVisibleChange?: (visible: boolean) => void;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* The content of the tooltip. Can be a React node or a function that returns one.
|
|
388
|
+
*/
|
|
389
|
+
overlay: (() => React.ReactNode) | React.ReactNode;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Inline styles for the tooltip card.
|
|
393
|
+
*/
|
|
394
|
+
overlayStyle?: React.CSSProperties;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Additional CSS class for the tooltip card.
|
|
398
|
+
*/
|
|
399
|
+
overlayClassName?: string;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Function to specify the container where the tooltip should be rendered.
|
|
403
|
+
*
|
|
404
|
+
* @param node - The DOM node triggering the tooltip.
|
|
405
|
+
* @returns - The container element for the tooltip.
|
|
406
|
+
*/
|
|
407
|
+
getTooltipContainer?: (node: HTMLElement) => HTMLElement;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Whether to destroy the tooltip when it is hidden.
|
|
411
|
+
*/
|
|
412
|
+
destroyTooltipOnHide?: boolean;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Alignment configuration for the tooltip. Combines placement settings with additional alignment rules.
|
|
416
|
+
* See: <a href="https://github.com/yiminghe/dom-align" target="_blank">dom-align</a>
|
|
417
|
+
*/
|
|
418
|
+
align?: AlignType;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Whether to display an arrow in the tooltip.
|
|
422
|
+
*/
|
|
423
|
+
showArrow?: boolean | ArrowType;
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Custom content for the arrow in the tooltip.
|
|
427
|
+
*/
|
|
428
|
+
arrowContent?: React.ReactNode;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Unique identifier for the tooltip element.
|
|
432
|
+
*/
|
|
433
|
+
id?: string;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Inline styles for the inner content of the tooltip.
|
|
437
|
+
*/
|
|
438
|
+
overlayInnerStyle?: React.CSSProperties;
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* The z-index of the tooltip.
|
|
442
|
+
*/
|
|
443
|
+
zIndex?: number;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Configuration for the arrow displayed in the tooltip.
|
|
448
|
+
*/
|
|
449
|
+
interface ArrowType {
|
|
450
|
+
/**
|
|
451
|
+
* Additional CSS class for the arrow.
|
|
452
|
+
*/
|
|
453
|
+
className?: string;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Custom content for the arrow.
|
|
457
|
+
*/
|
|
458
|
+
content?: React.ReactNode;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Reference to the tooltip, providing utility methods for alignment and DOM access.
|
|
463
|
+
*/
|
|
464
|
+
interface TooltipRef {
|
|
465
|
+
/**
|
|
466
|
+
* The native DOM element of the tooltip.
|
|
467
|
+
*/
|
|
468
|
+
nativeElement: HTMLElement;
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Forces the alignment of the tooltip, recalculating its position relative to its target.
|
|
472
|
+
*/
|
|
473
|
+
forceAlign: VoidFunction;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
type TransitionNameType = string;
|
|
477
|
+
|
|
478
|
+
type AnimationType = string;
|
|
479
|
+
|
|
480
|
+
type BuildInPlacements = Record<string, AlignType>;
|
|
481
|
+
|
|
482
|
+
type StretchType = string;
|
|
483
|
+
|
|
484
|
+
type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Properties for configuring a trigger that controls the visibility of a popup element.
|
|
488
|
+
*/
|
|
489
|
+
interface TriggerProps {
|
|
490
|
+
/**
|
|
491
|
+
* The child element that triggers the popup.
|
|
492
|
+
*/
|
|
493
|
+
children: React.ReactElement;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* The action(s) that trigger the popup. Options include 'hover', 'focus', 'click', or 'contextMenu'.
|
|
497
|
+
*/
|
|
498
|
+
action?: ActionType | ActionType[];
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Actions that explicitly show the popup.
|
|
502
|
+
*/
|
|
503
|
+
showAction?: ActionType[];
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Actions that explicitly hide the popup.
|
|
507
|
+
*/
|
|
508
|
+
hideAction?: ActionType[];
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Prefix for the popup CSS class.
|
|
512
|
+
*/
|
|
513
|
+
prefixCls?: string;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* The z-index of the popup.
|
|
517
|
+
*/
|
|
518
|
+
zIndex?: number;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Callback function executed when the popup is aligned with its target.
|
|
522
|
+
*
|
|
523
|
+
* @param element - The popup element.
|
|
524
|
+
* @param align - The alignment configuration.
|
|
525
|
+
*/
|
|
526
|
+
onPopupAlign?: (element: HTMLElement, align: AlignType) => void;
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Determines how the popup stretches to fit its container.
|
|
530
|
+
*/
|
|
531
|
+
stretch?: string;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Whether the popup is currently visible.
|
|
535
|
+
*/
|
|
536
|
+
popupVisible?: boolean;
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Whether the popup is visible by default.
|
|
540
|
+
*/
|
|
541
|
+
defaultPopupVisible?: boolean;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Callback function executed when the popup visibility changes.
|
|
545
|
+
*
|
|
546
|
+
* @param visible - Whether the popup is now visible.
|
|
547
|
+
*/
|
|
548
|
+
onPopupVisibleChange?: (visible: boolean) => void;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Callback function executed after the popup visibility has changed.
|
|
552
|
+
*
|
|
553
|
+
* @param visible - Whether the popup is now visible.
|
|
554
|
+
*/
|
|
555
|
+
afterPopupVisibleChange?: (visible: boolean) => void;
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Function to specify the container where the popup should be rendered.
|
|
559
|
+
*
|
|
560
|
+
* @param node - The DOM node triggering the popup.
|
|
561
|
+
* @returns - The container element for the popup.
|
|
562
|
+
*/
|
|
563
|
+
getPopupContainer?: (node: HTMLElement) => HTMLElement;
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Whether to force the rendering of the popup, even if it is not visible.
|
|
567
|
+
*/
|
|
568
|
+
forceRender?: boolean;
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Whether to automatically destroy the popup when it is hidden.
|
|
572
|
+
*/
|
|
573
|
+
autoDestroy?: boolean;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Whether to display a mask behind the popup.
|
|
577
|
+
*/
|
|
578
|
+
mask?: boolean;
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Whether the popup should close when the mask is clicked.
|
|
582
|
+
*/
|
|
583
|
+
maskClosable?: boolean;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Motion configuration for animating the popup. See `rc-motion` for more information.
|
|
587
|
+
*/
|
|
588
|
+
popupMotion?: CSSMotionProps;
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Motion configuration for animating the mask. See `rc-motion` for more information.
|
|
592
|
+
*/
|
|
593
|
+
maskMotion?: CSSMotionProps;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Delay (in seconds) before the popup is shown on mouse enter.
|
|
597
|
+
*/
|
|
598
|
+
mouseEnterDelay?: number;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Delay (in seconds) before the popup is hidden on mouse leave.
|
|
602
|
+
*/
|
|
603
|
+
mouseLeaveDelay?: number;
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Delay (in seconds) before the popup is shown on focus.
|
|
607
|
+
*/
|
|
608
|
+
focusDelay?: number;
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Delay (in seconds) before the popup is hidden on blur.
|
|
612
|
+
*/
|
|
613
|
+
blurDelay?: number;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* The content of the popup, which can be a React node or a function that returns one.
|
|
617
|
+
*/
|
|
618
|
+
popup: React.ReactNode | (() => React.ReactNode);
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* The placement of the popup relative to its target.
|
|
622
|
+
*/
|
|
623
|
+
popupPlacement?: string;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Custom placements for the popup, defined as a mapping of placement names to alignment configurations.
|
|
627
|
+
*/
|
|
628
|
+
builtinPlacements?: BuildInPlacements;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Alignment configuration for the popup.
|
|
632
|
+
*/
|
|
633
|
+
popupAlign?: AlignType;
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Additional CSS class for the popup container.
|
|
637
|
+
*/
|
|
638
|
+
popupClassName?: string;
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Inline styles for the popup container.
|
|
642
|
+
*/
|
|
643
|
+
popupStyle?: React.CSSProperties;
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Function to generate the popup's class name based on its alignment.
|
|
647
|
+
*
|
|
648
|
+
* @param align - The alignment configuration.
|
|
649
|
+
* @returns - The class name for the popup.
|
|
650
|
+
*/
|
|
651
|
+
getPopupClassNameFromAlign?: (align: AlignType) => string;
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Callback function executed when the popup is clicked.
|
|
655
|
+
*/
|
|
656
|
+
onPopupClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Whether to align the popup to a specific point instead of an element.
|
|
660
|
+
*/
|
|
661
|
+
alignPoint?: boolean;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Whether to refresh the popup content every time it is shown.
|
|
665
|
+
* If `false`, the content is memoized and not updated between visibility changes.
|
|
666
|
+
*/
|
|
667
|
+
fresh?: boolean;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Whether to display an arrow in the popup.
|
|
671
|
+
*/
|
|
672
|
+
arrow?: boolean | ArrowTypeOuter;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Configuration for the outer arrow of the popup.
|
|
677
|
+
*/
|
|
678
|
+
interface ArrowTypeOuter {
|
|
679
|
+
/**
|
|
680
|
+
* Additional CSS class for the arrow.
|
|
681
|
+
*/
|
|
682
|
+
className?: string;
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Custom content for the arrow.
|
|
686
|
+
*/
|
|
687
|
+
content?: React.ReactNode;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
type MotionName =
|
|
691
|
+
| string
|
|
692
|
+
| {
|
|
693
|
+
appear?: string;
|
|
694
|
+
enter?: string;
|
|
695
|
+
leave?: string;
|
|
696
|
+
appearActive?: string;
|
|
697
|
+
enterActive?: string;
|
|
698
|
+
leaveActive?: string;
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Properties for configuring CSS-based motion animations.
|
|
703
|
+
*/
|
|
704
|
+
interface CSSMotionProps {
|
|
705
|
+
/**
|
|
706
|
+
* Name of the motion animation, which corresponds to a CSS class.
|
|
707
|
+
*/
|
|
708
|
+
motionName?: MotionName;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Determines whether the motion is currently visible.
|
|
712
|
+
*/
|
|
713
|
+
visible?: boolean;
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Enables the motion to appear with an animation.
|
|
717
|
+
*/
|
|
718
|
+
motionAppear?: boolean;
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Enables the motion to enter with an animation.
|
|
722
|
+
*/
|
|
723
|
+
motionEnter?: boolean;
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Enables the motion to leave with an animation.
|
|
727
|
+
*/
|
|
728
|
+
motionLeave?: boolean;
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Forces the motion to leave immediately without waiting for the animation.
|
|
732
|
+
*/
|
|
733
|
+
motionLeaveImmediately?: boolean;
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Specifies the maximum duration (in milliseconds) for the motion.
|
|
737
|
+
*/
|
|
738
|
+
motionDeadline?: number;
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Forces the creation of the element in the DOM, even if it is not visible.
|
|
742
|
+
* Invisible elements are styled with `display: none`.
|
|
743
|
+
*/
|
|
744
|
+
forceRender?: boolean;
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Removes the element from the DOM when the motion ends.
|
|
748
|
+
* This option will not work if `forceRender` is enabled.
|
|
749
|
+
*/
|
|
750
|
+
removeOnLeave?: boolean;
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* CSS class applied to elements that have completed their motion and left the viewport.
|
|
754
|
+
*/
|
|
755
|
+
leavedClassName?: string;
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Called during the preparation phase of the appear animation.
|
|
759
|
+
* Used to measure the element's properties.
|
|
760
|
+
*/
|
|
761
|
+
onAppearPrepare?: MotionPrepareEventHandler;
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Called during the preparation phase of the enter animation.
|
|
765
|
+
* Used to measure the element's properties.
|
|
766
|
+
*/
|
|
767
|
+
onEnterPrepare?: MotionPrepareEventHandler;
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Called during the preparation phase of the leave animation.
|
|
771
|
+
* Used to measure the element's properties.
|
|
772
|
+
*/
|
|
773
|
+
onLeavePrepare?: MotionPrepareEventHandler;
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Called when the appear animation starts.
|
|
777
|
+
*/
|
|
778
|
+
onAppearStart?: MotionEventHandler;
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Called when the enter animation starts.
|
|
782
|
+
*/
|
|
783
|
+
onEnterStart?: MotionEventHandler;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Called when the leave animation starts.
|
|
787
|
+
*/
|
|
788
|
+
onLeaveStart?: MotionEventHandler;
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Called when the appear animation becomes active.
|
|
792
|
+
*/
|
|
793
|
+
onAppearActive?: MotionEventHandler;
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Called when the enter animation becomes active.
|
|
797
|
+
*/
|
|
798
|
+
onEnterActive?: MotionEventHandler;
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Called when the leave animation becomes active.
|
|
802
|
+
*/
|
|
803
|
+
onLeaveActive?: MotionEventHandler;
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Called when the appear animation ends.
|
|
807
|
+
*/
|
|
808
|
+
onAppearEnd?: MotionEndEventHandler;
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Called when the enter animation ends.
|
|
812
|
+
*/
|
|
813
|
+
onEnterEnd?: MotionEndEventHandler;
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* Called when the leave animation ends.
|
|
817
|
+
*/
|
|
818
|
+
onLeaveEnd?: MotionEndEventHandler;
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Always called after the final visibility state has changed, regardless of whether a motion is configured.
|
|
822
|
+
*
|
|
823
|
+
* @param visible - Indicates whether the element is visible after the change.
|
|
824
|
+
*/
|
|
825
|
+
onVisibleChanged?: (visible: boolean) => void;
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Internal reference to the animated element.
|
|
829
|
+
*/
|
|
830
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
831
|
+
internalRef?: React.Ref<any>;
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* A render function for the motion's children.
|
|
835
|
+
*
|
|
836
|
+
* @param props - Props passed to the child element, including `visible`, `className`, and `style`.
|
|
837
|
+
* @param ref - Reference to the child element.
|
|
838
|
+
* @returns - A React element representing the animated child.
|
|
839
|
+
*/
|
|
840
|
+
children?: (
|
|
841
|
+
props: {
|
|
842
|
+
visible?: boolean;
|
|
843
|
+
className?: string;
|
|
844
|
+
style?: React.CSSProperties;
|
|
845
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
846
|
+
[key: string]: any;
|
|
847
|
+
},
|
|
848
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
849
|
+
ref: (node: any) => void
|
|
850
|
+
) => React.ReactElement;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
854
|
+
type MotionPrepareEventHandler = (element: HTMLElement) => Promise<any> | void;
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Type definition for a handler function that executes during a motion event.
|
|
858
|
+
* The function can modify CSS properties of the animated element or perform side effects.
|
|
859
|
+
*
|
|
860
|
+
* @param element - The HTML element that is being animated.
|
|
861
|
+
* @param event - The motion event triggering this handler.
|
|
862
|
+
* @returns - Optionally returns a set of CSS properties to apply to the element.
|
|
863
|
+
*/
|
|
864
|
+
type MotionEventHandler = (
|
|
865
|
+
element: HTMLElement,
|
|
866
|
+
event: MotionEvent
|
|
867
|
+
) => React.CSSProperties | void;
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Type definition for a handler function that executes at the end of a motion event.
|
|
871
|
+
* The function determines whether the motion was successfully completed or requires further actions.
|
|
872
|
+
*
|
|
873
|
+
* @param element - The HTML element that was animated.
|
|
874
|
+
* @param event - The motion event that has ended.
|
|
875
|
+
* @returns - Returns `true` if the motion is successfully completed, or `false` to indicate an error or retry.
|
|
876
|
+
*/
|
|
877
|
+
type MotionEndEventHandler = (
|
|
878
|
+
element: HTMLElement,
|
|
879
|
+
event: MotionEvent
|
|
880
|
+
) => boolean | void;
|
|
881
|
+
|
|
882
|
+
type OffsetType = number | `${number}%`;
|
|
883
|
+
|
|
884
|
+
type AlignPointTopBottom = 't' | 'b' | 'c';
|
|
885
|
+
|
|
886
|
+
type AlignPointLeftRight = 'l' | 'r' | 'c';
|
|
887
|
+
|
|
888
|
+
type AlignPoint = `${AlignPointTopBottom}${AlignPointLeftRight}`;
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Configuration for aligning the tooltip or popup content relative to a target element.
|
|
892
|
+
*/
|
|
893
|
+
interface AlignType {
|
|
894
|
+
/**
|
|
895
|
+
* Defines the alignment points of the source and target nodes.
|
|
896
|
+
* Each point can be 't' (top), 'b' (bottom), 'c' (center), 'l' (left), or 'r' (right).
|
|
897
|
+
* For example, `['tr', 'cc']` aligns the top-right of the source node
|
|
898
|
+
* with the center of the target node.
|
|
899
|
+
*/
|
|
900
|
+
points?: (string | AlignPoint)[];
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Defines the offset for the source node in the x and y directions.
|
|
904
|
+
* If the offset contains a percentage string, it is relative to the source node's region.
|
|
905
|
+
*/
|
|
906
|
+
offset?: OffsetType[];
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* Defines the offset for the target node in the x and y directions.
|
|
910
|
+
* If the targetOffset contains a percentage string, it is relative to the target node's region.
|
|
911
|
+
*/
|
|
912
|
+
targetOffset?: OffsetType[];
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Configuration for adjusting the source node's position to prevent it from being invisible.
|
|
916
|
+
* - `adjustX`: Adjusts the x position.
|
|
917
|
+
* - `adjustY`: Adjusts the y position.
|
|
918
|
+
* - `shiftX`: Shifts the x position slightly.
|
|
919
|
+
* - `shiftY`: Shifts the y position slightly.
|
|
920
|
+
*/
|
|
921
|
+
overflow?: {
|
|
922
|
+
adjustX?: boolean | number;
|
|
923
|
+
adjustY?: boolean | number;
|
|
924
|
+
shiftX?: boolean | number;
|
|
925
|
+
shiftY?: boolean | number;
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* Whether to automatically adjust the arrow position based on the alignment.
|
|
930
|
+
*/
|
|
931
|
+
autoArrow?: boolean;
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Defines the visible region check for the tooltip or popup.
|
|
935
|
+
* - `visible`: Checks the visible region of the browser window (default).
|
|
936
|
+
* - `scroll`: Includes the entire scrollable region.
|
|
937
|
+
* - `visibleFirst`: Prioritizes the visible region but falls back to `scroll` if necessary.
|
|
938
|
+
*/
|
|
939
|
+
htmlRegion?: 'visible' | 'scroll' | 'visibleFirst';
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Automatically chooses a position with `top` or `bottom` based on the alignment result.
|
|
943
|
+
*/
|
|
944
|
+
dynamicInset?: boolean;
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* Uses `css right` instead of `left` for positioning, if enabled.
|
|
948
|
+
*/
|
|
949
|
+
useCssRight?: boolean;
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* Uses `css bottom` instead of `top` for positioning, if enabled.
|
|
953
|
+
*/
|
|
954
|
+
useCssBottom?: boolean;
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Uses `css transform` for positioning instead of absolute properties like left, top, right, or bottom.
|
|
958
|
+
* Defaults to `false`.
|
|
959
|
+
*/
|
|
960
|
+
useCssTransform?: boolean;
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Ignores minor shaking effects in tooltip alignment.
|
|
964
|
+
*/
|
|
965
|
+
ignoreShake?: boolean;
|
|
966
|
+
}
|