@rescui/tooltip 0.12.1-RUI-297-Add-react-compiler-to-the-packages-build-dbbefd7b8.10 → 0.12.1-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.39
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 +30 -23
- package/lib/tooltip.d.ts +1 -0
- package/lib/tooltip.js +329 -175
- 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.d.ts +10 -1
- package/lib/use-tooltip-state.js +177 -18
- package/package.json +7 -5
- package/lib/css-vars-utils.d.ts +0 -3
- package/lib/css-vars-utils.js +0 -20
package/lib/index.css
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
@property --_rs-theme-dark-coefficient{
|
|
2
|
+
syntax:'<number>';
|
|
3
|
+
inherits:true;
|
|
4
|
+
initial-value:0;
|
|
5
|
+
}
|
|
6
|
+
._tooltip_umk73y_5{
|
|
2
7
|
position:relative;
|
|
3
8
|
}
|
|
4
|
-
.
|
|
9
|
+
._closing_umk73y_9{
|
|
5
10
|
pointer-events:none;
|
|
6
11
|
}
|
|
7
|
-
.
|
|
12
|
+
._content_umk73y_13{
|
|
8
13
|
--rs-theme-dark:1;
|
|
9
14
|
--_rs-tooltip-border-width:1px;
|
|
10
15
|
|
|
@@ -63,6 +68,8 @@
|
|
|
63
68
|
--_rs-typography-link-external-standalone-border-offset-from-text-base:1.02em;
|
|
64
69
|
--_rs-typography-link-border-bottom-width-from-text:1px;
|
|
65
70
|
|
|
71
|
+
color-scheme:dark;
|
|
72
|
+
|
|
66
73
|
max-width:283px;
|
|
67
74
|
|
|
68
75
|
padding:calc(8px - var(--_rs-tooltip-border-width));
|
|
@@ -76,33 +83,33 @@
|
|
|
76
83
|
transition:opacity 300ms var(--rs-transition-function, ease), transform 300ms var(--rs-transition-function, ease);
|
|
77
84
|
transform:translate(0, 0);
|
|
78
85
|
}
|
|
79
|
-
[data-popper-placement='top-end'] .
|
|
80
|
-
[data-popper-placement='bottom-end'] .
|
|
86
|
+
[data-popper-placement='top-end'] ._content_umk73y_13,
|
|
87
|
+
[data-popper-placement='bottom-end'] ._content_umk73y_13{
|
|
81
88
|
margin-right:0;
|
|
82
89
|
}
|
|
83
|
-
[data-popper-placement='top-start'] .
|
|
84
|
-
[data-popper-placement='bottom-start'] .
|
|
90
|
+
[data-popper-placement='top-start'] ._content_umk73y_13,
|
|
91
|
+
[data-popper-placement='bottom-start'] ._content_umk73y_13{
|
|
85
92
|
margin-left:0;
|
|
86
93
|
}
|
|
87
|
-
[data-popper-placement='left-end'] .
|
|
88
|
-
[data-popper-placement='right-end'] .
|
|
94
|
+
[data-popper-placement='left-end'] ._content_umk73y_13,
|
|
95
|
+
[data-popper-placement='right-end'] ._content_umk73y_13{
|
|
89
96
|
margin-bottom:0;
|
|
90
97
|
}
|
|
91
|
-
[data-popper-placement='left-start'] .
|
|
92
|
-
[data-popper-placement='right-start'] .
|
|
98
|
+
[data-popper-placement='left-start'] ._content_umk73y_13,
|
|
99
|
+
[data-popper-placement='right-start'] ._content_umk73y_13{
|
|
93
100
|
margin-top:0;
|
|
94
101
|
}
|
|
95
|
-
.
|
|
102
|
+
._initial_umk73y_57 ._content_umk73y_13{
|
|
96
103
|
transition:none;
|
|
97
104
|
}
|
|
98
|
-
.
|
|
105
|
+
._closing_umk73y_9 ._content_umk73y_13{
|
|
99
106
|
transition-duration:200ms, 200ms;
|
|
100
107
|
}
|
|
101
|
-
.
|
|
102
|
-
.
|
|
108
|
+
._initial_umk73y_57 ._content_umk73y_13,
|
|
109
|
+
._closing_umk73y_9 ._content_umk73y_13{
|
|
103
110
|
opacity:0;
|
|
104
111
|
}
|
|
105
|
-
.
|
|
112
|
+
._outerThemeLight_umk73y_71 ._content_umk73y_13{
|
|
106
113
|
--rs-color-primary-dark-theme:var(--rs-color-primary-light-theme);
|
|
107
114
|
--rs-color-primary-dim-dark-theme:var(--rs-color-primary-dim-light-theme);
|
|
108
115
|
--rs-color-primary-fog-dark-theme:var(--rs-color-primary-fog-light-theme);
|
|
@@ -113,7 +120,7 @@
|
|
|
113
120
|
--rs-color-primary-t-fog-light-theme
|
|
114
121
|
);
|
|
115
122
|
}
|
|
116
|
-
.
|
|
123
|
+
._outerThemeDark_umk73y_84 ._content_umk73y_13{
|
|
117
124
|
--rs-color-primary-light-theme:var(--rs-color-primary-dark-theme);
|
|
118
125
|
--rs-color-primary-dim-light-theme:var(--rs-color-primary-dim-dark-theme);
|
|
119
126
|
--rs-color-primary-fog-light-theme:var(--rs-color-primary-fog-dark-theme);
|
|
@@ -124,20 +131,20 @@
|
|
|
124
131
|
--rs-color-primary-t-fog-dark-theme
|
|
125
132
|
);
|
|
126
133
|
}
|
|
127
|
-
.
|
|
134
|
+
._initial_umk73y_57[data-popper-placement^='top'] ._content_umk73y_13, ._closing_umk73y_9[data-popper-placement^='top'] ._content_umk73y_13{
|
|
128
135
|
transform:translate(0, 10px);
|
|
129
136
|
}
|
|
130
|
-
.
|
|
137
|
+
._initial_umk73y_57[data-popper-placement^='right'] ._content_umk73y_13, ._closing_umk73y_9[data-popper-placement^='right'] ._content_umk73y_13{
|
|
131
138
|
transform:translate(-10px, 0);
|
|
132
139
|
}
|
|
133
|
-
.
|
|
140
|
+
._initial_umk73y_57[data-popper-placement^='bottom'] ._content_umk73y_13, ._closing_umk73y_9[data-popper-placement^='bottom'] ._content_umk73y_13{
|
|
134
141
|
transform:translate(0, -10px);
|
|
135
142
|
}
|
|
136
|
-
.
|
|
143
|
+
._initial_umk73y_57[data-popper-placement^='left'] ._content_umk73y_13, ._closing_umk73y_9[data-popper-placement^='left'] ._content_umk73y_13{
|
|
137
144
|
transform:translate(10px, 0);
|
|
138
145
|
}
|
|
139
|
-
.
|
|
140
|
-
.
|
|
146
|
+
._trigger_umk73y_116:focus-visible,
|
|
147
|
+
._trigger_umk73y_116:focus[data-focus-method='key']{
|
|
141
148
|
outline:none;
|
|
142
149
|
|
|
143
150
|
box-shadow:var(--rs-color-primary-t-dim-light-theme) 0 0 0 4px;
|
package/lib/tooltip.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export interface TooltipProps {
|
|
|
48
48
|
* When no space is available on the preferred placement, the tooltip will test
|
|
49
49
|
* the ones provided in the list, and use the first useful one.
|
|
50
50
|
* See [docs](https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements).
|
|
51
|
+
* @rawDefaultValue
|
|
51
52
|
*/
|
|
52
53
|
fallbackPlacements?: Placement[];
|
|
53
54
|
/**
|
package/lib/tooltip.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
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';
|
|
7
9
|
import { usePopper } from 'react-popper';
|
|
8
10
|
import { useLayeringContext, ThemeContext, ThemeProvider } from '@rescui/ui-contexts';
|
|
11
|
+
import { useResizeObserver } from '@rescui/use-resize-observer';
|
|
9
12
|
import styles from './tooltip.p.module.css.js';
|
|
10
13
|
import { useTooltipState, TOOLTIP_STATES } from './use-tooltip-state.js';
|
|
11
|
-
import {
|
|
14
|
+
import { useExtractCssValues } from './use-extract-css-values.js';
|
|
12
15
|
const HIDE_TIMEOUT = 500;
|
|
13
16
|
|
|
14
17
|
const Portal = _ref => {
|
|
@@ -19,20 +22,32 @@ const Portal = _ref => {
|
|
|
19
22
|
return target ? /*#__PURE__*/ReactDOM.createPortal(children, target) : null;
|
|
20
23
|
};
|
|
21
24
|
|
|
22
|
-
const TooltipPortal =
|
|
23
|
-
|
|
25
|
+
const TooltipPortal = t0 => {
|
|
26
|
+
const $ = c(3);
|
|
27
|
+
const {
|
|
24
28
|
children,
|
|
25
29
|
renderBesideTrigger,
|
|
26
30
|
target
|
|
27
|
-
} =
|
|
31
|
+
} = t0;
|
|
28
32
|
|
|
29
33
|
if (renderBesideTrigger) {
|
|
30
34
|
return children;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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;
|
|
36
51
|
};
|
|
37
52
|
|
|
38
53
|
const isNode = maybeNode => {
|
|
@@ -61,7 +76,7 @@ const OUTER_THEME_STYLES = {
|
|
|
61
76
|
light: styles.outerThemeLight,
|
|
62
77
|
dark: styles.outerThemeDark
|
|
63
78
|
};
|
|
64
|
-
const TriggerRenderer = /*#__PURE__*/React.forwardRef((
|
|
79
|
+
const TriggerRenderer = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
65
80
|
let {
|
|
66
81
|
setTriggerRef,
|
|
67
82
|
targetComponent,
|
|
@@ -69,7 +84,7 @@ const TriggerRenderer = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
69
84
|
handleMouseEnterTarget,
|
|
70
85
|
handleMouseLeaveTarget,
|
|
71
86
|
children
|
|
72
|
-
} =
|
|
87
|
+
} = _ref2;
|
|
73
88
|
const eventListeners = !isControlled ? {
|
|
74
89
|
onMouseEnter: handleMouseEnterTarget,
|
|
75
90
|
onMouseLeave: handleMouseLeaveTarget,
|
|
@@ -119,202 +134,341 @@ const TriggerRenderer = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
119
134
|
});
|
|
120
135
|
TriggerRenderer.displayName = 'TriggerRenderer'; // eslint-disable-next-line complexity
|
|
121
136
|
|
|
122
|
-
const Tooltip =
|
|
123
|
-
|
|
137
|
+
const Tooltip = t0 => {
|
|
138
|
+
const $ = c(55);
|
|
139
|
+
const {
|
|
124
140
|
children,
|
|
125
|
-
targetComponent
|
|
141
|
+
targetComponent: t1,
|
|
126
142
|
content,
|
|
127
143
|
className,
|
|
128
144
|
isVisible: isVisibleFromProps,
|
|
129
145
|
modifiers,
|
|
130
|
-
placement
|
|
131
|
-
sparse
|
|
132
|
-
fallbackPlacements
|
|
146
|
+
placement: t2,
|
|
147
|
+
sparse: t3,
|
|
148
|
+
fallbackPlacements: t4,
|
|
133
149
|
disableHideDelay,
|
|
134
|
-
renderBesideTrigger
|
|
135
|
-
} =
|
|
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;
|
|
136
167
|
const {
|
|
137
168
|
tooltipZIndex
|
|
138
169
|
} = useLayeringContext();
|
|
139
170
|
const [popperRef, setPopperRef] = useState(null);
|
|
140
|
-
const [triggerRef, setTriggerRef] = useState(
|
|
171
|
+
const [triggerRef, setTriggerRef] = useState(undefined);
|
|
141
172
|
const [isVisibleState, setIsVisibleState] = useState(false);
|
|
142
173
|
const [isTooltipHovered, setIsTooltipHovered] = useState(false);
|
|
143
|
-
const
|
|
144
|
-
const contentRef = useRef(null);
|
|
174
|
+
const [contentEl, setContentEl] = useState(null);
|
|
145
175
|
const hideTimeoutRef = useRef(null);
|
|
146
|
-
const isControlled = typeof isVisibleFromProps !==
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
// So even if isVisible prop is used, the tooltip will not render on the server, and
|
|
150
|
-
// it's the same on the first client render, so there is no hydration issue.
|
|
151
|
-
|
|
152
|
-
const [isFirstRender, setIsFirstRender] = useState(true);
|
|
153
|
-
useEffect(() => {
|
|
154
|
-
setIsFirstRender(false);
|
|
155
|
-
}, []);
|
|
156
|
-
isVisible = isFirstRender && !renderBesideTrigger ? false : isVisible;
|
|
176
|
+
const isControlled = typeof isVisibleFromProps !== "undefined";
|
|
177
|
+
const requestedVisibility = isControlled ? isVisibleFromProps : isVisibleState;
|
|
178
|
+
const isVisible = typeof triggerRef !== "undefined" || renderBesideTrigger ? requestedVisibility : false;
|
|
157
179
|
const ownerDocument = triggerRef?.ownerDocument;
|
|
158
180
|
const isOpen = isVisible || isTooltipHovered;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
181
|
+
let t7;
|
|
182
|
+
|
|
183
|
+
if ($[2] !== content) {
|
|
184
|
+
t7 = isNode(content);
|
|
185
|
+
$[2] = content;
|
|
186
|
+
$[3] = t7;
|
|
187
|
+
} else {
|
|
188
|
+
t7 = $[3];
|
|
189
|
+
}
|
|
164
190
|
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
191
|
+
const contentCanBeRendered = t7;
|
|
192
|
+
const portalTargetIsAvailable = renderBesideTrigger || Boolean(ownerDocument?.body);
|
|
193
|
+
const canRenderTooltip = contentCanBeRendered && portalTargetIsAvailable;
|
|
194
|
+
let t8;
|
|
195
|
+
|
|
196
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
197
|
+
t8 = () => {
|
|
198
|
+
if (hideTimeoutRef.current) {
|
|
199
|
+
clearTimeout(hideTimeoutRef.current);
|
|
200
|
+
hideTimeoutRef.current = null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
setIsVisibleState(true);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
$[4] = t8;
|
|
207
|
+
} else {
|
|
208
|
+
t8 = $[4];
|
|
209
|
+
}
|
|
170
210
|
|
|
171
|
-
|
|
172
|
-
|
|
211
|
+
const handleMouseEnterTarget = t8;
|
|
212
|
+
let t9;
|
|
173
213
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
} else {
|
|
178
|
-
hideTimeoutRef.current = setTimeout(() => {
|
|
214
|
+
if ($[5] !== disableHideDelay) {
|
|
215
|
+
t9 = () => {
|
|
216
|
+
if (disableHideDelay) {
|
|
179
217
|
setIsVisibleState(false);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
218
|
+
} else {
|
|
219
|
+
hideTimeoutRef.current = setTimeout(() => {
|
|
220
|
+
setIsVisibleState(false);
|
|
221
|
+
}, HIDE_TIMEOUT);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
183
224
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
225
|
+
$[5] = disableHideDelay;
|
|
226
|
+
$[6] = t9;
|
|
227
|
+
} else {
|
|
228
|
+
t9 = $[6];
|
|
229
|
+
}
|
|
187
230
|
|
|
188
|
-
const
|
|
231
|
+
const handleMouseLeaveTarget = t9;
|
|
232
|
+
let t10;
|
|
189
233
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
// to make sure that the dom has registered the initial
|
|
201
|
-
// styles with resolved placement (for `auto` placement)
|
|
202
|
-
|
|
203
|
-
el.getBoundingClientRect();
|
|
204
|
-
setIsInitial(false);
|
|
205
|
-
}, []);
|
|
206
|
-
const tooltipShouldBeRendered = isExists && isNode(content); // immediately fire handleAnimationEnd event on visibility change in case transition is disabled
|
|
207
|
-
// it may happen if the user hard-disabled all transitions in his browser
|
|
208
|
-
|
|
209
|
-
useEffect(() => {
|
|
210
|
-
if (!isInitial && contentRef.current) {
|
|
211
|
-
const ownerWindow = contentRef.current.ownerDocument.defaultView;
|
|
212
|
-
const isTransitionDisabled = ownerWindow?.getComputedStyle(contentRef.current).transitionDuration === '0s';
|
|
213
|
-
|
|
214
|
-
if (isTransitionDisabled) {
|
|
215
|
-
handleAnimationEnd();
|
|
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];
|
|
216
244
|
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
// In theory this part of the code might cause issues with SSR.
|
|
224
|
-
// But in this specific context, because of the nature of the state-ref "triggerRef",
|
|
225
|
-
// we are sure that the tooltip wouldn't be rendered on the first client render.
|
|
226
|
-
// Therefore, the first render on the client will be the same as on the server.
|
|
227
|
-
const triggerStyles = ownerDocument?.defaultView?.getComputedStyle(triggerRef);
|
|
228
|
-
|
|
229
|
-
if (triggerStyles) {
|
|
230
|
-
themeFromCss = extractThemeFromCss(triggerStyles);
|
|
231
|
-
primaryColors = extractPrimaryColors(triggerStyles);
|
|
232
|
-
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
$[7] = sparse;
|
|
248
|
+
$[8] = t10;
|
|
249
|
+
} else {
|
|
250
|
+
t10 = $[8];
|
|
233
251
|
}
|
|
234
252
|
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
let {
|
|
242
|
-
placement: offsetPlacement
|
|
243
|
-
} = _ref6;
|
|
244
|
-
|
|
245
|
-
if (_includesInstanceProperty(offsetPlacement).call(offsetPlacement, 'left') || _includesInstanceProperty(offsetPlacement).call(offsetPlacement, 'right')) {
|
|
246
|
-
return [0, sparse ? 16 : 8];
|
|
247
|
-
} else {
|
|
248
|
-
return [0, sparse ? 12 : 8];
|
|
249
|
-
}
|
|
250
|
-
}, [sparse]);
|
|
251
|
-
const {
|
|
252
|
-
styles: popperStyles,
|
|
253
|
-
attributes,
|
|
254
|
-
update
|
|
255
|
-
} = usePopper(triggerRef, popperRef, {
|
|
256
|
-
placement,
|
|
257
|
-
modifiers: [// the modifier to trigger starting animation
|
|
258
|
-
{
|
|
259
|
-
name: 'disableInitialFlag',
|
|
260
|
-
enabled: true,
|
|
261
|
-
phase: 'afterWrite',
|
|
262
|
-
fn: disableInitialFlag,
|
|
263
|
-
requires: []
|
|
264
|
-
}, {
|
|
265
|
-
name: 'flip',
|
|
253
|
+
const calcOffset = t10;
|
|
254
|
+
let t11;
|
|
255
|
+
|
|
256
|
+
if ($[9] !== fallbackPlacements) {
|
|
257
|
+
t11 = {
|
|
258
|
+
name: "flip",
|
|
266
259
|
options: {
|
|
267
260
|
fallbackPlacements
|
|
268
261
|
}
|
|
269
|
-
}
|
|
270
|
-
|
|
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",
|
|
271
274
|
options: {
|
|
272
275
|
offset: calcOffset
|
|
273
276
|
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
isControlled: isControlled,
|
|
281
|
-
handleMouseEnterTarget: handleMouseEnterTarget,
|
|
282
|
-
handleMouseLeaveTarget: handleMouseLeaveTarget
|
|
283
|
-
}, children), tooltipShouldBeRendered && /*#__PURE__*/React.createElement(TooltipPortal, {
|
|
284
|
-
renderBesideTrigger: renderBesideTrigger,
|
|
285
|
-
target: ownerDocument?.body
|
|
286
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
287
|
-
className: cn(styles.tooltip, isInitial && styles.initial, isClosing && styles.closing, OUTER_THEME_STYLES[theme], className),
|
|
288
|
-
ref: setPopperRef,
|
|
289
|
-
style: { ...popperStyles.popper,
|
|
290
|
-
...primaryColors,
|
|
291
|
-
zIndex: tooltipZIndex
|
|
292
|
-
},
|
|
293
|
-
onMouseEnter: () => {
|
|
294
|
-
if (hideTimeoutRef.current) {
|
|
295
|
-
clearTimeout(hideTimeoutRef.current);
|
|
296
|
-
hideTimeoutRef.current = null;
|
|
297
|
-
}
|
|
277
|
+
};
|
|
278
|
+
$[11] = calcOffset;
|
|
279
|
+
$[12] = t12;
|
|
280
|
+
} else {
|
|
281
|
+
t12 = $[12];
|
|
282
|
+
}
|
|
298
283
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
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);
|
|
372
|
+
const isInitial = tooltipState === TOOLTIP_STATES.OPENING_PREPARE;
|
|
373
|
+
const isClosing = tooltipState === TOOLTIP_STATES.CLOSING;
|
|
374
|
+
const isExists = tooltipState !== TOOLTIP_STATES.CLOSE;
|
|
375
|
+
const tooltipShouldBeRendered = isExists && canRenderTooltip;
|
|
376
|
+
const {
|
|
377
|
+
primaryColors,
|
|
378
|
+
themeFromCss
|
|
379
|
+
} = useExtractCssValues(triggerRef, tooltipShouldBeRendered, ownerDocument?.defaultView);
|
|
380
|
+
const {
|
|
381
|
+
theme: themeFromContext,
|
|
382
|
+
noProvider
|
|
383
|
+
} = useContext(ThemeContext);
|
|
384
|
+
const theme = noProvider ? themeFromCss : themeFromContext;
|
|
385
|
+
let t19;
|
|
386
|
+
|
|
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;
|
|
318
472
|
};
|
|
319
473
|
|
|
320
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_umk73y_5",
|
|
3
|
+
"closing": "_closing_umk73y_9",
|
|
4
|
+
"content": "_content_umk73y_13",
|
|
5
|
+
"initial": "_initial_umk73y_57",
|
|
6
|
+
"outerThemeLight": "_outerThemeLight_umk73y_71",
|
|
7
|
+
"outerThemeDark": "_outerThemeDark_umk73y_84",
|
|
8
|
+
"trigger": "_trigger_umk73y_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 };
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
export declare enum TOOLTIP_STATES {
|
|
2
|
+
OPENING_PREPARE = "OPENING_PREPARE",
|
|
2
3
|
OPENING = "OPENING",
|
|
3
4
|
OPEN = "OPEN",
|
|
4
5
|
CLOSING = "CLOSING",
|
|
5
6
|
CLOSE = "CLOSE"
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
type UseTooltipStateOptions = {
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
canRender?: boolean;
|
|
11
|
+
contentEl: HTMLDivElement | null;
|
|
12
|
+
popperElement: HTMLElement | null;
|
|
13
|
+
resolvedPlacement: string | null;
|
|
14
|
+
};
|
|
15
|
+
export declare function useTooltipState({ isOpen, canRender, contentEl, popperElement, resolvedPlacement }: UseTooltipStateOptions): TOOLTIP_STATES;
|
|
16
|
+
export {};
|
package/lib/use-tooltip-state.js
CHANGED
|
@@ -1,36 +1,195 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { c } from 'react-compiler-runtime';
|
|
3
|
+
import { useState, useEffect, useLayoutEffect } from 'react';
|
|
4
|
+
const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
5
|
+
const TOOLTIP_TRANSITION_PROPERTIES = ['opacity', 'transform'];
|
|
6
|
+
|
|
7
|
+
const getTooltipTransition = (element, property) => element.getAnimations().find(animation => animation.transitionProperty === property);
|
|
8
|
+
|
|
3
9
|
var TOOLTIP_STATES;
|
|
4
10
|
|
|
5
11
|
(function (TOOLTIP_STATES) {
|
|
12
|
+
TOOLTIP_STATES["OPENING_PREPARE"] = "OPENING_PREPARE";
|
|
6
13
|
TOOLTIP_STATES["OPENING"] = "OPENING";
|
|
7
14
|
TOOLTIP_STATES["OPEN"] = "OPEN";
|
|
8
15
|
TOOLTIP_STATES["CLOSING"] = "CLOSING";
|
|
9
16
|
TOOLTIP_STATES["CLOSE"] = "CLOSE";
|
|
10
17
|
})(TOOLTIP_STATES || (TOOLTIP_STATES = {}));
|
|
11
18
|
|
|
12
|
-
function useTooltipState(
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
function useTooltipState(t0) {
|
|
20
|
+
const $ = c(14);
|
|
21
|
+
const {
|
|
22
|
+
isOpen,
|
|
23
|
+
canRender: t1,
|
|
24
|
+
contentEl,
|
|
25
|
+
popperElement,
|
|
26
|
+
resolvedPlacement
|
|
27
|
+
} = t0;
|
|
28
|
+
const canRender = t1 === undefined ? true : t1;
|
|
29
|
+
const [tooltipState, setTooltipState] = useState(isOpen && canRender ? TOOLTIP_STATES.OPENING_PREPARE : TOOLTIP_STATES.CLOSE);
|
|
30
|
+
let t2;
|
|
18
31
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
33
|
+
t2 = expectedState => {
|
|
34
|
+
setTooltipState(state => {
|
|
35
|
+
if (state !== expectedState) {
|
|
36
|
+
return state;
|
|
37
|
+
}
|
|
22
38
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
|
|
47
|
+
return state;
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
$[0] = t2;
|
|
52
|
+
} else {
|
|
53
|
+
t2 = $[0];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const completeTransition = t2;
|
|
57
|
+
let t3;
|
|
58
|
+
|
|
59
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
60
|
+
t3 = () => {
|
|
61
|
+
setTooltipState(_temp);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
$[1] = t3;
|
|
65
|
+
} else {
|
|
66
|
+
t3 = $[1];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const completeOpeningPreparation = t3;
|
|
70
|
+
let t4;
|
|
71
|
+
let t5;
|
|
72
|
+
|
|
73
|
+
if ($[2] !== popperElement || $[3] !== resolvedPlacement || $[4] !== tooltipState) {
|
|
74
|
+
t4 = () => {
|
|
75
|
+
if (tooltipState !== TOOLTIP_STATES.OPENING_PREPARE || !popperElement || !resolvedPlacement) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
popperElement.getBoundingClientRect();
|
|
80
|
+
completeOpeningPreparation();
|
|
81
|
+
};
|
|
82
|
+
|
|
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
|
+
}
|
|
93
|
+
|
|
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
|
+
}
|
|
102
|
+
|
|
103
|
+
if (!contentEl) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
26
106
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
107
|
+
let isCurrentPhase = true;
|
|
108
|
+
|
|
109
|
+
const completeCurrentPhase = () => {
|
|
110
|
+
if (isCurrentPhase) {
|
|
111
|
+
completeTransition(tooltipState);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const waitForCurrentTransition = (property, previousTransition) => {
|
|
116
|
+
if (!isCurrentPhase) {
|
|
117
|
+
return Promise.resolve();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const transition = getTooltipTransition(contentEl, property);
|
|
121
|
+
|
|
122
|
+
if (!transition || transition === previousTransition) {
|
|
123
|
+
return Promise.resolve();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return transition.finished.then(() => {
|
|
127
|
+
if (!isCurrentPhase) {
|
|
128
|
+
return Promise.resolve();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const replacementTransition = getTooltipTransition(contentEl, property);
|
|
132
|
+
|
|
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
|
+
};
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
$[7] = contentEl;
|
|
148
|
+
$[8] = tooltipState;
|
|
149
|
+
$[9] = t6;
|
|
150
|
+
} else {
|
|
151
|
+
t6 = $[9];
|
|
31
152
|
}
|
|
32
153
|
|
|
33
|
-
|
|
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);
|
|
167
|
+
|
|
168
|
+
if (!canRender && tooltipState !== TOOLTIP_STATES.CLOSE) {
|
|
169
|
+
setTooltipState(TOOLTIP_STATES.CLOSE);
|
|
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
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return tooltipState;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function _temp(state_0) {
|
|
192
|
+
return state_0 === TOOLTIP_STATES.OPENING_PREPARE ? TOOLTIP_STATES.OPENING : state_0;
|
|
34
193
|
}
|
|
35
194
|
|
|
36
195
|
export { TOOLTIP_STATES, useTooltipState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/tooltip",
|
|
3
|
-
"version": "0.12.1-RUI-297-Add-react-compiler-to-the-packages-build-
|
|
3
|
+
"version": "0.12.1-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.39+8aaaed4be",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime-corejs3": "^7.26.0",
|
|
20
20
|
"@popperjs/core": "^2.11.8",
|
|
21
|
+
"@rescui/use-resize-observer": "0.3.4-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.39+8aaaed4be",
|
|
21
22
|
"classnames": "^2.2.6",
|
|
23
|
+
"react-compiler-runtime": "^1.0.0",
|
|
22
24
|
"react-popper": "^2.2.5"
|
|
23
25
|
},
|
|
24
26
|
"peerDependencies": {
|
|
@@ -28,14 +30,14 @@
|
|
|
28
30
|
"react-dom": ">=17.0.0 <20"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
|
-
"@rescui/colors": "0.3.3-RUI-297-Add-react-compiler-to-the-packages-build-
|
|
32
|
-
"@rescui/icons": "1.8.3-RUI-297-Add-react-compiler-to-the-packages-build-
|
|
33
|
+
"@rescui/colors": "0.3.3-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.43+8aaaed4be",
|
|
34
|
+
"@rescui/icons": "1.8.3-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.43+8aaaed4be",
|
|
33
35
|
"@rescui/scripts": "0.5.2",
|
|
34
|
-
"@rescui/typography": "0.27.3-RUI-297-Add-react-compiler-to-the-packages-build-
|
|
36
|
+
"@rescui/typography": "0.27.3-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.43+8aaaed4be"
|
|
35
37
|
},
|
|
36
38
|
"scripts": {
|
|
37
39
|
"build": "rescui-scripts build"
|
|
38
40
|
},
|
|
39
41
|
"nx": {},
|
|
40
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "8aaaed4bee650c002b7f195438380b70c31cc5a4"
|
|
41
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 };
|