@rescui/tooltip 0.12.3-RUI-308-Fix-select-issues-405b9fa40.12 → 0.13.1
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.js +319 -130
- package/lib/tooltip.p.module.css.js +7 -7
- package/lib/use-extract-css-values.d.ts +5 -0
- package/lib/use-extract-css-values.js +81 -0
- package/lib/use-tooltip-state.js +142 -78
- package/package.json +11 -10
- package/lib/css-vars-utils.d.ts +0 -3
- package/lib/css-vars-utils.js +0 -20
package/lib/index.css
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
inherits:true;
|
|
4
4
|
initial-value:0;
|
|
5
5
|
}
|
|
6
|
-
.
|
|
6
|
+
._tooltip_m9qz43_5{
|
|
7
7
|
position:relative;
|
|
8
8
|
}
|
|
9
|
-
.
|
|
9
|
+
._closing_m9qz43_9{
|
|
10
10
|
pointer-events:none;
|
|
11
11
|
}
|
|
12
|
-
.
|
|
12
|
+
._content_m9qz43_13{
|
|
13
13
|
--rs-theme-dark:1;
|
|
14
14
|
--_rs-tooltip-border-width:1px;
|
|
15
15
|
|
|
@@ -83,33 +83,33 @@
|
|
|
83
83
|
transition:opacity 300ms var(--rs-transition-function, ease), transform 300ms var(--rs-transition-function, ease);
|
|
84
84
|
transform:translate(0, 0);
|
|
85
85
|
}
|
|
86
|
-
[data-popper-placement='top-end'] .
|
|
87
|
-
[data-popper-placement='bottom-end'] .
|
|
86
|
+
[data-popper-placement='top-end'] ._content_m9qz43_13,
|
|
87
|
+
[data-popper-placement='bottom-end'] ._content_m9qz43_13{
|
|
88
88
|
margin-right:0;
|
|
89
89
|
}
|
|
90
|
-
[data-popper-placement='top-start'] .
|
|
91
|
-
[data-popper-placement='bottom-start'] .
|
|
90
|
+
[data-popper-placement='top-start'] ._content_m9qz43_13,
|
|
91
|
+
[data-popper-placement='bottom-start'] ._content_m9qz43_13{
|
|
92
92
|
margin-left:0;
|
|
93
93
|
}
|
|
94
|
-
[data-popper-placement='left-end'] .
|
|
95
|
-
[data-popper-placement='right-end'] .
|
|
94
|
+
[data-popper-placement='left-end'] ._content_m9qz43_13,
|
|
95
|
+
[data-popper-placement='right-end'] ._content_m9qz43_13{
|
|
96
96
|
margin-bottom:0;
|
|
97
97
|
}
|
|
98
|
-
[data-popper-placement='left-start'] .
|
|
99
|
-
[data-popper-placement='right-start'] .
|
|
98
|
+
[data-popper-placement='left-start'] ._content_m9qz43_13,
|
|
99
|
+
[data-popper-placement='right-start'] ._content_m9qz43_13{
|
|
100
100
|
margin-top:0;
|
|
101
101
|
}
|
|
102
|
-
.
|
|
102
|
+
._initial_m9qz43_57 ._content_m9qz43_13{
|
|
103
103
|
transition:none;
|
|
104
104
|
}
|
|
105
|
-
.
|
|
105
|
+
._closing_m9qz43_9 ._content_m9qz43_13{
|
|
106
106
|
transition-duration:200ms, 200ms;
|
|
107
107
|
}
|
|
108
|
-
.
|
|
109
|
-
.
|
|
108
|
+
._initial_m9qz43_57 ._content_m9qz43_13,
|
|
109
|
+
._closing_m9qz43_9 ._content_m9qz43_13{
|
|
110
110
|
opacity:0;
|
|
111
111
|
}
|
|
112
|
-
.
|
|
112
|
+
._outerThemeLight_m9qz43_71 ._content_m9qz43_13{
|
|
113
113
|
--rs-color-primary-dark-theme:var(--rs-color-primary-light-theme);
|
|
114
114
|
--rs-color-primary-dim-dark-theme:var(--rs-color-primary-dim-light-theme);
|
|
115
115
|
--rs-color-primary-fog-dark-theme:var(--rs-color-primary-fog-light-theme);
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
--rs-color-primary-t-fog-light-theme
|
|
121
121
|
);
|
|
122
122
|
}
|
|
123
|
-
.
|
|
123
|
+
._outerThemeDark_m9qz43_84 ._content_m9qz43_13{
|
|
124
124
|
--rs-color-primary-light-theme:var(--rs-color-primary-dark-theme);
|
|
125
125
|
--rs-color-primary-dim-light-theme:var(--rs-color-primary-dim-dark-theme);
|
|
126
126
|
--rs-color-primary-fog-light-theme:var(--rs-color-primary-fog-dark-theme);
|
|
@@ -131,20 +131,20 @@
|
|
|
131
131
|
--rs-color-primary-t-fog-dark-theme
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
|
-
.
|
|
134
|
+
._initial_m9qz43_57[data-popper-placement^='top'] ._content_m9qz43_13, ._closing_m9qz43_9[data-popper-placement^='top'] ._content_m9qz43_13{
|
|
135
135
|
transform:translate(0, 10px);
|
|
136
136
|
}
|
|
137
|
-
.
|
|
137
|
+
._initial_m9qz43_57[data-popper-placement^='right'] ._content_m9qz43_13, ._closing_m9qz43_9[data-popper-placement^='right'] ._content_m9qz43_13{
|
|
138
138
|
transform:translate(-10px, 0);
|
|
139
139
|
}
|
|
140
|
-
.
|
|
140
|
+
._initial_m9qz43_57[data-popper-placement^='bottom'] ._content_m9qz43_13, ._closing_m9qz43_9[data-popper-placement^='bottom'] ._content_m9qz43_13{
|
|
141
141
|
transform:translate(0, -10px);
|
|
142
142
|
}
|
|
143
|
-
.
|
|
143
|
+
._initial_m9qz43_57[data-popper-placement^='left'] ._content_m9qz43_13, ._closing_m9qz43_9[data-popper-placement^='left'] ._content_m9qz43_13{
|
|
144
144
|
transform:translate(10px, 0);
|
|
145
145
|
}
|
|
146
|
-
.
|
|
147
|
-
.
|
|
146
|
+
._trigger_m9qz43_116:focus-visible,
|
|
147
|
+
._trigger_m9qz43_116:focus[data-focus-method='key']{
|
|
148
148
|
outline:none;
|
|
149
149
|
|
|
150
150
|
box-shadow:var(--rs-color-primary-t-dim-light-theme) 0 0 0 4px;
|
package/lib/tooltip.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import _extends from '@babel/runtime-corejs3/helpers/esm/extends';
|
|
3
|
+
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
4
|
+
import { c } from 'react-compiler-runtime';
|
|
5
|
+
import React, { cloneElement, createElement, useState, useRef, useContext, isValidElement } from 'react';
|
|
4
6
|
import cn from 'classnames';
|
|
5
7
|
import PropTypes from 'prop-types';
|
|
6
8
|
import ReactDOM from 'react-dom';
|
|
@@ -9,7 +11,7 @@ import { useLayeringContext, ThemeContext, ThemeProvider } from '@rescui/ui-cont
|
|
|
9
11
|
import { useResizeObserver } from '@rescui/use-resize-observer';
|
|
10
12
|
import styles from './tooltip.p.module.css.js';
|
|
11
13
|
import { useTooltipState, TOOLTIP_STATES } from './use-tooltip-state.js';
|
|
12
|
-
import {
|
|
14
|
+
import { useExtractCssValues } from './use-extract-css-values.js';
|
|
13
15
|
const HIDE_TIMEOUT = 500;
|
|
14
16
|
|
|
15
17
|
const Portal = _ref => {
|
|
@@ -20,20 +22,32 @@ const Portal = _ref => {
|
|
|
20
22
|
return target ? /*#__PURE__*/ReactDOM.createPortal(children, target) : null;
|
|
21
23
|
};
|
|
22
24
|
|
|
23
|
-
const TooltipPortal =
|
|
24
|
-
|
|
25
|
+
const TooltipPortal = t0 => {
|
|
26
|
+
const $ = c(3);
|
|
27
|
+
const {
|
|
25
28
|
children,
|
|
26
29
|
renderBesideTrigger,
|
|
27
30
|
target
|
|
28
|
-
} =
|
|
31
|
+
} = t0;
|
|
29
32
|
|
|
30
33
|
if (renderBesideTrigger) {
|
|
31
34
|
return children;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
let t1;
|
|
38
|
+
|
|
39
|
+
if ($[0] !== children || $[1] !== target) {
|
|
40
|
+
t1 = /*#__PURE__*/React.createElement(Portal, {
|
|
41
|
+
target: target
|
|
42
|
+
}, children);
|
|
43
|
+
$[0] = children;
|
|
44
|
+
$[1] = target;
|
|
45
|
+
$[2] = t1;
|
|
46
|
+
} else {
|
|
47
|
+
t1 = $[2];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return t1;
|
|
37
51
|
};
|
|
38
52
|
|
|
39
53
|
const isNode = maybeNode => {
|
|
@@ -62,7 +76,7 @@ const OUTER_THEME_STYLES = {
|
|
|
62
76
|
light: styles.outerThemeLight,
|
|
63
77
|
dark: styles.outerThemeDark
|
|
64
78
|
};
|
|
65
|
-
const TriggerRenderer = /*#__PURE__*/React.forwardRef((
|
|
79
|
+
const TriggerRenderer = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
66
80
|
let {
|
|
67
81
|
setTriggerRef,
|
|
68
82
|
targetComponent,
|
|
@@ -70,7 +84,7 @@ const TriggerRenderer = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
70
84
|
handleMouseEnterTarget,
|
|
71
85
|
handleMouseLeaveTarget,
|
|
72
86
|
children
|
|
73
|
-
} =
|
|
87
|
+
} = _ref2;
|
|
74
88
|
const eventListeners = !isControlled ? {
|
|
75
89
|
onMouseEnter: handleMouseEnterTarget,
|
|
76
90
|
onMouseLeave: handleMouseLeaveTarget,
|
|
@@ -120,20 +134,36 @@ const TriggerRenderer = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
120
134
|
});
|
|
121
135
|
TriggerRenderer.displayName = 'TriggerRenderer'; // eslint-disable-next-line complexity
|
|
122
136
|
|
|
123
|
-
const Tooltip =
|
|
124
|
-
|
|
137
|
+
const Tooltip = t0 => {
|
|
138
|
+
const $ = c(55);
|
|
139
|
+
const {
|
|
125
140
|
children,
|
|
126
|
-
targetComponent
|
|
141
|
+
targetComponent: t1,
|
|
127
142
|
content,
|
|
128
143
|
className,
|
|
129
144
|
isVisible: isVisibleFromProps,
|
|
130
145
|
modifiers,
|
|
131
|
-
placement
|
|
132
|
-
sparse
|
|
133
|
-
fallbackPlacements
|
|
146
|
+
placement: t2,
|
|
147
|
+
sparse: t3,
|
|
148
|
+
fallbackPlacements: t4,
|
|
134
149
|
disableHideDelay,
|
|
135
|
-
renderBesideTrigger
|
|
136
|
-
} =
|
|
150
|
+
renderBesideTrigger: t5
|
|
151
|
+
} = t0;
|
|
152
|
+
const targetComponent = t1 === undefined ? "span" : t1;
|
|
153
|
+
const placement = t2 === undefined ? "auto" : t2;
|
|
154
|
+
const sparse = t3 === undefined ? true : t3;
|
|
155
|
+
let t6;
|
|
156
|
+
|
|
157
|
+
if ($[0] !== t4) {
|
|
158
|
+
t6 = t4 === undefined ? ["top", "bottom"] : t4;
|
|
159
|
+
$[0] = t4;
|
|
160
|
+
$[1] = t6;
|
|
161
|
+
} else {
|
|
162
|
+
t6 = $[1];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const fallbackPlacements = t6;
|
|
166
|
+
const renderBesideTrigger = t5 === undefined ? false : t5;
|
|
137
167
|
const {
|
|
138
168
|
tooltipZIndex
|
|
139
169
|
} = useLayeringContext();
|
|
@@ -143,143 +173,302 @@ const Tooltip = _ref4 => {
|
|
|
143
173
|
const [isTooltipHovered, setIsTooltipHovered] = useState(false);
|
|
144
174
|
const [contentEl, setContentEl] = useState(null);
|
|
145
175
|
const hideTimeoutRef = useRef(null);
|
|
146
|
-
const isControlled = typeof isVisibleFromProps !==
|
|
147
|
-
const requestedVisibility = isControlled ? isVisibleFromProps : isVisibleState;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const isVisible = typeof triggerRef !== 'undefined' || renderBesideTrigger ? requestedVisibility : false;
|
|
176
|
+
const isControlled = typeof isVisibleFromProps !== "undefined";
|
|
177
|
+
const requestedVisibility = isControlled ? isVisibleFromProps : isVisibleState;
|
|
178
|
+
const isVisible = typeof triggerRef !== "undefined" || renderBesideTrigger ? requestedVisibility : false;
|
|
151
179
|
const ownerDocument = triggerRef?.ownerDocument;
|
|
152
180
|
const isOpen = isVisible || isTooltipHovered;
|
|
153
|
-
|
|
181
|
+
let t7;
|
|
182
|
+
|
|
183
|
+
if ($[2] !== content) {
|
|
184
|
+
t7 = isNode(content);
|
|
185
|
+
$[2] = content;
|
|
186
|
+
$[3] = t7;
|
|
187
|
+
} else {
|
|
188
|
+
t7 = $[3];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const contentCanBeRendered = t7;
|
|
154
192
|
const portalTargetIsAvailable = renderBesideTrigger || Boolean(ownerDocument?.body);
|
|
155
193
|
const canRenderTooltip = contentCanBeRendered && portalTargetIsAvailable;
|
|
194
|
+
let t8;
|
|
156
195
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
196
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
197
|
+
t8 = () => {
|
|
198
|
+
if (hideTimeoutRef.current) {
|
|
199
|
+
clearTimeout(hideTimeoutRef.current);
|
|
200
|
+
hideTimeoutRef.current = null;
|
|
201
|
+
}
|
|
162
202
|
|
|
163
|
-
|
|
164
|
-
|
|
203
|
+
setIsVisibleState(true);
|
|
204
|
+
};
|
|
165
205
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
206
|
+
$[4] = t8;
|
|
207
|
+
} else {
|
|
208
|
+
t8 = $[4];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const handleMouseEnterTarget = t8;
|
|
212
|
+
let t9;
|
|
213
|
+
|
|
214
|
+
if ($[5] !== disableHideDelay) {
|
|
215
|
+
t9 = () => {
|
|
216
|
+
if (disableHideDelay) {
|
|
171
217
|
setIsVisibleState(false);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
218
|
+
} else {
|
|
219
|
+
hideTimeoutRef.current = setTimeout(() => {
|
|
220
|
+
setIsVisibleState(false);
|
|
221
|
+
}, HIDE_TIMEOUT);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
175
224
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
225
|
+
$[5] = disableHideDelay;
|
|
226
|
+
$[6] = t9;
|
|
227
|
+
} else {
|
|
228
|
+
t9 = $[6];
|
|
229
|
+
}
|
|
180
230
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
231
|
+
const handleMouseLeaveTarget = t9;
|
|
232
|
+
let t10;
|
|
233
|
+
|
|
234
|
+
if ($[7] !== sparse) {
|
|
235
|
+
t10 = t11 => {
|
|
236
|
+
const {
|
|
237
|
+
placement: offsetPlacement
|
|
238
|
+
} = t11;
|
|
239
|
+
|
|
240
|
+
if (_includesInstanceProperty(offsetPlacement).call(offsetPlacement, "left") || _includesInstanceProperty(offsetPlacement).call(offsetPlacement, "right")) {
|
|
241
|
+
return [0, sparse ? 16 : 8];
|
|
242
|
+
} else {
|
|
243
|
+
return [0, sparse ? 12 : 8];
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
$[7] = sparse;
|
|
248
|
+
$[8] = t10;
|
|
249
|
+
} else {
|
|
250
|
+
t10 = $[8];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const calcOffset = t10;
|
|
254
|
+
let t11;
|
|
255
|
+
|
|
256
|
+
if ($[9] !== fallbackPlacements) {
|
|
257
|
+
t11 = {
|
|
258
|
+
name: "flip",
|
|
195
259
|
options: {
|
|
196
260
|
fallbackPlacements
|
|
197
261
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
262
|
+
};
|
|
263
|
+
$[9] = fallbackPlacements;
|
|
264
|
+
$[10] = t11;
|
|
265
|
+
} else {
|
|
266
|
+
t11 = $[10];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
let t12;
|
|
270
|
+
|
|
271
|
+
if ($[11] !== calcOffset) {
|
|
272
|
+
t12 = {
|
|
273
|
+
name: "offset",
|
|
200
274
|
options: {
|
|
201
275
|
offset: calcOffset
|
|
202
276
|
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
277
|
+
};
|
|
278
|
+
$[11] = calcOffset;
|
|
279
|
+
$[12] = t12;
|
|
280
|
+
} else {
|
|
281
|
+
t12 = $[12];
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
let t13;
|
|
285
|
+
|
|
286
|
+
if ($[13] !== modifiers) {
|
|
287
|
+
t13 = modifiers || [];
|
|
288
|
+
$[13] = modifiers;
|
|
289
|
+
$[14] = t13;
|
|
290
|
+
} else {
|
|
291
|
+
t13 = $[14];
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
let t14;
|
|
295
|
+
|
|
296
|
+
if ($[15] !== t11 || $[16] !== t12 || $[17] !== t13) {
|
|
297
|
+
t14 = [t11, t12, ...t13];
|
|
298
|
+
$[15] = t11;
|
|
299
|
+
$[16] = t12;
|
|
300
|
+
$[17] = t13;
|
|
301
|
+
$[18] = t14;
|
|
302
|
+
} else {
|
|
303
|
+
t14 = $[18];
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
let t15;
|
|
307
|
+
|
|
308
|
+
if ($[19] !== placement || $[20] !== t14) {
|
|
309
|
+
t15 = {
|
|
310
|
+
placement,
|
|
311
|
+
modifiers: t14
|
|
312
|
+
};
|
|
313
|
+
$[19] = placement;
|
|
314
|
+
$[20] = t14;
|
|
315
|
+
$[21] = t15;
|
|
316
|
+
} else {
|
|
317
|
+
t15 = $[21];
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const {
|
|
321
|
+
styles: popperStyles,
|
|
322
|
+
attributes,
|
|
323
|
+
update
|
|
324
|
+
} = usePopper(triggerRef ?? null, popperRef, t15);
|
|
325
|
+
let t16;
|
|
326
|
+
|
|
327
|
+
if ($[22] !== update) {
|
|
328
|
+
t16 = () => {
|
|
329
|
+
update?.();
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
$[22] = update;
|
|
333
|
+
$[23] = t16;
|
|
334
|
+
} else {
|
|
335
|
+
t16 = $[23];
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
let t17;
|
|
339
|
+
|
|
340
|
+
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
341
|
+
t17 = {
|
|
342
|
+
ignoreFirstCall: true
|
|
343
|
+
};
|
|
344
|
+
$[24] = t17;
|
|
345
|
+
} else {
|
|
346
|
+
t17 = $[24];
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
useResizeObserver(contentEl, t16, t17);
|
|
350
|
+
const resolvedPlacement = attributes.popper?.["data-popper-placement"] ?? null;
|
|
351
|
+
let t18;
|
|
352
|
+
|
|
353
|
+
if ($[25] !== canRenderTooltip || $[26] !== contentEl || $[27] !== isOpen || $[28] !== popperRef || $[29] !== resolvedPlacement) {
|
|
354
|
+
t18 = {
|
|
355
|
+
isOpen,
|
|
356
|
+
canRender: canRenderTooltip,
|
|
357
|
+
contentEl,
|
|
358
|
+
popperElement: popperRef,
|
|
359
|
+
resolvedPlacement
|
|
360
|
+
};
|
|
361
|
+
$[25] = canRenderTooltip;
|
|
362
|
+
$[26] = contentEl;
|
|
363
|
+
$[27] = isOpen;
|
|
364
|
+
$[28] = popperRef;
|
|
365
|
+
$[29] = resolvedPlacement;
|
|
366
|
+
$[30] = t18;
|
|
367
|
+
} else {
|
|
368
|
+
t18 = $[30];
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const tooltipState = useTooltipState(t18);
|
|
218
372
|
const isInitial = tooltipState === TOOLTIP_STATES.OPENING_PREPARE;
|
|
219
373
|
const isClosing = tooltipState === TOOLTIP_STATES.CLOSING;
|
|
220
374
|
const isExists = tooltipState !== TOOLTIP_STATES.CLOSE;
|
|
221
375
|
const tooltipShouldBeRendered = isExists && canRenderTooltip;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
// In theory this part of the code might cause issues with SSR.
|
|
227
|
-
// But in this specific context, because of the nature of the state-ref "triggerRef",
|
|
228
|
-
// we are sure that the tooltip wouldn't be rendered on the first client render.
|
|
229
|
-
// Therefore, the first render on the client will be the same as on the server.
|
|
230
|
-
const triggerStyles = ownerDocument?.defaultView?.getComputedStyle(triggerRef);
|
|
231
|
-
|
|
232
|
-
if (triggerStyles) {
|
|
233
|
-
themeFromCss = extractThemeFromCss(triggerStyles);
|
|
234
|
-
primaryColors = extractPrimaryColors(triggerStyles);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
376
|
+
const {
|
|
377
|
+
primaryColors,
|
|
378
|
+
themeFromCss
|
|
379
|
+
} = useExtractCssValues(triggerRef, tooltipShouldBeRendered, ownerDocument?.defaultView);
|
|
238
380
|
const {
|
|
239
381
|
theme: themeFromContext,
|
|
240
382
|
noProvider
|
|
241
383
|
} = useContext(ThemeContext);
|
|
242
384
|
const theme = noProvider ? themeFromCss : themeFromContext;
|
|
243
|
-
|
|
244
|
-
setTriggerRef: setTriggerRef,
|
|
245
|
-
targetComponent: targetComponent,
|
|
246
|
-
isControlled: isControlled,
|
|
247
|
-
handleMouseEnterTarget: handleMouseEnterTarget,
|
|
248
|
-
handleMouseLeaveTarget: handleMouseLeaveTarget
|
|
249
|
-
}, children), tooltipShouldBeRendered && /*#__PURE__*/React.createElement(TooltipPortal, {
|
|
250
|
-
renderBesideTrigger: renderBesideTrigger,
|
|
251
|
-
target: ownerDocument?.body
|
|
252
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
253
|
-
className: cn(styles.tooltip, isInitial && styles.initial, isClosing && styles.closing, OUTER_THEME_STYLES[theme], className),
|
|
254
|
-
ref: setPopperRef,
|
|
255
|
-
style: { ...popperStyles.popper,
|
|
256
|
-
...primaryColors,
|
|
257
|
-
zIndex: tooltipZIndex
|
|
258
|
-
},
|
|
259
|
-
onMouseEnter: () => {
|
|
260
|
-
if (hideTimeoutRef.current) {
|
|
261
|
-
clearTimeout(hideTimeoutRef.current);
|
|
262
|
-
hideTimeoutRef.current = null;
|
|
263
|
-
}
|
|
385
|
+
let t19;
|
|
264
386
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
387
|
+
if ($[31] !== children || $[32] !== handleMouseLeaveTarget || $[33] !== isControlled || $[34] !== targetComponent) {
|
|
388
|
+
t19 = /*#__PURE__*/React.createElement(TriggerRenderer, {
|
|
389
|
+
setTriggerRef: setTriggerRef,
|
|
390
|
+
targetComponent: targetComponent,
|
|
391
|
+
isControlled: isControlled,
|
|
392
|
+
handleMouseEnterTarget: handleMouseEnterTarget,
|
|
393
|
+
handleMouseLeaveTarget: handleMouseLeaveTarget
|
|
394
|
+
}, children);
|
|
395
|
+
$[31] = children;
|
|
396
|
+
$[32] = handleMouseLeaveTarget;
|
|
397
|
+
$[33] = isControlled;
|
|
398
|
+
$[34] = targetComponent;
|
|
399
|
+
$[35] = t19;
|
|
400
|
+
} else {
|
|
401
|
+
t19 = $[35];
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
let t20;
|
|
405
|
+
|
|
406
|
+
if ($[36] !== attributes.popper || $[37] !== className || $[38] !== content || $[39] !== handleMouseLeaveTarget || $[40] !== isClosing || $[41] !== isInitial || $[42] !== noProvider || $[43] !== ownerDocument?.body || $[44] !== placement || $[45] !== popperStyles || $[46] !== primaryColors || $[47] !== renderBesideTrigger || $[48] !== theme || $[49] !== tooltipShouldBeRendered || $[50] !== tooltipZIndex) {
|
|
407
|
+
t20 = tooltipShouldBeRendered && /*#__PURE__*/React.createElement(TooltipPortal, {
|
|
408
|
+
renderBesideTrigger: renderBesideTrigger,
|
|
409
|
+
target: ownerDocument?.body
|
|
410
|
+
}, /*#__PURE__*/React.createElement("span", _extends({
|
|
411
|
+
className: cn(styles.tooltip, isInitial && styles.initial, isClosing && styles.closing, OUTER_THEME_STYLES[theme], className),
|
|
412
|
+
ref: setPopperRef,
|
|
413
|
+
style: { ...popperStyles.popper,
|
|
414
|
+
...primaryColors,
|
|
415
|
+
zIndex: tooltipZIndex
|
|
416
|
+
},
|
|
417
|
+
onMouseEnter: () => {
|
|
418
|
+
if (hideTimeoutRef.current) {
|
|
419
|
+
clearTimeout(hideTimeoutRef.current);
|
|
420
|
+
hideTimeoutRef.current = null;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
setIsTooltipHovered(true);
|
|
424
|
+
},
|
|
425
|
+
onMouseLeave: () => {
|
|
426
|
+
setIsVisibleState(false);
|
|
427
|
+
setIsTooltipHovered(false);
|
|
428
|
+
},
|
|
429
|
+
"data-placement": placement,
|
|
430
|
+
"data-test": "tooltip"
|
|
431
|
+
}, attributes.popper), /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
432
|
+
theme: "dark",
|
|
433
|
+
ignoreThemeValueForCSSApi: noProvider
|
|
434
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
435
|
+
className: cn(styles.content),
|
|
436
|
+
onBlur: handleMouseLeaveTarget,
|
|
437
|
+
onFocus: handleMouseEnterTarget,
|
|
438
|
+
ref: setContentEl
|
|
439
|
+
}, content))));
|
|
440
|
+
$[36] = attributes.popper;
|
|
441
|
+
$[37] = className;
|
|
442
|
+
$[38] = content;
|
|
443
|
+
$[39] = handleMouseLeaveTarget;
|
|
444
|
+
$[40] = isClosing;
|
|
445
|
+
$[41] = isInitial;
|
|
446
|
+
$[42] = noProvider;
|
|
447
|
+
$[43] = ownerDocument?.body;
|
|
448
|
+
$[44] = placement;
|
|
449
|
+
$[45] = popperStyles;
|
|
450
|
+
$[46] = primaryColors;
|
|
451
|
+
$[47] = renderBesideTrigger;
|
|
452
|
+
$[48] = theme;
|
|
453
|
+
$[49] = tooltipShouldBeRendered;
|
|
454
|
+
$[50] = tooltipZIndex;
|
|
455
|
+
$[51] = t20;
|
|
456
|
+
} else {
|
|
457
|
+
t20 = $[51];
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
let t21;
|
|
461
|
+
|
|
462
|
+
if ($[52] !== t19 || $[53] !== t20) {
|
|
463
|
+
t21 = /*#__PURE__*/React.createElement(React.Fragment, null, t19, t20);
|
|
464
|
+
$[52] = t19;
|
|
465
|
+
$[53] = t20;
|
|
466
|
+
$[54] = t21;
|
|
467
|
+
} else {
|
|
468
|
+
t21 = $[54];
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return t21;
|
|
283
472
|
};
|
|
284
473
|
|
|
285
474
|
Tooltip.propTypes = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"tooltip": "
|
|
3
|
-
"closing": "
|
|
4
|
-
"content": "
|
|
5
|
-
"initial": "
|
|
6
|
-
"outerThemeLight": "
|
|
7
|
-
"outerThemeDark": "
|
|
8
|
-
"trigger": "
|
|
2
|
+
"tooltip": "_tooltip_m9qz43_5",
|
|
3
|
+
"closing": "_closing_m9qz43_9",
|
|
4
|
+
"content": "_content_m9qz43_13",
|
|
5
|
+
"initial": "_initial_m9qz43_57",
|
|
6
|
+
"outerThemeLight": "_outerThemeLight_m9qz43_71",
|
|
7
|
+
"outerThemeDark": "_outerThemeDark_m9qz43_84",
|
|
8
|
+
"trigger": "_trigger_m9qz43_116"
|
|
9
9
|
};
|
|
10
10
|
export { styles as default };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { c } from 'react-compiler-runtime';
|
|
2
|
+
import { useState, useEffect, useLayoutEffect } from 'react';
|
|
3
|
+
const PRIMARY_COLORS = ['--rs-color-primary-light-theme', '--rs-color-primary-dim-light-theme', '--rs-color-primary-fog-light-theme', '--rs-color-primary-t-dim-light-theme', '--rs-color-primary-t-fog-light-theme', '--rs-color-primary-dark-theme', '--rs-color-primary-dim-dark-theme', '--rs-color-primary-fog-dark-theme', '--rs-color-primary-t-dim-dark-theme', '--rs-color-primary-t-fog-dark-theme'];
|
|
4
|
+
|
|
5
|
+
const extractPrimaryColors = styles => {
|
|
6
|
+
const colors = {};
|
|
7
|
+
PRIMARY_COLORS.forEach(varName => {
|
|
8
|
+
colors[varName] = styles.getPropertyValue(varName) || 'initial';
|
|
9
|
+
});
|
|
10
|
+
return colors;
|
|
11
|
+
};
|
|
12
|
+
/** Check out `@rescui/colors/src/public-api.p.css` file */
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const extractThemeFromCss = styles => {
|
|
16
|
+
const themeDark = parseInt(styles.getPropertyValue('--rs-theme-dark'), 10) || 0;
|
|
17
|
+
const themeFlip = parseInt(styles.getPropertyValue('--rs-theme-flip'), 10) || 0;
|
|
18
|
+
const themeDarkCoefficient = themeDark * (1 - themeFlip) + themeFlip * (1 - themeDark);
|
|
19
|
+
return themeDarkCoefficient === 1 ? 'dark' : 'light';
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
23
|
+
|
|
24
|
+
const useExtractCssValues = (triggerRef, shouldBeRendered, defaultView) => {
|
|
25
|
+
const $ = c(9);
|
|
26
|
+
let t0;
|
|
27
|
+
|
|
28
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
29
|
+
t0 = {};
|
|
30
|
+
$[0] = t0;
|
|
31
|
+
} else {
|
|
32
|
+
t0 = $[0];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const [primaryColors, setPrimaryColors] = useState(t0);
|
|
36
|
+
const [themeFromCss, setThemeFromCss] = useState("light");
|
|
37
|
+
let t1;
|
|
38
|
+
let t2;
|
|
39
|
+
|
|
40
|
+
if ($[1] !== defaultView || $[2] !== shouldBeRendered || $[3] !== triggerRef) {
|
|
41
|
+
t1 = () => {
|
|
42
|
+
if (triggerRef && shouldBeRendered) {
|
|
43
|
+
const triggerStyles = defaultView?.getComputedStyle(triggerRef);
|
|
44
|
+
|
|
45
|
+
if (triggerStyles) {
|
|
46
|
+
setThemeFromCss(extractThemeFromCss(triggerStyles));
|
|
47
|
+
setPrimaryColors(extractPrimaryColors(triggerStyles));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
t2 = [defaultView, shouldBeRendered, triggerRef];
|
|
53
|
+
$[1] = defaultView;
|
|
54
|
+
$[2] = shouldBeRendered;
|
|
55
|
+
$[3] = triggerRef;
|
|
56
|
+
$[4] = t1;
|
|
57
|
+
$[5] = t2;
|
|
58
|
+
} else {
|
|
59
|
+
t1 = $[4];
|
|
60
|
+
t2 = $[5];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
useIsomorphicLayoutEffect(t1, t2);
|
|
64
|
+
let t3;
|
|
65
|
+
|
|
66
|
+
if ($[6] !== primaryColors || $[7] !== themeFromCss) {
|
|
67
|
+
t3 = {
|
|
68
|
+
primaryColors,
|
|
69
|
+
themeFromCss
|
|
70
|
+
};
|
|
71
|
+
$[6] = primaryColors;
|
|
72
|
+
$[7] = themeFromCss;
|
|
73
|
+
$[8] = t3;
|
|
74
|
+
} else {
|
|
75
|
+
t3 = $[8];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return t3;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export { useExtractCssValues };
|
package/lib/use-tooltip-state.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { c } from 'react-compiler-runtime';
|
|
3
|
+
import { useState, useEffect, useLayoutEffect } from 'react';
|
|
3
4
|
const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
4
5
|
const TOOLTIP_TRANSITION_PROPERTIES = ['opacity', 'transform'];
|
|
5
6
|
|
|
@@ -15,117 +16,180 @@ var TOOLTIP_STATES;
|
|
|
15
16
|
TOOLTIP_STATES["CLOSE"] = "CLOSE";
|
|
16
17
|
})(TOOLTIP_STATES || (TOOLTIP_STATES = {}));
|
|
17
18
|
|
|
18
|
-
function useTooltipState(
|
|
19
|
-
|
|
19
|
+
function useTooltipState(t0) {
|
|
20
|
+
const $ = c(14);
|
|
21
|
+
const {
|
|
20
22
|
isOpen,
|
|
21
|
-
canRender
|
|
23
|
+
canRender: t1,
|
|
22
24
|
contentEl,
|
|
23
25
|
popperElement,
|
|
24
26
|
resolvedPlacement
|
|
25
|
-
} =
|
|
27
|
+
} = t0;
|
|
28
|
+
const canRender = t1 === undefined ? true : t1;
|
|
26
29
|
const [tooltipState, setTooltipState] = useState(isOpen && canRender ? TOOLTIP_STATES.OPENING_PREPARE : TOOLTIP_STATES.CLOSE);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
let t2;
|
|
31
|
+
|
|
32
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
33
|
+
t2 = expectedState => {
|
|
34
|
+
setTooltipState(state => {
|
|
35
|
+
if (state !== expectedState) {
|
|
36
|
+
return state;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (expectedState === TOOLTIP_STATES.CLOSING) {
|
|
40
|
+
return TOOLTIP_STATES.CLOSE;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (expectedState === TOOLTIP_STATES.OPENING) {
|
|
44
|
+
return TOOLTIP_STATES.OPEN;
|
|
45
|
+
}
|
|
46
|
+
|
|
30
47
|
return state;
|
|
31
|
-
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
32
50
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
51
|
+
$[0] = t2;
|
|
52
|
+
} else {
|
|
53
|
+
t2 = $[0];
|
|
54
|
+
}
|
|
36
55
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
56
|
+
const completeTransition = t2;
|
|
57
|
+
let t3;
|
|
40
58
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
setTooltipState(state => state === TOOLTIP_STATES.OPENING_PREPARE ? TOOLTIP_STATES.OPENING : state);
|
|
46
|
-
}, []);
|
|
47
|
-
useIsomorphicLayoutEffect(() => {
|
|
48
|
-
if (tooltipState !== TOOLTIP_STATES.OPENING_PREPARE || !popperElement || !resolvedPlacement) {
|
|
49
|
-
return;
|
|
50
|
-
} // Force layout to register the initial styles with the resolved placement
|
|
51
|
-
// before starting the opening transition.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
popperElement.getBoundingClientRect();
|
|
55
|
-
completeOpeningPreparation();
|
|
56
|
-
}, [completeOpeningPreparation, popperElement, resolvedPlacement, tooltipState]); // Track the transitions that currently belong to the OPENING/CLOSING phase:
|
|
57
|
-
// - normally, wait for both opacity and transform before completing the phase;
|
|
58
|
-
// - a style/placement change can cancel or replace a transition without
|
|
59
|
-
// changing the phase; follow the latest one, including a replacement that
|
|
60
|
-
// appears just after the previous transition finishes;
|
|
61
|
-
// - if OPENING changes to CLOSING (or vice versa), cleanup invalidates these
|
|
62
|
-
// waiters and the next phase installs its own, so a stale transition cannot
|
|
63
|
-
// complete it;
|
|
64
|
-
// - if no transitions are created (for example, their duration is 0s),
|
|
65
|
-
// complete the phase immediately.
|
|
66
|
-
|
|
67
|
-
useIsomorphicLayoutEffect(() => {
|
|
68
|
-
if (tooltipState !== TOOLTIP_STATES.OPENING && tooltipState !== TOOLTIP_STATES.CLOSING) {
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
59
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
60
|
+
t3 = () => {
|
|
61
|
+
setTooltipState(_temp);
|
|
62
|
+
};
|
|
71
63
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
$[1] = t3;
|
|
65
|
+
} else {
|
|
66
|
+
t3 = $[1];
|
|
67
|
+
}
|
|
75
68
|
|
|
76
|
-
|
|
69
|
+
const completeOpeningPreparation = t3;
|
|
70
|
+
let t4;
|
|
71
|
+
let t5;
|
|
77
72
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
if ($[2] !== popperElement || $[3] !== resolvedPlacement || $[4] !== tooltipState) {
|
|
74
|
+
t4 = () => {
|
|
75
|
+
if (tooltipState !== TOOLTIP_STATES.OPENING_PREPARE || !popperElement || !resolvedPlacement) {
|
|
76
|
+
return;
|
|
81
77
|
}
|
|
78
|
+
|
|
79
|
+
popperElement.getBoundingClientRect();
|
|
80
|
+
completeOpeningPreparation();
|
|
82
81
|
};
|
|
83
82
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
t5 = [completeOpeningPreparation, popperElement, resolvedPlacement, tooltipState];
|
|
84
|
+
$[2] = popperElement;
|
|
85
|
+
$[3] = resolvedPlacement;
|
|
86
|
+
$[4] = tooltipState;
|
|
87
|
+
$[5] = t4;
|
|
88
|
+
$[6] = t5;
|
|
89
|
+
} else {
|
|
90
|
+
t4 = $[5];
|
|
91
|
+
t5 = $[6];
|
|
92
|
+
}
|
|
88
93
|
|
|
89
|
-
|
|
94
|
+
useIsomorphicLayoutEffect(t4, t5);
|
|
95
|
+
let t6;
|
|
96
|
+
|
|
97
|
+
if ($[7] !== contentEl || $[8] !== tooltipState) {
|
|
98
|
+
t6 = () => {
|
|
99
|
+
if (tooltipState !== TOOLTIP_STATES.OPENING && tooltipState !== TOOLTIP_STATES.CLOSING) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
90
102
|
|
|
91
|
-
if (!
|
|
92
|
-
return
|
|
103
|
+
if (!contentEl) {
|
|
104
|
+
return;
|
|
93
105
|
}
|
|
94
106
|
|
|
95
|
-
|
|
107
|
+
let isCurrentPhase = true;
|
|
108
|
+
|
|
109
|
+
const completeCurrentPhase = () => {
|
|
110
|
+
if (isCurrentPhase) {
|
|
111
|
+
completeTransition(tooltipState);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const waitForCurrentTransition = (property, previousTransition) => {
|
|
96
116
|
if (!isCurrentPhase) {
|
|
97
117
|
return Promise.resolve();
|
|
98
118
|
}
|
|
99
119
|
|
|
100
|
-
const
|
|
120
|
+
const transition = getTooltipTransition(contentEl, property);
|
|
101
121
|
|
|
102
|
-
if (
|
|
103
|
-
return
|
|
122
|
+
if (!transition || transition === previousTransition) {
|
|
123
|
+
return Promise.resolve();
|
|
104
124
|
}
|
|
105
125
|
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
|
|
126
|
+
return transition.finished.then(() => {
|
|
127
|
+
if (!isCurrentPhase) {
|
|
128
|
+
return Promise.resolve();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const replacementTransition = getTooltipTransition(contentEl, property);
|
|
109
132
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
133
|
+
if (replacementTransition && replacementTransition !== transition) {
|
|
134
|
+
return waitForCurrentTransition(property, transition);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return Promise.resolve();
|
|
138
|
+
}, () => waitForCurrentTransition(property, transition));
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
Promise.all(TOOLTIP_TRANSITION_PROPERTIES.map(property_0 => waitForCurrentTransition(property_0))).then(completeCurrentPhase);
|
|
142
|
+
return () => {
|
|
143
|
+
isCurrentPhase = false;
|
|
144
|
+
};
|
|
113
145
|
};
|
|
114
|
-
|
|
146
|
+
|
|
147
|
+
$[7] = contentEl;
|
|
148
|
+
$[8] = tooltipState;
|
|
149
|
+
$[9] = t6;
|
|
150
|
+
} else {
|
|
151
|
+
t6 = $[9];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
let t7;
|
|
155
|
+
|
|
156
|
+
if ($[10] !== contentEl || $[11] !== popperElement || $[12] !== tooltipState) {
|
|
157
|
+
t7 = [completeTransition, contentEl, popperElement, tooltipState];
|
|
158
|
+
$[10] = contentEl;
|
|
159
|
+
$[11] = popperElement;
|
|
160
|
+
$[12] = tooltipState;
|
|
161
|
+
$[13] = t7;
|
|
162
|
+
} else {
|
|
163
|
+
t7 = $[13];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
useIsomorphicLayoutEffect(t6, t7);
|
|
115
167
|
|
|
116
168
|
if (!canRender && tooltipState !== TOOLTIP_STATES.CLOSE) {
|
|
117
169
|
setTooltipState(TOOLTIP_STATES.CLOSE);
|
|
118
|
-
} else
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
170
|
+
} else {
|
|
171
|
+
if (isOpen && canRender && tooltipState === TOOLTIP_STATES.CLOSE) {
|
|
172
|
+
setTooltipState(TOOLTIP_STATES.OPENING_PREPARE);
|
|
173
|
+
} else {
|
|
174
|
+
if (isOpen && canRender && tooltipState === TOOLTIP_STATES.CLOSING) {
|
|
175
|
+
setTooltipState(TOOLTIP_STATES.OPENING);
|
|
176
|
+
} else {
|
|
177
|
+
if (!isOpen && tooltipState === TOOLTIP_STATES.OPENING_PREPARE) {
|
|
178
|
+
setTooltipState(TOOLTIP_STATES.CLOSE);
|
|
179
|
+
} else {
|
|
180
|
+
if (!isOpen && (tooltipState === TOOLTIP_STATES.OPEN || tooltipState === TOOLTIP_STATES.OPENING)) {
|
|
181
|
+
setTooltipState(TOOLTIP_STATES.CLOSING);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
126
186
|
}
|
|
127
187
|
|
|
128
188
|
return tooltipState;
|
|
129
189
|
}
|
|
130
190
|
|
|
191
|
+
function _temp(state_0) {
|
|
192
|
+
return state_0 === TOOLTIP_STATES.OPENING_PREPARE ? TOOLTIP_STATES.OPENING : state_0;
|
|
193
|
+
}
|
|
194
|
+
|
|
131
195
|
export { TOOLTIP_STATES, useTooltipState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/tooltip",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -18,25 +18,26 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime-corejs3": "^7.26.0",
|
|
20
20
|
"@popperjs/core": "^2.11.8",
|
|
21
|
-
"@rescui/use-resize-observer": "0.
|
|
21
|
+
"@rescui/use-resize-observer": "^0.4.0",
|
|
22
22
|
"classnames": "^2.2.6",
|
|
23
|
+
"react-compiler-runtime": "^1.0.0",
|
|
23
24
|
"react-popper": "^2.2.5"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
|
26
|
-
"@rescui/ui-contexts": "^0.
|
|
27
|
+
"@rescui/ui-contexts": "^0.7.0",
|
|
27
28
|
"prop-types": "^15",
|
|
28
|
-
"react": ">=
|
|
29
|
-
"react-dom": ">=
|
|
29
|
+
"react": ">=17.0.0 <20",
|
|
30
|
+
"react-dom": ">=17.0.0 <20"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@rescui/colors": "0.3.4
|
|
33
|
-
"@rescui/icons": "1.
|
|
34
|
-
"@rescui/scripts": "0.5.
|
|
35
|
-
"@rescui/typography": "0.
|
|
33
|
+
"@rescui/colors": "^0.3.4",
|
|
34
|
+
"@rescui/icons": "^1.9.1",
|
|
35
|
+
"@rescui/scripts": "^0.5.3",
|
|
36
|
+
"@rescui/typography": "^0.28.1"
|
|
36
37
|
},
|
|
37
38
|
"scripts": {
|
|
38
39
|
"build": "rescui-scripts build"
|
|
39
40
|
},
|
|
40
41
|
"nx": {},
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "ce4c6c5e3fd5aede0006f6ef8e655fc0ab394c0f"
|
|
42
43
|
}
|
package/lib/css-vars-utils.d.ts
DELETED
package/lib/css-vars-utils.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const PRIMARY_COLORS = ['--rs-color-primary-light-theme', '--rs-color-primary-dim-light-theme', '--rs-color-primary-fog-light-theme', '--rs-color-primary-t-dim-light-theme', '--rs-color-primary-t-fog-light-theme', '--rs-color-primary-dark-theme', '--rs-color-primary-dim-dark-theme', '--rs-color-primary-fog-dark-theme', '--rs-color-primary-t-dim-dark-theme', '--rs-color-primary-t-fog-dark-theme'];
|
|
2
|
-
|
|
3
|
-
const extractPrimaryColors = styles => {
|
|
4
|
-
const colors = {};
|
|
5
|
-
PRIMARY_COLORS.forEach(varName => {
|
|
6
|
-
colors[varName] = styles.getPropertyValue(varName) || 'initial';
|
|
7
|
-
});
|
|
8
|
-
return colors;
|
|
9
|
-
};
|
|
10
|
-
/** Check out `@rescui/colors/src/public-api.p.css` file */
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const extractThemeFromCss = styles => {
|
|
14
|
-
const themeDark = parseInt(styles.getPropertyValue('--rs-theme-dark'), 10) || 0;
|
|
15
|
-
const themeFlip = parseInt(styles.getPropertyValue('--rs-theme-flip'), 10) || 0;
|
|
16
|
-
const themeDarkCoefficient = themeDark * (1 - themeFlip) + themeFlip * (1 - themeDark);
|
|
17
|
-
return themeDarkCoefficient === 1 ? 'dark' : 'light';
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { extractPrimaryColors, extractThemeFromCss };
|