@tamagui/select 1.2.9 → 1.2.11
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/esm/BubbleSelect.mjs +25 -0
- package/dist/esm/BubbleSelect.mjs.map +7 -0
- package/dist/esm/Select.mjs +463 -0
- package/dist/esm/Select.mjs.map +7 -0
- package/dist/esm/SelectContent.mjs +31 -0
- package/dist/esm/SelectContent.mjs.map +7 -0
- package/dist/esm/SelectContent.native.mjs +7 -0
- package/dist/esm/SelectContent.native.mjs.map +7 -0
- package/dist/esm/SelectImpl.mjs +295 -0
- package/dist/esm/SelectImpl.mjs.map +7 -0
- package/dist/esm/SelectImpl.native.mjs +11 -0
- package/dist/esm/SelectImpl.native.mjs.map +7 -0
- package/dist/esm/SelectScrollButton.mjs +140 -0
- package/dist/esm/SelectScrollButton.mjs.map +7 -0
- package/dist/esm/SelectScrollButton.native.mjs +7 -0
- package/dist/esm/SelectScrollButton.native.mjs.map +7 -0
- package/dist/esm/SelectViewport.mjs +91 -0
- package/dist/esm/SelectViewport.mjs.map +7 -0
- package/dist/esm/SelectViewport.native.mjs +19 -0
- package/dist/esm/SelectViewport.native.mjs.map +7 -0
- package/dist/esm/constants.mjs +17 -0
- package/dist/esm/constants.mjs.map +7 -0
- package/dist/esm/context.mjs +16 -0
- package/dist/esm/context.mjs.map +7 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/index.mjs.map +7 -0
- package/dist/esm/types.mjs +1 -0
- package/dist/esm/types.mjs.map +7 -0
- package/dist/esm/useSelectBreakpointActive.mjs +18 -0
- package/dist/esm/useSelectBreakpointActive.mjs.map +7 -0
- package/dist/jsx/BubbleSelect.mjs +25 -0
- package/dist/jsx/BubbleSelect.mjs.map +7 -0
- package/dist/jsx/Select.mjs +427 -0
- package/dist/jsx/Select.mjs.map +7 -0
- package/dist/jsx/SelectContent.mjs +30 -0
- package/dist/jsx/SelectContent.mjs.map +7 -0
- package/dist/jsx/SelectContent.native.mjs +7 -0
- package/dist/jsx/SelectContent.native.mjs.map +7 -0
- package/dist/jsx/SelectImpl.mjs +287 -0
- package/dist/jsx/SelectImpl.mjs.map +7 -0
- package/dist/jsx/SelectImpl.native.mjs +10 -0
- package/dist/jsx/SelectImpl.native.mjs.map +7 -0
- package/dist/jsx/SelectScrollButton.mjs +126 -0
- package/dist/jsx/SelectScrollButton.mjs.map +7 -0
- package/dist/jsx/SelectScrollButton.native.mjs +7 -0
- package/dist/jsx/SelectScrollButton.native.mjs.map +7 -0
- package/dist/jsx/SelectViewport.mjs +83 -0
- package/dist/jsx/SelectViewport.mjs.map +7 -0
- package/dist/jsx/SelectViewport.native.mjs +18 -0
- package/dist/jsx/SelectViewport.native.mjs.map +7 -0
- package/dist/jsx/constants.mjs +17 -0
- package/dist/jsx/constants.mjs.map +7 -0
- package/dist/jsx/context.mjs +15 -0
- package/dist/jsx/context.mjs.map +7 -0
- package/dist/jsx/index.mjs +3 -0
- package/dist/jsx/index.mjs.map +7 -0
- package/dist/jsx/types.mjs +1 -0
- package/dist/jsx/types.mjs.map +7 -0
- package/dist/jsx/useSelectBreakpointActive.mjs +18 -0
- package/dist/jsx/useSelectBreakpointActive.mjs.map +7 -0
- package/package.json +16 -16
- package/types/context.d.ts +8 -2
- package/types/context.d.ts.map +1 -1
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
autoUpdate,
|
|
4
|
+
flip,
|
|
5
|
+
inner,
|
|
6
|
+
offset,
|
|
7
|
+
shift,
|
|
8
|
+
size,
|
|
9
|
+
useClick,
|
|
10
|
+
useDismiss,
|
|
11
|
+
useFloating,
|
|
12
|
+
useInnerOffset,
|
|
13
|
+
useInteractions,
|
|
14
|
+
useListNavigation,
|
|
15
|
+
useRole,
|
|
16
|
+
useTypeahead
|
|
17
|
+
} from "@floating-ui/react-dom-interactions";
|
|
18
|
+
import {
|
|
19
|
+
isClient,
|
|
20
|
+
isWeb,
|
|
21
|
+
useIsTouchDevice,
|
|
22
|
+
useIsomorphicLayoutEffect
|
|
23
|
+
} from "@tamagui/core";
|
|
24
|
+
import * as React from "react";
|
|
25
|
+
import { flushSync } from "react-dom";
|
|
26
|
+
import { SCROLL_ARROW_THRESHOLD, WINDOW_PADDING } from "./constants";
|
|
27
|
+
import { SelectProvider, useSelectContext } from "./context";
|
|
28
|
+
const SelectInlineImpl = (props) => {
|
|
29
|
+
const {
|
|
30
|
+
__scopeSelect,
|
|
31
|
+
children,
|
|
32
|
+
open = false,
|
|
33
|
+
selectedIndexRef,
|
|
34
|
+
listContentRef
|
|
35
|
+
} = props;
|
|
36
|
+
const selectContext = useSelectContext("SelectSheetImpl", __scopeSelect);
|
|
37
|
+
const {
|
|
38
|
+
setActiveIndex,
|
|
39
|
+
setOpen,
|
|
40
|
+
setSelectedIndex,
|
|
41
|
+
selectedIndex,
|
|
42
|
+
activeIndex,
|
|
43
|
+
forceUpdate
|
|
44
|
+
} = selectContext;
|
|
45
|
+
const [scrollTop, setScrollTop] = React.useState(0);
|
|
46
|
+
const touch = useIsTouchDevice();
|
|
47
|
+
const listItemsRef = React.useRef([]);
|
|
48
|
+
const overflowRef = React.useRef(null);
|
|
49
|
+
const upArrowRef = React.useRef(null);
|
|
50
|
+
const downArrowRef = React.useRef(null);
|
|
51
|
+
const allowSelectRef = React.useRef(false);
|
|
52
|
+
const allowMouseUpRef = React.useRef(true);
|
|
53
|
+
const selectTimeoutRef = React.useRef();
|
|
54
|
+
const state = React.useRef({
|
|
55
|
+
isMouseOutside: false
|
|
56
|
+
});
|
|
57
|
+
const [controlledScrolling, setControlledScrolling] = React.useState(false);
|
|
58
|
+
const [fallback, setFallback] = React.useState(false);
|
|
59
|
+
const [innerOffset, setInnerOffset] = React.useState(0);
|
|
60
|
+
const [blockSelection, setBlockSelection] = React.useState(false);
|
|
61
|
+
const floatingStyle = React.useRef({});
|
|
62
|
+
React.useEffect(() => {
|
|
63
|
+
const frame = requestAnimationFrame(() => {
|
|
64
|
+
if (!open) {
|
|
65
|
+
setScrollTop(0);
|
|
66
|
+
setFallback(false);
|
|
67
|
+
setActiveIndex(null);
|
|
68
|
+
setControlledScrolling(false);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return () => {
|
|
72
|
+
cancelAnimationFrame(frame);
|
|
73
|
+
};
|
|
74
|
+
}, [open, setActiveIndex]);
|
|
75
|
+
if (isWeb && isClient) {
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
if (!open)
|
|
78
|
+
return;
|
|
79
|
+
const mouseUp = (e) => {
|
|
80
|
+
if (state.current.isMouseOutside) {
|
|
81
|
+
setOpen(false);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
document.addEventListener("mouseup", mouseUp);
|
|
85
|
+
return () => {
|
|
86
|
+
document.removeEventListener("mouseup", mouseUp);
|
|
87
|
+
};
|
|
88
|
+
}, [open]);
|
|
89
|
+
}
|
|
90
|
+
const updateFloatingSize = size({
|
|
91
|
+
apply({
|
|
92
|
+
availableHeight,
|
|
93
|
+
rects: {
|
|
94
|
+
reference: { width }
|
|
95
|
+
}
|
|
96
|
+
}) {
|
|
97
|
+
floatingStyle.current = {
|
|
98
|
+
width,
|
|
99
|
+
maxHeight: availableHeight
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
padding: WINDOW_PADDING
|
|
103
|
+
});
|
|
104
|
+
const { x, y, reference, floating, strategy, context, refs } = useFloating({
|
|
105
|
+
open,
|
|
106
|
+
onOpenChange: setOpen,
|
|
107
|
+
whileElementsMounted: autoUpdate,
|
|
108
|
+
placement: "bottom-start",
|
|
109
|
+
middleware: fallback ? [
|
|
110
|
+
offset(5),
|
|
111
|
+
...[
|
|
112
|
+
touch ? shift({ crossAxis: true, padding: WINDOW_PADDING }) : flip({ padding: WINDOW_PADDING })
|
|
113
|
+
],
|
|
114
|
+
updateFloatingSize
|
|
115
|
+
] : [
|
|
116
|
+
inner({
|
|
117
|
+
listRef: listItemsRef,
|
|
118
|
+
overflowRef,
|
|
119
|
+
index: selectedIndex,
|
|
120
|
+
offset: innerOffset,
|
|
121
|
+
onFallbackChange: setFallback,
|
|
122
|
+
padding: 10,
|
|
123
|
+
minItemsVisible: touch ? 10 : 4,
|
|
124
|
+
referenceOverflowThreshold: 20
|
|
125
|
+
}),
|
|
126
|
+
updateFloatingSize
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
const floatingRef = refs.floating;
|
|
130
|
+
const showUpArrow = open && scrollTop > SCROLL_ARROW_THRESHOLD;
|
|
131
|
+
const showDownArrow = open && floatingRef.current && scrollTop < floatingRef.current.scrollHeight - floatingRef.current.clientHeight - SCROLL_ARROW_THRESHOLD;
|
|
132
|
+
const interactions = useInteractions([
|
|
133
|
+
useClick(context, { pointerDown: true }),
|
|
134
|
+
useDismiss(context, { outsidePointerDown: true }),
|
|
135
|
+
useRole(context, { role: "listbox" }),
|
|
136
|
+
useInnerOffset(context, {
|
|
137
|
+
enabled: !fallback,
|
|
138
|
+
onChange: setInnerOffset,
|
|
139
|
+
overflowRef
|
|
140
|
+
}),
|
|
141
|
+
useListNavigation(context, {
|
|
142
|
+
listRef: listItemsRef,
|
|
143
|
+
activeIndex,
|
|
144
|
+
selectedIndex,
|
|
145
|
+
onNavigate: setActiveIndex
|
|
146
|
+
}),
|
|
147
|
+
useTypeahead(context, {
|
|
148
|
+
listRef: listContentRef,
|
|
149
|
+
onMatch: open ? setActiveIndex : setSelectedIndex,
|
|
150
|
+
selectedIndex,
|
|
151
|
+
activeIndex
|
|
152
|
+
})
|
|
153
|
+
]);
|
|
154
|
+
const interactionsContext = React.useMemo(() => {
|
|
155
|
+
return {
|
|
156
|
+
...interactions,
|
|
157
|
+
getReferenceProps() {
|
|
158
|
+
return interactions.getReferenceProps({
|
|
159
|
+
ref: reference,
|
|
160
|
+
className: "SelectTrigger",
|
|
161
|
+
onKeyDown(event) {
|
|
162
|
+
if (event.key === "Enter" || event.key === " " && !context.dataRef.current.typing) {
|
|
163
|
+
event.preventDefault();
|
|
164
|
+
setOpen(true);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
getFloatingProps(props2) {
|
|
170
|
+
return interactions.getFloatingProps({
|
|
171
|
+
ref: floating,
|
|
172
|
+
className: "Select",
|
|
173
|
+
...props2,
|
|
174
|
+
style: {
|
|
175
|
+
position: strategy,
|
|
176
|
+
top: y ?? "",
|
|
177
|
+
left: x ?? "",
|
|
178
|
+
outline: 0,
|
|
179
|
+
scrollbarWidth: "none",
|
|
180
|
+
...floatingStyle.current,
|
|
181
|
+
...props2 == null ? void 0 : props2.style
|
|
182
|
+
},
|
|
183
|
+
onPointerEnter() {
|
|
184
|
+
setControlledScrolling(false);
|
|
185
|
+
state.current.isMouseOutside = false;
|
|
186
|
+
},
|
|
187
|
+
onPointerLeave() {
|
|
188
|
+
state.current.isMouseOutside = true;
|
|
189
|
+
},
|
|
190
|
+
onPointerMove() {
|
|
191
|
+
state.current.isMouseOutside = false;
|
|
192
|
+
setControlledScrolling(false);
|
|
193
|
+
},
|
|
194
|
+
onKeyDown() {
|
|
195
|
+
setControlledScrolling(true);
|
|
196
|
+
},
|
|
197
|
+
onContextMenu(e) {
|
|
198
|
+
e.preventDefault();
|
|
199
|
+
},
|
|
200
|
+
onScroll(event) {
|
|
201
|
+
flushSync(() => setScrollTop(event.currentTarget.scrollTop));
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}, [floating, y, x, interactions]);
|
|
207
|
+
useIsomorphicLayoutEffect(() => {
|
|
208
|
+
if (open) {
|
|
209
|
+
selectTimeoutRef.current = setTimeout(() => {
|
|
210
|
+
allowSelectRef.current = true;
|
|
211
|
+
}, 300);
|
|
212
|
+
return () => {
|
|
213
|
+
clearTimeout(selectTimeoutRef.current);
|
|
214
|
+
};
|
|
215
|
+
} else {
|
|
216
|
+
allowSelectRef.current = false;
|
|
217
|
+
allowMouseUpRef.current = true;
|
|
218
|
+
setInnerOffset(0);
|
|
219
|
+
setFallback(false);
|
|
220
|
+
setBlockSelection(false);
|
|
221
|
+
}
|
|
222
|
+
}, [open]);
|
|
223
|
+
useIsomorphicLayoutEffect(() => {
|
|
224
|
+
function onPointerDown(e) {
|
|
225
|
+
var _a, _b, _c;
|
|
226
|
+
const target = e.target;
|
|
227
|
+
if (!(((_a = refs.floating.current) == null ? void 0 : _a.contains(target)) || ((_b = upArrowRef.current) == null ? void 0 : _b.contains(target)) || ((_c = downArrowRef.current) == null ? void 0 : _c.contains(target)))) {
|
|
228
|
+
setOpen(false);
|
|
229
|
+
setControlledScrolling(false);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (open) {
|
|
233
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
234
|
+
return () => {
|
|
235
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
}, [open, refs, setOpen]);
|
|
239
|
+
useIsomorphicLayoutEffect(() => {
|
|
240
|
+
var _a, _b;
|
|
241
|
+
if (open && controlledScrolling) {
|
|
242
|
+
if (activeIndex != null) {
|
|
243
|
+
(_a = listItemsRef.current[activeIndex]) == null ? void 0 : _a.scrollIntoView({ block: "nearest" });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
setScrollTop(((_b = refs.floating.current) == null ? void 0 : _b.scrollTop) ?? 0);
|
|
247
|
+
}, [open, refs, controlledScrolling, activeIndex]);
|
|
248
|
+
useIsomorphicLayoutEffect(() => {
|
|
249
|
+
var _a;
|
|
250
|
+
if (open && fallback) {
|
|
251
|
+
if (selectedIndex != null) {
|
|
252
|
+
(_a = listItemsRef.current[selectedIndex]) == null ? void 0 : _a.scrollIntoView({ block: "nearest" });
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}, [open, fallback, selectedIndex]);
|
|
256
|
+
useIsomorphicLayoutEffect(() => {
|
|
257
|
+
if (refs.floating.current && fallback) {
|
|
258
|
+
refs.floating.current.style.maxHeight = "";
|
|
259
|
+
}
|
|
260
|
+
}, [refs, fallback]);
|
|
261
|
+
return /* @__PURE__ */ jsx(
|
|
262
|
+
SelectProvider,
|
|
263
|
+
{
|
|
264
|
+
scope: __scopeSelect,
|
|
265
|
+
...selectContext,
|
|
266
|
+
setScrollTop,
|
|
267
|
+
setInnerOffset,
|
|
268
|
+
floatingRef,
|
|
269
|
+
setValueAtIndex: (index, value) => {
|
|
270
|
+
listContentRef.current[index] = value;
|
|
271
|
+
},
|
|
272
|
+
fallback,
|
|
273
|
+
interactions: interactionsContext,
|
|
274
|
+
floatingContext: context,
|
|
275
|
+
activeIndex,
|
|
276
|
+
canScrollDown: !!showDownArrow,
|
|
277
|
+
canScrollUp: !!showUpArrow,
|
|
278
|
+
controlledScrolling,
|
|
279
|
+
dataRef: context.dataRef,
|
|
280
|
+
listRef: listItemsRef,
|
|
281
|
+
blockSelection,
|
|
282
|
+
allowMouseUpRef,
|
|
283
|
+
upArrowRef,
|
|
284
|
+
downArrowRef,
|
|
285
|
+
selectTimeoutRef,
|
|
286
|
+
allowSelectRef,
|
|
287
|
+
children
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
};
|
|
291
|
+
const userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
|
|
292
|
+
export {
|
|
293
|
+
SelectInlineImpl
|
|
294
|
+
};
|
|
295
|
+
//# sourceMappingURL=SelectImpl.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/SelectImpl.tsx"],
|
|
4
|
+
"sourcesContent": ["import {\n SideObject,\n autoUpdate,\n flip,\n inner,\n offset,\n shift,\n size,\n useClick,\n useDismiss,\n useFloating,\n useInnerOffset,\n useInteractions,\n useListNavigation,\n useRole,\n useTypeahead,\n} from '@floating-ui/react-dom-interactions'\nimport {\n isClient,\n isWeb,\n useIsTouchDevice,\n useIsomorphicLayoutEffect,\n} from '@tamagui/core'\nimport * as React from 'react'\nimport { flushSync } from 'react-dom'\n\nimport { SCROLL_ARROW_THRESHOLD, WINDOW_PADDING } from './constants'\nimport { SelectProvider, useSelectContext } from './context'\nimport { SelectImplProps } from './types'\n\n// TODO use id for focusing from label\nexport const SelectInlineImpl = (props: SelectImplProps) => {\n const {\n __scopeSelect,\n children,\n open = false,\n selectedIndexRef,\n listContentRef,\n } = props\n\n const selectContext = useSelectContext('SelectSheetImpl', __scopeSelect)\n const {\n setActiveIndex,\n setOpen,\n setSelectedIndex,\n selectedIndex,\n activeIndex,\n forceUpdate,\n } = selectContext\n const [scrollTop, setScrollTop] = React.useState(0)\n const touch = useIsTouchDevice()\n\n const listItemsRef = React.useRef<Array<HTMLElement | null>>([])\n const overflowRef = React.useRef<null | SideObject>(null)\n const upArrowRef = React.useRef<HTMLDivElement | null>(null)\n const downArrowRef = React.useRef<HTMLDivElement | null>(null)\n const allowSelectRef = React.useRef(false)\n const allowMouseUpRef = React.useRef(true)\n const selectTimeoutRef = React.useRef<any>()\n const state = React.useRef({\n isMouseOutside: false,\n })\n\n const [controlledScrolling, setControlledScrolling] = React.useState(false)\n const [fallback, setFallback] = React.useState(false)\n const [innerOffset, setInnerOffset] = React.useState(0)\n const [blockSelection, setBlockSelection] = React.useState(false)\n const floatingStyle = React.useRef({})\n\n // Wait for scroll position to settle before showing arrows to prevent\n // interference with pointer events.\n React.useEffect(() => {\n const frame = requestAnimationFrame(() => {\n if (!open) {\n setScrollTop(0)\n setFallback(false)\n setActiveIndex(null)\n setControlledScrolling(false)\n }\n })\n return () => {\n cancelAnimationFrame(frame)\n }\n }, [open, setActiveIndex])\n\n // close when mouseup outside select\n if (isWeb && isClient) {\n React.useEffect(() => {\n if (!open) return\n const mouseUp = (e: MouseEvent) => {\n if (state.current.isMouseOutside) {\n setOpen(false)\n }\n }\n document.addEventListener('mouseup', mouseUp)\n return () => {\n document.removeEventListener('mouseup', mouseUp)\n }\n }, [open])\n }\n\n const updateFloatingSize = size({\n apply({\n availableHeight,\n rects: {\n reference: { width },\n },\n }) {\n floatingStyle.current = {\n width: width,\n maxHeight: availableHeight,\n }\n },\n padding: WINDOW_PADDING,\n })\n\n const { x, y, reference, floating, strategy, context, refs } = useFloating({\n open,\n onOpenChange: setOpen,\n whileElementsMounted: autoUpdate,\n placement: 'bottom-start',\n middleware: fallback\n ? [\n offset(5),\n ...[\n touch\n ? shift({ crossAxis: true, padding: WINDOW_PADDING })\n : flip({ padding: WINDOW_PADDING }),\n ],\n updateFloatingSize,\n ]\n : [\n inner({\n listRef: listItemsRef,\n overflowRef,\n index: selectedIndex,\n offset: innerOffset,\n onFallbackChange: setFallback,\n padding: 10,\n minItemsVisible: touch ? 10 : 4,\n referenceOverflowThreshold: 20,\n }),\n updateFloatingSize,\n ],\n })\n\n const floatingRef = refs.floating\n\n const showUpArrow = open && scrollTop > SCROLL_ARROW_THRESHOLD\n const showDownArrow =\n open &&\n floatingRef.current &&\n scrollTop <\n floatingRef.current.scrollHeight -\n floatingRef.current.clientHeight -\n SCROLL_ARROW_THRESHOLD\n\n const interactions = useInteractions([\n useClick(context, { pointerDown: true }),\n useDismiss(context, { outsidePointerDown: true }),\n useRole(context, { role: 'listbox' }),\n useInnerOffset(context, {\n enabled: !fallback,\n onChange: setInnerOffset,\n overflowRef,\n }),\n useListNavigation(context, {\n listRef: listItemsRef,\n activeIndex,\n selectedIndex,\n onNavigate: setActiveIndex,\n }),\n useTypeahead(context, {\n listRef: listContentRef,\n onMatch: open ? setActiveIndex : setSelectedIndex,\n selectedIndex,\n activeIndex,\n }),\n ])\n\n const interactionsContext = React.useMemo(() => {\n return {\n ...interactions,\n getReferenceProps() {\n return interactions.getReferenceProps({\n ref: reference,\n className: 'SelectTrigger',\n onKeyDown(event) {\n if (\n event.key === 'Enter' ||\n (event.key === ' ' && !context.dataRef.current.typing)\n ) {\n event.preventDefault()\n setOpen(true)\n }\n },\n })\n },\n getFloatingProps(props) {\n return interactions.getFloatingProps({\n ref: floating,\n className: 'Select',\n ...props,\n style: {\n position: strategy,\n top: y ?? '',\n left: x ?? '',\n outline: 0,\n scrollbarWidth: 'none',\n ...floatingStyle.current,\n ...props?.style,\n },\n onPointerEnter() {\n setControlledScrolling(false)\n state.current.isMouseOutside = false\n },\n onPointerLeave() {\n state.current.isMouseOutside = true\n },\n onPointerMove() {\n state.current.isMouseOutside = false\n setControlledScrolling(false)\n },\n onKeyDown() {\n setControlledScrolling(true)\n },\n onContextMenu(e) {\n e.preventDefault()\n },\n onScroll(event) {\n // In React 18, the ScrollArrows need to synchronously know this value to prevent\n // painting at the wrong time.\n flushSync(() => setScrollTop(event.currentTarget.scrollTop))\n },\n })\n },\n }\n }, [floating, y, x, interactions])\n\n // effects\n\n useIsomorphicLayoutEffect(() => {\n if (open) {\n selectTimeoutRef.current = setTimeout(() => {\n allowSelectRef.current = true\n }, 300)\n\n return () => {\n clearTimeout(selectTimeoutRef.current)\n }\n } else {\n allowSelectRef.current = false\n allowMouseUpRef.current = true\n setInnerOffset(0)\n setFallback(false)\n setBlockSelection(false)\n }\n }, [open])\n\n // Replacement for `useDismiss` as the arrows are outside of the floating\n // element DOM tree.\n useIsomorphicLayoutEffect(() => {\n function onPointerDown(e: PointerEvent) {\n const target = e.target as Node\n if (\n !(\n refs.floating.current?.contains(target) ||\n upArrowRef.current?.contains(target) ||\n downArrowRef.current?.contains(target)\n )\n ) {\n setOpen(false)\n setControlledScrolling(false)\n }\n }\n\n if (open) {\n document.addEventListener('pointerdown', onPointerDown)\n return () => {\n document.removeEventListener('pointerdown', onPointerDown)\n }\n }\n }, [open, refs, setOpen])\n\n // Scroll the `activeIndex` item into view only in \"controlledScrolling\"\n // (keyboard nav) mode.\n useIsomorphicLayoutEffect(() => {\n if (open && controlledScrolling) {\n if (activeIndex != null) {\n listItemsRef.current[activeIndex]?.scrollIntoView({ block: 'nearest' })\n }\n }\n\n setScrollTop(refs.floating.current?.scrollTop ?? 0)\n }, [open, refs, controlledScrolling, activeIndex])\n\n // Scroll the `selectedIndex` into view upon opening the floating element.\n useIsomorphicLayoutEffect(() => {\n if (open && fallback) {\n if (selectedIndex != null) {\n listItemsRef.current[selectedIndex]?.scrollIntoView({ block: 'nearest' })\n }\n }\n }, [open, fallback, selectedIndex])\n\n // Unset the height limiting for fallback mode. This gets executed prior to\n // the positioning call.\n useIsomorphicLayoutEffect(() => {\n if (refs.floating.current && fallback) {\n refs.floating.current.style.maxHeight = ''\n }\n }, [refs, fallback])\n\n // We set this to true by default so that events bubble to forms without JS (SSR)\n // const isFormControl = trigger ? Boolean(trigger.closest('form')) : true\n // const [bubbleSelect, setBubbleSelect] = React.useState<HTMLSelectElement | null>(null)\n // const triggerPointerDownPosRef = React.useRef<{ x: number; y: number } | null>(null)\n\n return (\n <SelectProvider\n scope={__scopeSelect}\n {...(selectContext as Required<typeof selectContext>)}\n setScrollTop={setScrollTop}\n setInnerOffset={setInnerOffset}\n floatingRef={floatingRef}\n setValueAtIndex={(index, value) => {\n listContentRef.current[index] = value\n }}\n fallback={fallback}\n interactions={interactionsContext}\n floatingContext={context}\n activeIndex={activeIndex}\n canScrollDown={!!showDownArrow}\n canScrollUp={!!showUpArrow}\n controlledScrolling={controlledScrolling}\n dataRef={context.dataRef}\n listRef={listItemsRef}\n blockSelection={blockSelection}\n allowMouseUpRef={allowMouseUpRef}\n upArrowRef={upArrowRef}\n downArrowRef={downArrowRef}\n selectTimeoutRef={selectTimeoutRef}\n allowSelectRef={allowSelectRef}\n >\n {children}\n {/* {isFormControl ? (\n <BubbleSelect\n ref={setBubbleSelect}\n aria-hidden\n tabIndex={-1}\n name={name}\n autoComplete={autoComplete}\n value={value}\n // enable form autofill\n onChange={(event) => setValue(event.target.value)}\n />\n ) : null} */}\n </SelectProvider>\n )\n}\n\n// Cross browser fixes for pinch-zooming/backdrop-filter \uD83D\uDE44\nconst userAgent = (typeof navigator !== 'undefined' && navigator.userAgent) || ''\n"],
|
|
5
|
+
"m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,MACjB,aAAa,CAAC,CAAC;AAAA,MACf;AAAA,MACA,SAAS,QAAQ;AAAA,MACjB,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,EAaH;AAEJ;AAGA,MAAM,YAAa,OAAO,cAAc,eAAe,UAAU,aAAc;",
|
|
6
|
+
"names": ["props"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
const SelectInlineImpl = (props) => {
|
|
3
|
+
if (process.env.NODE_ENV === "development") {
|
|
4
|
+
console.warn("Sheet not implemented inline on native");
|
|
5
|
+
}
|
|
6
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
SelectInlineImpl
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=SelectImpl.native.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/SelectImpl.native.tsx"],
|
|
4
|
+
"sourcesContent": ["import { SelectImplProps } from './types'\n\n/**\n * TODO can just make it a sheet for native\n * later on can have `native` prop\n */\n\nexport const SelectInlineImpl = (props: SelectImplProps) => {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('Sheet not implemented inline on native')\n }\n return <>{props.children}</>\n}\n"],
|
|
5
|
+
"mappings": "AAYS;AALF,MAAM,mBAAmB,CAAC,UAA2B;AAC1D,MAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,YAAQ,KAAK,wCAAwC;AAAA,EACvD;AACA,SAAO,gCAAG,gBAAM,UAAS;AAC3B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { autoUpdate, offset, useFloating } from "@floating-ui/react-dom-interactions";
|
|
3
|
+
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
4
|
+
import { useIsomorphicLayoutEffect } from "@tamagui/core";
|
|
5
|
+
import { YStack } from "@tamagui/stacks";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { flushSync } from "react-dom";
|
|
8
|
+
import { useSelectContext } from "./context";
|
|
9
|
+
const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
10
|
+
const SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
SelectScrollButtonImpl,
|
|
13
|
+
{
|
|
14
|
+
componentName: SCROLL_UP_BUTTON_NAME,
|
|
15
|
+
...props,
|
|
16
|
+
dir: "up",
|
|
17
|
+
ref: forwardedRef
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
22
|
+
const SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
23
|
+
const SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
SelectScrollButtonImpl,
|
|
26
|
+
{
|
|
27
|
+
componentName: SCROLL_DOWN_BUTTON_NAME,
|
|
28
|
+
...props,
|
|
29
|
+
dir: "down",
|
|
30
|
+
ref: forwardedRef
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
35
|
+
const SelectScrollButtonImpl = React.memo(
|
|
36
|
+
React.forwardRef(
|
|
37
|
+
(props, forwardedRef) => {
|
|
38
|
+
var _a;
|
|
39
|
+
const { __scopeSelect, dir, componentName, ...scrollIndicatorProps } = props;
|
|
40
|
+
const {
|
|
41
|
+
floatingRef,
|
|
42
|
+
forceUpdate,
|
|
43
|
+
open,
|
|
44
|
+
fallback,
|
|
45
|
+
setScrollTop,
|
|
46
|
+
setInnerOffset,
|
|
47
|
+
...context
|
|
48
|
+
} = useSelectContext(componentName, __scopeSelect);
|
|
49
|
+
const [element, setElement] = React.useState(null);
|
|
50
|
+
const statusRef = React.useRef("idle");
|
|
51
|
+
const isVisible = context[dir === "down" ? "canScrollDown" : "canScrollUp"];
|
|
52
|
+
const frameRef = React.useRef();
|
|
53
|
+
const { x, y, reference, floating, strategy, update, refs } = useFloating({
|
|
54
|
+
open: open && isVisible,
|
|
55
|
+
strategy: "fixed",
|
|
56
|
+
placement: dir === "up" ? "top" : "bottom",
|
|
57
|
+
middleware: [offset(({ rects }) => -rects.floating.height)],
|
|
58
|
+
whileElementsMounted: (...args) => autoUpdate(...args, { animationFrame: true })
|
|
59
|
+
});
|
|
60
|
+
const composedRef = useComposedRefs(forwardedRef, floating);
|
|
61
|
+
if (floatingRef) {
|
|
62
|
+
if (open) {
|
|
63
|
+
if (element !== floatingRef.current) {
|
|
64
|
+
setElement(floatingRef.current);
|
|
65
|
+
reference(floatingRef.current);
|
|
66
|
+
requestAnimationFrame(update);
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
cancelAnimationFrame(frameRef.current);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
useIsomorphicLayoutEffect(() => {
|
|
73
|
+
return () => {
|
|
74
|
+
cancelAnimationFrame(frameRef.current);
|
|
75
|
+
};
|
|
76
|
+
}, []);
|
|
77
|
+
if (!(isVisible && floatingRef)) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const onScroll = (amount) => {
|
|
81
|
+
if (fallback) {
|
|
82
|
+
if (refs.floating.current) {
|
|
83
|
+
refs.floating.current.scrollTop -= amount;
|
|
84
|
+
flushSync(() => {
|
|
85
|
+
var _a2;
|
|
86
|
+
return setScrollTop(((_a2 = refs.floating.current) == null ? void 0 : _a2.scrollTop) ?? 0);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
flushSync(() => setInnerOffset((value) => value - amount));
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return /* @__PURE__ */ jsx(
|
|
94
|
+
YStack,
|
|
95
|
+
{
|
|
96
|
+
ref: composedRef,
|
|
97
|
+
componentName,
|
|
98
|
+
"aria-hidden": true,
|
|
99
|
+
...scrollIndicatorProps,
|
|
100
|
+
zIndex: 1e3,
|
|
101
|
+
position: strategy,
|
|
102
|
+
left: x || 0,
|
|
103
|
+
top: y || 0,
|
|
104
|
+
width: `calc(${(((_a = floatingRef == null ? void 0 : floatingRef.current) == null ? void 0 : _a.offsetWidth) ?? 0) - 2}px)`,
|
|
105
|
+
onPointerEnter: () => {
|
|
106
|
+
statusRef.current = "active";
|
|
107
|
+
let prevNow = Date.now();
|
|
108
|
+
function frame() {
|
|
109
|
+
if (element) {
|
|
110
|
+
const currentNow = Date.now();
|
|
111
|
+
const msElapsed = currentNow - prevNow;
|
|
112
|
+
prevNow = currentNow;
|
|
113
|
+
const pixelsToScroll = msElapsed / 2;
|
|
114
|
+
const remainingPixels = dir === "up" ? element.scrollTop : element.scrollHeight - element.clientHeight - element.scrollTop;
|
|
115
|
+
const scrollRemaining = dir === "up" ? element.scrollTop - pixelsToScroll > 0 : element.scrollTop + pixelsToScroll < element.scrollHeight - element.clientHeight;
|
|
116
|
+
onScroll(
|
|
117
|
+
dir === "up" ? Math.min(pixelsToScroll, remainingPixels) : Math.max(-pixelsToScroll, -remainingPixels)
|
|
118
|
+
);
|
|
119
|
+
if (scrollRemaining) {
|
|
120
|
+
frameRef.current = requestAnimationFrame(frame);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
cancelAnimationFrame(frameRef.current);
|
|
125
|
+
frameRef.current = requestAnimationFrame(frame);
|
|
126
|
+
},
|
|
127
|
+
onPointerLeave: () => {
|
|
128
|
+
statusRef.current = "idle";
|
|
129
|
+
cancelAnimationFrame(frameRef.current);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
export {
|
|
137
|
+
SelectScrollDownButton,
|
|
138
|
+
SelectScrollUpButton
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=SelectScrollButton.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/SelectScrollButton.tsx"],
|
|
4
|
+
"sourcesContent": ["import { autoUpdate, offset, useFloating } from '@floating-ui/react-dom-interactions'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport { TamaguiElement, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { flushSync } from 'react-dom'\n\nimport { useSelectContext } from './context'\nimport {\n ScopedProps,\n SelectScrollButtonImplProps,\n SelectScrollButtonProps,\n} from './types'\n\n/* -------------------------------------------------------------------------------------------------\n * SelectScrollUpButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst SCROLL_UP_BUTTON_NAME = 'SelectScrollUpButton'\n\nexport const SelectScrollUpButton = React.forwardRef<\n TamaguiElement,\n SelectScrollButtonProps\n>((props: ScopedProps<SelectScrollButtonProps>, forwardedRef) => {\n return (\n <SelectScrollButtonImpl\n componentName={SCROLL_UP_BUTTON_NAME}\n {...props}\n dir=\"up\"\n ref={forwardedRef}\n />\n )\n})\n\nSelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SelectScrollDownButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst SCROLL_DOWN_BUTTON_NAME = 'SelectScrollDownButton'\n\nexport const SelectScrollDownButton = React.forwardRef<\n TamaguiElement,\n SelectScrollButtonProps\n>((props: ScopedProps<SelectScrollButtonProps>, forwardedRef) => {\n return (\n <SelectScrollButtonImpl\n componentName={SCROLL_DOWN_BUTTON_NAME}\n {...props}\n dir=\"down\"\n ref={forwardedRef}\n />\n )\n})\n\nSelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME\n\ntype SelectScrollButtonImplElement = TamaguiElement\n\nconst SelectScrollButtonImpl = React.memo(\n React.forwardRef<SelectScrollButtonImplElement, SelectScrollButtonImplProps>(\n (props: ScopedProps<SelectScrollButtonImplProps>, forwardedRef) => {\n const { __scopeSelect, dir, componentName, ...scrollIndicatorProps } = props\n const {\n floatingRef,\n forceUpdate,\n open,\n fallback,\n setScrollTop,\n setInnerOffset,\n ...context\n } = useSelectContext(componentName, __scopeSelect)\n\n const [element, setElement] = React.useState<HTMLElement | null>(null)\n const statusRef = React.useRef<'idle' | 'active'>('idle')\n const isVisible = context[dir === 'down' ? 'canScrollDown' : 'canScrollUp']\n const frameRef = React.useRef<any>()\n\n const { x, y, reference, floating, strategy, update, refs } = useFloating({\n open: open && isVisible,\n strategy: 'fixed',\n placement: dir === 'up' ? 'top' : 'bottom',\n middleware: [offset(({ rects }) => -rects.floating.height)],\n whileElementsMounted: (...args) => autoUpdate(...args, { animationFrame: true }),\n })\n\n const composedRef = useComposedRefs(forwardedRef, floating)\n\n if (floatingRef) {\n if (open) {\n if (element !== floatingRef.current) {\n setElement(floatingRef.current)\n reference(floatingRef.current)\n requestAnimationFrame(update)\n }\n } else {\n cancelAnimationFrame(frameRef.current)\n }\n }\n\n useIsomorphicLayoutEffect(() => {\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n cancelAnimationFrame(frameRef.current)\n }\n }, [])\n\n if (!(isVisible && floatingRef)) {\n return null\n }\n\n const onScroll = (amount: number) => {\n if (fallback) {\n if (refs.floating.current) {\n refs.floating.current.scrollTop -= amount\n flushSync(() => setScrollTop!(refs.floating.current?.scrollTop ?? 0))\n }\n } else {\n flushSync(() => setInnerOffset!((value) => value - amount))\n }\n }\n\n return (\n <YStack\n ref={composedRef}\n componentName={componentName}\n aria-hidden\n {...scrollIndicatorProps}\n zIndex={1000}\n // @ts-expect-error\n position={strategy}\n left={x || 0}\n top={y || 0}\n width={`calc(${(floatingRef?.current?.offsetWidth ?? 0) - 2}px)`}\n onPointerEnter={() => {\n statusRef.current = 'active'\n let prevNow = Date.now()\n\n function frame() {\n if (element) {\n const currentNow = Date.now()\n const msElapsed = currentNow - prevNow\n prevNow = currentNow\n\n const pixelsToScroll = msElapsed / 2\n\n const remainingPixels =\n dir === 'up'\n ? element.scrollTop\n : element.scrollHeight - element.clientHeight - element.scrollTop\n\n const scrollRemaining =\n dir === 'up'\n ? element.scrollTop - pixelsToScroll > 0\n : element.scrollTop + pixelsToScroll <\n element.scrollHeight - element.clientHeight\n\n onScroll(\n dir === 'up'\n ? Math.min(pixelsToScroll, remainingPixels)\n : Math.max(-pixelsToScroll, -remainingPixels)\n )\n\n if (scrollRemaining) {\n frameRef.current = requestAnimationFrame(frame)\n }\n }\n }\n\n cancelAnimationFrame(frameRef.current)\n frameRef.current = requestAnimationFrame(frame)\n }}\n onPointerLeave={() => {\n statusRef.current = 'idle'\n cancelAnimationFrame(frameRef.current)\n }}\n />\n )\n }\n )\n)\n"],
|
|
5
|
+
"mappings": "AAyBI;AAzBJ,SAAS,YAAY,QAAQ,mBAAmB;AAChD,SAAS,uBAAuB;AAChC,SAAyB,iCAAiC;AAC1D,SAAS,cAAc;AACvB,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAE1B,SAAS,wBAAwB;AAWjC,MAAM,wBAAwB;AAEvB,MAAM,uBAAuB,MAAM,WAGxC,CAAC,OAA6C,iBAAiB;AAC/D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAe;AAAA,MACd,GAAG;AAAA,MACJ,KAAI;AAAA,MACJ,KAAK;AAAA;AAAA,EACP;AAEJ,CAAC;AAED,qBAAqB,cAAc;AAMnC,MAAM,0BAA0B;AAEzB,MAAM,yBAAyB,MAAM,WAG1C,CAAC,OAA6C,iBAAiB;AAC/D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAe;AAA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ACF;AAAA,YACF;AAEA,iCAAqB,SAAS,OAAO;AACrC,qBAAS,UAAU,sBAAsB,KAAK;AAAA,UAChD;AAAA,UACA,gBAAgB,MAAM;AACpB,sBAAU,UAAU;AACpB,iCAAqB,SAAS,OAAO;AAAA,UACvC;AAAA;AAAA,MACF;AAAA,IAEJ;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["_a"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/SelectScrollButton.native.tsx"],
|
|
4
|
+
"sourcesContent": ["import { ScopedProps, SelectScrollButtonProps } from './types'\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const SelectScrollUpButton = (_: ScopedProps<SelectScrollButtonProps>) => null\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const SelectScrollDownButton = (_: ScopedProps<SelectScrollButtonProps>) =>\n null\n"],
|
|
5
|
+
"mappings": "AAGO,MAAM,uBAAuB,CAAC,MAA4C;AAG1E,MAAM,yBAAyB,CAAC,MACrC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FloatingFocusManager } from "@floating-ui/react-dom-interactions";
|
|
3
|
+
import { isWeb } from "@tamagui/core";
|
|
4
|
+
import { styled } from "@tamagui/core";
|
|
5
|
+
import { PortalItem } from "@tamagui/portal";
|
|
6
|
+
import { ThemeableStack } from "@tamagui/stacks";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { VIEWPORT_NAME } from "./constants";
|
|
9
|
+
import { ForwardSelectContext, useSelectContext } from "./context";
|
|
10
|
+
import { useSelectBreakpointActive } from "./useSelectBreakpointActive";
|
|
11
|
+
const SelectViewportFrame = styled(ThemeableStack, {
|
|
12
|
+
name: VIEWPORT_NAME,
|
|
13
|
+
backgroundColor: "$background",
|
|
14
|
+
elevate: true,
|
|
15
|
+
bordered: true,
|
|
16
|
+
overflow: "scroll",
|
|
17
|
+
userSelect: "none",
|
|
18
|
+
outlineWidth: 0,
|
|
19
|
+
variants: {
|
|
20
|
+
size: {
|
|
21
|
+
"...size": (val, { tokens }) => {
|
|
22
|
+
return {
|
|
23
|
+
borderRadius: tokens.radius[val] ?? val
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
size: "$2"
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const SelectViewport = React.forwardRef(
|
|
33
|
+
(props, forwardedRef) => {
|
|
34
|
+
const { __scopeSelect, children, disableScroll, ...viewportProps } = props;
|
|
35
|
+
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
36
|
+
const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint);
|
|
37
|
+
if (breakpointActive || !isWeb) {
|
|
38
|
+
return /* @__PURE__ */ jsx(PortalItem, { hostName: `${context.scopeKey}SheetContents`, children: /* @__PURE__ */ jsx(ForwardSelectContext, { context, children }) });
|
|
39
|
+
}
|
|
40
|
+
if (!context.floatingContext) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (!context.open) {
|
|
44
|
+
return children;
|
|
45
|
+
}
|
|
46
|
+
const {
|
|
47
|
+
style: { scrollbarWidth, listStyleType, overflow, ...restStyle },
|
|
48
|
+
...floatingProps
|
|
49
|
+
} = context.interactions.getFloatingProps();
|
|
50
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
51
|
+
!disableScroll && /* @__PURE__ */ jsx(
|
|
52
|
+
"style",
|
|
53
|
+
{
|
|
54
|
+
dangerouslySetInnerHTML: {
|
|
55
|
+
__html: selectViewportCSS
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
/* @__PURE__ */ jsx(FloatingFocusManager, { context: context.floatingContext, children: /* @__PURE__ */ jsx(
|
|
60
|
+
SelectViewportFrame,
|
|
61
|
+
{
|
|
62
|
+
size: context.size,
|
|
63
|
+
role: "presentation",
|
|
64
|
+
...viewportProps,
|
|
65
|
+
ref: forwardedRef,
|
|
66
|
+
...floatingProps,
|
|
67
|
+
...restStyle,
|
|
68
|
+
overflow: disableScroll ? void 0 : overflow,
|
|
69
|
+
children
|
|
70
|
+
}
|
|
71
|
+
) })
|
|
72
|
+
] });
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
SelectViewport.displayName = VIEWPORT_NAME;
|
|
76
|
+
const selectViewportCSS = `
|
|
77
|
+
.is_SelectViewport {
|
|
78
|
+
scrollbar-width: none;
|
|
79
|
+
-webkit-overflow-scrolling: touch;
|
|
80
|
+
overscroll-behavior: contain;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.is_SelectViewport::-webkit-scrollbar{
|
|
84
|
+
display:none
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
export {
|
|
88
|
+
SelectViewport,
|
|
89
|
+
SelectViewportFrame
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=SelectViewport.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/SelectViewport.tsx"],
|
|
4
|
+
"sourcesContent": ["import { FloatingFocusManager } from '@floating-ui/react-dom-interactions'\nimport { TamaguiElement, isWeb } from '@tamagui/core'\nimport { styled } from '@tamagui/core'\nimport { PortalItem } from '@tamagui/portal'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport * as React from 'react'\n\nimport { VIEWPORT_NAME } from './constants'\nimport { ForwardSelectContext, useSelectContext } from './context'\nimport { ScopedProps, SelectViewportProps } from './types'\nimport { useSelectBreakpointActive } from './useSelectBreakpointActive'\n\n/* -------------------------------------------------------------------------------------------------\n * SelectViewport\n * -----------------------------------------------------------------------------------------------*/\n\nexport const SelectViewportFrame = styled(ThemeableStack, {\n name: VIEWPORT_NAME,\n backgroundColor: '$background',\n elevate: true,\n bordered: true,\n overflow: 'scroll',\n userSelect: 'none',\n outlineWidth: 0,\n\n variants: {\n size: {\n '...size': (val, { tokens }) => {\n return {\n borderRadius: tokens.radius[val] ?? val,\n }\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$2',\n },\n})\n\nexport const SelectViewport = React.forwardRef<TamaguiElement, SelectViewportProps>(\n (props: ScopedProps<SelectViewportProps>, forwardedRef) => {\n const { __scopeSelect, children, disableScroll, ...viewportProps } = props\n const context = useSelectContext(VIEWPORT_NAME, __scopeSelect)\n const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint)\n\n if (breakpointActive || !isWeb) {\n return (\n <PortalItem hostName={`${context.scopeKey}SheetContents`}>\n <ForwardSelectContext context={context}>{children}</ForwardSelectContext>\n </PortalItem>\n )\n }\n\n if (!context.floatingContext) {\n return null\n }\n\n if (!context.open) {\n return children\n }\n\n const {\n style: { scrollbarWidth, listStyleType, overflow, ...restStyle },\n ...floatingProps\n } = context.interactions!.getFloatingProps()\n\n return (\n <>\n {!disableScroll && (\n <style\n dangerouslySetInnerHTML={{\n __html: selectViewportCSS,\n }}\n />\n )}\n <FloatingFocusManager context={context.floatingContext}>\n <SelectViewportFrame\n size={context.size}\n // @ts-ignore\n role=\"presentation\"\n {...viewportProps}\n ref={forwardedRef}\n {...floatingProps}\n {...restStyle}\n overflow={disableScroll ? undefined : overflow}\n >\n {children}\n </SelectViewportFrame>\n </FloatingFocusManager>\n </>\n )\n }\n)\n\nSelectViewport.displayName = VIEWPORT_NAME\n\nconst selectViewportCSS = `\n.is_SelectViewport {\n scrollbar-width: none;\n -webkit-overflow-scrolling: touch;\n overscroll-behavior: contain;\n}\n\n.is_SelectViewport::-webkit-scrollbar{\n display:none\n}\n`\n"],
|
|
5
|
+
"mappings": "AAiDU,SAmBJ,UAnBI,KAmBJ,YAnBI;AAjDV,SAAS,4BAA4B;AACrC,SAAyB,aAAa;AACtC,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MACF;AAAA,MAEF,oBAAC,wBAAqB,SAAS,QAAQ,iBACrC;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,QAAQ;AAAA,UAEd,MAAK;AAAA,UACJ,GAAG;AAAA,UACJ,KAAK;AAAA,UACJ,GAAG;AAAA,UACH,GAAG;AAAA,UACJ,UAAU,gBAAgB,SAAY;AAAA,UAErC;AAAA;AAAA,MACH,GACF;AAAA,OACF;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;AAE7B,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AdaptParentContext } from "@tamagui/adapt";
|
|
3
|
+
import { Theme, useThemeName } from "@tamagui/core";
|
|
4
|
+
import { PortalItem } from "@tamagui/portal";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { VIEWPORT_NAME } from "./constants";
|
|
7
|
+
import { SelectProvider, useSelectContext } from "./context";
|
|
8
|
+
const SelectViewport = (props) => {
|
|
9
|
+
const { __scopeSelect, children } = props;
|
|
10
|
+
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
11
|
+
const themeName = useThemeName();
|
|
12
|
+
const adaptContext = React.useContext(AdaptParentContext);
|
|
13
|
+
return /* @__PURE__ */ jsx(PortalItem, { hostName: `${context.scopeKey}SheetContents`, children: /* @__PURE__ */ jsx(Theme, { name: themeName, children: /* @__PURE__ */ jsx(SelectProvider, { scope: __scopeSelect, ...context, children: /* @__PURE__ */ jsx(AdaptParentContext.Provider, { value: adaptContext, children }) }) }) });
|
|
14
|
+
};
|
|
15
|
+
SelectViewport.displayName = VIEWPORT_NAME;
|
|
16
|
+
export {
|
|
17
|
+
SelectViewport
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=SelectViewport.native.mjs.map
|