@rescui/select 0.11.7 → 0.11.9-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/_virtual/check.js +90 -21
- package/lib/_virtual/close.js +90 -21
- package/lib/_virtual/down.js +90 -21
- package/lib/_virtual/index.css.js +12 -7
- package/lib/_virtual/loading.js +106 -29
- package/lib/_virtual/warning.js +90 -21
- package/lib/common-prop-types.js +6 -6
- package/lib/index.css +287 -303
- package/lib/key-codes.js +7 -7
- package/lib/parts/common-select.p.module.css.js +12 -12
- package/lib/parts/foldable.js +158 -220
- package/lib/parts/form-trigger-wrapper.js +22 -17
- package/lib/parts/form-trigger.p.module.css.js +10 -10
- package/lib/parts/multiselect.js +132 -202
- package/lib/parts/native-select.js +85 -117
- package/lib/parts/native-select.p.module.css.js +6 -6
- package/lib/parts/throttle.js +9 -12
- package/lib/parts/trigger.js +94 -122
- package/lib/parts/trigger.p.module.css.js +27 -27
- package/lib/parts/use-observable-force-rerender.js +5 -12
- package/lib/public-api.p.css +181 -112
- package/lib/public-api.pcss +181 -112
- package/lib/select.js +118 -195
- package/lib/utils.js +44 -90
- package/package.json +12 -12
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime-corejs3/helpers/esm/toConsumableArray";
|
|
2
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
3
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
4
|
-
|
|
5
|
-
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; }
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
9
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
10
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
11
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
12
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
13
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
14
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
15
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
16
|
-
import "core-js/modules/es.object.to-string.js";
|
|
17
|
-
import "core-js/modules/es.array.join.js";
|
|
18
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
19
|
-
import "core-js/modules/es.function.name.js";
|
|
20
1
|
import React, { useState } from 'react';
|
|
21
2
|
import PropTypes from 'prop-types';
|
|
22
3
|
import cn from 'classnames';
|
|
@@ -25,52 +6,52 @@ import { nativeOptionType, nativeOptionsGroupType, noOptionsMessageType } from '
|
|
|
25
6
|
import SelectTrigger from './trigger.js';
|
|
26
7
|
import FormTriggerWrapper from './form-trigger-wrapper.js';
|
|
27
8
|
import styles from './native-select.p.module.css.js';
|
|
28
|
-
|
|
9
|
+
const DEFAULT_NO_OPTIONS_MESSAGES = {
|
|
29
10
|
noOptions: 'No options',
|
|
30
11
|
loading: 'Loading...'
|
|
31
12
|
};
|
|
32
|
-
|
|
13
|
+
const PLACEHOLDER_VALUE = '__placeholder__';
|
|
33
14
|
|
|
34
15
|
function isString(s) {
|
|
35
16
|
return Object.prototype.toString.call(s) === '[object String]';
|
|
36
17
|
}
|
|
37
18
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled;
|
|
19
|
+
const isOptionsGroup = optionOrGroup => typeof optionOrGroup.options !== 'undefined';
|
|
20
|
+
|
|
21
|
+
const collectOptionGroupValues = options => options.map(_ref => {
|
|
22
|
+
let {
|
|
23
|
+
value
|
|
24
|
+
} = _ref;
|
|
25
|
+
return value;
|
|
26
|
+
}).join('-');
|
|
27
|
+
|
|
28
|
+
const Option = _ref2 => {
|
|
29
|
+
let {
|
|
30
|
+
value,
|
|
31
|
+
label,
|
|
32
|
+
disabled = false
|
|
33
|
+
} = _ref2;
|
|
54
34
|
return /*#__PURE__*/React.createElement("option", {
|
|
55
35
|
value: value,
|
|
56
36
|
disabled: disabled
|
|
57
37
|
}, label);
|
|
58
38
|
};
|
|
59
39
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
disabled = _ref3$disabled === void 0 ? false : _ref3$disabled;
|
|
40
|
+
const OptionGroup = _ref3 => {
|
|
41
|
+
let {
|
|
42
|
+
options = [],
|
|
43
|
+
label = '',
|
|
44
|
+
disabled = false
|
|
45
|
+
} = _ref3;
|
|
67
46
|
return /*#__PURE__*/React.createElement("optgroup", {
|
|
68
47
|
label: label,
|
|
69
48
|
disabled: disabled
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
49
|
+
}, options.map(_ref4 => {
|
|
50
|
+
let {
|
|
51
|
+
value,
|
|
52
|
+
label: optionLabel,
|
|
53
|
+
disabled: optionDisabled
|
|
54
|
+
} = _ref4;
|
|
74
55
|
return /*#__PURE__*/React.createElement(Option, {
|
|
75
56
|
key: value,
|
|
76
57
|
value: value,
|
|
@@ -80,22 +61,22 @@ var OptionGroup = function OptionGroup(_ref3) {
|
|
|
80
61
|
}));
|
|
81
62
|
};
|
|
82
63
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
64
|
+
const OptionsWithGroups = _ref5 => {
|
|
65
|
+
let {
|
|
66
|
+
optionsWithGroups
|
|
67
|
+
} = _ref5;
|
|
68
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, optionsWithGroups.map(optionOrGroup => {
|
|
86
69
|
if (isOptionsGroup(optionOrGroup)) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var group = optionOrGroup;
|
|
70
|
+
const group = optionOrGroup;
|
|
90
71
|
return /*#__PURE__*/React.createElement(OptionGroup, {
|
|
91
|
-
key:
|
|
72
|
+
key: `group--${group.label}--${collectOptionGroupValues(group.options)}`,
|
|
92
73
|
options: group.options,
|
|
93
74
|
disabled: group.disabled,
|
|
94
75
|
label: group.label
|
|
95
76
|
});
|
|
96
77
|
}
|
|
97
78
|
|
|
98
|
-
|
|
79
|
+
const option = optionOrGroup;
|
|
99
80
|
return /*#__PURE__*/React.createElement(Option, {
|
|
100
81
|
key: option.value,
|
|
101
82
|
value: option.value,
|
|
@@ -106,20 +87,20 @@ var OptionsWithGroups = function OptionsWithGroups(_ref5) {
|
|
|
106
87
|
};
|
|
107
88
|
|
|
108
89
|
function findSelectedOption(options, selectedValue) {
|
|
109
|
-
|
|
90
|
+
let result = null;
|
|
110
91
|
|
|
111
|
-
|
|
92
|
+
const checkOption = option => {
|
|
112
93
|
if (result === null || option.value === selectedValue) {
|
|
113
94
|
result = option;
|
|
114
95
|
}
|
|
115
96
|
};
|
|
116
97
|
|
|
117
|
-
options.forEach(
|
|
98
|
+
options.forEach(optionOrGroup => {
|
|
118
99
|
if (isOptionsGroup(optionOrGroup)) {
|
|
119
100
|
var _group$options;
|
|
120
101
|
|
|
121
|
-
|
|
122
|
-
(_group$options = group.options) === null || _group$options === void 0
|
|
102
|
+
const group = optionOrGroup;
|
|
103
|
+
(_group$options = group.options) === null || _group$options === void 0 || _group$options.forEach(checkOption);
|
|
123
104
|
} else {
|
|
124
105
|
checkOption(optionOrGroup);
|
|
125
106
|
}
|
|
@@ -128,11 +109,14 @@ function findSelectedOption(options, selectedValue) {
|
|
|
128
109
|
}
|
|
129
110
|
|
|
130
111
|
function getNoOptionsMessage(noOptionsMessage, isLoading) {
|
|
131
|
-
|
|
112
|
+
const {
|
|
113
|
+
noOptions,
|
|
114
|
+
loading
|
|
115
|
+
} = isString(noOptionsMessage) ? { ...DEFAULT_NO_OPTIONS_MESSAGES,
|
|
132
116
|
noOptions: noOptionsMessage
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
117
|
+
} : { ...DEFAULT_NO_OPTIONS_MESSAGES,
|
|
118
|
+
...noOptionsMessage
|
|
119
|
+
};
|
|
136
120
|
|
|
137
121
|
if (isLoading) {
|
|
138
122
|
return loading;
|
|
@@ -141,70 +125,60 @@ function getNoOptionsMessage(noOptionsMessage, isLoading) {
|
|
|
141
125
|
}
|
|
142
126
|
}
|
|
143
127
|
|
|
144
|
-
|
|
128
|
+
const SIZE_STYLES = {
|
|
145
129
|
s: styles.sizeS,
|
|
146
130
|
m: styles.sizeM,
|
|
147
131
|
l: styles.sizeL
|
|
148
132
|
}; // eslint-disable-next-line complexity
|
|
149
133
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
var theme = useThemeWithUndefined(themeFromProps);
|
|
177
|
-
|
|
178
|
-
var _useState = useState(false),
|
|
179
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
180
|
-
hovered = _useState2[0],
|
|
181
|
-
setHovered = _useState2[1];
|
|
182
|
-
|
|
183
|
-
var handleChange = function handleChange(event) {
|
|
184
|
-
var newValue = event.target.value;
|
|
185
|
-
var selectedOption = findSelectedOption(options, newValue);
|
|
134
|
+
const NativeSelect = _ref6 => {
|
|
135
|
+
let {
|
|
136
|
+
options = [],
|
|
137
|
+
size = 'm',
|
|
138
|
+
theme: themeFromProps,
|
|
139
|
+
className = null,
|
|
140
|
+
style,
|
|
141
|
+
value = undefined,
|
|
142
|
+
onChange,
|
|
143
|
+
placeholder,
|
|
144
|
+
isLoading = false,
|
|
145
|
+
isDisabled = false,
|
|
146
|
+
trigger,
|
|
147
|
+
label,
|
|
148
|
+
note,
|
|
149
|
+
error,
|
|
150
|
+
noOptionsMessage,
|
|
151
|
+
name,
|
|
152
|
+
boldLabel
|
|
153
|
+
} = _ref6;
|
|
154
|
+
const theme = useThemeWithUndefined(themeFromProps);
|
|
155
|
+
const [hovered, setHovered] = useState(false);
|
|
156
|
+
|
|
157
|
+
const handleChange = event => {
|
|
158
|
+
const newValue = event.target.value;
|
|
159
|
+
const selectedOption = findSelectedOption(options, newValue);
|
|
186
160
|
|
|
187
161
|
if (onChange) {
|
|
188
162
|
onChange(selectedOption);
|
|
189
163
|
}
|
|
190
164
|
};
|
|
191
165
|
|
|
192
|
-
|
|
193
|
-
optionsWithGroups: placeholder !== null ?
|
|
166
|
+
const optionList = /*#__PURE__*/React.createElement(OptionsWithGroups, {
|
|
167
|
+
optionsWithGroups: placeholder !== null ? [{
|
|
194
168
|
value: PLACEHOLDER_VALUE,
|
|
195
169
|
label: options.length > 0 ? placeholder : getNoOptionsMessage(noOptionsMessage, isLoading),
|
|
196
170
|
disabled: true
|
|
197
|
-
}
|
|
171
|
+
}, ...options] : options
|
|
198
172
|
});
|
|
199
173
|
|
|
200
|
-
|
|
174
|
+
let _trigger;
|
|
201
175
|
|
|
202
176
|
if (trigger) {
|
|
203
177
|
_trigger = trigger({
|
|
204
178
|
selectedLabel: value === null || value === void 0 ? void 0 : value.label,
|
|
205
179
|
selectedValue: value === null || value === void 0 ? void 0 : value.value,
|
|
206
|
-
placeholder
|
|
207
|
-
hovered
|
|
180
|
+
placeholder,
|
|
181
|
+
hovered
|
|
208
182
|
});
|
|
209
183
|
} else {
|
|
210
184
|
_trigger = /*#__PURE__*/React.createElement(SelectTrigger, {
|
|
@@ -228,18 +202,12 @@ var NativeSelect = function NativeSelect(_ref7) {
|
|
|
228
202
|
error: error,
|
|
229
203
|
label: label,
|
|
230
204
|
note: note,
|
|
231
|
-
onKeyDown:
|
|
232
|
-
return false;
|
|
233
|
-
},
|
|
205
|
+
onKeyDown: () => false,
|
|
234
206
|
boldLabel: boldLabel
|
|
235
207
|
}, /*#__PURE__*/React.createElement("div", {
|
|
236
208
|
className: styles.wrapper,
|
|
237
|
-
onMouseEnter:
|
|
238
|
-
|
|
239
|
-
},
|
|
240
|
-
onMouseLeave: function onMouseLeave() {
|
|
241
|
-
return setHovered(false);
|
|
242
|
-
},
|
|
209
|
+
onMouseEnter: () => setHovered(true),
|
|
210
|
+
onMouseLeave: () => setHovered(false),
|
|
243
211
|
style: style,
|
|
244
212
|
"data-test": "native-select"
|
|
245
213
|
}, _trigger, /*#__PURE__*/React.createElement("select", {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"sizeS": "
|
|
3
|
-
"sizeM": "
|
|
4
|
-
"sizeL": "
|
|
5
|
-
"main": "
|
|
6
|
-
"wrapper": "
|
|
7
|
-
"select": "
|
|
2
|
+
"sizeS": "_sizeS_v2to2o_6",
|
|
3
|
+
"sizeM": "_sizeM_v2to2o_9",
|
|
4
|
+
"sizeL": "_sizeL_v2to2o_12",
|
|
5
|
+
"main": "_main_v2to2o_16",
|
|
6
|
+
"wrapper": "_wrapper_v2to2o_20",
|
|
7
|
+
"select": "_select_v2to2o_24"
|
|
8
8
|
};
|
|
9
9
|
export { styles as default };
|
package/lib/parts/throttle.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime-corejs3/helpers/esm/toConsumableArray";
|
|
2
|
-
import "core-js/modules/es.number.constructor.js";
|
|
3
|
-
|
|
4
1
|
function throttle(func, wait) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
let argsToApply;
|
|
3
|
+
let result;
|
|
4
|
+
let timeout = null;
|
|
5
|
+
let previous = 0;
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
const later = () => {
|
|
11
8
|
previous = Number(Date.now());
|
|
12
9
|
timeout = null;
|
|
13
|
-
result = func
|
|
10
|
+
result = func(...argsToApply);
|
|
14
11
|
argsToApply = null;
|
|
15
12
|
};
|
|
16
13
|
|
|
17
14
|
return function () {
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const now = Number(Date.now());
|
|
16
|
+
const remaining = wait - (now - previous);
|
|
20
17
|
|
|
21
18
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
22
19
|
args[_key] = arguments[_key];
|
|
@@ -31,7 +28,7 @@ function throttle(func, wait) {
|
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
previous = now;
|
|
34
|
-
result = func
|
|
31
|
+
result = func(...argsToApply);
|
|
35
32
|
argsToApply = null;
|
|
36
33
|
} else if (!timeout) {
|
|
37
34
|
timeout = setTimeout(later, remaining);
|