@rescui/tooltip 0.14.3 → 0.14.4-floating-ui-migration-ee8cf10db.9.sha-ee8cf10db
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/lib/index.css +23 -23
- package/lib/tooltip.d.ts +8 -7
- package/lib/tooltip.js +168 -171
- package/lib/tooltip.p.module.css.js +1 -1
- package/llm/components/tooltip.md +7 -7
- package/package.json +8 -10
package/lib/index.css
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
inherits:true;
|
|
4
4
|
initial-value:0;
|
|
5
5
|
}
|
|
6
|
-
.
|
|
6
|
+
._tooltip_gllyq6_5{
|
|
7
7
|
position:relative;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.
|
|
10
|
+
._closing_gllyq6_9{
|
|
11
11
|
pointer-events:none;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.
|
|
14
|
+
._content_gllyq6_13{
|
|
15
15
|
--rs-theme-dark:1;
|
|
16
16
|
--_rs-tooltip-border-width:1px;
|
|
17
17
|
|
|
@@ -86,40 +86,40 @@
|
|
|
86
86
|
transform:translate(0, 0);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
[data-popper-placement='top-end'] .
|
|
90
|
-
[data-popper-placement='bottom-end'] .
|
|
89
|
+
[data-popper-placement='top-end'] ._content_gllyq6_13,
|
|
90
|
+
[data-popper-placement='bottom-end'] ._content_gllyq6_13{
|
|
91
91
|
margin-right:0;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
[data-popper-placement='top-start'] .
|
|
95
|
-
[data-popper-placement='bottom-start'] .
|
|
94
|
+
[data-popper-placement='top-start'] ._content_gllyq6_13,
|
|
95
|
+
[data-popper-placement='bottom-start'] ._content_gllyq6_13{
|
|
96
96
|
margin-left:0;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
[data-popper-placement='left-end'] .
|
|
100
|
-
[data-popper-placement='right-end'] .
|
|
99
|
+
[data-popper-placement='left-end'] ._content_gllyq6_13,
|
|
100
|
+
[data-popper-placement='right-end'] ._content_gllyq6_13{
|
|
101
101
|
margin-bottom:0;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
[data-popper-placement='left-start'] .
|
|
105
|
-
[data-popper-placement='right-start'] .
|
|
104
|
+
[data-popper-placement='left-start'] ._content_gllyq6_13,
|
|
105
|
+
[data-popper-placement='right-start'] ._content_gllyq6_13{
|
|
106
106
|
margin-top:0;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
.
|
|
109
|
+
._initial_gllyq6_57 ._content_gllyq6_13{
|
|
110
110
|
transition:none;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
.
|
|
113
|
+
._closing_gllyq6_9 ._content_gllyq6_13{
|
|
114
114
|
transition-duration:200ms, 200ms;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
.
|
|
118
|
-
.
|
|
117
|
+
._initial_gllyq6_57 ._content_gllyq6_13,
|
|
118
|
+
._closing_gllyq6_9 ._content_gllyq6_13{
|
|
119
119
|
opacity:0;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
.
|
|
122
|
+
._outerThemeLight_gllyq6_71 ._content_gllyq6_13{
|
|
123
123
|
--rs-color-primary-dark-theme:var(--rs-color-primary-light-theme);
|
|
124
124
|
--rs-color-primary-dim-dark-theme:var(--rs-color-primary-dim-light-theme);
|
|
125
125
|
--rs-color-primary-fog-dark-theme:var(--rs-color-primary-fog-light-theme);
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
.
|
|
134
|
+
._outerThemeDark_gllyq6_84 ._content_gllyq6_13{
|
|
135
135
|
--rs-color-primary-light-theme:var(--rs-color-primary-dark-theme);
|
|
136
136
|
--rs-color-primary-dim-light-theme:var(--rs-color-primary-dim-dark-theme);
|
|
137
137
|
--rs-color-primary-fog-light-theme:var(--rs-color-primary-fog-dark-theme);
|
|
@@ -143,24 +143,24 @@
|
|
|
143
143
|
);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
.
|
|
146
|
+
._initial_gllyq6_57[data-popper-placement^='top'] ._content_gllyq6_13, ._closing_gllyq6_9[data-popper-placement^='top'] ._content_gllyq6_13{
|
|
147
147
|
transform:translate(0, 10px);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
.
|
|
150
|
+
._initial_gllyq6_57[data-popper-placement^='right'] ._content_gllyq6_13, ._closing_gllyq6_9[data-popper-placement^='right'] ._content_gllyq6_13{
|
|
151
151
|
transform:translate(-10px, 0);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
.
|
|
154
|
+
._initial_gllyq6_57[data-popper-placement^='bottom'] ._content_gllyq6_13, ._closing_gllyq6_9[data-popper-placement^='bottom'] ._content_gllyq6_13{
|
|
155
155
|
transform:translate(0, -10px);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
.
|
|
158
|
+
._initial_gllyq6_57[data-popper-placement^='left'] ._content_gllyq6_13, ._closing_gllyq6_9[data-popper-placement^='left'] ._content_gllyq6_13{
|
|
159
159
|
transform:translate(10px, 0);
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
.
|
|
163
|
-
.
|
|
162
|
+
._trigger_gllyq6_116:focus-visible,
|
|
163
|
+
._trigger_gllyq6_116:focus[data-focus-method='key']{
|
|
164
164
|
outline:none;
|
|
165
165
|
|
|
166
166
|
box-shadow:var(--rs-color-primary-t-dim-light-theme) 0 0 0 4px;
|
package/lib/tooltip.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import type { Placement } from '@popperjs/core/lib/enums';
|
|
2
|
+
import type { Middleware, Placement } from '@floating-ui/react-dom';
|
|
4
3
|
interface TriggerTargetRequiredProps {
|
|
5
4
|
ref: React.Ref<HTMLElement>;
|
|
6
5
|
}
|
|
@@ -16,7 +15,8 @@ type ChildrenFunc = (arg: {
|
|
|
16
15
|
targetProps: TriggerTargetProps;
|
|
17
16
|
}) => React.ReactNode;
|
|
18
17
|
export type TooltipChildren = ChildrenFunc | React.ReactNode;
|
|
19
|
-
|
|
18
|
+
type AutoPlacement = 'auto' | 'auto-start' | 'auto-end';
|
|
19
|
+
export type TooltipPlacement = Placement | AutoPlacement;
|
|
20
20
|
export interface TooltipProps {
|
|
21
21
|
/**
|
|
22
22
|
* Target node or `({targetProps}) => node` function
|
|
@@ -37,9 +37,10 @@ export interface TooltipProps {
|
|
|
37
37
|
*/
|
|
38
38
|
isVisible?: boolean;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Floating UI [middleware](https://floating-ui.com/docs/middleware).
|
|
41
|
+
* A middleware replaces the built-in one with the same name (`offset`, `flip`, `autoPlacement` or `shift`)
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
middleware?: Middleware[];
|
|
43
44
|
/**
|
|
44
45
|
* Please use only `auto`, `top-end`, `right`, `left`, `right-start` or `left-start` to be compliant with styleguide
|
|
45
46
|
*/
|
|
@@ -47,10 +48,10 @@ export interface TooltipProps {
|
|
|
47
48
|
/**
|
|
48
49
|
* When no space is available on the preferred placement, the tooltip will test
|
|
49
50
|
* the ones provided in the list, and use the first useful one.
|
|
50
|
-
* See [docs](https://
|
|
51
|
+
* See [docs](https://floating-ui.com/docs/flip#fallbackplacements).
|
|
51
52
|
* @rawDefaultValue
|
|
52
53
|
*/
|
|
53
|
-
fallbackPlacements?:
|
|
54
|
+
fallbackPlacements?: TooltipPlacement[];
|
|
54
55
|
/**
|
|
55
56
|
* Disable timeout before hide tooltip after mouse left target,
|
|
56
57
|
* use with cation, it can make impossible to click on links inside tooltip
|
package/lib/tooltip.js
CHANGED
|
@@ -4,19 +4,51 @@ import React, { cloneElement, createElement, useState, useRef, useContext, isVal
|
|
|
4
4
|
import cn from 'classnames';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import ReactDOM from 'react-dom';
|
|
7
|
-
import {
|
|
7
|
+
import { offset, autoPlacement, flip, shift, limitShift, useFloating, autoUpdate } from '@floating-ui/react-dom';
|
|
8
8
|
import { useLayeringContext, ThemeContext, ThemeProvider } from '@rescui/ui-contexts';
|
|
9
|
-
import { useResizeObserver } from '@rescui/use-resize-observer';
|
|
10
9
|
import styles from './tooltip.p.module.css.js';
|
|
11
10
|
import { useTooltipState, TOOLTIP_STATES } from './use-tooltip-state.js';
|
|
12
11
|
import { useExtractCssValues } from './use-extract-css-values.js';
|
|
13
12
|
|
|
14
13
|
const HIDE_TIMEOUT = 500;
|
|
15
|
-
const
|
|
14
|
+
const ALIGNED_PLACEMENTS = ['top-start', 'top-end', 'bottom-start', 'bottom-end', 'right-start', 'right-end', 'left-start', 'left-end'];
|
|
15
|
+
/**
|
|
16
|
+
* Candidates for `autoPlacement()`, in the order Popper.js used to try them when
|
|
17
|
+
* several placements have the same space: `auto-start` and `auto-end` both try
|
|
18
|
+
* all aligned placements, `-start` first.
|
|
19
|
+
*/
|
|
20
|
+
const AUTO_PLACEMENTS = {
|
|
21
|
+
auto: ['top', 'bottom', 'right', 'left'],
|
|
22
|
+
'auto-start': ALIGNED_PLACEMENTS,
|
|
23
|
+
'auto-end': ALIGNED_PLACEMENTS
|
|
24
|
+
};
|
|
25
|
+
const isAutoPlacement = placement => placement.startsWith('auto');
|
|
26
|
+
// `flip()` takes only exact placements. Popper.js tried the same placements for `auto*`,
|
|
27
|
+
// but sorted them by the available space.
|
|
28
|
+
const expandAutoPlacements = placements => placements.reduce((result, placement) => {
|
|
29
|
+
const expanded = isAutoPlacement(placement) ? AUTO_PLACEMENTS[placement] : [placement];
|
|
30
|
+
return result.concat(expanded.filter(item => !result.includes(item)));
|
|
31
|
+
}, []);
|
|
32
|
+
function mergeMiddleware(builtInMiddleware) {
|
|
33
|
+
let customMiddleware = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
34
|
+
const isBuiltIn = _ref => {
|
|
35
|
+
let {
|
|
36
|
+
name
|
|
37
|
+
} = _ref;
|
|
38
|
+
return builtInMiddleware.some(builtIn => builtIn.name === name);
|
|
39
|
+
};
|
|
40
|
+
return [...builtInMiddleware.map(builtIn => customMiddleware.find(_ref2 => {
|
|
41
|
+
let {
|
|
42
|
+
name
|
|
43
|
+
} = _ref2;
|
|
44
|
+
return name === builtIn.name;
|
|
45
|
+
}) ?? builtIn), ...customMiddleware.filter(custom => !isBuiltIn(custom))];
|
|
46
|
+
}
|
|
47
|
+
const Portal = _ref3 => {
|
|
16
48
|
let {
|
|
17
49
|
children,
|
|
18
50
|
target
|
|
19
|
-
} =
|
|
51
|
+
} = _ref3;
|
|
20
52
|
return target ? /*#__PURE__*/ReactDOM.createPortal(children, target) : null;
|
|
21
53
|
};
|
|
22
54
|
const TooltipPortal = t0 => {
|
|
@@ -63,7 +95,7 @@ const OUTER_THEME_STYLES = {
|
|
|
63
95
|
light: styles.outerThemeLight,
|
|
64
96
|
dark: styles.outerThemeDark
|
|
65
97
|
};
|
|
66
|
-
const TriggerRenderer = /*#__PURE__*/React.forwardRef((
|
|
98
|
+
const TriggerRenderer = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
67
99
|
let {
|
|
68
100
|
setTriggerRef,
|
|
69
101
|
targetComponent,
|
|
@@ -71,7 +103,7 @@ const TriggerRenderer = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
71
103
|
handleMouseEnterTarget,
|
|
72
104
|
handleMouseLeaveTarget,
|
|
73
105
|
children
|
|
74
|
-
} =
|
|
106
|
+
} = _ref4;
|
|
75
107
|
const eventListeners = !isControlled ? {
|
|
76
108
|
onMouseEnter: handleMouseEnterTarget,
|
|
77
109
|
onMouseLeave: handleMouseLeaveTarget,
|
|
@@ -118,14 +150,14 @@ const TriggerRenderer = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
118
150
|
TriggerRenderer.displayName = 'TriggerRenderer';
|
|
119
151
|
// eslint-disable-next-line complexity
|
|
120
152
|
const Tooltip = t0 => {
|
|
121
|
-
const $ = c(
|
|
153
|
+
const $ = c(54);
|
|
122
154
|
const {
|
|
123
155
|
children,
|
|
124
156
|
targetComponent: t1,
|
|
125
157
|
content,
|
|
126
158
|
className,
|
|
127
159
|
isVisible: isVisibleFromProps,
|
|
128
|
-
|
|
160
|
+
middleware,
|
|
129
161
|
placement: t2,
|
|
130
162
|
sparse: t3,
|
|
131
163
|
fallbackPlacements: t4,
|
|
@@ -135,15 +167,7 @@ const Tooltip = t0 => {
|
|
|
135
167
|
const targetComponent = t1 === undefined ? "span" : t1;
|
|
136
168
|
const placement = t2 === undefined ? "auto" : t2;
|
|
137
169
|
const sparse = t3 === undefined ? true : t3;
|
|
138
|
-
|
|
139
|
-
if ($[0] !== t4) {
|
|
140
|
-
t6 = t4 === undefined ? ["top", "bottom"] : t4;
|
|
141
|
-
$[0] = t4;
|
|
142
|
-
$[1] = t6;
|
|
143
|
-
} else {
|
|
144
|
-
t6 = $[1];
|
|
145
|
-
}
|
|
146
|
-
const fallbackPlacements = t6;
|
|
170
|
+
const fallbackPlacements = t4 === undefined ? ["top", "bottom"] : t4;
|
|
147
171
|
const renderBesideTrigger = t5 === undefined ? false : t5;
|
|
148
172
|
const {
|
|
149
173
|
tooltipZIndex
|
|
@@ -159,34 +183,35 @@ const Tooltip = t0 => {
|
|
|
159
183
|
const isVisible = typeof triggerRef !== "undefined" || renderBesideTrigger ? requestedVisibility : false;
|
|
160
184
|
const ownerDocument = triggerRef?.ownerDocument;
|
|
161
185
|
const isOpen = isVisible || isTooltipHovered;
|
|
162
|
-
let
|
|
163
|
-
if ($[
|
|
164
|
-
|
|
165
|
-
$[
|
|
166
|
-
$[
|
|
186
|
+
let t6;
|
|
187
|
+
if ($[0] !== content) {
|
|
188
|
+
t6 = isNode(content);
|
|
189
|
+
$[0] = content;
|
|
190
|
+
$[1] = t6;
|
|
167
191
|
} else {
|
|
168
|
-
|
|
192
|
+
t6 = $[1];
|
|
169
193
|
}
|
|
170
|
-
const contentCanBeRendered =
|
|
194
|
+
const contentCanBeRendered = t6;
|
|
171
195
|
const portalTargetIsAvailable = renderBesideTrigger || Boolean(ownerDocument?.body);
|
|
172
196
|
const canRenderTooltip = contentCanBeRendered && portalTargetIsAvailable;
|
|
173
|
-
let
|
|
174
|
-
if ($[
|
|
175
|
-
|
|
197
|
+
let t7;
|
|
198
|
+
if ($[2] !== setIsVisibleState) {
|
|
199
|
+
t7 = () => {
|
|
176
200
|
if (hideTimeoutRef.current) {
|
|
177
201
|
clearTimeout(hideTimeoutRef.current);
|
|
178
202
|
hideTimeoutRef.current = null;
|
|
179
203
|
}
|
|
180
204
|
setIsVisibleState(true);
|
|
181
205
|
};
|
|
182
|
-
$[
|
|
206
|
+
$[2] = setIsVisibleState;
|
|
207
|
+
$[3] = t7;
|
|
183
208
|
} else {
|
|
184
|
-
|
|
209
|
+
t7 = $[3];
|
|
185
210
|
}
|
|
186
|
-
const handleMouseEnterTarget =
|
|
187
|
-
let
|
|
188
|
-
if ($[5] !==
|
|
189
|
-
|
|
211
|
+
const handleMouseEnterTarget = t7;
|
|
212
|
+
let t8;
|
|
213
|
+
if ($[4] !== disableHideDelay || $[5] !== setIsVisibleState) {
|
|
214
|
+
t8 = () => {
|
|
190
215
|
if (disableHideDelay) {
|
|
191
216
|
setIsVisibleState(false);
|
|
192
217
|
} else {
|
|
@@ -195,131 +220,95 @@ const Tooltip = t0 => {
|
|
|
195
220
|
}, HIDE_TIMEOUT);
|
|
196
221
|
}
|
|
197
222
|
};
|
|
198
|
-
$[
|
|
199
|
-
$[
|
|
223
|
+
$[4] = disableHideDelay;
|
|
224
|
+
$[5] = setIsVisibleState;
|
|
225
|
+
$[6] = t8;
|
|
200
226
|
} else {
|
|
201
|
-
|
|
227
|
+
t8 = $[6];
|
|
202
228
|
}
|
|
203
|
-
const handleMouseLeaveTarget =
|
|
204
|
-
let
|
|
229
|
+
const handleMouseLeaveTarget = t8;
|
|
230
|
+
let t9;
|
|
205
231
|
if ($[7] !== sparse) {
|
|
206
|
-
|
|
232
|
+
t9 = t10 => {
|
|
207
233
|
const {
|
|
208
234
|
placement: offsetPlacement
|
|
209
|
-
} =
|
|
235
|
+
} = t10;
|
|
210
236
|
if (offsetPlacement.includes("left") || offsetPlacement.includes("right")) {
|
|
211
|
-
return
|
|
237
|
+
return sparse ? 16 : 8;
|
|
212
238
|
} else {
|
|
213
|
-
return
|
|
239
|
+
return sparse ? 12 : 8;
|
|
214
240
|
}
|
|
215
241
|
};
|
|
216
242
|
$[7] = sparse;
|
|
217
|
-
$[8] =
|
|
218
|
-
} else {
|
|
219
|
-
t10 = $[8];
|
|
220
|
-
}
|
|
221
|
-
const calcOffset = t10;
|
|
222
|
-
let t11;
|
|
223
|
-
if ($[9] !== fallbackPlacements) {
|
|
224
|
-
t11 = {
|
|
225
|
-
name: "flip",
|
|
226
|
-
options: {
|
|
227
|
-
fallbackPlacements
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
$[9] = fallbackPlacements;
|
|
231
|
-
$[10] = t11;
|
|
243
|
+
$[8] = t9;
|
|
232
244
|
} else {
|
|
233
|
-
|
|
245
|
+
t9 = $[8];
|
|
234
246
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
247
|
+
const calcOffset = t9;
|
|
248
|
+
let t10;
|
|
249
|
+
if ($[9] !== popperRef || $[10] !== triggerRef) {
|
|
250
|
+
t10 = {
|
|
251
|
+
reference: triggerRef,
|
|
252
|
+
floating: popperRef
|
|
242
253
|
};
|
|
243
|
-
$[
|
|
244
|
-
$[
|
|
245
|
-
|
|
246
|
-
t12 = $[12];
|
|
247
|
-
}
|
|
248
|
-
let t13;
|
|
249
|
-
if ($[13] !== modifiers) {
|
|
250
|
-
t13 = modifiers || [];
|
|
251
|
-
$[13] = modifiers;
|
|
252
|
-
$[14] = t13;
|
|
254
|
+
$[9] = popperRef;
|
|
255
|
+
$[10] = triggerRef;
|
|
256
|
+
$[11] = t10;
|
|
253
257
|
} else {
|
|
254
|
-
|
|
258
|
+
t10 = $[11];
|
|
255
259
|
}
|
|
260
|
+
const t11 = isAutoPlacement(placement) ? undefined : placement;
|
|
261
|
+
const t12 = mergeMiddleware([offset(calcOffset, [sparse]), isAutoPlacement(placement) ? autoPlacement({
|
|
262
|
+
allowedPlacements: AUTO_PLACEMENTS[placement]
|
|
263
|
+
}) : flip({
|
|
264
|
+
fallbackPlacements: expandAutoPlacements(fallbackPlacements),
|
|
265
|
+
fallbackStrategy: "initialPlacement"
|
|
266
|
+
}), shift({
|
|
267
|
+
limiter: limitShift()
|
|
268
|
+
})], middleware);
|
|
269
|
+
const t13 = popperRef !== null;
|
|
256
270
|
let t14;
|
|
257
|
-
if ($[
|
|
258
|
-
t14 =
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
t14 = $[18];
|
|
265
|
-
}
|
|
266
|
-
let t15;
|
|
267
|
-
if ($[19] !== placement || $[20] !== t14) {
|
|
268
|
-
t15 = {
|
|
269
|
-
placement,
|
|
270
|
-
modifiers: t14
|
|
271
|
+
if ($[12] !== t10 || $[13] !== t11 || $[14] !== t12 || $[15] !== t13) {
|
|
272
|
+
t14 = {
|
|
273
|
+
elements: t10,
|
|
274
|
+
placement: t11,
|
|
275
|
+
middleware: t12,
|
|
276
|
+
whileElementsMounted: autoUpdate,
|
|
277
|
+
open: t13
|
|
271
278
|
};
|
|
272
|
-
$[
|
|
273
|
-
$[
|
|
274
|
-
$[
|
|
279
|
+
$[12] = t10;
|
|
280
|
+
$[13] = t11;
|
|
281
|
+
$[14] = t12;
|
|
282
|
+
$[15] = t13;
|
|
283
|
+
$[16] = t14;
|
|
275
284
|
} else {
|
|
276
|
-
|
|
285
|
+
t14 = $[16];
|
|
277
286
|
}
|
|
278
287
|
const {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
} =
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
};
|
|
288
|
-
$[22] = update;
|
|
289
|
-
$[23] = t16;
|
|
290
|
-
} else {
|
|
291
|
-
t16 = $[23];
|
|
292
|
-
}
|
|
293
|
-
let t17;
|
|
294
|
-
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
295
|
-
t17 = {
|
|
296
|
-
ignoreFirstCall: true
|
|
297
|
-
};
|
|
298
|
-
$[24] = t17;
|
|
299
|
-
} else {
|
|
300
|
-
t17 = $[24];
|
|
301
|
-
}
|
|
302
|
-
useResizeObserver(contentEl, t16, t17);
|
|
303
|
-
const resolvedPlacement = attributes.popper?.["data-popper-placement"] ?? null;
|
|
304
|
-
let t18;
|
|
305
|
-
if ($[25] !== canRenderTooltip || $[26] !== contentEl || $[27] !== isOpen || $[28] !== popperRef || $[29] !== resolvedPlacement) {
|
|
306
|
-
t18 = {
|
|
288
|
+
floatingStyles,
|
|
289
|
+
placement: floatingPlacement,
|
|
290
|
+
isPositioned
|
|
291
|
+
} = useFloating(t14);
|
|
292
|
+
const resolvedPlacement = isPositioned ? floatingPlacement : null;
|
|
293
|
+
let t15;
|
|
294
|
+
if ($[17] !== canRenderTooltip || $[18] !== contentEl || $[19] !== isOpen || $[20] !== popperRef || $[21] !== resolvedPlacement) {
|
|
295
|
+
t15 = {
|
|
307
296
|
isOpen,
|
|
308
297
|
canRender: canRenderTooltip,
|
|
309
298
|
contentEl,
|
|
310
299
|
popperElement: popperRef,
|
|
311
300
|
resolvedPlacement
|
|
312
301
|
};
|
|
313
|
-
$[
|
|
314
|
-
$[
|
|
315
|
-
$[
|
|
316
|
-
$[
|
|
317
|
-
$[
|
|
318
|
-
$[
|
|
302
|
+
$[17] = canRenderTooltip;
|
|
303
|
+
$[18] = contentEl;
|
|
304
|
+
$[19] = isOpen;
|
|
305
|
+
$[20] = popperRef;
|
|
306
|
+
$[21] = resolvedPlacement;
|
|
307
|
+
$[22] = t15;
|
|
319
308
|
} else {
|
|
320
|
-
|
|
309
|
+
t15 = $[22];
|
|
321
310
|
}
|
|
322
|
-
const tooltipState = useTooltipState(
|
|
311
|
+
const tooltipState = useTooltipState(t15);
|
|
323
312
|
const isInitial = tooltipState === TOOLTIP_STATES.OPENING_PREPARE;
|
|
324
313
|
const isClosing = tooltipState === TOOLTIP_STATES.CLOSING;
|
|
325
314
|
const isExists = tooltipState !== TOOLTIP_STATES.CLOSE;
|
|
@@ -333,33 +322,35 @@ const Tooltip = t0 => {
|
|
|
333
322
|
noProvider
|
|
334
323
|
} = useContext(ThemeContext);
|
|
335
324
|
const theme = noProvider ? themeFromCss : themeFromContext;
|
|
336
|
-
let
|
|
337
|
-
if ($[
|
|
338
|
-
|
|
325
|
+
let t16;
|
|
326
|
+
if ($[23] !== children || $[24] !== handleMouseEnterTarget || $[25] !== handleMouseLeaveTarget || $[26] !== isControlled || $[27] !== setTriggerRef || $[28] !== targetComponent) {
|
|
327
|
+
t16 = /*#__PURE__*/React.createElement(TriggerRenderer, {
|
|
339
328
|
setTriggerRef: setTriggerRef,
|
|
340
329
|
targetComponent: targetComponent,
|
|
341
330
|
isControlled: isControlled,
|
|
342
331
|
handleMouseEnterTarget: handleMouseEnterTarget,
|
|
343
332
|
handleMouseLeaveTarget: handleMouseLeaveTarget
|
|
344
333
|
}, children);
|
|
345
|
-
$[
|
|
346
|
-
$[
|
|
347
|
-
$[
|
|
348
|
-
$[
|
|
349
|
-
$[
|
|
334
|
+
$[23] = children;
|
|
335
|
+
$[24] = handleMouseEnterTarget;
|
|
336
|
+
$[25] = handleMouseLeaveTarget;
|
|
337
|
+
$[26] = isControlled;
|
|
338
|
+
$[27] = setTriggerRef;
|
|
339
|
+
$[28] = targetComponent;
|
|
340
|
+
$[29] = t16;
|
|
350
341
|
} else {
|
|
351
|
-
|
|
342
|
+
t16 = $[29];
|
|
352
343
|
}
|
|
353
|
-
let
|
|
354
|
-
if ($[
|
|
355
|
-
|
|
344
|
+
let t17;
|
|
345
|
+
if ($[30] !== className || $[31] !== content || $[32] !== floatingStyles || $[33] !== handleMouseEnterTarget || $[34] !== handleMouseLeaveTarget || $[35] !== isClosing || $[36] !== isInitial || $[37] !== noProvider || $[38] !== ownerDocument?.body || $[39] !== placement || $[40] !== primaryColors || $[41] !== renderBesideTrigger || $[42] !== resolvedPlacement || $[43] !== setContentEl || $[44] !== setIsTooltipHovered || $[45] !== setIsVisibleState || $[46] !== setPopperRef || $[47] !== theme || $[48] !== tooltipShouldBeRendered || $[49] !== tooltipZIndex) {
|
|
346
|
+
t17 = tooltipShouldBeRendered && /*#__PURE__*/React.createElement(TooltipPortal, {
|
|
356
347
|
renderBesideTrigger: renderBesideTrigger,
|
|
357
348
|
target: ownerDocument?.body
|
|
358
|
-
}, /*#__PURE__*/React.createElement("span",
|
|
349
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
359
350
|
className: cn(styles.tooltip, isInitial && styles.initial, isClosing && styles.closing, OUTER_THEME_STYLES[theme], className),
|
|
360
351
|
ref: setPopperRef,
|
|
361
352
|
style: {
|
|
362
|
-
...
|
|
353
|
+
...floatingStyles,
|
|
363
354
|
...primaryColors,
|
|
364
355
|
zIndex: tooltipZIndex
|
|
365
356
|
},
|
|
@@ -375,8 +366,9 @@ const Tooltip = t0 => {
|
|
|
375
366
|
setIsTooltipHovered(false);
|
|
376
367
|
},
|
|
377
368
|
"data-placement": placement,
|
|
369
|
+
"data-popper-placement": resolvedPlacement ?? undefined,
|
|
378
370
|
"data-test": "tooltip"
|
|
379
|
-
},
|
|
371
|
+
}, /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
380
372
|
theme: "dark",
|
|
381
373
|
ignoreThemeValueForCSSApi: noProvider
|
|
382
374
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -385,35 +377,40 @@ const Tooltip = t0 => {
|
|
|
385
377
|
onFocus: handleMouseEnterTarget,
|
|
386
378
|
ref: setContentEl
|
|
387
379
|
}, content))));
|
|
388
|
-
$[
|
|
389
|
-
$[
|
|
390
|
-
$[
|
|
391
|
-
$[
|
|
392
|
-
$[
|
|
393
|
-
$[
|
|
394
|
-
$[
|
|
395
|
-
$[
|
|
396
|
-
$[
|
|
397
|
-
$[
|
|
398
|
-
$[
|
|
399
|
-
$[
|
|
400
|
-
$[
|
|
401
|
-
$[
|
|
402
|
-
$[
|
|
403
|
-
$[
|
|
380
|
+
$[30] = className;
|
|
381
|
+
$[31] = content;
|
|
382
|
+
$[32] = floatingStyles;
|
|
383
|
+
$[33] = handleMouseEnterTarget;
|
|
384
|
+
$[34] = handleMouseLeaveTarget;
|
|
385
|
+
$[35] = isClosing;
|
|
386
|
+
$[36] = isInitial;
|
|
387
|
+
$[37] = noProvider;
|
|
388
|
+
$[38] = ownerDocument?.body;
|
|
389
|
+
$[39] = placement;
|
|
390
|
+
$[40] = primaryColors;
|
|
391
|
+
$[41] = renderBesideTrigger;
|
|
392
|
+
$[42] = resolvedPlacement;
|
|
393
|
+
$[43] = setContentEl;
|
|
394
|
+
$[44] = setIsTooltipHovered;
|
|
395
|
+
$[45] = setIsVisibleState;
|
|
396
|
+
$[46] = setPopperRef;
|
|
397
|
+
$[47] = theme;
|
|
398
|
+
$[48] = tooltipShouldBeRendered;
|
|
399
|
+
$[49] = tooltipZIndex;
|
|
400
|
+
$[50] = t17;
|
|
404
401
|
} else {
|
|
405
|
-
|
|
402
|
+
t17 = $[50];
|
|
406
403
|
}
|
|
407
|
-
let
|
|
408
|
-
if ($[
|
|
409
|
-
|
|
410
|
-
$[
|
|
411
|
-
$[
|
|
412
|
-
$[
|
|
404
|
+
let t18;
|
|
405
|
+
if ($[51] !== t16 || $[52] !== t17) {
|
|
406
|
+
t18 = /*#__PURE__*/React.createElement(React.Fragment, null, t16, t17);
|
|
407
|
+
$[51] = t16;
|
|
408
|
+
$[52] = t17;
|
|
409
|
+
$[53] = t18;
|
|
413
410
|
} else {
|
|
414
|
-
|
|
411
|
+
t18 = $[53];
|
|
415
412
|
}
|
|
416
|
-
return
|
|
413
|
+
return t18;
|
|
417
414
|
};
|
|
418
415
|
Tooltip.propTypes = {
|
|
419
416
|
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
|
|
@@ -421,7 +418,7 @@ Tooltip.propTypes = {
|
|
|
421
418
|
content: PropTypes.node,
|
|
422
419
|
className: PropTypes.string,
|
|
423
420
|
isVisible: PropTypes.bool,
|
|
424
|
-
|
|
421
|
+
middleware: PropTypes.array,
|
|
425
422
|
placement: PropTypes.oneOf(['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start']),
|
|
426
423
|
fallbackPlacements: PropTypes.arrayOf(PropTypes.oneOf(['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'])),
|
|
427
424
|
sparse: PropTypes.bool,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var styles = {"tooltip":"
|
|
1
|
+
var styles = {"tooltip":"_tooltip_gllyq6_5","closing":"_closing_gllyq6_9","content":"_content_gllyq6_13","initial":"_initial_gllyq6_57","outerThemeLight":"_outerThemeLight_gllyq6_71","outerThemeDark":"_outerThemeDark_gllyq6_84","trigger":"_trigger_gllyq6_116"};
|
|
2
2
|
|
|
3
3
|
export { styles as default };
|
|
@@ -6,7 +6,7 @@ Tooltips display informative text when users hover over, focus on, or click an e
|
|
|
6
6
|
|
|
7
7
|
#### Simple
|
|
8
8
|
|
|
9
|
-
```
|
|
9
|
+
```jsx
|
|
10
10
|
import { Tooltip } from '@rescui/tooltip';
|
|
11
11
|
|
|
12
12
|
<Tooltip content="Simple text">Tooltip will appear on mouseIn</Tooltip>;
|
|
@@ -14,7 +14,7 @@ import { Tooltip } from '@rescui/tooltip';
|
|
|
14
14
|
|
|
15
15
|
#### With Icon
|
|
16
16
|
|
|
17
|
-
```
|
|
17
|
+
```jsx
|
|
18
18
|
import { Tooltip } from '@rescui/tooltip';
|
|
19
19
|
import { InfoIcon } from '@rescui/icons';
|
|
20
20
|
|
|
@@ -29,7 +29,7 @@ import { InfoIcon } from '@rescui/icons';
|
|
|
29
29
|
|
|
30
30
|
#### Controlled
|
|
31
31
|
|
|
32
|
-
```
|
|
32
|
+
```jsx
|
|
33
33
|
import { Tooltip } from '@rescui/tooltip';
|
|
34
34
|
import { useState } from 'react';
|
|
35
35
|
import { Checkbox } from '@rescui/checkbox';
|
|
@@ -63,7 +63,7 @@ render(<MyTooltip />);
|
|
|
63
63
|
|
|
64
64
|
Use `renderBesideTrigger` property to allow tab-focusing on the content inside tooltip.
|
|
65
65
|
|
|
66
|
-
```
|
|
66
|
+
```jsx
|
|
67
67
|
import { Tooltip } from '@rescui/tooltip';
|
|
68
68
|
import { textCn } from '@rescui/typography';
|
|
69
69
|
|
|
@@ -87,7 +87,7 @@ import { textCn } from '@rescui/typography';
|
|
|
87
87
|
</Tooltip>;
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
```
|
|
90
|
+
```jsx
|
|
91
91
|
import { Tooltip } from '@rescui/tooltip';
|
|
92
92
|
import { textCn } from '@rescui/typography';
|
|
93
93
|
|
|
@@ -114,7 +114,7 @@ import { textCn } from '@rescui/typography';
|
|
|
114
114
|
|
|
115
115
|
#### Showing tooltip on click
|
|
116
116
|
|
|
117
|
-
```
|
|
117
|
+
```jsx
|
|
118
118
|
import { useState } from 'react';
|
|
119
119
|
import { Tooltip } from '@rescui/tooltip';
|
|
120
120
|
|
|
@@ -135,7 +135,7 @@ render(<MyTooltip />);
|
|
|
135
135
|
|
|
136
136
|
#### Tooltip with dark background
|
|
137
137
|
|
|
138
|
-
```
|
|
138
|
+
```jsx
|
|
139
139
|
import { Tooltip } from '@rescui/tooltip';
|
|
140
140
|
import { InfoIcon } from '@rescui/icons';
|
|
141
141
|
import { textCn } from '@rescui/typography';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/tooltip",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4-floating-ui-migration-ee8cf10db.9.sha-ee8cf10db",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -16,11 +16,9 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@rescui/use-resize-observer": "^0.5.0",
|
|
19
|
+
"@floating-ui/react-dom": "^2.1.9",
|
|
21
20
|
"classnames": "^2.2.6",
|
|
22
|
-
"react-compiler-runtime": "^1.0.0"
|
|
23
|
-
"react-popper": "^2.2.5"
|
|
21
|
+
"react-compiler-runtime": "^1.0.0"
|
|
24
22
|
},
|
|
25
23
|
"peerDependencies": {
|
|
26
24
|
"@rescui/ui-contexts": "^0.7.0 || ^0.8.0",
|
|
@@ -29,14 +27,14 @@
|
|
|
29
27
|
"react-dom": ">=17.0.0 <20"
|
|
30
28
|
},
|
|
31
29
|
"devDependencies": {
|
|
32
|
-
"@rescui/colors": "
|
|
33
|
-
"@rescui/icons": "
|
|
34
|
-
"@rescui/scripts": "
|
|
35
|
-
"@rescui/typography": "
|
|
30
|
+
"@rescui/colors": "0.3.7-floating-ui-migration-ee8cf10db.12.sha-ee8cf10db",
|
|
31
|
+
"@rescui/icons": "1.12.1-floating-ui-migration-ee8cf10db.9.sha-ee8cf10db",
|
|
32
|
+
"@rescui/scripts": "0.6.0",
|
|
33
|
+
"@rescui/typography": "0.30.3-floating-ui-migration-ee8cf10db.9.sha-ee8cf10db"
|
|
36
34
|
},
|
|
37
35
|
"scripts": {
|
|
38
36
|
"build": "rescui-scripts build"
|
|
39
37
|
},
|
|
40
38
|
"nx": {},
|
|
41
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "ee8cf10dbbe12af812fa565b2325a88196088d92"
|
|
42
40
|
}
|