@rescui/tooltip 0.14.2 → 0.14.3-floating-ui-migration-19bb1e9d6.6.sha-19bb1e9d6
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 +7 -6
- package/lib/tooltip.js +163 -172
- package/lib/tooltip.p.module.css.js +1 -1
- package/llm/components/tooltip.md +7 -7
- package/package.json +9 -11
package/lib/index.css
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
inherits:true;
|
|
4
4
|
initial-value:0;
|
|
5
5
|
}
|
|
6
|
-
.
|
|
6
|
+
._tooltip_krzhz_5{
|
|
7
7
|
position:relative;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.
|
|
10
|
+
._closing_krzhz_9{
|
|
11
11
|
pointer-events:none;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.
|
|
14
|
+
._content_krzhz_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_krzhz_13,
|
|
90
|
+
[data-popper-placement='bottom-end'] ._content_krzhz_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_krzhz_13,
|
|
95
|
+
[data-popper-placement='bottom-start'] ._content_krzhz_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_krzhz_13,
|
|
100
|
+
[data-popper-placement='right-end'] ._content_krzhz_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_krzhz_13,
|
|
105
|
+
[data-popper-placement='right-start'] ._content_krzhz_13{
|
|
106
106
|
margin-top:0;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
.
|
|
109
|
+
._initial_krzhz_57 ._content_krzhz_13{
|
|
110
110
|
transition:none;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
.
|
|
113
|
+
._closing_krzhz_9 ._content_krzhz_13{
|
|
114
114
|
transition-duration:200ms, 200ms;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
.
|
|
118
|
-
.
|
|
117
|
+
._initial_krzhz_57 ._content_krzhz_13,
|
|
118
|
+
._closing_krzhz_9 ._content_krzhz_13{
|
|
119
119
|
opacity:0;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
.
|
|
122
|
+
._outerThemeLight_krzhz_71 ._content_krzhz_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_krzhz_84 ._content_krzhz_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_krzhz_57[data-popper-placement^='top'] ._content_krzhz_13, ._closing_krzhz_9[data-popper-placement^='top'] ._content_krzhz_13{
|
|
147
147
|
transform:translate(0, 10px);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
.
|
|
150
|
+
._initial_krzhz_57[data-popper-placement^='right'] ._content_krzhz_13, ._closing_krzhz_9[data-popper-placement^='right'] ._content_krzhz_13{
|
|
151
151
|
transform:translate(-10px, 0);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
.
|
|
154
|
+
._initial_krzhz_57[data-popper-placement^='bottom'] ._content_krzhz_13, ._closing_krzhz_9[data-popper-placement^='bottom'] ._content_krzhz_13{
|
|
155
155
|
transform:translate(0, -10px);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
.
|
|
158
|
+
._initial_krzhz_57[data-popper-placement^='left'] ._content_krzhz_13, ._closing_krzhz_9[data-popper-placement^='left'] ._content_krzhz_13{
|
|
159
159
|
transform:translate(10px, 0);
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
.
|
|
163
|
-
.
|
|
162
|
+
._trigger_krzhz_116:focus-visible,
|
|
163
|
+
._trigger_krzhz_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,7 +48,7 @@ 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
54
|
fallbackPlacements?: Placement[];
|
package/lib/tooltip.js
CHANGED
|
@@ -4,19 +4,45 @@ 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
|
+
function mergeMiddleware(builtInMiddleware) {
|
|
27
|
+
let customMiddleware = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
28
|
+
const isBuiltIn = _ref => {
|
|
29
|
+
let {
|
|
30
|
+
name
|
|
31
|
+
} = _ref;
|
|
32
|
+
return builtInMiddleware.some(builtIn => builtIn.name === name);
|
|
33
|
+
};
|
|
34
|
+
return [...builtInMiddleware.map(builtIn => customMiddleware.find(_ref2 => {
|
|
35
|
+
let {
|
|
36
|
+
name
|
|
37
|
+
} = _ref2;
|
|
38
|
+
return name === builtIn.name;
|
|
39
|
+
}) ?? builtIn), ...customMiddleware.filter(custom => !isBuiltIn(custom))];
|
|
40
|
+
}
|
|
41
|
+
const Portal = _ref3 => {
|
|
16
42
|
let {
|
|
17
43
|
children,
|
|
18
44
|
target
|
|
19
|
-
} =
|
|
45
|
+
} = _ref3;
|
|
20
46
|
return target ? /*#__PURE__*/ReactDOM.createPortal(children, target) : null;
|
|
21
47
|
};
|
|
22
48
|
const TooltipPortal = t0 => {
|
|
@@ -63,7 +89,7 @@ const OUTER_THEME_STYLES = {
|
|
|
63
89
|
light: styles.outerThemeLight,
|
|
64
90
|
dark: styles.outerThemeDark
|
|
65
91
|
};
|
|
66
|
-
const TriggerRenderer = /*#__PURE__*/React.forwardRef((
|
|
92
|
+
const TriggerRenderer = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
67
93
|
let {
|
|
68
94
|
setTriggerRef,
|
|
69
95
|
targetComponent,
|
|
@@ -71,7 +97,7 @@ const TriggerRenderer = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
71
97
|
handleMouseEnterTarget,
|
|
72
98
|
handleMouseLeaveTarget,
|
|
73
99
|
children
|
|
74
|
-
} =
|
|
100
|
+
} = _ref4;
|
|
75
101
|
const eventListeners = !isControlled ? {
|
|
76
102
|
onMouseEnter: handleMouseEnterTarget,
|
|
77
103
|
onMouseLeave: handleMouseLeaveTarget,
|
|
@@ -118,14 +144,14 @@ const TriggerRenderer = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
118
144
|
TriggerRenderer.displayName = 'TriggerRenderer';
|
|
119
145
|
// eslint-disable-next-line complexity
|
|
120
146
|
const Tooltip = t0 => {
|
|
121
|
-
const $ = c(
|
|
147
|
+
const $ = c(54);
|
|
122
148
|
const {
|
|
123
149
|
children,
|
|
124
150
|
targetComponent: t1,
|
|
125
151
|
content,
|
|
126
152
|
className,
|
|
127
153
|
isVisible: isVisibleFromProps,
|
|
128
|
-
|
|
154
|
+
middleware,
|
|
129
155
|
placement: t2,
|
|
130
156
|
sparse: t3,
|
|
131
157
|
fallbackPlacements: t4,
|
|
@@ -135,15 +161,7 @@ const Tooltip = t0 => {
|
|
|
135
161
|
const targetComponent = t1 === undefined ? "span" : t1;
|
|
136
162
|
const placement = t2 === undefined ? "auto" : t2;
|
|
137
163
|
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;
|
|
164
|
+
const fallbackPlacements = t4 === undefined ? ["top", "bottom"] : t4;
|
|
147
165
|
const renderBesideTrigger = t5 === undefined ? false : t5;
|
|
148
166
|
const {
|
|
149
167
|
tooltipZIndex
|
|
@@ -159,34 +177,35 @@ const Tooltip = t0 => {
|
|
|
159
177
|
const isVisible = typeof triggerRef !== "undefined" || renderBesideTrigger ? requestedVisibility : false;
|
|
160
178
|
const ownerDocument = triggerRef?.ownerDocument;
|
|
161
179
|
const isOpen = isVisible || isTooltipHovered;
|
|
162
|
-
let
|
|
163
|
-
if ($[
|
|
164
|
-
|
|
165
|
-
$[
|
|
166
|
-
$[
|
|
180
|
+
let t6;
|
|
181
|
+
if ($[0] !== content) {
|
|
182
|
+
t6 = isNode(content);
|
|
183
|
+
$[0] = content;
|
|
184
|
+
$[1] = t6;
|
|
167
185
|
} else {
|
|
168
|
-
|
|
186
|
+
t6 = $[1];
|
|
169
187
|
}
|
|
170
|
-
const contentCanBeRendered =
|
|
188
|
+
const contentCanBeRendered = t6;
|
|
171
189
|
const portalTargetIsAvailable = renderBesideTrigger || Boolean(ownerDocument?.body);
|
|
172
190
|
const canRenderTooltip = contentCanBeRendered && portalTargetIsAvailable;
|
|
173
|
-
let
|
|
174
|
-
if ($[
|
|
175
|
-
|
|
191
|
+
let t7;
|
|
192
|
+
if ($[2] !== setIsVisibleState) {
|
|
193
|
+
t7 = () => {
|
|
176
194
|
if (hideTimeoutRef.current) {
|
|
177
195
|
clearTimeout(hideTimeoutRef.current);
|
|
178
196
|
hideTimeoutRef.current = null;
|
|
179
197
|
}
|
|
180
198
|
setIsVisibleState(true);
|
|
181
199
|
};
|
|
182
|
-
$[
|
|
200
|
+
$[2] = setIsVisibleState;
|
|
201
|
+
$[3] = t7;
|
|
183
202
|
} else {
|
|
184
|
-
|
|
203
|
+
t7 = $[3];
|
|
185
204
|
}
|
|
186
|
-
const handleMouseEnterTarget =
|
|
187
|
-
let
|
|
188
|
-
if ($[5] !==
|
|
189
|
-
|
|
205
|
+
const handleMouseEnterTarget = t7;
|
|
206
|
+
let t8;
|
|
207
|
+
if ($[4] !== disableHideDelay || $[5] !== setIsVisibleState) {
|
|
208
|
+
t8 = () => {
|
|
190
209
|
if (disableHideDelay) {
|
|
191
210
|
setIsVisibleState(false);
|
|
192
211
|
} else {
|
|
@@ -195,131 +214,95 @@ const Tooltip = t0 => {
|
|
|
195
214
|
}, HIDE_TIMEOUT);
|
|
196
215
|
}
|
|
197
216
|
};
|
|
198
|
-
$[
|
|
199
|
-
$[
|
|
217
|
+
$[4] = disableHideDelay;
|
|
218
|
+
$[5] = setIsVisibleState;
|
|
219
|
+
$[6] = t8;
|
|
200
220
|
} else {
|
|
201
|
-
|
|
221
|
+
t8 = $[6];
|
|
202
222
|
}
|
|
203
|
-
const handleMouseLeaveTarget =
|
|
204
|
-
let
|
|
223
|
+
const handleMouseLeaveTarget = t8;
|
|
224
|
+
let t9;
|
|
205
225
|
if ($[7] !== sparse) {
|
|
206
|
-
|
|
226
|
+
t9 = t10 => {
|
|
207
227
|
const {
|
|
208
228
|
placement: offsetPlacement
|
|
209
|
-
} =
|
|
229
|
+
} = t10;
|
|
210
230
|
if (offsetPlacement.includes("left") || offsetPlacement.includes("right")) {
|
|
211
|
-
return
|
|
231
|
+
return sparse ? 16 : 8;
|
|
212
232
|
} else {
|
|
213
|
-
return
|
|
233
|
+
return sparse ? 12 : 8;
|
|
214
234
|
}
|
|
215
235
|
};
|
|
216
236
|
$[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;
|
|
237
|
+
$[8] = t9;
|
|
232
238
|
} else {
|
|
233
|
-
|
|
239
|
+
t9 = $[8];
|
|
234
240
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
241
|
+
const calcOffset = t9;
|
|
242
|
+
let t10;
|
|
243
|
+
if ($[9] !== popperRef || $[10] !== triggerRef) {
|
|
244
|
+
t10 = {
|
|
245
|
+
reference: triggerRef,
|
|
246
|
+
floating: popperRef
|
|
242
247
|
};
|
|
243
|
-
$[
|
|
244
|
-
$[
|
|
245
|
-
|
|
246
|
-
t12 = $[12];
|
|
247
|
-
}
|
|
248
|
-
let t13;
|
|
249
|
-
if ($[13] !== modifiers) {
|
|
250
|
-
t13 = modifiers || [];
|
|
251
|
-
$[13] = modifiers;
|
|
252
|
-
$[14] = t13;
|
|
248
|
+
$[9] = popperRef;
|
|
249
|
+
$[10] = triggerRef;
|
|
250
|
+
$[11] = t10;
|
|
253
251
|
} else {
|
|
254
|
-
|
|
252
|
+
t10 = $[11];
|
|
255
253
|
}
|
|
254
|
+
const t11 = isAutoPlacement(placement) ? undefined : placement;
|
|
255
|
+
const t12 = mergeMiddleware([offset(calcOffset, [sparse]), isAutoPlacement(placement) ? autoPlacement({
|
|
256
|
+
allowedPlacements: AUTO_PLACEMENTS[placement]
|
|
257
|
+
}) : flip({
|
|
258
|
+
fallbackPlacements,
|
|
259
|
+
fallbackStrategy: "initialPlacement"
|
|
260
|
+
}), shift({
|
|
261
|
+
limiter: limitShift()
|
|
262
|
+
})], middleware);
|
|
263
|
+
const t13 = popperRef !== null;
|
|
256
264
|
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
|
|
265
|
+
if ($[12] !== t10 || $[13] !== t11 || $[14] !== t12 || $[15] !== t13) {
|
|
266
|
+
t14 = {
|
|
267
|
+
elements: t10,
|
|
268
|
+
placement: t11,
|
|
269
|
+
middleware: t12,
|
|
270
|
+
whileElementsMounted: autoUpdate,
|
|
271
|
+
open: t13
|
|
271
272
|
};
|
|
272
|
-
$[
|
|
273
|
-
$[
|
|
274
|
-
$[
|
|
273
|
+
$[12] = t10;
|
|
274
|
+
$[13] = t11;
|
|
275
|
+
$[14] = t12;
|
|
276
|
+
$[15] = t13;
|
|
277
|
+
$[16] = t14;
|
|
275
278
|
} else {
|
|
276
|
-
|
|
279
|
+
t14 = $[16];
|
|
277
280
|
}
|
|
278
281
|
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 = {
|
|
282
|
+
floatingStyles,
|
|
283
|
+
placement: floatingPlacement,
|
|
284
|
+
isPositioned
|
|
285
|
+
} = useFloating(t14);
|
|
286
|
+
const resolvedPlacement = isPositioned ? floatingPlacement : null;
|
|
287
|
+
let t15;
|
|
288
|
+
if ($[17] !== canRenderTooltip || $[18] !== contentEl || $[19] !== isOpen || $[20] !== popperRef || $[21] !== resolvedPlacement) {
|
|
289
|
+
t15 = {
|
|
307
290
|
isOpen,
|
|
308
291
|
canRender: canRenderTooltip,
|
|
309
292
|
contentEl,
|
|
310
293
|
popperElement: popperRef,
|
|
311
294
|
resolvedPlacement
|
|
312
295
|
};
|
|
313
|
-
$[
|
|
314
|
-
$[
|
|
315
|
-
$[
|
|
316
|
-
$[
|
|
317
|
-
$[
|
|
318
|
-
$[
|
|
296
|
+
$[17] = canRenderTooltip;
|
|
297
|
+
$[18] = contentEl;
|
|
298
|
+
$[19] = isOpen;
|
|
299
|
+
$[20] = popperRef;
|
|
300
|
+
$[21] = resolvedPlacement;
|
|
301
|
+
$[22] = t15;
|
|
319
302
|
} else {
|
|
320
|
-
|
|
303
|
+
t15 = $[22];
|
|
321
304
|
}
|
|
322
|
-
const tooltipState = useTooltipState(
|
|
305
|
+
const tooltipState = useTooltipState(t15);
|
|
323
306
|
const isInitial = tooltipState === TOOLTIP_STATES.OPENING_PREPARE;
|
|
324
307
|
const isClosing = tooltipState === TOOLTIP_STATES.CLOSING;
|
|
325
308
|
const isExists = tooltipState !== TOOLTIP_STATES.CLOSE;
|
|
@@ -333,33 +316,35 @@ const Tooltip = t0 => {
|
|
|
333
316
|
noProvider
|
|
334
317
|
} = useContext(ThemeContext);
|
|
335
318
|
const theme = noProvider ? themeFromCss : themeFromContext;
|
|
336
|
-
let
|
|
337
|
-
if ($[
|
|
338
|
-
|
|
319
|
+
let t16;
|
|
320
|
+
if ($[23] !== children || $[24] !== handleMouseEnterTarget || $[25] !== handleMouseLeaveTarget || $[26] !== isControlled || $[27] !== setTriggerRef || $[28] !== targetComponent) {
|
|
321
|
+
t16 = /*#__PURE__*/React.createElement(TriggerRenderer, {
|
|
339
322
|
setTriggerRef: setTriggerRef,
|
|
340
323
|
targetComponent: targetComponent,
|
|
341
324
|
isControlled: isControlled,
|
|
342
325
|
handleMouseEnterTarget: handleMouseEnterTarget,
|
|
343
326
|
handleMouseLeaveTarget: handleMouseLeaveTarget
|
|
344
327
|
}, children);
|
|
345
|
-
$[
|
|
346
|
-
$[
|
|
347
|
-
$[
|
|
348
|
-
$[
|
|
349
|
-
$[
|
|
328
|
+
$[23] = children;
|
|
329
|
+
$[24] = handleMouseEnterTarget;
|
|
330
|
+
$[25] = handleMouseLeaveTarget;
|
|
331
|
+
$[26] = isControlled;
|
|
332
|
+
$[27] = setTriggerRef;
|
|
333
|
+
$[28] = targetComponent;
|
|
334
|
+
$[29] = t16;
|
|
350
335
|
} else {
|
|
351
|
-
|
|
336
|
+
t16 = $[29];
|
|
352
337
|
}
|
|
353
|
-
let
|
|
354
|
-
if ($[
|
|
355
|
-
|
|
338
|
+
let t17;
|
|
339
|
+
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) {
|
|
340
|
+
t17 = tooltipShouldBeRendered && /*#__PURE__*/React.createElement(TooltipPortal, {
|
|
356
341
|
renderBesideTrigger: renderBesideTrigger,
|
|
357
342
|
target: ownerDocument?.body
|
|
358
|
-
}, /*#__PURE__*/React.createElement("span",
|
|
343
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
359
344
|
className: cn(styles.tooltip, isInitial && styles.initial, isClosing && styles.closing, OUTER_THEME_STYLES[theme], className),
|
|
360
345
|
ref: setPopperRef,
|
|
361
346
|
style: {
|
|
362
|
-
...
|
|
347
|
+
...floatingStyles,
|
|
363
348
|
...primaryColors,
|
|
364
349
|
zIndex: tooltipZIndex
|
|
365
350
|
},
|
|
@@ -375,8 +360,9 @@ const Tooltip = t0 => {
|
|
|
375
360
|
setIsTooltipHovered(false);
|
|
376
361
|
},
|
|
377
362
|
"data-placement": placement,
|
|
363
|
+
"data-popper-placement": resolvedPlacement ?? undefined,
|
|
378
364
|
"data-test": "tooltip"
|
|
379
|
-
},
|
|
365
|
+
}, /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
380
366
|
theme: "dark",
|
|
381
367
|
ignoreThemeValueForCSSApi: noProvider
|
|
382
368
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -385,35 +371,40 @@ const Tooltip = t0 => {
|
|
|
385
371
|
onFocus: handleMouseEnterTarget,
|
|
386
372
|
ref: setContentEl
|
|
387
373
|
}, content))));
|
|
388
|
-
$[
|
|
389
|
-
$[
|
|
390
|
-
$[
|
|
391
|
-
$[
|
|
392
|
-
$[
|
|
393
|
-
$[
|
|
394
|
-
$[
|
|
395
|
-
$[
|
|
396
|
-
$[
|
|
397
|
-
$[
|
|
398
|
-
$[
|
|
399
|
-
$[
|
|
400
|
-
$[
|
|
401
|
-
$[
|
|
402
|
-
$[
|
|
403
|
-
$[
|
|
374
|
+
$[30] = className;
|
|
375
|
+
$[31] = content;
|
|
376
|
+
$[32] = floatingStyles;
|
|
377
|
+
$[33] = handleMouseEnterTarget;
|
|
378
|
+
$[34] = handleMouseLeaveTarget;
|
|
379
|
+
$[35] = isClosing;
|
|
380
|
+
$[36] = isInitial;
|
|
381
|
+
$[37] = noProvider;
|
|
382
|
+
$[38] = ownerDocument?.body;
|
|
383
|
+
$[39] = placement;
|
|
384
|
+
$[40] = primaryColors;
|
|
385
|
+
$[41] = renderBesideTrigger;
|
|
386
|
+
$[42] = resolvedPlacement;
|
|
387
|
+
$[43] = setContentEl;
|
|
388
|
+
$[44] = setIsTooltipHovered;
|
|
389
|
+
$[45] = setIsVisibleState;
|
|
390
|
+
$[46] = setPopperRef;
|
|
391
|
+
$[47] = theme;
|
|
392
|
+
$[48] = tooltipShouldBeRendered;
|
|
393
|
+
$[49] = tooltipZIndex;
|
|
394
|
+
$[50] = t17;
|
|
404
395
|
} else {
|
|
405
|
-
|
|
396
|
+
t17 = $[50];
|
|
406
397
|
}
|
|
407
|
-
let
|
|
408
|
-
if ($[
|
|
409
|
-
|
|
410
|
-
$[
|
|
411
|
-
$[
|
|
412
|
-
$[
|
|
398
|
+
let t18;
|
|
399
|
+
if ($[51] !== t16 || $[52] !== t17) {
|
|
400
|
+
t18 = /*#__PURE__*/React.createElement(React.Fragment, null, t16, t17);
|
|
401
|
+
$[51] = t16;
|
|
402
|
+
$[52] = t17;
|
|
403
|
+
$[53] = t18;
|
|
413
404
|
} else {
|
|
414
|
-
|
|
405
|
+
t18 = $[53];
|
|
415
406
|
}
|
|
416
|
-
return
|
|
407
|
+
return t18;
|
|
417
408
|
};
|
|
418
409
|
Tooltip.propTypes = {
|
|
419
410
|
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
|
|
@@ -421,9 +412,9 @@ Tooltip.propTypes = {
|
|
|
421
412
|
content: PropTypes.node,
|
|
422
413
|
className: PropTypes.string,
|
|
423
414
|
isVisible: PropTypes.bool,
|
|
424
|
-
|
|
415
|
+
middleware: PropTypes.array,
|
|
425
416
|
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
|
-
fallbackPlacements: PropTypes.arrayOf(PropTypes.oneOf(['
|
|
417
|
+
fallbackPlacements: PropTypes.arrayOf(PropTypes.oneOf(['top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'])),
|
|
427
418
|
sparse: PropTypes.bool,
|
|
428
419
|
disableHideDelay: PropTypes.bool,
|
|
429
420
|
renderBesideTrigger: PropTypes.bool
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var styles = {"tooltip":"
|
|
1
|
+
var styles = {"tooltip":"_tooltip_krzhz_5","closing":"_closing_krzhz_9","content":"_content_krzhz_13","initial":"_initial_krzhz_57","outerThemeLight":"_outerThemeLight_krzhz_71","outerThemeDark":"_outerThemeDark_krzhz_84","trigger":"_trigger_krzhz_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.3-floating-ui-migration-19bb1e9d6.6.sha-19bb1e9d6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -16,27 +16,25 @@
|
|
|
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
|
-
"@rescui/ui-contexts": "^0.7.0",
|
|
24
|
+
"@rescui/ui-contexts": "^0.7.0 || ^0.8.0",
|
|
27
25
|
"prop-types": "^15",
|
|
28
26
|
"react": ">=17.0.0 <20",
|
|
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-19bb1e9d6.6.sha-19bb1e9d6",
|
|
31
|
+
"@rescui/icons": "1.11.3-floating-ui-migration-19bb1e9d6.6.sha-19bb1e9d6",
|
|
32
|
+
"@rescui/scripts": "0.6.0",
|
|
33
|
+
"@rescui/typography": "0.30.2-floating-ui-migration-19bb1e9d6.6.sha-19bb1e9d6"
|
|
36
34
|
},
|
|
37
35
|
"scripts": {
|
|
38
36
|
"build": "rescui-scripts build"
|
|
39
37
|
},
|
|
40
38
|
"nx": {},
|
|
41
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "19bb1e9d6209ed46222713346d964bc6af332c37"
|
|
42
40
|
}
|