@tamagui/sheet 1.130.2 → 1.130.4
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 +8 -11
- package/dist/cjs/SheetImplementationCustom.js +50 -59
- package/dist/cjs/SheetImplementationCustom.js.map +1 -1
- package/dist/cjs/SheetImplementationCustom.native.js +10 -11
- package/dist/cjs/SheetImplementationCustom.native.js.map +2 -2
- package/dist/cjs/SheetScrollView.cjs +45 -11
- package/dist/cjs/SheetScrollView.js +54 -12
- package/dist/cjs/SheetScrollView.js.map +1 -1
- package/dist/cjs/SheetScrollView.native.js +132 -86
- package/dist/cjs/SheetScrollView.native.js.map +2 -2
- package/dist/cjs/nativeSheet.cjs +0 -1
- package/dist/cjs/nativeSheet.js +14 -23
- package/dist/cjs/nativeSheet.js.map +1 -1
- package/dist/cjs/nativeSheet.native.js +0 -1
- package/dist/cjs/nativeSheet.native.js.map +2 -2
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/useSheetOpenState.cjs +2 -2
- package/dist/cjs/useSheetOpenState.js +2 -2
- package/dist/cjs/useSheetOpenState.js.map +1 -1
- package/dist/cjs/useSheetOpenState.native.js +2 -2
- package/dist/cjs/useSheetOpenState.native.js.map +2 -2
- package/dist/cjs/useSheetProviderProps.cjs +22 -11
- package/dist/cjs/useSheetProviderProps.js +23 -13
- package/dist/cjs/useSheetProviderProps.js.map +1 -1
- package/dist/cjs/useSheetProviderProps.native.js +15 -3
- package/dist/cjs/useSheetProviderProps.native.js.map +2 -2
- package/dist/esm/SheetImplementationCustom.js +51 -60
- package/dist/esm/SheetImplementationCustom.js.map +1 -1
- package/dist/esm/SheetImplementationCustom.mjs +9 -12
- package/dist/esm/SheetImplementationCustom.mjs.map +1 -1
- package/dist/esm/SheetImplementationCustom.native.js +11 -13
- package/dist/esm/SheetImplementationCustom.native.js.map +1 -1
- package/dist/esm/SheetScrollView.js +57 -15
- package/dist/esm/SheetScrollView.js.map +1 -1
- package/dist/esm/SheetScrollView.mjs +48 -14
- package/dist/esm/SheetScrollView.mjs.map +1 -1
- package/dist/esm/SheetScrollView.native.js +57 -16
- package/dist/esm/SheetScrollView.native.js.map +1 -1
- package/dist/esm/nativeSheet.js +14 -23
- package/dist/esm/nativeSheet.js.map +1 -1
- package/dist/esm/nativeSheet.mjs +0 -1
- package/dist/esm/nativeSheet.mjs.map +1 -1
- package/dist/esm/nativeSheet.native.js +0 -1
- package/dist/esm/nativeSheet.native.js.map +1 -1
- package/dist/esm/useSheetOpenState.js +2 -2
- package/dist/esm/useSheetOpenState.js.map +1 -1
- package/dist/esm/useSheetOpenState.mjs +2 -2
- package/dist/esm/useSheetOpenState.mjs.map +1 -1
- package/dist/esm/useSheetOpenState.native.js +3 -2
- package/dist/esm/useSheetOpenState.native.js.map +1 -1
- package/dist/esm/useSheetProviderProps.js +23 -13
- package/dist/esm/useSheetProviderProps.js.map +1 -1
- package/dist/esm/useSheetProviderProps.mjs +22 -11
- package/dist/esm/useSheetProviderProps.mjs.map +1 -1
- package/dist/esm/useSheetProviderProps.native.js +24 -11
- package/dist/esm/useSheetProviderProps.native.js.map +1 -1
- package/dist/jsx/SheetImplementationCustom.js +51 -60
- package/dist/jsx/SheetImplementationCustom.js.map +1 -1
- package/dist/jsx/SheetImplementationCustom.mjs +9 -12
- package/dist/jsx/SheetImplementationCustom.mjs.map +1 -1
- package/dist/jsx/SheetImplementationCustom.native.js +11 -12
- package/dist/jsx/SheetImplementationCustom.native.js.map +2 -2
- package/dist/jsx/SheetScrollView.js +57 -15
- package/dist/jsx/SheetScrollView.js.map +1 -1
- package/dist/jsx/SheetScrollView.mjs +48 -14
- package/dist/jsx/SheetScrollView.mjs.map +1 -1
- package/dist/jsx/SheetScrollView.native.js +135 -89
- package/dist/jsx/SheetScrollView.native.js.map +2 -2
- package/dist/jsx/nativeSheet.js +14 -23
- package/dist/jsx/nativeSheet.js.map +1 -1
- package/dist/jsx/nativeSheet.mjs +0 -1
- package/dist/jsx/nativeSheet.mjs.map +1 -1
- package/dist/jsx/nativeSheet.native.js +0 -1
- package/dist/jsx/nativeSheet.native.js.map +2 -2
- package/dist/jsx/useSheetOpenState.js +2 -2
- package/dist/jsx/useSheetOpenState.js.map +1 -1
- package/dist/jsx/useSheetOpenState.mjs +2 -2
- package/dist/jsx/useSheetOpenState.mjs.map +1 -1
- package/dist/jsx/useSheetOpenState.native.js +2 -2
- package/dist/jsx/useSheetOpenState.native.js.map +2 -2
- package/dist/jsx/useSheetProviderProps.js +23 -13
- package/dist/jsx/useSheetProviderProps.js.map +1 -1
- package/dist/jsx/useSheetProviderProps.mjs +22 -11
- package/dist/jsx/useSheetProviderProps.mjs.map +1 -1
- package/dist/jsx/useSheetProviderProps.native.js +15 -3
- package/dist/jsx/useSheetProviderProps.native.js.map +2 -2
- package/package.json +19 -19
- package/src/SheetImplementationCustom.tsx +22 -20
- package/src/SheetScrollView.tsx +87 -19
- package/src/nativeSheet.tsx +1 -6
- package/src/types.tsx +25 -0
- package/src/useSheetOpenState.tsx +5 -2
- package/src/useSheetProviderProps.tsx +30 -12
- package/types/Sheet.d.ts +11 -10
- package/types/Sheet.d.ts.map +1 -1
- package/types/SheetContext.d.ts +0 -1
- package/types/SheetContext.d.ts.map +1 -1
- package/types/SheetImplementationCustom.d.ts +1 -0
- package/types/SheetImplementationCustom.d.ts.map +1 -1
- package/types/SheetScrollView.d.ts.map +1 -1
- package/types/createSheet.d.ts +1 -0
- package/types/createSheet.d.ts.map +1 -1
- package/types/nativeSheet.d.ts.map +1 -1
- package/types/types.d.ts +20 -0
- package/types/types.d.ts.map +1 -1
- package/types/useSheetOpenState.d.ts.map +1 -1
- package/types/useSheetProviderProps.d.ts +0 -1
- package/types/useSheetProviderProps.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useConfiguration","useConstant","useControllableState","useSheetProviderProps","props","state","options","handleRef","useRef","contentRef","frameSize","setFrameSize","useState","maxContentSize","setMaxContentSize","snapPointsMode","snapPointsProp","snapPoints","hasFit","useMemo","dismissOnSnapToBottom","JSON","stringify","position_","setPositionImmediate","prop","position","defaultProp","defaultPosition","open","onChange","onPositionChange","strategy","setPosition","useCallback","next","length","setOpen","process","env","NODE_ENV","some","p","endsWith","n","Number","slice","console","warn","indexOf","shouldSetPositionOpen","useEffect","animationDriver","Error","scrollBridge","enabled","y","paneY","paneMinY","scrollStartY","drag","release","scrollLock","removeScrollEnabled","forceRemoveScrollEnabled","modal","maxSnapPoint","screenSize","hidden","isHidden","dismissOnOverlayPress","onOverlayComponent","scope","__scopeSheet","onlyShowFrame"],"sources":["../../src/useSheetProviderProps.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAElB,SAASC,gBAAA,QAAwB;AACjC,SAASC,WAAA,QAAmB;AAC5B,SAASC,oBAAA,QAA4B;
|
|
1
|
+
{"version":3,"names":["React","useConfiguration","useConstant","useControllableState","useSheetProviderProps","props","state","options","handleRef","useRef","contentRef","frameSize","setFrameSize","useState","maxContentSize","setMaxContentSize","snapPointsMode","snapPointsProp","snapPoints","hasFit","useMemo","dismissOnSnapToBottom","JSON","stringify","position_","setPositionImmediate","prop","position","defaultProp","defaultPosition","open","onChange","onPositionChange","strategy","setPosition","useCallback","next","length","setOpen","process","env","NODE_ENV","some","p","endsWith","n","Number","slice","console","warn","indexOf","shouldSetPositionOpen","useEffect","animationDriver","Error","scrollBridge","parentDragListeners","Set","bridge","enabled","y","paneY","paneMinY","scrollStartY","drag","release","scrollLock","isParentDragging","onParentDragging","cb","add","delete","setParentDragging","val","forEach","removeScrollEnabled","forceRemoveScrollEnabled","modal","maxSnapPoint","screenSize","hidden","isHidden","dismissOnOverlayPress","onOverlayComponent","scope","__scopeSheet","onlyShowFrame"],"sources":["../../src/useSheetProviderProps.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAElB,SAASC,gBAAA,QAAwB;AACjC,SA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GAAG,CAAC;UAE/C;QACF;MAEA,OAAOf,MAAA;IACT,CAAC;IAEKiB,mBAAA,GAAsBtE,KAAA,CAAMuE,wBAAA,KAA6B9C,IAAA,IAAQzB,KAAA,CAAMwE,KAAA;IAEvEC,YAAA,GAAe5D,UAAA,CAAW,CAAC;EAiCjC,OA3BsB;IACpB6D,UAAA,EALA/D,cAAA,KAAmB,YACfL,SAAA,KAAc,OAAOmE,YAAA,IAAiB,WAAWA,YAAA,GAAe,OAAO,OACvEhE,cAAA;IAIJgE,YAAA;IACAH,mBAAA;IACApB,YAAA;IACAsB,KAAA,EAAO,CAAC,CAACxE,KAAA,CAAMwE,KAAA;IACf/C,IAAA,EAAMxB,KAAA,CAAMwB,IAAA;IACZQ,OAAA,EAAShC,KAAA,CAAMgC,OAAA;IACf0C,MAAA,EAAQ,CAAC,CAAC1E,KAAA,CAAM2E,QAAA;IAChBvE,UAAA;IACAF,SAAA;IACAG,SAAA;IACAC,YAAA;IACAsE,qBAAA,EAAuB7E,KAAA,CAAM6E,qBAAA,IAAyB;IACtD7D,qBAAA,EAAuBhB,KAAA,CAAMgB,qBAAA,IAAyB;IACtD8D,kBAAA,EAAoB5E,OAAA,CAAQ4E,kBAAA;IAC5BC,KAAA,EAAO/E,KAAA,CAAMgF,YAAA;IACblE,MAAA;IACAQ,QAAA;IACAT,UAAA;IACAF,cAAA;IACAD,iBAAA;IACAmB,WAAA;IACAT,oBAAA;IACA6D,aAAA,EAAe;EACjB;AAGF","ignoreList":[]}
|
|
@@ -21,7 +21,7 @@ function useSheetProviderProps(props, state) {
|
|
|
21
21
|
prop: props.position,
|
|
22
22
|
defaultProp: props.defaultPosition || (state.open ? 0 : -1),
|
|
23
23
|
onChange: props.onPositionChange,
|
|
24
|
-
strategy: "
|
|
24
|
+
strategy: "most-recent-wins"
|
|
25
25
|
}), position = state.open === !1 ? -1 : position_, { open } = state, setPosition = React.useCallback(function(next) {
|
|
26
26
|
props.dismissOnSnapToBottom && next === snapPoints.length - 1 ? state.setOpen(!1) : setPositionImmediate(next);
|
|
27
27
|
}, [
|
|
@@ -57,7 +57,7 @@ function useSheetProviderProps(props, state) {
|
|
|
57
57
|
if (!animationDriver)
|
|
58
58
|
throw new Error(process.env.NODE_ENV === "production" ? "\u274C 008" : "Must set animations in tamagui.config.ts");
|
|
59
59
|
var scrollBridge = useConstant(function() {
|
|
60
|
-
|
|
60
|
+
var parentDragListeners = /* @__PURE__ */ new Set(), bridge = {
|
|
61
61
|
enabled: !1,
|
|
62
62
|
y: 0,
|
|
63
63
|
paneY: 0,
|
|
@@ -67,8 +67,20 @@ function useSheetProviderProps(props, state) {
|
|
|
67
67
|
},
|
|
68
68
|
release: function() {
|
|
69
69
|
},
|
|
70
|
-
scrollLock: !1
|
|
70
|
+
scrollLock: !1,
|
|
71
|
+
isParentDragging: !1,
|
|
72
|
+
onParentDragging: function(cb) {
|
|
73
|
+
return parentDragListeners.add(cb), function() {
|
|
74
|
+
parentDragListeners.delete(cb);
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
setParentDragging: function(val) {
|
|
78
|
+
val !== bridge.isParentDragging && (bridge.isParentDragging = val, parentDragListeners.forEach(function(cb) {
|
|
79
|
+
return cb(val);
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
71
82
|
};
|
|
83
|
+
return bridge;
|
|
72
84
|
}), _props_forceRemoveScrollEnabled, removeScrollEnabled = (_props_forceRemoveScrollEnabled = props.forceRemoveScrollEnabled) !== null && _props_forceRemoveScrollEnabled !== void 0 ? _props_forceRemoveScrollEnabled : open && props.modal, maxSnapPoint = snapPoints[0], screenSize = snapPointsMode === "percent" ? frameSize / ((typeof maxSnapPoint == "number" ? maxSnapPoint : 100) / 100) : maxContentSize, _props_dismissOnOverlayPress, _props_dismissOnSnapToBottom, providerProps = {
|
|
73
85
|
screenSize,
|
|
74
86
|
maxSnapPoint,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useSheetProviderProps.tsx"],
|
|
4
|
-
"mappings": "AAAA,OAAOA,WAAW;AAElB,SAASC,wBAAwB;AACjC,SAASC,mBAAmB;AAC5B,SAASC,4BAA4B;
|
|
5
|
-
"names": ["React", "useConfiguration", "useConstant", "useControllableState", "useSheetProviderProps", "props", "state", "options", "handleRef", "useRef", "contentRef", "frameSize", "setFrameSize", "useState", "maxContentSize", "setMaxContentSize", "snapPointsMode", "snapPointsProp", "snapPoints", "hasFit", "useMemo", "dismissOnSnapToBottom", "JSON", "stringify", "position_", "setPositionImmediate", "prop", "position", "defaultProp", "defaultPosition", "open", "onChange", "onPositionChange", "strategy", "setPosition", "useCallback", "next", "length", "setOpen", "process", "env", "NODE_ENV", "some", "p", "endsWith", "n", "Number", "slice", "console", "warn", "indexOf", "shouldSetPositionOpen", "useEffect", "animationDriver", "Error", "scrollBridge", "enabled", "y", "paneY", "paneMinY", "scrollStartY", "drag", "release", "scrollLock", "removeScrollEnabled", "forceRemoveScrollEnabled", "modal", "maxSnapPoint", "screenSize", "providerProps", "hidden", "isHidden", "dismissOnOverlayPress", "onOverlayComponent", "scope", "__scopeSheet", "onlyShowFrame"]
|
|
4
|
+
"mappings": "AAAA,OAAOA,WAAW;AAElB,SAASC,wBAAwB;AACjC,SAASC,mBAAmB;AAC5B,SAASC,4BAA4B;AAS9B,SAASC,sBACdC,OACAC,OAAqB;MACrBC,UAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAEI,CAAC,GAECC,YAAYR,MAAMS,OAAuB,IAAA,GACzCC,aAAaV,MAAMS,OAAuB,IAAA,GAC1C,CAACE,WAAWC,YAAAA,IAAgBZ,MAAMa,SAAiB,CAAA,GACnD,CAACC,gBAAgBC,iBAAAA,IAAqBf,MAAMa,SAAiB,CAAA,GAC5CR,uBAAjBW,kBAAiBX,wBAAAA,MAAMW,oBAAc,QAApBX,0BAAAA,SAAAA,wBAAwB,WAE7CA,mB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,iCAAtBsE,uBAAsBtE,kCAAAA,MAAMuE,8BAAwB,QAA9BvE,oCAAAA,SAAAA,kCAAmCyB,QAAQzB,MAAMwE,OAEvEC,eAAe5D,WAAW,CAAA,GAC1B6D,aACJ/D,mBAAmB,YACfL,cAAc,OAAOmE,gBAAiB,WAAWA,eAAe,OAAO,OACvEhE,gBAemBT,8BACAA,8BAdnB2E,gBAAgB;IACpBD;IACAD;IACAH;IACApB;IACAsB,OAAO,CAAC,CAACxE,MAAMwE;IACf/C,MAAMxB,MAAMwB;IACZQ,SAAShC,MAAMgC;IACf2C,QAAQ,CAAC,CAAC3E,MAAM4E;IAChBxE;IACAF;IACAG;IACAC;IACAuE,wBAAuB9E,+BAAAA,MAAM8E,2BAAqB,QAA3B9E,iCAAAA,SAAAA,+BAA+B;IACtDgB,wBAAuBhB,+BAAAA,MAAMgB,2BAAqB,QAA3BhB,iCAAAA,SAAAA,+BAA+B;IACtD+E,oBAAoB7E,QAAQ6E;IAC5BC,OAAOhF,MAAMiF;IACbnE;IACAQ;IACAT;IACAF;IACAD;IACAmB;IACAT;IACA8D,eAAe;EACjB;AAEA,SAAOP;AACT;",
|
|
5
|
+
"names": ["React", "useConfiguration", "useConstant", "useControllableState", "useSheetProviderProps", "props", "state", "options", "handleRef", "useRef", "contentRef", "frameSize", "setFrameSize", "useState", "maxContentSize", "setMaxContentSize", "snapPointsMode", "snapPointsProp", "snapPoints", "hasFit", "useMemo", "dismissOnSnapToBottom", "JSON", "stringify", "position_", "setPositionImmediate", "prop", "position", "defaultProp", "defaultPosition", "open", "onChange", "onPositionChange", "strategy", "setPosition", "useCallback", "next", "length", "setOpen", "process", "env", "NODE_ENV", "some", "p", "endsWith", "n", "Number", "slice", "console", "warn", "indexOf", "shouldSetPositionOpen", "useEffect", "animationDriver", "Error", "scrollBridge", "parentDragListeners", "Set", "bridge", "enabled", "y", "paneY", "paneMinY", "scrollStartY", "drag", "release", "scrollLock", "isParentDragging", "onParentDragging", "cb", "add", "delete", "setParentDragging", "val", "forEach", "removeScrollEnabled", "forceRemoveScrollEnabled", "modal", "maxSnapPoint", "screenSize", "providerProps", "hidden", "isHidden", "dismissOnOverlayPress", "onOverlayComponent", "scope", "__scopeSheet", "onlyShowFrame"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/sheet",
|
|
3
|
-
"version": "1.130.
|
|
3
|
+
"version": "1.130.4",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -37,29 +37,29 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@tamagui/adapt": "1.130.
|
|
41
|
-
"@tamagui/animate-presence": "1.130.
|
|
42
|
-
"@tamagui/animations-react-native": "1.130.
|
|
43
|
-
"@tamagui/compose-refs": "1.130.
|
|
44
|
-
"@tamagui/constants": "1.130.
|
|
45
|
-
"@tamagui/core": "1.130.
|
|
46
|
-
"@tamagui/create-context": "1.130.
|
|
47
|
-
"@tamagui/helpers": "1.130.
|
|
48
|
-
"@tamagui/portal": "1.130.
|
|
49
|
-
"@tamagui/remove-scroll": "1.130.
|
|
50
|
-
"@tamagui/scroll-view": "1.130.
|
|
51
|
-
"@tamagui/stacks": "1.130.
|
|
52
|
-
"@tamagui/use-constant": "1.130.
|
|
53
|
-
"@tamagui/use-controllable-state": "1.130.
|
|
54
|
-
"@tamagui/use-did-finish-ssr": "1.130.
|
|
55
|
-
"@tamagui/use-keyboard-visible": "1.130.
|
|
56
|
-
"@tamagui/z-index-stack": "1.130.
|
|
40
|
+
"@tamagui/adapt": "1.130.4",
|
|
41
|
+
"@tamagui/animate-presence": "1.130.4",
|
|
42
|
+
"@tamagui/animations-react-native": "1.130.4",
|
|
43
|
+
"@tamagui/compose-refs": "1.130.4",
|
|
44
|
+
"@tamagui/constants": "1.130.4",
|
|
45
|
+
"@tamagui/core": "1.130.4",
|
|
46
|
+
"@tamagui/create-context": "1.130.4",
|
|
47
|
+
"@tamagui/helpers": "1.130.4",
|
|
48
|
+
"@tamagui/portal": "1.130.4",
|
|
49
|
+
"@tamagui/remove-scroll": "1.130.4",
|
|
50
|
+
"@tamagui/scroll-view": "1.130.4",
|
|
51
|
+
"@tamagui/stacks": "1.130.4",
|
|
52
|
+
"@tamagui/use-constant": "1.130.4",
|
|
53
|
+
"@tamagui/use-controllable-state": "1.130.4",
|
|
54
|
+
"@tamagui/use-did-finish-ssr": "1.130.4",
|
|
55
|
+
"@tamagui/use-keyboard-visible": "1.130.4",
|
|
56
|
+
"@tamagui/z-index-stack": "1.130.4"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"react": "*"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@tamagui/build": "1.130.
|
|
62
|
+
"@tamagui/build": "1.130.4",
|
|
63
63
|
"react": "*"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|
|
@@ -239,11 +239,6 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
239
239
|
const disableDrag = props.disableDrag ?? controller?.disableDrag
|
|
240
240
|
const themeName = useThemeName()
|
|
241
241
|
const [isDragging, setIsDragging] = React.useState(false)
|
|
242
|
-
const scrollEnabled = useRef(true)
|
|
243
|
-
|
|
244
|
-
const setScrollEnabled = React.useCallback((val: boolean) => {
|
|
245
|
-
scrollEnabled.current = val
|
|
246
|
-
}, [])
|
|
247
242
|
|
|
248
243
|
const panResponder = React.useMemo(() => {
|
|
249
244
|
if (disableDrag) return
|
|
@@ -275,6 +270,7 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
275
270
|
}
|
|
276
271
|
|
|
277
272
|
const release = ({ vy, dragAt }: { dragAt: number; vy: number }) => {
|
|
273
|
+
scrollBridge.setParentDragging(false)
|
|
278
274
|
if (scrollBridge.scrollLock) {
|
|
279
275
|
return
|
|
280
276
|
}
|
|
@@ -301,8 +297,6 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
301
297
|
// have to call both because state may not change but need to snap back
|
|
302
298
|
setPosition(closestPoint)
|
|
303
299
|
animateTo(closestPoint)
|
|
304
|
-
|
|
305
|
-
setScrollEnabled(closestPoint === 0)
|
|
306
300
|
}
|
|
307
301
|
|
|
308
302
|
const finish = (_e: GestureResponderEvent, state: PanResponderGestureState) => {
|
|
@@ -346,19 +340,22 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
346
340
|
}
|
|
347
341
|
}
|
|
348
342
|
|
|
349
|
-
// if (scrollEnabled.current) {
|
|
350
|
-
// return false
|
|
351
|
-
// }
|
|
352
|
-
|
|
353
343
|
// we could do some detection of other touchables and cancel here..
|
|
354
|
-
return Math.abs(dy) >
|
|
344
|
+
return Math.abs(dy) > 5
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const granted = getShouldSet()
|
|
348
|
+
|
|
349
|
+
// console.log('DEBUG', granted, scrollBridge.scrollLock, scrollBridge.y)
|
|
350
|
+
|
|
351
|
+
if (granted) {
|
|
352
|
+
scrollBridge.setParentDragging(true)
|
|
355
353
|
}
|
|
356
354
|
|
|
357
|
-
return
|
|
355
|
+
return granted
|
|
358
356
|
}
|
|
359
357
|
|
|
360
358
|
const grant = () => {
|
|
361
|
-
setScrollEnabled(false)
|
|
362
359
|
setPanning(true)
|
|
363
360
|
stopSpring()
|
|
364
361
|
startY = at.current
|
|
@@ -383,6 +380,15 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
383
380
|
onPanResponderMove: (_e, { dy }) => {
|
|
384
381
|
const toFull = dy + startY
|
|
385
382
|
const to = resisted(toFull, minY)
|
|
383
|
+
|
|
384
|
+
// handles the case where you hand off back and forth more than once
|
|
385
|
+
const isAtTop = to <= minY
|
|
386
|
+
if (isAtTop) {
|
|
387
|
+
scrollBridge.setParentDragging(false)
|
|
388
|
+
} else {
|
|
389
|
+
scrollBridge.setParentDragging(true)
|
|
390
|
+
}
|
|
391
|
+
|
|
386
392
|
animatedNumber.setValue(to, { type: 'direct' })
|
|
387
393
|
},
|
|
388
394
|
onPanResponderEnd: finish,
|
|
@@ -488,11 +494,7 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
488
494
|
|
|
489
495
|
let contents = (
|
|
490
496
|
<ParentSheetContext.Provider value={nextParentContext}>
|
|
491
|
-
<SheetProvider
|
|
492
|
-
{...providerProps}
|
|
493
|
-
scrollEnabled={scrollEnabled.current}
|
|
494
|
-
setHasScrollView={setHasScrollView}
|
|
495
|
-
>
|
|
497
|
+
<SheetProvider {...providerProps} setHasScrollView={setHasScrollView}>
|
|
496
498
|
<AnimatePresence custom={{ open }}>
|
|
497
499
|
{shouldHideParentSheet || !open ? null : overlayComponent}
|
|
498
500
|
</AnimatePresence>
|
|
@@ -561,7 +563,7 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
|
|
|
561
563
|
<Portal stackZIndex={zIndex} {...portalProps}>
|
|
562
564
|
{shouldMountChildren && (
|
|
563
565
|
<ContainerComponent>
|
|
564
|
-
<Theme forceClassName name={themeName}>
|
|
566
|
+
<Theme contain forceClassName name={themeName}>
|
|
565
567
|
{contents}
|
|
566
568
|
</Theme>
|
|
567
569
|
</ContainerComponent>
|
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
|
(
|
|
@@ -31,7 +33,7 @@ export const SheetScrollView = React.forwardRef<
|
|
|
31
33
|
ref
|
|
32
34
|
) => {
|
|
33
35
|
const context = useSheetContext(SHEET_SCROLL_VIEW_NAME, __scopeSheet)
|
|
34
|
-
const { scrollBridge,
|
|
36
|
+
const { scrollBridge, setHasScrollView } = context
|
|
35
37
|
const [scrollEnabled, setScrollEnabled_] = useControllableState({
|
|
36
38
|
prop: scrollEnabledProp,
|
|
37
39
|
defaultProp: true,
|
|
@@ -55,7 +57,7 @@ export const SheetScrollView = React.forwardRef<
|
|
|
55
57
|
dragAt: 0,
|
|
56
58
|
dys: [] as number[], // store a few recent dys to get velocity on release
|
|
57
59
|
isScrolling: false,
|
|
58
|
-
|
|
60
|
+
isDraggingScrollArea: false,
|
|
59
61
|
})
|
|
60
62
|
|
|
61
63
|
useEffect(() => {
|
|
@@ -66,10 +68,10 @@ export const SheetScrollView = React.forwardRef<
|
|
|
66
68
|
}, [])
|
|
67
69
|
|
|
68
70
|
const release = () => {
|
|
69
|
-
if (!state.current.
|
|
71
|
+
if (!state.current.isDraggingScrollArea) {
|
|
70
72
|
return
|
|
71
73
|
}
|
|
72
|
-
state.current.
|
|
74
|
+
state.current.isDraggingScrollArea = false
|
|
73
75
|
scrollBridge.scrollStartY = -1
|
|
74
76
|
scrollBridge.scrollLock = false
|
|
75
77
|
state.current.isScrolling = false
|
|
@@ -88,11 +90,63 @@ export const SheetScrollView = React.forwardRef<
|
|
|
88
90
|
})
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
const scrollable = scrollEnabled
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!isClient) return
|
|
97
|
+
if (!scrollRef.current) return
|
|
98
|
+
|
|
99
|
+
const controller = new AbortController()
|
|
100
|
+
|
|
101
|
+
const node = scrollRef.current.getScrollableNode() as HTMLElement
|
|
102
|
+
|
|
103
|
+
// this is unfortuantely the only way to prevent a scroll once a scroll already started
|
|
104
|
+
// we just keep setting it back to the last value - it should only ever be 0 as this only
|
|
105
|
+
// ever runs when you scroll down, then back to top and start dragging, then back to scroll
|
|
106
|
+
node.addEventListener(
|
|
107
|
+
'touchmove',
|
|
108
|
+
(e) => {
|
|
109
|
+
if (scrollBridge.isParentDragging) {
|
|
110
|
+
node.scrollTo({
|
|
111
|
+
top: scrollBridge.y,
|
|
112
|
+
behavior: 'instant',
|
|
113
|
+
})
|
|
114
|
+
// can't preventdefault its not cancellable
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
signal: controller.signal,
|
|
119
|
+
passive: false,
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
const disposeBridgeListen = scrollBridge.onParentDragging((val) => {
|
|
124
|
+
if (val) {
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
return () => {
|
|
129
|
+
disposeBridgeListen()
|
|
130
|
+
controller.abort()
|
|
131
|
+
}
|
|
132
|
+
}, [])
|
|
133
|
+
|
|
134
|
+
const [hasScrollableContent, setHasScrollableContent] = useState(true)
|
|
135
|
+
const parentHeight = useRef(0)
|
|
136
|
+
const contentHeight = useRef(0)
|
|
137
|
+
|
|
138
|
+
const setIsScrollable = () => {
|
|
139
|
+
if (parentHeight.current && contentHeight.current) {
|
|
140
|
+
setHasScrollableContent(contentHeight.current > parentHeight.current)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
93
143
|
|
|
94
144
|
return (
|
|
95
145
|
<ScrollView
|
|
146
|
+
onLayout={(e) => {
|
|
147
|
+
parentHeight.current = e.nativeEvent.layout.height
|
|
148
|
+
setIsScrollable()
|
|
149
|
+
}}
|
|
96
150
|
ref={composeRefs(scrollRef as any, ref)}
|
|
97
151
|
flex={1}
|
|
98
152
|
scrollEventThrottle={8}
|
|
@@ -126,7 +180,7 @@ export const SheetScrollView = React.forwardRef<
|
|
|
126
180
|
}}
|
|
127
181
|
onStartShouldSetResponder={() => {
|
|
128
182
|
scrollBridge.scrollStartY = -1
|
|
129
|
-
state.current.
|
|
183
|
+
state.current.isDraggingScrollArea = true
|
|
130
184
|
return scrollable
|
|
131
185
|
}}
|
|
132
186
|
// setting to false while onResponderMove is disabled
|
|
@@ -141,14 +195,11 @@ export const SheetScrollView = React.forwardRef<
|
|
|
141
195
|
if (isWeb) {
|
|
142
196
|
const { pageY } = e.nativeEvent
|
|
143
197
|
|
|
144
|
-
if (state.current.isScrolling) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (scrollBridge.scrollStartY === -1) {
|
|
150
|
-
scrollBridge.scrollStartY = pageY
|
|
151
|
-
state.current.lastPageY = pageY
|
|
198
|
+
if (!state.current.isScrolling) {
|
|
199
|
+
if (scrollBridge.scrollStartY === -1) {
|
|
200
|
+
scrollBridge.scrollStartY = pageY
|
|
201
|
+
state.current.lastPageY = pageY
|
|
202
|
+
}
|
|
152
203
|
}
|
|
153
204
|
|
|
154
205
|
const dragAt = pageY - scrollBridge.scrollStartY
|
|
@@ -157,15 +208,20 @@ export const SheetScrollView = React.forwardRef<
|
|
|
157
208
|
const isDraggingUp = dy < 0
|
|
158
209
|
const isPaneAtTop = scrollBridge.paneY <= scrollBridge.paneMinY
|
|
159
210
|
|
|
160
|
-
const shouldScrollLock =
|
|
211
|
+
const shouldScrollLock =
|
|
212
|
+
hasScrollableContent && (dy === 0 || isDraggingUp) && isPaneAtTop
|
|
161
213
|
|
|
162
|
-
if (shouldScrollLock) {
|
|
214
|
+
if (shouldScrollLock && !state.current.isScrolling) {
|
|
163
215
|
state.current.isScrolling = true
|
|
164
216
|
scrollBridge.scrollLock = true
|
|
165
217
|
setScrollEnabled(true)
|
|
166
218
|
return
|
|
167
219
|
}
|
|
168
220
|
|
|
221
|
+
if (scrollBridge.y >= 0) {
|
|
222
|
+
return
|
|
223
|
+
}
|
|
224
|
+
|
|
169
225
|
setScrollEnabled(false)
|
|
170
226
|
scrollBridge.drag(dragAt)
|
|
171
227
|
state.current.dragAt = dragAt
|
|
@@ -178,6 +234,18 @@ export const SheetScrollView = React.forwardRef<
|
|
|
178
234
|
}}
|
|
179
235
|
{...props}
|
|
180
236
|
>
|
|
237
|
+
{/* content height measurer */}
|
|
238
|
+
<View
|
|
239
|
+
position="absolute"
|
|
240
|
+
inset={0}
|
|
241
|
+
pointerEvents="none"
|
|
242
|
+
zIndex={-1}
|
|
243
|
+
onLayout={(e) => {
|
|
244
|
+
contentHeight.current = e.nativeEvent.layout.height
|
|
245
|
+
setIsScrollable()
|
|
246
|
+
}}
|
|
247
|
+
/>
|
|
248
|
+
|
|
181
249
|
{children}
|
|
182
250
|
</ScrollView>
|
|
183
251
|
)
|
package/src/nativeSheet.tsx
CHANGED
|
@@ -59,12 +59,7 @@ export function setupNativeSheet(
|
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
61
|
<>
|
|
62
|
-
<SheetProvider
|
|
63
|
-
scrollEnabled
|
|
64
|
-
setHasScrollView={emptyFn}
|
|
65
|
-
{...providerProps}
|
|
66
|
-
onlyShowFrame
|
|
67
|
-
>
|
|
62
|
+
<SheetProvider setHasScrollView={emptyFn} {...providerProps} onlyShowFrame>
|
|
68
63
|
<ModalSheetView ref={ref} onModalDidDismiss={() => setOpenInternal(false)}>
|
|
69
64
|
<ModalSheetViewMainContent>
|
|
70
65
|
<View style={{ flex: 1 }}>{props.children}</View>
|
package/src/types.tsx
CHANGED
|
@@ -10,9 +10,23 @@ export type SheetProps = ScopedProps<
|
|
|
10
10
|
open?: boolean
|
|
11
11
|
defaultOpen?: boolean
|
|
12
12
|
onOpenChange?: OpenChangeHandler
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Control the index of the position in the `snapPoints` array
|
|
16
|
+
*/
|
|
13
17
|
position?: number
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Initial position from the `snapPoints` array
|
|
21
|
+
*/
|
|
14
22
|
defaultPosition?: number
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Array of pixels or percents the Sheet will attempt to move to when dragged.
|
|
26
|
+
* The first is the topmost and default when first opened via open prop.
|
|
27
|
+
*/
|
|
15
28
|
snapPoints?: (string | number)[]
|
|
29
|
+
|
|
16
30
|
snapPointsMode?: SnapPointsMode
|
|
17
31
|
onPositionChange?: PositionChangeHandler
|
|
18
32
|
children?: ReactNode
|
|
@@ -21,6 +35,14 @@ export type SheetProps = ScopedProps<
|
|
|
21
35
|
forceRemoveScrollEnabled?: boolean
|
|
22
36
|
animationConfig?: AnimatedNumberStrategy
|
|
23
37
|
|
|
38
|
+
/**
|
|
39
|
+
* By default Sheet will prefer the open prop over a parent component that is
|
|
40
|
+
* controlling it via Adapt. In general if you want to Adapt to a sheet, you'd
|
|
41
|
+
* leave the open prop undefined. If you'd like to have the parent override the
|
|
42
|
+
* prop you've set manually on Sheet, set this to true.
|
|
43
|
+
*/
|
|
44
|
+
preferAdaptParentOpenState?: boolean
|
|
45
|
+
|
|
24
46
|
/**
|
|
25
47
|
* (experimental) Remove the children while hidden (to save some performance, but can cause issues with animations)
|
|
26
48
|
*/
|
|
@@ -70,5 +92,8 @@ export type ScrollBridge = {
|
|
|
70
92
|
drag: (dy: number) => void
|
|
71
93
|
release: (state: { dragAt: number; vy: number }) => void
|
|
72
94
|
scrollLock: boolean
|
|
95
|
+
isParentDragging: boolean
|
|
96
|
+
onParentDragging: (props: (val: boolean) => void) => () => void
|
|
97
|
+
setParentDragging: (val: boolean) => void
|
|
73
98
|
onFinishAnimate?: () => void
|
|
74
99
|
}
|
|
@@ -11,12 +11,15 @@ export const useSheetOpenState = (props: SheetProps) => {
|
|
|
11
11
|
props.onOpenChange?.(val)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const propVal =
|
|
14
|
+
const propVal = props.preferAdaptParentOpenState
|
|
15
|
+
? (controller?.open ?? props.open)
|
|
16
|
+
: (props.open ?? controller?.open)
|
|
17
|
+
|
|
15
18
|
const [open, setOpen] = useControllableState({
|
|
16
19
|
prop: propVal,
|
|
17
20
|
defaultProp: props.defaultOpen ?? false,
|
|
18
21
|
onChange: onOpenChangeInternal,
|
|
19
|
-
strategy: '
|
|
22
|
+
strategy: 'most-recent-wins',
|
|
20
23
|
})
|
|
21
24
|
|
|
22
25
|
return {
|
|
@@ -8,7 +8,6 @@ import type { ScrollBridge, SheetProps } from './types'
|
|
|
8
8
|
import type { SheetOpenState } from './useSheetOpenState'
|
|
9
9
|
|
|
10
10
|
export type SheetContextValue = ReturnType<typeof useSheetProviderProps> & {
|
|
11
|
-
scrollEnabled: boolean
|
|
12
11
|
setHasScrollView: (val: boolean) => void
|
|
13
12
|
}
|
|
14
13
|
|
|
@@ -44,7 +43,7 @@ export function useSheetProviderProps(
|
|
|
44
43
|
prop: props.position,
|
|
45
44
|
defaultProp: props.defaultPosition || (state.open ? 0 : -1),
|
|
46
45
|
onChange: props.onPositionChange,
|
|
47
|
-
strategy: '
|
|
46
|
+
strategy: 'most-recent-wins',
|
|
48
47
|
})
|
|
49
48
|
|
|
50
49
|
const position = state.open === false ? -1 : position_
|
|
@@ -138,16 +137,35 @@ export function useSheetProviderProps(
|
|
|
138
137
|
)
|
|
139
138
|
}
|
|
140
139
|
|
|
141
|
-
const scrollBridge = useConstant<ScrollBridge>(() =>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
140
|
+
const scrollBridge = useConstant<ScrollBridge>(() => {
|
|
141
|
+
const parentDragListeners = new Set<Function>()
|
|
142
|
+
|
|
143
|
+
const bridge: ScrollBridge = {
|
|
144
|
+
enabled: false,
|
|
145
|
+
y: 0,
|
|
146
|
+
paneY: 0,
|
|
147
|
+
paneMinY: 0,
|
|
148
|
+
scrollStartY: -1,
|
|
149
|
+
drag: () => {},
|
|
150
|
+
release: () => {},
|
|
151
|
+
scrollLock: false,
|
|
152
|
+
isParentDragging: false,
|
|
153
|
+
onParentDragging: (cb) => {
|
|
154
|
+
parentDragListeners.add(cb)
|
|
155
|
+
return () => {
|
|
156
|
+
parentDragListeners.delete(cb)
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
setParentDragging: (val) => {
|
|
160
|
+
if (val !== bridge.isParentDragging) {
|
|
161
|
+
bridge.isParentDragging = val
|
|
162
|
+
parentDragListeners.forEach((cb) => cb(val))
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return bridge
|
|
168
|
+
})
|
|
151
169
|
|
|
152
170
|
const removeScrollEnabled = props.forceRemoveScrollEnabled ?? (open && props.modal)
|
|
153
171
|
|