@tamagui/sheet 1.130.3 → 1.130.5
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/SheetImplementationCustom.cjs +3 -2
- package/dist/cjs/SheetImplementationCustom.js +3 -3
- package/dist/cjs/SheetImplementationCustom.js.map +1 -1
- package/dist/cjs/SheetImplementationCustom.native.js +3 -2
- package/dist/cjs/SheetImplementationCustom.native.js.map +2 -2
- package/dist/cjs/SheetScrollView.cjs +25 -6
- package/dist/cjs/SheetScrollView.js +29 -6
- package/dist/cjs/SheetScrollView.js.map +1 -1
- package/dist/cjs/SheetScrollView.native.js +135 -107
- package/dist/cjs/SheetScrollView.native.js.map +2 -2
- package/dist/cjs/nativeSheet.js +14 -22
- package/dist/cjs/nativeSheet.js.map +1 -1
- package/dist/cjs/nativeSheet.native.js.map +1 -1
- package/dist/esm/SheetImplementationCustom.js +3 -3
- package/dist/esm/SheetImplementationCustom.js.map +1 -1
- package/dist/esm/SheetImplementationCustom.mjs +3 -2
- package/dist/esm/SheetImplementationCustom.mjs.map +1 -1
- package/dist/esm/SheetImplementationCustom.native.js +3 -2
- package/dist/esm/SheetImplementationCustom.native.js.map +1 -1
- package/dist/esm/SheetScrollView.js +32 -9
- package/dist/esm/SheetScrollView.js.map +1 -1
- package/dist/esm/SheetScrollView.mjs +28 -9
- package/dist/esm/SheetScrollView.mjs.map +1 -1
- package/dist/esm/SheetScrollView.native.js +49 -24
- package/dist/esm/SheetScrollView.native.js.map +1 -1
- package/dist/esm/nativeSheet.js +14 -22
- package/dist/esm/nativeSheet.js.map +1 -1
- package/dist/esm/nativeSheet.mjs.map +1 -1
- package/dist/esm/nativeSheet.native.js.map +1 -1
- package/dist/jsx/SheetImplementationCustom.js +3 -3
- package/dist/jsx/SheetImplementationCustom.js.map +1 -1
- package/dist/jsx/SheetImplementationCustom.mjs +3 -2
- package/dist/jsx/SheetImplementationCustom.mjs.map +1 -1
- package/dist/jsx/SheetImplementationCustom.native.js +3 -2
- package/dist/jsx/SheetImplementationCustom.native.js.map +2 -2
- package/dist/jsx/SheetScrollView.js +32 -9
- package/dist/jsx/SheetScrollView.js.map +1 -1
- package/dist/jsx/SheetScrollView.mjs +28 -9
- package/dist/jsx/SheetScrollView.mjs.map +1 -1
- package/dist/jsx/SheetScrollView.native.js +138 -110
- package/dist/jsx/SheetScrollView.native.js.map +2 -2
- package/dist/jsx/nativeSheet.js +14 -22
- package/dist/jsx/nativeSheet.js.map +1 -1
- package/dist/jsx/nativeSheet.mjs.map +1 -1
- package/dist/jsx/nativeSheet.native.js.map +1 -1
- package/package.json +19 -19
- package/src/SheetImplementationCustom.tsx +4 -2
- package/src/SheetScrollView.tsx +39 -6
- package/types/Sheet.d.ts +10 -10
- package/types/SheetImplementationCustom.d.ts.map +1 -1
- package/types/SheetScrollView.d.ts.map +1 -1
- package/types/nativeSheet.d.ts.map +1 -1
package/src/SheetScrollView.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { composeRefs } from '@tamagui/compose-refs'
|
|
2
|
-
import { isWeb, type GetRef } from '@tamagui/core'
|
|
2
|
+
import { isClient, isWeb, View, type GetRef } from '@tamagui/core'
|
|
3
3
|
import type { ScrollViewProps } from '@tamagui/scroll-view'
|
|
4
4
|
import { ScrollView } from '@tamagui/scroll-view'
|
|
5
5
|
import { useControllableState } from '@tamagui/use-controllable-state'
|
|
6
|
-
import React, { useEffect } from 'react'
|
|
6
|
+
import React, { useEffect, useRef, useState } from 'react'
|
|
7
7
|
import type { ScrollView as RNScrollView } from 'react-native'
|
|
8
8
|
import { useSheetContext } from './SheetContext'
|
|
9
9
|
import type { SheetScopedProps } from './types'
|
|
@@ -18,6 +18,8 @@ const SHEET_SCROLL_VIEW_NAME = 'SheetScrollView'
|
|
|
18
18
|
|
|
19
19
|
export const SheetScrollView = React.forwardRef<
|
|
20
20
|
GetRef<typeof ScrollView>,
|
|
21
|
+
// we disallow customizing it because we want to let people know it doens't work well with out measuring of inner content
|
|
22
|
+
// height using a view
|
|
21
23
|
ScrollViewProps
|
|
22
24
|
>(
|
|
23
25
|
(
|
|
@@ -91,12 +93,16 @@ export const SheetScrollView = React.forwardRef<
|
|
|
91
93
|
const scrollable = scrollEnabled
|
|
92
94
|
|
|
93
95
|
useEffect(() => {
|
|
94
|
-
if (
|
|
96
|
+
if (!isClient) return
|
|
95
97
|
if (!scrollRef.current) return
|
|
96
98
|
|
|
97
99
|
const controller = new AbortController()
|
|
98
100
|
|
|
99
|
-
const node = scrollRef.current
|
|
101
|
+
const node = scrollRef.current?.getScrollableNode() as HTMLElement | undefined
|
|
102
|
+
|
|
103
|
+
if (!node) {
|
|
104
|
+
return
|
|
105
|
+
}
|
|
100
106
|
|
|
101
107
|
// this is unfortuantely the only way to prevent a scroll once a scroll already started
|
|
102
108
|
// we just keep setting it back to the last value - it should only ever be 0 as this only
|
|
@@ -127,10 +133,24 @@ export const SheetScrollView = React.forwardRef<
|
|
|
127
133
|
disposeBridgeListen()
|
|
128
134
|
controller.abort()
|
|
129
135
|
}
|
|
130
|
-
}, [])
|
|
136
|
+
}, [scrollRef])
|
|
137
|
+
|
|
138
|
+
const [hasScrollableContent, setHasScrollableContent] = useState(true)
|
|
139
|
+
const parentHeight = useRef(0)
|
|
140
|
+
const contentHeight = useRef(0)
|
|
141
|
+
|
|
142
|
+
const setIsScrollable = () => {
|
|
143
|
+
if (parentHeight.current && contentHeight.current) {
|
|
144
|
+
setHasScrollableContent(contentHeight.current > parentHeight.current)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
131
147
|
|
|
132
148
|
return (
|
|
133
149
|
<ScrollView
|
|
150
|
+
onLayout={(e) => {
|
|
151
|
+
parentHeight.current = e.nativeEvent.layout.height
|
|
152
|
+
setIsScrollable()
|
|
153
|
+
}}
|
|
134
154
|
ref={composeRefs(scrollRef as any, ref)}
|
|
135
155
|
flex={1}
|
|
136
156
|
scrollEventThrottle={8}
|
|
@@ -192,7 +212,8 @@ export const SheetScrollView = React.forwardRef<
|
|
|
192
212
|
const isDraggingUp = dy < 0
|
|
193
213
|
const isPaneAtTop = scrollBridge.paneY <= scrollBridge.paneMinY
|
|
194
214
|
|
|
195
|
-
const shouldScrollLock =
|
|
215
|
+
const shouldScrollLock =
|
|
216
|
+
hasScrollableContent && (dy === 0 || isDraggingUp) && isPaneAtTop
|
|
196
217
|
|
|
197
218
|
if (shouldScrollLock && !state.current.isScrolling) {
|
|
198
219
|
state.current.isScrolling = true
|
|
@@ -217,6 +238,18 @@ export const SheetScrollView = React.forwardRef<
|
|
|
217
238
|
}}
|
|
218
239
|
{...props}
|
|
219
240
|
>
|
|
241
|
+
{/* content height measurer */}
|
|
242
|
+
<View
|
|
243
|
+
position="absolute"
|
|
244
|
+
inset={0}
|
|
245
|
+
pointerEvents="none"
|
|
246
|
+
zIndex={-1}
|
|
247
|
+
onLayout={(e) => {
|
|
248
|
+
contentHeight.current = e.nativeEvent.layout.height
|
|
249
|
+
setIsScrollable()
|
|
250
|
+
}}
|
|
251
|
+
/>
|
|
252
|
+
|
|
220
253
|
{children}
|
|
221
254
|
</ScrollView>
|
|
222
255
|
)
|
package/types/Sheet.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { createSheetScope } from './SheetContext';
|
|
2
2
|
export * from './types';
|
|
3
3
|
export declare const Handle: import("@tamagui/core").TamaguiComponent<import("@tamagui/core").TamaDefer, import("@tamagui/core").TamaguiElement, import("@tamagui/core").RNTamaguiViewNonStyleProps, import("@tamagui/core").StackStyleBase, {
|
|
4
|
+
open?: boolean | undefined;
|
|
4
5
|
elevation?: number | import("@tamagui/core").SizeTokens | undefined;
|
|
5
6
|
inset?: number | import("@tamagui/core").SizeTokens | {
|
|
6
7
|
top?: number;
|
|
@@ -9,10 +10,10 @@ export declare const Handle: import("@tamagui/core").TamaguiComponent<import("@t
|
|
|
9
10
|
right?: number;
|
|
10
11
|
} | null | undefined;
|
|
11
12
|
fullscreen?: boolean | undefined;
|
|
12
|
-
open?: boolean | undefined;
|
|
13
13
|
unstyled?: boolean | undefined;
|
|
14
14
|
}, import("@tamagui/core").StaticConfigPublic>;
|
|
15
15
|
export declare const Overlay: import("@tamagui/core").TamaguiComponent<import("@tamagui/core").TamaDefer, import("@tamagui/core").TamaguiElement, import("@tamagui/core").RNTamaguiViewNonStyleProps, import("@tamagui/core").StackStyleBase, {
|
|
16
|
+
open?: boolean | undefined;
|
|
16
17
|
elevation?: number | import("@tamagui/core").SizeTokens | undefined;
|
|
17
18
|
inset?: number | import("@tamagui/core").SizeTokens | {
|
|
18
19
|
top?: number;
|
|
@@ -21,9 +22,8 @@ export declare const Overlay: import("@tamagui/core").TamaguiComponent<import("@
|
|
|
21
22
|
right?: number;
|
|
22
23
|
} | null | undefined;
|
|
23
24
|
fullscreen?: boolean | undefined;
|
|
24
|
-
open?: boolean | undefined;
|
|
25
|
-
transparent?: boolean | undefined;
|
|
26
25
|
circular?: boolean | undefined;
|
|
26
|
+
transparent?: boolean | undefined;
|
|
27
27
|
unstyled?: boolean | undefined;
|
|
28
28
|
hoverTheme?: boolean | undefined;
|
|
29
29
|
pressTheme?: boolean | undefined;
|
|
@@ -93,6 +93,7 @@ export declare const Sheet: import("react").ForwardRefExoticComponent<{
|
|
|
93
93
|
adjustPaddingForOffscreenContent?: boolean;
|
|
94
94
|
}>>;
|
|
95
95
|
Overlay: import("react").MemoExoticComponent<(propsIn: import("./types").SheetScopedProps<import("@tamagui/core").GetFinalProps<import("@tamagui/core").RNTamaguiViewNonStyleProps, import("@tamagui/core").StackStyleBase, {
|
|
96
|
+
open?: boolean | undefined;
|
|
96
97
|
elevation?: number | import("@tamagui/core").SizeTokens | undefined;
|
|
97
98
|
inset?: number | import("@tamagui/core").SizeTokens | {
|
|
98
99
|
top?: number;
|
|
@@ -101,9 +102,8 @@ export declare const Sheet: import("react").ForwardRefExoticComponent<{
|
|
|
101
102
|
right?: number;
|
|
102
103
|
} | null | undefined;
|
|
103
104
|
fullscreen?: boolean | undefined;
|
|
104
|
-
open?: boolean | undefined;
|
|
105
|
-
transparent?: boolean | undefined;
|
|
106
105
|
circular?: boolean | undefined;
|
|
106
|
+
transparent?: boolean | undefined;
|
|
107
107
|
unstyled?: boolean | undefined;
|
|
108
108
|
hoverTheme?: boolean | undefined;
|
|
109
109
|
pressTheme?: boolean | undefined;
|
|
@@ -154,6 +154,7 @@ export declare const Sheet: import("react").ForwardRefExoticComponent<{
|
|
|
154
154
|
adjustPaddingForOffscreenContent?: boolean;
|
|
155
155
|
}>>;
|
|
156
156
|
Overlay: import("react").MemoExoticComponent<(propsIn: import("./types").SheetScopedProps<import("@tamagui/core").GetFinalProps<import("@tamagui/core").RNTamaguiViewNonStyleProps, import("@tamagui/core").StackStyleBase, {
|
|
157
|
+
open?: boolean | undefined;
|
|
157
158
|
elevation?: number | import("@tamagui/core").SizeTokens | undefined;
|
|
158
159
|
inset?: number | import("@tamagui/core").SizeTokens | {
|
|
159
160
|
top?: number;
|
|
@@ -162,9 +163,8 @@ export declare const Sheet: import("react").ForwardRefExoticComponent<{
|
|
|
162
163
|
right?: number;
|
|
163
164
|
} | null | undefined;
|
|
164
165
|
fullscreen?: boolean | undefined;
|
|
165
|
-
open?: boolean | undefined;
|
|
166
|
-
transparent?: boolean | undefined;
|
|
167
166
|
circular?: boolean | undefined;
|
|
167
|
+
transparent?: boolean | undefined;
|
|
168
168
|
unstyled?: boolean | undefined;
|
|
169
169
|
hoverTheme?: boolean | undefined;
|
|
170
170
|
pressTheme?: boolean | undefined;
|
|
@@ -199,6 +199,7 @@ export declare const Sheet: import("react").ForwardRefExoticComponent<{
|
|
|
199
199
|
};
|
|
200
200
|
/** @deprecated use Overlay instead */
|
|
201
201
|
export declare const SheetOverlayFrame: import("@tamagui/core").TamaguiComponent<import("@tamagui/core").TamaDefer, import("@tamagui/core").TamaguiElement, import("@tamagui/core").RNTamaguiViewNonStyleProps, import("@tamagui/core").StackStyleBase, {
|
|
202
|
+
open?: boolean | undefined;
|
|
202
203
|
elevation?: number | import("@tamagui/core").SizeTokens | undefined;
|
|
203
204
|
inset?: number | import("@tamagui/core").SizeTokens | {
|
|
204
205
|
top?: number;
|
|
@@ -207,9 +208,8 @@ export declare const SheetOverlayFrame: import("@tamagui/core").TamaguiComponent
|
|
|
207
208
|
right?: number;
|
|
208
209
|
} | null | undefined;
|
|
209
210
|
fullscreen?: boolean | undefined;
|
|
210
|
-
open?: boolean | undefined;
|
|
211
|
-
transparent?: boolean | undefined;
|
|
212
211
|
circular?: boolean | undefined;
|
|
212
|
+
transparent?: boolean | undefined;
|
|
213
213
|
unstyled?: boolean | undefined;
|
|
214
214
|
hoverTheme?: boolean | undefined;
|
|
215
215
|
pressTheme?: boolean | undefined;
|
|
@@ -223,6 +223,7 @@ export declare const SheetOverlayFrame: import("@tamagui/core").TamaguiComponent
|
|
|
223
223
|
}, import("@tamagui/core").StaticConfigPublic>;
|
|
224
224
|
/** @deprecated use Overlay instead */
|
|
225
225
|
export declare const SheetHandleFrame: import("@tamagui/core").TamaguiComponent<import("@tamagui/core").TamaDefer, import("@tamagui/core").TamaguiElement, import("@tamagui/core").RNTamaguiViewNonStyleProps, import("@tamagui/core").StackStyleBase, {
|
|
226
|
+
open?: boolean | undefined;
|
|
226
227
|
elevation?: number | import("@tamagui/core").SizeTokens | undefined;
|
|
227
228
|
inset?: number | import("@tamagui/core").SizeTokens | {
|
|
228
229
|
top?: number;
|
|
@@ -231,7 +232,6 @@ export declare const SheetHandleFrame: import("@tamagui/core").TamaguiComponent<
|
|
|
231
232
|
right?: number;
|
|
232
233
|
} | null | undefined;
|
|
233
234
|
fullscreen?: boolean | undefined;
|
|
234
|
-
open?: boolean | undefined;
|
|
235
235
|
unstyled?: boolean | undefined;
|
|
236
236
|
}, import("@tamagui/core").StaticConfigPublic>;
|
|
237
237
|
//# sourceMappingURL=Sheet.d.ts.map
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAmiBrC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetScrollView.d.ts","sourceRoot":"","sources":["../src/SheetScrollView.tsx"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"SheetScrollView.d.ts","sourceRoot":"","sources":["../src/SheetScrollView.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,cAAc,CAAA;AAY9D,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;wCA8O3B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeSheet.d.ts","sourceRoot":"","sources":["../src/nativeSheet.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAI9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAMzC,KAAK,oBAAoB,GAAG,KAAK,CAAA;AAMjC,wBAAgB,cAAc,CAAC,QAAQ,EAAE,oBAAoB,wCAE5D;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,oBAAoB,EAC9B,UAAU,EAAE;IAAE,cAAc,EAAE,GAAG,CAAC;IAAC,yBAAyB,EAAE,GAAG,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"nativeSheet.d.ts","sourceRoot":"","sources":["../src/nativeSheet.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAI9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAMzC,KAAK,oBAAoB,GAAG,KAAK,CAAA;AAMjC,wBAAgB,cAAc,CAAC,QAAQ,EAAE,oBAAoB,wCAE5D;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,oBAAoB,EAC9B,UAAU,EAAE;IAAE,cAAc,EAAE,GAAG,CAAC;IAAC,yBAAyB,EAAE,GAAG,CAAA;CAAE,QA6DpE"}
|