@tamagui/select 1.0.1-beta.113 → 1.0.1-beta.116
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 +61 -567
- package/dist/cjs/Select.js.map +2 -2
- package/dist/cjs/SelectContent.js +53 -0
- package/dist/cjs/SelectContent.js.map +7 -0
- package/dist/cjs/SelectContent.native.js +31 -0
- package/dist/cjs/SelectContent.native.js.map +7 -0
- package/dist/cjs/SelectImpl.js +393 -0
- package/dist/cjs/SelectImpl.js.map +7 -0
- package/dist/cjs/SelectScrollButton.js +128 -0
- package/dist/cjs/SelectScrollButton.js.map +7 -0
- package/dist/cjs/SelectScrollButton.native.js +32 -0
- package/dist/cjs/SelectScrollButton.native.js.map +7 -0
- package/dist/cjs/SelectViewport.js +96 -0
- package/dist/cjs/SelectViewport.js.map +7 -0
- package/dist/cjs/SelectViewport.native.js +43 -0
- package/dist/cjs/SelectViewport.native.js.map +7 -0
- package/dist/cjs/constants.js +47 -0
- package/dist/cjs/constants.js.map +7 -0
- package/dist/cjs/context.js +38 -0
- package/dist/cjs/context.js.map +7 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js +17 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/esm/Select.js +44 -574
- package/dist/esm/Select.js.map +2 -2
- package/dist/esm/SelectContent.js +26 -0
- package/dist/esm/SelectContent.js.map +7 -0
- package/dist/esm/SelectContent.native.js +7 -0
- package/dist/esm/SelectContent.native.js.map +7 -0
- package/dist/esm/SelectImpl.js +378 -0
- package/dist/esm/SelectImpl.js.map +7 -0
- package/dist/esm/SelectScrollButton.js +100 -0
- package/dist/esm/SelectScrollButton.js.map +7 -0
- package/dist/esm/SelectScrollButton.native.js +7 -0
- package/dist/esm/SelectScrollButton.native.js.map +7 -0
- package/dist/esm/SelectViewport.js +68 -0
- package/dist/esm/SelectViewport.js.map +7 -0
- package/dist/esm/SelectViewport.native.js +16 -0
- package/dist/esm/SelectViewport.native.js.map +7 -0
- package/dist/esm/constants.js +17 -0
- package/dist/esm/constants.js.map +7 -0
- package/dist/esm/context.js +11 -0
- package/dist/esm/context.js.map +7 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/jsx/Select.js +43 -516
- package/dist/jsx/Select.js.map +2 -2
- package/dist/jsx/SelectContent.js +19 -0
- package/dist/jsx/SelectContent.js.map +7 -0
- package/dist/jsx/SelectContent.native.js +7 -0
- package/dist/jsx/SelectContent.native.js.map +7 -0
- package/dist/jsx/SelectImpl.js +366 -0
- package/dist/jsx/SelectImpl.js.map +7 -0
- package/dist/jsx/SelectScrollButton.js +78 -0
- package/dist/jsx/SelectScrollButton.js.map +7 -0
- package/dist/jsx/SelectScrollButton.native.js +7 -0
- package/dist/jsx/SelectScrollButton.native.js.map +7 -0
- package/dist/jsx/SelectViewport.js +57 -0
- package/dist/jsx/SelectViewport.js.map +7 -0
- package/dist/jsx/SelectViewport.native.js +14 -0
- package/dist/jsx/SelectViewport.native.js.map +7 -0
- package/dist/jsx/constants.js +17 -0
- package/dist/jsx/constants.js.map +7 -0
- package/dist/jsx/context.js +11 -0
- package/dist/jsx/context.js.map +7 -0
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/index.js.map +2 -2
- package/dist/jsx/types.js +1 -0
- package/dist/jsx/types.js.map +7 -0
- package/package.json +12 -12
- package/src/Select.tsx +69 -890
- package/src/SelectContent.native.tsx +5 -0
- package/src/SelectContent.tsx +34 -0
- package/src/SelectImpl.tsx +511 -0
- package/src/SelectScrollButton.native.tsx +7 -0
- package/src/SelectScrollButton.tsx +150 -0
- package/src/SelectViewport.native.tsx +17 -0
- package/src/SelectViewport.tsx +86 -0
- package/src/constants.tsx +7 -0
- package/src/context.tsx +9 -0
- package/src/index.tsx +7 -0
- package/src/types.tsx +83 -0
- package/types/Select.d.ts +83 -241
- package/types/Select.d.ts.map +1 -1
- package/types/SelectContent.d.ts +4 -0
- package/types/SelectContent.d.ts.map +1 -0
- package/types/SelectContent.native.d.ts +4 -0
- package/types/SelectContent.native.d.ts.map +1 -0
- package/types/SelectImpl.d.ts +9 -0
- package/types/SelectImpl.d.ts.map +1 -0
- package/types/SelectScrollButton.d.ts +6 -0
- package/types/SelectScrollButton.d.ts.map +1 -0
- package/types/SelectScrollButton.native.d.ts +4 -0
- package/types/SelectScrollButton.native.d.ts.map +1 -0
- package/types/SelectViewport.d.ts +127 -0
- package/types/SelectViewport.d.ts.map +1 -0
- package/types/SelectViewport.native.d.ts +54 -0
- package/types/SelectViewport.native.d.ts.map +1 -0
- package/types/constants.d.ts +8 -0
- package/types/constants.d.ts.map +1 -0
- package/types/context.d.ts +17 -0
- package/types/context.d.ts.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -1
- package/types/types.d.ts +74 -0
- package/types/types.d.ts.map +1 -0
package/dist/cjs/Select.js
CHANGED
|
@@ -29,18 +29,16 @@ __export(Select_exports, {
|
|
|
29
29
|
SelectSeparator: () => SelectSeparator,
|
|
30
30
|
SelectSheetContents: () => SelectSheetContents,
|
|
31
31
|
SelectTrigger: () => SelectTrigger,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
getVisualOffsetTop: () => getVisualOffsetTop,
|
|
33
|
+
isFirefox: () => isFirefox,
|
|
34
|
+
useSelectBreakpointActive: () => useSelectBreakpointActive,
|
|
35
|
+
useShowSelectSheet: () => useShowSelectSheet
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(Select_exports);
|
|
37
|
-
var import_react_dom_interactions = require("@floating-ui/react-dom-interactions");
|
|
38
|
-
var import_react_use_previous = require("@radix-ui/react-use-previous");
|
|
39
38
|
var import_compose_refs = require("@tamagui/compose-refs");
|
|
40
39
|
var import_core = require("@tamagui/core");
|
|
41
40
|
var import_core2 = require("@tamagui/core");
|
|
42
41
|
var import_core3 = require("@tamagui/core");
|
|
43
|
-
var import_create_context = require("@tamagui/create-context");
|
|
44
42
|
var import_list_item = require("@tamagui/list-item");
|
|
45
43
|
var import_portal = require("@tamagui/portal");
|
|
46
44
|
var import_separator = require("@tamagui/separator");
|
|
@@ -50,23 +48,28 @@ var import_text = require("@tamagui/text");
|
|
|
50
48
|
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
51
49
|
var React = __toESM(require("react"));
|
|
52
50
|
var ReactDOM = __toESM(require("react-dom"));
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
var import_constants = require("./constants");
|
|
52
|
+
var import_context = require("./context");
|
|
53
|
+
var import_SelectContent = require("./SelectContent");
|
|
54
|
+
var import_SelectImpl = require("./SelectImpl");
|
|
55
|
+
var import_SelectScrollButton = require("./SelectScrollButton");
|
|
56
|
+
var import_SelectViewport = require("./SelectViewport");
|
|
59
57
|
const userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
|
|
60
58
|
const isFirefox = userAgent.toLowerCase().includes("firefox");
|
|
61
|
-
if (isFirefox) {
|
|
62
|
-
document.body.classList.add("firefox");
|
|
63
|
-
}
|
|
64
59
|
function getVisualOffsetTop() {
|
|
65
60
|
return !/^((?!chrome|android).)*safari/i.test(userAgent) ? (visualViewport == null ? void 0 : visualViewport.offsetTop) ?? 0 : 0;
|
|
66
61
|
}
|
|
67
|
-
const [createSelectContext, createSelectScope] = (0, import_create_context.createContextScope)(SELECT_NAME);
|
|
68
|
-
const [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
|
|
69
62
|
const TRIGGER_NAME = "SelectTrigger";
|
|
63
|
+
const SelectTriggerFrame = (0, import_core2.styled)(import_list_item.ListItem, {
|
|
64
|
+
componentName: TRIGGER_NAME,
|
|
65
|
+
backgrounded: true,
|
|
66
|
+
radiused: true,
|
|
67
|
+
hoverTheme: true,
|
|
68
|
+
pressTheme: true,
|
|
69
|
+
focusTheme: true,
|
|
70
|
+
focusable: false,
|
|
71
|
+
borderWidth: 1
|
|
72
|
+
});
|
|
70
73
|
const SelectTrigger = React.forwardRef((props, forwardedRef) => {
|
|
71
74
|
const {
|
|
72
75
|
__scopeSelect,
|
|
@@ -74,17 +77,9 @@ const SelectTrigger = React.forwardRef((props, forwardedRef) => {
|
|
|
74
77
|
"aria-labelledby": ariaLabelledby,
|
|
75
78
|
...triggerProps
|
|
76
79
|
} = props;
|
|
77
|
-
const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
|
|
80
|
+
const context = (0, import_context.useSelectContext)(TRIGGER_NAME, __scopeSelect);
|
|
78
81
|
const labelledBy = ariaLabelledby;
|
|
79
|
-
return /* @__PURE__ */ React.createElement(
|
|
80
|
-
backgrounded: true,
|
|
81
|
-
radiused: true,
|
|
82
|
-
hoverTheme: true,
|
|
83
|
-
pressTheme: true,
|
|
84
|
-
focusTheme: true,
|
|
85
|
-
focusable: false,
|
|
86
|
-
borderWidth: 1,
|
|
87
|
-
componentName: TRIGGER_NAME,
|
|
82
|
+
return /* @__PURE__ */ React.createElement(SelectTriggerFrame, {
|
|
88
83
|
size: context.size,
|
|
89
84
|
"aria-expanded": context.open,
|
|
90
85
|
"aria-autocomplete": "none",
|
|
@@ -107,14 +102,15 @@ const SelectValueFrame = (0, import_core2.styled)(import_text.Paragraph, {
|
|
|
107
102
|
name: VALUE_NAME,
|
|
108
103
|
selectable: false
|
|
109
104
|
});
|
|
110
|
-
const SelectValue = SelectValueFrame.extractable(React.forwardRef(({ __scopeSelect, children, placeholder }, forwardedRef) => {
|
|
111
|
-
const context = useSelectContext(VALUE_NAME, __scopeSelect);
|
|
105
|
+
const SelectValue = SelectValueFrame.extractable(React.forwardRef(({ __scopeSelect, children: childrenProp, placeholder }, forwardedRef) => {
|
|
106
|
+
const context = (0, import_context.useSelectContext)(VALUE_NAME, __scopeSelect);
|
|
112
107
|
const { onValueNodeHasChildrenChange } = context;
|
|
113
|
-
const hasChildren =
|
|
108
|
+
const hasChildren = childrenProp !== void 0;
|
|
114
109
|
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.onValueNodeChange);
|
|
115
110
|
React.useLayoutEffect(() => {
|
|
116
111
|
onValueNodeHasChildrenChange(hasChildren);
|
|
117
112
|
}, [onValueNodeHasChildrenChange, hasChildren]);
|
|
113
|
+
const children = childrenProp ?? context.selectedItem;
|
|
118
114
|
return /* @__PURE__ */ React.createElement(SelectValueFrame, {
|
|
119
115
|
size: context.size,
|
|
120
116
|
ref: composedRefs,
|
|
@@ -127,80 +123,8 @@ const SelectIcon = (0, import_core2.styled)(import_stacks.XStack, {
|
|
|
127
123
|
"aria-hidden": true,
|
|
128
124
|
children: /* @__PURE__ */ React.createElement(import_text.Paragraph, null, "\u25BC")
|
|
129
125
|
});
|
|
130
|
-
const CONTENT_NAME = "SelectContent";
|
|
131
|
-
const SelectContent = ({ children, __scopeSelect }) => {
|
|
132
|
-
const context = useSelectContext(CONTENT_NAME, __scopeSelect);
|
|
133
|
-
const themeName = (0, import_core2.useThemeName)();
|
|
134
|
-
const showSheet = useShowSelectSheet(context);
|
|
135
|
-
const contents = /* @__PURE__ */ React.createElement(import_core2.Theme, {
|
|
136
|
-
name: themeName
|
|
137
|
-
}, children);
|
|
138
|
-
if (showSheet && context.open) {
|
|
139
|
-
return contents;
|
|
140
|
-
}
|
|
141
|
-
return /* @__PURE__ */ React.createElement(import_react_dom_interactions.FloatingPortal, null, context.open ? /* @__PURE__ */ React.createElement(import_react_dom_interactions.FloatingOverlay, {
|
|
142
|
-
lockScroll: true
|
|
143
|
-
}, contents) : /* @__PURE__ */ React.createElement("div", {
|
|
144
|
-
style: { display: "none" }
|
|
145
|
-
}, contents));
|
|
146
|
-
};
|
|
147
|
-
const VIEWPORT_NAME = "SelectViewport";
|
|
148
|
-
const SelectViewportFrame = (0, import_core2.styled)(import_stacks.ThemeableStack, {
|
|
149
|
-
name: VIEWPORT_NAME,
|
|
150
|
-
backgroundColor: "$background",
|
|
151
|
-
elevate: true,
|
|
152
|
-
bordered: true,
|
|
153
|
-
overflow: "scroll",
|
|
154
|
-
userSelect: "none",
|
|
155
|
-
variants: {
|
|
156
|
-
size: {
|
|
157
|
-
"...size": (val, { tokens }) => {
|
|
158
|
-
return {
|
|
159
|
-
borderRadius: tokens.radius[val] ?? val
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
defaultVariants: {
|
|
165
|
-
size: "$2"
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
const SelectViewport = React.forwardRef((props, forwardedRef) => {
|
|
169
|
-
var _a;
|
|
170
|
-
const { __scopeSelect, children, ...viewportProps } = props;
|
|
171
|
-
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
172
|
-
const { style, ...floatingProps } = ((_a = context.interactions) == null ? void 0 : _a.getFloatingProps()) ?? {};
|
|
173
|
-
const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint);
|
|
174
|
-
if (breakpointActive || !import_core.isWeb) {
|
|
175
|
-
return /* @__PURE__ */ React.createElement(import_portal.PortalItem, {
|
|
176
|
-
hostName: `${context.scopeKey}SheetContents`
|
|
177
|
-
}, children);
|
|
178
|
-
}
|
|
179
|
-
if (!context.floatingContext) {
|
|
180
|
-
return null;
|
|
181
|
-
}
|
|
182
|
-
delete style["scrollbarWidth"];
|
|
183
|
-
delete style["listStyleType"];
|
|
184
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("style", {
|
|
185
|
-
dangerouslySetInnerHTML: {
|
|
186
|
-
__html: `[data-tamagui-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-tamagui-select-viewport]::-webkit-scrollbar{display:none}`
|
|
187
|
-
}
|
|
188
|
-
}), /* @__PURE__ */ React.createElement(import_react_dom_interactions.FloatingFocusManager, {
|
|
189
|
-
context: context.floatingContext,
|
|
190
|
-
preventTabbing: true
|
|
191
|
-
}, /* @__PURE__ */ React.createElement(SelectViewportFrame, {
|
|
192
|
-
size: context.size,
|
|
193
|
-
"data-tamagui-select-viewport": "",
|
|
194
|
-
role: "presentation",
|
|
195
|
-
...viewportProps,
|
|
196
|
-
ref: forwardedRef,
|
|
197
|
-
...floatingProps,
|
|
198
|
-
...style
|
|
199
|
-
}, children)));
|
|
200
|
-
});
|
|
201
|
-
SelectViewport.displayName = VIEWPORT_NAME;
|
|
202
126
|
const ITEM_NAME = "SelectItem";
|
|
203
|
-
const [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
|
|
127
|
+
const [SelectItemContextProvider, useSelectItemContext] = (0, import_context.createSelectContext)(ITEM_NAME);
|
|
204
128
|
const SelectItem = React.forwardRef((props, forwardedRef) => {
|
|
205
129
|
const {
|
|
206
130
|
__scopeSelect,
|
|
@@ -210,7 +134,7 @@ const SelectItem = React.forwardRef((props, forwardedRef) => {
|
|
|
210
134
|
index,
|
|
211
135
|
...itemProps
|
|
212
136
|
} = props;
|
|
213
|
-
const context = useSelectContext(ITEM_NAME, __scopeSelect);
|
|
137
|
+
const context = (0, import_context.useSelectContext)(ITEM_NAME, __scopeSelect);
|
|
214
138
|
const isSelected = context.value === value;
|
|
215
139
|
const [textValue, setTextValue] = React.useState(textValueProp ?? "");
|
|
216
140
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
@@ -228,6 +152,8 @@ const SelectItem = React.forwardRef((props, forwardedRef) => {
|
|
|
228
152
|
dataRef
|
|
229
153
|
} = context;
|
|
230
154
|
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node) => {
|
|
155
|
+
if (!import_core.isWeb)
|
|
156
|
+
return;
|
|
231
157
|
if (node instanceof HTMLElement) {
|
|
232
158
|
if (listRef) {
|
|
233
159
|
listRef.current[index] = node;
|
|
@@ -304,17 +230,26 @@ const SelectItemTextFrame = (0, import_core2.styled)(import_text.Paragraph, {
|
|
|
304
230
|
});
|
|
305
231
|
const SelectItemText = React.forwardRef((props, forwardedRef) => {
|
|
306
232
|
const { __scopeSelect, className, ...itemTextProps } = props;
|
|
307
|
-
const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
233
|
+
const context = (0, import_context.useSelectContext)(ITEM_TEXT_NAME, __scopeSelect);
|
|
308
234
|
const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
309
235
|
const ref = React.useRef(null);
|
|
310
236
|
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref, itemContext.onItemTextChange);
|
|
311
|
-
|
|
237
|
+
const isSelected = itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren;
|
|
238
|
+
const contents = /* @__PURE__ */ React.createElement(SelectItemTextFrame, {
|
|
312
239
|
className,
|
|
313
240
|
size: context.size,
|
|
314
241
|
id: itemContext.textId,
|
|
315
242
|
...itemTextProps,
|
|
316
243
|
ref: composedRefs
|
|
317
|
-
})
|
|
244
|
+
});
|
|
245
|
+
if (!import_core.isWeb) {
|
|
246
|
+
React.useEffect(() => {
|
|
247
|
+
if (isSelected) {
|
|
248
|
+
context.setSelectedItem(contents);
|
|
249
|
+
}
|
|
250
|
+
}, [isSelected]);
|
|
251
|
+
}
|
|
252
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, contents, import_core.isWeb && isSelected ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null);
|
|
318
253
|
});
|
|
319
254
|
SelectItemText.displayName = ITEM_TEXT_NAME;
|
|
320
255
|
const ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
|
@@ -332,7 +267,7 @@ const SelectItemIndicator = React.forwardRef((props, forwardedRef) => {
|
|
|
332
267
|
});
|
|
333
268
|
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
334
269
|
const GROUP_NAME = "SelectGroup";
|
|
335
|
-
const [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
|
|
270
|
+
const [SelectGroupContextProvider, useSelectGroupContext] = (0, import_context.createSelectContext)(GROUP_NAME);
|
|
336
271
|
const SelectGroupFrame = (0, import_core2.styled)(import_stacks.YStack, {
|
|
337
272
|
name: GROUP_NAME,
|
|
338
273
|
width: "100%"
|
|
@@ -354,7 +289,7 @@ SelectGroup.displayName = GROUP_NAME;
|
|
|
354
289
|
const LABEL_NAME = "SelectLabel";
|
|
355
290
|
const SelectLabel = React.forwardRef((props, forwardedRef) => {
|
|
356
291
|
const { __scopeSelect, ...labelProps } = props;
|
|
357
|
-
const context = useSelectContext(LABEL_NAME, __scopeSelect);
|
|
292
|
+
const context = (0, import_context.useSelectContext)(LABEL_NAME, __scopeSelect);
|
|
358
293
|
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
359
294
|
return /* @__PURE__ */ React.createElement(import_list_item.ListItem, {
|
|
360
295
|
componentName: LABEL_NAME,
|
|
@@ -366,95 +301,6 @@ const SelectLabel = React.forwardRef((props, forwardedRef) => {
|
|
|
366
301
|
});
|
|
367
302
|
});
|
|
368
303
|
SelectLabel.displayName = LABEL_NAME;
|
|
369
|
-
const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
370
|
-
const SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
|
|
371
|
-
return /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, {
|
|
372
|
-
componentName: SCROLL_UP_BUTTON_NAME,
|
|
373
|
-
...props,
|
|
374
|
-
dir: "up",
|
|
375
|
-
ref: forwardedRef
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
379
|
-
const SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
380
|
-
const SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
|
|
381
|
-
return /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, {
|
|
382
|
-
componentName: SCROLL_DOWN_BUTTON_NAME,
|
|
383
|
-
...props,
|
|
384
|
-
dir: "down",
|
|
385
|
-
ref: forwardedRef
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
389
|
-
const SelectScrollButtonImpl = React.memo(React.forwardRef((props, forwardedRef) => {
|
|
390
|
-
var _a;
|
|
391
|
-
const { __scopeSelect, dir, componentName, ...scrollIndicatorProps } = props;
|
|
392
|
-
const { floatingRef, increaseHeight, forceUpdate, ...context } = useSelectContext(componentName, __scopeSelect);
|
|
393
|
-
const intervalRef = React.useRef();
|
|
394
|
-
const loopingRef = React.useRef(false);
|
|
395
|
-
const isVisible = context[dir === "down" ? "canScrollDown" : "canScrollUp"];
|
|
396
|
-
const { x, y, reference, floating, strategy, update, refs } = (0, import_react_dom_interactions.useFloating)({
|
|
397
|
-
strategy: "fixed",
|
|
398
|
-
placement: dir === "up" ? "top" : "bottom",
|
|
399
|
-
middleware: [(0, import_react_dom_interactions.offset)(({ rects }) => -rects.floating.height)]
|
|
400
|
-
});
|
|
401
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, floating);
|
|
402
|
-
React.useLayoutEffect(() => {
|
|
403
|
-
if (!floatingRef)
|
|
404
|
-
return;
|
|
405
|
-
reference(floatingRef.current);
|
|
406
|
-
}, [reference, floatingRef == null ? void 0 : floatingRef.current]);
|
|
407
|
-
React.useEffect(() => {
|
|
408
|
-
if (!refs.reference.current || !refs.floating.current || !isVisible) {
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
const cleanup = (0, import_react_dom_interactions.autoUpdate)(refs.reference.current, refs.floating.current, update, {
|
|
412
|
-
animationFrame: true
|
|
413
|
-
});
|
|
414
|
-
return () => {
|
|
415
|
-
clearInterval(intervalRef.current);
|
|
416
|
-
loopingRef.current = false;
|
|
417
|
-
cleanup();
|
|
418
|
-
};
|
|
419
|
-
}, [isVisible, update, refs.floating, refs.reference]);
|
|
420
|
-
if (!isVisible) {
|
|
421
|
-
return null;
|
|
422
|
-
}
|
|
423
|
-
const handleScrollArrowChange = () => {
|
|
424
|
-
if (!floatingRef)
|
|
425
|
-
return;
|
|
426
|
-
const floating2 = floatingRef.current;
|
|
427
|
-
const isUp = dir === "up";
|
|
428
|
-
if (floating2) {
|
|
429
|
-
const value = isUp ? -SCROLL_ARROW_VELOCITY : SCROLL_ARROW_VELOCITY;
|
|
430
|
-
const multi = isUp && floating2.scrollTop <= SCROLL_ARROW_THRESHOLD * 2 || !isUp && floating2.scrollTop >= floating2.scrollHeight - floating2.clientHeight - SCROLL_ARROW_THRESHOLD * 2 ? 2 : 1;
|
|
431
|
-
floating2.scrollTop += multi * (isUp ? -SCROLL_ARROW_VELOCITY : SCROLL_ARROW_VELOCITY);
|
|
432
|
-
increaseHeight == null ? void 0 : increaseHeight(floating2, multi === 2 ? value * 2 : value);
|
|
433
|
-
forceUpdate();
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
return /* @__PURE__ */ React.createElement(import_stacks.YStack, {
|
|
437
|
-
ref: composedRefs,
|
|
438
|
-
componentName,
|
|
439
|
-
"aria-hidden": true,
|
|
440
|
-
...scrollIndicatorProps,
|
|
441
|
-
zIndex: 1e3,
|
|
442
|
-
position: strategy,
|
|
443
|
-
left: x || 0,
|
|
444
|
-
top: y || 0,
|
|
445
|
-
width: `calc(${(((_a = floatingRef == null ? void 0 : floatingRef.current) == null ? void 0 : _a.offsetWidth) ?? 0) - 2}px)`,
|
|
446
|
-
onPointerMove: () => {
|
|
447
|
-
if (!loopingRef.current) {
|
|
448
|
-
intervalRef.current = setInterval(handleScrollArrowChange, 1e3 / 60);
|
|
449
|
-
loopingRef.current = true;
|
|
450
|
-
}
|
|
451
|
-
},
|
|
452
|
-
onPointerLeave: () => {
|
|
453
|
-
loopingRef.current = false;
|
|
454
|
-
clearInterval(intervalRef.current);
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
}));
|
|
458
304
|
const SelectSeparator = (0, import_core2.styled)(import_separator.Separator, {
|
|
459
305
|
name: "SelectSeparator"
|
|
460
306
|
});
|
|
@@ -467,7 +313,7 @@ const useShowSelectSheet = (context) => {
|
|
|
467
313
|
return context.open === false ? false : breakpointActive;
|
|
468
314
|
};
|
|
469
315
|
const SelectSheetController = (props) => {
|
|
470
|
-
const context = useSelectContext("SelectSheetController", props.__scopeSelect);
|
|
316
|
+
const context = (0, import_context.useSelectContext)("SelectSheetController", props.__scopeSelect);
|
|
471
317
|
const showSheet = useShowSelectSheet(context);
|
|
472
318
|
const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint);
|
|
473
319
|
const getShowSheet = (0, import_core2.useGet)(showSheet);
|
|
@@ -483,368 +329,12 @@ const SelectSheetController = (props) => {
|
|
|
483
329
|
};
|
|
484
330
|
const SHEET_CONTENTS_NAME = "SelectSheetContents";
|
|
485
331
|
const SelectSheetContents = ({ __scopeSelect }) => {
|
|
486
|
-
const context = useSelectContext(SHEET_CONTENTS_NAME, __scopeSelect);
|
|
332
|
+
const context = (0, import_context.useSelectContext)(SHEET_CONTENTS_NAME, __scopeSelect);
|
|
487
333
|
return /* @__PURE__ */ React.createElement(import_portal.PortalHost, {
|
|
488
334
|
name: `${context.scopeKey}SheetContents`
|
|
489
335
|
});
|
|
490
336
|
};
|
|
491
337
|
SelectSheetContents.displayName = SHEET_CONTENTS_NAME;
|
|
492
|
-
const SelectInlineImpl = (props) => {
|
|
493
|
-
const {
|
|
494
|
-
__scopeSelect,
|
|
495
|
-
children,
|
|
496
|
-
open = false,
|
|
497
|
-
activeIndexRef,
|
|
498
|
-
selectedIndexRef,
|
|
499
|
-
listContentRef
|
|
500
|
-
} = props;
|
|
501
|
-
const selectContext = useSelectContext("SelectSheetImpl", __scopeSelect);
|
|
502
|
-
const { setActiveIndex, setOpen, setSelectedIndex, selectedIndex, activeIndex, forceUpdate } = selectContext;
|
|
503
|
-
const [showArrows, setShowArrows] = React.useState(false);
|
|
504
|
-
const [scrollTop, setScrollTop] = React.useState(0);
|
|
505
|
-
const prevActiveIndex = (0, import_react_use_previous.usePrevious)(activeIndex);
|
|
506
|
-
const listItemsRef = React.useRef([]);
|
|
507
|
-
const [controlledScrolling, setControlledScrolling] = React.useState(false);
|
|
508
|
-
const [middlewareType, setMiddlewareType] = React.useState("align");
|
|
509
|
-
React.useEffect(() => {
|
|
510
|
-
const frame = requestAnimationFrame(() => {
|
|
511
|
-
setShowArrows(open);
|
|
512
|
-
if (!open) {
|
|
513
|
-
setScrollTop(0);
|
|
514
|
-
setMiddlewareType("align");
|
|
515
|
-
setActiveIndex(null);
|
|
516
|
-
setControlledScrolling(false);
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
return () => {
|
|
520
|
-
cancelAnimationFrame(frame);
|
|
521
|
-
};
|
|
522
|
-
}, [open, setActiveIndex]);
|
|
523
|
-
function getFloatingPadding(floating2) {
|
|
524
|
-
var _a;
|
|
525
|
-
if (!floating2) {
|
|
526
|
-
return 0;
|
|
527
|
-
}
|
|
528
|
-
return Number((_a = getComputedStyle(floating2).paddingLeft) == null ? void 0 : _a.replace("px", ""));
|
|
529
|
-
}
|
|
530
|
-
const { x, y, reference, floating, strategy, context, refs, middlewareData, update } = (0, import_react_dom_interactions.useFloating)({
|
|
531
|
-
open,
|
|
532
|
-
onOpenChange: setOpen,
|
|
533
|
-
placement: "bottom",
|
|
534
|
-
middleware: middlewareType === "align" ? [
|
|
535
|
-
(0, import_react_dom_interactions.offset)(({ rects }) => {
|
|
536
|
-
const index = activeIndexRef.current ?? selectedIndexRef.current;
|
|
537
|
-
if (index == null) {
|
|
538
|
-
return 0;
|
|
539
|
-
}
|
|
540
|
-
const item = listItemsRef.current[index];
|
|
541
|
-
if (item == null) {
|
|
542
|
-
return 0;
|
|
543
|
-
}
|
|
544
|
-
const offsetTop = item.offsetTop;
|
|
545
|
-
const itemHeight = item.offsetHeight;
|
|
546
|
-
const height = rects.reference.height;
|
|
547
|
-
return -offsetTop - height - (itemHeight - height) / 2;
|
|
548
|
-
}),
|
|
549
|
-
{
|
|
550
|
-
name: "size",
|
|
551
|
-
async fn(args) {
|
|
552
|
-
var _a;
|
|
553
|
-
const {
|
|
554
|
-
elements: { floating: floating2 },
|
|
555
|
-
rects: { reference: reference2 },
|
|
556
|
-
middlewareData: middlewareData2
|
|
557
|
-
} = args;
|
|
558
|
-
const overflow = await (0, import_react_dom_interactions.detectOverflow)(args, {
|
|
559
|
-
padding: WINDOW_PADDING
|
|
560
|
-
});
|
|
561
|
-
const top = Math.max(0, overflow.top);
|
|
562
|
-
const bottom = Math.max(0, overflow.bottom);
|
|
563
|
-
const nextY = args.y + top;
|
|
564
|
-
if ((_a = middlewareData2.size) == null ? void 0 : _a.skip) {
|
|
565
|
-
return {
|
|
566
|
-
y: nextY,
|
|
567
|
-
data: {
|
|
568
|
-
y: middlewareData2.size.y
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
Object.assign(floating2.style, {
|
|
573
|
-
maxHeight: `${floating2.scrollHeight - Math.abs(top + bottom)}px`,
|
|
574
|
-
minWidth: `${reference2.width + getFloatingPadding(floating2) * 2}px`
|
|
575
|
-
});
|
|
576
|
-
return {
|
|
577
|
-
y: nextY,
|
|
578
|
-
data: {
|
|
579
|
-
y: top,
|
|
580
|
-
skip: true
|
|
581
|
-
},
|
|
582
|
-
reset: {
|
|
583
|
-
rects: true
|
|
584
|
-
}
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
] : [
|
|
589
|
-
(0, import_react_dom_interactions.offset)(5),
|
|
590
|
-
(0, import_react_dom_interactions.flip)(),
|
|
591
|
-
(0, import_react_dom_interactions.size)({
|
|
592
|
-
apply({ rects, availableHeight, elements }) {
|
|
593
|
-
Object.assign(elements.floating.style, {
|
|
594
|
-
width: `${rects.reference.width}px`,
|
|
595
|
-
maxHeight: `${availableHeight}px`
|
|
596
|
-
});
|
|
597
|
-
},
|
|
598
|
-
padding: WINDOW_PADDING
|
|
599
|
-
})
|
|
600
|
-
]
|
|
601
|
-
});
|
|
602
|
-
const floatingRef = refs.floating;
|
|
603
|
-
const showUpArrow = showArrows && scrollTop > SCROLL_ARROW_THRESHOLD;
|
|
604
|
-
const showDownArrow = showArrows && floatingRef.current && scrollTop < floatingRef.current.scrollHeight - floatingRef.current.clientHeight - SCROLL_ARROW_THRESHOLD;
|
|
605
|
-
const interactions = (0, import_react_dom_interactions.useInteractions)([
|
|
606
|
-
(0, import_react_dom_interactions.useClick)(context, { pointerDown: true }),
|
|
607
|
-
(0, import_react_dom_interactions.useRole)(context, { role: "listbox" }),
|
|
608
|
-
(0, import_react_dom_interactions.useDismiss)(context),
|
|
609
|
-
(0, import_react_dom_interactions.useListNavigation)(context, {
|
|
610
|
-
listRef: listItemsRef,
|
|
611
|
-
activeIndex,
|
|
612
|
-
selectedIndex,
|
|
613
|
-
onNavigate: setActiveIndex
|
|
614
|
-
}),
|
|
615
|
-
(0, import_react_dom_interactions.useTypeahead)(context, {
|
|
616
|
-
listRef: listContentRef,
|
|
617
|
-
onMatch: open ? setActiveIndex : setSelectedIndex,
|
|
618
|
-
selectedIndex,
|
|
619
|
-
activeIndex
|
|
620
|
-
})
|
|
621
|
-
]);
|
|
622
|
-
const increaseHeight = React.useCallback((floating2, amount = 0) => {
|
|
623
|
-
if (middlewareType === "fallback") {
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
const currentMaxHeight = Number(floating2.style.maxHeight.replace("px", ""));
|
|
627
|
-
const currentTop = Number(floating2.style.top.replace("px", ""));
|
|
628
|
-
const rect = floating2.getBoundingClientRect();
|
|
629
|
-
const rectTop = rect.top;
|
|
630
|
-
const rectBottom = rect.bottom;
|
|
631
|
-
const viewportHeight = (visualViewport == null ? void 0 : visualViewport.height) ?? 0;
|
|
632
|
-
const visualMaxHeight = viewportHeight - WINDOW_PADDING * 2;
|
|
633
|
-
if (amount < 0 && selectedIndexRef.current != null && Math.round(rectBottom) < Math.round(viewportHeight + getVisualOffsetTop() - WINDOW_PADDING)) {
|
|
634
|
-
floating2.style.maxHeight = `${Math.min(visualMaxHeight, currentMaxHeight - amount)}px`;
|
|
635
|
-
}
|
|
636
|
-
if (amount > 0 && Math.round(rectTop) > Math.round(WINDOW_PADDING - getVisualOffsetTop()) && floating2.scrollHeight > floating2.offsetHeight) {
|
|
637
|
-
const nextTop = Math.max(WINDOW_PADDING + getVisualOffsetTop(), currentTop - amount);
|
|
638
|
-
const nextMaxHeight = Math.min(visualMaxHeight, currentMaxHeight + amount);
|
|
639
|
-
Object.assign(floating2.style, {
|
|
640
|
-
maxHeight: `${nextMaxHeight}px`,
|
|
641
|
-
top: `${nextTop}px`
|
|
642
|
-
});
|
|
643
|
-
if (nextTop - WINDOW_PADDING > getVisualOffsetTop()) {
|
|
644
|
-
floating2.scrollTop -= nextMaxHeight - currentMaxHeight + getFloatingPadding(floating2);
|
|
645
|
-
}
|
|
646
|
-
return currentTop - nextTop;
|
|
647
|
-
}
|
|
648
|
-
}, [middlewareType, selectedIndexRef]);
|
|
649
|
-
const touchPageYRef = React.useRef(null);
|
|
650
|
-
const handleWheel = React.useCallback((event) => {
|
|
651
|
-
var _a;
|
|
652
|
-
const pinching = event.ctrlKey;
|
|
653
|
-
const currentTarget = event.currentTarget;
|
|
654
|
-
function isWheelEvent(event2) {
|
|
655
|
-
return typeof event2.deltaY === "number";
|
|
656
|
-
}
|
|
657
|
-
function isTouchEvent(event2) {
|
|
658
|
-
return event2.touches != null;
|
|
659
|
-
}
|
|
660
|
-
if (Math.abs(((currentTarget == null ? void 0 : currentTarget.offsetHeight) ?? 0) - (((visualViewport == null ? void 0 : visualViewport.height) ?? 0) - WINDOW_PADDING * 2)) > 1 && !pinching) {
|
|
661
|
-
event.preventDefault();
|
|
662
|
-
} else if (isWheelEvent(event) && isFirefox) {
|
|
663
|
-
currentTarget.scrollTop += event.deltaY;
|
|
664
|
-
}
|
|
665
|
-
if (!pinching) {
|
|
666
|
-
let delta = 5;
|
|
667
|
-
if (isTouchEvent(event)) {
|
|
668
|
-
const currentPageY = touchPageYRef.current;
|
|
669
|
-
const pageY = (_a = event.touches[0]) == null ? void 0 : _a.pageY;
|
|
670
|
-
if (pageY != null) {
|
|
671
|
-
touchPageYRef.current = pageY;
|
|
672
|
-
if (currentPageY != null) {
|
|
673
|
-
delta = currentPageY - pageY;
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
increaseHeight(currentTarget, isWheelEvent(event) ? event.deltaY : delta);
|
|
678
|
-
setScrollTop(currentTarget.scrollTop);
|
|
679
|
-
forceUpdate();
|
|
680
|
-
}
|
|
681
|
-
}, [forceUpdate, increaseHeight]);
|
|
682
|
-
React.useEffect(() => {
|
|
683
|
-
function onTouchEnd() {
|
|
684
|
-
touchPageYRef.current = null;
|
|
685
|
-
}
|
|
686
|
-
const floating2 = floatingRef.current;
|
|
687
|
-
if (open && floating2 && middlewareType === "align") {
|
|
688
|
-
floating2.addEventListener("wheel", handleWheel);
|
|
689
|
-
floating2.addEventListener("touchmove", handleWheel);
|
|
690
|
-
floating2.addEventListener("touchend", onTouchEnd, { passive: true });
|
|
691
|
-
return () => {
|
|
692
|
-
floating2.removeEventListener("wheel", handleWheel);
|
|
693
|
-
floating2.removeEventListener("touchmove", handleWheel);
|
|
694
|
-
floating2.removeEventListener("touchend", onTouchEnd);
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
}, [open, floatingRef, handleWheel, middlewareType]);
|
|
698
|
-
React.useEffect(() => {
|
|
699
|
-
window.addEventListener("resize", update);
|
|
700
|
-
return () => {
|
|
701
|
-
window.removeEventListener("resize", update);
|
|
702
|
-
};
|
|
703
|
-
}, [update]);
|
|
704
|
-
React.useLayoutEffect(() => {
|
|
705
|
-
var _a;
|
|
706
|
-
const floating2 = floatingRef.current;
|
|
707
|
-
if (open && controlledScrolling && floating2) {
|
|
708
|
-
const item = activeIndex != null ? listItemsRef.current[activeIndex] : selectedIndex != null ? listItemsRef.current[selectedIndex] : null;
|
|
709
|
-
if (item && prevActiveIndex != null) {
|
|
710
|
-
const itemHeight = ((_a = listItemsRef.current[prevActiveIndex]) == null ? void 0 : _a.offsetHeight) ?? 0;
|
|
711
|
-
const floatingHeight = floating2.offsetHeight;
|
|
712
|
-
const top = item.offsetTop;
|
|
713
|
-
const bottom = top + itemHeight;
|
|
714
|
-
if (top < floating2.scrollTop + 20) {
|
|
715
|
-
const diff = floating2.scrollTop - top + 20;
|
|
716
|
-
floating2.scrollTop -= diff;
|
|
717
|
-
if (activeIndex != selectedIndex && activeIndex != null) {
|
|
718
|
-
increaseHeight(floating2, -diff);
|
|
719
|
-
}
|
|
720
|
-
} else if (bottom > floatingHeight + floating2.scrollTop - 20) {
|
|
721
|
-
const diff = bottom - floatingHeight - floating2.scrollTop + 20;
|
|
722
|
-
floating2.scrollTop += diff;
|
|
723
|
-
if (activeIndex != selectedIndex && activeIndex != null) {
|
|
724
|
-
floating2.scrollTop -= increaseHeight(floating2, diff) ?? 0;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
}, [
|
|
730
|
-
open,
|
|
731
|
-
controlledScrolling,
|
|
732
|
-
prevActiveIndex,
|
|
733
|
-
activeIndex,
|
|
734
|
-
selectedIndex,
|
|
735
|
-
floatingRef,
|
|
736
|
-
increaseHeight
|
|
737
|
-
]);
|
|
738
|
-
React.useLayoutEffect(() => {
|
|
739
|
-
var _a;
|
|
740
|
-
const floating2 = refs.floating.current;
|
|
741
|
-
const reference2 = refs.reference.current;
|
|
742
|
-
if (open && floating2 && reference2 && floating2.offsetHeight < floating2.scrollHeight) {
|
|
743
|
-
const referenceRect = reference2.getBoundingClientRect();
|
|
744
|
-
if (middlewareType === "fallback") {
|
|
745
|
-
const item = listItemsRef.current[selectedIndex];
|
|
746
|
-
if (item) {
|
|
747
|
-
floating2.scrollTop = item.offsetTop - floating2.clientHeight + referenceRect.height;
|
|
748
|
-
}
|
|
749
|
-
return;
|
|
750
|
-
}
|
|
751
|
-
floating2.scrollTop = (_a = middlewareData.size) == null ? void 0 : _a.y;
|
|
752
|
-
const closeToBottom = ((visualViewport == null ? void 0 : visualViewport.height) ?? 0) + getVisualOffsetTop() - referenceRect.bottom < FALLBACK_THRESHOLD;
|
|
753
|
-
const closeToTop = referenceRect.top < FALLBACK_THRESHOLD;
|
|
754
|
-
if (floating2.offsetHeight < MIN_HEIGHT || closeToTop || closeToBottom) {
|
|
755
|
-
setMiddlewareType("fallback");
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
}, [
|
|
759
|
-
open,
|
|
760
|
-
increaseHeight,
|
|
761
|
-
selectedIndex,
|
|
762
|
-
middlewareType,
|
|
763
|
-
refs.floating,
|
|
764
|
-
refs.reference,
|
|
765
|
-
middlewareData
|
|
766
|
-
]);
|
|
767
|
-
React.useLayoutEffect(() => {
|
|
768
|
-
if (open && selectedIndex != null) {
|
|
769
|
-
requestAnimationFrame(() => {
|
|
770
|
-
var _a;
|
|
771
|
-
(_a = listItemsRef.current[selectedIndex]) == null ? void 0 : _a.focus({ preventScroll: true });
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
}, [listItemsRef, selectedIndex, open]);
|
|
775
|
-
React.useEffect(() => {
|
|
776
|
-
const frame = requestAnimationFrame(() => {
|
|
777
|
-
setShowArrows(open);
|
|
778
|
-
if (!open) {
|
|
779
|
-
setScrollTop(0);
|
|
780
|
-
setMiddlewareType("align");
|
|
781
|
-
setActiveIndex(null);
|
|
782
|
-
setControlledScrolling(false);
|
|
783
|
-
}
|
|
784
|
-
});
|
|
785
|
-
return () => cancelAnimationFrame(frame);
|
|
786
|
-
}, [open]);
|
|
787
|
-
return /* @__PURE__ */ React.createElement(SelectProvider, {
|
|
788
|
-
scope: __scopeSelect,
|
|
789
|
-
...selectContext,
|
|
790
|
-
increaseHeight,
|
|
791
|
-
floatingRef,
|
|
792
|
-
setValueAtIndex: (index, value) => {
|
|
793
|
-
listContentRef.current[index] = value;
|
|
794
|
-
},
|
|
795
|
-
interactions: {
|
|
796
|
-
...interactions,
|
|
797
|
-
getReferenceProps() {
|
|
798
|
-
return interactions.getReferenceProps({
|
|
799
|
-
ref: reference,
|
|
800
|
-
className: "SelectTrigger",
|
|
801
|
-
onKeyDown(event) {
|
|
802
|
-
if (event.key === "Enter" || event.key === " " && !context.dataRef.current.typing) {
|
|
803
|
-
event.preventDefault();
|
|
804
|
-
setOpen(true);
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
});
|
|
808
|
-
},
|
|
809
|
-
getFloatingProps(props2) {
|
|
810
|
-
return interactions.getFloatingProps({
|
|
811
|
-
ref: floating,
|
|
812
|
-
className: "Select",
|
|
813
|
-
...props2,
|
|
814
|
-
style: {
|
|
815
|
-
position: strategy,
|
|
816
|
-
top: y ?? "",
|
|
817
|
-
left: x ?? "",
|
|
818
|
-
outline: 0,
|
|
819
|
-
listStyleType: "none",
|
|
820
|
-
scrollbarWidth: "none",
|
|
821
|
-
userSelect: "none",
|
|
822
|
-
...props2 == null ? void 0 : props2.style
|
|
823
|
-
},
|
|
824
|
-
onPointerEnter() {
|
|
825
|
-
setControlledScrolling(false);
|
|
826
|
-
},
|
|
827
|
-
onPointerMove() {
|
|
828
|
-
setControlledScrolling(false);
|
|
829
|
-
},
|
|
830
|
-
onKeyDown() {
|
|
831
|
-
setControlledScrolling(true);
|
|
832
|
-
},
|
|
833
|
-
onScroll(event) {
|
|
834
|
-
setScrollTop(event.currentTarget.scrollTop);
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
}
|
|
838
|
-
},
|
|
839
|
-
floatingContext: context,
|
|
840
|
-
activeIndex,
|
|
841
|
-
canScrollDown: !!showDownArrow,
|
|
842
|
-
canScrollUp: !!showUpArrow,
|
|
843
|
-
controlledScrolling: true,
|
|
844
|
-
dataRef: context.dataRef,
|
|
845
|
-
listRef: listItemsRef
|
|
846
|
-
}, children);
|
|
847
|
-
};
|
|
848
338
|
const SelectSheetImpl = (props) => {
|
|
849
339
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
|
|
850
340
|
};
|
|
@@ -858,13 +348,14 @@ const Select = (0, import_core2.withStaticProperties)((props) => {
|
|
|
858
348
|
value: valueProp,
|
|
859
349
|
defaultValue,
|
|
860
350
|
onValueChange,
|
|
861
|
-
size: sizeProp,
|
|
351
|
+
size: sizeProp = "$4",
|
|
862
352
|
sheetBreakpoint = false,
|
|
863
353
|
dir
|
|
864
354
|
} = props;
|
|
865
355
|
const isSheet = useSelectBreakpointActive(sheetBreakpoint);
|
|
866
|
-
const SelectImpl = isSheet ? SelectSheetImpl : SelectInlineImpl;
|
|
356
|
+
const SelectImpl = isSheet ? SelectSheetImpl : import_SelectImpl.SelectInlineImpl;
|
|
867
357
|
const forceUpdate = React.useReducer(() => ({}), {})[1];
|
|
358
|
+
const [selectedItem, setSelectedItem] = React.useState(null);
|
|
868
359
|
const [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
869
360
|
prop: openProp,
|
|
870
361
|
defaultProp: defaultOpen || false,
|
|
@@ -886,9 +377,11 @@ const Select = (0, import_core2.withStaticProperties)((props) => {
|
|
|
886
377
|
selectedIndexRef.current = selectedIndex;
|
|
887
378
|
activeIndexRef.current = activeIndex;
|
|
888
379
|
});
|
|
889
|
-
return /* @__PURE__ */ React.createElement(SelectProvider, {
|
|
380
|
+
return /* @__PURE__ */ React.createElement(import_context.SelectProvider, {
|
|
890
381
|
dir,
|
|
891
382
|
size: sizeProp,
|
|
383
|
+
selectedItem,
|
|
384
|
+
setSelectedItem,
|
|
892
385
|
forceUpdate,
|
|
893
386
|
valueNode,
|
|
894
387
|
onValueNodeChange: setValueNode,
|
|
@@ -920,22 +413,22 @@ const Select = (0, import_core2.withStaticProperties)((props) => {
|
|
|
920
413
|
value
|
|
921
414
|
}, children)));
|
|
922
415
|
}, {
|
|
923
|
-
Content: SelectContent,
|
|
416
|
+
Content: import_SelectContent.SelectContent,
|
|
924
417
|
Group: SelectGroup,
|
|
925
418
|
Icon: SelectIcon,
|
|
926
419
|
Item: SelectItem,
|
|
927
420
|
ItemIndicator: SelectItemIndicator,
|
|
928
421
|
ItemText: SelectItemText,
|
|
929
422
|
Label: SelectLabel,
|
|
930
|
-
ScrollDownButton: SelectScrollDownButton,
|
|
931
|
-
ScrollUpButton: SelectScrollUpButton,
|
|
423
|
+
ScrollDownButton: import_SelectScrollButton.SelectScrollDownButton,
|
|
424
|
+
ScrollUpButton: import_SelectScrollButton.SelectScrollUpButton,
|
|
932
425
|
Trigger: SelectTrigger,
|
|
933
426
|
Value: SelectValue,
|
|
934
|
-
Viewport: SelectViewport,
|
|
427
|
+
Viewport: import_SelectViewport.SelectViewport,
|
|
935
428
|
SheetContents: SelectSheetContents,
|
|
936
429
|
Sheet: import_sheet.Sheet
|
|
937
430
|
});
|
|
938
|
-
Select.displayName = SELECT_NAME;
|
|
431
|
+
Select.displayName = import_constants.SELECT_NAME;
|
|
939
432
|
// Annotate the CommonJS export names for ESM import in node:
|
|
940
433
|
0 && (module.exports = {
|
|
941
434
|
Select,
|
|
@@ -946,8 +439,9 @@ Select.displayName = SELECT_NAME;
|
|
|
946
439
|
SelectSeparator,
|
|
947
440
|
SelectSheetContents,
|
|
948
441
|
SelectTrigger,
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
442
|
+
getVisualOffsetTop,
|
|
443
|
+
isFirefox,
|
|
444
|
+
useSelectBreakpointActive,
|
|
445
|
+
useShowSelectSheet
|
|
952
446
|
});
|
|
953
447
|
//# sourceMappingURL=Select.js.map
|