@tamagui/select 1.0.1-beta.123 → 1.0.1-beta.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/SelectImpl.js +21 -0
- package/dist/cjs/SelectImpl.js.map +2 -2
- package/dist/cjs/SelectViewport.js +5 -1
- package/dist/cjs/SelectViewport.js.map +2 -2
- package/dist/esm/SelectImpl.js +22 -0
- package/dist/esm/SelectImpl.js.map +2 -2
- package/dist/esm/SelectViewport.js +5 -1
- package/dist/esm/SelectViewport.js.map +2 -2
- package/dist/jsx/SelectImpl.js +22 -0
- package/dist/jsx/SelectImpl.js.map +2 -2
- package/dist/jsx/SelectViewport.js +5 -1
- package/dist/jsx/SelectViewport.js.map +2 -2
- package/package.json +12 -12
- package/src/SelectImpl.tsx +25 -4
- package/src/SelectViewport.tsx +5 -1
- package/types/Select.d.ts +66 -66
- package/types/SelectContent.d.ts +0 -1
- package/types/SelectImpl.d.ts +0 -1
- package/types/SelectViewport.d.ts +6 -6
- package/types/Select.d.ts.map +0 -1
- package/types/SelectContent.d.ts.map +0 -1
- package/types/SelectContent.native.d.ts.map +0 -1
- package/types/SelectImpl.d.ts.map +0 -1
- package/types/SelectScrollButton.d.ts.map +0 -1
- package/types/SelectScrollButton.native.d.ts.map +0 -1
- package/types/SelectViewport.d.ts.map +0 -1
- package/types/SelectViewport.native.d.ts.map +0 -1
- package/types/context.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/types.d.ts.map +0 -1
package/src/SelectImpl.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SideObject,
|
|
3
|
-
|
|
3
|
+
autoUpdate,
|
|
4
4
|
flip,
|
|
5
5
|
inner,
|
|
6
6
|
offset,
|
|
@@ -15,12 +15,11 @@ import {
|
|
|
15
15
|
useRole,
|
|
16
16
|
useTypeahead,
|
|
17
17
|
} from '@floating-ui/react-dom-interactions'
|
|
18
|
-
import {
|
|
19
|
-
import { useForceUpdate, useIsTouchDevice } from '@tamagui/core'
|
|
18
|
+
import { useIsTouchDevice } from '@tamagui/core'
|
|
20
19
|
import * as React from 'react'
|
|
21
20
|
import { flushSync } from 'react-dom'
|
|
22
21
|
|
|
23
|
-
import {
|
|
22
|
+
import { SCROLL_ARROW_THRESHOLD, WINDOW_PADDING } from './constants'
|
|
24
23
|
import { SelectProvider, useSelectContext } from './context'
|
|
25
24
|
import { ScopedProps, SelectProps } from './types'
|
|
26
25
|
|
|
@@ -47,6 +46,9 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
|
|
|
47
46
|
const allowSelectRef = React.useRef(false)
|
|
48
47
|
const allowMouseUpRef = React.useRef(true)
|
|
49
48
|
const selectTimeoutRef = React.useRef<any>()
|
|
49
|
+
const state = React.useRef({
|
|
50
|
+
isMouseOutside: false,
|
|
51
|
+
})
|
|
50
52
|
|
|
51
53
|
const [controlledScrolling, setControlledScrolling] = React.useState(false)
|
|
52
54
|
const [fallback, setFallback] = React.useState(false)
|
|
@@ -70,6 +72,20 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
|
|
|
70
72
|
}
|
|
71
73
|
}, [open, setActiveIndex])
|
|
72
74
|
|
|
75
|
+
// close when mouseup outside select
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
if (!open) return
|
|
78
|
+
const mouseUp = (e: MouseEvent) => {
|
|
79
|
+
if (state.current.isMouseOutside) {
|
|
80
|
+
setOpen(false)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
document.addEventListener('mouseup', mouseUp)
|
|
84
|
+
return () => {
|
|
85
|
+
document.removeEventListener('mouseup', mouseUp)
|
|
86
|
+
}
|
|
87
|
+
}, [open])
|
|
88
|
+
|
|
73
89
|
const updateFloatingSize = size({
|
|
74
90
|
apply({
|
|
75
91
|
availableHeight,
|
|
@@ -88,6 +104,7 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
|
|
|
88
104
|
const { x, y, reference, floating, strategy, context, refs } = useFloating({
|
|
89
105
|
open,
|
|
90
106
|
onOpenChange: setOpen,
|
|
107
|
+
whileElementsMounted: autoUpdate,
|
|
91
108
|
placement: 'bottom-start',
|
|
92
109
|
middleware: fallback
|
|
93
110
|
? [
|
|
@@ -177,6 +194,10 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
|
|
|
177
194
|
},
|
|
178
195
|
onPointerEnter() {
|
|
179
196
|
setControlledScrolling(false)
|
|
197
|
+
state.current.isMouseOutside = false
|
|
198
|
+
},
|
|
199
|
+
onPointerLeave() {
|
|
200
|
+
state.current.isMouseOutside = true
|
|
180
201
|
},
|
|
181
202
|
onPointerMove() {
|
|
182
203
|
setControlledScrolling(false)
|
package/src/SelectViewport.tsx
CHANGED
|
@@ -89,4 +89,8 @@ export const SelectViewport = React.forwardRef<TamaguiElement, SelectViewportPro
|
|
|
89
89
|
|
|
90
90
|
SelectViewport.displayName = VIEWPORT_NAME
|
|
91
91
|
|
|
92
|
-
const disableScrollbarCSS = `[data-tamagui-select-viewport]{
|
|
92
|
+
const disableScrollbarCSS = `[data-tamagui-select-viewport]{
|
|
93
|
+
scrollbar-width:none;-webkit-overflow-scrolling:touch;
|
|
94
|
+
overscroll-behavior: contain;
|
|
95
|
+
}
|
|
96
|
+
[data-tamagui-select-viewport]::-webkit-scrollbar{display:none}`
|