@tamagui/select 1.0.1-beta.73 → 1.0.1-beta.76
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/dist/cjs/Select.js +14 -14
- package/dist/cjs/Select.js.map +2 -2
- package/dist/esm/BubbleSelect.js +16 -1
- package/dist/esm/BubbleSelect.js.map +1 -1
- package/dist/esm/Select.js +122 -92
- package/dist/esm/Select.js.map +2 -2
- package/dist/jsx/Select.js +17 -16
- package/package.json +10 -10
- package/src/Select.tsx +16 -25
- package/types/Select.d.ts.map +1 -1
package/dist/esm/Select.js
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
1
32
|
import {
|
|
2
33
|
FloatingFocusManager,
|
|
3
34
|
FloatingOverlay,
|
|
@@ -18,7 +49,6 @@ import {
|
|
|
18
49
|
import { usePrevious } from "@radix-ui/react-use-previous";
|
|
19
50
|
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
20
51
|
import {
|
|
21
|
-
getVariableValue,
|
|
22
52
|
styled,
|
|
23
53
|
useIsomorphicLayoutEffect,
|
|
24
54
|
withStaticProperties
|
|
@@ -40,13 +70,6 @@ if (isFirefox) {
|
|
|
40
70
|
function getVisualOffsetTop() {
|
|
41
71
|
return !/^((?!chrome|android).)*safari/i.test(userAgent) ? visualViewport.offsetTop : 0;
|
|
42
72
|
}
|
|
43
|
-
const getSelectItemSize = (val, { tokens }) => {
|
|
44
|
-
const padding = getVariableValue(tokens.size[val]);
|
|
45
|
-
return {
|
|
46
|
-
paddingHorizontal: padding / 2,
|
|
47
|
-
paddingVertical: padding / 4
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
73
|
const SELECT_NAME = "Select";
|
|
51
74
|
const WINDOW_PADDING = 8;
|
|
52
75
|
const SCROLL_ARROW_VELOCITY = 8;
|
|
@@ -55,18 +78,19 @@ const MIN_HEIGHT = 80;
|
|
|
55
78
|
const FALLBACK_THRESHOLD = 16;
|
|
56
79
|
const [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME);
|
|
57
80
|
const [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
|
|
58
|
-
const OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
|
|
59
|
-
const SELECTION_KEYS = [" ", "Enter"];
|
|
60
81
|
const TRIGGER_NAME = "SelectTrigger";
|
|
61
82
|
const SelectTrigger = React.forwardRef((props, forwardedRef) => {
|
|
62
|
-
const {
|
|
83
|
+
const _a = props, {
|
|
63
84
|
__scopeSelect,
|
|
64
85
|
disabled = false,
|
|
65
|
-
"aria-labelledby": ariaLabelledby
|
|
66
|
-
|
|
67
|
-
|
|
86
|
+
"aria-labelledby": ariaLabelledby
|
|
87
|
+
} = _a, triggerProps = __objRest(_a, [
|
|
88
|
+
"__scopeSelect",
|
|
89
|
+
"disabled",
|
|
90
|
+
"aria-labelledby"
|
|
91
|
+
]);
|
|
68
92
|
const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
|
|
69
|
-
return /* @__PURE__ */ React.createElement(ListItem, {
|
|
93
|
+
return /* @__PURE__ */ React.createElement(ListItem, __spreadValues(__spreadProps(__spreadValues({
|
|
70
94
|
backgrounded: true,
|
|
71
95
|
radiused: true,
|
|
72
96
|
hoverTheme: true,
|
|
@@ -79,16 +103,16 @@ const SelectTrigger = React.forwardRef((props, forwardedRef) => {
|
|
|
79
103
|
"aria-expanded": context.open,
|
|
80
104
|
"aria-autocomplete": "none",
|
|
81
105
|
disabled,
|
|
82
|
-
"data-disabled": disabled ? "" : void 0
|
|
83
|
-
|
|
84
|
-
ref: forwardedRef
|
|
85
|
-
|
|
86
|
-
});
|
|
106
|
+
"data-disabled": disabled ? "" : void 0
|
|
107
|
+
}, triggerProps), {
|
|
108
|
+
ref: forwardedRef
|
|
109
|
+
}), context.interactions.getReferenceProps()));
|
|
87
110
|
});
|
|
88
111
|
SelectTrigger.displayName = TRIGGER_NAME;
|
|
89
112
|
const VALUE_NAME = "SelectValue";
|
|
90
113
|
const SelectValueFrame = styled(Paragraph, {
|
|
91
|
-
name: VALUE_NAME
|
|
114
|
+
name: VALUE_NAME,
|
|
115
|
+
selectable: false
|
|
92
116
|
});
|
|
93
117
|
const SelectValue = SelectValueFrame.extractable(React.forwardRef(({ __scopeSelect, children, placeholder }, forwardedRef) => {
|
|
94
118
|
const context = useSelectContext(VALUE_NAME, __scopeSelect);
|
|
@@ -126,12 +150,12 @@ const SelectViewportFrame = styled(ThemeableStack, {
|
|
|
126
150
|
elevate: true,
|
|
127
151
|
overflow: "hidden",
|
|
128
152
|
userSelect: "none",
|
|
153
|
+
maxHeight: "100%",
|
|
129
154
|
variants: {
|
|
130
155
|
size: {
|
|
131
156
|
"...size": (val, { tokens }) => {
|
|
132
|
-
var _a;
|
|
133
157
|
return {
|
|
134
|
-
borderRadius:
|
|
158
|
+
borderRadius: tokens.radius[val] ?? val
|
|
135
159
|
};
|
|
136
160
|
}
|
|
137
161
|
}
|
|
@@ -141,7 +165,7 @@ const SelectViewportFrame = styled(ThemeableStack, {
|
|
|
141
165
|
}
|
|
142
166
|
});
|
|
143
167
|
const SelectViewport = React.forwardRef((props, forwardedRef) => {
|
|
144
|
-
const { __scopeSelect, children,
|
|
168
|
+
const _a = props, { __scopeSelect, children } = _a, viewportProps = __objRest(_a, ["__scopeSelect", "children"]);
|
|
145
169
|
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
146
170
|
const composedRefs = useComposedRefs(forwardedRef);
|
|
147
171
|
const prevScrollTopRef = React.useRef(0);
|
|
@@ -152,31 +176,34 @@ const SelectViewport = React.forwardRef((props, forwardedRef) => {
|
|
|
152
176
|
}), /* @__PURE__ */ React.createElement(FloatingFocusManager, {
|
|
153
177
|
context: context.floatingContext,
|
|
154
178
|
preventTabbing: true
|
|
155
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
156
|
-
...context.interactions.getFloatingProps()
|
|
157
|
-
}, /* @__PURE__ */ React.createElement(SelectViewportFrame, {
|
|
179
|
+
}, /* @__PURE__ */ React.createElement("div", __spreadValues({}, context.interactions.getFloatingProps()), /* @__PURE__ */ React.createElement(SelectViewportFrame, __spreadProps(__spreadValues({
|
|
158
180
|
size: context.size,
|
|
159
181
|
"data-radix-select-viewport": "",
|
|
160
|
-
role: "presentation"
|
|
161
|
-
|
|
182
|
+
role: "presentation"
|
|
183
|
+
}, viewportProps), {
|
|
162
184
|
ref: composedRefs
|
|
163
|
-
}, children))));
|
|
185
|
+
}), children))));
|
|
164
186
|
});
|
|
165
187
|
SelectViewport.displayName = VIEWPORT_NAME;
|
|
166
188
|
const ITEM_NAME = "SelectItem";
|
|
167
189
|
const [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
|
|
168
190
|
const SelectItem = React.forwardRef((props, forwardedRef) => {
|
|
169
|
-
const {
|
|
191
|
+
const _a = props, {
|
|
170
192
|
__scopeSelect,
|
|
171
193
|
value,
|
|
172
194
|
disabled = false,
|
|
173
195
|
textValue: textValueProp,
|
|
174
|
-
index
|
|
175
|
-
|
|
176
|
-
|
|
196
|
+
index
|
|
197
|
+
} = _a, itemProps = __objRest(_a, [
|
|
198
|
+
"__scopeSelect",
|
|
199
|
+
"value",
|
|
200
|
+
"disabled",
|
|
201
|
+
"textValue",
|
|
202
|
+
"index"
|
|
203
|
+
]);
|
|
177
204
|
const context = useSelectContext(ITEM_NAME, __scopeSelect);
|
|
178
205
|
const isSelected = context.value === value;
|
|
179
|
-
const [textValue, setTextValue] = React.useState(textValueProp
|
|
206
|
+
const [textValue, setTextValue] = React.useState(textValueProp ?? "");
|
|
180
207
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
181
208
|
const textId = useId();
|
|
182
209
|
const {
|
|
@@ -206,7 +233,7 @@ const SelectItem = React.forwardRef((props, forwardedRef) => {
|
|
|
206
233
|
onChange(value);
|
|
207
234
|
setOpen(false);
|
|
208
235
|
}
|
|
209
|
-
React.
|
|
236
|
+
React.useLayoutEffect(() => {
|
|
210
237
|
clearTimeout(timeoutRef.current);
|
|
211
238
|
if (open) {
|
|
212
239
|
if (selectedIndex !== index) {
|
|
@@ -237,8 +264,9 @@ const SelectItem = React.forwardRef((props, forwardedRef) => {
|
|
|
237
264
|
textId: textId || "",
|
|
238
265
|
isSelected,
|
|
239
266
|
onItemTextChange: React.useCallback((node) => {
|
|
267
|
+
setTextValue((prevTextValue) => prevTextValue || ((node == null ? void 0 : node.textContent) ?? "").trim());
|
|
240
268
|
}, [])
|
|
241
|
-
}, /* @__PURE__ */ React.createElement(ListItem, {
|
|
269
|
+
}, /* @__PURE__ */ React.createElement(ListItem, __spreadValues(__spreadValues({
|
|
242
270
|
backgrounded: true,
|
|
243
271
|
hoverTheme: true,
|
|
244
272
|
pressTheme: true,
|
|
@@ -251,29 +279,27 @@ const SelectItem = React.forwardRef((props, forwardedRef) => {
|
|
|
251
279
|
"aria-disabled": disabled || void 0,
|
|
252
280
|
"data-disabled": disabled ? "" : void 0,
|
|
253
281
|
tabIndex: disabled ? void 0 : -1,
|
|
254
|
-
size: context.size
|
|
255
|
-
|
|
256
|
-
...selectItemProps
|
|
257
|
-
}));
|
|
282
|
+
size: context.size
|
|
283
|
+
}, itemProps), selectItemProps)));
|
|
258
284
|
});
|
|
259
285
|
SelectItem.displayName = ITEM_NAME;
|
|
260
286
|
const ITEM_TEXT_NAME = "SelectItemText";
|
|
261
287
|
const SelectItemTextFrame = styled(Paragraph, {
|
|
262
288
|
name: ITEM_TEXT_NAME,
|
|
263
|
-
|
|
289
|
+
selectable: false
|
|
264
290
|
});
|
|
265
291
|
const SelectItemText = React.forwardRef((props, forwardedRef) => {
|
|
266
|
-
const { __scopeSelect, className, style,
|
|
292
|
+
const _a = props, { __scopeSelect, className, style } = _a, itemTextProps = __objRest(_a, ["__scopeSelect", "className", "style"]);
|
|
267
293
|
const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
268
294
|
const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
269
295
|
const ref = React.useRef(null);
|
|
270
296
|
const composedRefs = useComposedRefs(forwardedRef, ref, itemContext.onItemTextChange);
|
|
271
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SelectItemTextFrame, {
|
|
297
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SelectItemTextFrame, __spreadProps(__spreadValues({
|
|
272
298
|
size: context.size,
|
|
273
|
-
id: itemContext.textId
|
|
274
|
-
|
|
299
|
+
id: itemContext.textId
|
|
300
|
+
}, itemTextProps), {
|
|
275
301
|
ref: composedRefs
|
|
276
|
-
}), itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null);
|
|
302
|
+
})), itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null);
|
|
277
303
|
});
|
|
278
304
|
SelectItemText.displayName = ITEM_TEXT_NAME;
|
|
279
305
|
const ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
|
@@ -281,13 +307,13 @@ const SelectItemIndicatorFrame = styled(XStack, {
|
|
|
281
307
|
name: ITEM_TEXT_NAME
|
|
282
308
|
});
|
|
283
309
|
const SelectItemIndicator = React.forwardRef((props, forwardedRef) => {
|
|
284
|
-
const { __scopeSelect,
|
|
310
|
+
const _a = props, { __scopeSelect } = _a, itemIndicatorProps = __objRest(_a, ["__scopeSelect"]);
|
|
285
311
|
const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
|
286
|
-
return itemContext.isSelected ? /* @__PURE__ */ React.createElement(SelectItemIndicatorFrame, {
|
|
287
|
-
"aria-hidden": true
|
|
288
|
-
|
|
312
|
+
return itemContext.isSelected ? /* @__PURE__ */ React.createElement(SelectItemIndicatorFrame, __spreadProps(__spreadValues({
|
|
313
|
+
"aria-hidden": true
|
|
314
|
+
}, itemIndicatorProps), {
|
|
289
315
|
ref: forwardedRef
|
|
290
|
-
}) : null;
|
|
316
|
+
})) : null;
|
|
291
317
|
});
|
|
292
318
|
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
293
319
|
const GROUP_NAME = "SelectGroup";
|
|
@@ -297,58 +323,58 @@ const SelectGroupFrame = styled(YStack, {
|
|
|
297
323
|
width: "100%"
|
|
298
324
|
});
|
|
299
325
|
const SelectGroup = React.forwardRef((props, forwardedRef) => {
|
|
300
|
-
const { __scopeSelect,
|
|
326
|
+
const _a = props, { __scopeSelect } = _a, groupProps = __objRest(_a, ["__scopeSelect"]);
|
|
301
327
|
const groupId = useId();
|
|
302
328
|
return /* @__PURE__ */ React.createElement(SelectGroupContextProvider, {
|
|
303
329
|
scope: __scopeSelect,
|
|
304
330
|
id: groupId || ""
|
|
305
|
-
}, /* @__PURE__ */ React.createElement(SelectGroupFrame, {
|
|
331
|
+
}, /* @__PURE__ */ React.createElement(SelectGroupFrame, __spreadProps(__spreadValues({
|
|
306
332
|
role: "group",
|
|
307
|
-
"aria-labelledby": groupId
|
|
308
|
-
|
|
333
|
+
"aria-labelledby": groupId
|
|
334
|
+
}, groupProps), {
|
|
309
335
|
ref: forwardedRef
|
|
310
|
-
}));
|
|
336
|
+
})));
|
|
311
337
|
});
|
|
312
338
|
SelectGroup.displayName = GROUP_NAME;
|
|
313
339
|
const LABEL_NAME = "SelectLabel";
|
|
314
340
|
const SelectLabel = React.forwardRef((props, forwardedRef) => {
|
|
315
|
-
const { __scopeSelect,
|
|
341
|
+
const _a = props, { __scopeSelect } = _a, labelProps = __objRest(_a, ["__scopeSelect"]);
|
|
316
342
|
const context = useSelectContext(LABEL_NAME, __scopeSelect);
|
|
317
343
|
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
318
|
-
return /* @__PURE__ */ React.createElement(ListItem, {
|
|
344
|
+
return /* @__PURE__ */ React.createElement(ListItem, __spreadProps(__spreadValues({
|
|
319
345
|
componentName: LABEL_NAME,
|
|
320
346
|
fontWeight: "800",
|
|
321
347
|
id: groupContext.id,
|
|
322
|
-
size: context.size
|
|
323
|
-
|
|
348
|
+
size: context.size
|
|
349
|
+
}, labelProps), {
|
|
324
350
|
ref: forwardedRef
|
|
325
|
-
});
|
|
351
|
+
}));
|
|
326
352
|
});
|
|
327
353
|
SelectLabel.displayName = LABEL_NAME;
|
|
328
354
|
const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
329
355
|
const SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
|
|
330
|
-
return /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, {
|
|
331
|
-
componentName: SCROLL_UP_BUTTON_NAME
|
|
332
|
-
|
|
356
|
+
return /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, __spreadProps(__spreadValues({
|
|
357
|
+
componentName: SCROLL_UP_BUTTON_NAME
|
|
358
|
+
}, props), {
|
|
333
359
|
dir: "up",
|
|
334
360
|
ref: forwardedRef
|
|
335
|
-
});
|
|
361
|
+
}));
|
|
336
362
|
});
|
|
337
363
|
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
338
364
|
const SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
339
365
|
const SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
|
|
340
|
-
return /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, {
|
|
341
|
-
componentName: SCROLL_DOWN_BUTTON_NAME
|
|
342
|
-
|
|
366
|
+
return /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, __spreadProps(__spreadValues({
|
|
367
|
+
componentName: SCROLL_DOWN_BUTTON_NAME
|
|
368
|
+
}, props), {
|
|
343
369
|
dir: "down",
|
|
344
370
|
ref: forwardedRef
|
|
345
|
-
});
|
|
371
|
+
}));
|
|
346
372
|
});
|
|
347
373
|
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
348
374
|
const SelectScrollButtonImpl = React.forwardRef((props, forwardedRef) => {
|
|
349
|
-
var
|
|
350
|
-
const { __scopeSelect, dir, componentName,
|
|
351
|
-
const { floatingRef, increaseHeight, forceUpdate,
|
|
375
|
+
var _c;
|
|
376
|
+
const _a = props, { __scopeSelect, dir, componentName } = _a, scrollIndicatorProps = __objRest(_a, ["__scopeSelect", "dir", "componentName"]);
|
|
377
|
+
const _b = useSelectContext(componentName, __scopeSelect), { floatingRef, increaseHeight, forceUpdate } = _b, context = __objRest(_b, ["floatingRef", "increaseHeight", "forceUpdate"]);
|
|
352
378
|
const intervalRef = React.useRef();
|
|
353
379
|
const loopingRef = React.useRef(false);
|
|
354
380
|
const isVisible = context[dir === "down" ? "canScrollDown" : "canScrollUp"];
|
|
@@ -388,15 +414,16 @@ const SelectScrollButtonImpl = React.forwardRef((props, forwardedRef) => {
|
|
|
388
414
|
forceUpdate();
|
|
389
415
|
}
|
|
390
416
|
};
|
|
391
|
-
return /* @__PURE__ */ React.createElement(YStack, {
|
|
417
|
+
return /* @__PURE__ */ React.createElement(YStack, __spreadProps(__spreadValues({
|
|
392
418
|
ref: composedRefs,
|
|
393
419
|
componentName,
|
|
394
|
-
"aria-hidden": true
|
|
395
|
-
|
|
420
|
+
"aria-hidden": true
|
|
421
|
+
}, scrollIndicatorProps), {
|
|
422
|
+
zIndex: 1e3,
|
|
396
423
|
position: strategy,
|
|
397
424
|
left: x || 0,
|
|
398
425
|
top: y || 0,
|
|
399
|
-
width: `calc(${((
|
|
426
|
+
width: `calc(${(((_c = floatingRef.current) == null ? void 0 : _c.offsetWidth) ?? 0) - 2}px)`,
|
|
400
427
|
background: `linear-gradient(to ${dir === "up" ? "bottom" : "top"}, #29282b 50%, rgba(53, 54, 55, 0.01))`,
|
|
401
428
|
onPointerMove: () => {
|
|
402
429
|
if (!loopingRef.current) {
|
|
@@ -408,7 +435,7 @@ const SelectScrollButtonImpl = React.forwardRef((props, forwardedRef) => {
|
|
|
408
435
|
loopingRef.current = false;
|
|
409
436
|
clearInterval(intervalRef.current);
|
|
410
437
|
}
|
|
411
|
-
});
|
|
438
|
+
}));
|
|
412
439
|
});
|
|
413
440
|
const SelectSeparator = styled(Separator, {
|
|
414
441
|
name: "SelectSeparator"
|
|
@@ -481,8 +508,7 @@ const Select = withStaticProperties((props) => {
|
|
|
481
508
|
placement: "bottom",
|
|
482
509
|
middleware: middlewareType === "align" ? [
|
|
483
510
|
offset(({ rects }) => {
|
|
484
|
-
|
|
485
|
-
const index = (_a = activeIndexRef.current) != null ? _a : selectedIndexRef.current;
|
|
511
|
+
const index = activeIndexRef.current ?? selectedIndexRef.current;
|
|
486
512
|
if (index == null) {
|
|
487
513
|
return 0;
|
|
488
514
|
}
|
|
@@ -597,7 +623,7 @@ const Select = withStaticProperties((props) => {
|
|
|
597
623
|
}, [middlewareType]);
|
|
598
624
|
const touchPageYRef = React.useRef(null);
|
|
599
625
|
const handleWheel = React.useCallback((event) => {
|
|
600
|
-
var _a
|
|
626
|
+
var _a;
|
|
601
627
|
const pinching = event.ctrlKey;
|
|
602
628
|
const currentTarget = event.currentTarget;
|
|
603
629
|
function isWheelEvent(event2) {
|
|
@@ -606,7 +632,7 @@ const Select = withStaticProperties((props) => {
|
|
|
606
632
|
function isTouchEvent(event2) {
|
|
607
633
|
return event2.touches != null;
|
|
608
634
|
}
|
|
609
|
-
if (Math.abs(((
|
|
635
|
+
if (Math.abs(((currentTarget == null ? void 0 : currentTarget.offsetHeight) ?? 0) - (visualViewport.height - WINDOW_PADDING * 2)) > 1 && !pinching) {
|
|
610
636
|
event.preventDefault();
|
|
611
637
|
} else if (isWheelEvent(event) && isFirefox) {
|
|
612
638
|
currentTarget.scrollTop += event.deltaY;
|
|
@@ -615,7 +641,7 @@ const Select = withStaticProperties((props) => {
|
|
|
615
641
|
let delta = 5;
|
|
616
642
|
if (isTouchEvent(event)) {
|
|
617
643
|
const currentPageY = touchPageYRef.current;
|
|
618
|
-
const pageY = (
|
|
644
|
+
const pageY = (_a = event.touches[0]) == null ? void 0 : _a.pageY;
|
|
619
645
|
if (pageY != null) {
|
|
620
646
|
touchPageYRef.current = pageY;
|
|
621
647
|
if (currentPageY != null) {
|
|
@@ -651,12 +677,12 @@ const Select = withStaticProperties((props) => {
|
|
|
651
677
|
};
|
|
652
678
|
}, [update]);
|
|
653
679
|
React.useLayoutEffect(() => {
|
|
654
|
-
var _a
|
|
680
|
+
var _a;
|
|
655
681
|
const floating2 = floatingRef.current;
|
|
656
682
|
if (open && controlledScrolling && floating2) {
|
|
657
683
|
const item = activeIndex != null ? listItemsRef.current[activeIndex] : selectedIndex != null ? listItemsRef.current[selectedIndex] : null;
|
|
658
684
|
if (item && prevActiveIndex != null) {
|
|
659
|
-
const itemHeight = (
|
|
685
|
+
const itemHeight = ((_a = listItemsRef.current[prevActiveIndex]) == null ? void 0 : _a.offsetHeight) ?? 0;
|
|
660
686
|
const floatingHeight = floating2.offsetHeight;
|
|
661
687
|
const top = item.offsetTop;
|
|
662
688
|
const bottom = top + itemHeight;
|
|
@@ -670,7 +696,7 @@ const Select = withStaticProperties((props) => {
|
|
|
670
696
|
const diff = bottom - floatingHeight - floating2.scrollTop + 20;
|
|
671
697
|
floating2.scrollTop += diff;
|
|
672
698
|
if (activeIndex != selectedIndex && activeIndex != null) {
|
|
673
|
-
floating2.scrollTop -=
|
|
699
|
+
floating2.scrollTop -= increaseHeight(floating2, diff) ?? 0;
|
|
674
700
|
}
|
|
675
701
|
}
|
|
676
702
|
}
|
|
@@ -748,8 +774,7 @@ const Select = withStaticProperties((props) => {
|
|
|
748
774
|
setValueAtIndex: (index, value2) => {
|
|
749
775
|
listContentRef.current[index] = value2;
|
|
750
776
|
},
|
|
751
|
-
interactions: {
|
|
752
|
-
...interactions,
|
|
777
|
+
interactions: __spreadProps(__spreadValues({}, interactions), {
|
|
753
778
|
getReferenceProps() {
|
|
754
779
|
return interactions.getReferenceProps({
|
|
755
780
|
ref: reference,
|
|
@@ -768,8 +793,13 @@ const Select = withStaticProperties((props) => {
|
|
|
768
793
|
className: "Select",
|
|
769
794
|
style: {
|
|
770
795
|
position: strategy,
|
|
771
|
-
top: y
|
|
772
|
-
left: x
|
|
796
|
+
top: y ?? "",
|
|
797
|
+
left: x ?? "",
|
|
798
|
+
outline: 0,
|
|
799
|
+
overflowY: "auto",
|
|
800
|
+
listStyleType: "none",
|
|
801
|
+
scrollbarWidth: "none",
|
|
802
|
+
userSelect: "none"
|
|
773
803
|
},
|
|
774
804
|
onPointerEnter() {
|
|
775
805
|
setControlledScrolling(false);
|
|
@@ -785,7 +815,7 @@ const Select = withStaticProperties((props) => {
|
|
|
785
815
|
}
|
|
786
816
|
});
|
|
787
817
|
}
|
|
788
|
-
},
|
|
818
|
+
}),
|
|
789
819
|
floatingContext: context,
|
|
790
820
|
activeIndex,
|
|
791
821
|
canScrollDown: !!showDownArrow,
|
|
@@ -794,7 +824,7 @@ const Select = withStaticProperties((props) => {
|
|
|
794
824
|
dataRef: context.dataRef,
|
|
795
825
|
listRef: listItemsRef,
|
|
796
826
|
onChange: setValue,
|
|
797
|
-
selectedIndex
|
|
827
|
+
selectedIndex,
|
|
798
828
|
setActiveIndex,
|
|
799
829
|
setOpen,
|
|
800
830
|
setSelectedIndex,
|