@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.
@@ -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
- var DEFAULT_NO_OPTIONS_MESSAGES = {
9
+ const DEFAULT_NO_OPTIONS_MESSAGES = {
29
10
  noOptions: 'No options',
30
11
  loading: 'Loading...'
31
12
  };
32
- var PLACEHOLDER_VALUE = '__placeholder__';
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
- var isOptionsGroup = function isOptionsGroup(optionOrGroup) {
39
- return typeof optionOrGroup.options !== 'undefined';
40
- };
41
-
42
- var collectOptionGroupValues = function collectOptionGroupValues(options) {
43
- return _mapInstanceProperty(options).call(options, function (_ref) {
44
- var value = _ref.value;
45
- return value;
46
- }).join('-');
47
- };
48
-
49
- var Option = function Option(_ref2) {
50
- var value = _ref2.value,
51
- label = _ref2.label,
52
- _ref2$disabled = _ref2.disabled,
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
- var OptionGroup = function OptionGroup(_ref3) {
61
- var _ref3$options = _ref3.options,
62
- options = _ref3$options === void 0 ? [] : _ref3$options,
63
- _ref3$label = _ref3.label,
64
- label = _ref3$label === void 0 ? '' : _ref3$label,
65
- _ref3$disabled = _ref3.disabled,
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
- }, _mapInstanceProperty(options).call(options, function (_ref4) {
71
- var value = _ref4.value,
72
- optionLabel = _ref4.label,
73
- optionDisabled = _ref4.disabled;
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
- var OptionsWithGroups = function OptionsWithGroups(_ref5) {
84
- var optionsWithGroups = _ref5.optionsWithGroups;
85
- return /*#__PURE__*/React.createElement(React.Fragment, null, _mapInstanceProperty(optionsWithGroups).call(optionsWithGroups, function (optionOrGroup) {
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
- var _context;
88
-
89
- var group = optionOrGroup;
70
+ const group = optionOrGroup;
90
71
  return /*#__PURE__*/React.createElement(OptionGroup, {
91
- key: _concatInstanceProperty(_context = "group--".concat(group.label, "--")).call(_context, collectOptionGroupValues(group.options)),
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
- var option = optionOrGroup;
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
- var result = null;
90
+ let result = null;
110
91
 
111
- var checkOption = function checkOption(option) {
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(function (optionOrGroup) {
98
+ options.forEach(optionOrGroup => {
118
99
  if (isOptionsGroup(optionOrGroup)) {
119
100
  var _group$options;
120
101
 
121
- var group = optionOrGroup;
122
- (_group$options = group.options) === null || _group$options === void 0 ? void 0 : _group$options.forEach(checkOption);
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
- var _ref6 = isString(noOptionsMessage) ? _objectSpread(_objectSpread({}, DEFAULT_NO_OPTIONS_MESSAGES), {}, {
112
+ const {
113
+ noOptions,
114
+ loading
115
+ } = isString(noOptionsMessage) ? { ...DEFAULT_NO_OPTIONS_MESSAGES,
132
116
  noOptions: noOptionsMessage
133
- }) : _objectSpread(_objectSpread({}, DEFAULT_NO_OPTIONS_MESSAGES), noOptionsMessage),
134
- noOptions = _ref6.noOptions,
135
- loading = _ref6.loading;
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
- var SIZE_STYLES = {
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
- var NativeSelect = function NativeSelect(_ref7) {
151
- var _context2;
152
-
153
- var _ref7$options = _ref7.options,
154
- options = _ref7$options === void 0 ? [] : _ref7$options,
155
- _ref7$size = _ref7.size,
156
- size = _ref7$size === void 0 ? 'm' : _ref7$size,
157
- themeFromProps = _ref7.theme,
158
- _ref7$className = _ref7.className,
159
- className = _ref7$className === void 0 ? null : _ref7$className,
160
- style = _ref7.style,
161
- _ref7$value = _ref7.value,
162
- value = _ref7$value === void 0 ? undefined : _ref7$value,
163
- onChange = _ref7.onChange,
164
- placeholder = _ref7.placeholder,
165
- _ref7$isLoading = _ref7.isLoading,
166
- isLoading = _ref7$isLoading === void 0 ? false : _ref7$isLoading,
167
- _ref7$isDisabled = _ref7.isDisabled,
168
- isDisabled = _ref7$isDisabled === void 0 ? false : _ref7$isDisabled,
169
- trigger = _ref7.trigger,
170
- label = _ref7.label,
171
- note = _ref7.note,
172
- error = _ref7.error,
173
- noOptionsMessage = _ref7.noOptionsMessage,
174
- name = _ref7.name,
175
- boldLabel = _ref7.boldLabel;
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
- var optionList = /*#__PURE__*/React.createElement(OptionsWithGroups, {
193
- optionsWithGroups: placeholder !== null ? _concatInstanceProperty(_context2 = [{
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
- }]).call(_context2, _toConsumableArray(options)) : options
171
+ }, ...options] : options
198
172
  });
199
173
 
200
- var _trigger;
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: placeholder,
207
- hovered: 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: function 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: function onMouseEnter() {
238
- return setHovered(true);
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": "_sizeS_1uckog1_6",
3
- "sizeM": "_sizeM_1uckog1_9",
4
- "sizeL": "_sizeL_1uckog1_12",
5
- "main": "_main_1uckog1_16",
6
- "wrapper": "_wrapper_1uckog1_20",
7
- "select": "_select_1uckog1_24"
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 };
@@ -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
- var argsToApply;
6
- var result;
7
- var timeout = null;
8
- var previous = 0;
2
+ let argsToApply;
3
+ let result;
4
+ let timeout = null;
5
+ let previous = 0;
9
6
 
10
- var later = function later() {
7
+ const later = () => {
11
8
  previous = Number(Date.now());
12
9
  timeout = null;
13
- result = func.apply(void 0, _toConsumableArray(argsToApply));
10
+ result = func(...argsToApply);
14
11
  argsToApply = null;
15
12
  };
16
13
 
17
14
  return function () {
18
- var now = Number(Date.now());
19
- var remaining = wait - (now - previous);
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.apply(void 0, _toConsumableArray(argsToApply));
31
+ result = func(...argsToApply);
35
32
  argsToApply = null;
36
33
  } else if (!timeout) {
37
34
  timeout = setTimeout(later, remaining);