@tamagui/select 1.0.1-beta.128 → 1.0.1-beta.131

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.
Files changed (46) hide show
  1. package/dist/cjs/Select.js +1 -1
  2. package/dist/cjs/Select.js.map +2 -2
  3. package/dist/cjs/SelectContent.js +4 -1
  4. package/dist/cjs/SelectContent.js.map +2 -2
  5. package/dist/cjs/SelectImpl.js +16 -23
  6. package/dist/cjs/SelectImpl.js.map +2 -2
  7. package/dist/cjs/SelectScrollButton.js +2 -1
  8. package/dist/cjs/SelectScrollButton.js.map +2 -2
  9. package/dist/cjs/SelectViewport.css +9 -0
  10. package/dist/cjs/SelectViewport.css.map +7 -0
  11. package/dist/cjs/SelectViewport.js +10 -5
  12. package/dist/cjs/SelectViewport.js.map +2 -2
  13. package/dist/esm/Select.js +1 -1
  14. package/dist/esm/Select.js.map +2 -2
  15. package/dist/esm/SelectContent.js +9 -2
  16. package/dist/esm/SelectContent.js.map +2 -2
  17. package/dist/esm/SelectImpl.js +17 -24
  18. package/dist/esm/SelectImpl.js.map +2 -2
  19. package/dist/esm/SelectScrollButton.js +2 -1
  20. package/dist/esm/SelectScrollButton.js.map +2 -2
  21. package/dist/esm/SelectViewport.css +9 -0
  22. package/dist/esm/SelectViewport.css.map +7 -0
  23. package/dist/esm/SelectViewport.js +10 -5
  24. package/dist/esm/SelectViewport.js.map +2 -2
  25. package/dist/jsx/Select.js +1 -1
  26. package/dist/jsx/Select.js.map +2 -2
  27. package/dist/jsx/SelectContent.js +6 -2
  28. package/dist/jsx/SelectContent.js.map +2 -2
  29. package/dist/jsx/SelectImpl.js +17 -25
  30. package/dist/jsx/SelectImpl.js.map +2 -2
  31. package/dist/jsx/SelectScrollButton.js +2 -1
  32. package/dist/jsx/SelectScrollButton.js.map +2 -2
  33. package/dist/jsx/SelectViewport.css +9 -0
  34. package/dist/jsx/SelectViewport.css.map +7 -0
  35. package/dist/jsx/SelectViewport.js +11 -5
  36. package/dist/jsx/SelectViewport.js.map +2 -2
  37. package/package.json +12 -12
  38. package/src/Select.tsx +1 -1
  39. package/src/SelectContent.tsx +10 -3
  40. package/src/SelectImpl.tsx +14 -21
  41. package/src/SelectScrollButton.tsx +2 -2
  42. package/src/SelectViewport.tsx +10 -6
  43. package/types/Select.d.ts +60 -60
  44. package/types/SelectContent.d.ts +0 -1
  45. package/types/SelectImpl.d.ts +0 -1
  46. package/types/SelectViewport.d.ts +9 -9
@@ -15,7 +15,7 @@ import {
15
15
  useRole,
16
16
  useTypeahead,
17
17
  } from '@floating-ui/react-dom-interactions'
18
- import { useIsTouchDevice } from '@tamagui/core'
18
+ import { useIsTouchDevice, useIsomorphicLayoutEffect } from '@tamagui/core'
19
19
  import * as React from 'react'
20
20
  import { flushSync } from 'react-dom'
21
21
 
@@ -200,6 +200,7 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
200
200
  state.current.isMouseOutside = true
201
201
  },
202
202
  onPointerMove() {
203
+ state.current.isMouseOutside = false
203
204
  setControlledScrolling(false)
204
205
  },
205
206
  onKeyDown() {
@@ -219,7 +220,7 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
219
220
 
220
221
  // effects
221
222
 
222
- React.useLayoutEffect(() => {
223
+ useIsomorphicLayoutEffect(() => {
223
224
  if (open) {
224
225
  selectTimeoutRef.current = setTimeout(() => {
225
226
  allowSelectRef.current = true
@@ -239,7 +240,7 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
239
240
 
240
241
  // Replacement for `useDismiss` as the arrows are outside of the floating
241
242
  // element DOM tree.
242
- React.useLayoutEffect(() => {
243
+ useIsomorphicLayoutEffect(() => {
243
244
  function onPointerDown(e: PointerEvent) {
244
245
  const target = e.target as Node
245
246
  if (
@@ -248,6 +249,7 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
248
249
  !downArrowRef.current?.contains(target)
249
250
  ) {
250
251
  setOpen(false)
252
+ setControlledScrolling(false)
251
253
  }
252
254
  }
253
255
 
@@ -261,32 +263,28 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
261
263
 
262
264
  // Scroll the `activeIndex` item into view only in "controlledScrolling"
263
265
  // (keyboard nav) mode.
264
- React.useLayoutEffect(() => {
266
+ useIsomorphicLayoutEffect(() => {
265
267
  if (open && controlledScrolling) {
266
- requestAnimationFrame(() => {
267
- if (activeIndex != null) {
268
- listItemsRef.current[activeIndex]?.scrollIntoView({ block: 'nearest' })
269
- }
270
- })
268
+ if (activeIndex != null) {
269
+ listItemsRef.current[activeIndex]?.scrollIntoView({ block: 'nearest' })
270
+ }
271
271
  }
272
272
 
273
273
  setScrollTop(refs.floating.current?.scrollTop ?? 0)
274
274
  }, [open, refs, controlledScrolling, activeIndex])
275
275
 
276
276
  // Scroll the `selectedIndex` into view upon opening the floating element.
277
- React.useLayoutEffect(() => {
277
+ useIsomorphicLayoutEffect(() => {
278
278
  if (open && fallback) {
279
- requestAnimationFrame(() => {
280
- if (selectedIndex != null) {
281
- listItemsRef.current[selectedIndex]?.scrollIntoView({ block: 'nearest' })
282
- }
283
- })
279
+ if (selectedIndex != null) {
280
+ listItemsRef.current[selectedIndex]?.scrollIntoView({ block: 'nearest' })
281
+ }
284
282
  }
285
283
  }, [open, fallback, selectedIndex])
286
284
 
287
285
  // Unset the height limiting for fallback mode. This gets executed prior to
288
286
  // the positioning call.
289
- React.useLayoutEffect(() => {
287
+ useIsomorphicLayoutEffect(() => {
290
288
  if (refs.floating.current && fallback) {
291
289
  refs.floating.current.style.maxHeight = ''
292
290
  }
@@ -342,8 +340,3 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
342
340
 
343
341
  // Cross browser fixes for pinch-zooming/backdrop-filter 🙄
344
342
  const userAgent = (typeof navigator !== 'undefined' && navigator.userAgent) || ''
345
- const isFirefox = userAgent.toLowerCase().includes('firefox')
346
-
347
- function getVisualOffsetTop() {
348
- return !/^((?!chrome|android).)*safari/i.test(userAgent) ? visualViewport?.offsetTop ?? 0 : 0
349
- }
@@ -1,6 +1,6 @@
1
1
  import { autoUpdate, offset, useFloating } from '@floating-ui/react-dom-interactions'
2
2
  import { useComposedRefs } from '@tamagui/compose-refs'
3
- import { TamaguiElement } from '@tamagui/core'
3
+ import { TamaguiElement, useIsomorphicLayoutEffect } from '@tamagui/core'
4
4
  import { YStack } from '@tamagui/stacks'
5
5
  import * as React from 'react'
6
6
  import { flushSync } from 'react-dom'
@@ -85,7 +85,7 @@ const SelectScrollButtonImpl = React.memo(
85
85
  }
86
86
  }
87
87
 
88
- React.useLayoutEffect(() => {
88
+ useIsomorphicLayoutEffect(() => {
89
89
  return () => {
90
90
  // eslint-disable-next-line react-hooks/exhaustive-deps
91
91
  cancelAnimationFrame(frameRef.current)
@@ -62,16 +62,14 @@ export const SelectViewport = React.forwardRef<TamaguiElement, SelectViewportPro
62
62
 
63
63
  return (
64
64
  <>
65
- {/* Hide scrollbars cross-browser and enable momentum scroll for touch devices */}
66
65
  <style
67
66
  dangerouslySetInnerHTML={{
68
- __html: disableScrollbarCSS,
67
+ __html: selectViewportCSS,
69
68
  }}
70
69
  />
71
70
  <FloatingFocusManager context={context.floatingContext} preventTabbing>
72
71
  <SelectViewportFrame
73
72
  size={context.size}
74
- data-tamagui-select-viewport=""
75
73
  // @ts-ignore
76
74
  role="presentation"
77
75
  {...viewportProps}
@@ -89,8 +87,14 @@ export const SelectViewport = React.forwardRef<TamaguiElement, SelectViewportPro
89
87
 
90
88
  SelectViewport.displayName = VIEWPORT_NAME
91
89
 
92
- const disableScrollbarCSS = `[data-tamagui-select-viewport]{
93
- scrollbar-width:none;-webkit-overflow-scrolling:touch;
90
+ const selectViewportCSS = `
91
+ .is_SelectViewport {
92
+ scrollbar-width: none;
93
+ -webkit-overflow-scrolling: touch;
94
94
  overscroll-behavior: contain;
95
95
  }
96
- [data-tamagui-select-viewport]::-webkit-scrollbar{display:none}`
96
+
97
+ .is_SelectViewport::-webkit-scrollbar{
98
+ display:none
99
+ }
100
+ `