@rescui/select 0.15.1-RUI-280-Update-select-component-downshift-2f40ef205.67 → 0.15.2
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/common-prop-types.d.ts +14 -9
- package/lib/common-prop-types.js +3 -4
- package/lib/index.css +432 -808
- package/lib/index.d.ts +6 -4
- package/lib/index.js +3 -3
- package/lib/key-codes.d.ts +7 -0
- package/lib/key-codes.js +8 -0
- package/lib/parts/common-select.p.module.css.js +15 -0
- package/lib/parts/foldable.js +2 -1
- package/lib/parts/form-trigger-wrapper.d.ts +7 -7
- package/lib/parts/form-trigger-wrapper.js +34 -16
- package/lib/parts/form-trigger.p.module.css.js +15 -0
- package/lib/parts/multiselect.d.ts +86 -0
- package/lib/parts/multiselect.js +455 -0
- package/lib/parts/native-select.d.ts +36 -0
- package/lib/parts/native-select.js +255 -0
- package/lib/parts/native-select.p.module.css.js +9 -0
- package/lib/parts/throttle.d.ts +1 -0
- package/lib/parts/trigger.d.ts +37 -0
- package/lib/parts/trigger.js +255 -0
- package/lib/parts/trigger.p.module.css.js +31 -0
- package/lib/parts/use-observable-force-rerender.d.ts +2 -0
- package/lib/parts/use-observable-force-rerender.js +16 -0
- package/lib/public-api.p.css +309 -545
- package/lib/public-api.pcss +309 -545
- package/lib/select.d.ts +91 -27
- package/lib/select.js +351 -51
- package/lib/types.d.ts +4 -167
- package/lib/utils.d.ts +22 -0
- package/lib/utils.js +199 -0
- package/package.json +12 -12
- package/lib/constants.d.ts +0 -6
- package/lib/constants.js +0 -7
- package/lib/hooks/use-a11y.d.ts +0 -29
- package/lib/hooks/use-a11y.js +0 -53
- package/lib/hooks/use-focus.d.ts +0 -10
- package/lib/hooks/use-focus.js +0 -17
- package/lib/hooks/use-hover.d.ts +0 -10
- package/lib/hooks/use-hover.js +0 -17
- package/lib/hooks/use-label-focus.d.ts +0 -9
- package/lib/hooks/use-label-focus.js +0 -22
- package/lib/hooks/use-multi-handlers.d.ts +0 -11
- package/lib/hooks/use-multi-handlers.js +0 -48
- package/lib/hooks/use-options.d.ts +0 -13
- package/lib/hooks/use-options.js +0 -89
- package/lib/multiselect.d.ts +0 -3
- package/lib/multiselect.js +0 -312
- package/lib/native-select.d.ts +0 -4
- package/lib/native-select.js +0 -211
- package/lib/parts/hidden-select.d.ts +0 -13
- package/lib/parts/hidden-select.js +0 -45
- package/lib/parts/icons.d.ts +0 -17
- package/lib/parts/icons.js +0 -69
- package/lib/parts/list-box.d.ts +0 -11
- package/lib/parts/list-box.js +0 -116
- package/lib/parts/multi-trigger.d.ts +0 -12
- package/lib/parts/multi-trigger.js +0 -74
- package/lib/parts/native-select-options-with-groups.d.ts +0 -8
- package/lib/parts/native-select-options-with-groups.js +0 -76
- package/lib/select-basic.d.ts +0 -3
- package/lib/select-basic.js +0 -203
- package/lib/select-searchable.d.ts +0 -3
- package/lib/select-searchable.js +0 -250
- package/lib/styles/common.p.module.css.js +0 -31
- package/lib/styles/form-trigger.p.module.css.js +0 -15
- package/lib/styles/list-box.p.module.css.js +0 -14
- package/lib/utils/calculate-max-height-by-items.d.ts +0 -13
- package/lib/utils/calculate-max-height-by-items.js +0 -22
- package/lib/utils/get-empty-message.d.ts +0 -6
- package/lib/utils/get-empty-message.js +0 -32
- package/lib/utils/get-option-value.d.ts +0 -2
- package/lib/utils/get-option-value.js +0 -11
- package/lib/utils/get-real-items-cnt.d.ts +0 -2
- package/lib/utils/get-real-items-cnt.js +0 -19
- package/lib/utils/get-text-from-nodes.d.ts +0 -2
- package/lib/utils/get-text-from-nodes.js +0 -28
- package/lib/utils/is-option-a-group.d.ts +0 -2
- package/lib/utils/is-option-a-group.js +0 -5
- package/lib/utils/item-to-string.d.ts +0 -2
- package/lib/utils/item-to-string.js +0 -7
- package/lib/utils/merge-props.d.ts +0 -29
- package/lib/utils/merge-props.js +0 -106
- package/lib/utils/throttle.d.ts +0 -1
- /package/lib/{utils → parts}/throttle.js +0 -0
- /package/lib/{hooks → parts}/use-backward-compatible-id.d.ts +0 -0
- /package/lib/{hooks → parts}/use-backward-compatible-id.js +0 -0
package/lib/select-searchable.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import { Dropdown } from '@rescui/dropdown';
|
|
3
|
-
import { useCombobox } from 'downshift';
|
|
4
|
-
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
5
|
-
import { useLabelFocus } from './hooks/use-label-focus.js';
|
|
6
|
-
import { useOptions } from './hooks/use-options.js';
|
|
7
|
-
import { useA11y } from './hooks/use-a11y.js';
|
|
8
|
-
import { ListBox } from './parts/list-box.js';
|
|
9
|
-
import { Icons } from './parts/icons.js';
|
|
10
|
-
import { HiddenSelect } from './parts/hidden-select.js';
|
|
11
|
-
import { FormTriggerWrapper } from './parts/form-trigger-wrapper.js';
|
|
12
|
-
import { getEmptyMessage } from './utils/get-empty-message.js';
|
|
13
|
-
import { mergeProps } from './utils/merge-props.js';
|
|
14
|
-
import { itemToString } from './utils/item-to-string.js';
|
|
15
|
-
import { getOptionValue } from './utils/get-option-value.js';
|
|
16
|
-
import { getRealItemsCnt } from './utils/get-real-items-cnt.js';
|
|
17
|
-
import styles from './styles/common.p.module.css.js'; // eslint-disable-next-line complexity
|
|
18
|
-
|
|
19
|
-
function SelectSearchable(_ref) {
|
|
20
|
-
let {
|
|
21
|
-
options,
|
|
22
|
-
value: selectedItem,
|
|
23
|
-
onChange,
|
|
24
|
-
error,
|
|
25
|
-
label,
|
|
26
|
-
note,
|
|
27
|
-
size,
|
|
28
|
-
mode,
|
|
29
|
-
theme,
|
|
30
|
-
placement,
|
|
31
|
-
boldLabel,
|
|
32
|
-
reserveErrorLine,
|
|
33
|
-
maxVisibleItems,
|
|
34
|
-
isClearable,
|
|
35
|
-
isLoading,
|
|
36
|
-
isDisabled,
|
|
37
|
-
name,
|
|
38
|
-
noOptionsMessage,
|
|
39
|
-
className,
|
|
40
|
-
id,
|
|
41
|
-
style,
|
|
42
|
-
placeholder,
|
|
43
|
-
...rest
|
|
44
|
-
} = _ref;
|
|
45
|
-
const inputRef = useRef(null);
|
|
46
|
-
const dropdownRef = useRef(null);
|
|
47
|
-
const menuRef = useRef(null);
|
|
48
|
-
const {
|
|
49
|
-
flattenedOptions,
|
|
50
|
-
listBoxItems,
|
|
51
|
-
setFilterString
|
|
52
|
-
} = useOptions(options);
|
|
53
|
-
const isListBoxEmpty = getRealItemsCnt(listBoxItems) === 0;
|
|
54
|
-
const hasValue = Boolean(selectedItem);
|
|
55
|
-
const selectedMap = selectedItem ? new Map([[getOptionValue(selectedItem), selectedItem]]) : new Map();
|
|
56
|
-
const {
|
|
57
|
-
fieldProps,
|
|
58
|
-
errorMessageProps,
|
|
59
|
-
descriptionProps,
|
|
60
|
-
baseId,
|
|
61
|
-
labelProps
|
|
62
|
-
} = useA11y({
|
|
63
|
-
prefix: 'select',
|
|
64
|
-
error,
|
|
65
|
-
description: note,
|
|
66
|
-
fieldRef: inputRef
|
|
67
|
-
});
|
|
68
|
-
const {
|
|
69
|
-
isOpen,
|
|
70
|
-
getToggleButtonProps,
|
|
71
|
-
getLabelProps,
|
|
72
|
-
getMenuProps,
|
|
73
|
-
getInputProps,
|
|
74
|
-
highlightedIndex,
|
|
75
|
-
getItemProps,
|
|
76
|
-
reset,
|
|
77
|
-
setInputValue
|
|
78
|
-
} = useCombobox({
|
|
79
|
-
onInputValueChange(_ref2) {
|
|
80
|
-
let {
|
|
81
|
-
inputValue,
|
|
82
|
-
type
|
|
83
|
-
} = _ref2;
|
|
84
|
-
|
|
85
|
-
if (type === useCombobox.stateChangeTypes.InputChange) {
|
|
86
|
-
setFilterString(inputValue);
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
items: flattenedOptions,
|
|
91
|
-
id: baseId,
|
|
92
|
-
itemToString,
|
|
93
|
-
selectedItem,
|
|
94
|
-
// defining our scroll behavior because on the first menu render the hook
|
|
95
|
-
// doesn't know menuRef and use page as the scroll boundary
|
|
96
|
-
scrollIntoView: (listItemEl, listEl) => {
|
|
97
|
-
scrollIntoView(listItemEl, {
|
|
98
|
-
scrollMode: 'if-needed',
|
|
99
|
-
block: 'nearest',
|
|
100
|
-
boundary: listEl ?? menuRef.current
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
onSelectedItemChange: _ref3 => {
|
|
104
|
-
let {
|
|
105
|
-
selectedItem: newSelectedItem
|
|
106
|
-
} = _ref3;
|
|
107
|
-
onChange === null || onChange === void 0 || onChange(newSelectedItem);
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
isItemDisabled(item) {
|
|
111
|
-
return item && item.disabled;
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
onIsOpenChange(_ref4) {
|
|
115
|
-
let {
|
|
116
|
-
isOpen: newIsOpen,
|
|
117
|
-
selectedItem: newSelectedItem
|
|
118
|
-
} = _ref4;
|
|
119
|
-
|
|
120
|
-
if (newIsOpen) {
|
|
121
|
-
setFilterString('');
|
|
122
|
-
} else {
|
|
123
|
-
setInputValue(itemToString(newSelectedItem));
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
stateReducer(state, actionAndChanges) {
|
|
128
|
-
const {
|
|
129
|
-
changes,
|
|
130
|
-
type
|
|
131
|
-
} = actionAndChanges;
|
|
132
|
-
|
|
133
|
-
switch (type) {
|
|
134
|
-
case useCombobox.stateChangeTypes.InputKeyDownEscape:
|
|
135
|
-
if (!state.isOpen) {
|
|
136
|
-
return state;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return changes;
|
|
140
|
-
|
|
141
|
-
default:
|
|
142
|
-
return changes;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
});
|
|
147
|
-
const menuProps = getMenuProps({
|
|
148
|
-
ref: menuRef
|
|
149
|
-
}, {
|
|
150
|
-
suppressRefError: true
|
|
151
|
-
});
|
|
152
|
-
const inputProps = getInputProps({
|
|
153
|
-
ref: inputRef,
|
|
154
|
-
// fix screen-reader focus on an opened popup with an empty list
|
|
155
|
-
...(isOpen && isListBoxEmpty ? {
|
|
156
|
-
'aria-activedescendant': menuProps.id
|
|
157
|
-
} : {})
|
|
158
|
-
});
|
|
159
|
-
const {
|
|
160
|
-
isFocusedByLabel,
|
|
161
|
-
labelClickProps,
|
|
162
|
-
triggerFocusProps: labelFocusForTriggerProps
|
|
163
|
-
} = useLabelFocus();
|
|
164
|
-
const emptyListMessage = getEmptyMessage({
|
|
165
|
-
isLoading,
|
|
166
|
-
isNothingFound: false,
|
|
167
|
-
noOptionsMessage
|
|
168
|
-
});
|
|
169
|
-
const listBoxState = {
|
|
170
|
-
selectedMap,
|
|
171
|
-
selectionMode: 'single',
|
|
172
|
-
highlightedIndex,
|
|
173
|
-
getItemProps,
|
|
174
|
-
menuProps
|
|
175
|
-
};
|
|
176
|
-
return /*#__PURE__*/React.createElement(FormTriggerWrapper, {
|
|
177
|
-
theme: theme,
|
|
178
|
-
size: size,
|
|
179
|
-
disabled: isDisabled,
|
|
180
|
-
label: label,
|
|
181
|
-
labelProps: mergeProps(labelProps, getLabelProps(), labelClickProps),
|
|
182
|
-
boldLabel: boldLabel,
|
|
183
|
-
error: error,
|
|
184
|
-
reserveErrorLine: reserveErrorLine,
|
|
185
|
-
errorMessageProps: errorMessageProps,
|
|
186
|
-
note: note,
|
|
187
|
-
descriptionProps: descriptionProps
|
|
188
|
-
}, /*#__PURE__*/React.createElement(HiddenSelect, {
|
|
189
|
-
name: name,
|
|
190
|
-
value: selectedItem,
|
|
191
|
-
isMultiple: false,
|
|
192
|
-
options: flattenedOptions
|
|
193
|
-
}), /*#__PURE__*/React.createElement(Dropdown, {
|
|
194
|
-
mode: mode,
|
|
195
|
-
theme: theme,
|
|
196
|
-
ref: dropdownRef,
|
|
197
|
-
placement: placement,
|
|
198
|
-
maxWidth: "trigger",
|
|
199
|
-
minWidth: "trigger",
|
|
200
|
-
isOpen: isOpen,
|
|
201
|
-
cancelCloseAnimation: true,
|
|
202
|
-
disableFocusLock: true,
|
|
203
|
-
trigger: _ref5 => {
|
|
204
|
-
let {
|
|
205
|
-
ref: triggerRefForDropdown
|
|
206
|
-
} = _ref5;
|
|
207
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
208
|
-
className: styles.triggerContainer,
|
|
209
|
-
"data-open": isOpen,
|
|
210
|
-
"data-label-focused": isFocusedByLabel
|
|
211
|
-
}, /*#__PURE__*/React.createElement("input", { ...rest,
|
|
212
|
-
...mergeProps(fieldProps, // aria-invalid & aria-describedby, rest are overridden by inputProps,
|
|
213
|
-
inputProps, labelFocusForTriggerProps),
|
|
214
|
-
className: styles.searchInput,
|
|
215
|
-
placeholder: placeholder,
|
|
216
|
-
"data-test": "select__trigger_input"
|
|
217
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
218
|
-
role: "button",
|
|
219
|
-
...mergeProps(getToggleButtonProps(), {
|
|
220
|
-
ref: triggerRefForDropdown,
|
|
221
|
-
onFocus: () => {
|
|
222
|
-
var _inputRef$current;
|
|
223
|
-
|
|
224
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
|
225
|
-
}
|
|
226
|
-
}),
|
|
227
|
-
className: styles.trigger,
|
|
228
|
-
"data-test": "select__trigger"
|
|
229
|
-
}, /*#__PURE__*/React.createElement(Icons, {
|
|
230
|
-
isLoading: isLoading,
|
|
231
|
-
canHaveClearIcon: isClearable && !isDisabled && hasValue,
|
|
232
|
-
onClear: () => {
|
|
233
|
-
var _inputRef$current2;
|
|
234
|
-
|
|
235
|
-
reset();
|
|
236
|
-
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || _inputRef$current2.focus();
|
|
237
|
-
},
|
|
238
|
-
triggerId: inputProps.id
|
|
239
|
-
})));
|
|
240
|
-
}
|
|
241
|
-
}, /*#__PURE__*/React.createElement(ListBox, {
|
|
242
|
-
state: listBoxState,
|
|
243
|
-
size: size,
|
|
244
|
-
maxVisibleItems: maxVisibleItems,
|
|
245
|
-
emptyListMessage: emptyListMessage,
|
|
246
|
-
items: listBoxItems
|
|
247
|
-
})));
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
export { SelectSearchable };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
var styles = {
|
|
2
|
-
"themeLight": "_themeLight_buyj66_6",
|
|
3
|
-
"themeDark": "_themeDark_buyj66_9",
|
|
4
|
-
"sizeS": "_sizeS_buyj66_13",
|
|
5
|
-
"sizeM": "_sizeM_buyj66_16",
|
|
6
|
-
"sizeL": "_sizeL_buyj66_19",
|
|
7
|
-
"classic": "_classic_buyj66_23",
|
|
8
|
-
"rock": "_rock_buyj66_26",
|
|
9
|
-
"root": "_root_buyj66_30",
|
|
10
|
-
"trigger": "_trigger_buyj66_36",
|
|
11
|
-
"error": "_error_buyj66_70",
|
|
12
|
-
"enabled": "_enabled_buyj66_75",
|
|
13
|
-
"disabled": "_disabled_buyj66_79",
|
|
14
|
-
"searchable": "_searchable_buyj66_92",
|
|
15
|
-
"canBeMultiline": "_canBeMultiline_buyj66_119",
|
|
16
|
-
"triggerContainer": "_triggerContainer_buyj66_123",
|
|
17
|
-
"triggerText": "_triggerText_buyj66_127",
|
|
18
|
-
"searchInput": "_searchInput_buyj66_128",
|
|
19
|
-
"labelNotSelected": "_labelNotSelected_buyj66_159",
|
|
20
|
-
"multi": "_multi_buyj66_213",
|
|
21
|
-
"tagsContainer": "_tagsContainer_buyj66_230",
|
|
22
|
-
"tag": "_tag_buyj66_230",
|
|
23
|
-
"filledTag": "_filledTag_buyj66_252",
|
|
24
|
-
"iconsWrapper": "_iconsWrapper_buyj66_260",
|
|
25
|
-
"toggle": "_toggle_buyj66_278",
|
|
26
|
-
"icon": "_icon_buyj66_260",
|
|
27
|
-
"clearIcon": "_clearIcon_buyj66_352",
|
|
28
|
-
"visuallyHidden": "_visuallyHidden_buyj66_412",
|
|
29
|
-
"select": "_select_buyj66_429"
|
|
30
|
-
};
|
|
31
|
-
export { styles as default };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var styles = {
|
|
2
|
-
"themeLight": "_themeLight_lyv0k_6",
|
|
3
|
-
"themeDark": "_themeDark_lyv0k_9",
|
|
4
|
-
"sizeS": "_sizeS_lyv0k_13",
|
|
5
|
-
"sizeM": "_sizeM_lyv0k_16",
|
|
6
|
-
"sizeL": "_sizeL_lyv0k_19",
|
|
7
|
-
"main": "_main_lyv0k_23",
|
|
8
|
-
"label": "_label_lyv0k_27",
|
|
9
|
-
"disabled": "_disabled_lyv0k_33",
|
|
10
|
-
"footer": "_footer_lyv0k_38",
|
|
11
|
-
"errorMessage": "_errorMessage_lyv0k_45",
|
|
12
|
-
"error": "_error_lyv0k_45",
|
|
13
|
-
"note": "_note_lyv0k_54"
|
|
14
|
-
};
|
|
15
|
-
export { styles as default };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var styles = {
|
|
2
|
-
"sizeS": "_sizeS_tuv1by_6",
|
|
3
|
-
"sizeM": "_sizeM_tuv1by_9",
|
|
4
|
-
"sizeL": "_sizeL_tuv1by_12",
|
|
5
|
-
"listBox": "_listBox_tuv1by_16",
|
|
6
|
-
"item": "_item_tuv1by_30",
|
|
7
|
-
"selected": "_selected_tuv1by_76",
|
|
8
|
-
"disabled": "_disabled_tuv1by_87",
|
|
9
|
-
"checkIcon": "_checkIcon_tuv1by_94",
|
|
10
|
-
"visible": "_visible_tuv1by_101",
|
|
11
|
-
"divider": "_divider_tuv1by_108",
|
|
12
|
-
"groupHeader": "_groupHeader_tuv1by_122"
|
|
13
|
-
};
|
|
14
|
-
export { styles as default };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calculate the max height of the list based on items count and allowedMaxVisibleItems.
|
|
3
|
-
* Instead of simply adding 0.5 to the allowedMaxVisibleItems, we process
|
|
4
|
-
* `itemsCount == allowedMaxVisibleItems + 1` differently.
|
|
5
|
-
*
|
|
6
|
-
* For allowedMaxVisibleItems={5}:
|
|
7
|
-
* - If items itemsCount <= 5: restrain by 5.5 items (to avoid scrollbar due to layout shifts)
|
|
8
|
-
* - If items itemsCount = 6: restrain by all 6.1 items (6 + 0.1 for group separators)
|
|
9
|
-
* - If items itemsCount > 6: restrain by 5.5 items
|
|
10
|
-
*
|
|
11
|
-
* Formula: max(5.5, min(itemsCount + 0.1, 6.1) - min(max(0, itemsCount - 6), 0.6))
|
|
12
|
-
*/
|
|
13
|
-
export declare const calculateMaxHeightByItems: (itemsCount: number, allowedMaxVisibleItems: number) => number;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calculate the max height of the list based on items count and allowedMaxVisibleItems.
|
|
3
|
-
* Instead of simply adding 0.5 to the allowedMaxVisibleItems, we process
|
|
4
|
-
* `itemsCount == allowedMaxVisibleItems + 1` differently.
|
|
5
|
-
*
|
|
6
|
-
* For allowedMaxVisibleItems={5}:
|
|
7
|
-
* - If items itemsCount <= 5: restrain by 5.5 items (to avoid scrollbar due to layout shifts)
|
|
8
|
-
* - If items itemsCount = 6: restrain by all 6.1 items (6 + 0.1 for group separators)
|
|
9
|
-
* - If items itemsCount > 6: restrain by 5.5 items
|
|
10
|
-
*
|
|
11
|
-
* Formula: max(5.5, min(itemsCount + 0.1, 6.1) - min(max(0, itemsCount - 6), 0.6))
|
|
12
|
-
*/
|
|
13
|
-
const calculateMaxHeightByItems = (itemsCount, allowedMaxVisibleItems) => {
|
|
14
|
-
const allowedFloor = Math.floor(allowedMaxVisibleItems);
|
|
15
|
-
const groupSeparatorsDelta = 0.1;
|
|
16
|
-
const partiallyVisiblePart = 0.5;
|
|
17
|
-
const upperLimit = Math.min(itemsCount + groupSeparatorsDelta, allowedFloor + 1 + groupSeparatorsDelta);
|
|
18
|
-
const delta = Math.min(Math.max(0, itemsCount - (allowedFloor + 1)), partiallyVisiblePart + groupSeparatorsDelta);
|
|
19
|
-
return Math.max(allowedFloor + partiallyVisiblePart, upperLimit - delta);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { calculateMaxHeightByItems };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_NO_OPTIONS_MESSAGES } from '../constants.js';
|
|
2
|
-
|
|
3
|
-
function isString(s) {
|
|
4
|
-
return Object.prototype.toString.call(s) === '[object String]';
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function getEmptyMessage(_ref) {
|
|
8
|
-
let {
|
|
9
|
-
isLoading,
|
|
10
|
-
isNothingFound,
|
|
11
|
-
noOptionsMessage
|
|
12
|
-
} = _ref;
|
|
13
|
-
const {
|
|
14
|
-
noOptions,
|
|
15
|
-
nothingFound,
|
|
16
|
-
loading
|
|
17
|
-
} = isString(noOptionsMessage) ? { ...DEFAULT_NO_OPTIONS_MESSAGES,
|
|
18
|
-
noOptions: noOptionsMessage
|
|
19
|
-
} : { ...DEFAULT_NO_OPTIONS_MESSAGES,
|
|
20
|
-
...noOptionsMessage
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
if (isLoading) {
|
|
24
|
-
return loading;
|
|
25
|
-
} else if (isNothingFound) {
|
|
26
|
-
return nothingFound;
|
|
27
|
-
} else {
|
|
28
|
-
return noOptions;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { getEmptyMessage };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getTextFromNodes } from './get-text-from-nodes.js';
|
|
2
|
-
|
|
3
|
-
function getOptionValue(option) {
|
|
4
|
-
if (!option) {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return typeof option.value === 'string' || typeof option.value === 'number' ? option.value : getTextFromNodes(option.label);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export { getOptionValue };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const getRealItemsCnt = items => {
|
|
2
|
-
// Count total number of items
|
|
3
|
-
return items.reduce((count, item) => {
|
|
4
|
-
if (item.type === 'group') {
|
|
5
|
-
const groupOptions = item.options;
|
|
6
|
-
const hasHeading = item.label !== null && item.label !== undefined; // Count heading (if present) + all options in the section
|
|
7
|
-
|
|
8
|
-
return count + (hasHeading ? 1 : 0) + groupOptions.length;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (item.type === 'option') {
|
|
12
|
-
return count + 1;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return count;
|
|
16
|
-
}, 0);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { getRealItemsCnt };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
const getTextFromNodes = function (node) {
|
|
4
|
-
var _node$type;
|
|
5
|
-
|
|
6
|
-
let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
7
|
-
|
|
8
|
-
if (typeof node === 'string' || typeof node === 'number') {
|
|
9
|
-
return node.toString();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (depth > 15) {
|
|
13
|
-
console.warn('Max depth reached while getting text from nodes');
|
|
14
|
-
return '';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (Array.isArray(node)) {
|
|
18
|
-
return node.map(n => getTextFromNodes(n, depth + 1)).join('');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if ( /*#__PURE__*/React.isValidElement(node) && (node === null || node === void 0 || (_node$type = node.type) === null || _node$type === void 0 || (_node$type = _node$type.toString()) === null || _node$type === void 0 ? void 0 : _node$type.toLowerCase()) !== 'svg') {
|
|
22
|
-
return getTextFromNodes(node.props.children, depth + 1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return '';
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { getTextFromNodes };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import type { SelectOptionOrGroup, SelectOptionsGroup, NativeSelectOptionOrGroup, NativeSelectOption } from '../types';
|
|
2
|
-
export declare const isOptionAGroup: (optionOrGroup: SelectOptionOrGroup | NativeSelectOptionOrGroup) => optionOrGroup is SelectOptionsGroup | NativeSelectOption;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copied from react-aria repo
|
|
3
|
-
* @see https://github.com/adobe/react-spectrum/blob/main/packages/react-aria/src/utils/mergeProps.ts
|
|
4
|
-
*/
|
|
5
|
-
import type { MutableRefObject, RefCallback } from 'react';
|
|
6
|
-
/**
|
|
7
|
-
* Merges multiple refs into one. Works with either callback or object refs.
|
|
8
|
-
*/
|
|
9
|
-
export declare function mergeRefs<T>(...refs: Array<RefCallback<T> | MutableRefObject<T> | null | undefined>): RefCallback<T> | MutableRefObject<T>;
|
|
10
|
-
export declare function chain(...callbacks: any[]): (...args: any[]) => void;
|
|
11
|
-
interface Props {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
}
|
|
14
|
-
declare type PropsArg = Props | null | undefined;
|
|
15
|
-
declare type TupleTypes<T> = {
|
|
16
|
-
[P in keyof T]: T[P];
|
|
17
|
-
} extends {
|
|
18
|
-
[key: number]: infer V;
|
|
19
|
-
} ? NullToObject<V> : never;
|
|
20
|
-
declare type NullToObject<T> = T extends null | undefined ? object : T;
|
|
21
|
-
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
22
|
-
/**
|
|
23
|
-
* Merges multiple props objects together. Event handlers are chained,
|
|
24
|
-
* classNames are combined, ids are deduplicated, and refs are merged.
|
|
25
|
-
* For all other props, the last prop object overrides all previous ones.
|
|
26
|
-
* @param args - Multiple sets of props to merge together.
|
|
27
|
-
*/
|
|
28
|
-
export declare function mergeProps<T extends PropsArg[]>(...args: T): UnionToIntersection<TupleTypes<T>>;
|
|
29
|
-
export {};
|
package/lib/utils/merge-props.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import cn from 'classnames';
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any,consistent-return */
|
|
3
|
-
|
|
4
|
-
function setRef(ref, value) {
|
|
5
|
-
if (typeof ref === 'function') {
|
|
6
|
-
return ref(value);
|
|
7
|
-
} else if (ref !== null) {
|
|
8
|
-
ref.current = value;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Merges multiple refs into one. Works with either callback or object refs.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function mergeRefs() {
|
|
17
|
-
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
-
refs[_key] = arguments[_key];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (refs.length === 1 && refs[0]) {
|
|
22
|
-
return refs[0];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return value => {
|
|
26
|
-
let hasCleanup = false;
|
|
27
|
-
const cleanups = refs.map(ref => {
|
|
28
|
-
const cleanup = setRef(ref, value);
|
|
29
|
-
hasCleanup = hasCleanup || typeof cleanup === 'function';
|
|
30
|
-
return cleanup;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if (hasCleanup) {
|
|
34
|
-
return () => {
|
|
35
|
-
cleanups.forEach((cleanup, i) => {
|
|
36
|
-
if (typeof cleanup === 'function') {
|
|
37
|
-
cleanup();
|
|
38
|
-
} else {
|
|
39
|
-
setRef(refs[i], null);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function chain() {
|
|
48
|
-
for (var _len2 = arguments.length, callbacks = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
49
|
-
callbacks[_key2] = arguments[_key2];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return function () {
|
|
53
|
-
for (const callback of callbacks) {
|
|
54
|
-
if (typeof callback === 'function') {
|
|
55
|
-
callback(...arguments);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Merges multiple props objects together. Event handlers are chained,
|
|
62
|
-
* classNames are combined, ids are deduplicated, and refs are merged.
|
|
63
|
-
* For all other props, the last prop object overrides all previous ones.
|
|
64
|
-
* @param args - Multiple sets of props to merge together.
|
|
65
|
-
*/
|
|
66
|
-
// eslint-disable-next-line complexity
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
function mergeProps() {
|
|
70
|
-
// Start with a base clone of the first argument. This is a lot faster than starting
|
|
71
|
-
// with an empty object and adding properties as we go.
|
|
72
|
-
const result = { ...(arguments.length <= 0 ? undefined : arguments[0])
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
for (let i = 1; i < arguments.length; i++) {
|
|
76
|
-
const props = i < 0 || arguments.length <= i ? undefined : arguments[i];
|
|
77
|
-
|
|
78
|
-
for (const key in props) {
|
|
79
|
-
if (!props.hasOwnProperty(key)) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const a = result[key];
|
|
84
|
-
const b = props[key]; // Chain events
|
|
85
|
-
|
|
86
|
-
if (typeof a === 'function' && typeof b === 'function' && // This is a lot faster than a regex.
|
|
87
|
-
key[0] === 'o' && key[1] === 'n' && key.charCodeAt(2) >=
|
|
88
|
-
/* 'A' */
|
|
89
|
-
65 && key.charCodeAt(2) <=
|
|
90
|
-
/* 'Z' */
|
|
91
|
-
90) {
|
|
92
|
-
result[key] = chain(a, b); // Merge classnames, sometimes classNames are empty string which eval to false, so we just need to do a type check
|
|
93
|
-
} else if (key === 'className' && typeof a === 'string' && typeof b === 'string') {
|
|
94
|
-
result[key] = cn(a, b);
|
|
95
|
-
} else if (key === 'ref' && a && b) {
|
|
96
|
-
result.ref = mergeRefs(a, b); // Override others
|
|
97
|
-
} else {
|
|
98
|
-
result[key] = b !== undefined ? b : a;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export { chain, mergeProps, mergeRefs };
|
package/lib/utils/throttle.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function throttle<A extends unknown[], R>(func: (...args: A) => R, wait: number): (...args: A) => R;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|