@rescui/dropdown 0.15.0 → 0.15.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/auto-update.d.ts +5 -4
- package/lib/auto-update.js +14 -30
- package/lib/dropdown.p.module.css.js +1 -1
- package/lib/index.css +20 -20
- package/package.json +2 -2
package/lib/auto-update.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `autoUpdate()` that applies
|
|
3
|
-
*
|
|
4
|
-
* If it happens in the same ResizeObserver loop
|
|
5
|
-
* deliver
|
|
2
|
+
* `autoUpdate()` that applies element resizes in the next animation frame.
|
|
3
|
+
* An update can change the dropdown's size (e.g. its max-height) and its content's size,
|
|
4
|
+
* which `useScrollableContainer` observes. If it happens in the same ResizeObserver loop,
|
|
5
|
+
* the browser can't deliver those notifications and reports
|
|
6
|
+
* "ResizeObserver loop completed with undelivered notifications".
|
|
6
7
|
*/
|
|
7
8
|
export declare function autoUpdateDropdown(reference: Element, floating: HTMLElement, update: () => void): () => void;
|
package/lib/auto-update.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { autoUpdate } from '@floating-ui/react-dom';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* `autoUpdate()` that applies
|
|
5
|
-
*
|
|
6
|
-
* If it happens in the same ResizeObserver loop
|
|
7
|
-
* deliver
|
|
4
|
+
* `autoUpdate()` that applies element resizes in the next animation frame.
|
|
5
|
+
* An update can change the dropdown's size (e.g. its max-height) and its content's size,
|
|
6
|
+
* which `useScrollableContainer` observes. If it happens in the same ResizeObserver loop,
|
|
7
|
+
* the browser can't deliver those notifications and reports
|
|
8
|
+
* "ResizeObserver loop completed with undelivered notifications".
|
|
8
9
|
*/
|
|
9
10
|
function autoUpdateDropdown(reference, floating, update) {
|
|
10
11
|
// Without ResizeObserver (e.g. in JSDOM), `autoUpdate()` skips element resize updates too
|
|
@@ -14,40 +15,23 @@ function autoUpdateDropdown(reference, floating, update) {
|
|
|
14
15
|
const cleanupAutoUpdate = autoUpdate(reference, floating, update, {
|
|
15
16
|
elementResize: false
|
|
16
17
|
});
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
target
|
|
24
|
-
} = _ref;
|
|
25
|
-
return target === reference;
|
|
26
|
-
})) {
|
|
27
|
-
// Like `autoUpdate()`, stop observing the dropdown until the next frame:
|
|
28
|
-
// the new position can change its size within the same loop
|
|
29
|
-
resizeObserver.unobserve(floating);
|
|
30
|
-
cancelAnimationFrame(reobserveFrame);
|
|
31
|
-
reobserveFrame = requestAnimationFrame(() => {
|
|
32
|
-
resizeObserver.observe(floating);
|
|
18
|
+
let updateFrame = null;
|
|
19
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
20
|
+
if (updateFrame === null) {
|
|
21
|
+
updateFrame = requestAnimationFrame(() => {
|
|
22
|
+
updateFrame = null;
|
|
23
|
+
update();
|
|
33
24
|
});
|
|
34
25
|
}
|
|
35
|
-
const previousWidth = referenceWidth;
|
|
36
|
-
referenceWidth = reference.getBoundingClientRect().width;
|
|
37
|
-
if (referenceWidth !== previousWidth) {
|
|
38
|
-
cancelAnimationFrame(updateFrame);
|
|
39
|
-
updateFrame = requestAnimationFrame(update);
|
|
40
|
-
} else {
|
|
41
|
-
update();
|
|
42
|
-
}
|
|
43
26
|
});
|
|
44
27
|
resizeObserver.observe(reference);
|
|
45
28
|
resizeObserver.observe(floating);
|
|
46
29
|
return () => {
|
|
47
30
|
cleanupAutoUpdate();
|
|
48
31
|
resizeObserver.disconnect();
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
if (updateFrame !== null) {
|
|
33
|
+
cancelAnimationFrame(updateFrame);
|
|
34
|
+
}
|
|
51
35
|
};
|
|
52
36
|
}
|
|
53
37
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var styles = {"themeLight":"
|
|
1
|
+
var styles = {"themeLight":"_themeLight_x3ltd_7","themeDark":"_themeDark_x3ltd_10","dropdown":"_dropdown_x3ltd_14","triggerWrapper":"_triggerWrapper_x3ltd_21","visuallyHidden":"_visuallyHidden_x3ltd_25","contentWrapper":"_contentWrapper_x3ltd_41","wrapperInitial":"_wrapperInitial_x3ltd_57","wrapperHidden":"_wrapperHidden_x3ltd_61","modeClassic":"_modeClassic_x3ltd_81","modeRock":"_modeRock_x3ltd_85"};
|
|
2
2
|
|
|
3
3
|
export { styles as default };
|
package/lib/index.css
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
initial-value:0;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
.
|
|
7
|
+
._themeLight_x3ltd_7{
|
|
8
8
|
--rs-theme-dark:0;
|
|
9
9
|
}
|
|
10
|
-
.
|
|
10
|
+
._themeDark_x3ltd_10{
|
|
11
11
|
--rs-theme-dark:1;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.
|
|
14
|
+
._dropdown_x3ltd_14{
|
|
15
15
|
--_rs-theme-dark:var(
|
|
16
16
|
--_rs-internal-force-theme-dark-consult-rescui-before-using,
|
|
17
17
|
var(--rs-theme-dark, 0)
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
@supports (color: color-mix(in srgb, #fff 50%, #000 50%)){
|
|
25
25
|
|
|
26
|
-
.
|
|
26
|
+
._dropdown_x3ltd_14{
|
|
27
27
|
--_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)));
|
|
28
28
|
--_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)));
|
|
29
29
|
--_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)));
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
@supports not (color: color-mix(in srgb, #fff 50%, #000 50%)){
|
|
36
36
|
|
|
37
|
-
.
|
|
37
|
+
._dropdown_x3ltd_14{
|
|
38
38
|
--_rs-color-primary:rgb(calc(107 * var(--_rs-theme-light-coefficient, 1) + 132 * var(--_rs-theme-dark-coefficient, 0)), calc(87 * var(--_rs-theme-light-coefficient, 1) + 115 * var(--_rs-theme-dark-coefficient, 0)), 255);
|
|
39
39
|
--_rs-color-primary-dim:rgb(calc(137 * var(--_rs-theme-light-coefficient, 1) + 111 * var(--_rs-theme-dark-coefficient, 0)), calc(121 * var(--_rs-theme-light-coefficient, 1) + 97 * var(--_rs-theme-dark-coefficient, 0)), calc(255 * var(--_rs-theme-light-coefficient, 1) + 210 * var(--_rs-theme-dark-coefficient, 0)));
|
|
40
40
|
--_rs-color-primary-fog:rgb(calc(225 * var(--_rs-theme-light-coefficient, 1) + 46 * var(--_rs-theme-dark-coefficient, 0)), calc(221 * var(--_rs-theme-light-coefficient, 1) + 43 * var(--_rs-theme-dark-coefficient, 0)), calc(255 * var(--_rs-theme-light-coefficient, 1) + 73 * var(--_rs-theme-dark-coefficient, 0)));
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
.
|
|
46
|
+
._dropdown_x3ltd_14 {
|
|
47
47
|
display:flex;
|
|
48
48
|
flex-direction:column;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
.
|
|
51
|
+
._triggerWrapper_x3ltd_21{
|
|
52
52
|
display:inline-block;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
.
|
|
55
|
+
._visuallyHidden_x3ltd_25{
|
|
56
56
|
position:absolute;
|
|
57
57
|
|
|
58
58
|
overflow:hidden;
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
clip-path:inset(50%);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
.
|
|
71
|
+
._contentWrapper_x3ltd_41{
|
|
72
72
|
position:relative;
|
|
73
73
|
|
|
74
74
|
display:block;
|
|
@@ -83,42 +83,42 @@
|
|
|
83
83
|
transition:opacity var(--rs-transition-function, ease) 200ms, transform var(--rs-transition-function, ease) 200ms;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
.
|
|
86
|
+
._wrapperInitial_x3ltd_57{
|
|
87
87
|
transition:none;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
.
|
|
90
|
+
._wrapperHidden_x3ltd_61{
|
|
91
91
|
opacity:0;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
[data-popper-placement^='top'] .
|
|
94
|
+
[data-popper-placement^='top'] ._wrapperHidden_x3ltd_61{
|
|
95
95
|
transform:translateY(10px);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
[data-popper-placement^='bottom'] .
|
|
98
|
+
[data-popper-placement^='bottom'] ._wrapperHidden_x3ltd_61{
|
|
99
99
|
transform:translateY(-10px);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
[data-popper-placement^='right'] .
|
|
102
|
+
[data-popper-placement^='right'] ._wrapperHidden_x3ltd_61{
|
|
103
103
|
transform:translateX(-10px);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
[data-popper-placement^='left'] .
|
|
106
|
+
[data-popper-placement^='left'] ._wrapperHidden_x3ltd_61{
|
|
107
107
|
transform:translateX(10px);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
.
|
|
110
|
+
._modeClassic_x3ltd_81 ._contentWrapper_x3ltd_41{
|
|
111
111
|
background-color:rgb(calc(255 - 230 * var(--_rs-theme-dark-coefficient, 0)), calc(255 - 230 * var(--_rs-theme-dark-coefficient, 0)), calc(255 - 227 * var(--_rs-theme-dark-coefficient, 0)));
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
.
|
|
114
|
+
._modeRock_x3ltd_85 ._contentWrapper_x3ltd_41{
|
|
115
115
|
background-color:rgb(calc(25 + 230 * var(--_rs-theme-dark-coefficient, 0)), calc(25 + 230 * var(--_rs-theme-dark-coefficient, 0)), calc(28 + 227 * var(--_rs-theme-dark-coefficient, 0)));
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
.
|
|
118
|
+
._modeClassic_x3ltd_81._themeDark_x3ltd_10 ._contentWrapper_x3ltd_41, ._modeRock_x3ltd_85._themeLight_x3ltd_7 ._contentWrapper_x3ltd_41{
|
|
119
119
|
color-scheme:dark;
|
|
120
120
|
}
|
|
121
|
-
.
|
|
121
|
+
._modeRock_x3ltd_85{
|
|
122
122
|
--rs-parent-color-primary-light-theme:var(--rs-color-primary-light-theme);
|
|
123
123
|
--rs-parent-color-primary-dim-light-theme:var(
|
|
124
124
|
--rs-color-primary-dim-light-theme
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
.
|
|
151
|
+
._modeRock_x3ltd_85 > *{
|
|
152
152
|
--rs-color-primary-dark-theme:var(--rs-parent-color-primary-light-theme);
|
|
153
153
|
--rs-color-primary-dim-dark-theme:var(
|
|
154
154
|
--rs-parent-color-primary-dim-light-theme
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/dropdown",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"build": "rescui-scripts build"
|
|
41
41
|
},
|
|
42
42
|
"nx": {},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "edc876dc0d9672bd1653525e3a9569ce623d1e47"
|
|
44
44
|
}
|