react-native-bottom-sheet-stack 0.1.3 → 0.1.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/lib/commonjs/useBottomSheetManager.js +2 -9
- package/lib/commonjs/useBottomSheetManager.js.map +1 -1
- package/lib/commonjs/useBottomSheetState.js +3 -2
- package/lib/commonjs/useBottomSheetState.js.map +1 -1
- package/lib/typescript/src/useBottomSheetManager.d.ts +0 -1
- package/lib/typescript/src/useBottomSheetManager.d.ts.map +1 -1
- package/lib/typescript/src/useBottomSheetState.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/useBottomSheetManager.tsx +12 -17
- package/src/useBottomSheetState.ts +13 -7
|
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _bottomSheet = require("./bottomSheet.store");
|
|
9
9
|
var _BottomSheetManager = require("./BottomSheetManager.provider");
|
|
10
10
|
var _refsMap = require("./refsMap");
|
|
11
|
+
var _shallow = require("zustand/shallow");
|
|
11
12
|
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); }
|
|
12
13
|
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; }
|
|
13
14
|
const useBottomSheetManager = () => {
|
|
@@ -16,7 +17,6 @@ const useBottomSheetManager = () => {
|
|
|
16
17
|
pushBottomSheet,
|
|
17
18
|
replaceBottomSheet,
|
|
18
19
|
switchBottomSheet,
|
|
19
|
-
stack,
|
|
20
20
|
startClosing,
|
|
21
21
|
storeClearAll
|
|
22
22
|
} = (0, _bottomSheet.useBottomSheetStore)(store => ({
|
|
@@ -26,7 +26,7 @@ const useBottomSheetManager = () => {
|
|
|
26
26
|
switchBottomSheet: store.switch,
|
|
27
27
|
stack: store.stack,
|
|
28
28
|
startClosing: store.startClosing
|
|
29
|
-
}));
|
|
29
|
+
}), _shallow.shallow);
|
|
30
30
|
const openBottomSheet = (0, _react.useCallback)((content, options = {}) => {
|
|
31
31
|
const groupId = options.groupId || bottomSheetManagerContext?.groupId || 'default';
|
|
32
32
|
const id = Math.random().toString(36);
|
|
@@ -58,12 +58,6 @@ const useBottomSheetManager = () => {
|
|
|
58
58
|
}
|
|
59
59
|
return id;
|
|
60
60
|
}, [bottomSheetManagerContext?.groupId, pushBottomSheet, replaceBottomSheet, switchBottomSheet]);
|
|
61
|
-
const closeTop = (0, _react.useCallback)(() => {
|
|
62
|
-
const top = stack.at(-1);
|
|
63
|
-
if (top) {
|
|
64
|
-
startClosing(top.id);
|
|
65
|
-
}
|
|
66
|
-
}, [stack, startClosing]);
|
|
67
61
|
const close = (0, _react.useCallback)(id => {
|
|
68
62
|
startClosing(id);
|
|
69
63
|
}, [startClosing]);
|
|
@@ -72,7 +66,6 @@ const useBottomSheetManager = () => {
|
|
|
72
66
|
}, [storeClearAll]);
|
|
73
67
|
return {
|
|
74
68
|
clearAll,
|
|
75
|
-
closeTop,
|
|
76
69
|
close,
|
|
77
70
|
openBottomSheet,
|
|
78
71
|
pushBottomSheet,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_bottomSheet","_BottomSheetManager","_refsMap","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","useBottomSheetManager","bottomSheetManagerContext","useMaybeBottomSheetManagerContext","pushBottomSheet","replaceBottomSheet","switchBottomSheet","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_bottomSheet","_BottomSheetManager","_refsMap","_shallow","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","useBottomSheetManager","bottomSheetManagerContext","useMaybeBottomSheetManagerContext","pushBottomSheet","replaceBottomSheet","switchBottomSheet","startClosing","storeClearAll","useBottomSheetStore","store","clearAll","replace","push","switch","stack","shallow","openBottomSheet","useCallback","content","options","groupId","id","Math","random","toString","ref","React","createRef","sheetRefs","contentWithRef","cloneElement","mode","close","exports"],"sourceRoot":"../../src","sources":["useBottomSheetManager.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AAA0C,SAAAK,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,SAAAP,wBAAAO,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,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAA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C,EAAE,CAAC;IACrC,MAAMC,GAAG,gBAAGC,cAAK,CAACC,SAAS,CAAqB,CAAC;IAEjDC,kBAAS,CAACP,EAAE,CAAC,GAAGI,GAAG;;IAEnB;IACA,MAAMI,cAAc,gBAAGH,cAAK,CAACI,YAAY,CAACZ,OAAO,EAAE;MAAEO;IAAI,CAAC,CAAC;IAE3D,IAAIN,OAAO,CAACY,IAAI,KAAK,SAAS,EAAE;MAC9B3B,kBAAkB,CAAC;QACjBiB,EAAE;QACFD,OAAO;QACPF,OAAO,EAAEW;MACX,CAAC,CAAC;IACJ,CAAC,MAAM,IAAIV,OAAO,CAACY,IAAI,KAAK,QAAQ,EAAE;MACpC1B,iBAAiB,CAAC;QAChBgB,EAAE;QACFD,OAAO;QACPF,OAAO,EAAEW;MACX,CAAC,CAAC;IACJ,CAAC,MAAM;MACL1B,eAAe,CAAC;QACdkB,EAAE;QACFD,OAAO;QACPF,OAAO,EAAEW;MACX,CAAC,CAAC;IACJ;IAEA,OAAOR,EAAE;EACX,CAAC,EACD,CACEpB,yBAAyB,EAAEmB,OAAO,EAClCjB,eAAe,EACfC,kBAAkB,EAClBC,iBAAiB,CAErB,CAAC;EAED,MAAM2B,KAAK,GAAG,IAAAf,kBAAW,EACtBI,EAAU,IAAK;IACdf,YAAY,CAACe,EAAE,CAAC;EAClB,CAAC,EACD,CAACf,YAAY,CACf,CAAC;EAED,MAAMI,QAAQ,GAAG,IAAAO,kBAAW,EAAC,MAAM;IACjCV,aAAa,CAAC,CAAC;EACjB,CAAC,EAAE,CAACA,aAAa,CAAC,CAAC;EAEnB,OAAO;IACLG,QAAQ;IACRsB,KAAK;IACLhB,eAAe;IACfb,eAAe;IACfC;EACF,CAAC;AACH,CAAC;AAAC6B,OAAA,CAAAjC,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ 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");
|
|
10
11
|
function useBottomSheetState() {
|
|
11
12
|
const context = (0, _BottomSheet.useMaybeBottomSheetContext)();
|
|
12
13
|
const {
|
|
@@ -15,8 +16,8 @@ function useBottomSheetState() {
|
|
|
15
16
|
} = (0, _bottomSheet.useBottomSheetStore)(store => ({
|
|
16
17
|
bottomSheetsStack: store.stack,
|
|
17
18
|
startClosing: store.startClosing
|
|
18
|
-
}));
|
|
19
|
-
const bottomSheetState = bottomSheetsStack.find(bottomSheet => bottomSheet.id === context?.id);
|
|
19
|
+
}), _shallow.shallow);
|
|
20
|
+
const bottomSheetState = (0, _react.useMemo)(() => bottomSheetsStack.find(bottomSheet => bottomSheet.id === context?.id), [bottomSheetsStack, context?.id]);
|
|
20
21
|
if (!bottomSheetState) {
|
|
21
22
|
throw new Error('useBottomSheetState must be used within a BottomSheetProvider');
|
|
22
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_BottomSheet","_bottomSheet","useBottomSheetState","context","useMaybeBottomSheetContext","bottomSheetsStack","startClosing","useBottomSheetStore","store","stack","bottomSheetState","find","bottomSheet","id","Error","close","useCallback","closeBottomSheet"],"sourceRoot":"../../src","sources":["useBottomSheetState.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;
|
|
1
|
+
{"version":3,"names":["_react","require","_BottomSheet","_bottomSheet","_shallow","useBottomSheetState","context","useMaybeBottomSheetContext","bottomSheetsStack","startClosing","useBottomSheetStore","store","stack","shallow","bottomSheetState","useMemo","find","bottomSheet","id","Error","close","useCallback","closeBottomSheet"],"sourceRoot":"../../src","sources":["useBottomSheetState.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAIA,IAAAG,QAAA,GAAAH,OAAA;AAEO,SAASI,mBAAmBA,CAAA,EAIjC;EACA,MAAMC,OAAO,GAAG,IAAAC,uCAA0B,EAAC,CAAC;EAC5C,MAAM;IAAEC,iBAAiB;IAAEC;EAAa,CAAC,GAAG,IAAAC,gCAAmB,EAC5DC,KAAK,KAAM;IACVH,iBAAiB,EAAEG,KAAK,CAACC,KAAK;IAC9BH,YAAY,EAAEE,KAAK,CAACF;EACtB,CAAC,CAAC,EACFI,gBACF,CAAC;EAED,MAAMC,gBAAgB,GAAG,IAAAC,cAAO,EAC9B,MACEP,iBAAiB,CAACQ,IAAI,CAAEC,WAAW,IAAKA,WAAW,CAACC,EAAE,KAAKZ,OAAO,EAAEY,EAAE,CAAC,EACzE,CAACV,iBAAiB,EAAEF,OAAO,EAAEY,EAAE,CACjC,CAAC;EAED,IAAI,CAACJ,gBAAgB,EAAE;IACrB,MAAM,IAAIK,KAAK,CACb,+DACF,CAAC;EACH;EAEA,MAAMC,KAAK,GAAG,IAAAC,kBAAW,EACvB,MAAMZ,YAAY,CAACK,gBAAgB,CAACI,EAAE,CAAC,EACvC,CAACJ,gBAAgB,CAACI,EAAE,EAAET,YAAY,CACpC,CAAC;EAED,OAAO;IACLK,gBAAgB;IAChBM,KAAK;IACLE,gBAAgB,EAAEF;EACpB,CAAC;AACH","ignoreList":[]}
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { type OpenMode } from './bottomSheet.store';
|
|
3
3
|
export declare const useBottomSheetManager: () => {
|
|
4
4
|
clearAll: () => void;
|
|
5
|
-
closeTop: () => void;
|
|
6
5
|
close: (id: string) => void;
|
|
7
6
|
openBottomSheet: (content: React.ReactElement, options?: {
|
|
8
7
|
id?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBottomSheetManager.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAuB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"useBottomSheetManager.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAuB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAMzE,eAAO,MAAM,qBAAqB;;gBAwEzB,MAAM;+BAjDA,KAAK,CAAC,YAAY,YAClB;QACP,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,QAAQ,CAAC;KACjB;;;;;;;;;;;CA6DN,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;AAG7B,wBAAgB,mBAAmB,IAAI;IACrC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B,CAgCA"}
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import { useBottomSheetStore, type OpenMode } from './bottomSheet.store';
|
|
|
4
4
|
import { useMaybeBottomSheetManagerContext } from './BottomSheetManager.provider';
|
|
5
5
|
import { sheetRefs } from './refsMap';
|
|
6
6
|
import type { BottomSheetMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
|
|
7
|
+
import { shallow } from 'zustand/shallow';
|
|
7
8
|
|
|
8
9
|
export const useBottomSheetManager = () => {
|
|
9
10
|
const bottomSheetManagerContext = useMaybeBottomSheetManagerContext();
|
|
@@ -12,17 +13,19 @@ export const useBottomSheetManager = () => {
|
|
|
12
13
|
pushBottomSheet,
|
|
13
14
|
replaceBottomSheet,
|
|
14
15
|
switchBottomSheet,
|
|
15
|
-
stack,
|
|
16
16
|
startClosing,
|
|
17
17
|
storeClearAll,
|
|
18
|
-
} = useBottomSheetStore(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
} = useBottomSheetStore(
|
|
19
|
+
(store) => ({
|
|
20
|
+
storeClearAll: store.clearAll,
|
|
21
|
+
replaceBottomSheet: store.replace,
|
|
22
|
+
pushBottomSheet: store.push,
|
|
23
|
+
switchBottomSheet: store.switch,
|
|
24
|
+
stack: store.stack,
|
|
25
|
+
startClosing: store.startClosing,
|
|
26
|
+
}),
|
|
27
|
+
shallow
|
|
28
|
+
);
|
|
26
29
|
|
|
27
30
|
const openBottomSheet = useCallback(
|
|
28
31
|
(
|
|
@@ -74,13 +77,6 @@ export const useBottomSheetManager = () => {
|
|
|
74
77
|
]
|
|
75
78
|
);
|
|
76
79
|
|
|
77
|
-
const closeTop = useCallback(() => {
|
|
78
|
-
const top = stack.at(-1);
|
|
79
|
-
if (top) {
|
|
80
|
-
startClosing(top.id);
|
|
81
|
-
}
|
|
82
|
-
}, [stack, startClosing]);
|
|
83
|
-
|
|
84
80
|
const close = useCallback(
|
|
85
81
|
(id: string) => {
|
|
86
82
|
startClosing(id);
|
|
@@ -94,7 +90,6 @@ export const useBottomSheetManager = () => {
|
|
|
94
90
|
|
|
95
91
|
return {
|
|
96
92
|
clearAll,
|
|
97
|
-
closeTop,
|
|
98
93
|
close,
|
|
99
94
|
openBottomSheet,
|
|
100
95
|
pushBottomSheet,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
1
|
+
import { useCallback, useMemo } 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';
|
|
7
8
|
|
|
8
9
|
export function useBottomSheetState(): {
|
|
9
10
|
bottomSheetState: BottomSheetState;
|
|
@@ -11,13 +12,18 @@ export function useBottomSheetState(): {
|
|
|
11
12
|
closeBottomSheet: () => void;
|
|
12
13
|
} {
|
|
13
14
|
const context = useMaybeBottomSheetContext();
|
|
14
|
-
const { bottomSheetsStack, startClosing } = useBottomSheetStore(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const { bottomSheetsStack, startClosing } = useBottomSheetStore(
|
|
16
|
+
(store) => ({
|
|
17
|
+
bottomSheetsStack: store.stack,
|
|
18
|
+
startClosing: store.startClosing,
|
|
19
|
+
}),
|
|
20
|
+
shallow
|
|
21
|
+
);
|
|
18
22
|
|
|
19
|
-
const bottomSheetState =
|
|
20
|
-
(
|
|
23
|
+
const bottomSheetState = useMemo(
|
|
24
|
+
() =>
|
|
25
|
+
bottomSheetsStack.find((bottomSheet) => bottomSheet.id === context?.id),
|
|
26
|
+
[bottomSheetsStack, context?.id]
|
|
21
27
|
);
|
|
22
28
|
|
|
23
29
|
if (!bottomSheetState) {
|