@sentry/scraps 0.6.0 → 0.7.0
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/README.md +27 -0
- package/dist/alert/alert.js +10 -7
- package/dist/compactSelect/compactSelect.d.ts +2 -2
- package/dist/compactSelect/compactSelect.js +37 -23
- package/dist/compactSelect/control.js +12 -9
- package/dist/compactSelect/gridList/index.js +35 -36
- package/dist/compactSelect/gridList/option.d.ts +4 -1
- package/dist/compactSelect/gridList/option.js +4 -3
- package/dist/compactSelect/gridList/section.d.ts +10 -3
- package/dist/compactSelect/gridList/section.js +16 -33
- package/dist/compactSelect/listBox/index.d.ts +1 -1
- package/dist/compactSelect/listBox/index.js +46 -58
- package/dist/compactSelect/listBox/section.d.ts +10 -8
- package/dist/compactSelect/listBox/section.js +11 -30
- package/dist/compactSelect/styles.d.ts +6 -7
- package/dist/compactSelect/styles.js +1 -23
- package/dist/diagnostics/context.d.ts +12 -0
- package/dist/diagnostics/context.js +11 -0
- package/dist/diagnostics/index.d.ts +2 -0
- package/dist/diagnostics/index.js +1 -0
- package/dist/disclosure/disclosure.js +1 -1
- package/dist/dragHandle/dragHandle.js +3 -5
- package/dist/dropdownMenu/context.d.ts +10 -0
- package/dist/dropdownMenu/context.js +2 -1
- package/dist/dropdownMenu/item.d.ts +2 -7
- package/dist/dropdownMenu/item.js +13 -7
- package/dist/dropdownMenu/list.js +25 -23
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +6 -14
- package/dist/form/field/radioGroupField.d.ts +7 -0
- package/dist/form/field/radioGroupField.js +14 -0
- package/dist/form/field/selectField.d.ts +3 -4
- package/dist/form/field/selectField.js +16 -24
- package/dist/layout/container.d.ts +18 -7
- package/dist/layout/container.js +8 -11
- package/dist/layout/flex.js +1 -1
- package/dist/layout/grid.js +2 -2
- package/dist/layout/index.d.ts +1 -1
- package/dist/layout/index.js +1 -1
- package/dist/layout/stack.js +1 -1
- package/dist/layout/styles.d.ts +28 -8
- package/dist/layout/styles.js +67 -13
- package/dist/layout/surface.d.ts +2 -2
- package/dist/layout/surface.js +6 -3
- package/dist/menu/menu.js +4 -4
- package/dist/menu/selectValue.d.ts +2 -6
- package/dist/modal/components.js +2 -2
- package/dist/overlayArrow.js +2 -2
- package/dist/select/chips.d.ts +14 -0
- package/dist/select/chips.js +45 -0
- package/dist/select/filter.js +7 -11
- package/dist/select/index.d.ts +1 -1
- package/dist/select/indicators.d.ts +11 -0
- package/dist/select/indicators.js +61 -0
- package/dist/select/menu.d.ts +44 -0
- package/dist/select/menu.js +103 -0
- package/dist/select/option.d.ts +23 -15
- package/dist/select/option.js +66 -58
- package/dist/select/options.d.ts +31 -0
- package/dist/select/options.js +74 -0
- package/dist/select/select.d.ts +24 -11
- package/dist/select/select.js +527 -429
- package/dist/select/styles.d.ts +148 -2
- package/dist/select/styles.js +156 -1
- package/dist/select/types.d.ts +6 -7
- package/dist/select/types.js +4 -0
- package/dist/select/utils.d.ts +2 -0
- package/dist/select/utils.js +4 -0
- package/dist/separator/separator.d.ts +2 -2
- package/dist/separator/separator.js +4 -3
- package/dist/slot/slot.js +16 -12
- package/dist/tabs/tab.js +3 -1
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/types.d.ts +1 -0
- package/dist/theme/useResolvedTheme.d.ts +12 -0
- package/dist/theme/useResolvedTheme.js +20 -0
- package/dist/theme/variables.css +1116 -0
- package/dist/theme/variables.d.ts +985 -0
- package/dist/theme/variables.js +455 -0
- package/dist/useVirtualCollection.d.ts +14 -1
- package/dist/useVirtualCollection.js +59 -3
- package/package.json +12 -6
- package/dist/compactSelect/useVirtualizedItems.d.ts +0 -52
- package/dist/compactSelect/useVirtualizedItems.js +0 -74
- package/dist/select/reactSelectWrapper.d.ts +0 -8
- package/dist/select/reactSelectWrapper.js +0 -25
- package/dist/select/virtualizedMenuList.d.ts +0 -24
- package/dist/select/virtualizedMenuList.js +0 -123
package/dist/select/select.js
CHANGED
|
@@ -1,454 +1,552 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useCallback, useImperativeHandle, useMemo, useRef } from "react";
|
|
2
|
+
import { Fragment, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { useTheme } from "@emotion/react";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
4
|
+
import { getFocusableTreeWalker } from "@react-aria/focus";
|
|
5
|
+
import { useInteractOutside } from "@react-aria/interactions";
|
|
6
|
+
import { getItemId, useListBox } from "@react-aria/listbox";
|
|
7
|
+
import { ListKeyboardDelegate, useSelectableCollection } from "@react-aria/selection";
|
|
8
|
+
import { mergeRefs, scrollIntoView, useObjectRef } from "@react-aria/utils";
|
|
9
|
+
import { VisuallyHidden } from "@react-aria/visually-hidden";
|
|
10
|
+
import { Item, Section } from "@react-stately/collections";
|
|
11
|
+
import { useListState } from "@react-stately/list";
|
|
12
|
+
import { Flex } from "../layout/index.js";
|
|
11
13
|
import { useTranslation } from "../translation/index.js";
|
|
14
|
+
import { useOverlay } from "../useOverlay.js";
|
|
15
|
+
import { DEFAULT_VIRTUALIZE_THRESHOLD, flattenSections, getWidestMenuItemKey, useVirtualCollection, useVirtualMenuWidth } from "../useVirtualCollection.js";
|
|
16
|
+
import { SelectChips } from "./chips.js";
|
|
12
17
|
import { createFilter } from "./filter.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
control: (_, state)=>({
|
|
49
|
-
display: 'flex',
|
|
50
|
-
color: state.isDisabled ? theme.tokens.content.disabled : theme.tokens.content.primary,
|
|
51
|
-
backgroundColor: theme.tokens.interactive.chonky.debossed.neutral.background,
|
|
52
|
-
border: `1px solid ${theme.tokens.border.primary}`,
|
|
53
|
-
boxShadow,
|
|
54
|
-
borderRadius: theme.form[size].borderRadius,
|
|
55
|
-
transition: `border ${theme.motion.smooth.fast}, box-shadow ${theme.motion.smooth.fast}`,
|
|
56
|
-
alignItems: 'center',
|
|
57
|
-
...state.isFocused && theme.focusRing(boxShadow),
|
|
58
|
-
...state.isDisabled && {
|
|
59
|
-
background: theme.tokens.background.primary,
|
|
60
|
-
color: theme.tokens.content.disabled,
|
|
61
|
-
cursor: 'not-allowed',
|
|
62
|
-
opacity: '60%'
|
|
63
|
-
},
|
|
64
|
-
minHeight: theme.form[size].minHeight,
|
|
65
|
-
fontSize: theme.form[size].fontSize,
|
|
66
|
-
lineHeight: theme.form[size].lineHeight,
|
|
67
|
-
...state.isMulti && {
|
|
68
|
-
maxHeight: '12em',
|
|
69
|
-
overflow: 'hidden'
|
|
70
|
-
}
|
|
71
|
-
}),
|
|
72
|
-
menu: (provided)=>({
|
|
73
|
-
...provided,
|
|
74
|
-
zIndex: theme.zIndex.dropdown,
|
|
75
|
-
background: theme.tokens.background.primary,
|
|
76
|
-
borderRadius: theme.radius.md,
|
|
77
|
-
border: `1px solid ${theme.tokens.border.primary}`,
|
|
78
|
-
boxShadow: 'none',
|
|
79
|
-
width: 'auto',
|
|
80
|
-
minWidth: '100%',
|
|
81
|
-
maxWidth: maxMenuWidth ?? 'auto'
|
|
82
|
-
}),
|
|
83
|
-
noOptionsMessage: (provided)=>({
|
|
84
|
-
...provided,
|
|
85
|
-
color: theme.tokens.content.disabled
|
|
86
|
-
}),
|
|
87
|
-
menuPortal: (provided)=>({
|
|
88
|
-
...provided,
|
|
89
|
-
maxWidth: maxMenuWidth ?? '24rem',
|
|
90
|
-
zIndex: isInsideModal ? theme.zIndex.modal + 1 : theme.zIndex.dropdown
|
|
91
|
-
}),
|
|
92
|
-
option: (provided)=>({
|
|
93
|
-
...provided,
|
|
94
|
-
color: theme.tokens.content.primary,
|
|
95
|
-
background: 'transparent',
|
|
96
|
-
padding: 0,
|
|
97
|
-
':active': {
|
|
98
|
-
background: 'transparent'
|
|
99
|
-
}
|
|
100
|
-
}),
|
|
101
|
-
container: (provided, state)=>({
|
|
102
|
-
...provided,
|
|
103
|
-
...state.isDisabled && {
|
|
104
|
-
pointerEvents: 'unset'
|
|
105
|
-
}
|
|
106
|
-
}),
|
|
107
|
-
valueContainer: (provided, state)=>({
|
|
108
|
-
...provided,
|
|
109
|
-
cursor: isDisabled ? 'not-allowed' : isSearchable ? 'default' : 'pointer',
|
|
110
|
-
alignItems: 'center',
|
|
111
|
-
paddingTop: 0,
|
|
112
|
-
paddingBottom: 0,
|
|
113
|
-
paddingLeft: theme.form[size].paddingLeft,
|
|
114
|
-
paddingRight: selectSpacing[size],
|
|
115
|
-
...state.isMulti && {
|
|
116
|
-
maxHeight: 'inherit',
|
|
117
|
-
overflowY: 'auto',
|
|
118
|
-
scrollbarColor: `${theme.tokens.graphics.accent.moderate} ${theme.tokens.background.primary}`
|
|
119
|
-
}
|
|
120
|
-
}),
|
|
121
|
-
input: (provided)=>({
|
|
122
|
-
...provided,
|
|
123
|
-
color: theme.tokens.content.primary,
|
|
124
|
-
margin: 0
|
|
125
|
-
}),
|
|
126
|
-
singleValue: (provided, state)=>({
|
|
127
|
-
...provided,
|
|
128
|
-
color: state.isDisabled ? theme.tokens.content.disabled : theme.tokens.content.primary,
|
|
129
|
-
display: 'flex',
|
|
130
|
-
alignItems: 'center',
|
|
131
|
-
marginLeft: 0,
|
|
132
|
-
marginRight: 0,
|
|
133
|
-
width: `calc(100% - ${theme.form[size].paddingLeft}px - ${theme.space.xs})`
|
|
134
|
-
}),
|
|
135
|
-
placeholder: (provided, state)=>({
|
|
136
|
-
...provided,
|
|
137
|
-
color: state.isDisabled ? theme.tokens.content.disabled : theme.tokens.content.secondary
|
|
138
|
-
}),
|
|
139
|
-
multiValue: (provided)=>({
|
|
140
|
-
...provided,
|
|
141
|
-
backgroundColor: theme.tokens.background.primary,
|
|
142
|
-
color: isDisabled ? theme.tokens.content.disabled : theme.tokens.content.primary,
|
|
143
|
-
borderRadius: '4px',
|
|
144
|
-
border: `1px solid ${theme.tokens.border.primary}`,
|
|
145
|
-
boxShadow: `0px 1px 0px 0px ${theme.tokens.border.primary}`,
|
|
146
|
-
display: 'flex',
|
|
147
|
-
margin: 0,
|
|
148
|
-
marginTop: multiValueSizeMapping[size].spacing,
|
|
149
|
-
marginBottom: multiValueSizeMapping[size].spacing,
|
|
150
|
-
marginRight: multiValueSizeMapping[size].spacing
|
|
151
|
-
}),
|
|
152
|
-
multiValueLabel: (provided)=>({
|
|
153
|
-
...provided,
|
|
154
|
-
color: isDisabled ? theme.tokens.content.disabled : theme.tokens.content.primary,
|
|
155
|
-
padding: multiValueSizeMapping[size].spacing,
|
|
156
|
-
paddingLeft: multiValueSizeMapping[size].spacing,
|
|
157
|
-
height: multiValueSizeMapping[size].height,
|
|
158
|
-
display: 'flex',
|
|
159
|
-
alignItems: 'center'
|
|
160
|
-
}),
|
|
161
|
-
multiValueRemove: ()=>({
|
|
162
|
-
alignItems: 'center',
|
|
163
|
-
display: 'flex',
|
|
164
|
-
margin: '4px 4px',
|
|
165
|
-
...isDisabled ? {
|
|
166
|
-
pointerEvents: 'none'
|
|
167
|
-
} : {
|
|
168
|
-
'&:hover': {
|
|
169
|
-
cursor: 'pointer',
|
|
170
|
-
background: theme.tokens.interactive.transparent.neutral.background.hover
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}),
|
|
174
|
-
indicatorsContainer: ()=>({
|
|
175
|
-
display: 'grid',
|
|
176
|
-
gridAutoFlow: 'column',
|
|
177
|
-
marginRight: selectSpacing[size]
|
|
178
|
-
}),
|
|
179
|
-
clearIndicator: indicatorStyles,
|
|
180
|
-
dropdownIndicator: indicatorStyles,
|
|
181
|
-
loadingIndicator: indicatorStyles,
|
|
182
|
-
groupHeading: (provided)=>({
|
|
183
|
-
...provided,
|
|
184
|
-
lineHeight: '1.5',
|
|
185
|
-
fontWeight: 600,
|
|
186
|
-
color: theme.tokens.content.secondary,
|
|
187
|
-
marginBottom: 0,
|
|
188
|
-
padding: `${theme.space.xs} ${theme.space.lg}`,
|
|
189
|
-
':empty': {
|
|
190
|
-
display: 'none'
|
|
191
|
-
}
|
|
192
|
-
}),
|
|
193
|
-
group: (provided)=>({
|
|
194
|
-
...provided,
|
|
195
|
-
paddingTop: 0,
|
|
196
|
-
':last-of-type': {
|
|
197
|
-
paddingBottom: 0
|
|
198
|
-
},
|
|
199
|
-
':not(:last-of-type)': {
|
|
200
|
-
position: 'relative',
|
|
201
|
-
marginBottom: theme.space.md
|
|
202
|
-
},
|
|
203
|
-
':not(:last-of-type)::after': {
|
|
204
|
-
content: '""',
|
|
205
|
-
position: 'absolute',
|
|
206
|
-
left: theme.space.lg,
|
|
207
|
-
right: theme.space.lg,
|
|
208
|
-
bottom: 0,
|
|
209
|
-
borderBottom: `solid 1px ${theme.tokens.border.secondary}`
|
|
210
|
-
}
|
|
211
|
-
})
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
function SelectInput({ selectProps, ...props }) {
|
|
215
|
-
const { inputRef } = selectProps;
|
|
216
|
-
const nativeInputRef = useObjectRef(inputRef);
|
|
217
|
-
const ref = useCallback((instance)=>{
|
|
218
|
-
nativeInputRef.current = instance?.input ?? null;
|
|
219
|
-
}, [
|
|
220
|
-
nativeInputRef
|
|
18
|
+
import { SelectIndicators } from "./indicators.js";
|
|
19
|
+
import { MENU_GAP, SelectMenu } from "./menu.js";
|
|
20
|
+
import { CREATE_KEY, useOptionIndex } from "./options.js";
|
|
21
|
+
import { getSelectStyles } from "./styles.js";
|
|
22
|
+
import { applyStyleSlot } from "./types.js";
|
|
23
|
+
import { isRenderable } from "./utils.js";
|
|
24
|
+
const defaultFilter = createFilter();
|
|
25
|
+
function optionText(option) {
|
|
26
|
+
return option.textValue ?? ('string' == typeof option.label || 'number' == typeof option.label ? String(option.label) : String(option.value));
|
|
27
|
+
}
|
|
28
|
+
function Select(props) {
|
|
29
|
+
const { options, ref: selectHandleRef, inputRef: providedInputRef, isLoading, dropdownIndicator, leadingItems, trailingItems, placeholder, isValueEqual, multiple = false, clearable = multiple, disabled, creatable, searchable = true, styles, size = 'md', menuAlign = 'start', virtualizeThreshold = DEFAULT_VIRTUALIZE_THRESHOLD, components, blurInputOnSelect = !multiple, inputValue, maxMenuHeight = 300, minMenuHeight, openMenuOnClick = true, openMenuOnFocus = false, menuPortalTarget, name } = props;
|
|
30
|
+
const { t } = useTranslation();
|
|
31
|
+
const theme = useTheme();
|
|
32
|
+
const inputRef = useObjectRef(providedInputRef);
|
|
33
|
+
const blurFrame = useRef(null);
|
|
34
|
+
const selectRef = useRef(null);
|
|
35
|
+
const controlRef = useRef(null);
|
|
36
|
+
const menuRef = useRef(null);
|
|
37
|
+
const listRef = useRef(null);
|
|
38
|
+
const footerRef = useRef(null);
|
|
39
|
+
const scrolledLists = useRef(null);
|
|
40
|
+
const [localQuery, setLocalQuery] = useState('');
|
|
41
|
+
const [focused, setFocused] = useState(false);
|
|
42
|
+
const [focusedChip, setFocusedChip] = useState(null);
|
|
43
|
+
const [lockedMenuWidth, setLockedMenuWidth] = useState();
|
|
44
|
+
const query = inputValue ?? localQuery;
|
|
45
|
+
const cancelSelectionBlur = useCallback(()=>{
|
|
46
|
+
if (null !== blurFrame.current) {
|
|
47
|
+
cancelAnimationFrame(blurFrame.current);
|
|
48
|
+
blurFrame.current = null;
|
|
49
|
+
}
|
|
50
|
+
}, []);
|
|
51
|
+
useEffect(()=>cancelSelectionBlur, [
|
|
52
|
+
cancelSelectionBlur
|
|
221
53
|
]);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
54
|
+
function updateQuery(value, reason) {
|
|
55
|
+
setLocalQuery(value);
|
|
56
|
+
props.onInputChange?.(value, reason);
|
|
57
|
+
}
|
|
58
|
+
const { isOpen, state: overlayState, overlayRef, overlayProps: { ref: setOverlayElement, style: overlayStyle }, triggerProps: { ref: setTriggerElement } } = useOverlay({
|
|
59
|
+
isOpen: disabled ? false : props.isOpen,
|
|
60
|
+
onOpenChange: (open)=>{
|
|
61
|
+
if (open) cancelSelectionBlur();
|
|
62
|
+
else updateQuery('', 'reset');
|
|
63
|
+
props.onOpenChange?.(open);
|
|
64
|
+
},
|
|
65
|
+
position: `bottom-${menuAlign}`,
|
|
66
|
+
offset: MENU_GAP,
|
|
67
|
+
strategy: menuPortalTarget ? 'fixed' : 'absolute',
|
|
68
|
+
type: 'listbox',
|
|
69
|
+
isKeyboardDismissDisabled: true,
|
|
70
|
+
isDismissable: false
|
|
227
71
|
});
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
]
|
|
72
|
+
if (!isOpen && void 0 !== lockedMenuWidth) setLockedMenuWidth(void 0);
|
|
73
|
+
useInteractOutside({
|
|
74
|
+
ref: selectRef,
|
|
75
|
+
isDisabled: !isOpen,
|
|
76
|
+
onInteractOutside: (event)=>{
|
|
77
|
+
if (event.target instanceof Node && !overlayRef.current?.contains(event.target)) overlayState.close();
|
|
78
|
+
}
|
|
236
79
|
});
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
children: children
|
|
80
|
+
const { entries, rows, selectedRows, canCreate } = useOptionIndex(options, {
|
|
81
|
+
creatable,
|
|
82
|
+
isLoading,
|
|
83
|
+
isValueEqual,
|
|
84
|
+
query,
|
|
85
|
+
values: props.multiple ? props.value : [
|
|
86
|
+
props.value
|
|
87
|
+
]
|
|
246
88
|
});
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
89
|
+
const virtualized = rows.length > virtualizeThreshold;
|
|
90
|
+
const rowsByKey = new Map(rows.map((row)=>[
|
|
91
|
+
row.key,
|
|
92
|
+
row.option
|
|
93
|
+
]));
|
|
94
|
+
const selectedKeys = selectedRows.flatMap(({ key })=>void 0 === key ? [] : [
|
|
95
|
+
key
|
|
96
|
+
]);
|
|
97
|
+
const selected = selectedRows.map(({ option })=>option);
|
|
98
|
+
const disabledKeys = rows.flatMap(({ key, option })=>option.disabled ? [
|
|
99
|
+
key
|
|
100
|
+
] : []);
|
|
101
|
+
function choose(key, { deselect = false, fromKeyboard = false }) {
|
|
102
|
+
const option = rowsByKey.get(key);
|
|
103
|
+
if (key !== CREATE_KEY && (!option || option.disabled)) return;
|
|
104
|
+
const created = key === CREATE_KEY;
|
|
105
|
+
const choice = option ?? {
|
|
106
|
+
value: query,
|
|
107
|
+
label: query
|
|
108
|
+
};
|
|
109
|
+
setFocusedChip(null);
|
|
110
|
+
if (!multiple && isOpen) overlayState.close();
|
|
111
|
+
else updateQuery('', 'reset');
|
|
112
|
+
if (created && props.onCreateOption) props.onCreateOption(query);
|
|
113
|
+
else if (props.multiple) props.onChange?.(deselect ? selectedRows.filter((row)=>row.key !== key).map((row)=>row.option) : [
|
|
114
|
+
...selected,
|
|
115
|
+
choice
|
|
116
|
+
]);
|
|
117
|
+
else props.onChange?.(choice);
|
|
118
|
+
if (blurInputOnSelect) {
|
|
119
|
+
const input = inputRef.current;
|
|
120
|
+
if (fromKeyboard) input?.blur();
|
|
121
|
+
else blurFrame.current = requestAnimationFrame(()=>{
|
|
122
|
+
blurFrame.current = null;
|
|
123
|
+
input?.blur();
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function clear() {
|
|
128
|
+
if (props.multiple) props.onChange?.([]);
|
|
129
|
+
else if (props.clearable) props.onChange?.(null);
|
|
130
|
+
setFocusedChip(null);
|
|
131
|
+
inputRef.current?.focus();
|
|
132
|
+
}
|
|
133
|
+
function remove(index) {
|
|
134
|
+
if (!props.multiple) return;
|
|
135
|
+
props.onChange?.(selected.filter((_, itemIndex)=>itemIndex !== index));
|
|
136
|
+
setFocusedChip(null);
|
|
137
|
+
inputRef.current?.focus();
|
|
138
|
+
}
|
|
139
|
+
const matches = (row)=>null === props.filterOption || (props.filterOption ?? defaultFilter)(row.option, query);
|
|
140
|
+
const collection = entries.map((entry, index)=>{
|
|
141
|
+
if (!('rows' in entry)) return matches(entry) ? /*#__PURE__*/ jsx(Item, {
|
|
142
|
+
textValue: optionText(entry.option),
|
|
143
|
+
children: entry.option.label
|
|
144
|
+
}, entry.key) : null;
|
|
145
|
+
const children = entry.rows.filter(matches).map(({ key, option })=>/*#__PURE__*/ jsx(Item, {
|
|
146
|
+
textValue: optionText(option),
|
|
147
|
+
children: option.label
|
|
148
|
+
}, key));
|
|
149
|
+
return children.length > 0 ? /*#__PURE__*/ jsx(Section, {
|
|
150
|
+
title: entry.label,
|
|
254
151
|
children: children
|
|
255
|
-
}) :
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
children:
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
152
|
+
}, `section:${index}`) : null;
|
|
153
|
+
}).filter((child)=>null !== child);
|
|
154
|
+
if (canCreate) collection.push(/*#__PURE__*/ jsx(Item, {
|
|
155
|
+
textValue: query,
|
|
156
|
+
children: props.formatCreateLabel?.(query) ?? t('Create "%s"', query)
|
|
157
|
+
}, CREATE_KEY));
|
|
158
|
+
const state = useListState({
|
|
159
|
+
children: collection,
|
|
160
|
+
disabledKeys,
|
|
161
|
+
selectedKeys,
|
|
162
|
+
selectionMode: multiple ? 'multiple' : 'single',
|
|
163
|
+
selectionBehavior: 'toggle',
|
|
164
|
+
disallowEmptySelection: !multiple,
|
|
165
|
+
allowDuplicateSelectionEvents: true,
|
|
166
|
+
onSelectionChange: (keys)=>{
|
|
167
|
+
if ('all' === keys) return;
|
|
168
|
+
const added = [
|
|
169
|
+
...keys
|
|
170
|
+
].find((key)=>!selectedKeys.includes(String(key)));
|
|
171
|
+
const removed = selectedKeys.find((key)=>!keys.has(key));
|
|
172
|
+
const key = added ?? removed ?? keys.values().next().value;
|
|
173
|
+
if (void 0 !== key) choose(key, {
|
|
174
|
+
deselect: void 0 === added && void 0 !== removed
|
|
175
|
+
});
|
|
176
|
+
}
|
|
271
177
|
});
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
178
|
+
const { selectionManager } = state;
|
|
179
|
+
const listId = useId();
|
|
180
|
+
const inputId = useId();
|
|
181
|
+
const valueId = useId();
|
|
182
|
+
const selectStyles = getSelectStyles(theme, size, {
|
|
183
|
+
disabled,
|
|
184
|
+
focused,
|
|
185
|
+
hasChips: multiple && selected.length > 0,
|
|
186
|
+
hasQuery: '' !== query,
|
|
187
|
+
searchable
|
|
280
188
|
});
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
size
|
|
296
|
-
|
|
297
|
-
height: 14,
|
|
298
|
-
width: 14
|
|
299
|
-
}
|
|
189
|
+
const { maxMenuWidth } = props;
|
|
190
|
+
const baseMenuStyle = {
|
|
191
|
+
...selectStyles.menu,
|
|
192
|
+
maxWidth: '100%' === maxMenuWidth ? overlayStyle?.minWidth ?? '100%' : maxMenuWidth
|
|
193
|
+
};
|
|
194
|
+
const menuStyle = applyStyleSlot(styles, 'menu', baseMenuStyle, {});
|
|
195
|
+
const shouldLockMenuWidth = isOpen && virtualized && 'max-content' === menuStyle.width;
|
|
196
|
+
const widestKey = shouldLockMenuWidth ? getWidestMenuItemKey(flattenSections(state.collection).filter((node)=>'item' === node.type)) : void 0;
|
|
197
|
+
const virtual = useVirtualCollection({
|
|
198
|
+
collection: state.collection,
|
|
199
|
+
enabled: virtualized,
|
|
200
|
+
scrollRef: listRef,
|
|
201
|
+
focusedKey: isOpen ? selectionManager.focusedKey : null,
|
|
202
|
+
listPadding: 4,
|
|
203
|
+
size,
|
|
204
|
+
widestKey
|
|
300
205
|
});
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
isFocused: false,
|
|
308
|
-
isSelected: true
|
|
309
|
-
}) : leadingItems;
|
|
310
|
-
return /*#__PURE__*/ jsx(external_reactSelectWrapper_js_components.SingleValue, {
|
|
311
|
-
...props,
|
|
312
|
-
children: ValueComponent ? /*#__PURE__*/ jsx(ValueComponent, {
|
|
313
|
-
option: props.data
|
|
314
|
-
}) : /*#__PURE__*/ jsxs(SingleValueWrap, {
|
|
315
|
-
children: [
|
|
316
|
-
renderedLeadingItems,
|
|
317
|
-
/*#__PURE__*/ jsx(SingleValueLabel, {
|
|
318
|
-
children: label
|
|
319
|
-
})
|
|
320
|
-
]
|
|
321
|
-
})
|
|
206
|
+
useVirtualMenuWidth({
|
|
207
|
+
enabled: shouldLockMenuWidth,
|
|
208
|
+
isWidthCandidateMounted: virtual.rows.some((row)=>row.node.key === widestKey),
|
|
209
|
+
isWidthLocked: void 0 !== lockedMenuWidth,
|
|
210
|
+
menuRef,
|
|
211
|
+
onLockWidth: setLockedMenuWidth
|
|
322
212
|
});
|
|
323
|
-
}
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
]
|
|
346
|
-
})
|
|
213
|
+
const { collection: listCollection, disabledKeys: listDisabledKeys } = state;
|
|
214
|
+
const delegate = useMemo(()=>new ListKeyboardDelegate({
|
|
215
|
+
collection: listCollection,
|
|
216
|
+
disabledKeys: listDisabledKeys,
|
|
217
|
+
ref: listRef,
|
|
218
|
+
layoutDelegate: virtual.layoutDelegate
|
|
219
|
+
}), [
|
|
220
|
+
listCollection,
|
|
221
|
+
listDisabledKeys,
|
|
222
|
+
listRef,
|
|
223
|
+
virtual.layoutDelegate
|
|
224
|
+
]);
|
|
225
|
+
const { collectionProps } = useSelectableCollection({
|
|
226
|
+
selectionManager,
|
|
227
|
+
keyboardDelegate: delegate,
|
|
228
|
+
ref: inputRef,
|
|
229
|
+
shouldFocusWrap: true,
|
|
230
|
+
shouldUseVirtualFocus: true,
|
|
231
|
+
disallowTypeAhead: true,
|
|
232
|
+
disallowSelectAll: true,
|
|
233
|
+
disallowEmptySelection: true,
|
|
234
|
+
isVirtualized: virtualized
|
|
347
235
|
});
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
isSearchable,
|
|
360
|
-
isDisabled
|
|
236
|
+
const { listBoxProps } = useListBox({
|
|
237
|
+
id: listId,
|
|
238
|
+
'aria-label': t('Options'),
|
|
239
|
+
shouldUseVirtualFocus: true,
|
|
240
|
+
shouldFocusOnHover: true,
|
|
241
|
+
shouldSelectOnPressUp: true,
|
|
242
|
+
isVirtualized: virtualized
|
|
243
|
+
}, state, listRef);
|
|
244
|
+
useImperativeHandle(selectHandleRef, ()=>({
|
|
245
|
+
focus: ()=>inputRef.current?.focus(),
|
|
246
|
+
blur: ()=>inputRef.current?.blur()
|
|
361
247
|
}), [
|
|
362
|
-
|
|
363
|
-
size,
|
|
364
|
-
maxMenuWidth,
|
|
365
|
-
isInsideModal,
|
|
366
|
-
isSearchable,
|
|
367
|
-
isDisabled
|
|
248
|
+
inputRef
|
|
368
249
|
]);
|
|
369
|
-
const
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
250
|
+
const focusedKey = selectionManager.focusedKey;
|
|
251
|
+
const selectedOptionKey = selectedKeys.find((key)=>state.collection.getItem(key) && !selectionManager.isDisabled(key));
|
|
252
|
+
useEffect(()=>{
|
|
253
|
+
if (!isOpen) {
|
|
254
|
+
if (null != focusedKey) selectionManager.setFocusedKey(null);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (null == focusedKey && state.collection.size > 0) selectionManager.setFocusedKey((query ? null : selectedOptionKey) ?? delegate.getFirstKey());
|
|
258
|
+
}, [
|
|
259
|
+
delegate,
|
|
260
|
+
isOpen,
|
|
261
|
+
focusedKey,
|
|
262
|
+
query,
|
|
263
|
+
selectedOptionKey,
|
|
264
|
+
selectionManager,
|
|
265
|
+
state.collection
|
|
266
|
+
]);
|
|
267
|
+
const isMenuPositioned = 'initial' === menuStyle.position || overlayStyle?.maxHeight != null;
|
|
268
|
+
const { scrollToKey } = virtual;
|
|
269
|
+
const scrollKey = !isMenuPositioned || query || null == selectedOptionKey ? void 0 : String(selectedOptionKey);
|
|
270
|
+
const selectedOptionId = void 0 === scrollKey ? void 0 : getItemId(state, scrollKey);
|
|
271
|
+
const setListElement = useCallback((list)=>{
|
|
272
|
+
listRef.current = list;
|
|
273
|
+
if (!list || scrolledLists.current?.has(list) || void 0 === scrollKey) return;
|
|
274
|
+
const frame = requestAnimationFrame(()=>{
|
|
275
|
+
if (scrollToKey) scrollToKey(scrollKey);
|
|
276
|
+
else {
|
|
277
|
+
const option = selectedOptionId && list.ownerDocument.getElementById(selectedOptionId);
|
|
278
|
+
if (!option) return;
|
|
279
|
+
scrollIntoView(list, option);
|
|
280
|
+
}
|
|
281
|
+
(scrolledLists.current ??= new WeakSet()).add(list);
|
|
282
|
+
});
|
|
283
|
+
return ()=>{
|
|
284
|
+
cancelAnimationFrame(frame);
|
|
285
|
+
listRef.current = null;
|
|
286
|
+
};
|
|
287
|
+
}, [
|
|
288
|
+
scrollKey,
|
|
289
|
+
scrollToKey,
|
|
290
|
+
selectedOptionId
|
|
291
|
+
]);
|
|
292
|
+
function onKeyDown(event) {
|
|
293
|
+
props.onKeyDown?.(event);
|
|
294
|
+
if (event.defaultPrevented || event.nativeEvent.isComposing) return;
|
|
295
|
+
if (!handleMenuKey(event)) handleValueKey(event);
|
|
296
|
+
}
|
|
297
|
+
function handleMenuKey(event) {
|
|
298
|
+
if ('Tab' === event.key && !event.shiftKey && isOpen && menuPortalTarget && footerRef.current) {
|
|
299
|
+
const next = getFocusableTreeWalker(footerRef.current, {
|
|
300
|
+
tabbable: true
|
|
301
|
+
}).nextNode();
|
|
302
|
+
if (next instanceof HTMLElement) {
|
|
303
|
+
event.preventDefault();
|
|
304
|
+
next.focus();
|
|
305
|
+
}
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
const isSpaceAction = ' ' === event.key && (!searchable || !query);
|
|
309
|
+
if (isSpaceAction && !isOpen) {
|
|
310
|
+
event.preventDefault();
|
|
311
|
+
overlayState.open();
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
if (isOpen && ('Enter' === event.key || isSpaceAction)) {
|
|
315
|
+
event.preventDefault();
|
|
316
|
+
const key = focusedKey ?? delegate.getFirstKey();
|
|
317
|
+
if (null != key) choose(key, {
|
|
318
|
+
deselect: multiple && selectionManager.isSelected(key),
|
|
319
|
+
fromKeyboard: true
|
|
320
|
+
});
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
if ('ArrowDown' === event.key || 'ArrowUp' === event.key) {
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
if (isOpen && null != focusedKey) collectionProps.onKeyDown?.(event);
|
|
326
|
+
else {
|
|
327
|
+
const edgeKey = 'ArrowDown' === event.key ? delegate.getFirstKey() : delegate.getLastKey();
|
|
328
|
+
selectionManager.setFocusedKey(isOpen ? edgeKey : selectedOptionKey ?? edgeKey);
|
|
329
|
+
overlayState.open();
|
|
330
|
+
}
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
if (isOpen && null != focusedKey && [
|
|
334
|
+
'PageUp',
|
|
335
|
+
'PageDown',
|
|
336
|
+
'Home',
|
|
337
|
+
'End'
|
|
338
|
+
].includes(event.key)) {
|
|
339
|
+
collectionProps.onKeyDown?.(event);
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
function handleValueKey(event) {
|
|
345
|
+
if (query || !selected.length) return;
|
|
346
|
+
if (multiple && 'ArrowLeft' === event.key) setFocusedChip(Math.max(0, (focusedChip ?? selected.length) - 1));
|
|
347
|
+
else if (multiple && 'ArrowRight' === event.key) setFocusedChip(null != focusedChip && focusedChip < selected.length - 1 ? focusedChip + 1 : null);
|
|
348
|
+
else if (null != focusedChip && ('Backspace' === event.key || 'Delete' === event.key)) remove(focusedChip);
|
|
349
|
+
else if ('Backspace' === event.key && clearable) {
|
|
350
|
+
event.preventDefault();
|
|
351
|
+
if (multiple) remove(selected.length - 1);
|
|
352
|
+
else clear();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const inputEvents = {
|
|
356
|
+
onChange: (event)=>{
|
|
357
|
+
updateQuery(event.currentTarget.value, 'input');
|
|
358
|
+
selectionManager.setFocusedKey(null);
|
|
359
|
+
setFocusedChip(null);
|
|
360
|
+
overlayState.open();
|
|
403
361
|
},
|
|
404
|
-
|
|
405
|
-
|
|
362
|
+
onFocus: (event)=>{
|
|
363
|
+
cancelSelectionBlur();
|
|
364
|
+
setFocused(true);
|
|
365
|
+
selectionManager.setFocused(true);
|
|
366
|
+
props.onFocus?.(event);
|
|
367
|
+
if (openMenuOnFocus) overlayState.open();
|
|
406
368
|
},
|
|
407
|
-
|
|
408
|
-
|
|
369
|
+
onBlur: (event)=>{
|
|
370
|
+
setFocused(false);
|
|
371
|
+
selectionManager.setFocused(false);
|
|
372
|
+
setFocusedChip(null);
|
|
373
|
+
if (overlayRef.current?.contains(event.relatedTarget)) return;
|
|
374
|
+
props.onBlur?.(event);
|
|
375
|
+
if (isOpen) overlayState.close();
|
|
376
|
+
else updateQuery('', 'reset');
|
|
409
377
|
}
|
|
410
378
|
};
|
|
411
|
-
const
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
isOptionDisabled: (option)=>!!option.disabled,
|
|
423
|
-
showDividers: props.showDividers,
|
|
424
|
-
options: options,
|
|
425
|
-
blurInputOnSelect: !props.multiple,
|
|
426
|
-
closeMenuOnSelect: !props.multiple,
|
|
427
|
-
hideSelectedOptions: false,
|
|
428
|
-
tabSelectsValue: false,
|
|
429
|
-
...rest,
|
|
430
|
-
value: mappedValue,
|
|
379
|
+
const optionStyle = (option)=>({
|
|
380
|
+
data: option,
|
|
381
|
+
isDisabled: Boolean(disabled || option.disabled),
|
|
382
|
+
isSelected: true
|
|
383
|
+
});
|
|
384
|
+
const { Value, MultiValueLabel, OptionLabel } = components ?? {};
|
|
385
|
+
const showClearButton = clearable && selected.length > 0 && !disabled;
|
|
386
|
+
const first = selected[0];
|
|
387
|
+
const activeChip = null === focusedChip ? void 0 : selected[focusedChip];
|
|
388
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
389
|
+
className: props.className,
|
|
431
390
|
ref: selectRef,
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
391
|
+
"data-scraps-select": "",
|
|
392
|
+
onKeyDown: (event)=>{
|
|
393
|
+
if ('Escape' !== event.key || !isOpen || event.defaultPrevented || event.nativeEvent.isComposing) return;
|
|
394
|
+
const input = inputRef.current;
|
|
395
|
+
const fromMenu = event.target instanceof Node && overlayRef.current?.contains(event.target);
|
|
396
|
+
if (event.target !== input && !fromMenu) return;
|
|
397
|
+
event.preventDefault();
|
|
398
|
+
event.stopPropagation();
|
|
399
|
+
if (fromMenu) input?.focus();
|
|
400
|
+
overlayState.close();
|
|
436
401
|
},
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
402
|
+
css: applyStyleSlot(styles, 'container', selectStyles.container, {
|
|
403
|
+
isDisabled: disabled
|
|
404
|
+
}),
|
|
405
|
+
children: [
|
|
406
|
+
/*#__PURE__*/ jsxs("div", {
|
|
407
|
+
ref: mergeRefs(controlRef, (element)=>setTriggerElement(element)),
|
|
408
|
+
css: applyStyleSlot(styles, 'control', selectStyles.control, {
|
|
409
|
+
isDisabled: disabled
|
|
410
|
+
}),
|
|
411
|
+
onMouseDown: (event)=>{
|
|
412
|
+
if (event.target !== inputRef.current && !(event.target instanceof Element && event.target.closest('button'))) event.preventDefault();
|
|
413
|
+
},
|
|
414
|
+
onClick: (event)=>{
|
|
415
|
+
if (disabled || event.target instanceof Element && event.target.closest('button')) return;
|
|
416
|
+
event.preventDefault();
|
|
417
|
+
inputRef.current?.focus();
|
|
418
|
+
if (openMenuOnClick && (!isOpen || event.target !== inputRef.current || !searchable)) overlayState.toggle();
|
|
419
|
+
},
|
|
420
|
+
children: [
|
|
421
|
+
isRenderable(leadingItems) && /*#__PURE__*/ jsx(Flex, {
|
|
422
|
+
align: "center",
|
|
423
|
+
flexShrink: 0,
|
|
424
|
+
gap: "xs",
|
|
425
|
+
css: selectStyles.leadingItems,
|
|
426
|
+
children: leadingItems
|
|
427
|
+
}),
|
|
428
|
+
/*#__PURE__*/ jsxs("div", {
|
|
429
|
+
css: selectStyles.values,
|
|
430
|
+
children: [
|
|
431
|
+
multiple && /*#__PURE__*/ jsx(SelectChips, {
|
|
432
|
+
disabled: disabled,
|
|
433
|
+
focusedChip: focusedChip,
|
|
434
|
+
MultiValueLabel: MultiValueLabel,
|
|
435
|
+
onRemove: remove,
|
|
436
|
+
selectedRows: selectedRows,
|
|
437
|
+
selectStyles: selectStyles,
|
|
438
|
+
styles: styles
|
|
439
|
+
}),
|
|
440
|
+
!query && !multiple && first && /*#__PURE__*/ jsx("div", {
|
|
441
|
+
css: applyStyleSlot(styles, 'singleValue', selectStyles.singleValue, optionStyle(first)),
|
|
442
|
+
children: Value ? /*#__PURE__*/ jsx(Value, {
|
|
443
|
+
option: first
|
|
444
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
445
|
+
children: [
|
|
446
|
+
'function' == typeof first.leadingItems ? first.leadingItems({
|
|
447
|
+
disabled: Boolean(disabled),
|
|
448
|
+
isSelected: true,
|
|
449
|
+
isFocused: false
|
|
450
|
+
}) : first.leadingItems,
|
|
451
|
+
/*#__PURE__*/ jsx("span", {
|
|
452
|
+
css: selectStyles.valueLabel,
|
|
453
|
+
children: first.label
|
|
454
|
+
})
|
|
455
|
+
]
|
|
456
|
+
})
|
|
457
|
+
}),
|
|
458
|
+
!query && !selected.length && /*#__PURE__*/ jsx("div", {
|
|
459
|
+
css: applyStyleSlot(styles, 'placeholder', selectStyles.placeholder, {}),
|
|
460
|
+
children: void 0 === placeholder ? t('Select...') : placeholder
|
|
461
|
+
}),
|
|
462
|
+
selected.length > 0 && /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
463
|
+
id: valueId,
|
|
464
|
+
children: t('Selected: %s', selected.map(optionText).join(', '))
|
|
465
|
+
}),
|
|
466
|
+
/*#__PURE__*/ jsx("input", {
|
|
467
|
+
...inputEvents,
|
|
468
|
+
id: props.id ?? inputId,
|
|
469
|
+
"aria-label": props['aria-label'] ?? (props.id || props['aria-labelledby'] ? void 0 : t('Select options')),
|
|
470
|
+
"aria-labelledby": props['aria-labelledby'],
|
|
471
|
+
"aria-describedby": [
|
|
472
|
+
props['aria-describedby'],
|
|
473
|
+
selected.length ? valueId : void 0
|
|
474
|
+
].filter(Boolean).join(' ') || void 0,
|
|
475
|
+
value: query,
|
|
476
|
+
autoComplete: "off",
|
|
477
|
+
autoFocus: props.autoFocus,
|
|
478
|
+
readOnly: !searchable,
|
|
479
|
+
disabled: disabled,
|
|
480
|
+
ref: inputRef,
|
|
481
|
+
role: "combobox",
|
|
482
|
+
onKeyDown: onKeyDown,
|
|
483
|
+
onPointerDown: cancelSelectionBlur,
|
|
484
|
+
"aria-invalid": props['aria-invalid'],
|
|
485
|
+
"aria-autocomplete": searchable ? 'list' : 'none',
|
|
486
|
+
"aria-expanded": isOpen,
|
|
487
|
+
"aria-controls": isOpen ? listId : void 0,
|
|
488
|
+
"aria-activedescendant": isOpen && null != focusedKey && virtual.rows.some((row)=>row.node.key === focusedKey) ? getItemId(state, focusedKey) : void 0,
|
|
489
|
+
tabIndex: props.tabIndex,
|
|
490
|
+
css: applyStyleSlot(styles, 'input', selectStyles.input, {})
|
|
491
|
+
})
|
|
492
|
+
]
|
|
493
|
+
}),
|
|
494
|
+
/*#__PURE__*/ jsx(SelectIndicators, {
|
|
495
|
+
dropdownIndicator: dropdownIndicator,
|
|
496
|
+
isLoading: isLoading,
|
|
497
|
+
isOpen: isOpen,
|
|
498
|
+
onClear: clear,
|
|
499
|
+
selectStyles: selectStyles,
|
|
500
|
+
showClearButton: showClearButton,
|
|
501
|
+
trailingItems: trailingItems
|
|
502
|
+
})
|
|
503
|
+
]
|
|
504
|
+
}),
|
|
505
|
+
multiple && /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
506
|
+
role: "status",
|
|
507
|
+
"aria-atomic": "true",
|
|
508
|
+
children: !query && null !== focusedChip && activeChip ? t('%s, %s of %s. Press Backspace to remove.', optionText(activeChip), focusedChip + 1, selected.length) : null
|
|
509
|
+
}),
|
|
510
|
+
name && !disabled && (selected.length ? selected : [
|
|
511
|
+
null
|
|
512
|
+
]).map((option, index)=>/*#__PURE__*/ jsx("input", {
|
|
513
|
+
type: "hidden",
|
|
514
|
+
name: name,
|
|
515
|
+
value: String(option?.value ?? '')
|
|
516
|
+
}, index)),
|
|
517
|
+
isOpen && /*#__PURE__*/ jsx(SelectMenu, {
|
|
518
|
+
controlRef: controlRef,
|
|
519
|
+
footerRef: footerRef,
|
|
520
|
+
isInsideModal: props.isInsideModal,
|
|
521
|
+
isLoading: isLoading,
|
|
522
|
+
listBoxProps: listBoxProps,
|
|
523
|
+
listRef: setListElement,
|
|
524
|
+
loadingMessage: props.loadingMessage,
|
|
525
|
+
lockedMenuWidth: shouldLockMenuWidth ? lockedMenuWidth : void 0,
|
|
526
|
+
maxMenuHeight: maxMenuHeight,
|
|
527
|
+
menuFooter: props.menuFooter,
|
|
528
|
+
menuPortalTarget: menuPortalTarget,
|
|
529
|
+
menuRef: menuRef,
|
|
530
|
+
menuStyle: menuStyle,
|
|
531
|
+
minMenuHeight: minMenuHeight,
|
|
532
|
+
multiple: multiple,
|
|
533
|
+
noOptionsMessage: props.noOptionsMessage,
|
|
534
|
+
onClose: overlayState.close,
|
|
535
|
+
OptionLabel: OptionLabel,
|
|
536
|
+
overlayStyle: overlayStyle,
|
|
537
|
+
query: query,
|
|
538
|
+
rowsByKey: rowsByKey,
|
|
539
|
+
selectStyles: selectStyles,
|
|
540
|
+
setOverlayElement: setOverlayElement,
|
|
541
|
+
showCreateOptionIcon: props.showCreateOptionIcon,
|
|
542
|
+
showDividers: props.showDividers,
|
|
543
|
+
size: size,
|
|
544
|
+
state: state,
|
|
545
|
+
styles: styles,
|
|
546
|
+
virtual: virtual,
|
|
547
|
+
virtualized: virtualized
|
|
548
|
+
})
|
|
549
|
+
]
|
|
452
550
|
});
|
|
453
551
|
}
|
|
454
552
|
export { Select };
|