@rescui/dropdown 0.7.11 → 0.7.13-RUI-226-Update-card-cn-6e43cc89.60
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/css-vars-utils.js +8 -9
- package/lib/custom-modifiers.js +40 -31
- package/lib/dropdown.js +114 -173
- package/lib/index.css +44 -146
- package/lib/index.js +1 -1
- package/lib/index.p.module.css.js +12 -12
- package/lib/use-dropdown-state.js +5 -13
- package/lib/use-scrollable-container.js +12 -21
- package/package.json +9 -9
package/lib/css-vars-utils.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
var 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'];
|
|
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'];
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
PRIMARY_COLORS.forEach(
|
|
3
|
+
const extractPrimaryColors = styles => {
|
|
4
|
+
const colors = {};
|
|
5
|
+
PRIMARY_COLORS.forEach(varName => {
|
|
7
6
|
colors[varName] = styles.getPropertyValue(varName) || 'initial';
|
|
8
7
|
});
|
|
9
8
|
return colors;
|
|
@@ -11,10 +10,10 @@ var extractPrimaryColors = function extractPrimaryColors(styles) {
|
|
|
11
10
|
/** Check out `@rescui/colors/src/public-api.p.css` file */
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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);
|
|
18
17
|
return themeDarkCoefficient === 1 ? 'dark' : 'light';
|
|
19
18
|
};
|
|
20
19
|
|
package/lib/custom-modifiers.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function getMaxWidth(dropdownMaxWidth, referenceWidth) {
|
|
2
2
|
if (dropdownMaxWidth === 'trigger') {
|
|
3
|
-
return
|
|
3
|
+
return `${referenceWidth}px`;
|
|
4
4
|
} else if (typeof dropdownMaxWidth === 'number') {
|
|
5
|
-
return
|
|
5
|
+
return `${dropdownMaxWidth}px`;
|
|
6
6
|
} else if (dropdownMaxWidth) {
|
|
7
7
|
return dropdownMaxWidth;
|
|
8
8
|
}
|
|
@@ -12,11 +12,11 @@ function getMaxWidth(dropdownMaxWidth, referenceWidth) {
|
|
|
12
12
|
|
|
13
13
|
function getMinWidth(dropdownMinWidth, referenceWidth) {
|
|
14
14
|
if (dropdownMinWidth === 'trigger') {
|
|
15
|
-
return
|
|
15
|
+
return `${referenceWidth}px`;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
if (typeof dropdownMinWidth === 'number') {
|
|
19
|
-
return
|
|
19
|
+
return `${dropdownMinWidth}px`;
|
|
20
20
|
} else if (dropdownMinWidth) {
|
|
21
21
|
return dropdownMinWidth;
|
|
22
22
|
}
|
|
@@ -24,50 +24,58 @@ function getMinWidth(dropdownMinWidth, referenceWidth) {
|
|
|
24
24
|
return undefined; //rely on CSS by default
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const sameWidthModifier = {
|
|
28
28
|
name: 'sameWidth',
|
|
29
29
|
enabled: true,
|
|
30
30
|
phase: 'beforeWrite',
|
|
31
31
|
requires: ['computeStyles'],
|
|
32
|
-
fn:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
minWidth
|
|
32
|
+
fn: _ref => {
|
|
33
|
+
let {
|
|
34
|
+
state,
|
|
35
|
+
options: {
|
|
36
|
+
maxWidth,
|
|
37
|
+
minWidth
|
|
38
|
+
} = {}
|
|
39
|
+
} = _ref;
|
|
38
40
|
state.styles.popper.minWidth = getMinWidth(minWidth, state.rects.reference.width);
|
|
39
41
|
state.styles.popper.maxWidth = getMaxWidth(maxWidth, state.rects.reference.width);
|
|
40
42
|
},
|
|
41
|
-
effect:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
minWidth
|
|
43
|
+
effect: _ref2 => {
|
|
44
|
+
let {
|
|
45
|
+
state,
|
|
46
|
+
options: {
|
|
47
|
+
maxWidth,
|
|
48
|
+
minWidth
|
|
49
|
+
} = {}
|
|
50
|
+
} = _ref2;
|
|
47
51
|
state.elements.popper.style.minWidth = getMinWidth(minWidth, state.elements.reference.offsetWidth);
|
|
48
52
|
state.elements.popper.style.maxWidth = getMaxWidth(maxWidth, state.elements.reference.offsetWidth);
|
|
49
53
|
return undefined;
|
|
50
54
|
}
|
|
51
55
|
};
|
|
52
|
-
|
|
56
|
+
const applyMaxSize = {
|
|
53
57
|
name: 'applyMaxSize',
|
|
54
58
|
enabled: true,
|
|
55
59
|
phase: 'beforeWrite',
|
|
56
60
|
requires: ['maxSize'],
|
|
61
|
+
|
|
57
62
|
// eslint-disable-next-line complexity
|
|
58
|
-
fn
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
leastMaxHeight =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
fn(_ref3) {
|
|
64
|
+
let {
|
|
65
|
+
state,
|
|
66
|
+
options: {
|
|
67
|
+
leastMaxHeight = 0,
|
|
68
|
+
maxHeight = Infinity
|
|
69
|
+
}
|
|
70
|
+
} = _ref3;
|
|
71
|
+
const {
|
|
72
|
+
height
|
|
73
|
+
} = state.modifiersData.maxSize;
|
|
74
|
+
const heightLeft = height;
|
|
75
|
+
let resultHeightString;
|
|
68
76
|
|
|
69
77
|
if (maxHeight > heightLeft && heightLeft > leastMaxHeight) {
|
|
70
|
-
resultHeightString =
|
|
78
|
+
resultHeightString = `${heightLeft}px`;
|
|
71
79
|
|
|
72
80
|
if (state.styles.popper.maxHeight !== resultHeightString && state.rects.popper.height >= heightLeft) {
|
|
73
81
|
// change popper height for detectOverflow util to force flip modifier to find better placement
|
|
@@ -75,7 +83,7 @@ var applyMaxSize = {
|
|
|
75
83
|
state.reset = true;
|
|
76
84
|
}
|
|
77
85
|
} else if (heightLeft < leastMaxHeight) {
|
|
78
|
-
resultHeightString =
|
|
86
|
+
resultHeightString = `${leastMaxHeight}px`;
|
|
79
87
|
|
|
80
88
|
if (state.styles.popper.maxHeight !== resultHeightString && state.rects.popper.height >= leastMaxHeight) {
|
|
81
89
|
// change popper height for detectOverflow util to force flip modifier to find better placement
|
|
@@ -83,10 +91,11 @@ var applyMaxSize = {
|
|
|
83
91
|
state.reset = true;
|
|
84
92
|
}
|
|
85
93
|
} else {
|
|
86
|
-
resultHeightString =
|
|
94
|
+
resultHeightString = `${maxHeight}px`;
|
|
87
95
|
}
|
|
88
96
|
|
|
89
97
|
state.styles.popper.maxHeight = resultHeightString;
|
|
90
98
|
}
|
|
99
|
+
|
|
91
100
|
};
|
|
92
101
|
export { applyMaxSize, sameWidthModifier };
|
package/lib/dropdown.js
CHANGED
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
2
|
-
import "core-js/modules/es.function.name.js";
|
|
3
|
-
import "core-js/modules/es.regexp.exec.js";
|
|
4
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
5
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
6
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
7
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
8
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
9
|
-
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
10
|
-
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
11
|
-
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
12
|
-
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
13
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
14
|
-
import _toConsumableArray from "@babel/runtime-corejs3/helpers/esm/toConsumableArray";
|
|
15
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
16
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
17
|
-
|
|
18
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
19
|
-
|
|
20
|
-
function _unsupportedIterableToArray(o, minLen) { var _context2; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
21
|
-
|
|
22
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
23
|
-
|
|
24
|
-
import "core-js/modules/es.object.to-string.js";
|
|
25
|
-
|
|
26
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
29
|
-
|
|
30
1
|
import React, { useState, useImperativeHandle, useContext, useCallback, useEffect } from 'react';
|
|
31
2
|
import PropTypes from 'prop-types';
|
|
32
3
|
import cn from 'classnames';
|
|
@@ -42,13 +13,15 @@ import { applyMaxSize, sameWidthModifier } from './custom-modifiers.js';
|
|
|
42
13
|
import { extractThemeFromCss, extractPrimaryColors } from './css-vars-utils.js';
|
|
43
14
|
|
|
44
15
|
function getPopperOptions(_ref) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
16
|
+
let {
|
|
17
|
+
placement,
|
|
18
|
+
maxHeight,
|
|
19
|
+
leastMaxHeight,
|
|
20
|
+
maxWidth,
|
|
21
|
+
minWidth
|
|
22
|
+
} = _ref;
|
|
50
23
|
return {
|
|
51
|
-
placement
|
|
24
|
+
placement,
|
|
52
25
|
modifiers: [{
|
|
53
26
|
name: 'hide',
|
|
54
27
|
enabled: false
|
|
@@ -61,76 +34,65 @@ function getPopperOptions(_ref) {
|
|
|
61
34
|
options: {
|
|
62
35
|
offset: [0, 8]
|
|
63
36
|
}
|
|
64
|
-
}, maxSizeModifier,
|
|
37
|
+
}, maxSizeModifier, { ...applyMaxSize,
|
|
65
38
|
options: {
|
|
66
|
-
maxHeight
|
|
67
|
-
leastMaxHeight
|
|
39
|
+
maxHeight,
|
|
40
|
+
leastMaxHeight
|
|
68
41
|
}
|
|
69
|
-
}
|
|
42
|
+
}, { ...sameWidthModifier,
|
|
70
43
|
options: {
|
|
71
|
-
maxWidth
|
|
72
|
-
minWidth
|
|
44
|
+
maxWidth,
|
|
45
|
+
minWidth
|
|
73
46
|
}
|
|
74
|
-
}
|
|
47
|
+
}]
|
|
75
48
|
};
|
|
76
49
|
}
|
|
77
50
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
51
|
+
const Portal = _ref2 => {
|
|
52
|
+
let {
|
|
53
|
+
children,
|
|
54
|
+
target = document.body
|
|
55
|
+
} = _ref2;
|
|
82
56
|
return /*#__PURE__*/ReactDOM.createPortal(children, target);
|
|
83
57
|
};
|
|
84
58
|
|
|
85
59
|
function useOnOutsideClick(_ref3) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
99
|
-
var element = _step.value;
|
|
100
|
-
|
|
101
|
-
if (!element || e.target === element || element.contains(e.target)) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
60
|
+
let {
|
|
61
|
+
onOutsideClick,
|
|
62
|
+
isEnabled,
|
|
63
|
+
ignoreElements = []
|
|
64
|
+
} = _ref3;
|
|
65
|
+
const ignoreElementRefsExists = ignoreElements.length > 0 && ignoreElements.every(Boolean);
|
|
66
|
+
const handleDocumentClick = useCallback(e => {
|
|
67
|
+
for (const element of ignoreElements) {
|
|
68
|
+
if (!element || e.target === element || element.contains(e.target)) {
|
|
69
|
+
return;
|
|
104
70
|
}
|
|
105
|
-
} catch (err) {
|
|
106
|
-
_iterator.e(err);
|
|
107
|
-
} finally {
|
|
108
|
-
_iterator.f();
|
|
109
71
|
}
|
|
110
72
|
|
|
111
73
|
onOutsideClick();
|
|
112
|
-
},
|
|
74
|
+
}, [onOutsideClick, ...ignoreElements]); // eslint-disable-next-line consistent-return
|
|
113
75
|
|
|
114
|
-
useEffect(
|
|
76
|
+
useEffect(() => {
|
|
115
77
|
if (isEnabled && ignoreElementRefsExists) {
|
|
116
78
|
document.addEventListener('click', handleDocumentClick, true);
|
|
117
|
-
return
|
|
118
|
-
return document.removeEventListener('click', handleDocumentClick, true);
|
|
119
|
-
};
|
|
79
|
+
return () => document.removeEventListener('click', handleDocumentClick, true);
|
|
120
80
|
}
|
|
121
81
|
}, [handleDocumentClick, isEnabled, ignoreElementRefsExists]);
|
|
122
82
|
}
|
|
123
83
|
|
|
124
84
|
function useKeyPress(_ref4) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
85
|
+
let {
|
|
86
|
+
key,
|
|
87
|
+
onKeyPress,
|
|
88
|
+
isEnabled
|
|
89
|
+
} = _ref4;
|
|
90
|
+
useEffect(() => {
|
|
129
91
|
if (!isEnabled) {
|
|
130
92
|
return;
|
|
131
93
|
}
|
|
132
94
|
|
|
133
|
-
|
|
95
|
+
const keyDownHandler = e => {
|
|
134
96
|
if (e.key === key) {
|
|
135
97
|
e.preventDefault();
|
|
136
98
|
onKeyPress();
|
|
@@ -139,63 +101,48 @@ function useKeyPress(_ref4) {
|
|
|
139
101
|
|
|
140
102
|
document.addEventListener('keydown', keyDownHandler, true); // eslint-disable-next-line consistent-return
|
|
141
103
|
|
|
142
|
-
return
|
|
104
|
+
return () => {
|
|
143
105
|
document.removeEventListener('keydown', keyDownHandler, true);
|
|
144
106
|
};
|
|
145
107
|
}, [key, onKeyPress, isEnabled]);
|
|
146
108
|
}
|
|
147
109
|
|
|
148
|
-
|
|
110
|
+
const THEME_STYLES = {
|
|
149
111
|
light: styles.themeLight,
|
|
150
112
|
dark: styles.themeDark
|
|
151
113
|
};
|
|
152
|
-
|
|
114
|
+
const MODE_STYLES = {
|
|
153
115
|
classic: styles.modeClassic,
|
|
154
116
|
rock: styles.modeRock
|
|
155
117
|
};
|
|
156
118
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
var _useState = useState(null),
|
|
186
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
187
|
-
popperRef = _useState2[0],
|
|
188
|
-
setPopperRef = _useState2[1];
|
|
189
|
-
|
|
190
|
-
var _useState3 = useState(null),
|
|
191
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
192
|
-
triggerRef = _useState4[0],
|
|
193
|
-
setTriggerRef = _useState4[1];
|
|
194
|
-
|
|
195
|
-
var _useScrollableContain = useScrollableContainer(),
|
|
196
|
-
setContentEl = _useScrollableContain.setContentEl,
|
|
197
|
-
scrollableStyles = _useScrollableContain.scrollableStyles;
|
|
198
|
-
|
|
119
|
+
const DropdownRender = (_ref5, externalRef) => {
|
|
120
|
+
let {
|
|
121
|
+
children,
|
|
122
|
+
trigger,
|
|
123
|
+
theme: themeFromProps,
|
|
124
|
+
isOpen = false,
|
|
125
|
+
placement = 'bottom-start',
|
|
126
|
+
mode = 'classic',
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
128
|
+
onRequestClose = () => {},
|
|
129
|
+
minWidth,
|
|
130
|
+
maxWidth,
|
|
131
|
+
maxHeight,
|
|
132
|
+
leastMaxHeight,
|
|
133
|
+
cancelCloseAnimation = false,
|
|
134
|
+
className,
|
|
135
|
+
closeOnEsc = true,
|
|
136
|
+
closeOnTab = false,
|
|
137
|
+
disableFocusLock = false,
|
|
138
|
+
renderInTrigger = false
|
|
139
|
+
} = _ref5;
|
|
140
|
+
const [popperRef, setPopperRef] = useState(null);
|
|
141
|
+
const [triggerRef, setTriggerRef] = useState(null);
|
|
142
|
+
const {
|
|
143
|
+
setContentEl,
|
|
144
|
+
scrollableStyles
|
|
145
|
+
} = useScrollableContainer();
|
|
199
146
|
useOnOutsideClick({
|
|
200
147
|
isEnabled: isOpen,
|
|
201
148
|
onOutsideClick: onRequestClose,
|
|
@@ -211,76 +158,70 @@ var DropdownRender = function DropdownRender(_ref5, externalRef) {
|
|
|
211
158
|
isEnabled: isOpen && closeOnTab,
|
|
212
159
|
onKeyPress: onRequestClose
|
|
213
160
|
});
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
useImperativeHandle(externalRef, function () {
|
|
232
|
-
return {
|
|
233
|
-
scheduleUpdate: function scheduleUpdate() {
|
|
234
|
-
if (update) {
|
|
235
|
-
update();
|
|
236
|
-
}
|
|
161
|
+
const [handleAnimationEnd, dropdownState] = useDropdownState(isOpen, cancelCloseAnimation);
|
|
162
|
+
const {
|
|
163
|
+
styles: popperStyles,
|
|
164
|
+
attributes,
|
|
165
|
+
update
|
|
166
|
+
} = usePopper(triggerRef, popperRef, getPopperOptions({
|
|
167
|
+
placement,
|
|
168
|
+
maxHeight,
|
|
169
|
+
leastMaxHeight,
|
|
170
|
+
minWidth,
|
|
171
|
+
maxWidth
|
|
172
|
+
}));
|
|
173
|
+
useImperativeHandle(externalRef, () => ({
|
|
174
|
+
scheduleUpdate: () => {
|
|
175
|
+
if (update) {
|
|
176
|
+
update();
|
|
237
177
|
}
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
var triggerRenderer = typeof trigger === 'function' ? trigger({
|
|
178
|
+
}
|
|
179
|
+
}));
|
|
180
|
+
const {
|
|
181
|
+
dropdownZIndex
|
|
182
|
+
} = useLayeringContext();
|
|
183
|
+
const triggerRenderer = typeof trigger === 'function' ? trigger({
|
|
245
184
|
ref: setTriggerRef
|
|
246
185
|
}) : /*#__PURE__*/React.createElement("span", {
|
|
247
186
|
"data-test": "dropdown-trigger",
|
|
248
187
|
className: styles.triggerWrapper,
|
|
249
188
|
ref: setTriggerRef
|
|
250
189
|
}, trigger);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
190
|
+
const dropdownShouldBeRendered = dropdownState !== DROPDOWN_STATES.CLOSE;
|
|
191
|
+
const wrapperShouldBeHidden = dropdownState === DROPDOWN_STATES.CLOSING;
|
|
192
|
+
let primaryColors = {};
|
|
193
|
+
let themeFromCss = 'light';
|
|
255
194
|
|
|
256
195
|
if (triggerRef && dropdownShouldBeRendered) {
|
|
257
196
|
// In theory this part of the code might cause issues with SSR.
|
|
258
197
|
// But in this specific context, because of the nature of the state-ref "triggerRef",
|
|
259
198
|
// we are sure that the dropdown wouldn't be rendered on the first client render.
|
|
260
199
|
// Therefore, the first render on the client will be the same as on the server.
|
|
261
|
-
|
|
200
|
+
const triggerStyles = getComputedStyle(triggerRef);
|
|
262
201
|
themeFromCss = extractThemeFromCss(triggerStyles);
|
|
263
202
|
primaryColors = extractPrimaryColors(triggerStyles);
|
|
264
203
|
}
|
|
265
204
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
205
|
+
const {
|
|
206
|
+
theme: themeFromContext,
|
|
207
|
+
noProvider
|
|
208
|
+
} = useContext(ThemeContext);
|
|
209
|
+
const theme = themeFromProps || (noProvider ? themeFromCss : themeFromContext);
|
|
210
|
+
const childrenTheme = mode === 'rock' ? getInverseTheme(theme) : theme;
|
|
272
211
|
return /*#__PURE__*/React.createElement(React.Fragment, null, triggerRenderer, dropdownShouldBeRendered && /*#__PURE__*/React.createElement(Portal, {
|
|
273
212
|
target: renderInTrigger ? triggerRef : undefined
|
|
274
|
-
}, /*#__PURE__*/React.createElement("div",
|
|
213
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
275
214
|
ref: setPopperRef,
|
|
276
|
-
style:
|
|
277
|
-
maxHeight
|
|
278
|
-
|
|
279
|
-
zIndex: dropdownZIndex
|
|
280
|
-
|
|
215
|
+
style: {
|
|
216
|
+
maxHeight,
|
|
217
|
+
...popperStyles.popper,
|
|
218
|
+
zIndex: dropdownZIndex,
|
|
219
|
+
...primaryColors
|
|
220
|
+
},
|
|
281
221
|
className: cn(styles.dropdown, className, MODE_STYLES[mode], THEME_STYLES[theme]),
|
|
282
|
-
"data-test": "dropdown"
|
|
283
|
-
|
|
222
|
+
"data-test": "dropdown",
|
|
223
|
+
...attributes.popper
|
|
224
|
+
}, /*#__PURE__*/React.createElement(LayeringProvider, {
|
|
284
225
|
baseLayer: 'dropdown'
|
|
285
226
|
}, /*#__PURE__*/React.createElement("div", {
|
|
286
227
|
style: scrollableStyles,
|
|
@@ -306,7 +247,7 @@ var DropdownRender = function DropdownRender(_ref5, externalRef) {
|
|
|
306
247
|
/* eslint-enable react/prop-types */
|
|
307
248
|
|
|
308
249
|
|
|
309
|
-
|
|
250
|
+
const Dropdown = /*#__PURE__*/React.forwardRef(DropdownRender);
|
|
310
251
|
Dropdown.propTypes = {
|
|
311
252
|
trigger: PropTypes.oneOfType([PropTypes.element, PropTypes.func]).isRequired,
|
|
312
253
|
isOpen: PropTypes.bool.isRequired,
|
package/lib/index.css
CHANGED
|
@@ -1,138 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
@keyframes _fadeInTopToBottom_1vwuw64_1{
|
|
2
2
|
0%{
|
|
3
3
|
opacity:0;
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
transform:translateY(-10px);
|
|
8
|
-
}
|
|
9
|
-
100%{
|
|
10
|
-
opacity:1;
|
|
11
|
-
|
|
12
|
-
-webkit-transform:none;
|
|
13
|
-
|
|
14
|
-
transform:none;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
@keyframes _fadeInTopToBottom_1ezf27x_1{
|
|
18
|
-
0%{
|
|
19
|
-
opacity:0;
|
|
20
|
-
|
|
21
|
-
-webkit-transform:translateY(-10px);
|
|
22
|
-
|
|
23
|
-
transform:translateY(-10px);
|
|
24
|
-
}
|
|
25
|
-
100%{
|
|
26
|
-
opacity:1;
|
|
27
|
-
|
|
28
|
-
-webkit-transform:none;
|
|
29
|
-
|
|
30
|
-
transform:none;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
@-webkit-keyframes _fadeInBottomToTop_1ezf27x_1{
|
|
34
|
-
0%{
|
|
35
|
-
opacity:0;
|
|
36
|
-
|
|
37
|
-
-webkit-transform:translateY(10px);
|
|
38
|
-
|
|
39
|
-
transform:translateY(10px);
|
|
40
|
-
}
|
|
41
|
-
100%{
|
|
42
|
-
opacity:1;
|
|
43
|
-
|
|
44
|
-
-webkit-transform:none;
|
|
45
|
-
|
|
46
|
-
transform:none;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
@keyframes _fadeInBottomToTop_1ezf27x_1{
|
|
50
|
-
0%{
|
|
51
|
-
opacity:0;
|
|
52
|
-
|
|
53
|
-
-webkit-transform:translateY(10px);
|
|
54
|
-
|
|
55
|
-
transform:translateY(10px);
|
|
56
|
-
}
|
|
57
|
-
100%{
|
|
58
|
-
opacity:1;
|
|
59
|
-
|
|
60
|
-
-webkit-transform:none;
|
|
61
|
-
|
|
62
|
-
transform:none;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
@-webkit-keyframes _fadeInLeftToRight_1ezf27x_1{
|
|
66
|
-
0%{
|
|
67
|
-
opacity:0;
|
|
68
|
-
|
|
69
|
-
-webkit-transform:translateX(-10px);
|
|
70
|
-
|
|
71
|
-
transform:translateX(-10px);
|
|
5
|
+
transform:translateY(-10px);
|
|
72
6
|
}
|
|
73
7
|
100%{
|
|
74
8
|
opacity:1;
|
|
75
9
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
transform:none;
|
|
10
|
+
transform:none;
|
|
79
11
|
}
|
|
80
12
|
}
|
|
81
|
-
@keyframes
|
|
13
|
+
@keyframes _fadeInBottomToTop_1vwuw64_1{
|
|
82
14
|
0%{
|
|
83
15
|
opacity:0;
|
|
84
16
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
transform:translateX(-10px);
|
|
17
|
+
transform:translateY(10px);
|
|
88
18
|
}
|
|
89
19
|
100%{
|
|
90
20
|
opacity:1;
|
|
91
21
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
transform:none;
|
|
22
|
+
transform:none;
|
|
95
23
|
}
|
|
96
24
|
}
|
|
97
|
-
|
|
25
|
+
@keyframes _fadeInLeftToRight_1vwuw64_1{
|
|
98
26
|
0%{
|
|
99
27
|
opacity:0;
|
|
100
28
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
transform:translateX(10px);
|
|
29
|
+
transform:translateX(-10px);
|
|
104
30
|
}
|
|
105
31
|
100%{
|
|
106
32
|
opacity:1;
|
|
107
33
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
transform:none;
|
|
34
|
+
transform:none;
|
|
111
35
|
}
|
|
112
36
|
}
|
|
113
|
-
@keyframes
|
|
37
|
+
@keyframes _fadeInRightToLeft_1vwuw64_1{
|
|
114
38
|
0%{
|
|
115
39
|
opacity:0;
|
|
116
40
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
transform:translateX(10px);
|
|
41
|
+
transform:translateX(10px);
|
|
120
42
|
}
|
|
121
43
|
100%{
|
|
122
44
|
opacity:1;
|
|
123
45
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
transform:none;
|
|
46
|
+
transform:none;
|
|
127
47
|
}
|
|
128
48
|
}
|
|
129
|
-
.
|
|
49
|
+
._themeLight_1vwuw64_60{
|
|
130
50
|
--rs-theme-dark:0;
|
|
131
51
|
}
|
|
132
|
-
.
|
|
52
|
+
._themeDark_1vwuw64_63{
|
|
133
53
|
--rs-theme-dark:1;
|
|
134
54
|
}
|
|
135
|
-
.
|
|
55
|
+
._dropdown_1vwuw64_67{
|
|
136
56
|
--_rs-theme-dark:var(
|
|
137
57
|
--_rs-internal-force-theme-dark-consult-rescui-before-using,
|
|
138
58
|
var(--rs-theme-dark, 0)
|
|
@@ -142,7 +62,7 @@
|
|
|
142
62
|
--_rs-theme-light-coefficient:calc(1 - var(--_rs-theme-dark-coefficient));
|
|
143
63
|
}
|
|
144
64
|
@supports (color: color-mix(in srgb, #fff 50%, #000 50%)){
|
|
145
|
-
.
|
|
65
|
+
._dropdown_1vwuw64_67{
|
|
146
66
|
--_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)));
|
|
147
67
|
--_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)));
|
|
148
68
|
--_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)));
|
|
@@ -151,7 +71,7 @@
|
|
|
151
71
|
}
|
|
152
72
|
}
|
|
153
73
|
@supports not (color: color-mix(in srgb, #fff 50%, #000 50%)){
|
|
154
|
-
.
|
|
74
|
+
._dropdown_1vwuw64_67{
|
|
155
75
|
--_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);
|
|
156
76
|
--_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));
|
|
157
77
|
--_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));
|
|
@@ -159,83 +79,61 @@
|
|
|
159
79
|
--_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));
|
|
160
80
|
}
|
|
161
81
|
}
|
|
162
|
-
.
|
|
163
|
-
display:-webkit-box;
|
|
164
|
-
display:-ms-flexbox;
|
|
82
|
+
._dropdown_1vwuw64_67 {
|
|
165
83
|
display:flex;
|
|
166
|
-
-
|
|
167
|
-
-webkit-box-direction:normal;
|
|
168
|
-
-ms-flex-direction:column;
|
|
169
|
-
flex-direction:column;
|
|
84
|
+
flex-direction:column;
|
|
170
85
|
}
|
|
171
|
-
.
|
|
86
|
+
._triggerWrapper_1vwuw64_74{
|
|
172
87
|
display:inline-block;
|
|
173
88
|
}
|
|
174
|
-
.
|
|
89
|
+
._contentWrapper_1vwuw64_78{
|
|
175
90
|
position:relative;
|
|
176
91
|
|
|
177
92
|
display:block;
|
|
178
93
|
overflow-y:auto;
|
|
179
94
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
box-sizing:border-box;
|
|
95
|
+
box-sizing:border-box;
|
|
183
96
|
margin:1px;
|
|
184
97
|
|
|
185
98
|
background-clip:padding-box;
|
|
186
|
-
|
|
187
|
-
box-shadow:0 0 0 1px rgb(calc(209 - var(--_rs-theme-dark-coefficient, 0)*92), calc(209 - var(--_rs-theme-dark-coefficient, 0)*92), calc(210 - var(--_rs-theme-dark-coefficient, 0)*91));
|
|
188
|
-
|
|
189
|
-
-webkit-transition:opacity linear 200ms, -webkit-transform linear 200ms;
|
|
190
|
-
|
|
191
|
-
transition:opacity linear 200ms, -webkit-transform linear 200ms;
|
|
99
|
+
box-shadow:0 0 0 1px rgb(calc(209 - var(--_rs-theme-dark-coefficient, 0)*92), calc(209 - var(--_rs-theme-dark-coefficient, 0)*92), calc(210 - var(--_rs-theme-dark-coefficient, 0)*91));
|
|
192
100
|
|
|
193
101
|
transition:opacity linear 200ms, transform linear 200ms;
|
|
194
|
-
|
|
195
|
-
transition:opacity linear 200ms, transform linear 200ms, -webkit-transform linear 200ms;
|
|
196
102
|
}
|
|
197
|
-
[data-popper-placement^="top" ] .
|
|
198
|
-
|
|
199
|
-
animation:_fadeInBottomToTop_1ezf27x_1 ease 200ms;
|
|
103
|
+
[data-popper-placement^="top" ] ._contentWrapper_1vwuw64_78{
|
|
104
|
+
animation:_fadeInBottomToTop_1vwuw64_1 ease 200ms;
|
|
200
105
|
}
|
|
201
|
-
[data-popper-placement^="bottom" ] .
|
|
202
|
-
|
|
203
|
-
animation:_fadeInTopToBottom_1ezf27x_1 ease 200ms;
|
|
106
|
+
[data-popper-placement^="bottom" ] ._contentWrapper_1vwuw64_78{
|
|
107
|
+
animation:_fadeInTopToBottom_1vwuw64_1 ease 200ms;
|
|
204
108
|
}
|
|
205
|
-
[data-popper-placement^="right"] .
|
|
206
|
-
|
|
207
|
-
animation:_fadeInLeftToRight_1ezf27x_1 ease 200ms;
|
|
109
|
+
[data-popper-placement^="right"] ._contentWrapper_1vwuw64_78{
|
|
110
|
+
animation:_fadeInLeftToRight_1vwuw64_1 ease 200ms;
|
|
208
111
|
}
|
|
209
|
-
[data-popper-placement^="left"] .
|
|
210
|
-
|
|
211
|
-
animation:_fadeInRightToLeft_1ezf27x_1 ease 200ms;
|
|
112
|
+
[data-popper-placement^="left"] ._contentWrapper_1vwuw64_78{
|
|
113
|
+
animation:_fadeInRightToLeft_1vwuw64_1 ease 200ms;
|
|
212
114
|
}
|
|
213
|
-
.
|
|
115
|
+
._wrapperHidden_1vwuw64_109{
|
|
214
116
|
opacity:0;
|
|
215
117
|
}
|
|
216
|
-
[data-popper-placement^="top" ] .
|
|
217
|
-
|
|
218
|
-
transform:translateY(10px);
|
|
118
|
+
[data-popper-placement^="top" ] ._wrapperHidden_1vwuw64_109{
|
|
119
|
+
transform:translateY(10px);
|
|
219
120
|
}
|
|
220
|
-
[data-popper-placement^="bottom" ] .
|
|
221
|
-
|
|
222
|
-
transform:translateY(-10px);
|
|
121
|
+
[data-popper-placement^="bottom" ] ._wrapperHidden_1vwuw64_109{
|
|
122
|
+
transform:translateY(-10px);
|
|
223
123
|
}
|
|
224
|
-
[data-popper-placement^="right"] .
|
|
225
|
-
|
|
226
|
-
transform:translateX(-10px);
|
|
124
|
+
[data-popper-placement^="right"] ._wrapperHidden_1vwuw64_109{
|
|
125
|
+
transform:translateX(-10px);
|
|
227
126
|
}
|
|
228
|
-
[data-popper-placement^="left"] .
|
|
229
|
-
|
|
230
|
-
transform:translateX(10px);
|
|
127
|
+
[data-popper-placement^="left"] ._wrapperHidden_1vwuw64_109{
|
|
128
|
+
transform:translateX(10px);
|
|
231
129
|
}
|
|
232
|
-
.
|
|
130
|
+
._modeClassic_1vwuw64_129 ._contentWrapper_1vwuw64_78{
|
|
233
131
|
background-color:rgb(calc(255 - var(--_rs-theme-dark-coefficient, 0)*207), calc(255 - var(--_rs-theme-dark-coefficient, 0)*207), calc(255 - var(--_rs-theme-dark-coefficient, 0)*204));
|
|
234
132
|
}
|
|
235
|
-
.
|
|
133
|
+
._modeRock_1vwuw64_133 ._contentWrapper_1vwuw64_78{
|
|
236
134
|
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));
|
|
237
135
|
}
|
|
238
|
-
.
|
|
136
|
+
._modeRock_1vwuw64_133{
|
|
239
137
|
--rs-parent-color-primary-light-theme:var(--rs-color-primary-light-theme);
|
|
240
138
|
--rs-parent-color-primary-dim-light-theme:var(--rs-color-primary-dim-light-theme);
|
|
241
139
|
--rs-parent-color-primary-fog-light-theme:var(--rs-color-primary-fog-light-theme);
|
|
@@ -248,7 +146,7 @@
|
|
|
248
146
|
--rs-parent-color-primary-t-dim-dark-theme:var(--rs-color-primary-t-dim-dark-theme);
|
|
249
147
|
--rs-parent-color-primary-t-fog-dark-theme:var(--rs-color-primary-t-fog-dark-theme);
|
|
250
148
|
}
|
|
251
|
-
.
|
|
149
|
+
._modeRock_1vwuw64_133 > *{
|
|
252
150
|
--rs-color-primary-dark-theme:var(--rs-parent-color-primary-light-theme);
|
|
253
151
|
--rs-color-primary-dim-dark-theme:var(--rs-parent-color-primary-dim-light-theme);
|
|
254
152
|
--rs-color-primary-fog-dark-theme:var(--rs-parent-color-primary-fog-light-theme);
|
package/lib/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"themeLight": "
|
|
3
|
-
"themeDark": "
|
|
4
|
-
"dropdown": "
|
|
5
|
-
"triggerWrapper": "
|
|
6
|
-
"contentWrapper": "
|
|
7
|
-
"fadeInBottomToTop": "
|
|
8
|
-
"fadeInTopToBottom": "
|
|
9
|
-
"fadeInLeftToRight": "
|
|
10
|
-
"fadeInRightToLeft": "
|
|
11
|
-
"wrapperHidden": "
|
|
12
|
-
"modeClassic": "
|
|
13
|
-
"modeRock": "
|
|
2
|
+
"themeLight": "_themeLight_1vwuw64_60",
|
|
3
|
+
"themeDark": "_themeDark_1vwuw64_63",
|
|
4
|
+
"dropdown": "_dropdown_1vwuw64_67",
|
|
5
|
+
"triggerWrapper": "_triggerWrapper_1vwuw64_74",
|
|
6
|
+
"contentWrapper": "_contentWrapper_1vwuw64_78",
|
|
7
|
+
"fadeInBottomToTop": "_fadeInBottomToTop_1vwuw64_1",
|
|
8
|
+
"fadeInTopToBottom": "_fadeInTopToBottom_1vwuw64_1",
|
|
9
|
+
"fadeInLeftToRight": "_fadeInLeftToRight_1vwuw64_1",
|
|
10
|
+
"fadeInRightToLeft": "_fadeInRightToLeft_1vwuw64_1",
|
|
11
|
+
"wrapperHidden": "_wrapperHidden_1vwuw64_109",
|
|
12
|
+
"modeClassic": "_modeClassic_1vwuw64_129",
|
|
13
|
+
"modeRock": "_modeRock_1vwuw64_133"
|
|
14
14
|
};
|
|
15
15
|
export { styles as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
2
1
|
import { useState, useRef, useCallback } from 'react';
|
|
3
2
|
var DROPDOWN_STATES;
|
|
4
3
|
|
|
@@ -10,24 +9,17 @@ var DROPDOWN_STATES;
|
|
|
10
9
|
})(DROPDOWN_STATES || (DROPDOWN_STATES = {}));
|
|
11
10
|
|
|
12
11
|
function useDropdownState(isOpen, cancelCloseAnimation) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var stateRef = useRef(DROPDOWN_STATES.CLOSE);
|
|
18
|
-
var onAnimationEnd = useCallback(function () {
|
|
12
|
+
const [, setDummyState] = useState(false);
|
|
13
|
+
const stateRef = useRef(DROPDOWN_STATES.CLOSE);
|
|
14
|
+
const onAnimationEnd = useCallback(() => {
|
|
19
15
|
if ((stateRef.current === DROPDOWN_STATES.CLOSING || stateRef.current === DROPDOWN_STATES.OPENING) && !isOpen) {
|
|
20
16
|
stateRef.current = DROPDOWN_STATES.CLOSE; //force rerender
|
|
21
17
|
|
|
22
|
-
setDummyState(
|
|
23
|
-
return !s;
|
|
24
|
-
});
|
|
18
|
+
setDummyState(s => !s);
|
|
25
19
|
} else if (stateRef.current === DROPDOWN_STATES.OPENING && isOpen) {
|
|
26
20
|
stateRef.current = DROPDOWN_STATES.OPEN; //force rerender
|
|
27
21
|
|
|
28
|
-
setDummyState(
|
|
29
|
-
return !s;
|
|
30
|
-
});
|
|
22
|
+
setDummyState(s => !s);
|
|
31
23
|
}
|
|
32
24
|
}, [isOpen]);
|
|
33
25
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
2
1
|
import { useState, useEffect } from 'react';
|
|
3
2
|
|
|
4
3
|
function isOverflown(element) {
|
|
@@ -12,23 +11,15 @@ function isOverflown(element) {
|
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
setContentEl = _useState2[1];
|
|
20
|
-
|
|
21
|
-
var _useState3 = useState(false),
|
|
22
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
23
|
-
isScrollable = _useState4[0],
|
|
24
|
-
setIsScrollable = _useState4[1];
|
|
25
|
-
|
|
26
|
-
useEffect(function () {
|
|
14
|
+
const useScrollableContainer = () => {
|
|
15
|
+
const [contentEl, setContentEl] = useState(null);
|
|
16
|
+
const [isScrollable, setIsScrollable] = useState(false);
|
|
17
|
+
useEffect(() => {
|
|
27
18
|
if (contentEl && typeof ResizeObserver !== 'undefined') {
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
const containerEl = contentEl.parentElement;
|
|
20
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
30
21
|
// @see https://stackoverflow.com/a/58701523
|
|
31
|
-
window.requestAnimationFrame(
|
|
22
|
+
window.requestAnimationFrame(() => {
|
|
32
23
|
if (!Array.isArray(entries) || !entries.length) {
|
|
33
24
|
return;
|
|
34
25
|
}
|
|
@@ -37,20 +28,20 @@ var useScrollableContainer = function useScrollableContainer() {
|
|
|
37
28
|
});
|
|
38
29
|
});
|
|
39
30
|
resizeObserver.observe(contentEl);
|
|
40
|
-
return
|
|
31
|
+
return () => {
|
|
41
32
|
resizeObserver.disconnect();
|
|
42
33
|
};
|
|
43
34
|
} // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
44
35
|
|
|
45
36
|
|
|
46
|
-
return
|
|
37
|
+
return () => {};
|
|
47
38
|
}, [contentEl]);
|
|
48
|
-
|
|
39
|
+
const scrollableStyles = {
|
|
49
40
|
overflowY: isScrollable ? 'scroll' : 'auto'
|
|
50
41
|
};
|
|
51
42
|
return {
|
|
52
|
-
setContentEl
|
|
53
|
-
scrollableStyles
|
|
43
|
+
setContentEl,
|
|
44
|
+
scrollableStyles
|
|
54
45
|
};
|
|
55
46
|
};
|
|
56
47
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/dropdown",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.13-RUI-226-Update-card-cn-6e43cc89.60+6e43cc89",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
|
+
"module": "lib/index.js",
|
|
8
9
|
"src:main": "src/index.ts",
|
|
9
10
|
"files": [
|
|
10
11
|
"lib",
|
|
@@ -14,10 +15,9 @@
|
|
|
14
15
|
"access": "public"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
|
-
"@babel/runtime-corejs3": "^7.
|
|
18
|
+
"@babel/runtime-corejs3": "^7.26.0",
|
|
18
19
|
"@popperjs/core": "^2.9.2",
|
|
19
20
|
"classnames": "^2.2.6",
|
|
20
|
-
"core-js": "^3.9.1",
|
|
21
21
|
"popper-max-size-modifier": "^0.2.0",
|
|
22
22
|
"react-focus-lock": "^2.8.1",
|
|
23
23
|
"react-popper": "^2.2.5"
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
"react-dom": ">=16.8.0 <19"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@rescui/colors": "
|
|
33
|
-
"@rescui/icons": "
|
|
34
|
-
"@rescui/scripts": "
|
|
35
|
-
"@rescui/typography": "
|
|
36
|
-
"@rescui/visual-regression": "
|
|
32
|
+
"@rescui/colors": "0.2.7-RUI-226-Update-card-cn-6e43cc89.60+6e43cc89",
|
|
33
|
+
"@rescui/icons": "0.16.13-RUI-226-Update-card-cn-6e43cc89.60+6e43cc89",
|
|
34
|
+
"@rescui/scripts": "0.4.0",
|
|
35
|
+
"@rescui/typography": "0.19.2-RUI-226-Update-card-cn-6e43cc89.60+6e43cc89",
|
|
36
|
+
"@rescui/visual-regression": "0.1.2"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "rescui-scripts build"
|
|
40
40
|
},
|
|
41
41
|
"nx": {},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "6e43cc893fafb22b990273901bc0a070fb15761f"
|
|
43
43
|
}
|