@tamagui/sheet 1.127.0 → 1.127.2

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 (39) hide show
  1. package/dist/cjs/SheetImplementationCustom.cjs +1 -0
  2. package/dist/cjs/SheetImplementationCustom.js +2 -0
  3. package/dist/cjs/SheetImplementationCustom.js.map +1 -1
  4. package/dist/cjs/SheetImplementationCustom.native.js +2 -0
  5. package/dist/cjs/SheetImplementationCustom.native.js.map +2 -2
  6. package/dist/cjs/SheetScrollView.cjs +42 -6
  7. package/dist/cjs/SheetScrollView.js +34 -6
  8. package/dist/cjs/SheetScrollView.js.map +1 -1
  9. package/dist/cjs/SheetScrollView.native.js +34 -34
  10. package/dist/cjs/SheetScrollView.native.js.map +2 -2
  11. package/dist/esm/SheetImplementationCustom.js +2 -0
  12. package/dist/esm/SheetImplementationCustom.js.map +1 -1
  13. package/dist/esm/SheetImplementationCustom.mjs +1 -0
  14. package/dist/esm/SheetImplementationCustom.mjs.map +1 -1
  15. package/dist/esm/SheetImplementationCustom.native.js +1 -0
  16. package/dist/esm/SheetImplementationCustom.native.js.map +1 -1
  17. package/dist/esm/SheetScrollView.js +36 -6
  18. package/dist/esm/SheetScrollView.js.map +1 -1
  19. package/dist/esm/SheetScrollView.mjs +41 -5
  20. package/dist/esm/SheetScrollView.mjs.map +1 -1
  21. package/dist/esm/SheetScrollView.native.js +42 -34
  22. package/dist/esm/SheetScrollView.native.js.map +1 -1
  23. package/dist/jsx/SheetImplementationCustom.js +2 -0
  24. package/dist/jsx/SheetImplementationCustom.js.map +1 -1
  25. package/dist/jsx/SheetImplementationCustom.mjs +1 -0
  26. package/dist/jsx/SheetImplementationCustom.mjs.map +1 -1
  27. package/dist/jsx/SheetImplementationCustom.native.js +2 -0
  28. package/dist/jsx/SheetImplementationCustom.native.js.map +2 -2
  29. package/dist/jsx/SheetScrollView.js +36 -6
  30. package/dist/jsx/SheetScrollView.js.map +1 -1
  31. package/dist/jsx/SheetScrollView.mjs +41 -5
  32. package/dist/jsx/SheetScrollView.mjs.map +1 -1
  33. package/dist/jsx/SheetScrollView.native.js +36 -34
  34. package/dist/jsx/SheetScrollView.native.js.map +2 -2
  35. package/package.json +19 -19
  36. package/src/SheetImplementationCustom.tsx +5 -1
  37. package/src/SheetScrollView.tsx +62 -48
  38. package/types/SheetImplementationCustom.d.ts.map +1 -1
  39. package/types/SheetScrollView.d.ts.map +1 -1
@@ -1,11 +1,10 @@
1
- import React, { useEffect } from 'react'
2
1
  import { composeRefs } from '@tamagui/compose-refs'
3
- import type { GetRef } from '@tamagui/core'
2
+ import { isWeb, type GetRef } from '@tamagui/core'
4
3
  import type { ScrollViewProps } from '@tamagui/scroll-view'
5
4
  import { ScrollView } from '@tamagui/scroll-view'
6
-
5
+ import { useControllableState } from '@tamagui/use-controllable-state'
6
+ import React, { useEffect } from 'react'
7
7
  import type { ScrollView as RNScrollView } from 'react-native'
8
-
9
8
  import { useSheetContext } from './SheetContext'
10
9
  import type { SheetScopedProps } from './types'
11
10
 
@@ -26,14 +25,17 @@ export const SheetScrollView = React.forwardRef<
26
25
  __scopeSheet,
27
26
  children,
28
27
  onScroll,
29
- scrollEnabled,
28
+ scrollEnabled: scrollEnabledProp,
30
29
  ...props
31
30
  }: SheetScopedProps<ScrollViewProps>,
32
31
  ref
33
32
  ) => {
34
33
  const context = useSheetContext(SHEET_SCROLL_VIEW_NAME, __scopeSheet)
35
34
  const { scrollBridge, scrollEnabled: scrollEnabled_, setHasScrollView } = context
36
- // const [scrollEnabled, setScrollEnabled_] = useState(true)
35
+ const [scrollEnabled, setScrollEnabled_] = useControllableState({
36
+ prop: scrollEnabledProp,
37
+ defaultProp: true,
38
+ })
37
39
  const scrollRef = React.useRef<RNScrollView | null>(null)
38
40
 
39
41
  // could make it so it has negative bottom margin and then pads the bottom content
@@ -41,12 +43,12 @@ export const SheetScrollView = React.forwardRef<
41
43
  // or more ideally could use context to register if it has a scrollview and change behavior
42
44
  // const offscreenSize = useSheetOffscreenSize(context)
43
45
 
44
- // const setScrollEnabled = (next: boolean) => {
45
- // scrollRef.current?.setNativeProps?.({
46
- // scrollEnabled: next,
47
- // })
48
- // setScrollEnabled_(next)
49
- // }
46
+ const setScrollEnabled = (next: boolean) => {
47
+ scrollRef.current?.setNativeProps?.({
48
+ scrollEnabled: next,
49
+ })
50
+ setScrollEnabled_(next)
51
+ }
50
52
 
51
53
  const state = React.useRef({
52
54
  lastPageY: 0,
@@ -70,7 +72,7 @@ export const SheetScrollView = React.forwardRef<
70
72
  state.current.isDragging = false
71
73
  scrollBridge.scrollStartY = -1
72
74
  state.current.isScrolling = false
73
- // setScrollEnabled(true)
75
+ setScrollEnabled(true)
74
76
  let vy = 0
75
77
  if (state.current.dys.length) {
76
78
  const recentDys = state.current.dys.slice(-10)
@@ -102,6 +104,9 @@ export const SheetScrollView = React.forwardRef<
102
104
  onScroll={(e) => {
103
105
  const { y } = e.nativeEvent.contentOffset
104
106
  scrollBridge.y = y
107
+ if (isWeb) {
108
+ scrollBridge.scrollLock = y > 0
109
+ }
105
110
  if (y > 0) {
106
111
  scrollBridge.scrollStartY = -1
107
112
  }
@@ -123,41 +128,50 @@ export const SheetScrollView = React.forwardRef<
123
128
  return scrollable
124
129
  }}
125
130
  // setting to false while onResponderMove is disabled
126
- onMoveShouldSetResponder={() => scrollable}
127
- // somehow disabling works better, regression, no more nice drag continue scroll
128
- // onResponderMove={(e) => {
129
- // const { pageY } = e.nativeEvent
130
-
131
- // if (state.current.isScrolling) {
132
- // return
133
- // }
134
-
135
- // if (scrollBridge.scrollStartY === -1) {
136
- // scrollBridge.scrollStartY = pageY
137
- // state.current.lastPageY = pageY
138
- // }
139
-
140
- // const dragAt = pageY - scrollBridge.scrollStartY
141
- // const dy = pageY - state.current.lastPageY
142
- // state.current.lastPageY = pageY // after dy
143
- // const isDraggingUp = dy < 0
144
- // const isPaneAtTop = scrollBridge.paneY <= scrollBridge.paneMinY
145
-
146
- // if ((dy === 0 || isDraggingUp) && isPaneAtTop) {
147
- // state.current.isScrolling = true
148
- // setScrollEnabled(true)
149
- // return
150
- // }
151
-
152
- // setScrollEnabled(false)
153
- // scrollBridge.drag(dragAt)
154
- // state.current.dragAt = dragAt
155
- // state.current.dys.push(dy)
156
- // // only do every so often, cut down to 10 again
157
- // if (state.current.dys.length > 100) {
158
- // state.current.dys = state.current.dys.slice(-10)
159
- // }
160
- // }}
131
+ onMoveShouldSetResponder={(e) => {
132
+ return scrollable
133
+ }}
134
+ contentContainerStyle={{
135
+ minHeight: '100%',
136
+ }}
137
+ onResponderMove={(e) => {
138
+ // limiting to web as its tested on web
139
+ if (isWeb) {
140
+ const { pageY } = e.nativeEvent
141
+
142
+ if (state.current.isScrolling) {
143
+ e.stopPropagation()
144
+ return
145
+ }
146
+
147
+ if (scrollBridge.scrollStartY === -1) {
148
+ scrollBridge.scrollStartY = pageY
149
+ state.current.lastPageY = pageY
150
+ }
151
+
152
+ const dragAt = pageY - scrollBridge.scrollStartY
153
+ const dy = pageY - state.current.lastPageY
154
+ state.current.lastPageY = pageY // after dy
155
+ const isDraggingUp = dy < 0
156
+ const isPaneAtTop = scrollBridge.paneY <= scrollBridge.paneMinY
157
+
158
+ if ((dy === 0 || isDraggingUp) && isPaneAtTop) {
159
+ state.current.isScrolling = true
160
+ scrollBridge.scrollLock = true
161
+ setScrollEnabled(true)
162
+ return
163
+ }
164
+
165
+ setScrollEnabled(false)
166
+ scrollBridge.drag(dragAt)
167
+ state.current.dragAt = dragAt
168
+ state.current.dys.push(dy)
169
+ // only do every so often, cut down to 10 again
170
+ if (state.current.dys.length > 100) {
171
+ state.current.dys = state.current.dys.slice(-10)
172
+ }
173
+ }
174
+ }}
161
175
  {...props}
162
176
  >
163
177
  {children}
@@ -1 +1 @@
1
- {"version":3,"file":"SheetImplementationCustom.d.ts","sourceRoot":"","sources":["../src/SheetImplementationCustom.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAA2B,MAAM,OAAO,CAAA;AAO/C,OAAO,EAAsC,IAAI,EAAE,MAAM,cAAc,CAAA;AAIvE,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,SAAS,CAAA;AAWzD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;yBAOhC,MAAM,aACT;;;8BA4fF,CAAA"}
1
+ {"version":3,"file":"SheetImplementationCustom.d.ts","sourceRoot":"","sources":["../src/SheetImplementationCustom.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAA2B,MAAM,OAAO,CAAA;AAO/C,OAAO,EAAsC,IAAI,EAAE,MAAM,cAAc,CAAA;AAIvE,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,SAAS,CAAA;AAWzD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;yBAOhC,MAAM,aACT;;;8BAggBF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SheetScrollView.d.ts","sourceRoot":"","sources":["../src/SheetScrollView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAMxC,OAAO,KAAK,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,cAAc,CAAA;AAa9D,eAAO,MAAM,eAAe;oDARf,eAAc,uBAAuB,cAAc,0BAA0B,eAAc;;;;oDAA3F,eAAc,uBAAuB,cAAc,0BAA0B,eAAc;;oDAA3F,eAAc,uBAAuB,cAAc,0BAA0B,eAAc;;;;oDAA3F,eAAc,uBAAuB,cAAc,0BAA0B,eAAc;;oDAA3F,eAAc,uBAAuB,cAAc,0BAA0B,eAAc;;;wCA2JvG,CAAA"}
1
+ {"version":3,"file":"SheetScrollView.d.ts","sourceRoot":"","sources":["../src/SheetScrollView.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,KAAK,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,cAAc,CAAA;AAY9D,eAAO,MAAM,eAAe;oDAXO,eACnC,uBAAuB,cAAc,0BAEvB,eAAc;;;;oDAHO,eACnC,uBAAuB,cAAc,0BAEvB,eAAc;;oDAHO,eACnC,uBAAuB,cAAc,0BAEvB,eAAc;;;;oDAHO,eACnC,uBAAuB,cAAc,0BAEvB,eAAc;;oDAHO,eACnC,uBAAuB,cAAc,0BAEvB,eAAc;;;wCA0K3B,CAAA"}