@rescui/select 0.15.1-RUI-280-Update-select-component-separate-components-e772abaa1.56 → 0.15.1-RUI-280-Update-select-component-downshift-cd2a98813.66
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/index.css.js +12 -12
- package/lib/constants.d.ts +0 -1
- package/lib/constants.js +1 -2
- package/lib/hooks/use-a11y.d.ts +29 -0
- package/lib/hooks/use-a11y.js +53 -0
- package/lib/hooks/use-backward-compatible-id.d.ts +4 -0
- package/lib/hooks/use-backward-compatible-id.js +14 -0
- package/lib/hooks/use-label-focus.d.ts +1 -3
- package/lib/hooks/use-label-focus.js +3 -9
- package/lib/hooks/use-multi-handlers.d.ts +11 -0
- package/lib/hooks/use-multi-handlers.js +48 -0
- package/lib/hooks/use-options.d.ts +13 -0
- package/lib/hooks/use-options.js +89 -0
- package/lib/index.css +323 -371
- package/lib/multiselect.d.ts +3 -29
- package/lib/multiselect.js +249 -174
- package/lib/native-select.js +67 -46
- package/lib/parts/hidden-select.d.ts +13 -0
- package/lib/parts/hidden-select.js +45 -0
- package/lib/parts/icons.d.ts +3 -1
- package/lib/parts/icons.js +11 -14
- package/lib/parts/list-box.d.ts +7 -15
- package/lib/parts/list-box.js +50 -82
- package/lib/parts/multi-trigger.d.ts +5 -4
- package/lib/parts/multi-trigger.js +27 -15
- package/lib/parts/native-select-trigger.d.ts +6 -8
- package/lib/parts/native-select-trigger.js +14 -23
- package/lib/select-basic.d.ts +2 -2
- package/lib/select-basic.js +161 -97
- package/lib/select-searchable.d.ts +2 -2
- package/lib/select-searchable.js +208 -122
- package/lib/select.d.ts +1 -1
- package/lib/select.js +38 -31
- package/lib/styles/common.p.module.css.js +25 -24
- package/lib/styles/form-trigger.p.module.css.js +12 -12
- package/lib/styles/list-box.p.module.css.js +11 -13
- package/lib/styles/native-select-trigger.p.module.css.js +15 -14
- package/lib/styles/native-select.p.module.css.js +6 -6
- package/lib/types.d.ts +26 -27
- package/lib/utils/get-real-items-cnt.d.ts +2 -2
- package/lib/utils/get-real-items-cnt.js +8 -10
- package/lib/utils/item-to-string.d.ts +2 -0
- package/lib/utils/item-to-string.js +7 -0
- package/lib/utils/merge-props.d.ts +29 -0
- package/lib/utils/merge-props.js +106 -0
- package/package.json +13 -22
- package/lib/hooks/use-css-context-transfer.d.ts +0 -14
- package/lib/hooks/use-css-context-transfer.js +0 -40
- package/lib/hooks/use-multi-option-serialization.d.ts +0 -10
- package/lib/hooks/use-multi-option-serialization.js +0 -82
- package/lib/hooks/use-observable-force-rerender.d.ts +0 -2
- package/lib/hooks/use-observable-force-rerender.js +0 -16
- package/lib/hooks/use-option-serialization.d.ts +0 -10
- package/lib/hooks/use-option-serialization.js +0 -59
- package/lib/parts/popover.d.ts +0 -12
- package/lib/parts/popover.js +0 -64
- package/lib/parts/popup-content.d.ts +0 -19
- package/lib/parts/popup-content.js +0 -76
- package/lib/styles/popover.p.module.css.js +0 -10
- package/lib/utils/convert-options.d.ts +0 -3
- package/lib/utils/convert-options.js +0 -52
- package/lib/utils/convert-placement.d.ts +0 -3
- package/lib/utils/convert-placement.js +0 -22
- package/lib/utils/css-vars-utils.d.ts +0 -3
- package/lib/utils/css-vars-utils.js +0 -20
package/lib/select-searchable.js
CHANGED
|
@@ -1,98 +1,163 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { useComboBoxState } from '@react-stately/combobox';
|
|
5
|
-
import { HiddenSelect } from '@react-aria/select';
|
|
6
|
-
import { useComboBox } from '@react-aria/combobox';
|
|
7
|
-
import { useButton } from '@react-aria/button';
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { Dropdown } from '@rescui/dropdown';
|
|
3
|
+
import { useCombobox } from 'downshift';
|
|
8
4
|
import { useFocusRing } from '@react-aria/focus';
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
5
|
+
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
6
|
+
import { useLabelFocus } from './hooks/use-label-focus.js';
|
|
7
|
+
import { useOptions } from './hooks/use-options.js';
|
|
8
|
+
import { useA11y } from './hooks/use-a11y.js';
|
|
9
|
+
import { ListBox } from './parts/list-box.js';
|
|
11
10
|
import { Icons } from './parts/icons.js';
|
|
11
|
+
import { HiddenSelect } from './parts/hidden-select.js';
|
|
12
12
|
import { FormTriggerWrapper } from './parts/form-trigger-wrapper.js';
|
|
13
|
-
import { useLabelFocus } from './hooks/use-label-focus.js';
|
|
14
13
|
import { getEmptyMessage } from './utils/get-empty-message.js';
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const SIZE_STYLES = {
|
|
21
|
-
s: styles.sizeS,
|
|
22
|
-
m: styles.sizeM,
|
|
23
|
-
l: styles.sizeL
|
|
24
|
-
};
|
|
25
|
-
const MODE_STYLES = {
|
|
26
|
-
classic: styles.classic,
|
|
27
|
-
rock: styles.rock
|
|
28
|
-
}; // Do not use useFilter from 'react-aria' package as it's much slower for most cases
|
|
29
|
-
|
|
30
|
-
const contains = (string, substring) => {
|
|
31
|
-
var _context;
|
|
32
|
-
|
|
33
|
-
if (substring.length === 0) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return _includesInstanceProperty(_context = string.toLowerCase()).call(_context, substring.toLowerCase());
|
|
38
|
-
}; // eslint-disable-next-line complexity
|
|
39
|
-
|
|
14
|
+
import { mergeProps } from './utils/merge-props.js';
|
|
15
|
+
import { itemToString } from './utils/item-to-string.js';
|
|
16
|
+
import { getOptionValue } from './utils/get-option-value.js';
|
|
17
|
+
import { getRealItemsCnt } from './utils/get-real-items-cnt.js';
|
|
18
|
+
import styles from './styles/common.p.module.css.js'; // eslint-disable-next-line complexity
|
|
40
19
|
|
|
41
20
|
function SelectSearchable(_ref) {
|
|
42
|
-
var _state$inputValue;
|
|
43
|
-
|
|
44
21
|
let {
|
|
45
|
-
|
|
22
|
+
options,
|
|
23
|
+
value: selectedItem,
|
|
24
|
+
onChange,
|
|
25
|
+
error,
|
|
26
|
+
label,
|
|
27
|
+
note,
|
|
46
28
|
size,
|
|
47
29
|
mode,
|
|
48
30
|
theme,
|
|
49
|
-
className,
|
|
50
|
-
style,
|
|
51
|
-
isClearable,
|
|
52
|
-
isLoading,
|
|
53
31
|
placement,
|
|
54
32
|
boldLabel,
|
|
55
33
|
reserveErrorLine,
|
|
56
|
-
noOptionsMessage,
|
|
57
34
|
maxVisibleItems,
|
|
58
|
-
|
|
35
|
+
isClearable,
|
|
36
|
+
isLoading,
|
|
37
|
+
isDisabled,
|
|
38
|
+
name,
|
|
39
|
+
noOptionsMessage,
|
|
40
|
+
className,
|
|
41
|
+
id,
|
|
42
|
+
style,
|
|
43
|
+
placeholder,
|
|
44
|
+
...rest
|
|
59
45
|
} = _ref;
|
|
60
|
-
// Create state based on the incoming props
|
|
61
|
-
const state = useComboBoxState({ ...ariaProps,
|
|
62
|
-
defaultFilter: contains,
|
|
63
|
-
allowsEmptyCollection: true
|
|
64
|
-
});
|
|
65
|
-
const hasValue = state.selectedItems.length > 0; // Setup refs and get props for child elements.
|
|
66
|
-
|
|
67
46
|
const triggerRef = useRef(null);
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const popoverRef = useRef(null);
|
|
71
|
-
const {
|
|
72
|
-
labelProps,
|
|
73
|
-
buttonProps: triggerProps,
|
|
74
|
-
listBoxProps,
|
|
75
|
-
inputProps: inputPropsWithName,
|
|
76
|
-
errorMessageProps,
|
|
77
|
-
descriptionProps
|
|
78
|
-
} = useComboBox({ ...ariaProps,
|
|
79
|
-
inputRef,
|
|
80
|
-
buttonRef: triggerRef,
|
|
81
|
-
listBoxRef,
|
|
82
|
-
popoverRef
|
|
83
|
-
}, state); // Extract name from inputProps to use with HiddenSelect instead
|
|
47
|
+
const dropdownRef = useRef(null);
|
|
48
|
+
const menuRef = React.useRef(null); // use it instead of :has(.searchInput:focus)
|
|
84
49
|
|
|
50
|
+
const [inputFocused, setInputFocused] = useState(false);
|
|
85
51
|
const {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
52
|
+
flattenedOptions,
|
|
53
|
+
listBoxItems,
|
|
54
|
+
setFilterString
|
|
55
|
+
} = useOptions(options);
|
|
56
|
+
const isListBoxEmpty = getRealItemsCnt(listBoxItems) === 0;
|
|
57
|
+
const hasValue = Boolean(selectedItem);
|
|
58
|
+
const selectedMap = selectedItem ? new Map([[getOptionValue(selectedItem), selectedItem]]) : new Map();
|
|
89
59
|
const {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
60
|
+
fieldProps,
|
|
61
|
+
errorMessageProps,
|
|
62
|
+
descriptionProps,
|
|
63
|
+
baseId
|
|
64
|
+
} = useA11y({
|
|
65
|
+
prefix: 'select',
|
|
66
|
+
error,
|
|
67
|
+
description: note
|
|
68
|
+
});
|
|
69
|
+
const {
|
|
70
|
+
isOpen,
|
|
71
|
+
getToggleButtonProps,
|
|
72
|
+
getLabelProps,
|
|
73
|
+
getMenuProps,
|
|
74
|
+
getInputProps,
|
|
75
|
+
highlightedIndex,
|
|
76
|
+
getItemProps,
|
|
77
|
+
reset,
|
|
78
|
+
setInputValue
|
|
79
|
+
} = useCombobox({
|
|
80
|
+
onInputValueChange(_ref2) {
|
|
81
|
+
let {
|
|
82
|
+
inputValue,
|
|
83
|
+
type
|
|
84
|
+
} = _ref2;
|
|
85
|
+
|
|
86
|
+
if (type === useCombobox.stateChangeTypes.InputChange) {
|
|
87
|
+
setFilterString(inputValue);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
items: flattenedOptions,
|
|
92
|
+
id: baseId,
|
|
93
|
+
itemToString,
|
|
94
|
+
selectedItem,
|
|
95
|
+
// defining our scroll behavior because on the first menu render the hook
|
|
96
|
+
// doesn't know menuRef and use page as the scroll boundary
|
|
97
|
+
scrollIntoView: (listItemEl, listEl) => {
|
|
98
|
+
scrollIntoView(listItemEl, {
|
|
99
|
+
scrollMode: 'if-needed',
|
|
100
|
+
block: 'nearest',
|
|
101
|
+
boundary: listEl ?? menuRef.current
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
onSelectedItemChange: _ref3 => {
|
|
105
|
+
let {
|
|
106
|
+
selectedItem: newSelectedItem
|
|
107
|
+
} = _ref3;
|
|
108
|
+
onChange === null || onChange === void 0 || onChange(newSelectedItem);
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
isItemDisabled(item) {
|
|
112
|
+
return item && item.disabled;
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
onIsOpenChange(_ref4) {
|
|
116
|
+
let {
|
|
117
|
+
isOpen: newIsOpen,
|
|
118
|
+
selectedItem: newSelectedItem
|
|
119
|
+
} = _ref4;
|
|
120
|
+
|
|
121
|
+
if (newIsOpen) {
|
|
122
|
+
setFilterString('');
|
|
123
|
+
} else {
|
|
124
|
+
setInputValue(itemToString(newSelectedItem));
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
stateReducer(state, actionAndChanges) {
|
|
129
|
+
const {
|
|
130
|
+
changes,
|
|
131
|
+
type
|
|
132
|
+
} = actionAndChanges;
|
|
133
|
+
|
|
134
|
+
switch (type) {
|
|
135
|
+
case useCombobox.stateChangeTypes.InputKeyDownEscape:
|
|
136
|
+
if (!state.isOpen) {
|
|
137
|
+
return state;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return changes;
|
|
141
|
+
|
|
142
|
+
default:
|
|
143
|
+
return changes;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
});
|
|
148
|
+
const menuProps = getMenuProps({
|
|
149
|
+
ref: menuRef
|
|
150
|
+
}, {
|
|
151
|
+
suppressRefError: true
|
|
152
|
+
});
|
|
153
|
+
const triggerProps = getToggleButtonProps({
|
|
154
|
+
ref: triggerRef,
|
|
155
|
+
// fix screen-reader focus on an opened popup with an empty list
|
|
156
|
+
...(isOpen && isListBoxEmpty ? {
|
|
157
|
+
'aria-activedescendant': menuProps.id
|
|
158
|
+
} : {})
|
|
159
|
+
}); // use it instead of ":has(:focus-visible), :focus-visible"
|
|
160
|
+
|
|
96
161
|
const {
|
|
97
162
|
isFocusVisible,
|
|
98
163
|
focusProps
|
|
@@ -103,69 +168,90 @@ function SelectSearchable(_ref) {
|
|
|
103
168
|
isFocusedByLabel,
|
|
104
169
|
labelClickProps,
|
|
105
170
|
triggerFocusProps: labelFocusForTriggerProps
|
|
106
|
-
} = useLabelFocus(
|
|
171
|
+
} = useLabelFocus();
|
|
107
172
|
const emptyListMessage = getEmptyMessage({
|
|
108
173
|
isLoading,
|
|
109
|
-
isNothingFound:
|
|
174
|
+
isNothingFound: false,
|
|
110
175
|
noOptionsMessage
|
|
111
176
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
177
|
+
const listBoxState = {
|
|
178
|
+
selectedMap,
|
|
179
|
+
selectionMode: 'single',
|
|
180
|
+
highlightedIndex,
|
|
181
|
+
getItemProps,
|
|
182
|
+
menuProps
|
|
183
|
+
};
|
|
184
|
+
return /*#__PURE__*/React.createElement(FormTriggerWrapper, {
|
|
118
185
|
theme: theme,
|
|
119
186
|
size: size,
|
|
120
187
|
disabled: isDisabled,
|
|
121
|
-
label:
|
|
122
|
-
labelProps: mergeProps(
|
|
188
|
+
label: label,
|
|
189
|
+
labelProps: mergeProps(getLabelProps(), labelClickProps),
|
|
123
190
|
boldLabel: boldLabel,
|
|
124
|
-
error:
|
|
191
|
+
error: error,
|
|
125
192
|
reserveErrorLine: reserveErrorLine,
|
|
126
193
|
errorMessageProps: errorMessageProps,
|
|
127
|
-
note:
|
|
194
|
+
note: note,
|
|
128
195
|
descriptionProps: descriptionProps
|
|
129
196
|
}, /*#__PURE__*/React.createElement(HiddenSelect, {
|
|
130
|
-
state: state,
|
|
131
|
-
triggerRef: triggerRef,
|
|
132
|
-
label: ariaProps.label,
|
|
133
197
|
name: name,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"data-focus-visible": isFocusVisible,
|
|
140
|
-
"data-label-focused": isFocusedByLabel,
|
|
141
|
-
"data-test": "select__trigger"
|
|
142
|
-
}, /*#__PURE__*/React.createElement("input", { ...inputProps,
|
|
143
|
-
ref: inputRef,
|
|
144
|
-
className: styles.searchInput,
|
|
145
|
-
value: inputProps.value,
|
|
146
|
-
"data-test": "select__trigger_input"
|
|
147
|
-
}), /*#__PURE__*/React.createElement(Icons, {
|
|
148
|
-
isLoading: isLoading,
|
|
149
|
-
canHaveClearIcon: isClearable && !isDisabled && hasValue,
|
|
150
|
-
onClear: () => {
|
|
151
|
-
var _inputRef$current;
|
|
152
|
-
|
|
153
|
-
state.setValue(null);
|
|
154
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
|
155
|
-
},
|
|
156
|
-
triggerId: triggerProps.id
|
|
157
|
-
})), /*#__PURE__*/React.createElement(PopupContent, {
|
|
198
|
+
value: selectedItem,
|
|
199
|
+
isMultiple: false,
|
|
200
|
+
options: flattenedOptions
|
|
201
|
+
}), /*#__PURE__*/React.createElement(Dropdown, {
|
|
202
|
+
mode: mode,
|
|
158
203
|
theme: theme,
|
|
159
|
-
|
|
160
|
-
triggerRef: triggerRef,
|
|
161
|
-
popoverRef: popoverRef,
|
|
162
|
-
listBoxRef: listBoxRef,
|
|
204
|
+
ref: dropdownRef,
|
|
163
205
|
placement: placement,
|
|
206
|
+
maxWidth: "trigger",
|
|
207
|
+
minWidth: "trigger",
|
|
208
|
+
isOpen: isOpen,
|
|
209
|
+
cancelCloseAnimation: true,
|
|
210
|
+
disableFocusLock: true,
|
|
211
|
+
trigger: _ref5 => {
|
|
212
|
+
let {
|
|
213
|
+
ref: triggerRefForDropdown
|
|
214
|
+
} = _ref5;
|
|
215
|
+
return /*#__PURE__*/React.createElement("div", { ...rest,
|
|
216
|
+
...mergeProps(fieldProps, // aria-invalid & aria-describedby, rest are overridden by triggerProps
|
|
217
|
+
triggerProps, focusProps, labelFocusForTriggerProps, {
|
|
218
|
+
ref: triggerRefForDropdown
|
|
219
|
+
}),
|
|
220
|
+
className: styles.trigger,
|
|
221
|
+
"data-open": isOpen,
|
|
222
|
+
"data-has-focus-visible": isFocusVisible || inputFocused,
|
|
223
|
+
"data-label-focused": isFocusedByLabel,
|
|
224
|
+
"data-test": "select__trigger"
|
|
225
|
+
}, /*#__PURE__*/React.createElement("input", { ...getInputProps({
|
|
226
|
+
onFocus: () => setInputFocused(true),
|
|
227
|
+
onBlur: () => setInputFocused(false)
|
|
228
|
+
}),
|
|
229
|
+
// by the downshift spec, it's expected to place input near the trigger and not nest them,
|
|
230
|
+
// but we try to keep basic select and searchable similar, so that's a little hack to nest these elements
|
|
231
|
+
onClick: () => {},
|
|
232
|
+
className: styles.searchInput,
|
|
233
|
+
placeholder: placeholder,
|
|
234
|
+
"data-test": "select__trigger_input"
|
|
235
|
+
}), /*#__PURE__*/React.createElement(Icons, {
|
|
236
|
+
isLoading: isLoading,
|
|
237
|
+
canHaveClearIcon: isClearable && !isDisabled && hasValue,
|
|
238
|
+
onClear: () => {
|
|
239
|
+
var _triggerRef$current;
|
|
240
|
+
|
|
241
|
+
reset();
|
|
242
|
+
(_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 || _triggerRef$current.focus({
|
|
243
|
+
focusVisible: false
|
|
244
|
+
});
|
|
245
|
+
},
|
|
246
|
+
triggerId: triggerProps.id
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
}, /*#__PURE__*/React.createElement(ListBox, {
|
|
250
|
+
state: listBoxState,
|
|
164
251
|
size: size,
|
|
165
|
-
|
|
166
|
-
listBoxProps: listBoxProps,
|
|
252
|
+
maxVisibleItems: maxVisibleItems,
|
|
167
253
|
emptyListMessage: emptyListMessage,
|
|
168
|
-
|
|
254
|
+
items: listBoxItems
|
|
169
255
|
})));
|
|
170
256
|
}
|
|
171
257
|
|
package/lib/select.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import type { SelectProps, SelectOption, SelectOptionOrGroup } from './types';
|
|
4
4
|
export declare const Select: {
|
|
5
|
-
({ options, size, mode, theme: themeFromProps, className, style, value, onChange, placeholder, isClearable, isLoading, isDisabled, isSearchable, noOptionsMessage, error, placement, boldLabel, reserveErrorLine, note, maxVisibleItems, ...restProps }: SelectProps): JSX.Element;
|
|
5
|
+
({ options, size, mode, theme: themeFromProps, className, style, value, onChange, placeholder, isClearable, isLoading, isDisabled, isSearchable, noOptionsMessage, error, placement, boldLabel, reserveErrorLine, note, maxVisibleItems, id, ...restProps }: SelectProps): JSX.Element;
|
|
6
6
|
propTypes: {
|
|
7
7
|
className: PropTypes.Requireable<string>;
|
|
8
8
|
style: PropTypes.Requireable<object>;
|
package/lib/select.js
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
4
|
import { ErrorMessage } from '@rescui/form-field';
|
|
5
|
+
import cn from 'classnames';
|
|
6
|
+
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
6
7
|
import { optionType, optionsGroupType, noOptionsMessageType } from './common-prop-types.js';
|
|
7
|
-
import { useOptionSerialization } from './hooks/use-option-serialization.js';
|
|
8
|
-
import { convertOptions } from './utils/convert-options.js';
|
|
9
|
-
import { convertPlacement } from './utils/convert-placement.js';
|
|
10
|
-
import { getOptionValue } from './utils/get-option-value.js';
|
|
11
8
|
import { SelectBasic } from './select-basic.js';
|
|
12
9
|
import { SelectSearchable } from './select-searchable.js';
|
|
10
|
+
import styles from './styles/common.p.module.css.js';
|
|
11
|
+
const THEME_STYLES = {
|
|
12
|
+
light: styles.themeLight,
|
|
13
|
+
dark: styles.themeDark
|
|
14
|
+
};
|
|
15
|
+
const SIZE_STYLES = {
|
|
16
|
+
s: styles.sizeS,
|
|
17
|
+
m: styles.sizeM,
|
|
18
|
+
l: styles.sizeL
|
|
19
|
+
};
|
|
20
|
+
const MODE_STYLES = {
|
|
21
|
+
classic: styles.classic,
|
|
22
|
+
rock: styles.rock
|
|
23
|
+
};
|
|
13
24
|
|
|
14
25
|
const Select = _ref => {
|
|
15
26
|
let {
|
|
@@ -33,42 +44,38 @@ const Select = _ref => {
|
|
|
33
44
|
reserveErrorLine = false,
|
|
34
45
|
note,
|
|
35
46
|
maxVisibleItems = 5,
|
|
47
|
+
id,
|
|
36
48
|
...restProps
|
|
37
49
|
} = _ref;
|
|
38
50
|
const theme = useThemeWithUndefined(themeFromProps);
|
|
39
|
-
const {
|
|
40
|
-
selectedKey,
|
|
41
|
-
findOptionByKey,
|
|
42
|
-
virtualOption
|
|
43
|
-
} = useOptionSerialization(options, value);
|
|
44
|
-
|
|
45
|
-
const handleSelectionChange = key => {
|
|
46
|
-
const option = findOptionByKey(key);
|
|
47
|
-
onChange === null || onChange === void 0 || onChange(option);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
51
|
const InnerSingleComponent = isSearchable ? SelectSearchable : SelectBasic;
|
|
51
|
-
return /*#__PURE__*/React.createElement(
|
|
52
|
-
isDisabled:
|
|
53
|
-
|
|
54
|
-
onChange: handleSelectionChange,
|
|
55
|
-
placeholder: placeholder,
|
|
56
|
-
isClearable: isClearable,
|
|
57
|
-
isLoading: isLoading,
|
|
58
|
-
className: className,
|
|
52
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: cn(className, styles.root, THEME_STYLES[theme], SIZE_STYLES[size], MODE_STYLES[mode], isDisabled ? styles.disabled : styles.enabled, Boolean(error) && styles.error),
|
|
54
|
+
id: id,
|
|
59
55
|
style: style,
|
|
56
|
+
"data-test": "select"
|
|
57
|
+
}, /*#__PURE__*/React.createElement(InnerSingleComponent, { ...restProps,
|
|
58
|
+
options: options,
|
|
60
59
|
size: size,
|
|
61
60
|
mode: mode,
|
|
62
61
|
theme: theme,
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
className: className,
|
|
63
|
+
id: id,
|
|
64
|
+
style: style,
|
|
65
|
+
value: value,
|
|
66
|
+
onChange: onChange,
|
|
67
|
+
placeholder: placeholder,
|
|
68
|
+
isClearable: isClearable,
|
|
69
|
+
isLoading: isLoading,
|
|
70
|
+
isDisabled: isDisabled,
|
|
71
|
+
noOptionsMessage: noOptionsMessage,
|
|
72
|
+
error: error,
|
|
73
|
+
placement: placement,
|
|
65
74
|
boldLabel: boldLabel,
|
|
66
75
|
reserveErrorLine: reserveErrorLine,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
disabledKeys: virtualOption ? [getOptionValue(virtualOption)] : []
|
|
71
|
-
}, convertOptions(options, [virtualOption].filter(Boolean)));
|
|
76
|
+
note: note,
|
|
77
|
+
maxVisibleItems: maxVisibleItems
|
|
78
|
+
}));
|
|
72
79
|
};
|
|
73
80
|
|
|
74
81
|
Select.propTypes = {
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"themeLight": "
|
|
3
|
-
"themeDark": "
|
|
4
|
-
"sizeS": "
|
|
5
|
-
"sizeM": "
|
|
6
|
-
"sizeL": "
|
|
7
|
-
"classic": "
|
|
8
|
-
"rock": "
|
|
9
|
-
"root": "
|
|
10
|
-
"trigger": "
|
|
11
|
-
"error": "
|
|
12
|
-
"enabled": "
|
|
13
|
-
"disabled": "
|
|
14
|
-
"canBeMultiline": "
|
|
15
|
-
"iconsWrapper": "
|
|
16
|
-
"triggerText": "
|
|
17
|
-
"searchInput": "
|
|
18
|
-
"labelNotSelected": "
|
|
19
|
-
"multi": "
|
|
20
|
-
"tagsContainer": "
|
|
21
|
-
"tag": "
|
|
22
|
-
"filledTag": "
|
|
23
|
-
"toggle": "
|
|
24
|
-
"icon": "
|
|
25
|
-
"clearIcon": "
|
|
2
|
+
"themeLight": "_themeLight_kb0k7d_6",
|
|
3
|
+
"themeDark": "_themeDark_kb0k7d_9",
|
|
4
|
+
"sizeS": "_sizeS_kb0k7d_13",
|
|
5
|
+
"sizeM": "_sizeM_kb0k7d_16",
|
|
6
|
+
"sizeL": "_sizeL_kb0k7d_19",
|
|
7
|
+
"classic": "_classic_kb0k7d_23",
|
|
8
|
+
"rock": "_rock_kb0k7d_26",
|
|
9
|
+
"root": "_root_kb0k7d_30",
|
|
10
|
+
"trigger": "_trigger_kb0k7d_36",
|
|
11
|
+
"error": "_error_kb0k7d_69",
|
|
12
|
+
"enabled": "_enabled_kb0k7d_74",
|
|
13
|
+
"disabled": "_disabled_kb0k7d_78",
|
|
14
|
+
"canBeMultiline": "_canBeMultiline_kb0k7d_115",
|
|
15
|
+
"iconsWrapper": "_iconsWrapper_kb0k7d_119",
|
|
16
|
+
"triggerText": "_triggerText_kb0k7d_134",
|
|
17
|
+
"searchInput": "_searchInput_kb0k7d_140",
|
|
18
|
+
"labelNotSelected": "_labelNotSelected_kb0k7d_184",
|
|
19
|
+
"multi": "_multi_kb0k7d_198",
|
|
20
|
+
"tagsContainer": "_tagsContainer_kb0k7d_214",
|
|
21
|
+
"tag": "_tag_kb0k7d_214",
|
|
22
|
+
"filledTag": "_filledTag_kb0k7d_236",
|
|
23
|
+
"toggle": "_toggle_kb0k7d_244",
|
|
24
|
+
"icon": "_icon_kb0k7d_119",
|
|
25
|
+
"clearIcon": "_clearIcon_kb0k7d_311",
|
|
26
|
+
"hiddenSelect": "_hiddenSelect_kb0k7d_368"
|
|
26
27
|
};
|
|
27
28
|
export { styles as default };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"themeLight": "
|
|
3
|
-
"themeDark": "
|
|
4
|
-
"sizeS": "
|
|
5
|
-
"sizeM": "
|
|
6
|
-
"sizeL": "
|
|
7
|
-
"main": "
|
|
8
|
-
"label": "
|
|
9
|
-
"disabled": "
|
|
10
|
-
"footer": "
|
|
11
|
-
"errorMessage": "
|
|
12
|
-
"error": "
|
|
13
|
-
"note": "
|
|
2
|
+
"themeLight": "_themeLight_lkq6p4_6",
|
|
3
|
+
"themeDark": "_themeDark_lkq6p4_9",
|
|
4
|
+
"sizeS": "_sizeS_lkq6p4_13",
|
|
5
|
+
"sizeM": "_sizeM_lkq6p4_16",
|
|
6
|
+
"sizeL": "_sizeL_lkq6p4_19",
|
|
7
|
+
"main": "_main_lkq6p4_23",
|
|
8
|
+
"label": "_label_lkq6p4_27",
|
|
9
|
+
"disabled": "_disabled_lkq6p4_33",
|
|
10
|
+
"footer": "_footer_lkq6p4_38",
|
|
11
|
+
"errorMessage": "_errorMessage_lkq6p4_45",
|
|
12
|
+
"error": "_error_lkq6p4_45",
|
|
13
|
+
"note": "_note_lkq6p4_54"
|
|
14
14
|
};
|
|
15
15
|
export { styles as default };
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"sizeS": "
|
|
3
|
-
"sizeM": "
|
|
4
|
-
"sizeL": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"divider": "_divider_xturi0_114",
|
|
14
|
-
"groupHeader": "_groupHeader_xturi0_128"
|
|
2
|
+
"sizeS": "_sizeS_nz7l8y_6",
|
|
3
|
+
"sizeM": "_sizeM_nz7l8y_9",
|
|
4
|
+
"sizeL": "_sizeL_nz7l8y_12",
|
|
5
|
+
"listBox": "_listBox_nz7l8y_16",
|
|
6
|
+
"item": "_item_nz7l8y_30",
|
|
7
|
+
"selected": "_selected_nz7l8y_76",
|
|
8
|
+
"disabled": "_disabled_nz7l8y_87",
|
|
9
|
+
"checkIcon": "_checkIcon_nz7l8y_94",
|
|
10
|
+
"visible": "_visible_nz7l8y_101",
|
|
11
|
+
"divider": "_divider_nz7l8y_108",
|
|
12
|
+
"groupHeader": "_groupHeader_nz7l8y_122"
|
|
15
13
|
};
|
|
16
14
|
export { styles as default };
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"themeLight": "
|
|
3
|
-
"themeDark": "
|
|
4
|
-
"sizeS": "
|
|
5
|
-
"sizeM": "
|
|
6
|
-
"sizeL": "
|
|
7
|
-
"trigger": "
|
|
8
|
-
"error": "
|
|
9
|
-
"enabled": "
|
|
10
|
-
"disabled": "
|
|
11
|
-
"iconsWrapper": "
|
|
12
|
-
"triggerText": "
|
|
13
|
-
"labelNotSelected": "
|
|
14
|
-
"toggle": "
|
|
15
|
-
"icon": "
|
|
2
|
+
"themeLight": "_themeLight_3v0lc_6",
|
|
3
|
+
"themeDark": "_themeDark_3v0lc_9",
|
|
4
|
+
"sizeS": "_sizeS_3v0lc_13",
|
|
5
|
+
"sizeM": "_sizeM_3v0lc_16",
|
|
6
|
+
"sizeL": "_sizeL_3v0lc_19",
|
|
7
|
+
"trigger": "_trigger_3v0lc_23",
|
|
8
|
+
"error": "_error_3v0lc_61",
|
|
9
|
+
"enabled": "_enabled_3v0lc_66",
|
|
10
|
+
"disabled": "_disabled_3v0lc_70",
|
|
11
|
+
"iconsWrapper": "_iconsWrapper_3v0lc_104",
|
|
12
|
+
"triggerText": "_triggerText_3v0lc_119",
|
|
13
|
+
"labelNotSelected": "_labelNotSelected_3v0lc_145",
|
|
14
|
+
"toggle": "_toggle_3v0lc_156",
|
|
15
|
+
"icon": "_icon_3v0lc_104",
|
|
16
|
+
"clearIcon": "_clearIcon_3v0lc_218"
|
|
16
17
|
};
|
|
17
18
|
export { styles as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"sizeS": "
|
|
3
|
-
"sizeM": "
|
|
4
|
-
"sizeL": "
|
|
5
|
-
"main": "
|
|
6
|
-
"wrapper": "
|
|
7
|
-
"select": "
|
|
2
|
+
"sizeS": "_sizeS_ngrfhd_6",
|
|
3
|
+
"sizeM": "_sizeM_ngrfhd_9",
|
|
4
|
+
"sizeL": "_sizeL_ngrfhd_12",
|
|
5
|
+
"main": "_main_ngrfhd_16",
|
|
6
|
+
"wrapper": "_wrapper_ngrfhd_20",
|
|
7
|
+
"select": "_select_ngrfhd_24"
|
|
8
8
|
};
|
|
9
9
|
export { styles as default };
|