@rescui/dropdown 0.11.1-RUI-297-Add-react-compiler-to-the-packages-build-dbbefd7b8.10 → 0.11.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/dropdown.js +371 -164
- package/lib/dropdown.p.module.css.js +9 -12
- package/lib/index.css +27 -76
- package/lib/use-dropdown-state.d.ts +11 -1
- package/lib/use-dropdown-state.js +178 -18
- package/lib/use-extract-css-values.d.ts +5 -0
- package/lib/use-extract-css-values.js +78 -0
- package/lib/use-scrollable-container.js +37 -14
- package/package.json +7 -6
- package/lib/css-vars-utils.d.ts +0 -3
- package/lib/css-vars-utils.js +0 -20
package/lib/dropdown.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
2
|
+
import _extends from '@babel/runtime-corejs3/helpers/esm/extends';
|
|
3
|
+
import { c } from 'react-compiler-runtime';
|
|
4
|
+
import React, { useState, useRef, useImperativeHandle, useContext, useEffect } from 'react';
|
|
3
5
|
import PropTypes from 'prop-types';
|
|
4
6
|
import cn from 'classnames';
|
|
5
7
|
import { usePopper } from 'react-popper';
|
|
@@ -11,7 +13,7 @@ import { useDropdownState, DROPDOWN_STATES } from './use-dropdown-state.js';
|
|
|
11
13
|
import { useScrollableContainer } from './use-scrollable-container.js';
|
|
12
14
|
import styles from './dropdown.p.module.css.js';
|
|
13
15
|
import { applyMaxSize, sameWidthModifier } from './custom-modifiers.js';
|
|
14
|
-
import {
|
|
16
|
+
import { useExtractCssValues } from './use-extract-css-values.js';
|
|
15
17
|
|
|
16
18
|
function getPopperOptions(_ref) {
|
|
17
19
|
let {
|
|
@@ -58,57 +60,126 @@ const Portal = _ref2 => {
|
|
|
58
60
|
return target ? /*#__PURE__*/ReactDOM.createPortal(children, target) : null;
|
|
59
61
|
};
|
|
60
62
|
|
|
61
|
-
function useOnOutsideClick(
|
|
62
|
-
|
|
63
|
+
function useOnOutsideClick(t0) {
|
|
64
|
+
const $ = c(13);
|
|
65
|
+
const {
|
|
63
66
|
onOutsideClick,
|
|
64
67
|
isEnabled,
|
|
65
|
-
ignoreElements
|
|
68
|
+
ignoreElements: t1,
|
|
66
69
|
ownerDocument
|
|
67
|
-
} =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
} = t0;
|
|
71
|
+
let t2;
|
|
72
|
+
|
|
73
|
+
if ($[0] !== t1) {
|
|
74
|
+
t2 = t1 === undefined ? [] : t1;
|
|
75
|
+
$[0] = t1;
|
|
76
|
+
$[1] = t2;
|
|
77
|
+
} else {
|
|
78
|
+
t2 = $[1];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const ignoreElements = t2;
|
|
82
|
+
let t3;
|
|
83
|
+
|
|
84
|
+
if ($[2] !== ignoreElements) {
|
|
85
|
+
t3 = ignoreElements.length > 0 && ignoreElements.every(Boolean);
|
|
86
|
+
$[2] = ignoreElements;
|
|
87
|
+
$[3] = t3;
|
|
88
|
+
} else {
|
|
89
|
+
t3 = $[3];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const ignoreElementRefsExists = t3;
|
|
93
|
+
let t4;
|
|
94
|
+
|
|
95
|
+
if ($[4] !== ignoreElements || $[5] !== onOutsideClick) {
|
|
96
|
+
t4 = e => {
|
|
97
|
+
for (const element of ignoreElements) {
|
|
98
|
+
if (!element || e.target === element || element.contains(e.target)) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
73
101
|
}
|
|
74
|
-
}
|
|
75
102
|
|
|
76
|
-
|
|
77
|
-
|
|
103
|
+
onOutsideClick();
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
$[4] = ignoreElements;
|
|
107
|
+
$[5] = onOutsideClick;
|
|
108
|
+
$[6] = t4;
|
|
109
|
+
} else {
|
|
110
|
+
t4 = $[6];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const handleDocumentClick = t4;
|
|
114
|
+
let t5;
|
|
115
|
+
let t6;
|
|
116
|
+
|
|
117
|
+
if ($[7] !== handleDocumentClick || $[8] !== ignoreElementRefsExists || $[9] !== isEnabled || $[10] !== ownerDocument) {
|
|
118
|
+
t5 = () => {
|
|
119
|
+
if (isEnabled && ignoreElementRefsExists && ownerDocument) {
|
|
120
|
+
ownerDocument.addEventListener("click", handleDocumentClick, true);
|
|
121
|
+
return () => ownerDocument.removeEventListener("click", handleDocumentClick, true);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
78
124
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
125
|
+
t6 = [handleDocumentClick, ignoreElementRefsExists, isEnabled, ownerDocument];
|
|
126
|
+
$[7] = handleDocumentClick;
|
|
127
|
+
$[8] = ignoreElementRefsExists;
|
|
128
|
+
$[9] = isEnabled;
|
|
129
|
+
$[10] = ownerDocument;
|
|
130
|
+
$[11] = t5;
|
|
131
|
+
$[12] = t6;
|
|
132
|
+
} else {
|
|
133
|
+
t5 = $[11];
|
|
134
|
+
t6 = $[12];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
useEffect(t5, t6);
|
|
85
138
|
}
|
|
86
139
|
|
|
87
|
-
function useKeyPress(
|
|
88
|
-
|
|
140
|
+
function useKeyPress(t0) {
|
|
141
|
+
const $ = c(6);
|
|
142
|
+
const {
|
|
89
143
|
key,
|
|
90
144
|
onKeyPress,
|
|
91
145
|
isEnabled,
|
|
92
146
|
ownerDocument
|
|
93
|
-
} =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
e.preventDefault();
|
|
102
|
-
onKeyPress();
|
|
147
|
+
} = t0;
|
|
148
|
+
let t1;
|
|
149
|
+
let t2;
|
|
150
|
+
|
|
151
|
+
if ($[0] !== isEnabled || $[1] !== key || $[2] !== onKeyPress || $[3] !== ownerDocument) {
|
|
152
|
+
t1 = () => {
|
|
153
|
+
if (!isEnabled || !ownerDocument) {
|
|
154
|
+
return;
|
|
103
155
|
}
|
|
104
|
-
};
|
|
105
156
|
|
|
106
|
-
|
|
157
|
+
const keyDownHandler = e => {
|
|
158
|
+
if (e.key === key) {
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
onKeyPress();
|
|
161
|
+
}
|
|
162
|
+
};
|
|
107
163
|
|
|
108
|
-
|
|
109
|
-
|
|
164
|
+
ownerDocument.addEventListener("keydown", keyDownHandler, true);
|
|
165
|
+
return () => {
|
|
166
|
+
ownerDocument.removeEventListener("keydown", keyDownHandler, true);
|
|
167
|
+
};
|
|
110
168
|
};
|
|
111
|
-
|
|
169
|
+
|
|
170
|
+
t2 = [isEnabled, key, onKeyPress, ownerDocument];
|
|
171
|
+
$[0] = isEnabled;
|
|
172
|
+
$[1] = key;
|
|
173
|
+
$[2] = onKeyPress;
|
|
174
|
+
$[3] = ownerDocument;
|
|
175
|
+
$[4] = t1;
|
|
176
|
+
$[5] = t2;
|
|
177
|
+
} else {
|
|
178
|
+
t1 = $[4];
|
|
179
|
+
t2 = $[5];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
useEffect(t1, t2);
|
|
112
183
|
}
|
|
113
184
|
|
|
114
185
|
const THEME_STYLES = {
|
|
@@ -120,165 +191,298 @@ const MODE_STYLES = {
|
|
|
120
191
|
rock: styles.modeRock
|
|
121
192
|
};
|
|
122
193
|
|
|
123
|
-
const DropdownRender = (
|
|
124
|
-
|
|
194
|
+
const DropdownRender = (t0, externalRef) => {
|
|
195
|
+
const $ = c(60);
|
|
196
|
+
const {
|
|
125
197
|
children,
|
|
126
198
|
trigger,
|
|
127
199
|
theme: themeFromProps,
|
|
128
|
-
isOpen:
|
|
129
|
-
placement
|
|
130
|
-
mode
|
|
131
|
-
|
|
132
|
-
onRequestClose = () => {},
|
|
200
|
+
isOpen: t1,
|
|
201
|
+
placement: t2,
|
|
202
|
+
mode: t3,
|
|
203
|
+
onRequestClose: t4,
|
|
133
204
|
minWidth,
|
|
134
205
|
maxWidth,
|
|
135
206
|
maxHeight,
|
|
136
207
|
leastMaxHeight,
|
|
137
|
-
cancelCloseAnimation
|
|
208
|
+
cancelCloseAnimation: t5,
|
|
138
209
|
className,
|
|
139
|
-
closeOnEsc
|
|
140
|
-
closeOnTab
|
|
141
|
-
disableFocusLock
|
|
142
|
-
renderInTrigger
|
|
143
|
-
disableFlip
|
|
144
|
-
} =
|
|
210
|
+
closeOnEsc: t6,
|
|
211
|
+
closeOnTab: t7,
|
|
212
|
+
disableFocusLock: t8,
|
|
213
|
+
renderInTrigger: t9,
|
|
214
|
+
disableFlip: t10
|
|
215
|
+
} = t0;
|
|
216
|
+
const isOpenFromProps = t1 === undefined ? false : t1;
|
|
217
|
+
const placement = t2 === undefined ? "bottom-start" : t2;
|
|
218
|
+
const mode = t3 === undefined ? "classic" : t3;
|
|
219
|
+
const onRequestClose = t4 === undefined ? _temp : t4;
|
|
220
|
+
const cancelCloseAnimation = t5 === undefined ? false : t5;
|
|
221
|
+
const closeOnEsc = t6 === undefined ? true : t6;
|
|
222
|
+
const closeOnTab = t7 === undefined ? false : t7;
|
|
223
|
+
const disableFocusLock = t8 === undefined ? false : t8;
|
|
224
|
+
const renderInTrigger = t9 === undefined ? false : t9;
|
|
225
|
+
const disableFlip = t10 === undefined ? false : t10;
|
|
145
226
|
const [popperRef, setPopperRef] = useState(null);
|
|
146
|
-
const [triggerRef, setTriggerRef] = useState(
|
|
227
|
+
const [triggerRef, setTriggerRef] = useState(undefined);
|
|
147
228
|
const {
|
|
148
229
|
setContentEl,
|
|
149
230
|
scrollableStyles
|
|
150
231
|
} = useScrollableContainer();
|
|
151
|
-
const scrollableRef = useRef(null);
|
|
152
|
-
|
|
153
|
-
// So even if isOpen prop is used, the tooltip will not render on the server, and
|
|
154
|
-
// it's the same on the first client render, so there is no hydration issue.
|
|
155
|
-
|
|
156
|
-
const [isFirstRender, setIsFirstRender] = useState(true);
|
|
157
|
-
useEffect(() => {
|
|
158
|
-
setIsFirstRender(false);
|
|
159
|
-
}, []);
|
|
160
|
-
const isOpen = isFirstRender && !renderInTrigger ? false : isOpenFromProps;
|
|
232
|
+
const scrollableRef = useRef(null);
|
|
233
|
+
const isOpen = typeof triggerRef !== "undefined" || renderInTrigger ? isOpenFromProps : false;
|
|
161
234
|
const ownerDocument = triggerRef?.ownerDocument;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
235
|
+
let t11;
|
|
236
|
+
|
|
237
|
+
if ($[0] !== popperRef || $[1] !== triggerRef) {
|
|
238
|
+
t11 = [popperRef, triggerRef];
|
|
239
|
+
$[0] = popperRef;
|
|
240
|
+
$[1] = triggerRef;
|
|
241
|
+
$[2] = t11;
|
|
242
|
+
} else {
|
|
243
|
+
t11 = $[2];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const outsideClickIgnoreElements = t11;
|
|
247
|
+
let t12;
|
|
248
|
+
|
|
249
|
+
if ($[3] !== isOpen || $[4] !== onRequestClose || $[5] !== outsideClickIgnoreElements || $[6] !== ownerDocument) {
|
|
250
|
+
t12 = {
|
|
251
|
+
isEnabled: isOpen,
|
|
252
|
+
onOutsideClick: onRequestClose,
|
|
253
|
+
ignoreElements: outsideClickIgnoreElements,
|
|
254
|
+
ownerDocument
|
|
255
|
+
};
|
|
256
|
+
$[3] = isOpen;
|
|
257
|
+
$[4] = onRequestClose;
|
|
258
|
+
$[5] = outsideClickIgnoreElements;
|
|
259
|
+
$[6] = ownerDocument;
|
|
260
|
+
$[7] = t12;
|
|
261
|
+
} else {
|
|
262
|
+
t12 = $[7];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
useOnOutsideClick(t12);
|
|
266
|
+
const t13 = isOpen && closeOnEsc;
|
|
267
|
+
let t14;
|
|
268
|
+
|
|
269
|
+
if ($[8] !== onRequestClose || $[9] !== ownerDocument || $[10] !== t13) {
|
|
270
|
+
t14 = {
|
|
271
|
+
key: "Escape",
|
|
272
|
+
isEnabled: t13,
|
|
273
|
+
onKeyPress: onRequestClose,
|
|
274
|
+
ownerDocument
|
|
275
|
+
};
|
|
276
|
+
$[8] = onRequestClose;
|
|
277
|
+
$[9] = ownerDocument;
|
|
278
|
+
$[10] = t13;
|
|
279
|
+
$[11] = t14;
|
|
280
|
+
} else {
|
|
281
|
+
t14 = $[11];
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
useKeyPress(t14);
|
|
285
|
+
const t15 = isOpen && closeOnTab;
|
|
286
|
+
let t16;
|
|
287
|
+
|
|
288
|
+
if ($[12] !== onRequestClose || $[13] !== ownerDocument || $[14] !== t15) {
|
|
289
|
+
t16 = {
|
|
290
|
+
key: "Tab",
|
|
291
|
+
isEnabled: t15,
|
|
292
|
+
onKeyPress: onRequestClose,
|
|
293
|
+
ownerDocument
|
|
294
|
+
};
|
|
295
|
+
$[12] = onRequestClose;
|
|
296
|
+
$[13] = ownerDocument;
|
|
297
|
+
$[14] = t15;
|
|
298
|
+
$[15] = t16;
|
|
299
|
+
} else {
|
|
300
|
+
t16 = $[15];
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
useKeyPress(t16);
|
|
304
|
+
let t17;
|
|
305
|
+
|
|
306
|
+
if ($[16] !== disableFlip || $[17] !== leastMaxHeight || $[18] !== maxHeight || $[19] !== maxWidth || $[20] !== minWidth || $[21] !== placement) {
|
|
307
|
+
t17 = getPopperOptions({
|
|
308
|
+
placement,
|
|
309
|
+
maxHeight,
|
|
310
|
+
leastMaxHeight,
|
|
311
|
+
minWidth,
|
|
312
|
+
maxWidth,
|
|
313
|
+
disableFlip
|
|
314
|
+
});
|
|
315
|
+
$[16] = disableFlip;
|
|
316
|
+
$[17] = leastMaxHeight;
|
|
317
|
+
$[18] = maxHeight;
|
|
318
|
+
$[19] = maxWidth;
|
|
319
|
+
$[20] = minWidth;
|
|
320
|
+
$[21] = placement;
|
|
321
|
+
$[22] = t17;
|
|
322
|
+
} else {
|
|
323
|
+
t17 = $[22];
|
|
324
|
+
}
|
|
325
|
+
|
|
181
326
|
const {
|
|
182
327
|
styles: popperStyles,
|
|
183
328
|
attributes,
|
|
184
329
|
update
|
|
185
|
-
} = usePopper(triggerRef, popperRef,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
330
|
+
} = usePopper(triggerRef ?? null, popperRef, t17);
|
|
331
|
+
const resolvedPlacement = attributes.popper?.["data-popper-placement"] ?? null;
|
|
332
|
+
let t18;
|
|
333
|
+
|
|
334
|
+
if ($[23] !== cancelCloseAnimation || $[24] !== isOpen || $[25] !== popperRef || $[26] !== resolvedPlacement) {
|
|
335
|
+
t18 = {
|
|
336
|
+
isOpen,
|
|
337
|
+
cancelCloseAnimation,
|
|
338
|
+
contentRef: scrollableRef,
|
|
339
|
+
popperElement: popperRef,
|
|
340
|
+
resolvedPlacement
|
|
341
|
+
};
|
|
342
|
+
$[23] = cancelCloseAnimation;
|
|
343
|
+
$[24] = isOpen;
|
|
344
|
+
$[25] = popperRef;
|
|
345
|
+
$[26] = resolvedPlacement;
|
|
346
|
+
$[27] = t18;
|
|
347
|
+
} else {
|
|
348
|
+
t18 = $[27];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const dropdownState = useDropdownState(t18);
|
|
352
|
+
let t19;
|
|
353
|
+
|
|
354
|
+
if ($[28] !== update) {
|
|
355
|
+
t19 = () => ({
|
|
356
|
+
scheduleUpdate: () => {
|
|
357
|
+
update?.();
|
|
197
358
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
$[28] = update;
|
|
362
|
+
$[29] = t19;
|
|
363
|
+
} else {
|
|
364
|
+
t19 = $[29];
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
useImperativeHandle(externalRef, t19);
|
|
200
368
|
const {
|
|
201
369
|
dropdownZIndex
|
|
202
370
|
} = useLayeringContext();
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
"
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
// But in this specific context, because of the nature of the state-ref "triggerRef",
|
|
218
|
-
// we are sure that the dropdown wouldn't be rendered on the first client render.
|
|
219
|
-
// Therefore, the first render on the client will be the same as on the server.
|
|
220
|
-
const triggerStyles = ownerDocument?.defaultView?.getComputedStyle(triggerRef);
|
|
221
|
-
|
|
222
|
-
if (triggerStyles) {
|
|
223
|
-
themeFromCss = extractThemeFromCss(triggerStyles);
|
|
224
|
-
primaryColors = extractPrimaryColors(triggerStyles);
|
|
225
|
-
}
|
|
371
|
+
let t20;
|
|
372
|
+
|
|
373
|
+
if ($[30] !== trigger) {
|
|
374
|
+
t20 = typeof trigger === "function" ? trigger({
|
|
375
|
+
ref: setTriggerRef
|
|
376
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
377
|
+
"data-test": "dropdown-trigger",
|
|
378
|
+
className: styles.triggerWrapper,
|
|
379
|
+
ref: setTriggerRef
|
|
380
|
+
}, trigger);
|
|
381
|
+
$[30] = trigger;
|
|
382
|
+
$[31] = t20;
|
|
383
|
+
} else {
|
|
384
|
+
t20 = $[31];
|
|
226
385
|
}
|
|
227
386
|
|
|
387
|
+
const triggerRenderer = t20;
|
|
388
|
+
const dropdownShouldBeRendered = dropdownState !== DROPDOWN_STATES.CLOSE;
|
|
389
|
+
const wrapperIsInitial = dropdownState === DROPDOWN_STATES.OPENING_PREPARE;
|
|
390
|
+
const wrapperShouldBeHidden = wrapperIsInitial || dropdownState === DROPDOWN_STATES.CLOSING;
|
|
391
|
+
const {
|
|
392
|
+
primaryColors,
|
|
393
|
+
themeFromCss
|
|
394
|
+
} = useExtractCssValues(triggerRef, dropdownShouldBeRendered, ownerDocument?.defaultView);
|
|
228
395
|
const {
|
|
229
396
|
theme: themeFromContext,
|
|
230
397
|
noProvider
|
|
231
398
|
} = useContext(ThemeContext);
|
|
232
399
|
const theme = themeFromProps || (noProvider ? themeFromCss : themeFromContext);
|
|
233
|
-
|
|
234
|
-
|
|
400
|
+
let t21;
|
|
401
|
+
|
|
402
|
+
if ($[32] !== mode || $[33] !== theme) {
|
|
403
|
+
t21 = mode === "rock" ? getInverseTheme(theme) : theme;
|
|
404
|
+
$[32] = mode;
|
|
405
|
+
$[33] = theme;
|
|
406
|
+
$[34] = t21;
|
|
407
|
+
} else {
|
|
408
|
+
t21 = $[34];
|
|
409
|
+
}
|
|
235
410
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const ownerWindow = scrollableRef.current.ownerDocument.defaultView;
|
|
239
|
-
const isTransitionDisabled = ownerWindow?.getComputedStyle(scrollableRef.current).transitionDuration === '0s';
|
|
411
|
+
const childrenTheme = t21;
|
|
412
|
+
let t22;
|
|
240
413
|
|
|
241
|
-
|
|
242
|
-
|
|
414
|
+
if ($[35] !== attributes.popper || $[36] !== children || $[37] !== childrenTheme || $[38] !== className || $[39] !== disableFocusLock || $[40] !== dropdownShouldBeRendered || $[41] !== dropdownState || $[42] !== dropdownZIndex || $[43] !== maxHeight || $[44] !== mode || $[45] !== noProvider || $[46] !== ownerDocument?.body || $[47] !== popperStyles || $[48] !== primaryColors || $[49] !== renderInTrigger || $[50] !== scrollableStyles || $[51] !== setContentEl || $[52] !== theme || $[53] !== triggerRef || $[54] !== wrapperIsInitial || $[55] !== wrapperShouldBeHidden) {
|
|
415
|
+
t22 = dropdownShouldBeRendered && /*#__PURE__*/React.createElement(Portal, {
|
|
416
|
+
target: renderInTrigger ? triggerRef : ownerDocument?.body
|
|
417
|
+
}, /*#__PURE__*/React.createElement("div", _extends({
|
|
418
|
+
ref: setPopperRef,
|
|
419
|
+
style: {
|
|
420
|
+
maxHeight,
|
|
421
|
+
...popperStyles.popper,
|
|
422
|
+
zIndex: dropdownZIndex,
|
|
423
|
+
...primaryColors
|
|
424
|
+
},
|
|
425
|
+
className: cn(styles.dropdown, className, MODE_STYLES[mode], THEME_STYLES[theme]),
|
|
426
|
+
"data-test": "dropdown"
|
|
427
|
+
}, attributes.popper), /*#__PURE__*/React.createElement(LayeringProvider, {
|
|
428
|
+
baseLayer: "dropdown"
|
|
429
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
430
|
+
ref: scrollableRef,
|
|
431
|
+
style: scrollableStyles,
|
|
432
|
+
className: cn(styles.contentWrapper, wrapperIsInitial && styles.wrapperInitial, wrapperShouldBeHidden && styles.wrapperHidden),
|
|
433
|
+
"data-test": "dropdown-content"
|
|
434
|
+
}, /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
435
|
+
ignoreThemeValueForCSSApi: noProvider,
|
|
436
|
+
theme: childrenTheme
|
|
437
|
+
}, /*#__PURE__*/React.createElement(FocusLock, {
|
|
438
|
+
className: THEME_STYLES[childrenTheme],
|
|
439
|
+
ref: setContentEl,
|
|
440
|
+
disabled: dropdownState === DROPDOWN_STATES.CLOSING || disableFocusLock,
|
|
441
|
+
returnFocus: {
|
|
442
|
+
preventScroll: true
|
|
443
|
+
},
|
|
444
|
+
focusOptions: {
|
|
445
|
+
preventScroll: true
|
|
243
446
|
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
447
|
+
}, children))))));
|
|
448
|
+
$[35] = attributes.popper;
|
|
449
|
+
$[36] = children;
|
|
450
|
+
$[37] = childrenTheme;
|
|
451
|
+
$[38] = className;
|
|
452
|
+
$[39] = disableFocusLock;
|
|
453
|
+
$[40] = dropdownShouldBeRendered;
|
|
454
|
+
$[41] = dropdownState;
|
|
455
|
+
$[42] = dropdownZIndex;
|
|
456
|
+
$[43] = maxHeight;
|
|
457
|
+
$[44] = mode;
|
|
458
|
+
$[45] = noProvider;
|
|
459
|
+
$[46] = ownerDocument?.body;
|
|
460
|
+
$[47] = popperStyles;
|
|
461
|
+
$[48] = primaryColors;
|
|
462
|
+
$[49] = renderInTrigger;
|
|
463
|
+
$[50] = scrollableStyles;
|
|
464
|
+
$[51] = setContentEl;
|
|
465
|
+
$[52] = theme;
|
|
466
|
+
$[53] = triggerRef;
|
|
467
|
+
$[54] = wrapperIsInitial;
|
|
468
|
+
$[55] = wrapperShouldBeHidden;
|
|
469
|
+
$[56] = t22;
|
|
470
|
+
} else {
|
|
471
|
+
t22 = $[56];
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
let t23;
|
|
475
|
+
|
|
476
|
+
if ($[57] !== t22 || $[58] !== triggerRenderer) {
|
|
477
|
+
t23 = /*#__PURE__*/React.createElement(React.Fragment, null, triggerRenderer, t22);
|
|
478
|
+
$[57] = t22;
|
|
479
|
+
$[58] = triggerRenderer;
|
|
480
|
+
$[59] = t23;
|
|
481
|
+
} else {
|
|
482
|
+
t23 = $[59];
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
return t23;
|
|
282
486
|
};
|
|
283
487
|
/* eslint-enable react/prop-types */
|
|
284
488
|
|
|
@@ -298,4 +502,7 @@ Dropdown.propTypes = {
|
|
|
298
502
|
renderInTrigger: PropTypes.bool,
|
|
299
503
|
disableFlip: PropTypes.bool
|
|
300
504
|
};
|
|
505
|
+
|
|
506
|
+
function _temp() {}
|
|
507
|
+
|
|
301
508
|
export { Dropdown, Dropdown as default };
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"themeLight": "
|
|
3
|
-
"themeDark": "
|
|
4
|
-
"dropdown": "
|
|
5
|
-
"triggerWrapper": "
|
|
6
|
-
"contentWrapper": "
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"wrapperHidden": "_wrapperHidden_60may_110",
|
|
12
|
-
"modeClassic": "_modeClassic_60may_130",
|
|
13
|
-
"modeRock": "_modeRock_60may_134"
|
|
2
|
+
"themeLight": "_themeLight_1l8zv6n_7",
|
|
3
|
+
"themeDark": "_themeDark_1l8zv6n_10",
|
|
4
|
+
"dropdown": "_dropdown_1l8zv6n_14",
|
|
5
|
+
"triggerWrapper": "_triggerWrapper_1l8zv6n_21",
|
|
6
|
+
"contentWrapper": "_contentWrapper_1l8zv6n_25",
|
|
7
|
+
"wrapperInitial": "_wrapperInitial_1l8zv6n_41",
|
|
8
|
+
"wrapperHidden": "_wrapperHidden_1l8zv6n_45",
|
|
9
|
+
"modeClassic": "_modeClassic_1l8zv6n_65",
|
|
10
|
+
"modeRock": "_modeRock_1l8zv6n_69"
|
|
14
11
|
};
|
|
15
12
|
export { styles as default };
|
package/lib/index.css
CHANGED
|
@@ -1,58 +1,15 @@
|
|
|
1
|
-
@
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
transform:translateY(-10px);
|
|
6
|
-
}
|
|
7
|
-
100%{
|
|
8
|
-
opacity:1;
|
|
9
|
-
|
|
10
|
-
transform:none;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
@keyframes _fadeInBottomToTop_60may_1{
|
|
14
|
-
0%{
|
|
15
|
-
opacity:0;
|
|
16
|
-
|
|
17
|
-
transform:translateY(10px);
|
|
18
|
-
}
|
|
19
|
-
100%{
|
|
20
|
-
opacity:1;
|
|
21
|
-
|
|
22
|
-
transform:none;
|
|
23
|
-
}
|
|
1
|
+
@property --_rs-theme-dark-coefficient{
|
|
2
|
+
syntax:'<number>';
|
|
3
|
+
inherits:true;
|
|
4
|
+
initial-value:0;
|
|
24
5
|
}
|
|
25
|
-
|
|
26
|
-
0%{
|
|
27
|
-
opacity:0;
|
|
28
|
-
|
|
29
|
-
transform:translateX(-10px);
|
|
30
|
-
}
|
|
31
|
-
100%{
|
|
32
|
-
opacity:1;
|
|
33
|
-
|
|
34
|
-
transform:none;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
@keyframes _fadeInRightToLeft_60may_1{
|
|
38
|
-
0%{
|
|
39
|
-
opacity:0;
|
|
40
|
-
|
|
41
|
-
transform:translateX(10px);
|
|
42
|
-
}
|
|
43
|
-
100%{
|
|
44
|
-
opacity:1;
|
|
45
|
-
|
|
46
|
-
transform:none;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
._themeLight_60may_59{
|
|
6
|
+
._themeLight_1l8zv6n_7{
|
|
50
7
|
--rs-theme-dark:0;
|
|
51
8
|
}
|
|
52
|
-
.
|
|
9
|
+
._themeDark_1l8zv6n_10{
|
|
53
10
|
--rs-theme-dark:1;
|
|
54
11
|
}
|
|
55
|
-
.
|
|
12
|
+
._dropdown_1l8zv6n_14{
|
|
56
13
|
--_rs-theme-dark:var(
|
|
57
14
|
--_rs-internal-force-theme-dark-consult-rescui-before-using,
|
|
58
15
|
var(--rs-theme-dark, 0)
|
|
@@ -62,7 +19,7 @@
|
|
|
62
19
|
--_rs-theme-light-coefficient:calc(1 - var(--_rs-theme-dark-coefficient));
|
|
63
20
|
}
|
|
64
21
|
@supports (color: color-mix(in srgb, #fff 50%, #000 50%)){
|
|
65
|
-
.
|
|
22
|
+
._dropdown_1l8zv6n_14{
|
|
66
23
|
--_rs-color-primary:color-mix(in srgb, var(--rs-color-primary-light-theme, #6B57FF) calc(100%*var(--_rs-theme-light-coefficient, 1)), var(--rs-color-primary-dark-theme, #8473FF) calc(100%*var(--_rs-theme-dark-coefficient, 0)));
|
|
67
24
|
--_rs-color-primary-dim:color-mix(in srgb, var(--rs-color-primary-dim-light-theme, #8979ff) calc(100%*var(--_rs-theme-light-coefficient, 1)), var(--rs-color-primary-dim-dark-theme, #6f61d2) calc(100%*var(--_rs-theme-dark-coefficient, 0)));
|
|
68
25
|
--_rs-color-primary-fog:color-mix(in srgb, var(--rs-color-primary-fog-light-theme, #e1ddff) calc(100%*var(--_rs-theme-light-coefficient, 1)), var(--rs-color-primary-fog-dark-theme, #2e2b49) calc(100%*var(--_rs-theme-dark-coefficient, 0)));
|
|
@@ -71,7 +28,7 @@
|
|
|
71
28
|
}
|
|
72
29
|
}
|
|
73
30
|
@supports not (color: color-mix(in srgb, #fff 50%, #000 50%)){
|
|
74
|
-
.
|
|
31
|
+
._dropdown_1l8zv6n_14{
|
|
75
32
|
--_rs-color-primary:rgb(calc(var(--_rs-theme-light-coefficient, 1)*107 + var(--_rs-theme-dark-coefficient, 0)*132), calc(var(--_rs-theme-light-coefficient, 1)*87 + var(--_rs-theme-dark-coefficient, 0)*115), 255);
|
|
76
33
|
--_rs-color-primary-dim:rgb(calc(var(--_rs-theme-light-coefficient, 1)*137 + var(--_rs-theme-dark-coefficient, 0)*111), calc(var(--_rs-theme-light-coefficient, 1)*121 + var(--_rs-theme-dark-coefficient, 0)*97), calc(var(--_rs-theme-light-coefficient, 1)*255 + var(--_rs-theme-dark-coefficient, 0)*210));
|
|
77
34
|
--_rs-color-primary-fog:rgb(calc(var(--_rs-theme-light-coefficient, 1)*225 + var(--_rs-theme-dark-coefficient, 0)*46), calc(var(--_rs-theme-light-coefficient, 1)*221 + var(--_rs-theme-dark-coefficient, 0)*43), calc(var(--_rs-theme-light-coefficient, 1)*255 + var(--_rs-theme-dark-coefficient, 0)*73));
|
|
@@ -79,14 +36,14 @@
|
|
|
79
36
|
--_rs-color-primary-t-fog:rgba(calc(var(--_rs-theme-light-coefficient, 1)*107 + var(--_rs-theme-dark-coefficient, 0)*132), calc(var(--_rs-theme-light-coefficient, 1)*87 + var(--_rs-theme-dark-coefficient, 0)*115), 255, calc(var(--_rs-theme-light-coefficient, 1)*0.2 + var(--_rs-theme-dark-coefficient, 0)*0.3));
|
|
80
37
|
}
|
|
81
38
|
}
|
|
82
|
-
.
|
|
39
|
+
._dropdown_1l8zv6n_14 {
|
|
83
40
|
display:flex;
|
|
84
41
|
flex-direction:column;
|
|
85
42
|
}
|
|
86
|
-
.
|
|
43
|
+
._triggerWrapper_1l8zv6n_21{
|
|
87
44
|
display:inline-block;
|
|
88
45
|
}
|
|
89
|
-
.
|
|
46
|
+
._contentWrapper_1l8zv6n_25{
|
|
90
47
|
position:relative;
|
|
91
48
|
|
|
92
49
|
display:block;
|
|
@@ -98,42 +55,36 @@
|
|
|
98
55
|
background-clip:padding-box;
|
|
99
56
|
box-shadow:0 0 0 1px rgb(calc(209 - var(--_rs-theme-dark-coefficient, 0)*138), calc(209 - var(--_rs-theme-dark-coefficient, 0)*138), calc(210 - var(--_rs-theme-dark-coefficient, 0)*137));
|
|
100
57
|
|
|
101
|
-
transition:opacity var(--rs-transition-function,
|
|
102
|
-
}
|
|
103
|
-
[data-popper-placement^='top'] ._contentWrapper_60may_77{
|
|
104
|
-
animation:_fadeInBottomToTop_60may_1 var(--rs-transition-function, ease) 200ms;
|
|
105
|
-
}
|
|
106
|
-
[data-popper-placement^='bottom'] ._contentWrapper_60may_77{
|
|
107
|
-
animation:_fadeInTopToBottom_60may_1 var(--rs-transition-function, ease) 200ms;
|
|
58
|
+
transition:opacity var(--rs-transition-function, ease) 200ms, transform var(--rs-transition-function, ease) 200ms;
|
|
108
59
|
}
|
|
109
|
-
|
|
110
|
-
|
|
60
|
+
._wrapperInitial_1l8zv6n_41{
|
|
61
|
+
transition:none;
|
|
111
62
|
}
|
|
112
|
-
|
|
113
|
-
animation:_fadeInRightToLeft_60may_1 var(--rs-transition-function, ease) 200ms;
|
|
114
|
-
}
|
|
115
|
-
._wrapperHidden_60may_110{
|
|
63
|
+
._wrapperHidden_1l8zv6n_45{
|
|
116
64
|
opacity:0;
|
|
117
65
|
}
|
|
118
|
-
[data-popper-placement^='top'] .
|
|
66
|
+
[data-popper-placement^='top'] ._wrapperHidden_1l8zv6n_45{
|
|
119
67
|
transform:translateY(10px);
|
|
120
68
|
}
|
|
121
|
-
[data-popper-placement^='bottom'] .
|
|
69
|
+
[data-popper-placement^='bottom'] ._wrapperHidden_1l8zv6n_45{
|
|
122
70
|
transform:translateY(-10px);
|
|
123
71
|
}
|
|
124
|
-
[data-popper-placement^='right'] .
|
|
72
|
+
[data-popper-placement^='right'] ._wrapperHidden_1l8zv6n_45{
|
|
125
73
|
transform:translateX(-10px);
|
|
126
74
|
}
|
|
127
|
-
[data-popper-placement^='left'] .
|
|
75
|
+
[data-popper-placement^='left'] ._wrapperHidden_1l8zv6n_45{
|
|
128
76
|
transform:translateX(10px);
|
|
129
77
|
}
|
|
130
|
-
.
|
|
78
|
+
._modeClassic_1l8zv6n_65 ._contentWrapper_1l8zv6n_25{
|
|
131
79
|
background-color:rgb(calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*230), calc(255 - var(--_rs-theme-dark-coefficient, 0)*227));
|
|
132
80
|
}
|
|
133
|
-
.
|
|
81
|
+
._modeRock_1l8zv6n_69 ._contentWrapper_1l8zv6n_25{
|
|
134
82
|
background-color:rgb(calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(25 + var(--_rs-theme-dark-coefficient, 0)*230), calc(28 + var(--_rs-theme-dark-coefficient, 0)*227));
|
|
135
83
|
}
|
|
136
|
-
.
|
|
84
|
+
._modeClassic_1l8zv6n_65._themeDark_1l8zv6n_10 ._contentWrapper_1l8zv6n_25, ._modeRock_1l8zv6n_69._themeLight_1l8zv6n_7 ._contentWrapper_1l8zv6n_25{
|
|
85
|
+
color-scheme:dark;
|
|
86
|
+
}
|
|
87
|
+
._modeRock_1l8zv6n_69{
|
|
137
88
|
--rs-parent-color-primary-light-theme:var(--rs-color-primary-light-theme);
|
|
138
89
|
--rs-parent-color-primary-dim-light-theme:var(
|
|
139
90
|
--rs-color-primary-dim-light-theme
|
|
@@ -162,7 +113,7 @@
|
|
|
162
113
|
--rs-color-primary-t-fog-dark-theme
|
|
163
114
|
);
|
|
164
115
|
}
|
|
165
|
-
.
|
|
116
|
+
._modeRock_1l8zv6n_69 > *{
|
|
166
117
|
--rs-color-primary-dark-theme:var(--rs-parent-color-primary-light-theme);
|
|
167
118
|
--rs-color-primary-dim-dark-theme:var(
|
|
168
119
|
--rs-parent-color-primary-dim-light-theme
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
1
2
|
export declare enum DROPDOWN_STATES {
|
|
3
|
+
OPENING_PREPARE = "OPENING_PREPARE",
|
|
2
4
|
OPENING = "OPENING",
|
|
3
5
|
OPEN = "OPEN",
|
|
4
6
|
CLOSING = "CLOSING",
|
|
5
7
|
CLOSE = "CLOSE"
|
|
6
8
|
}
|
|
7
|
-
|
|
9
|
+
type UseDropdownStateOptions = {
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
cancelCloseAnimation?: boolean;
|
|
12
|
+
contentRef: RefObject<HTMLDivElement | null>;
|
|
13
|
+
popperElement: HTMLElement | null;
|
|
14
|
+
resolvedPlacement: string | null;
|
|
15
|
+
};
|
|
16
|
+
export declare function useDropdownState({ isOpen, cancelCloseAnimation, contentRef, popperElement, resolvedPlacement }: UseDropdownStateOptions): DROPDOWN_STATES;
|
|
17
|
+
export {};
|
|
@@ -1,36 +1,196 @@
|
|
|
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 DROPDOWN_TRANSITION_PROPERTIES = ['opacity', 'transform'];
|
|
6
|
+
|
|
7
|
+
const getDropdownTransition = (element, property) => element.getAnimations().find(animation => animation.transitionProperty === property);
|
|
8
|
+
|
|
3
9
|
var DROPDOWN_STATES;
|
|
4
10
|
|
|
5
11
|
(function (DROPDOWN_STATES) {
|
|
12
|
+
DROPDOWN_STATES["OPENING_PREPARE"] = "OPENING_PREPARE";
|
|
6
13
|
DROPDOWN_STATES["OPENING"] = "OPENING";
|
|
7
14
|
DROPDOWN_STATES["OPEN"] = "OPEN";
|
|
8
15
|
DROPDOWN_STATES["CLOSING"] = "CLOSING";
|
|
9
16
|
DROPDOWN_STATES["CLOSE"] = "CLOSE";
|
|
10
17
|
})(DROPDOWN_STATES || (DROPDOWN_STATES = {}));
|
|
11
18
|
|
|
12
|
-
function useDropdownState(
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
function useDropdownState(t0) {
|
|
20
|
+
const $ = c(16);
|
|
21
|
+
const {
|
|
22
|
+
isOpen,
|
|
23
|
+
cancelCloseAnimation,
|
|
24
|
+
contentRef,
|
|
25
|
+
popperElement,
|
|
26
|
+
resolvedPlacement
|
|
27
|
+
} = t0;
|
|
28
|
+
const [dropdownState, setDropdownState] = useState(isOpen ? DROPDOWN_STATES.OPENING_PREPARE : DROPDOWN_STATES.CLOSE);
|
|
29
|
+
let t1;
|
|
18
30
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
31
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
32
|
+
t1 = expectedState => {
|
|
33
|
+
setDropdownState(state => {
|
|
34
|
+
if (state !== expectedState) {
|
|
35
|
+
return state;
|
|
36
|
+
}
|
|
22
37
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
38
|
+
if (expectedState === DROPDOWN_STATES.CLOSING) {
|
|
39
|
+
return DROPDOWN_STATES.CLOSE;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (expectedState === DROPDOWN_STATES.OPENING) {
|
|
43
|
+
return DROPDOWN_STATES.OPEN;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return state;
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
$[0] = t1;
|
|
51
|
+
} else {
|
|
52
|
+
t1 = $[0];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const completeTransition = t1;
|
|
56
|
+
let t2;
|
|
57
|
+
|
|
58
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
59
|
+
t2 = () => {
|
|
60
|
+
setDropdownState(_temp);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
$[1] = t2;
|
|
64
|
+
} else {
|
|
65
|
+
t2 = $[1];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const completeOpeningPreparation = t2;
|
|
69
|
+
let t3;
|
|
70
|
+
let t4;
|
|
71
|
+
|
|
72
|
+
if ($[2] !== contentRef || $[3] !== dropdownState || $[4] !== popperElement || $[5] !== resolvedPlacement) {
|
|
73
|
+
t3 = () => {
|
|
74
|
+
const contentElement = contentRef.current;
|
|
75
|
+
|
|
76
|
+
if (dropdownState !== DROPDOWN_STATES.OPENING_PREPARE || !popperElement || !contentElement || !resolvedPlacement) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
contentElement.getBoundingClientRect();
|
|
81
|
+
completeOpeningPreparation();
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
t4 = [completeOpeningPreparation, contentRef, dropdownState, popperElement, resolvedPlacement];
|
|
85
|
+
$[2] = contentRef;
|
|
86
|
+
$[3] = dropdownState;
|
|
87
|
+
$[4] = popperElement;
|
|
88
|
+
$[5] = resolvedPlacement;
|
|
89
|
+
$[6] = t3;
|
|
90
|
+
$[7] = t4;
|
|
91
|
+
} else {
|
|
92
|
+
t3 = $[6];
|
|
93
|
+
t4 = $[7];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
useIsomorphicLayoutEffect(t3, t4);
|
|
97
|
+
let t5;
|
|
98
|
+
|
|
99
|
+
if ($[8] !== contentRef || $[9] !== dropdownState) {
|
|
100
|
+
t5 = () => {
|
|
101
|
+
if (dropdownState !== DROPDOWN_STATES.OPENING && dropdownState !== DROPDOWN_STATES.CLOSING) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const contentElement_0 = contentRef.current;
|
|
26
106
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
107
|
+
if (!contentElement_0) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let isCurrentPhase = true;
|
|
112
|
+
|
|
113
|
+
const completeCurrentPhase = () => {
|
|
114
|
+
if (isCurrentPhase) {
|
|
115
|
+
completeTransition(dropdownState);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const waitForCurrentTransition = (property, previousTransition) => {
|
|
120
|
+
if (!isCurrentPhase) {
|
|
121
|
+
return Promise.resolve();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const transition = getDropdownTransition(contentElement_0, property);
|
|
125
|
+
|
|
126
|
+
if (!transition || transition === previousTransition) {
|
|
127
|
+
return Promise.resolve();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return transition.finished.then(() => {
|
|
131
|
+
if (!isCurrentPhase) {
|
|
132
|
+
return Promise.resolve();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const replacementTransition = getDropdownTransition(contentElement_0, property);
|
|
136
|
+
|
|
137
|
+
if (replacementTransition && replacementTransition !== transition) {
|
|
138
|
+
return waitForCurrentTransition(property, transition);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return Promise.resolve();
|
|
142
|
+
}, () => waitForCurrentTransition(property, transition));
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
Promise.all(DROPDOWN_TRANSITION_PROPERTIES.map(property_0 => waitForCurrentTransition(property_0))).then(completeCurrentPhase);
|
|
146
|
+
return () => {
|
|
147
|
+
isCurrentPhase = false;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
$[8] = contentRef;
|
|
152
|
+
$[9] = dropdownState;
|
|
153
|
+
$[10] = t5;
|
|
154
|
+
} else {
|
|
155
|
+
t5 = $[10];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let t6;
|
|
159
|
+
|
|
160
|
+
if ($[11] !== contentRef || $[12] !== dropdownState || $[13] !== popperElement || $[14] !== resolvedPlacement) {
|
|
161
|
+
t6 = [completeTransition, contentRef, dropdownState, popperElement, resolvedPlacement];
|
|
162
|
+
$[11] = contentRef;
|
|
163
|
+
$[12] = dropdownState;
|
|
164
|
+
$[13] = popperElement;
|
|
165
|
+
$[14] = resolvedPlacement;
|
|
166
|
+
$[15] = t6;
|
|
167
|
+
} else {
|
|
168
|
+
t6 = $[15];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
useIsomorphicLayoutEffect(t5, t6);
|
|
172
|
+
|
|
173
|
+
if (isOpen && dropdownState === DROPDOWN_STATES.CLOSE) {
|
|
174
|
+
setDropdownState(DROPDOWN_STATES.OPENING_PREPARE);
|
|
175
|
+
} else {
|
|
176
|
+
if (isOpen && dropdownState === DROPDOWN_STATES.CLOSING) {
|
|
177
|
+
setDropdownState(DROPDOWN_STATES.OPENING);
|
|
178
|
+
} else {
|
|
179
|
+
if (!isOpen && dropdownState === DROPDOWN_STATES.OPENING_PREPARE) {
|
|
180
|
+
setDropdownState(DROPDOWN_STATES.CLOSE);
|
|
181
|
+
} else {
|
|
182
|
+
if (!isOpen && (dropdownState === DROPDOWN_STATES.OPEN || dropdownState === DROPDOWN_STATES.OPENING)) {
|
|
183
|
+
setDropdownState(cancelCloseAnimation ? DROPDOWN_STATES.CLOSE : DROPDOWN_STATES.CLOSING);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
31
187
|
}
|
|
32
188
|
|
|
33
|
-
return
|
|
189
|
+
return dropdownState;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function _temp(state_0) {
|
|
193
|
+
return state_0 === DROPDOWN_STATES.OPENING_PREPARE ? DROPDOWN_STATES.OPENING : state_0;
|
|
34
194
|
}
|
|
35
195
|
|
|
36
196
|
export { DROPDOWN_STATES, useDropdownState };
|
|
@@ -0,0 +1,78 @@
|
|
|
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(6);
|
|
26
|
+
let t0;
|
|
27
|
+
|
|
28
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
29
|
+
t0 = {
|
|
30
|
+
primaryColors: {},
|
|
31
|
+
themeFromCss: "light"
|
|
32
|
+
};
|
|
33
|
+
$[0] = t0;
|
|
34
|
+
} else {
|
|
35
|
+
t0 = $[0];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const [cssValues, setCssValues] = useState(t0);
|
|
39
|
+
let t1;
|
|
40
|
+
let t2;
|
|
41
|
+
|
|
42
|
+
if ($[1] !== defaultView || $[2] !== shouldBeRendered || $[3] !== triggerRef) {
|
|
43
|
+
t1 = () => {
|
|
44
|
+
if (triggerRef && shouldBeRendered) {
|
|
45
|
+
const triggerStyles = defaultView?.getComputedStyle(triggerRef);
|
|
46
|
+
|
|
47
|
+
if (triggerStyles) {
|
|
48
|
+
const newCssValues = {
|
|
49
|
+
primaryColors: extractPrimaryColors(triggerStyles),
|
|
50
|
+
themeFromCss: extractThemeFromCss(triggerStyles)
|
|
51
|
+
};
|
|
52
|
+
setCssValues(oldValues => {
|
|
53
|
+
if (JSON.stringify(oldValues) !== JSON.stringify(newCssValues)) {
|
|
54
|
+
return newCssValues;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return oldValues;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
t2 = [triggerRef, shouldBeRendered, defaultView];
|
|
64
|
+
$[1] = defaultView;
|
|
65
|
+
$[2] = shouldBeRendered;
|
|
66
|
+
$[3] = triggerRef;
|
|
67
|
+
$[4] = t1;
|
|
68
|
+
$[5] = t2;
|
|
69
|
+
} else {
|
|
70
|
+
t1 = $[4];
|
|
71
|
+
t2 = $[5];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
useIsomorphicLayoutEffect(t1, t2);
|
|
75
|
+
return cssValues;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export { useExtractCssValues };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { c } from 'react-compiler-runtime';
|
|
2
3
|
import { useState } from 'react';
|
|
3
4
|
import { useResizeObserver } from '@rescui/use-resize-observer';
|
|
4
5
|
|
|
@@ -14,22 +15,44 @@ function isOverflown(element) {
|
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
const useScrollableContainer = () => {
|
|
18
|
+
const $ = c(3);
|
|
17
19
|
const [contentEl, setContentEl] = useState(null);
|
|
18
20
|
const [isScrollable, setIsScrollable] = useState(false);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
let t0;
|
|
22
|
+
|
|
23
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
24
|
+
t0 = entry => {
|
|
25
|
+
const containerEl = entry.target.parentElement;
|
|
26
|
+
|
|
27
|
+
if (containerEl) {
|
|
28
|
+
setIsScrollable(isOverflown(containerEl));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
$[0] = t0;
|
|
33
|
+
} else {
|
|
34
|
+
t0 = $[0];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
useResizeObserver(contentEl, t0);
|
|
38
|
+
const t1 = isScrollable ? "scroll" : "auto";
|
|
39
|
+
let t2;
|
|
40
|
+
|
|
41
|
+
if ($[1] !== t1) {
|
|
42
|
+
const scrollableStyles = {
|
|
43
|
+
overflowY: t1
|
|
44
|
+
};
|
|
45
|
+
t2 = {
|
|
46
|
+
setContentEl,
|
|
47
|
+
scrollableStyles
|
|
48
|
+
};
|
|
49
|
+
$[1] = t1;
|
|
50
|
+
$[2] = t2;
|
|
51
|
+
} else {
|
|
52
|
+
t2 = $[2];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return t2;
|
|
33
56
|
};
|
|
34
57
|
|
|
35
58
|
export { useScrollableContainer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/dropdown",
|
|
3
|
-
"version": "0.11.1-RUI-297-Add-react-compiler-to-the-packages-build-
|
|
3
|
+
"version": "0.11.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,9 +18,10 @@
|
|
|
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-
|
|
21
|
+
"@rescui/use-resize-observer": "0.3.4-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.39+8aaaed4be",
|
|
22
22
|
"classnames": "^2.2.6",
|
|
23
23
|
"popper-max-size-modifier": "^0.2.0",
|
|
24
|
+
"react-compiler-runtime": "^1.0.0",
|
|
24
25
|
"react-focus-lock": "^2.8.1",
|
|
25
26
|
"react-popper": "^2.2.5"
|
|
26
27
|
},
|
|
@@ -31,15 +32,15 @@
|
|
|
31
32
|
"react-dom": ">=17.0.0 <20"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"@rescui/colors": "0.3.3-RUI-297-Add-react-compiler-to-the-packages-build-
|
|
35
|
-
"@rescui/icons": "1.8.3-RUI-297-Add-react-compiler-to-the-packages-build-
|
|
35
|
+
"@rescui/colors": "0.3.3-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.43+8aaaed4be",
|
|
36
|
+
"@rescui/icons": "1.8.3-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.43+8aaaed4be",
|
|
36
37
|
"@rescui/scripts": "0.5.2",
|
|
37
|
-
"@rescui/typography": "0.27.3-RUI-297-Add-react-compiler-to-the-packages-build-
|
|
38
|
+
"@rescui/typography": "0.27.3-RUI-297-Add-react-compiler-to-the-packages-build-8aaaed4be.43+8aaaed4be",
|
|
38
39
|
"@rescui/visual-regression": "0.1.4"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
42
|
"build": "rescui-scripts build"
|
|
42
43
|
},
|
|
43
44
|
"nx": {},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "8aaaed4bee650c002b7f195438380b70c31cc5a4"
|
|
45
46
|
}
|
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 };
|