@tamagui/linear-gradient 1.0.11 → 1.0.13
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/package.json +4 -4
- package/dist/cjs/BubbleSelect.js +0 -44
- package/dist/cjs/BubbleSelect.js.map +0 -7
- package/dist/cjs/Select.js +0 -480
- package/dist/cjs/Select.js.map +0 -7
- package/dist/cjs/SelectContent.js +0 -76
- package/dist/cjs/SelectContent.js.map +0 -7
- package/dist/cjs/SelectContent.native.js +0 -31
- package/dist/cjs/SelectContent.native.js.map +0 -7
- package/dist/cjs/SelectImpl.js +0 -301
- package/dist/cjs/SelectImpl.js.map +0 -7
- package/dist/cjs/SelectImpl.native.js +0 -37
- package/dist/cjs/SelectImpl.native.js.map +0 -7
- package/dist/cjs/SelectScrollButton.js +0 -161
- package/dist/cjs/SelectScrollButton.js.map +0 -7
- package/dist/cjs/SelectScrollButton.native.js +0 -32
- package/dist/cjs/SelectScrollButton.native.js.map +0 -7
- package/dist/cjs/SelectViewport.js +0 -126
- package/dist/cjs/SelectViewport.js.map +0 -7
- package/dist/cjs/SelectViewport.native.js +0 -62
- package/dist/cjs/SelectViewport.native.js.map +0 -7
- package/dist/cjs/constants.js +0 -47
- package/dist/cjs/constants.js.map +0 -7
- package/dist/cjs/context.js +0 -49
- package/dist/cjs/context.js.map +0 -7
- package/dist/cjs/types.js +0 -17
- package/dist/cjs/types.js.map +0 -7
- package/dist/cjs/useSelectBreakpointActive.js +0 -39
- package/dist/cjs/useSelectBreakpointActive.js.map +0 -7
- package/dist/esm/BubbleSelect.js +0 -25
- package/dist/esm/BubbleSelect.js.map +0 -7
- package/dist/esm/Select.js +0 -452
- package/dist/esm/Select.js.map +0 -7
- package/dist/esm/SelectContent.js +0 -52
- package/dist/esm/SelectContent.js.map +0 -7
- package/dist/esm/SelectContent.native.js +0 -7
- package/dist/esm/SelectContent.native.js.map +0 -7
- package/dist/esm/SelectImpl.js +0 -286
- package/dist/esm/SelectImpl.js.map +0 -7
- package/dist/esm/SelectImpl.native.js +0 -13
- package/dist/esm/SelectImpl.native.js.map +0 -7
- package/dist/esm/SelectScrollButton.js +0 -130
- package/dist/esm/SelectScrollButton.js.map +0 -7
- package/dist/esm/SelectScrollButton.native.js +0 -7
- package/dist/esm/SelectScrollButton.native.js.map +0 -7
- package/dist/esm/SelectViewport.js +0 -95
- package/dist/esm/SelectViewport.js.map +0 -7
- package/dist/esm/SelectViewport.native.js +0 -32
- package/dist/esm/SelectViewport.native.js.map +0 -7
- package/dist/esm/constants.js +0 -17
- package/dist/esm/constants.js.map +0 -7
- package/dist/esm/context.js +0 -21
- package/dist/esm/context.js.map +0 -7
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -7
- package/dist/esm/useSelectBreakpointActive.js +0 -14
- package/dist/esm/useSelectBreakpointActive.js.map +0 -7
- package/dist/jsx/BubbleSelect.js +0 -25
- package/dist/jsx/BubbleSelect.js.map +0 -7
- package/dist/jsx/Select.js +0 -326
- package/dist/jsx/Select.js.map +0 -7
- package/dist/jsx/SelectContent.js +0 -30
- package/dist/jsx/SelectContent.js.map +0 -7
- package/dist/jsx/SelectContent.native.js +0 -7
- package/dist/jsx/SelectContent.native.js.map +0 -7
- package/dist/jsx/SelectImpl.js +0 -259
- package/dist/jsx/SelectImpl.js.map +0 -7
- package/dist/jsx/SelectImpl.native.js +0 -10
- package/dist/jsx/SelectImpl.native.js.map +0 -7
- package/dist/jsx/SelectScrollButton.js +0 -103
- package/dist/jsx/SelectScrollButton.js.map +0 -7
- package/dist/jsx/SelectScrollButton.native.js +0 -7
- package/dist/jsx/SelectScrollButton.native.js.map +0 -7
- package/dist/jsx/SelectViewport.js +0 -73
- package/dist/jsx/SelectViewport.js.map +0 -7
- package/dist/jsx/SelectViewport.native.js +0 -18
- package/dist/jsx/SelectViewport.native.js.map +0 -7
- package/dist/jsx/constants.js +0 -17
- package/dist/jsx/constants.js.map +0 -7
- package/dist/jsx/context.js +0 -15
- package/dist/jsx/context.js.map +0 -7
- package/dist/jsx/types.js +0 -1
- package/dist/jsx/types.js.map +0 -7
- package/dist/jsx/useSelectBreakpointActive.js +0 -14
- package/dist/jsx/useSelectBreakpointActive.js.map +0 -7
package/dist/jsx/SelectImpl.js
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
autoUpdate,
|
|
3
|
-
flip,
|
|
4
|
-
inner,
|
|
5
|
-
offset,
|
|
6
|
-
shift,
|
|
7
|
-
size,
|
|
8
|
-
useClick,
|
|
9
|
-
useDismiss,
|
|
10
|
-
useFloating,
|
|
11
|
-
useInnerOffset,
|
|
12
|
-
useInteractions,
|
|
13
|
-
useListNavigation,
|
|
14
|
-
useRole,
|
|
15
|
-
useTypeahead
|
|
16
|
-
} from "@floating-ui/react-dom-interactions";
|
|
17
|
-
import { isWeb, useIsTouchDevice, useIsomorphicLayoutEffect } from "@tamagui/core";
|
|
18
|
-
import * as React from "react";
|
|
19
|
-
import { flushSync } from "react-dom";
|
|
20
|
-
import { SCROLL_ARROW_THRESHOLD, WINDOW_PADDING } from "./constants";
|
|
21
|
-
import { SelectProvider, useSelectContext } from "./context";
|
|
22
|
-
const SelectInlineImpl = (props) => {
|
|
23
|
-
const {
|
|
24
|
-
__scopeSelect,
|
|
25
|
-
children,
|
|
26
|
-
open = false,
|
|
27
|
-
selectedIndexRef,
|
|
28
|
-
listContentRef
|
|
29
|
-
} = props;
|
|
30
|
-
const selectContext = useSelectContext("SelectSheetImpl", __scopeSelect);
|
|
31
|
-
const {
|
|
32
|
-
setActiveIndex,
|
|
33
|
-
setOpen,
|
|
34
|
-
setSelectedIndex,
|
|
35
|
-
selectedIndex,
|
|
36
|
-
activeIndex,
|
|
37
|
-
forceUpdate
|
|
38
|
-
} = selectContext;
|
|
39
|
-
const [scrollTop, setScrollTop] = React.useState(0);
|
|
40
|
-
const touch = useIsTouchDevice();
|
|
41
|
-
const listItemsRef = React.useRef([]);
|
|
42
|
-
const overflowRef = React.useRef(null);
|
|
43
|
-
const upArrowRef = React.useRef(null);
|
|
44
|
-
const downArrowRef = React.useRef(null);
|
|
45
|
-
const allowSelectRef = React.useRef(false);
|
|
46
|
-
const allowMouseUpRef = React.useRef(true);
|
|
47
|
-
const selectTimeoutRef = React.useRef();
|
|
48
|
-
const state = React.useRef({
|
|
49
|
-
isMouseOutside: false
|
|
50
|
-
});
|
|
51
|
-
const [controlledScrolling, setControlledScrolling] = React.useState(false);
|
|
52
|
-
const [fallback, setFallback] = React.useState(false);
|
|
53
|
-
const [innerOffset, setInnerOffset] = React.useState(0);
|
|
54
|
-
const [blockSelection, setBlockSelection] = React.useState(false);
|
|
55
|
-
const floatingStyle = React.useRef({});
|
|
56
|
-
React.useEffect(() => {
|
|
57
|
-
const frame = requestAnimationFrame(() => {
|
|
58
|
-
if (!open) {
|
|
59
|
-
setScrollTop(0);
|
|
60
|
-
setFallback(false);
|
|
61
|
-
setActiveIndex(null);
|
|
62
|
-
setControlledScrolling(false);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
return () => {
|
|
66
|
-
cancelAnimationFrame(frame);
|
|
67
|
-
};
|
|
68
|
-
}, [open, setActiveIndex]);
|
|
69
|
-
if (isWeb) {
|
|
70
|
-
React.useEffect(() => {
|
|
71
|
-
if (!open)
|
|
72
|
-
return;
|
|
73
|
-
const mouseUp = (e) => {
|
|
74
|
-
if (state.current.isMouseOutside) {
|
|
75
|
-
setOpen(false);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
document.addEventListener("mouseup", mouseUp);
|
|
79
|
-
return () => {
|
|
80
|
-
document.removeEventListener("mouseup", mouseUp);
|
|
81
|
-
};
|
|
82
|
-
}, [open]);
|
|
83
|
-
}
|
|
84
|
-
const updateFloatingSize = size({
|
|
85
|
-
apply({
|
|
86
|
-
availableHeight,
|
|
87
|
-
rects: {
|
|
88
|
-
reference: { width }
|
|
89
|
-
}
|
|
90
|
-
}) {
|
|
91
|
-
floatingStyle.current = {
|
|
92
|
-
width,
|
|
93
|
-
maxHeight: availableHeight
|
|
94
|
-
};
|
|
95
|
-
},
|
|
96
|
-
padding: WINDOW_PADDING
|
|
97
|
-
});
|
|
98
|
-
const { x, y, reference, floating, strategy, context, refs } = useFloating({
|
|
99
|
-
open,
|
|
100
|
-
onOpenChange: setOpen,
|
|
101
|
-
whileElementsMounted: autoUpdate,
|
|
102
|
-
placement: "bottom-start",
|
|
103
|
-
middleware: fallback ? [
|
|
104
|
-
offset(5),
|
|
105
|
-
...[
|
|
106
|
-
touch ? shift({ crossAxis: true, padding: WINDOW_PADDING }) : flip({ padding: WINDOW_PADDING })
|
|
107
|
-
],
|
|
108
|
-
updateFloatingSize
|
|
109
|
-
] : [
|
|
110
|
-
inner({
|
|
111
|
-
listRef: listItemsRef,
|
|
112
|
-
overflowRef,
|
|
113
|
-
index: selectedIndex,
|
|
114
|
-
offset: innerOffset,
|
|
115
|
-
onFallbackChange: setFallback,
|
|
116
|
-
padding: 10,
|
|
117
|
-
minItemsVisible: touch ? 10 : 4,
|
|
118
|
-
referenceOverflowThreshold: 20
|
|
119
|
-
}),
|
|
120
|
-
updateFloatingSize
|
|
121
|
-
]
|
|
122
|
-
});
|
|
123
|
-
const floatingRef = refs.floating;
|
|
124
|
-
const showUpArrow = open && scrollTop > SCROLL_ARROW_THRESHOLD;
|
|
125
|
-
const showDownArrow = open && floatingRef.current && scrollTop < floatingRef.current.scrollHeight - floatingRef.current.clientHeight - SCROLL_ARROW_THRESHOLD;
|
|
126
|
-
const interactions = useInteractions([
|
|
127
|
-
useClick(context, { event: "mousedown" }),
|
|
128
|
-
useDismiss(context, { outsidePress: false }),
|
|
129
|
-
useRole(context, { role: "listbox" }),
|
|
130
|
-
useInnerOffset(context, {
|
|
131
|
-
enabled: !fallback,
|
|
132
|
-
onChange: setInnerOffset,
|
|
133
|
-
overflowRef
|
|
134
|
-
}),
|
|
135
|
-
useListNavigation(context, {
|
|
136
|
-
listRef: listItemsRef,
|
|
137
|
-
activeIndex,
|
|
138
|
-
selectedIndex,
|
|
139
|
-
onNavigate: setActiveIndex
|
|
140
|
-
}),
|
|
141
|
-
useTypeahead(context, {
|
|
142
|
-
listRef: listContentRef,
|
|
143
|
-
onMatch: open ? setActiveIndex : setSelectedIndex,
|
|
144
|
-
selectedIndex,
|
|
145
|
-
activeIndex
|
|
146
|
-
})
|
|
147
|
-
]);
|
|
148
|
-
const interactionsContext = {
|
|
149
|
-
...interactions,
|
|
150
|
-
getReferenceProps() {
|
|
151
|
-
return interactions.getReferenceProps({
|
|
152
|
-
ref: reference,
|
|
153
|
-
className: "SelectTrigger",
|
|
154
|
-
onKeyDown(event) {
|
|
155
|
-
if (event.key === "Enter" || event.key === " " && !context.dataRef.current.typing) {
|
|
156
|
-
event.preventDefault();
|
|
157
|
-
setOpen(true);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
},
|
|
162
|
-
getFloatingProps(props2) {
|
|
163
|
-
return interactions.getFloatingProps({
|
|
164
|
-
ref: floating,
|
|
165
|
-
className: "Select",
|
|
166
|
-
...props2,
|
|
167
|
-
style: {
|
|
168
|
-
position: strategy,
|
|
169
|
-
top: y ?? "",
|
|
170
|
-
left: x ?? "",
|
|
171
|
-
outline: 0,
|
|
172
|
-
listStyleType: "none",
|
|
173
|
-
scrollbarWidth: "none",
|
|
174
|
-
...floatingStyle.current,
|
|
175
|
-
...props2?.style
|
|
176
|
-
},
|
|
177
|
-
onPointerEnter() {
|
|
178
|
-
setControlledScrolling(false);
|
|
179
|
-
state.current.isMouseOutside = false;
|
|
180
|
-
},
|
|
181
|
-
onPointerLeave() {
|
|
182
|
-
state.current.isMouseOutside = true;
|
|
183
|
-
},
|
|
184
|
-
onPointerMove() {
|
|
185
|
-
state.current.isMouseOutside = false;
|
|
186
|
-
setControlledScrolling(false);
|
|
187
|
-
},
|
|
188
|
-
onKeyDown() {
|
|
189
|
-
setControlledScrolling(true);
|
|
190
|
-
},
|
|
191
|
-
onContextMenu(e) {
|
|
192
|
-
e.preventDefault();
|
|
193
|
-
},
|
|
194
|
-
onScroll(event) {
|
|
195
|
-
flushSync(() => setScrollTop(event.currentTarget.scrollTop));
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
useIsomorphicLayoutEffect(() => {
|
|
201
|
-
if (open) {
|
|
202
|
-
selectTimeoutRef.current = setTimeout(() => {
|
|
203
|
-
allowSelectRef.current = true;
|
|
204
|
-
}, 300);
|
|
205
|
-
return () => {
|
|
206
|
-
clearTimeout(selectTimeoutRef.current);
|
|
207
|
-
};
|
|
208
|
-
} else {
|
|
209
|
-
allowSelectRef.current = false;
|
|
210
|
-
allowMouseUpRef.current = true;
|
|
211
|
-
setInnerOffset(0);
|
|
212
|
-
setFallback(false);
|
|
213
|
-
setBlockSelection(false);
|
|
214
|
-
}
|
|
215
|
-
}, [open]);
|
|
216
|
-
useIsomorphicLayoutEffect(() => {
|
|
217
|
-
function onPointerDown(e) {
|
|
218
|
-
const target = e.target;
|
|
219
|
-
if (!(refs.floating.current?.contains(target) || upArrowRef.current?.contains(target) || downArrowRef.current?.contains(target))) {
|
|
220
|
-
setOpen(false);
|
|
221
|
-
setControlledScrolling(false);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
if (open) {
|
|
225
|
-
document.addEventListener("pointerdown", onPointerDown);
|
|
226
|
-
return () => {
|
|
227
|
-
document.removeEventListener("pointerdown", onPointerDown);
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
}, [open, refs, setOpen]);
|
|
231
|
-
useIsomorphicLayoutEffect(() => {
|
|
232
|
-
if (open && controlledScrolling) {
|
|
233
|
-
if (activeIndex != null) {
|
|
234
|
-
listItemsRef.current[activeIndex]?.scrollIntoView({ block: "nearest" });
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
setScrollTop(refs.floating.current?.scrollTop ?? 0);
|
|
238
|
-
}, [open, refs, controlledScrolling, activeIndex]);
|
|
239
|
-
useIsomorphicLayoutEffect(() => {
|
|
240
|
-
if (open && fallback) {
|
|
241
|
-
if (selectedIndex != null) {
|
|
242
|
-
listItemsRef.current[selectedIndex]?.scrollIntoView({ block: "nearest" });
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}, [open, fallback, selectedIndex]);
|
|
246
|
-
useIsomorphicLayoutEffect(() => {
|
|
247
|
-
if (refs.floating.current && fallback) {
|
|
248
|
-
refs.floating.current.style.maxHeight = "";
|
|
249
|
-
}
|
|
250
|
-
}, [refs, fallback]);
|
|
251
|
-
return <SelectProvider scope={__scopeSelect} {...selectContext} setScrollTop={setScrollTop} setInnerOffset={setInnerOffset} floatingRef={floatingRef} setValueAtIndex={(index, value) => {
|
|
252
|
-
listContentRef.current[index] = value;
|
|
253
|
-
}} fallback={fallback} interactions={interactionsContext} floatingContext={context} activeIndex={activeIndex} canScrollDown={!!showDownArrow} canScrollUp={!!showUpArrow} controlledScrolling dataRef={context.dataRef} listRef={listItemsRef} blockSelection={blockSelection} allowMouseUpRef={allowMouseUpRef} upArrowRef={upArrowRef} downArrowRef={downArrowRef} selectTimeoutRef={selectTimeoutRef} allowSelectRef={allowSelectRef}>{children}</SelectProvider>;
|
|
254
|
-
};
|
|
255
|
-
const userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
|
|
256
|
-
export {
|
|
257
|
-
SelectInlineImpl
|
|
258
|
-
};
|
|
259
|
-
//# sourceMappingURL=SelectImpl.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
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 { isWeb, useIsTouchDevice, useIsomorphicLayoutEffect } 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) {\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, { event: 'mousedown' }),\n useDismiss(context, { outsidePress: false }),\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 = {\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 listStyleType: 'none',\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\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\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
|
-
"mappings": "AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAC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= (props) => {
|
|
2
|
-
if (process.env.NODE_ENV === "development") {
|
|
3
|
-
console.warn("Sheet not implemented inline on native");
|
|
4
|
-
}
|
|
5
|
-
return <>{props.children}</>;
|
|
6
|
-
};
|
|
7
|
-
export {
|
|
8
|
-
SelectInlineImpl
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=SelectImpl.native.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
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": "AAOO,MAAM,mBAAmB,CAAC,UAA2B;AAC1D,MAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,YAAQ,KAAK,wCAAwC;AAAA,EACvD;AACA,SAAO,GAAG,MAAM,SAAS;AAC3B;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { autoUpdate, offset, useFloating } from "@floating-ui/react-dom-interactions";
|
|
2
|
-
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
3
|
-
import { useIsomorphicLayoutEffect } from "@tamagui/core";
|
|
4
|
-
import { YStack } from "@tamagui/stacks";
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
import { flushSync } from "react-dom";
|
|
7
|
-
import { useSelectContext } from "./context";
|
|
8
|
-
const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
9
|
-
const SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
|
|
10
|
-
return <SelectScrollButtonImpl componentName={SCROLL_UP_BUTTON_NAME} {...props} dir="up" ref={forwardedRef} />;
|
|
11
|
-
});
|
|
12
|
-
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
13
|
-
const SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
14
|
-
const SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
|
|
15
|
-
return <SelectScrollButtonImpl componentName={SCROLL_DOWN_BUTTON_NAME} {...props} dir="down" ref={forwardedRef} />;
|
|
16
|
-
});
|
|
17
|
-
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
18
|
-
const SelectScrollButtonImpl = React.memo(
|
|
19
|
-
React.forwardRef(
|
|
20
|
-
(props, forwardedRef) => {
|
|
21
|
-
const { __scopeSelect, dir, componentName, ...scrollIndicatorProps } = props;
|
|
22
|
-
const {
|
|
23
|
-
floatingRef,
|
|
24
|
-
forceUpdate,
|
|
25
|
-
open,
|
|
26
|
-
fallback,
|
|
27
|
-
setScrollTop,
|
|
28
|
-
setInnerOffset,
|
|
29
|
-
...context
|
|
30
|
-
} = useSelectContext(componentName, __scopeSelect);
|
|
31
|
-
const [element, setElement] = React.useState(null);
|
|
32
|
-
const statusRef = React.useRef("idle");
|
|
33
|
-
const isVisible = context[dir === "down" ? "canScrollDown" : "canScrollUp"];
|
|
34
|
-
const frameRef = React.useRef();
|
|
35
|
-
const { x, y, reference, floating, strategy, update, refs } = useFloating({
|
|
36
|
-
strategy: "fixed",
|
|
37
|
-
placement: dir === "up" ? "top" : "bottom",
|
|
38
|
-
middleware: [offset(({ rects }) => -rects.floating.height)],
|
|
39
|
-
whileElementsMounted: (...args) => autoUpdate(...args, { animationFrame: true })
|
|
40
|
-
});
|
|
41
|
-
const composedRef = useComposedRefs(forwardedRef, floating);
|
|
42
|
-
if (floatingRef) {
|
|
43
|
-
if (open) {
|
|
44
|
-
if (element !== floatingRef.current) {
|
|
45
|
-
setElement(floatingRef.current);
|
|
46
|
-
reference(floatingRef.current);
|
|
47
|
-
requestAnimationFrame(update);
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
cancelAnimationFrame(frameRef.current);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
useIsomorphicLayoutEffect(() => {
|
|
54
|
-
return () => {
|
|
55
|
-
cancelAnimationFrame(frameRef.current);
|
|
56
|
-
};
|
|
57
|
-
}, []);
|
|
58
|
-
if (!(isVisible && floatingRef)) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
const onScroll = (amount) => {
|
|
62
|
-
if (fallback) {
|
|
63
|
-
if (refs.floating.current) {
|
|
64
|
-
refs.floating.current.scrollTop -= amount;
|
|
65
|
-
flushSync(() => setScrollTop(refs.floating.current?.scrollTop ?? 0));
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
flushSync(() => setInnerOffset((value) => value - amount));
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
return <YStack ref={composedRef} componentName={componentName} aria-hidden {...scrollIndicatorProps} zIndex={1e3} position={strategy} left={x || 0} top={y || 0} width={`calc(${(floatingRef?.current?.offsetWidth ?? 0) - 2}px)`} onPointerEnter={() => {
|
|
72
|
-
statusRef.current = "active";
|
|
73
|
-
let prevNow = Date.now();
|
|
74
|
-
function frame() {
|
|
75
|
-
if (element) {
|
|
76
|
-
const currentNow = Date.now();
|
|
77
|
-
const msElapsed = currentNow - prevNow;
|
|
78
|
-
prevNow = currentNow;
|
|
79
|
-
const pixelsToScroll = msElapsed / 2;
|
|
80
|
-
const remainingPixels = dir === "up" ? element.scrollTop : element.scrollHeight - element.clientHeight - element.scrollTop;
|
|
81
|
-
const scrollRemaining = dir === "up" ? element.scrollTop - pixelsToScroll > 0 : element.scrollTop + pixelsToScroll < element.scrollHeight - element.clientHeight;
|
|
82
|
-
onScroll(
|
|
83
|
-
dir === "up" ? Math.min(pixelsToScroll, remainingPixels) : Math.max(-pixelsToScroll, -remainingPixels)
|
|
84
|
-
);
|
|
85
|
-
if (scrollRemaining) {
|
|
86
|
-
frameRef.current = requestAnimationFrame(frame);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
cancelAnimationFrame(frameRef.current);
|
|
91
|
-
frameRef.current = requestAnimationFrame(frame);
|
|
92
|
-
}} onPointerLeave={() => {
|
|
93
|
-
statusRef.current = "idle";
|
|
94
|
-
cancelAnimationFrame(frameRef.current);
|
|
95
|
-
}} />;
|
|
96
|
-
}
|
|
97
|
-
)
|
|
98
|
-
);
|
|
99
|
-
export {
|
|
100
|
-
SelectScrollDownButton,
|
|
101
|
-
SelectScrollUpButton
|
|
102
|
-
};
|
|
103
|
-
//# sourceMappingURL=SelectScrollButton.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
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 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": "AAAA,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,CAAC,uBACC,eAAe,2BACX,OACJ,IAAI,KACJ,KAAK,cACP;AAEJ,CAAC;AAED,qBAAqB,cAAc;AAMnC,MAA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,6BAAqB,SAAS,OAAO;AAAA,MACvC,GACF;AAAA,IAEJ;AAAA,EACF;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { FloatingFocusManager } from "@floating-ui/react-dom-interactions";
|
|
2
|
-
import { isWeb } from "@tamagui/core";
|
|
3
|
-
import { styled } from "@tamagui/core";
|
|
4
|
-
import { PortalItem } from "@tamagui/portal";
|
|
5
|
-
import { ThemeableStack } from "@tamagui/stacks";
|
|
6
|
-
import * as React from "react";
|
|
7
|
-
import { VIEWPORT_NAME } from "./constants";
|
|
8
|
-
import { ForwardSelectContext, useSelectContext } from "./context";
|
|
9
|
-
import { useSelectBreakpointActive } from "./useSelectBreakpointActive";
|
|
10
|
-
const SelectViewportFrame = styled(ThemeableStack, {
|
|
11
|
-
name: VIEWPORT_NAME,
|
|
12
|
-
backgroundColor: "$background",
|
|
13
|
-
elevate: true,
|
|
14
|
-
bordered: true,
|
|
15
|
-
overflow: "scroll",
|
|
16
|
-
userSelect: "none",
|
|
17
|
-
outlineWidth: 0,
|
|
18
|
-
variants: {
|
|
19
|
-
size: {
|
|
20
|
-
"...size": (val, { tokens }) => {
|
|
21
|
-
return {
|
|
22
|
-
borderRadius: tokens.radius[val] ?? val
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
defaultVariants: {
|
|
28
|
-
size: "$2"
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const SelectViewport = React.forwardRef(
|
|
32
|
-
(props, forwardedRef) => {
|
|
33
|
-
const { __scopeSelect, children, ...viewportProps } = props;
|
|
34
|
-
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
35
|
-
const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint);
|
|
36
|
-
if (breakpointActive || !isWeb) {
|
|
37
|
-
return <PortalItem hostName={`${context.scopeKey}SheetContents`}><ForwardSelectContext context={context}>{children}</ForwardSelectContext></PortalItem>;
|
|
38
|
-
}
|
|
39
|
-
if (!context.floatingContext) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
if (!context.open) {
|
|
43
|
-
return children;
|
|
44
|
-
}
|
|
45
|
-
const {
|
|
46
|
-
style: { scrollbarWidth, listStyleType, ...restStyle },
|
|
47
|
-
...floatingProps
|
|
48
|
-
} = context.interactions.getFloatingProps();
|
|
49
|
-
return <>
|
|
50
|
-
<style dangerouslySetInnerHTML={{
|
|
51
|
-
__html: selectViewportCSS
|
|
52
|
-
}} />
|
|
53
|
-
<FloatingFocusManager context={context.floatingContext}><SelectViewportFrame size={context.size} role="presentation" {...viewportProps} ref={forwardedRef} {...floatingProps} {...restStyle}>{children}</SelectViewportFrame></FloatingFocusManager>
|
|
54
|
-
</>;
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
SelectViewport.displayName = VIEWPORT_NAME;
|
|
58
|
-
const selectViewportCSS = `
|
|
59
|
-
.is_SelectViewport {
|
|
60
|
-
scrollbar-width: none;
|
|
61
|
-
-webkit-overflow-scrolling: touch;
|
|
62
|
-
overscroll-behavior: contain;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.is_SelectViewport::-webkit-scrollbar{
|
|
66
|
-
display:none
|
|
67
|
-
}
|
|
68
|
-
`;
|
|
69
|
-
export {
|
|
70
|
-
SelectViewport,
|
|
71
|
-
SelectViewportFrame
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=SelectViewport.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
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, ...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, ...restStyle },\n ...floatingProps\n } = context.interactions!.getFloatingProps()\n\n return (\n <>\n <style\n dangerouslySetInnerHTML={{\n __html: selectViewportCSS,\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 >\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": "AAAA,SAAS,4BAA4B;AACrC,SAAyB,aAAa;AACtC,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,YAAY,WAAW;AAEvB,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB,wBAAwB;AAEvD,SAAS,iCAAiC;AAMnC,MAAM,sBAAsB,OAAO,gBAAgB;AAAA,EACxD,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,cAAc;AAAA,EAEd,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW,CAAC,KAAK,EAAE,OAAO,MAAM;AAC9B,eAAO;AAAA,UACL,cAAc,OAAO,OAAO,QAAQ;AAAA,QACtC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;AAEM,MAAM,iBAAiB,MAAM;AAAA,EAClC,CAAC,OAAyC,iBAAiB;AACzD,UAAM,EAAE,eAAe,aAAa,cAAc,IAAI;AACtD,UAAM,UAAU,iBAAiB,eAAe,aAAa;AAC7D,UAAM,mBAAmB,0BAA0B,QAAQ,eAAe;AAE1E,QAAI,oBAAoB,CAAC,OAAO;AAC9B,aACE,CAAC,WAAW,UAAU,GAAG,QAAQ,yBAC/B,CAAC,qBAAqB,SAAS,UAAU,SAAS,EAAjD,qBACH,EAFC;AAAA,IAIL;AAEA,QAAI,CAAC,QAAQ,iBAAiB;AAC5B,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,QAAQ,MAAM;AACjB,aAAO;AAAA,IACT;AAEA,UAAM;AAAA,MACJ,OAAO,EAAE,gBAAgB,kBAAkB,UAAU;AAAA,SAClD;AAAA,IACL,IAAI,QAAQ,aAAc,iBAAiB;AAE3C,WACE;AAAA,MACE,CAAC,MACC,yBAAyB;AAAA,QACvB,QAAQ;AAAA,MACV,GACF;AAAA,MACA,CAAC,qBAAqB,SAAS,QAAQ,iBACrC,CAAC,oBACC,MAAM,QAAQ,MAEd,KAAK,mBACD,eACJ,KAAK,kBACD,mBACA,YAEH,SACH,EAVC,oBAWH,EAZC;AAAA,IAaH;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;AAE7B,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AdaptParentContext } from "@tamagui/adapt";
|
|
2
|
-
import { Theme, useThemeName } from "@tamagui/core";
|
|
3
|
-
import { PortalItem } from "@tamagui/portal";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
import { VIEWPORT_NAME } from "./constants";
|
|
6
|
-
import { SelectProvider, useSelectContext } from "./context";
|
|
7
|
-
const SelectViewport = (props) => {
|
|
8
|
-
const { __scopeSelect, children } = props;
|
|
9
|
-
const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
|
|
10
|
-
const themeName = useThemeName();
|
|
11
|
-
const adaptContext = React.useContext(AdaptParentContext);
|
|
12
|
-
return <PortalItem hostName={`${context.scopeKey}SheetContents`}><Theme name={themeName}><SelectProvider scope={__scopeSelect} {...context}><AdaptParentContext.Provider value={adaptContext}>{children}</AdaptParentContext.Provider></SelectProvider></Theme></PortalItem>;
|
|
13
|
-
};
|
|
14
|
-
SelectViewport.displayName = VIEWPORT_NAME;
|
|
15
|
-
export {
|
|
16
|
-
SelectViewport
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=SelectViewport.native.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/SelectViewport.native.tsx"],
|
|
4
|
-
"sourcesContent": ["import { AdaptParentContext } from '@tamagui/adapt'\nimport { Stack, Theme, useThemeName } from '@tamagui/core'\nimport { PortalItem } from '@tamagui/portal'\nimport * as React from 'react'\n\nimport { VIEWPORT_NAME } from './constants'\nimport { SelectProvider, useSelectContext } from './context'\nimport { ScopedProps, SelectViewportProps } from './types'\n\nexport const SelectViewport = (props: ScopedProps<SelectViewportProps>) => {\n const { __scopeSelect, children } = props\n const context = useSelectContext(VIEWPORT_NAME, __scopeSelect)\n const themeName = useThemeName()\n const adaptContext = React.useContext(AdaptParentContext)\n\n // need to forward context...\n return (\n <PortalItem hostName={`${context.scopeKey}SheetContents`}>\n <Theme name={themeName}>\n <SelectProvider scope={__scopeSelect} {...context}>\n <AdaptParentContext.Provider value={adaptContext}>\n {children}\n </AdaptParentContext.Provider>\n </SelectProvider>\n </Theme>\n </PortalItem>\n )\n}\n\nSelectViewport.displayName = VIEWPORT_NAME\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,0BAA0B;AACnC,SAAgB,OAAO,oBAAoB;AAC3C,SAAS,kBAAkB;AAC3B,YAAY,WAAW;AAEvB,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB,wBAAwB;AAG1C,MAAM,iBAAiB,CAAC,UAA4C;AACzE,QAAM,EAAE,eAAe,SAAS,IAAI;AACpC,QAAM,UAAU,iBAAiB,eAAe,aAAa;AAC7D,QAAM,YAAY,aAAa;AAC/B,QAAM,eAAe,MAAM,WAAW,kBAAkB;AAGxD,SACE,CAAC,WAAW,UAAU,GAAG,QAAQ,yBAC/B,CAAC,MAAM,MAAM,WACX,CAAC,eAAe,OAAO,mBAAmB,SACxC,CAAC,mBAAmB,SAAS,OAAO,eACjC,SACH,EAFC,mBAAmB,SAGtB,EAJC,eAKH,EANC,MAOH,EARC;AAUL;AAEA,eAAe,cAAc;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/jsx/constants.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const SELECT_NAME = "Select";
|
|
2
|
-
const WINDOW_PADDING = 8;
|
|
3
|
-
const SCROLL_ARROW_VELOCITY = 8;
|
|
4
|
-
const SCROLL_ARROW_THRESHOLD = 8;
|
|
5
|
-
const MIN_HEIGHT = 80;
|
|
6
|
-
const FALLBACK_THRESHOLD = 16;
|
|
7
|
-
const VIEWPORT_NAME = "SelectViewport";
|
|
8
|
-
export {
|
|
9
|
-
FALLBACK_THRESHOLD,
|
|
10
|
-
MIN_HEIGHT,
|
|
11
|
-
SCROLL_ARROW_THRESHOLD,
|
|
12
|
-
SCROLL_ARROW_VELOCITY,
|
|
13
|
-
SELECT_NAME,
|
|
14
|
-
VIEWPORT_NAME,
|
|
15
|
-
WINDOW_PADDING
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/constants.tsx"],
|
|
4
|
-
"sourcesContent": ["export const SELECT_NAME = 'Select'\nexport const WINDOW_PADDING = 8\nexport const SCROLL_ARROW_VELOCITY = 8\nexport const SCROLL_ARROW_THRESHOLD = 8\nexport const MIN_HEIGHT = 80\nexport const FALLBACK_THRESHOLD = 16\nexport const VIEWPORT_NAME = 'SelectViewport'\n"],
|
|
5
|
-
"mappings": "AAAO,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,wBAAwB;AAC9B,MAAM,yBAAyB;AAC/B,MAAM,aAAa;AACnB,MAAM,qBAAqB;AAC3B,MAAM,gBAAgB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/jsx/context.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createContextScope } from "@tamagui/create-context";
|
|
2
|
-
import { SELECT_NAME } from "./constants";
|
|
3
|
-
const [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME);
|
|
4
|
-
const [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
|
|
5
|
-
const ForwardSelectContext = (props) => {
|
|
6
|
-
return <SelectProvider isInSheet scope={props.__scopeSelect} {...props.context}>{props.children}</SelectProvider>;
|
|
7
|
-
};
|
|
8
|
-
export {
|
|
9
|
-
ForwardSelectContext,
|
|
10
|
-
SelectProvider,
|
|
11
|
-
createSelectContext,
|
|
12
|
-
createSelectScope,
|
|
13
|
-
useSelectContext
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=context.js.map
|
package/dist/jsx/context.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/context.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createContextScope } from '@tamagui/create-context'\n\nimport { SELECT_NAME } from './constants'\nimport { ScopedProps, SelectContextValue } from './types'\n\nexport const [createSelectContext, createSelectScope] =\n createContextScope(SELECT_NAME)\n\nexport const [SelectProvider, useSelectContext] =\n createSelectContext<SelectContextValue>(SELECT_NAME)\n\nexport const ForwardSelectContext = (\n props: ScopedProps<{ children?: any; context: SelectContextValue }>,\n) => {\n return (\n <SelectProvider isInSheet scope={props.__scopeSelect} {...props.context}>\n {props.children}\n </SelectProvider>\n )\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB;AAGrB,MAAM,CAAC,qBAAqB,iBAAiB,IAClD,mBAAmB,WAAW;AAEzB,MAAM,CAAC,gBAAgB,gBAAgB,IAC5C,oBAAwC,WAAW;AAE9C,MAAM,uBAAuB,CAClC,UACG;AACH,SACE,CAAC,eAAe,UAAU,OAAO,MAAM,mBAAmB,MAAM,UAC7D,MAAM,SACT,EAFC;AAIL;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/jsx/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.js.map
|