@tamagui/select 1.0.1-beta.75 → 1.0.1-beta.78
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 +6 -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 +115 -96
- package/dist/esm/Select.js.map +2 -2
- package/dist/jsx/Select.js +11 -18
- package/package.json +10 -10
- package/src/Select.tsx +9 -13
- package/types/Select.d.ts +72 -23
- 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
|
|
@@ -38,15 +68,8 @@ if (isFirefox) {
|
|
|
38
68
|
document.body.classList.add("firefox");
|
|
39
69
|
}
|
|
40
70
|
function getVisualOffsetTop() {
|
|
41
|
-
return !/^((?!chrome|android).)*safari/i.test(userAgent) ? visualViewport.offsetTop : 0;
|
|
71
|
+
return !/^((?!chrome|android).)*safari/i.test(userAgent) ? (visualViewport == null ? void 0 : visualViewport.offsetTop) ?? 0 : 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,11 +103,10 @@ 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";
|
|
@@ -131,9 +154,8 @@ const SelectViewportFrame = styled(ThemeableStack, {
|
|
|
131
154
|
variants: {
|
|
132
155
|
size: {
|
|
133
156
|
"...size": (val, { tokens }) => {
|
|
134
|
-
var _a;
|
|
135
157
|
return {
|
|
136
|
-
borderRadius:
|
|
158
|
+
borderRadius: tokens.radius[val] ?? val
|
|
137
159
|
};
|
|
138
160
|
}
|
|
139
161
|
}
|
|
@@ -143,7 +165,7 @@ const SelectViewportFrame = styled(ThemeableStack, {
|
|
|
143
165
|
}
|
|
144
166
|
});
|
|
145
167
|
const SelectViewport = React.forwardRef((props, forwardedRef) => {
|
|
146
|
-
const { __scopeSelect, children,
|
|
168
|
+
const _a = props, { __scopeSelect, children } = _a, viewportProps = __objRest(_a, ["__scopeSelect", "children"]);
|
|
147
169
|
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
148
170
|
const composedRefs = useComposedRefs(forwardedRef);
|
|
149
171
|
const prevScrollTopRef = React.useRef(0);
|
|
@@ -154,31 +176,34 @@ const SelectViewport = React.forwardRef((props, forwardedRef) => {
|
|
|
154
176
|
}), /* @__PURE__ */ React.createElement(FloatingFocusManager, {
|
|
155
177
|
context: context.floatingContext,
|
|
156
178
|
preventTabbing: true
|
|
157
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
158
|
-
...context.interactions.getFloatingProps()
|
|
159
|
-
}, /* @__PURE__ */ React.createElement(SelectViewportFrame, {
|
|
179
|
+
}, /* @__PURE__ */ React.createElement("div", __spreadValues({}, context.interactions.getFloatingProps()), /* @__PURE__ */ React.createElement(SelectViewportFrame, __spreadProps(__spreadValues({
|
|
160
180
|
size: context.size,
|
|
161
181
|
"data-radix-select-viewport": "",
|
|
162
|
-
role: "presentation"
|
|
163
|
-
|
|
182
|
+
role: "presentation"
|
|
183
|
+
}, viewportProps), {
|
|
164
184
|
ref: composedRefs
|
|
165
|
-
}, children))));
|
|
185
|
+
}), children))));
|
|
166
186
|
});
|
|
167
187
|
SelectViewport.displayName = VIEWPORT_NAME;
|
|
168
188
|
const ITEM_NAME = "SelectItem";
|
|
169
189
|
const [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
|
|
170
190
|
const SelectItem = React.forwardRef((props, forwardedRef) => {
|
|
171
|
-
const {
|
|
191
|
+
const _a = props, {
|
|
172
192
|
__scopeSelect,
|
|
173
193
|
value,
|
|
174
194
|
disabled = false,
|
|
175
195
|
textValue: textValueProp,
|
|
176
|
-
index
|
|
177
|
-
|
|
178
|
-
|
|
196
|
+
index
|
|
197
|
+
} = _a, itemProps = __objRest(_a, [
|
|
198
|
+
"__scopeSelect",
|
|
199
|
+
"value",
|
|
200
|
+
"disabled",
|
|
201
|
+
"textValue",
|
|
202
|
+
"index"
|
|
203
|
+
]);
|
|
179
204
|
const context = useSelectContext(ITEM_NAME, __scopeSelect);
|
|
180
205
|
const isSelected = context.value === value;
|
|
181
|
-
const [textValue, setTextValue] = React.useState(textValueProp
|
|
206
|
+
const [textValue, setTextValue] = React.useState(textValueProp ?? "");
|
|
182
207
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
183
208
|
const textId = useId();
|
|
184
209
|
const {
|
|
@@ -239,12 +264,9 @@ const SelectItem = React.forwardRef((props, forwardedRef) => {
|
|
|
239
264
|
textId: textId || "",
|
|
240
265
|
isSelected,
|
|
241
266
|
onItemTextChange: React.useCallback((node) => {
|
|
242
|
-
setTextValue((prevTextValue) =>
|
|
243
|
-
var _a;
|
|
244
|
-
return prevTextValue || ((_a = node == null ? void 0 : node.textContent) != null ? _a : "").trim();
|
|
245
|
-
});
|
|
267
|
+
setTextValue((prevTextValue) => prevTextValue || ((node == null ? void 0 : node.textContent) ?? "").trim());
|
|
246
268
|
}, [])
|
|
247
|
-
}, /* @__PURE__ */ React.createElement(ListItem, {
|
|
269
|
+
}, /* @__PURE__ */ React.createElement(ListItem, __spreadValues(__spreadValues({
|
|
248
270
|
backgrounded: true,
|
|
249
271
|
hoverTheme: true,
|
|
250
272
|
pressTheme: true,
|
|
@@ -257,10 +279,8 @@ const SelectItem = React.forwardRef((props, forwardedRef) => {
|
|
|
257
279
|
"aria-disabled": disabled || void 0,
|
|
258
280
|
"data-disabled": disabled ? "" : void 0,
|
|
259
281
|
tabIndex: disabled ? void 0 : -1,
|
|
260
|
-
size: context.size
|
|
261
|
-
|
|
262
|
-
...selectItemProps
|
|
263
|
-
}));
|
|
282
|
+
size: context.size
|
|
283
|
+
}, itemProps), selectItemProps)));
|
|
264
284
|
});
|
|
265
285
|
SelectItem.displayName = ITEM_NAME;
|
|
266
286
|
const ITEM_TEXT_NAME = "SelectItemText";
|
|
@@ -269,17 +289,17 @@ const SelectItemTextFrame = styled(Paragraph, {
|
|
|
269
289
|
selectable: false
|
|
270
290
|
});
|
|
271
291
|
const SelectItemText = React.forwardRef((props, forwardedRef) => {
|
|
272
|
-
const { __scopeSelect, className, style,
|
|
292
|
+
const _a = props, { __scopeSelect, className, style } = _a, itemTextProps = __objRest(_a, ["__scopeSelect", "className", "style"]);
|
|
273
293
|
const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
274
294
|
const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
275
295
|
const ref = React.useRef(null);
|
|
276
296
|
const composedRefs = useComposedRefs(forwardedRef, ref, itemContext.onItemTextChange);
|
|
277
|
-
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({
|
|
278
298
|
size: context.size,
|
|
279
|
-
id: itemContext.textId
|
|
280
|
-
|
|
299
|
+
id: itemContext.textId
|
|
300
|
+
}, itemTextProps), {
|
|
281
301
|
ref: composedRefs
|
|
282
|
-
}), 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);
|
|
283
303
|
});
|
|
284
304
|
SelectItemText.displayName = ITEM_TEXT_NAME;
|
|
285
305
|
const ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
|
@@ -287,13 +307,13 @@ const SelectItemIndicatorFrame = styled(XStack, {
|
|
|
287
307
|
name: ITEM_TEXT_NAME
|
|
288
308
|
});
|
|
289
309
|
const SelectItemIndicator = React.forwardRef((props, forwardedRef) => {
|
|
290
|
-
const { __scopeSelect,
|
|
310
|
+
const _a = props, { __scopeSelect } = _a, itemIndicatorProps = __objRest(_a, ["__scopeSelect"]);
|
|
291
311
|
const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
|
292
|
-
return itemContext.isSelected ? /* @__PURE__ */ React.createElement(SelectItemIndicatorFrame, {
|
|
293
|
-
"aria-hidden": true
|
|
294
|
-
|
|
312
|
+
return itemContext.isSelected ? /* @__PURE__ */ React.createElement(SelectItemIndicatorFrame, __spreadProps(__spreadValues({
|
|
313
|
+
"aria-hidden": true
|
|
314
|
+
}, itemIndicatorProps), {
|
|
295
315
|
ref: forwardedRef
|
|
296
|
-
}) : null;
|
|
316
|
+
})) : null;
|
|
297
317
|
});
|
|
298
318
|
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
299
319
|
const GROUP_NAME = "SelectGroup";
|
|
@@ -303,58 +323,58 @@ const SelectGroupFrame = styled(YStack, {
|
|
|
303
323
|
width: "100%"
|
|
304
324
|
});
|
|
305
325
|
const SelectGroup = React.forwardRef((props, forwardedRef) => {
|
|
306
|
-
const { __scopeSelect,
|
|
326
|
+
const _a = props, { __scopeSelect } = _a, groupProps = __objRest(_a, ["__scopeSelect"]);
|
|
307
327
|
const groupId = useId();
|
|
308
328
|
return /* @__PURE__ */ React.createElement(SelectGroupContextProvider, {
|
|
309
329
|
scope: __scopeSelect,
|
|
310
330
|
id: groupId || ""
|
|
311
|
-
}, /* @__PURE__ */ React.createElement(SelectGroupFrame, {
|
|
331
|
+
}, /* @__PURE__ */ React.createElement(SelectGroupFrame, __spreadProps(__spreadValues({
|
|
312
332
|
role: "group",
|
|
313
|
-
"aria-labelledby": groupId
|
|
314
|
-
|
|
333
|
+
"aria-labelledby": groupId
|
|
334
|
+
}, groupProps), {
|
|
315
335
|
ref: forwardedRef
|
|
316
|
-
}));
|
|
336
|
+
})));
|
|
317
337
|
});
|
|
318
338
|
SelectGroup.displayName = GROUP_NAME;
|
|
319
339
|
const LABEL_NAME = "SelectLabel";
|
|
320
340
|
const SelectLabel = React.forwardRef((props, forwardedRef) => {
|
|
321
|
-
const { __scopeSelect,
|
|
341
|
+
const _a = props, { __scopeSelect } = _a, labelProps = __objRest(_a, ["__scopeSelect"]);
|
|
322
342
|
const context = useSelectContext(LABEL_NAME, __scopeSelect);
|
|
323
343
|
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
324
|
-
return /* @__PURE__ */ React.createElement(ListItem, {
|
|
344
|
+
return /* @__PURE__ */ React.createElement(ListItem, __spreadProps(__spreadValues({
|
|
325
345
|
componentName: LABEL_NAME,
|
|
326
346
|
fontWeight: "800",
|
|
327
347
|
id: groupContext.id,
|
|
328
|
-
size: context.size
|
|
329
|
-
|
|
348
|
+
size: context.size
|
|
349
|
+
}, labelProps), {
|
|
330
350
|
ref: forwardedRef
|
|
331
|
-
});
|
|
351
|
+
}));
|
|
332
352
|
});
|
|
333
353
|
SelectLabel.displayName = LABEL_NAME;
|
|
334
354
|
const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
335
355
|
const SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
|
|
336
|
-
return /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, {
|
|
337
|
-
componentName: SCROLL_UP_BUTTON_NAME
|
|
338
|
-
|
|
356
|
+
return /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, __spreadProps(__spreadValues({
|
|
357
|
+
componentName: SCROLL_UP_BUTTON_NAME
|
|
358
|
+
}, props), {
|
|
339
359
|
dir: "up",
|
|
340
360
|
ref: forwardedRef
|
|
341
|
-
});
|
|
361
|
+
}));
|
|
342
362
|
});
|
|
343
363
|
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
344
364
|
const SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
345
365
|
const SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
|
|
346
|
-
return /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, {
|
|
347
|
-
componentName: SCROLL_DOWN_BUTTON_NAME
|
|
348
|
-
|
|
366
|
+
return /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, __spreadProps(__spreadValues({
|
|
367
|
+
componentName: SCROLL_DOWN_BUTTON_NAME
|
|
368
|
+
}, props), {
|
|
349
369
|
dir: "down",
|
|
350
370
|
ref: forwardedRef
|
|
351
|
-
});
|
|
371
|
+
}));
|
|
352
372
|
});
|
|
353
373
|
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
354
374
|
const SelectScrollButtonImpl = React.forwardRef((props, forwardedRef) => {
|
|
355
|
-
var
|
|
356
|
-
const { __scopeSelect, dir, componentName,
|
|
357
|
-
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"]);
|
|
358
378
|
const intervalRef = React.useRef();
|
|
359
379
|
const loopingRef = React.useRef(false);
|
|
360
380
|
const isVisible = context[dir === "down" ? "canScrollDown" : "canScrollUp"];
|
|
@@ -394,16 +414,16 @@ const SelectScrollButtonImpl = React.forwardRef((props, forwardedRef) => {
|
|
|
394
414
|
forceUpdate();
|
|
395
415
|
}
|
|
396
416
|
};
|
|
397
|
-
return /* @__PURE__ */ React.createElement(YStack, {
|
|
417
|
+
return /* @__PURE__ */ React.createElement(YStack, __spreadProps(__spreadValues({
|
|
398
418
|
ref: composedRefs,
|
|
399
419
|
componentName,
|
|
400
|
-
"aria-hidden": true
|
|
401
|
-
|
|
420
|
+
"aria-hidden": true
|
|
421
|
+
}, scrollIndicatorProps), {
|
|
402
422
|
zIndex: 1e3,
|
|
403
423
|
position: strategy,
|
|
404
424
|
left: x || 0,
|
|
405
425
|
top: y || 0,
|
|
406
|
-
width: `calc(${((
|
|
426
|
+
width: `calc(${(((_c = floatingRef.current) == null ? void 0 : _c.offsetWidth) ?? 0) - 2}px)`,
|
|
407
427
|
background: `linear-gradient(to ${dir === "up" ? "bottom" : "top"}, #29282b 50%, rgba(53, 54, 55, 0.01))`,
|
|
408
428
|
onPointerMove: () => {
|
|
409
429
|
if (!loopingRef.current) {
|
|
@@ -415,7 +435,7 @@ const SelectScrollButtonImpl = React.forwardRef((props, forwardedRef) => {
|
|
|
415
435
|
loopingRef.current = false;
|
|
416
436
|
clearInterval(intervalRef.current);
|
|
417
437
|
}
|
|
418
|
-
});
|
|
438
|
+
}));
|
|
419
439
|
});
|
|
420
440
|
const SelectSeparator = styled(Separator, {
|
|
421
441
|
name: "SelectSeparator"
|
|
@@ -488,8 +508,7 @@ const Select = withStaticProperties((props) => {
|
|
|
488
508
|
placement: "bottom",
|
|
489
509
|
middleware: middlewareType === "align" ? [
|
|
490
510
|
offset(({ rects }) => {
|
|
491
|
-
|
|
492
|
-
const index = (_a = activeIndexRef.current) != null ? _a : selectedIndexRef.current;
|
|
511
|
+
const index = activeIndexRef.current ?? selectedIndexRef.current;
|
|
493
512
|
if (index == null) {
|
|
494
513
|
return 0;
|
|
495
514
|
}
|
|
@@ -585,8 +604,9 @@ const Select = withStaticProperties((props) => {
|
|
|
585
604
|
const rect = floating2.getBoundingClientRect();
|
|
586
605
|
const rectTop = rect.top;
|
|
587
606
|
const rectBottom = rect.bottom;
|
|
588
|
-
const
|
|
589
|
-
|
|
607
|
+
const viewportHeight = (visualViewport == null ? void 0 : visualViewport.height) ?? 0;
|
|
608
|
+
const visualMaxHeight = viewportHeight - WINDOW_PADDING * 2;
|
|
609
|
+
if (amount < 0 && selectedIndexRef.current != null && Math.round(rectBottom) < Math.round(viewportHeight + getVisualOffsetTop() - WINDOW_PADDING)) {
|
|
590
610
|
floating2.style.maxHeight = `${Math.min(visualMaxHeight, currentMaxHeight - amount)}px`;
|
|
591
611
|
}
|
|
592
612
|
if (amount > 0 && Math.round(rectTop) > Math.round(WINDOW_PADDING - getVisualOffsetTop()) && floating2.scrollHeight > floating2.offsetHeight) {
|
|
@@ -604,7 +624,7 @@ const Select = withStaticProperties((props) => {
|
|
|
604
624
|
}, [middlewareType]);
|
|
605
625
|
const touchPageYRef = React.useRef(null);
|
|
606
626
|
const handleWheel = React.useCallback((event) => {
|
|
607
|
-
var _a
|
|
627
|
+
var _a;
|
|
608
628
|
const pinching = event.ctrlKey;
|
|
609
629
|
const currentTarget = event.currentTarget;
|
|
610
630
|
function isWheelEvent(event2) {
|
|
@@ -613,7 +633,7 @@ const Select = withStaticProperties((props) => {
|
|
|
613
633
|
function isTouchEvent(event2) {
|
|
614
634
|
return event2.touches != null;
|
|
615
635
|
}
|
|
616
|
-
if (Math.abs(((
|
|
636
|
+
if (Math.abs(((currentTarget == null ? void 0 : currentTarget.offsetHeight) ?? 0) - (((visualViewport == null ? void 0 : visualViewport.height) ?? 0) - WINDOW_PADDING * 2)) > 1 && !pinching) {
|
|
617
637
|
event.preventDefault();
|
|
618
638
|
} else if (isWheelEvent(event) && isFirefox) {
|
|
619
639
|
currentTarget.scrollTop += event.deltaY;
|
|
@@ -622,7 +642,7 @@ const Select = withStaticProperties((props) => {
|
|
|
622
642
|
let delta = 5;
|
|
623
643
|
if (isTouchEvent(event)) {
|
|
624
644
|
const currentPageY = touchPageYRef.current;
|
|
625
|
-
const pageY = (
|
|
645
|
+
const pageY = (_a = event.touches[0]) == null ? void 0 : _a.pageY;
|
|
626
646
|
if (pageY != null) {
|
|
627
647
|
touchPageYRef.current = pageY;
|
|
628
648
|
if (currentPageY != null) {
|
|
@@ -658,12 +678,12 @@ const Select = withStaticProperties((props) => {
|
|
|
658
678
|
};
|
|
659
679
|
}, [update]);
|
|
660
680
|
React.useLayoutEffect(() => {
|
|
661
|
-
var _a
|
|
681
|
+
var _a;
|
|
662
682
|
const floating2 = floatingRef.current;
|
|
663
683
|
if (open && controlledScrolling && floating2) {
|
|
664
684
|
const item = activeIndex != null ? listItemsRef.current[activeIndex] : selectedIndex != null ? listItemsRef.current[selectedIndex] : null;
|
|
665
685
|
if (item && prevActiveIndex != null) {
|
|
666
|
-
const itemHeight = (
|
|
686
|
+
const itemHeight = ((_a = listItemsRef.current[prevActiveIndex]) == null ? void 0 : _a.offsetHeight) ?? 0;
|
|
667
687
|
const floatingHeight = floating2.offsetHeight;
|
|
668
688
|
const top = item.offsetTop;
|
|
669
689
|
const bottom = top + itemHeight;
|
|
@@ -677,7 +697,7 @@ const Select = withStaticProperties((props) => {
|
|
|
677
697
|
const diff = bottom - floatingHeight - floating2.scrollTop + 20;
|
|
678
698
|
floating2.scrollTop += diff;
|
|
679
699
|
if (activeIndex != selectedIndex && activeIndex != null) {
|
|
680
|
-
floating2.scrollTop -=
|
|
700
|
+
floating2.scrollTop -= increaseHeight(floating2, diff) ?? 0;
|
|
681
701
|
}
|
|
682
702
|
}
|
|
683
703
|
}
|
|
@@ -705,7 +725,7 @@ const Select = withStaticProperties((props) => {
|
|
|
705
725
|
return;
|
|
706
726
|
}
|
|
707
727
|
floating2.scrollTop = (_a = middlewareData.size) == null ? void 0 : _a.y;
|
|
708
|
-
const closeToBottom = visualViewport.height + getVisualOffsetTop() - referenceRect.bottom < FALLBACK_THRESHOLD;
|
|
728
|
+
const closeToBottom = ((visualViewport == null ? void 0 : visualViewport.height) ?? 0) + getVisualOffsetTop() - referenceRect.bottom < FALLBACK_THRESHOLD;
|
|
709
729
|
const closeToTop = referenceRect.top < FALLBACK_THRESHOLD;
|
|
710
730
|
if (floating2.offsetHeight < MIN_HEIGHT || closeToTop || closeToBottom) {
|
|
711
731
|
setMiddlewareType("fallback");
|
|
@@ -755,8 +775,7 @@ const Select = withStaticProperties((props) => {
|
|
|
755
775
|
setValueAtIndex: (index, value2) => {
|
|
756
776
|
listContentRef.current[index] = value2;
|
|
757
777
|
},
|
|
758
|
-
interactions: {
|
|
759
|
-
...interactions,
|
|
778
|
+
interactions: __spreadProps(__spreadValues({}, interactions), {
|
|
760
779
|
getReferenceProps() {
|
|
761
780
|
return interactions.getReferenceProps({
|
|
762
781
|
ref: reference,
|
|
@@ -775,8 +794,8 @@ const Select = withStaticProperties((props) => {
|
|
|
775
794
|
className: "Select",
|
|
776
795
|
style: {
|
|
777
796
|
position: strategy,
|
|
778
|
-
top: y
|
|
779
|
-
left: x
|
|
797
|
+
top: y ?? "",
|
|
798
|
+
left: x ?? "",
|
|
780
799
|
outline: 0,
|
|
781
800
|
overflowY: "auto",
|
|
782
801
|
listStyleType: "none",
|
|
@@ -797,7 +816,7 @@ const Select = withStaticProperties((props) => {
|
|
|
797
816
|
}
|
|
798
817
|
});
|
|
799
818
|
}
|
|
800
|
-
},
|
|
819
|
+
}),
|
|
801
820
|
floatingContext: context,
|
|
802
821
|
activeIndex,
|
|
803
822
|
canScrollDown: !!showDownArrow,
|