react-native-bottom-sheet-stack 1.0.0 → 1.0.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.
- package/lib/commonjs/BottomSheetHost.js +40 -42
- package/lib/commonjs/BottomSheetHost.js.map +1 -1
- package/lib/commonjs/BottomSheetManager.provider.js +1 -15
- package/lib/commonjs/BottomSheetManager.provider.js.map +1 -1
- package/lib/commonjs/ScaleBackgroundWrapper.js +4 -2
- package/lib/commonjs/ScaleBackgroundWrapper.js.map +1 -1
- package/lib/commonjs/bottomSheet.store.js +86 -73
- package/lib/commonjs/bottomSheet.store.js.map +1 -1
- package/lib/commonjs/bottomSheetCoordinator.js +7 -8
- package/lib/commonjs/bottomSheetCoordinator.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/useBottomSheetState.js +2 -9
- package/lib/commonjs/useBottomSheetState.js.map +1 -1
- package/lib/typescript/example/src/App.d.ts.map +1 -1
- package/lib/typescript/src/BottomSheetHost.d.ts +1 -4
- package/lib/typescript/src/BottomSheetHost.d.ts.map +1 -1
- package/lib/typescript/src/BottomSheetManager.provider.d.ts +0 -14
- package/lib/typescript/src/BottomSheetManager.provider.d.ts.map +1 -1
- package/lib/typescript/src/ScaleBackgroundWrapper.d.ts.map +1 -1
- package/lib/typescript/src/bottomSheet.store.d.ts +2 -1
- package/lib/typescript/src/bottomSheet.store.d.ts.map +1 -1
- package/lib/typescript/src/bottomSheetCoordinator.d.ts +1 -1
- package/lib/typescript/src/bottomSheetCoordinator.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/useBottomSheetState.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/BottomSheetHost.tsx +49 -49
- package/src/BottomSheetManager.provider.tsx +1 -24
- package/src/ScaleBackgroundWrapper.tsx +9 -10
- package/src/bottomSheet.store.ts +83 -48
- package/src/bottomSheetCoordinator.ts +10 -9
- package/src/index.tsx +5 -5
- package/src/useBottomSheetState.ts +5 -13
|
@@ -7,67 +7,65 @@ exports.BottomSheetHost = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
10
|
+
var _shallow = require("zustand/shallow");
|
|
10
11
|
var _BottomSheet = require("./BottomSheet.context");
|
|
11
12
|
var _bottomSheet = require("./bottomSheet.store");
|
|
12
|
-
var _bottomSheetCoordinator = require("./bottomSheetCoordinator");
|
|
13
13
|
var _BottomSheetManager = require("./BottomSheetManager.provider");
|
|
14
|
+
var _bottomSheetCoordinator = require("./bottomSheetCoordinator");
|
|
14
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}) {
|
|
21
|
-
const {
|
|
22
|
-
bottomSheetsStack,
|
|
23
|
-
clearAll
|
|
24
|
-
} = (0, _bottomSheet.useBottomSheetStore)(store => ({
|
|
25
|
-
bottomSheetsStack: store.stack,
|
|
26
|
-
clearAll: store.clearAll
|
|
27
|
-
}));
|
|
28
|
-
const {
|
|
29
|
-
width,
|
|
30
|
-
height
|
|
31
|
-
} = (0, _reactNativeSafeAreaContext.useSafeAreaFrame)();
|
|
18
|
+
function BottomSheetHostComp() {
|
|
19
|
+
const queueIds = useQueueIds();
|
|
20
|
+
const clearAll = (0, _bottomSheet.useBottomSheetStore)(store => store.clearAll);
|
|
32
21
|
const {
|
|
33
22
|
groupId
|
|
34
23
|
} = (0, _BottomSheetManager.useBottomSheetManagerContext)();
|
|
35
|
-
|
|
24
|
+
(0, _react.useEffect)(() => {
|
|
25
|
+
const unsubscribe = (0, _bottomSheetCoordinator.initBottomSheetCoordinator)(groupId);
|
|
26
|
+
return () => {
|
|
27
|
+
unsubscribe();
|
|
28
|
+
};
|
|
29
|
+
}, [groupId]);
|
|
36
30
|
(0, _react.useEffect)(() => {
|
|
37
31
|
return () => {
|
|
38
32
|
clearAll();
|
|
39
33
|
};
|
|
40
34
|
}, [clearAll]);
|
|
41
35
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
42
|
-
children:
|
|
43
|
-
id
|
|
44
|
-
content
|
|
45
|
-
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_BottomSheet.BottomSheetContext.Provider, {
|
|
46
|
-
value: {
|
|
47
|
-
id
|
|
48
|
-
},
|
|
49
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Container, {
|
|
50
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
51
|
-
style: [_reactNative.StyleSheet.absoluteFillObject, styles.container, {
|
|
52
|
-
width,
|
|
53
|
-
height
|
|
54
|
-
}],
|
|
55
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(MemoizedContent, {
|
|
56
|
-
id: id,
|
|
57
|
-
children: content
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
})
|
|
36
|
+
children: queueIds.map(id => /*#__PURE__*/(0, _jsxRuntime.jsx)(QueueItem, {
|
|
37
|
+
id: id
|
|
61
38
|
}, id))
|
|
62
39
|
});
|
|
63
40
|
}
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
}) =>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
41
|
+
const QueueItem = /*#__PURE__*/_react.default.memo(({
|
|
42
|
+
id
|
|
43
|
+
}) => {
|
|
44
|
+
const content = (0, _bottomSheet.useBottomSheetStore)(state => state.sheetsById[id]?.content);
|
|
45
|
+
const {
|
|
46
|
+
width,
|
|
47
|
+
height
|
|
48
|
+
} = (0, _reactNativeSafeAreaContext.useSafeAreaFrame)();
|
|
49
|
+
const value = (0, _react.useMemo)(() => ({
|
|
50
|
+
id
|
|
51
|
+
}), [id]);
|
|
52
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_BottomSheet.BottomSheetContext.Provider, {
|
|
53
|
+
value: value,
|
|
54
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
55
|
+
style: [_reactNative.StyleSheet.absoluteFillObject, styles.container, {
|
|
56
|
+
width,
|
|
57
|
+
height
|
|
58
|
+
}],
|
|
59
|
+
children: content
|
|
60
|
+
})
|
|
61
|
+
});
|
|
70
62
|
});
|
|
63
|
+
const useQueueIds = () => {
|
|
64
|
+
const {
|
|
65
|
+
groupId
|
|
66
|
+
} = (0, _BottomSheetManager.useBottomSheetManagerContext)();
|
|
67
|
+
return (0, _bottomSheet.useBottomSheetStore)(state => state.stackOrder.filter(sheetId => state.sheetsById[sheetId]?.groupId === groupId), _shallow.shallow);
|
|
68
|
+
};
|
|
71
69
|
const BottomSheetHost = exports.BottomSheetHost = /*#__PURE__*/_react.default.memo(BottomSheetHostComp);
|
|
72
70
|
const styles = _reactNative.StyleSheet.create({
|
|
73
71
|
container: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeSafeAreaContext","_BottomSheet","_bottomSheet","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeSafeAreaContext","_shallow","_BottomSheet","_bottomSheet","_BottomSheetManager","_bottomSheetCoordinator","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","BottomSheetHostComp","queueIds","useQueueIds","clearAll","useBottomSheetStore","store","groupId","useBottomSheetManagerContext","useEffect","unsubscribe","initBottomSheetCoordinator","jsx","Fragment","children","map","id","QueueItem","React","memo","content","state","sheetsById","width","height","useSafeAreaFrame","value","useMemo","BottomSheetContext","Provider","View","style","StyleSheet","absoluteFillObject","styles","container","stackOrder","filter","sheetId","shallow","BottomSheetHost","exports","create","zIndex","pointerEvents"],"sourceRoot":"../../src","sources":["BottomSheetHost.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,2BAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AACA,IAAAO,uBAAA,GAAAP,OAAA;AAAsE,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAS,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAA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EACHgC,gBACF,CAAC;AACH,CAAC;AAEM,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,gBAAGtB,cAAK,CAACC,IAAI,CAAClB,mBAAmB,CAAC;AAE9D,MAAMiC,MAAM,GAAGF,uBAAU,CAACU,MAAM,CAAC;EAC/BP,SAAS,EAAE;IACTQ,MAAM,EAAE,WAAW;IACnBC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -5,14 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useMaybeBottomSheetManagerContext = exports.useBottomSheetManagerContext = exports.BottomSheetManagerProvider = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
8
|
var _BottomSheetManager = require("./BottomSheetManager.context");
|
|
10
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
/**
|
|
13
|
-
* Provider for bottom sheet manager context.
|
|
14
|
-
* Use ScaleBackgroundWrapper inside to enable iOS-style scale effect on content.
|
|
15
|
-
*/
|
|
16
11
|
function BottomSheetManagerProviderComp({
|
|
17
12
|
id,
|
|
18
13
|
children
|
|
@@ -21,10 +16,7 @@ function BottomSheetManagerProviderComp({
|
|
|
21
16
|
value: {
|
|
22
17
|
groupId: id
|
|
23
18
|
},
|
|
24
|
-
children:
|
|
25
|
-
style: styles.container,
|
|
26
|
-
children: children
|
|
27
|
-
})
|
|
19
|
+
children: children
|
|
28
20
|
}, id);
|
|
29
21
|
}
|
|
30
22
|
const BottomSheetManagerProvider = exports.BottomSheetManagerProvider = /*#__PURE__*/_react.default.memo(BottomSheetManagerProviderComp);
|
|
@@ -44,10 +36,4 @@ const useMaybeBottomSheetManagerContext = () => {
|
|
|
44
36
|
return context;
|
|
45
37
|
};
|
|
46
38
|
exports.useMaybeBottomSheetManagerContext = useMaybeBottomSheetManagerContext;
|
|
47
|
-
const styles = _reactNative.StyleSheet.create({
|
|
48
|
-
container: {
|
|
49
|
-
flex: 1,
|
|
50
|
-
backgroundColor: '#000'
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
39
|
//# sourceMappingURL=BottomSheetManager.provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_BottomSheetManager","_jsxRuntime","e","__esModule","default","BottomSheetManagerProviderComp","id","children","jsx","BottomSheetManagerContext","Provider","value","groupId","BottomSheetManagerProvider","exports","React","memo","useBottomSheetManagerContext","context","useContext","Error","useMaybeBottomSheetManagerContext"],"sourceRoot":"../../src","sources":["BottomSheetManager.provider.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAD,OAAA;AAGsC,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAMtC,SAASG,8BAA8BA,CAAC;EAAEC,EAAE;EAAEC;AAAwB,CAAC,EAAE;EACvE,oBACE,IAAAN,WAAA,CAAAO,GAAA,EAACR,mBAAA,CAAAS,yBAAyB,CAACC,QAAQ;IAAUC,KAAK,EAAE;MAAEC,OAAO,EAAEN;IAAG,CAAE;IAAAC,QAAA,EACjEA;EAAQ,GAD8BD,EAEL,CAAC;AAEzC;AAEO,MAAMO,0BAA0B,GAAAC,OAAA,CAAAD,0BAAA,gBAAGE,cAAK,CAACC,IAAI,CAClDX,8BACF,CAAC;AAEM,MAAMY,4BAA4B,GACvCA,CAAA,KAAsC;EACpC,MAAMC,OAAO,GAAGH,cAAK,CAACI,UAAU,CAACV,6CAAyB,CAAC;EAE3D,IAAI,CAACS,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CACb,+EACF,CAAC;EACH;EACA,OAAOF,OAAO;AAChB,CAAC;AAACJ,OAAA,CAAAG,4BAAA,GAAAA,4BAAA;AAEG,MAAMI,iCAAiC,GAC5CA,CAAA,KAA6C;EAC3C,MAAMH,OAAO,GAAGH,cAAK,CAACI,UAAU,CAACV,6CAAyB,CAAC;EAE3D,IAAI,CAACS,OAAO,EAAE;IACZ,OAAO,IAAI;EACb;EACA,OAAOA,OAAO;AAChB,CAAC;AAACJ,OAAA,CAAAO,iCAAA,GAAAA,iCAAA","ignoreList":[]}
|
|
@@ -7,7 +7,6 @@ exports.ScaleBackgroundWrapper = ScaleBackgroundWrapper;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
10
|
-
var _shallow = require("zustand/shallow");
|
|
11
10
|
var _BottomSheetManager = require("./BottomSheetManager.context");
|
|
12
11
|
var _bottomSheet = require("./bottomSheet.store");
|
|
13
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -40,7 +39,10 @@ function ScaleBackgroundWrapper({
|
|
|
40
39
|
borderRadius = 12,
|
|
41
40
|
duration = 300
|
|
42
41
|
} = config ?? {};
|
|
43
|
-
const hasActiveScaleSheet = (0, _bottomSheet.useBottomSheetStore)(
|
|
42
|
+
const hasActiveScaleSheet = (0, _bottomSheet.useBottomSheetStore)(state => state.stackOrder.some(id => {
|
|
43
|
+
const sheet = state.sheetsById[id];
|
|
44
|
+
return sheet?.groupId === groupId && sheet?.scaleBackground && sheet?.status !== 'closing';
|
|
45
|
+
}));
|
|
44
46
|
const animationProgress = (0, _reactNativeReanimated.useDerivedValue)(() => (0, _reactNativeReanimated.withTiming)(hasActiveScaleSheet ? 1 : 0, {
|
|
45
47
|
duration
|
|
46
48
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_reactNativeReanimated","_interopRequireWildcard","
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_reactNativeReanimated","_interopRequireWildcard","_BottomSheetManager","_bottomSheet","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ScaleBackgroundWrapper","children","config","context","useContext","BottomSheetManagerContext","groupId","scale","translateY","borderRadius","duration","hasActiveScaleSheet","useBottomSheetStore","state","stackOrder","some","id","sheet","sheetsById","scaleBackground","status","animationProgress","useDerivedValue","withTiming","animatedStyle","useAnimatedStyle","progress","value","transform","interpolate","overflow","jsx","View","style","styles","scaleWrapper","StyleSheet","create","flex"],"sourceRoot":"../../src","sources":["ScaleBackgroundWrapper.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAC,uBAAA,CAAAH,OAAA;AAMA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAA0D,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KA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
|
8
8
|
var _traditional = require("zustand/traditional");
|
|
9
9
|
const useBottomSheetStore = exports.useBottomSheetStore = (0, _traditional.createWithEqualityFn)((0, _middleware.subscribeWithSelector)(set => ({
|
|
10
|
-
|
|
10
|
+
sheetsById: {},
|
|
11
|
+
stackOrder: [],
|
|
11
12
|
push: sheet => set(state => {
|
|
12
|
-
if (state.
|
|
13
|
-
return
|
|
14
|
-
stack: state.stack
|
|
15
|
-
};
|
|
13
|
+
if (state.sheetsById[sheet.id]) {
|
|
14
|
+
return state;
|
|
16
15
|
}
|
|
17
16
|
return {
|
|
18
|
-
|
|
19
|
-
...
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
sheetsById: {
|
|
18
|
+
...state.sheetsById,
|
|
19
|
+
[sheet.id]: {
|
|
20
|
+
...sheet,
|
|
21
|
+
status: 'opening'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
stackOrder: [...state.stackOrder, sheet.id]
|
|
22
25
|
};
|
|
23
26
|
}),
|
|
24
27
|
switch: sheet => set(state => {
|
|
25
|
-
if (state.
|
|
26
|
-
return
|
|
27
|
-
stack: state.stack
|
|
28
|
-
};
|
|
28
|
+
if (state.sheetsById[sheet.id]) {
|
|
29
|
+
return state;
|
|
29
30
|
}
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
31
|
+
const newSheetsById = {
|
|
32
|
+
...state.sheetsById
|
|
33
|
+
};
|
|
34
|
+
const topId = state.stackOrder[state.stackOrder.length - 1];
|
|
35
|
+
if (topId && newSheetsById[topId]) {
|
|
36
|
+
newSheetsById[topId] = {
|
|
37
|
+
...newSheetsById[topId],
|
|
38
|
+
status: 'hidden'
|
|
39
|
+
};
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
+
newSheetsById[sheet.id] = {
|
|
41
42
|
...sheet,
|
|
42
43
|
status: 'opening'
|
|
43
|
-
}
|
|
44
|
+
};
|
|
44
45
|
return {
|
|
45
|
-
|
|
46
|
+
sheetsById: newSheetsById,
|
|
47
|
+
stackOrder: [...state.stackOrder, sheet.id]
|
|
46
48
|
};
|
|
47
49
|
}),
|
|
48
50
|
replace: sheet => set(state => {
|
|
49
|
-
if (state.
|
|
50
|
-
return
|
|
51
|
-
stack: state.stack
|
|
52
|
-
};
|
|
51
|
+
if (state.sheetsById[sheet.id]) {
|
|
52
|
+
return state;
|
|
53
53
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const newSheetsById = {
|
|
55
|
+
...state.sheetsById
|
|
56
|
+
};
|
|
57
|
+
const topId = state.stackOrder[state.stackOrder.length - 1];
|
|
58
|
+
if (topId && newSheetsById[topId]) {
|
|
59
|
+
newSheetsById[topId] = {
|
|
60
|
+
...newSheetsById[topId],
|
|
59
61
|
status: 'closing'
|
|
60
|
-
}
|
|
62
|
+
};
|
|
61
63
|
}
|
|
62
|
-
|
|
64
|
+
newSheetsById[sheet.id] = {
|
|
63
65
|
...sheet,
|
|
64
66
|
status: 'opening'
|
|
65
|
-
}
|
|
67
|
+
};
|
|
66
68
|
return {
|
|
67
|
-
|
|
69
|
+
sheetsById: newSheetsById,
|
|
70
|
+
stackOrder: [...state.stackOrder, sheet.id]
|
|
68
71
|
};
|
|
69
72
|
}),
|
|
70
73
|
markOpen: id => set(state => {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
74
|
+
const sheet = state.sheetsById[id];
|
|
75
|
+
if (!sheet) {
|
|
76
|
+
return state;
|
|
77
|
+
}
|
|
75
78
|
return {
|
|
76
|
-
|
|
79
|
+
sheetsById: {
|
|
80
|
+
...state.sheetsById,
|
|
81
|
+
[id]: {
|
|
82
|
+
...sheet,
|
|
83
|
+
status: 'open'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
77
86
|
};
|
|
78
87
|
}),
|
|
79
88
|
startClosing: id => set(state => {
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
stack
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
const closing = stack[index];
|
|
88
|
-
if (closing?.status === 'hidden') {
|
|
89
|
-
return {
|
|
90
|
-
stack
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
if (closing) {
|
|
94
|
-
stack[index] = {
|
|
95
|
-
...closing,
|
|
96
|
-
status: 'closing'
|
|
97
|
-
};
|
|
89
|
+
const sheet = state.sheetsById[id];
|
|
90
|
+
if (!sheet || sheet.status === 'hidden') {
|
|
91
|
+
return state;
|
|
98
92
|
}
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
93
|
+
const newSheetsById = {
|
|
94
|
+
...state.sheetsById
|
|
95
|
+
};
|
|
96
|
+
newSheetsById[id] = {
|
|
97
|
+
...sheet,
|
|
98
|
+
status: 'closing'
|
|
99
|
+
};
|
|
100
|
+
const index = state.stackOrder.indexOf(id);
|
|
101
|
+
const belowId = state.stackOrder[index - 1];
|
|
102
|
+
const belowSheet = belowId ? newSheetsById[belowId] : undefined;
|
|
103
|
+
if (belowId && belowSheet && belowSheet.status === 'hidden') {
|
|
104
|
+
newSheetsById[belowId] = {
|
|
105
|
+
...belowSheet,
|
|
103
106
|
status: 'opening'
|
|
104
107
|
};
|
|
105
108
|
}
|
|
106
109
|
return {
|
|
107
|
-
|
|
110
|
+
sheetsById: newSheetsById
|
|
108
111
|
};
|
|
109
112
|
}),
|
|
110
113
|
finishClosing: id => set(state => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
if (!state.sheetsById[id]) {
|
|
115
|
+
return state;
|
|
116
|
+
}
|
|
117
|
+
const newSheetsById = {
|
|
118
|
+
...state.sheetsById
|
|
119
|
+
};
|
|
120
|
+
delete newSheetsById[id];
|
|
121
|
+
const newStackOrder = state.stackOrder.filter(sheetId => sheetId !== id);
|
|
122
|
+
const topId = newStackOrder[newStackOrder.length - 1];
|
|
123
|
+
const topSheet = topId ? newSheetsById[topId] : undefined;
|
|
124
|
+
if (topId && topSheet && topSheet.status === 'hidden') {
|
|
125
|
+
newSheetsById[topId] = {
|
|
126
|
+
...topSheet,
|
|
116
127
|
status: 'opening'
|
|
117
128
|
};
|
|
118
129
|
}
|
|
119
130
|
return {
|
|
120
|
-
|
|
131
|
+
sheetsById: newSheetsById,
|
|
132
|
+
stackOrder: newStackOrder
|
|
121
133
|
};
|
|
122
134
|
}),
|
|
123
135
|
clearAll: () => set(() => ({
|
|
124
|
-
|
|
136
|
+
sheetsById: {},
|
|
137
|
+
stackOrder: []
|
|
125
138
|
}))
|
|
126
139
|
})));
|
|
127
140
|
//# sourceMappingURL=bottomSheet.store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_middleware","require","_traditional","useBottomSheetStore","exports","create","subscribeWithSelector","set","
|
|
1
|
+
{"version":3,"names":["_middleware","require","_traditional","useBottomSheetStore","exports","create","subscribeWithSelector","set","sheetsById","stackOrder","push","sheet","state","id","status","switch","newSheetsById","topId","length","replace","markOpen","startClosing","index","indexOf","belowId","belowSheet","undefined","finishClosing","newStackOrder","filter","sheetId","topSheet","clearAll"],"sourceRoot":"../../src","sources":["bottomSheet.store.ts"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AA8BO,MAAME,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,IAAAE,iCAAM,EACvC,IAAAC,iCAAqB,EAClBC,GAAG,KAAM;EACRC,UAAU,EAAE,CAAC,CAAC;EACdC,UAAU,EAAE,EAAE;EAEdC,IAAI,EAAGC,KAAK,IACVJ,GAAG,CAAEK,KAAK,IAAK;IACb,IAAIA,KAAK,CAACJ,UAAU,CAACG,KAAK,CAACE,EAAE,CAAC,EAAE;MAC9B,OA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,EAAEA,CAAA,KAAMzB,GAAG,CAAC,OAAO;IAAEC,UAAU,EAAE,CAAC,CAAC;IAAEC,UAAU,EAAE;EAAG,CAAC,CAAC;AAChE,CAAC,CACH,CACF,CAAC","ignoreList":[]}
|
|
@@ -7,13 +7,10 @@ exports.createSheetEventHandlers = createSheetEventHandlers;
|
|
|
7
7
|
exports.initBottomSheetCoordinator = initBottomSheetCoordinator;
|
|
8
8
|
var _bottomSheet = require("./bottomSheet.store");
|
|
9
9
|
var _refsMap = require("./refsMap");
|
|
10
|
-
function initBottomSheetCoordinator() {
|
|
11
|
-
_bottomSheet.useBottomSheetStore.subscribe(s => s.
|
|
10
|
+
function initBottomSheetCoordinator(groupId) {
|
|
11
|
+
return _bottomSheet.useBottomSheetStore.subscribe(s => s.stackOrder.filter(id => s.sheetsById[id]?.groupId === groupId).map(id => ({
|
|
12
12
|
id,
|
|
13
|
-
status
|
|
14
|
-
}) => ({
|
|
15
|
-
id,
|
|
16
|
-
status
|
|
13
|
+
status: s.sheetsById[id]?.status
|
|
17
14
|
})), (next, prev) => {
|
|
18
15
|
next.forEach(({
|
|
19
16
|
id,
|
|
@@ -53,7 +50,8 @@ function createSheetEventHandlers(sheetId) {
|
|
|
53
50
|
markOpen
|
|
54
51
|
} = _bottomSheet.useBottomSheetStore.getState();
|
|
55
52
|
const handleAnimate = (fromIndex, toIndex) => {
|
|
56
|
-
const
|
|
53
|
+
const state = _bottomSheet.useBottomSheetStore.getState();
|
|
54
|
+
const currentStatus = state.sheetsById[sheetId]?.status;
|
|
57
55
|
|
|
58
56
|
// Sheet is closing (animating to -1)
|
|
59
57
|
if (toIndex === -1) {
|
|
@@ -68,7 +66,8 @@ function createSheetEventHandlers(sheetId) {
|
|
|
68
66
|
}
|
|
69
67
|
};
|
|
70
68
|
const handleClose = () => {
|
|
71
|
-
const
|
|
69
|
+
const state = _bottomSheet.useBottomSheetStore.getState();
|
|
70
|
+
const currentStatus = state.sheetsById[sheetId]?.status;
|
|
72
71
|
if (currentStatus !== 'hidden') {
|
|
73
72
|
finishClosing(sheetId);
|
|
74
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_bottomSheet","require","_refsMap","initBottomSheetCoordinator","useBottomSheetStore","subscribe","s","
|
|
1
|
+
{"version":3,"names":["_bottomSheet","require","_refsMap","initBottomSheetCoordinator","groupId","useBottomSheetStore","subscribe","s","stackOrder","filter","id","sheetsById","map","status","next","prev","forEach","prevStatus","find","p","ref","sheetRefs","current","expand","close","createSheetEventHandlers","sheetId","startClosing","finishClosing","markOpen","getState","handleAnimate","fromIndex","toIndex","state","currentStatus","handleClose"],"sourceRoot":"../../src","sources":["bottomSheetCoordinator.ts"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,SAASE,0BAA0BA,CAACC,OAAe,EAAE;EAC1D,OAAOC,gCAAmB,CAACC,SAAS,CACjCC,CAAC,IACAA,CAAC,CAACC,UAAU,CACTC,MAAM,CAAEC,EAAE,IAAKH,CAAC,CAACI,UAAU,CAACD,EAAE,CAAC,EAAEN,OAAO,KAAKA,OAAO,CAAC,CACrDQ,GAAG,CAAEF,EAAE,KAAM;IAAEA,EAAE;IAAEG,MAAM,EAAEN,CAAC,CAACI,UAAU,CAACD,EAAE,CAAC,EAAEG;EAAO,CAAC,CAAC,CAAC,EAC5D,CAACC,IAAI,EAAEC,IAAI,KAAK;IACdD,IAAI,CAACE,OAAO,CAAC,CAAC;MAAEN,EAAE;MAAEG;IAAO,CAAC,KAAK;MAC/B,MAAMI,UAAU,GAAGF,IAAI,CAACG,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACT,EAAE,KAAKA,EAAE,CAAC,EAAEG,MAAM;MAExD,IAAII,UAAU,KAAKJ,MAAM,EAAE;QACzB;MACF;MAEA,MAAMO,GAAG,GAAGC,kBAAS,CAACX,EAAE,CAAC,EAAEY,OAAO;MAClC,IAAI,CAACF,GAAG,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|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_BottomSheetHost","require","_BottomSheetManager","_useBottomSheetManager","_useBottomSheetState","_BottomSheetManaged","_ScaleBackgroundWrapper"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;
|
|
1
|
+
{"version":3,"names":["_BottomSheetHost","require","_BottomSheetManager","_useBottomSheetManager","_useBottomSheetState","_BottomSheetManaged","_ScaleBackgroundWrapper"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,uBAAA,GAAAL,OAAA","ignoreList":[]}
|
|
@@ -7,17 +7,10 @@ exports.useBottomSheetState = useBottomSheetState;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _BottomSheet = require("./BottomSheet.context");
|
|
9
9
|
var _bottomSheet = require("./bottomSheet.store");
|
|
10
|
-
var _shallow = require("zustand/shallow");
|
|
11
10
|
function useBottomSheetState() {
|
|
12
11
|
const context = (0, _BottomSheet.useMaybeBottomSheetContext)();
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
startClosing
|
|
16
|
-
} = (0, _bottomSheet.useBottomSheetStore)(store => ({
|
|
17
|
-
bottomSheetsStack: store.stack,
|
|
18
|
-
startClosing: store.startClosing
|
|
19
|
-
}), _shallow.shallow);
|
|
20
|
-
const bottomSheetState = (0, _react.useMemo)(() => bottomSheetsStack.find(bottomSheet => bottomSheet.id === context?.id), [bottomSheetsStack, context?.id]);
|
|
12
|
+
const bottomSheetState = (0, _bottomSheet.useBottomSheetStore)((0, _react.useCallback)(state => state.sheetsById[context?.id], [context?.id]));
|
|
13
|
+
const startClosing = (0, _bottomSheet.useBottomSheetStore)(state => state.startClosing);
|
|
21
14
|
if (!bottomSheetState) {
|
|
22
15
|
throw new Error('useBottomSheetState must be used within a BottomSheetProvider');
|
|
23
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_BottomSheet","_bottomSheet","
|
|
1
|
+
{"version":3,"names":["_react","require","_BottomSheet","_bottomSheet","useBottomSheetState","context","useMaybeBottomSheetContext","bottomSheetState","useBottomSheetStore","useCallback","state","sheetsById","id","startClosing","Error","close","closeBottomSheet"],"sourceRoot":"../../src","sources":["useBottomSheetState.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAKO,SAASG,mBAAmBA,CAAA,EAIjC;EACA,MAAMC,OAAO,GAAG,IAAAC,uCAA0B,EAAC,CAAC;EAE5C,MAAMC,gBAAgB,GAAG,IAAAC,gCAAmB,EAC1C,IAAAC,kBAAW,EAAEC,KAAK,IAAKA,KAAK,CAACC,UAAU,CAACN,OAAO,EAAEO,EAAE,CAAE,EAAE,CAACP,OAAO,EAAEO,EAAE,CAAC,CACtE,CAAC;EAED,MAAMC,YAAY,GAAG,IAAAL,gCAAmB,EAAEE,KAAK,IAAKA,KAAK,CAACG,YAAY,CAAC;EAEvE,IAAI,CAACN,gBAAgB,EAAE;IACrB,MAAM,IAAIO,KAAK,CACb,+DACF,CAAC;EACH;EAEA,MAAMC,KAAK,GAAG,IAAAN,kBAAW,EACvB,MAAMI,YAAY,CAACN,gBAAgB,CAACK,EAAE,CAAC,EACvC,CAACL,gBAAgB,CAACK,EAAE,EAAEC,YAAY,CACpC,CAAC;EAED,OAAO;IACLN,gBAAgB;IAChBQ,KAAK;IACLC,gBAAgB,EAAED;EACpB,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../example/src/App.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../example/src/App.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAa3D,MAAM,CAAC,OAAO,UAAU,GAAG,4CAiB1B;AAmBD,eAAO,MAAM,OAAO,GAAI,IAAI,iBAAiB,4CAU5C,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
Container?: React.ComponentType<any>;
|
|
4
|
-
}
|
|
5
|
-
declare function BottomSheetHostComp({ Container }: BottomSheetHostProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare function BottomSheetHostComp(): import("react/jsx-runtime").JSX.Element;
|
|
6
3
|
export declare const BottomSheetHost: React.MemoExoticComponent<typeof BottomSheetHostComp>;
|
|
7
4
|
export {};
|
|
8
5
|
//# sourceMappingURL=BottomSheetHost.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheetHost.d.ts","sourceRoot":"","sources":["../../../src/BottomSheetHost.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"BottomSheetHost.d.ts","sourceRoot":"","sources":["../../../src/BottomSheetHost.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAUlD,iBAAS,mBAAmB,4CA0B3B;AAsCD,eAAO,MAAM,eAAe,uDAAkC,CAAC"}
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import React, { type PropsWithChildren } from 'react';
|
|
2
2
|
import { type BottomSheetManagerContextValue } from './BottomSheetManager.context';
|
|
3
|
-
export interface ScaleBackgroundConfig {
|
|
4
|
-
/** Scale factor when sheet is open (default: 0.92) */
|
|
5
|
-
scale?: number;
|
|
6
|
-
/** Vertical translation when sheet is open (default: 10) */
|
|
7
|
-
translateY?: number;
|
|
8
|
-
/** Border radius when sheet is open (default: 12) */
|
|
9
|
-
borderRadius?: number;
|
|
10
|
-
/** Animation duration in ms (default: 300) */
|
|
11
|
-
duration?: number;
|
|
12
|
-
}
|
|
13
3
|
interface ProviderProps extends PropsWithChildren {
|
|
14
4
|
id: string;
|
|
15
5
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Provider for bottom sheet manager context.
|
|
18
|
-
* Use ScaleBackgroundWrapper inside to enable iOS-style scale effect on content.
|
|
19
|
-
*/
|
|
20
6
|
declare function BottomSheetManagerProviderComp({ id, children }: ProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
21
7
|
export declare const BottomSheetManagerProvider: React.MemoExoticComponent<typeof BottomSheetManagerProviderComp>;
|
|
22
8
|
export declare const useBottomSheetManagerContext: () => BottomSheetManagerContextValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheetManager.provider.d.ts","sourceRoot":"","sources":["../../../src/BottomSheetManager.provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BottomSheetManager.provider.d.ts","sourceRoot":"","sources":["../../../src/BottomSheetManager.provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,8BAA8B,CAAC;AAEtC,UAAU,aAAc,SAAQ,iBAAiB;IAC/C,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,iBAAS,8BAA8B,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,aAAa,2CAMtE;AAED,eAAO,MAAM,0BAA0B,kEAEtC,CAAC;AAEF,eAAO,MAAM,4BAA4B,QACnC,8BASH,CAAC;AAEJ,eAAO,MAAM,iCAAiC,QACxC,8BAA8B,GAAG,IAOpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScaleBackgroundWrapper.d.ts","sourceRoot":"","sources":["../../../src/ScaleBackgroundWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ScaleBackgroundWrapper.d.ts","sourceRoot":"","sources":["../../../src/ScaleBackgroundWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAW3D,MAAM,WAAW,qBAAqB;IACpC,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,2BAA4B,SAAQ,iBAAiB;IAC7D,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,MAAM,GACP,EAAE,2BAA2B,2CA8C7B"}
|
|
@@ -10,7 +10,8 @@ export interface BottomSheetState {
|
|
|
10
10
|
}
|
|
11
11
|
type TriggerState = Omit<BottomSheetState, 'status'>;
|
|
12
12
|
interface BottomSheetStoreState {
|
|
13
|
-
|
|
13
|
+
sheetsById: Record<string, BottomSheetState>;
|
|
14
|
+
stackOrder: string[];
|
|
14
15
|
}
|
|
15
16
|
interface BottomSheetStoreActions {
|
|
16
17
|
push(sheet: TriggerState): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bottomSheet.store.d.ts","sourceRoot":"","sources":["../../../src/bottomSheet.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,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAChC,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB;;;;;;;;EAoI/B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function initBottomSheetCoordinator(): void;
|
|
1
|
+
export declare function initBottomSheetCoordinator(groupId: string): () => void;
|
|
2
2
|
/**
|
|
3
3
|
* Creates event handlers for a bottom sheet that sync gorhom events back to the store.
|
|
4
4
|
* Direction: Gorhom Events → Store
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bottomSheetCoordinator.d.ts","sourceRoot":"","sources":["../../../src/bottomSheetCoordinator.ts"],"names":[],"mappings":"AAGA,wBAAgB,0BAA0B,
|
|
1
|
+
{"version":3,"file":"bottomSheetCoordinator.d.ts","sourceRoot":"","sources":["../../../src/bottomSheetCoordinator.ts"],"names":[],"mappings":"AAGA,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,cAiCzD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM;+BAIpB,MAAM,WAAW,MAAM;;EA8B1D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { BottomSheetHost } from './BottomSheetHost';
|
|
2
|
-
export { BottomSheetManagerProvider
|
|
2
|
+
export { BottomSheetManagerProvider } from './BottomSheetManager.provider';
|
|
3
3
|
export { useBottomSheetManager } from './useBottomSheetManager';
|
|
4
4
|
export { useBottomSheetState } from './useBottomSheetState';
|
|
5
5
|
export { BottomSheetManaged } from './BottomSheetManaged';
|
|
6
|
-
export { ScaleBackgroundWrapper } from './ScaleBackgroundWrapper';
|
|
6
|
+
export { ScaleBackgroundWrapper, type ScaleBackgroundConfig, } from './ScaleBackgroundWrapper';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACL,sBAAsB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,0BAA0B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBottomSheetState.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetState.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"useBottomSheetState.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetState.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAE7B,wBAAgB,mBAAmB,IAAI;IACrC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B,CAyBA"}
|
package/package.json
CHANGED
package/src/BottomSheetHost.tsx
CHANGED
|
@@ -1,39 +1,25 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
Fragment,
|
|
3
|
-
useEffect,
|
|
4
|
-
useMemo,
|
|
5
|
-
type PropsWithChildren,
|
|
6
|
-
} from 'react';
|
|
1
|
+
import React, { useEffect, useMemo } from 'react';
|
|
7
2
|
import { StyleSheet, View } from 'react-native';
|
|
8
3
|
import { useSafeAreaFrame } from 'react-native-safe-area-context';
|
|
9
4
|
|
|
5
|
+
import { shallow } from 'zustand/shallow';
|
|
10
6
|
import { BottomSheetContext } from './BottomSheet.context';
|
|
11
7
|
import { useBottomSheetStore } from './bottomSheet.store';
|
|
12
|
-
import { initBottomSheetCoordinator } from './bottomSheetCoordinator';
|
|
13
8
|
import { useBottomSheetManagerContext } from './BottomSheetManager.provider';
|
|
9
|
+
import { initBottomSheetCoordinator } from './bottomSheetCoordinator';
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Container?: React.ComponentType<any>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function BottomSheetHostComp({ Container = Fragment }: BottomSheetHostProps) {
|
|
22
|
-
const { bottomSheetsStack, clearAll } = useBottomSheetStore((store) => ({
|
|
23
|
-
bottomSheetsStack: store.stack,
|
|
24
|
-
clearAll: store.clearAll,
|
|
25
|
-
}));
|
|
11
|
+
function BottomSheetHostComp() {
|
|
12
|
+
const queueIds = useQueueIds();
|
|
13
|
+
const clearAll = useBottomSheetStore((store) => store.clearAll);
|
|
26
14
|
|
|
27
|
-
const { width, height } = useSafeAreaFrame();
|
|
28
15
|
const { groupId } = useBottomSheetManagerContext();
|
|
29
16
|
|
|
30
|
-
|
|
31
|
-
()
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const unsubscribe = initBottomSheetCoordinator(groupId);
|
|
19
|
+
return () => {
|
|
20
|
+
unsubscribe();
|
|
21
|
+
};
|
|
22
|
+
}, [groupId]);
|
|
37
23
|
|
|
38
24
|
useEffect(() => {
|
|
39
25
|
return () => {
|
|
@@ -43,34 +29,48 @@ function BottomSheetHostComp({ Container = Fragment }: BottomSheetHostProps) {
|
|
|
43
29
|
|
|
44
30
|
return (
|
|
45
31
|
<>
|
|
46
|
-
{
|
|
47
|
-
<
|
|
48
|
-
<Container>
|
|
49
|
-
<View
|
|
50
|
-
style={[
|
|
51
|
-
StyleSheet.absoluteFillObject,
|
|
52
|
-
styles.container,
|
|
53
|
-
{
|
|
54
|
-
width,
|
|
55
|
-
height,
|
|
56
|
-
},
|
|
57
|
-
]}
|
|
58
|
-
>
|
|
59
|
-
<MemoizedContent id={id}>{content}</MemoizedContent>
|
|
60
|
-
</View>
|
|
61
|
-
</Container>
|
|
62
|
-
</BottomSheetContext.Provider>
|
|
32
|
+
{queueIds.map((id) => (
|
|
33
|
+
<QueueItem key={id} id={id} />
|
|
63
34
|
))}
|
|
64
35
|
</>
|
|
65
36
|
);
|
|
66
37
|
}
|
|
67
38
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
39
|
+
const QueueItem = React.memo(({ id }: { id: string }) => {
|
|
40
|
+
const content = useBottomSheetStore((state) => state.sheetsById[id]?.content);
|
|
41
|
+
|
|
42
|
+
const { width, height } = useSafeAreaFrame();
|
|
43
|
+
const value = useMemo(() => ({ id }), [id]);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<BottomSheetContext.Provider value={value}>
|
|
47
|
+
<View
|
|
48
|
+
style={[
|
|
49
|
+
StyleSheet.absoluteFillObject,
|
|
50
|
+
styles.container,
|
|
51
|
+
{
|
|
52
|
+
width,
|
|
53
|
+
height,
|
|
54
|
+
},
|
|
55
|
+
]}
|
|
56
|
+
>
|
|
57
|
+
{content}
|
|
58
|
+
</View>
|
|
59
|
+
</BottomSheetContext.Provider>
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const useQueueIds = () => {
|
|
64
|
+
const { groupId } = useBottomSheetManagerContext();
|
|
65
|
+
|
|
66
|
+
return useBottomSheetStore(
|
|
67
|
+
(state) =>
|
|
68
|
+
state.stackOrder.filter(
|
|
69
|
+
(sheetId) => state.sheetsById[sheetId]?.groupId === groupId
|
|
70
|
+
),
|
|
71
|
+
shallow
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
74
|
|
|
75
75
|
export const BottomSheetHost = React.memo(BottomSheetHostComp);
|
|
76
76
|
|
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
import React, { type PropsWithChildren } from 'react';
|
|
2
|
-
import { StyleSheet, View } from 'react-native';
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
4
|
BottomSheetManagerContext,
|
|
6
5
|
type BottomSheetManagerContextValue,
|
|
7
6
|
} from './BottomSheetManager.context';
|
|
8
7
|
|
|
9
|
-
export interface ScaleBackgroundConfig {
|
|
10
|
-
/** Scale factor when sheet is open (default: 0.92) */
|
|
11
|
-
scale?: number;
|
|
12
|
-
/** Vertical translation when sheet is open (default: 10) */
|
|
13
|
-
translateY?: number;
|
|
14
|
-
/** Border radius when sheet is open (default: 12) */
|
|
15
|
-
borderRadius?: number;
|
|
16
|
-
/** Animation duration in ms (default: 300) */
|
|
17
|
-
duration?: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
8
|
interface ProviderProps extends PropsWithChildren {
|
|
21
9
|
id: string;
|
|
22
10
|
}
|
|
23
11
|
|
|
24
|
-
/**
|
|
25
|
-
* Provider for bottom sheet manager context.
|
|
26
|
-
* Use ScaleBackgroundWrapper inside to enable iOS-style scale effect on content.
|
|
27
|
-
*/
|
|
28
12
|
function BottomSheetManagerProviderComp({ id, children }: ProviderProps) {
|
|
29
13
|
return (
|
|
30
14
|
<BottomSheetManagerContext.Provider key={id} value={{ groupId: id }}>
|
|
31
|
-
|
|
15
|
+
{children}
|
|
32
16
|
</BottomSheetManagerContext.Provider>
|
|
33
17
|
);
|
|
34
18
|
}
|
|
@@ -58,10 +42,3 @@ export const useMaybeBottomSheetManagerContext =
|
|
|
58
42
|
}
|
|
59
43
|
return context;
|
|
60
44
|
};
|
|
61
|
-
|
|
62
|
-
const styles = StyleSheet.create({
|
|
63
|
-
container: {
|
|
64
|
-
flex: 1,
|
|
65
|
-
backgroundColor: '#000',
|
|
66
|
-
},
|
|
67
|
-
});
|
|
@@ -6,7 +6,6 @@ import Animated, {
|
|
|
6
6
|
useDerivedValue,
|
|
7
7
|
withTiming,
|
|
8
8
|
} from 'react-native-reanimated';
|
|
9
|
-
import { shallow } from 'zustand/shallow';
|
|
10
9
|
import { BottomSheetManagerContext } from './BottomSheetManager.context';
|
|
11
10
|
import { useBottomSheetStore } from './bottomSheet.store';
|
|
12
11
|
|
|
@@ -54,15 +53,15 @@ export function ScaleBackgroundWrapper({
|
|
|
54
53
|
duration = 300,
|
|
55
54
|
} = config ?? {};
|
|
56
55
|
|
|
57
|
-
const hasActiveScaleSheet = useBottomSheetStore(
|
|
58
|
-
(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
|
|
56
|
+
const hasActiveScaleSheet = useBottomSheetStore((state) =>
|
|
57
|
+
state.stackOrder.some((id) => {
|
|
58
|
+
const sheet = state.sheetsById[id];
|
|
59
|
+
return (
|
|
60
|
+
sheet?.groupId === groupId &&
|
|
61
|
+
sheet?.scaleBackground &&
|
|
62
|
+
sheet?.status !== 'closing'
|
|
63
|
+
);
|
|
64
|
+
})
|
|
66
65
|
);
|
|
67
66
|
|
|
68
67
|
const animationProgress = useDerivedValue(() =>
|
package/src/bottomSheet.store.ts
CHANGED
|
@@ -16,7 +16,8 @@ export interface BottomSheetState {
|
|
|
16
16
|
type TriggerState = Omit<BottomSheetState, 'status'>;
|
|
17
17
|
|
|
18
18
|
interface BottomSheetStoreState {
|
|
19
|
-
|
|
19
|
+
sheetsById: Record<string, BottomSheetState>;
|
|
20
|
+
stackOrder: string[];
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
interface BottomSheetStoreActions {
|
|
@@ -32,99 +33,133 @@ interface BottomSheetStoreActions {
|
|
|
32
33
|
export const useBottomSheetStore = create(
|
|
33
34
|
subscribeWithSelector<BottomSheetStoreState & BottomSheetStoreActions>(
|
|
34
35
|
(set) => ({
|
|
35
|
-
|
|
36
|
+
sheetsById: {},
|
|
37
|
+
stackOrder: [],
|
|
36
38
|
|
|
37
39
|
push: (sheet) =>
|
|
38
40
|
set((state) => {
|
|
39
|
-
if (state.
|
|
40
|
-
return
|
|
41
|
+
if (state.sheetsById[sheet.id]) {
|
|
42
|
+
return state;
|
|
41
43
|
}
|
|
42
44
|
return {
|
|
43
|
-
|
|
45
|
+
sheetsById: {
|
|
46
|
+
...state.sheetsById,
|
|
47
|
+
[sheet.id]: { ...sheet, status: 'opening' },
|
|
48
|
+
},
|
|
49
|
+
stackOrder: [...state.stackOrder, sheet.id],
|
|
44
50
|
};
|
|
45
51
|
}),
|
|
52
|
+
|
|
46
53
|
switch: (sheet) =>
|
|
47
54
|
set((state) => {
|
|
48
|
-
if (state.
|
|
49
|
-
return
|
|
55
|
+
if (state.sheetsById[sheet.id]) {
|
|
56
|
+
return state;
|
|
50
57
|
}
|
|
51
58
|
|
|
52
|
-
const
|
|
59
|
+
const newSheetsById = { ...state.sheetsById };
|
|
60
|
+
const topId = state.stackOrder[state.stackOrder.length - 1];
|
|
53
61
|
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
62
|
+
if (topId && newSheetsById[topId]) {
|
|
63
|
+
newSheetsById[topId] = {
|
|
64
|
+
...newSheetsById[topId],
|
|
65
|
+
status: 'hidden',
|
|
66
|
+
};
|
|
59
67
|
}
|
|
60
68
|
|
|
61
|
-
|
|
69
|
+
newSheetsById[sheet.id] = { ...sheet, status: 'opening' };
|
|
62
70
|
|
|
63
|
-
return {
|
|
71
|
+
return {
|
|
72
|
+
sheetsById: newSheetsById,
|
|
73
|
+
stackOrder: [...state.stackOrder, sheet.id],
|
|
74
|
+
};
|
|
64
75
|
}),
|
|
65
76
|
|
|
66
77
|
replace: (sheet) =>
|
|
67
78
|
set((state) => {
|
|
68
|
-
if (state.
|
|
69
|
-
return
|
|
79
|
+
if (state.sheetsById[sheet.id]) {
|
|
80
|
+
return state;
|
|
70
81
|
}
|
|
71
82
|
|
|
72
|
-
const
|
|
73
|
-
const
|
|
83
|
+
const newSheetsById = { ...state.sheetsById };
|
|
84
|
+
const topId = state.stackOrder[state.stackOrder.length - 1];
|
|
74
85
|
|
|
75
|
-
if (
|
|
76
|
-
|
|
86
|
+
if (topId && newSheetsById[topId]) {
|
|
87
|
+
newSheetsById[topId] = {
|
|
88
|
+
...newSheetsById[topId],
|
|
89
|
+
status: 'closing',
|
|
90
|
+
};
|
|
77
91
|
}
|
|
78
|
-
stack.push({ ...sheet, status: 'opening' });
|
|
79
92
|
|
|
80
|
-
|
|
93
|
+
newSheetsById[sheet.id] = { ...sheet, status: 'opening' };
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
sheetsById: newSheetsById,
|
|
97
|
+
stackOrder: [...state.stackOrder, sheet.id],
|
|
98
|
+
};
|
|
81
99
|
}),
|
|
100
|
+
|
|
82
101
|
markOpen: (id) =>
|
|
83
102
|
set((state) => {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
103
|
+
const sheet = state.sheetsById[id];
|
|
104
|
+
if (!sheet) {
|
|
105
|
+
return state;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
sheetsById: {
|
|
109
|
+
...state.sheetsById,
|
|
110
|
+
[id]: { ...sheet, status: 'open' },
|
|
111
|
+
},
|
|
112
|
+
};
|
|
88
113
|
}),
|
|
89
114
|
|
|
90
115
|
startClosing: (id) =>
|
|
91
116
|
set((state) => {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return { stack };
|
|
117
|
+
const sheet = state.sheetsById[id];
|
|
118
|
+
if (!sheet || sheet.status === 'hidden') {
|
|
119
|
+
return state;
|
|
96
120
|
}
|
|
97
121
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
return { stack };
|
|
101
|
-
}
|
|
122
|
+
const newSheetsById = { ...state.sheetsById };
|
|
123
|
+
newSheetsById[id] = { ...sheet, status: 'closing' };
|
|
102
124
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
125
|
+
const index = state.stackOrder.indexOf(id);
|
|
126
|
+
const belowId = state.stackOrder[index - 1];
|
|
127
|
+
const belowSheet = belowId ? newSheetsById[belowId] : undefined;
|
|
106
128
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
stack[index - 1] = { ...below, status: 'opening' };
|
|
129
|
+
if (belowId && belowSheet && belowSheet.status === 'hidden') {
|
|
130
|
+
newSheetsById[belowId] = { ...belowSheet, status: 'opening' };
|
|
110
131
|
}
|
|
111
132
|
|
|
112
|
-
return {
|
|
133
|
+
return { sheetsById: newSheetsById };
|
|
113
134
|
}),
|
|
114
135
|
|
|
115
136
|
finishClosing: (id) =>
|
|
116
137
|
set((state) => {
|
|
117
|
-
|
|
138
|
+
if (!state.sheetsById[id]) {
|
|
139
|
+
return state;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const newSheetsById = { ...state.sheetsById };
|
|
143
|
+
delete newSheetsById[id];
|
|
118
144
|
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
145
|
+
const newStackOrder = state.stackOrder.filter(
|
|
146
|
+
(sheetId) => sheetId !== id
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const topId = newStackOrder[newStackOrder.length - 1];
|
|
150
|
+
const topSheet = topId ? newSheetsById[topId] : undefined;
|
|
151
|
+
|
|
152
|
+
if (topId && topSheet && topSheet.status === 'hidden') {
|
|
153
|
+
newSheetsById[topId] = { ...topSheet, status: 'opening' };
|
|
122
154
|
}
|
|
123
155
|
|
|
124
|
-
return {
|
|
156
|
+
return {
|
|
157
|
+
sheetsById: newSheetsById,
|
|
158
|
+
stackOrder: newStackOrder,
|
|
159
|
+
};
|
|
125
160
|
}),
|
|
126
161
|
|
|
127
|
-
clearAll: () => set(() => ({
|
|
162
|
+
clearAll: () => set(() => ({ sheetsById: {}, stackOrder: [] })),
|
|
128
163
|
})
|
|
129
164
|
)
|
|
130
165
|
);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { useBottomSheetStore } from './bottomSheet.store';
|
|
2
2
|
import { sheetRefs } from './refsMap';
|
|
3
3
|
|
|
4
|
-
export function initBottomSheetCoordinator() {
|
|
5
|
-
useBottomSheetStore.subscribe(
|
|
6
|
-
(s) =>
|
|
4
|
+
export function initBottomSheetCoordinator(groupId: string) {
|
|
5
|
+
return useBottomSheetStore.subscribe(
|
|
6
|
+
(s) =>
|
|
7
|
+
s.stackOrder
|
|
8
|
+
.filter((id) => s.sheetsById[id]?.groupId === groupId)
|
|
9
|
+
.map((id) => ({ id, status: s.sheetsById[id]?.status })),
|
|
7
10
|
(next, prev) => {
|
|
8
11
|
next.forEach(({ id, status }) => {
|
|
9
12
|
const prevStatus = prev.find((p) => p.id === id)?.status;
|
|
@@ -42,9 +45,8 @@ export function createSheetEventHandlers(sheetId: string) {
|
|
|
42
45
|
useBottomSheetStore.getState();
|
|
43
46
|
|
|
44
47
|
const handleAnimate = (fromIndex: number, toIndex: number) => {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
.stack.find((s) => s.id === sheetId)?.status;
|
|
48
|
+
const state = useBottomSheetStore.getState();
|
|
49
|
+
const currentStatus = state.sheetsById[sheetId]?.status;
|
|
48
50
|
|
|
49
51
|
// Sheet is closing (animating to -1)
|
|
50
52
|
if (toIndex === -1) {
|
|
@@ -60,9 +62,8 @@ export function createSheetEventHandlers(sheetId: string) {
|
|
|
60
62
|
};
|
|
61
63
|
|
|
62
64
|
const handleClose = () => {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
.stack.find((s) => s.id === sheetId)?.status;
|
|
65
|
+
const state = useBottomSheetStore.getState();
|
|
66
|
+
const currentStatus = state.sheetsById[sheetId]?.status;
|
|
66
67
|
|
|
67
68
|
if (currentStatus !== 'hidden') {
|
|
68
69
|
finishClosing(sheetId);
|
package/src/index.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { BottomSheetHost } from './BottomSheetHost';
|
|
2
|
-
export {
|
|
3
|
-
BottomSheetManagerProvider,
|
|
4
|
-
type ScaleBackgroundConfig,
|
|
5
|
-
} from './BottomSheetManager.provider';
|
|
2
|
+
export { BottomSheetManagerProvider } from './BottomSheetManager.provider';
|
|
6
3
|
export { useBottomSheetManager } from './useBottomSheetManager';
|
|
7
4
|
export { useBottomSheetState } from './useBottomSheetState';
|
|
8
5
|
export { BottomSheetManaged } from './BottomSheetManaged';
|
|
9
|
-
export {
|
|
6
|
+
export {
|
|
7
|
+
ScaleBackgroundWrapper,
|
|
8
|
+
type ScaleBackgroundConfig,
|
|
9
|
+
} from './ScaleBackgroundWrapper';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { useCallback
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
2
|
import { useMaybeBottomSheetContext } from './BottomSheet.context';
|
|
3
3
|
import {
|
|
4
4
|
useBottomSheetStore,
|
|
5
5
|
type BottomSheetState,
|
|
6
6
|
} from './bottomSheet.store';
|
|
7
|
-
import { shallow } from 'zustand/shallow';
|
|
8
7
|
|
|
9
8
|
export function useBottomSheetState(): {
|
|
10
9
|
bottomSheetState: BottomSheetState;
|
|
@@ -12,20 +11,13 @@ export function useBottomSheetState(): {
|
|
|
12
11
|
closeBottomSheet: () => void;
|
|
13
12
|
} {
|
|
14
13
|
const context = useMaybeBottomSheetContext();
|
|
15
|
-
const { bottomSheetsStack, startClosing } = useBottomSheetStore(
|
|
16
|
-
(store) => ({
|
|
17
|
-
bottomSheetsStack: store.stack,
|
|
18
|
-
startClosing: store.startClosing,
|
|
19
|
-
}),
|
|
20
|
-
shallow
|
|
21
|
-
);
|
|
22
14
|
|
|
23
|
-
const bottomSheetState =
|
|
24
|
-
() =>
|
|
25
|
-
bottomSheetsStack.find((bottomSheet) => bottomSheet.id === context?.id),
|
|
26
|
-
[bottomSheetsStack, context?.id]
|
|
15
|
+
const bottomSheetState = useBottomSheetStore(
|
|
16
|
+
useCallback((state) => state.sheetsById[context?.id!], [context?.id])
|
|
27
17
|
);
|
|
28
18
|
|
|
19
|
+
const startClosing = useBottomSheetStore((state) => state.startClosing);
|
|
20
|
+
|
|
29
21
|
if (!bottomSheetState) {
|
|
30
22
|
throw new Error(
|
|
31
23
|
'useBottomSheetState must be used within a BottomSheetProvider'
|