expo-router 6.1.0-canary-20251008-6acbc1c → 6.1.0-canary-20251008-f2d1b4a
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/build/ExpoRoot.d.ts.map +1 -1
- package/build/ExpoRoot.js +1 -4
- package/build/ExpoRoot.js.map +1 -1
- package/build/getRoutesCore.d.ts +1 -0
- package/build/getRoutesCore.d.ts.map +1 -1
- package/build/getRoutesCore.js.map +1 -1
- package/build/getServerManifest.d.ts +9 -1
- package/build/getServerManifest.d.ts.map +1 -1
- package/build/getServerManifest.js +4 -1
- package/build/getServerManifest.js.map +1 -1
- package/build/modal/web/ModalStack.d.ts.map +1 -1
- package/build/modal/web/ModalStack.js +17 -1
- package/build/modal/web/ModalStack.js.map +1 -1
- package/build/native-tabs/NativeBottomTabs/NativeTabTrigger.d.ts.map +1 -1
- package/build/native-tabs/NativeBottomTabs/NativeTabTrigger.js +5 -0
- package/build/native-tabs/NativeBottomTabs/NativeTabTrigger.js.map +1 -1
- package/build/native-tabs/common/elements.d.ts +59 -1
- package/build/native-tabs/common/elements.d.ts.map +1 -1
- package/build/native-tabs/common/elements.js.map +1 -1
- package/build/renderRootComponent.d.ts.map +1 -1
- package/build/renderRootComponent.js +2 -2
- package/build/renderRootComponent.js.map +1 -1
- package/build/routes-manifest.js +1 -1
- package/build/routes-manifest.js.map +1 -1
- package/package.json +9 -9
- package/plugin/build/index.d.ts +2 -0
- package/plugin/options.json +17 -0
- package/plugin/src/index.ts +2 -0
- package/build/modal/Modal.d.ts +0 -95
- package/build/modal/Modal.d.ts.map +0 -1
- package/build/modal/Modal.js +0 -116
- package/build/modal/Modal.js.map +0 -1
- package/build/modal/ModalComponent.d.ts +0 -7
- package/build/modal/ModalComponent.d.ts.map +0 -1
- package/build/modal/ModalComponent.js +0 -10
- package/build/modal/ModalComponent.js.map +0 -1
- package/build/modal/ModalContext.d.ts +0 -15
- package/build/modal/ModalContext.d.ts.map +0 -1
- package/build/modal/ModalContext.js +0 -90
- package/build/modal/ModalContext.js.map +0 -1
- package/build/modal/ModalsRenderer.d.ts +0 -3
- package/build/modal/ModalsRenderer.d.ts.map +0 -1
- package/build/modal/ModalsRenderer.js +0 -47
- package/build/modal/ModalsRenderer.js.map +0 -1
- package/build/modal/ModalsRenderer.web.d.ts +0 -3
- package/build/modal/ModalsRenderer.web.d.ts.map +0 -1
- package/build/modal/ModalsRenderer.web.js +0 -37
- package/build/modal/ModalsRenderer.web.js.map +0 -1
- package/build/modal/types.d.ts +0 -19
- package/build/modal/types.d.ts.map +0 -1
- package/build/modal/types.js +0 -3
- package/build/modal/types.js.map +0 -1
- package/build/modal/utils.d.ts +0 -7
- package/build/modal/utils.d.ts.map +0 -1
- package/build/modal/utils.js +0 -60
- package/build/modal/utils.js.map +0 -1
package/build/modal/Modal.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Modal = Modal;
|
|
5
|
-
const non_secure_1 = require("nanoid/non-secure");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const react_native_1 = require("react-native");
|
|
8
|
-
const ModalContext_1 = require("./ModalContext");
|
|
9
|
-
const useNavigation_1 = require("../useNavigation");
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
/**
|
|
12
|
-
* A standalone modal component that can be used in Expo Router apps.
|
|
13
|
-
* It always renders on top of the application's content.
|
|
14
|
-
* Internally, the modal is rendered as a `Stack.Screen`, with the presentation style determined by the `presentationStyle` prop.
|
|
15
|
-
*
|
|
16
|
-
* **Props should be set before the modal is opened. Changes to the props will take effect after the modal is reopened.**
|
|
17
|
-
*
|
|
18
|
-
* This component is not linkable. If you need to link to a modal, use `<Stack.Screen options={{ presentationStyle: "modal" }} />` instead.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```tsx
|
|
22
|
-
* import { Modal } from 'expo-router';
|
|
23
|
-
*
|
|
24
|
-
* function Page() {
|
|
25
|
-
* const [modalVisible, setModalVisible] = useState(false);
|
|
26
|
-
* return (
|
|
27
|
-
* <Modal
|
|
28
|
-
* visible={modalVisible}
|
|
29
|
-
* onClose={() => setModalVisible(false)}
|
|
30
|
-
* >
|
|
31
|
-
* <Text>Hello World</Text>
|
|
32
|
-
* </Modal>
|
|
33
|
-
* );
|
|
34
|
-
* }
|
|
35
|
-
*/
|
|
36
|
-
function Modal(props) {
|
|
37
|
-
const { children, visible, onClose, onShow, animationType, presentationStyle, transparent, detents, closeOnNavigation, ...viewProps } = props;
|
|
38
|
-
const { openModal, updateModal, closeModal, addEventListener } = (0, ModalContext_1.useModalContext)();
|
|
39
|
-
const [currentModalId, setCurrentModalId] = (0, react_1.useState)();
|
|
40
|
-
const navigation = (0, useNavigation_1.useNavigation)();
|
|
41
|
-
(0, react_1.useEffect)(() => {
|
|
42
|
-
if (!(0, utils_1.areDetentsValid)(detents)) {
|
|
43
|
-
throw new Error(`Invalid detents provided to Modal: ${JSON.stringify(detents)}`);
|
|
44
|
-
}
|
|
45
|
-
}, [detents]);
|
|
46
|
-
(0, react_1.useEffect)(() => {
|
|
47
|
-
if (__DEV__ &&
|
|
48
|
-
presentationStyle === 'formSheet' &&
|
|
49
|
-
detents !== 'fitToContents' &&
|
|
50
|
-
process.env.EXPO_OS === 'ios' &&
|
|
51
|
-
react_native_1.StyleSheet.flatten(props.style)?.flex) {
|
|
52
|
-
console.warn(
|
|
53
|
-
// TODO: ENG-16230: Add warning link to documentation
|
|
54
|
-
'The `formSheet` presentation style does not support flex styles on iOS. Consider using a fixed height view or scroll view with `fitToContents` detent instead. See ');
|
|
55
|
-
}
|
|
56
|
-
}, [props.style, presentationStyle, detents]);
|
|
57
|
-
(0, react_1.useEffect)(() => {
|
|
58
|
-
if (visible) {
|
|
59
|
-
const newId = (0, non_secure_1.nanoid)();
|
|
60
|
-
openModal({
|
|
61
|
-
animationType,
|
|
62
|
-
presentationStyle,
|
|
63
|
-
transparent,
|
|
64
|
-
viewProps,
|
|
65
|
-
component: children,
|
|
66
|
-
uniqueId: newId,
|
|
67
|
-
parentNavigationProp: navigation,
|
|
68
|
-
detents: detents ?? (presentationStyle === 'formSheet' ? 'fitToContents' : undefined),
|
|
69
|
-
});
|
|
70
|
-
setCurrentModalId(newId);
|
|
71
|
-
return () => {
|
|
72
|
-
closeModal(newId);
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return () => { };
|
|
76
|
-
}, [visible]);
|
|
77
|
-
(0, react_1.useEffect)(() => {
|
|
78
|
-
if (navigation.isFocused()) {
|
|
79
|
-
return navigation.addListener('blur', () => {
|
|
80
|
-
if (currentModalId && closeOnNavigation) {
|
|
81
|
-
closeModal(currentModalId);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
return () => { };
|
|
86
|
-
}, [navigation, closeModal, currentModalId, closeOnNavigation]);
|
|
87
|
-
(0, react_1.useEffect)(() => {
|
|
88
|
-
if (currentModalId && visible) {
|
|
89
|
-
updateModal(currentModalId, {
|
|
90
|
-
component: children,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}, [children]);
|
|
94
|
-
(0, react_1.useEffect)(() => {
|
|
95
|
-
if (currentModalId) {
|
|
96
|
-
const unsubscribeShow = addEventListener('show', (id) => {
|
|
97
|
-
if (id === currentModalId) {
|
|
98
|
-
onShow?.();
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
const unsubscribeClose = addEventListener('close', (id) => {
|
|
102
|
-
if (id === currentModalId) {
|
|
103
|
-
onClose?.();
|
|
104
|
-
setCurrentModalId(undefined);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
return () => {
|
|
108
|
-
unsubscribeShow();
|
|
109
|
-
unsubscribeClose();
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
return () => { };
|
|
113
|
-
}, [currentModalId, addEventListener, onClose, onShow]);
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=Modal.js.map
|
package/build/modal/Modal.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/modal/Modal.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAwGb,sBAgGC;AArMD,kDAA2C;AAC3C,iCAA4C;AAC5C,+CAAqD;AAGrD,iDAAmE;AACnE,oDAAiD;AACjD,mCAA0C;AAqE1C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,KAAK,CAAC,KAAiB;IACrC,MAAM,EACJ,QAAQ,EACR,OAAO,EACP,OAAO,EACP,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,iBAAiB,EACjB,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IACV,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,IAAA,8BAAe,GAAE,CAAC;IACnF,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,GAAsB,CAAC;IAC3E,MAAM,UAAU,GAAG,IAAA,6BAAa,GAAiC,CAAC;IAClE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,IAAA,uBAAe,EAAC,OAAO,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACnF,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACd,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IACE,OAAO;YACP,iBAAiB,KAAK,WAAW;YACjC,OAAO,KAAK,eAAe;YAC3B,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,KAAK;YAC7B,yBAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAA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C,GAAG,EAAE;QACb,IAAI,cAAc,IAAI,OAAO,EAAE,CAAC;YAC9B,WAAW,CAAC,cAAc,EAAE;gBAC1B,SAAS,EAAE,QAAQ;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,cAAc,EAAE,CAAC;YACnB,MAAM,eAAe,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE;gBACtD,IAAI,EAAE,KAAK,cAAc,EAAE,CAAC;oBAC1B,MAAM,EAAE,EAAE,CAAC;gBACb,CAAC;YACH,CAAC,CAAC,CAAC;YACH,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE;gBACxD,IAAI,EAAE,KAAK,cAAc,EAAE,CAAC;oBAC1B,OAAO,EAAE,EAAE,CAAC;oBACZ,iBAAiB,CAAC,SAAS,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC,CAAC,CAAC;YACH,OAAO,GAAG,EAAE;gBACV,eAAe,EAAE,CAAC;gBAClB,gBAAgB,EAAE,CAAC;YACrB,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC,EAAE,CAAC,cAAc,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["'use client';\n\nimport { type NavigationProp, type ParamListBase } from '@react-navigation/native';\nimport { nanoid } from 'nanoid/non-secure';\nimport { useEffect, useState } from 'react';\nimport { StyleSheet, ViewProps } from 'react-native';\nimport { type ScreenProps } from 'react-native-screens';\n\nimport { useModalContext, type ModalConfig } from './ModalContext';\nimport { useNavigation } from '../useNavigation';\nimport { areDetentsValid } from './utils';\n\nexport interface ModalProps extends ViewProps {\n /**\n * The content of the modal.\n */\n children?: React.ReactNode;\n /**\n * Whether the modal is visible or not.\n * When set to `true`, the modal will be opened.\n * When set to `false`, the modal will be closed.\n */\n visible: boolean;\n /**\n * Callback that is called after modal is closed.\n * This is called when the modal is closed programmatically or when the user dismisses it.\n */\n onClose?: () => void;\n /**\n * Callback that is called after modal is shown.\n */\n onShow?: () => void;\n /**\n * The animation type for the modal.\n * This can be one of 'none', 'slide', or 'fade'.\n */\n animationType?: ModalConfig['animationType'];\n /**\n * The presentation style for the modal.\n * This can be one of 'fullScreen', 'pageSheet', 'formSheet', or 'overFullScreen'.\n * - `fullScreen`: The modal covers the entire screen. When `transparent` is set to `true`, it will fallback to `overFullScreen`.\n * - `pageSheet`: The modal is presented as a page sheet on iOS. Defaults to `fullScreen` on Android.\n * - `formSheet`: The modal is presented as a form sheet.\n * - `overFullScreen`: The modal is presented over the full screen, allowing interaction with the underlying content.\n *\n * @default 'fullScreen'\n */\n presentationStyle?: ModalConfig['presentationStyle'];\n /**\n * Whether the modal should be rendered as a transparent overlay.\n * This will render the modal without a background, allowing the content behind it to be visible.\n *\n * On Android, this will fallback to `overFullScreen` presentation style.\n */\n transparent?: boolean;\n /**\n * See {@link ScreenProps[\"sheetAllowedDetents\"]}.\n *\n * Describes heights where a sheet can rest.\n * Works only when `presentation` is set to `formSheet`.\n *\n * Heights should be described as fraction (a number from `[0, 1]` interval) of screen height / maximum detent height.\n * You can pass an array of ascending values each defining allowed sheet detent. iOS accepts any number of detents,\n * while **Android is limited to three**.\n *\n * @default 'fitToContents'\n */\n detents?: ModalConfig['detents'];\n /**\n * Determines whether the modal should close when navigating away from the screen that opened it.\n *\n * If set to `true`, the modal will close when the user navigates to a different screen.\n *\n * If set to `false`, the modal will remain open when pushing a new screen.\n * However, it will still close when navigating back or replacing the current screen.\n */\n closeOnNavigation?: boolean;\n}\n\n/**\n * A standalone modal component that can be used in Expo Router apps.\n * It always renders on top of the application's content.\n * Internally, the modal is rendered as a `Stack.Screen`, with the presentation style determined by the `presentationStyle` prop.\n *\n * **Props should be set before the modal is opened. Changes to the props will take effect after the modal is reopened.**\n *\n * This component is not linkable. If you need to link to a modal, use `<Stack.Screen options={{ presentationStyle: \"modal\" }} />` instead.\n *\n * @example\n * ```tsx\n * import { Modal } from 'expo-router';\n *\n * function Page() {\n * const [modalVisible, setModalVisible] = useState(false);\n * return (\n * <Modal\n * visible={modalVisible}\n * onClose={() => setModalVisible(false)}\n * >\n * <Text>Hello World</Text>\n * </Modal>\n * );\n * }\n */\nexport function Modal(props: ModalProps) {\n const {\n children,\n visible,\n onClose,\n onShow,\n animationType,\n presentationStyle,\n transparent,\n detents,\n closeOnNavigation,\n ...viewProps\n } = props;\n const { openModal, updateModal, closeModal, addEventListener } = useModalContext();\n const [currentModalId, setCurrentModalId] = useState<string | undefined>();\n const navigation = useNavigation<NavigationProp<ParamListBase>>();\n useEffect(() => {\n if (!areDetentsValid(detents)) {\n throw new Error(`Invalid detents provided to Modal: ${JSON.stringify(detents)}`);\n }\n }, [detents]);\n useEffect(() => {\n if (\n __DEV__ &&\n presentationStyle === 'formSheet' &&\n detents !== 'fitToContents' &&\n process.env.EXPO_OS === 'ios' &&\n StyleSheet.flatten(props.style)?.flex\n ) {\n console.warn(\n // TODO: ENG-16230: Add warning link to documentation\n 'The `formSheet` presentation style does not support flex styles on iOS. Consider using a fixed height view or scroll view with `fitToContents` detent instead. See '\n );\n }\n }, [props.style, presentationStyle, detents]);\n useEffect(() => {\n if (visible) {\n const newId = nanoid();\n openModal({\n animationType,\n presentationStyle,\n transparent,\n viewProps,\n component: children,\n uniqueId: newId,\n parentNavigationProp: navigation,\n detents: detents ?? (presentationStyle === 'formSheet' ? 'fitToContents' : undefined),\n });\n setCurrentModalId(newId);\n return () => {\n closeModal(newId);\n };\n }\n return () => {};\n }, [visible]);\n\n useEffect(() => {\n if (navigation.isFocused()) {\n return navigation.addListener('blur', () => {\n if (currentModalId && closeOnNavigation) {\n closeModal(currentModalId);\n }\n });\n }\n return () => {};\n }, [navigation, closeModal, currentModalId, closeOnNavigation]);\n\n useEffect(() => {\n if (currentModalId && visible) {\n updateModal(currentModalId, {\n component: children,\n });\n }\n }, [children]);\n\n useEffect(() => {\n if (currentModalId) {\n const unsubscribeShow = addEventListener('show', (id) => {\n if (id === currentModalId) {\n onShow?.();\n }\n });\n const unsubscribeClose = addEventListener('close', (id) => {\n if (id === currentModalId) {\n onClose?.();\n setCurrentModalId(undefined);\n }\n });\n return () => {\n unsubscribeShow();\n unsubscribeClose();\n };\n }\n return () => {};\n }, [currentModalId, addEventListener, onClose, onShow]);\n return null;\n}\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type ModalConfig } from './ModalContext';
|
|
2
|
-
interface ModalComponentProps {
|
|
3
|
-
modalConfig: ModalConfig;
|
|
4
|
-
}
|
|
5
|
-
export declare function ModalComponent({ modalConfig }: ModalComponentProps): import("react").JSX.Element;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=ModalComponent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalComponent.d.ts","sourceRoot":"","sources":["../../src/modal/ModalComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,UAAU,mBAAmB;IAC3B,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED,wBAAgB,cAAc,CAAC,EAAE,WAAW,EAAE,EAAE,mBAAmB,+BAKlE"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ModalComponent = ModalComponent;
|
|
4
|
-
const native_1 = require("@react-navigation/native");
|
|
5
|
-
function ModalComponent({ modalConfig }) {
|
|
6
|
-
const component = modalConfig.component;
|
|
7
|
-
const navigationProp = modalConfig.parentNavigationProp;
|
|
8
|
-
return <native_1.NavigationContext value={navigationProp}>{component}</native_1.NavigationContext>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=ModalComponent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalComponent.js","sourceRoot":"","sources":["../../src/modal/ModalComponent.tsx"],"names":[],"mappings":";;AAQA,wCAKC;AAbD,qDAA6D;AAQ7D,SAAgB,cAAc,CAAC,EAAE,WAAW,EAAuB;IACjE,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;IACxC,MAAM,cAAc,GAAG,WAAW,CAAC,oBAAoB,CAAC;IAExD,OAAO,CAAC,0BAAiB,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,0BAAiB,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import { NavigationContext } from '@react-navigation/native';\n\nimport { type ModalConfig } from './ModalContext';\n\ninterface ModalComponentProps {\n modalConfig: ModalConfig;\n}\n\nexport function ModalComponent({ modalConfig }: ModalComponentProps) {\n const component = modalConfig.component;\n const navigationProp = modalConfig.parentNavigationProp;\n\n return <NavigationContext value={navigationProp}>{component}</NavigationContext>;\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type PropsWithChildren } from 'react';
|
|
2
|
-
import { type ModalConfig } from './types';
|
|
3
|
-
export { type ModalConfig };
|
|
4
|
-
declare const ALLOWED_EVENT_TYPE_LISTENERS: readonly ["close", "show"];
|
|
5
|
-
type AllowedEventTypeListeners = (typeof ALLOWED_EVENT_TYPE_LISTENERS)[number];
|
|
6
|
-
export interface ModalContextType {
|
|
7
|
-
modalConfigs: ModalConfig[];
|
|
8
|
-
openModal: (config: ModalConfig) => void;
|
|
9
|
-
updateModal: (id: string, config: Omit<Partial<ModalConfig>, 'uniqueId'>) => void;
|
|
10
|
-
closeModal: (id: string) => void;
|
|
11
|
-
addEventListener: (type: AllowedEventTypeListeners, callback: (id: string) => void) => () => void;
|
|
12
|
-
}
|
|
13
|
-
export declare const ModalContextProvider: ({ children }: PropsWithChildren) => import("react").JSX.Element;
|
|
14
|
-
export declare const useModalContext: () => ModalContextType;
|
|
15
|
-
//# sourceMappingURL=ModalContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalContext.d.ts","sourceRoot":"","sources":["../../src/modal/ModalContext.tsx"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,iBAAiB,EACvB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,KAAK,WAAW,EAAE,CAAC;AAE5B,QAAA,MAAM,4BAA4B,4BAA6B,CAAC;AAChE,KAAK,yBAAyB,GAAG,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/E,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;IAClF,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,gBAAgB,EAAE,CAAC,IAAI,EAAE,yBAAyB,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CACnG;AAID,eAAO,MAAM,oBAAoB,GAAI,cAAc,iBAAiB,gCA0FnE,CAAC;AAEF,eAAO,MAAM,eAAe,wBAM3B,CAAC"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.useModalContext = exports.ModalContextProvider = void 0;
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const ModalsRenderer_1 = require("./ModalsRenderer");
|
|
7
|
-
const ALLOWED_EVENT_TYPE_LISTENERS = ['close', 'show'];
|
|
8
|
-
const ModalContext = (0, react_1.createContext)(undefined);
|
|
9
|
-
const ModalContextProvider = ({ children }) => {
|
|
10
|
-
const [modalConfigs, setModalConfigs] = (0, react_1.useState)([]);
|
|
11
|
-
const eventListeners = (0, react_1.useRef)({
|
|
12
|
-
close: new Set(),
|
|
13
|
-
show: new Set(),
|
|
14
|
-
});
|
|
15
|
-
const prevModalConfigs = (0, react_1.useRef)([]);
|
|
16
|
-
(0, react_1.useEffect)(() => {
|
|
17
|
-
if (prevModalConfigs.current !== modalConfigs) {
|
|
18
|
-
prevModalConfigs.current.forEach((config) => {
|
|
19
|
-
if (!modalConfigs.find((c) => c.uniqueId === config.uniqueId)) {
|
|
20
|
-
emitCloseEvent(config.uniqueId);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
prevModalConfigs.current = modalConfigs;
|
|
24
|
-
}
|
|
25
|
-
}, [modalConfigs]);
|
|
26
|
-
const openModal = (0, react_1.useCallback)((config) => {
|
|
27
|
-
setModalConfigs((prev) => [...prev, config]);
|
|
28
|
-
}, []);
|
|
29
|
-
const updateModal = (0, react_1.useCallback)((id, config) => {
|
|
30
|
-
setModalConfigs((prev) => {
|
|
31
|
-
const index = prev.findIndex((c) => c.uniqueId === id);
|
|
32
|
-
if (index >= 0) {
|
|
33
|
-
const updatedConfigs = [...prev];
|
|
34
|
-
updatedConfigs[index] = { ...updatedConfigs[index], ...config };
|
|
35
|
-
return updatedConfigs;
|
|
36
|
-
}
|
|
37
|
-
return prev;
|
|
38
|
-
});
|
|
39
|
-
}, []);
|
|
40
|
-
const emitCloseEvent = (0, react_1.useCallback)((id) => {
|
|
41
|
-
eventListeners.current.close.forEach((callback) => callback(id));
|
|
42
|
-
}, []);
|
|
43
|
-
const emitShowEvent = (0, react_1.useCallback)((id) => {
|
|
44
|
-
eventListeners.current.show.forEach((callback) => callback(id));
|
|
45
|
-
}, []);
|
|
46
|
-
const closeModal = (0, react_1.useCallback)((id) => {
|
|
47
|
-
setModalConfigs((prev) => {
|
|
48
|
-
const modalIndex = prev.findIndex((config) => config.uniqueId === id);
|
|
49
|
-
if (modalIndex >= 0) {
|
|
50
|
-
return prev.filter((_, index) => index < modalIndex);
|
|
51
|
-
}
|
|
52
|
-
return prev;
|
|
53
|
-
});
|
|
54
|
-
}, []);
|
|
55
|
-
const addEventListener = (0, react_1.useCallback)((type, callback) => {
|
|
56
|
-
if (!ALLOWED_EVENT_TYPE_LISTENERS.includes(type))
|
|
57
|
-
return () => { };
|
|
58
|
-
if (!callback) {
|
|
59
|
-
console.warn('Passing undefined as a callback to addEventListener is forbidden');
|
|
60
|
-
return () => { };
|
|
61
|
-
}
|
|
62
|
-
eventListeners.current[type].add(callback);
|
|
63
|
-
return () => {
|
|
64
|
-
eventListeners.current[type].delete(callback);
|
|
65
|
-
};
|
|
66
|
-
}, []);
|
|
67
|
-
return (<ModalContext.Provider value={{
|
|
68
|
-
modalConfigs,
|
|
69
|
-
openModal,
|
|
70
|
-
closeModal,
|
|
71
|
-
updateModal,
|
|
72
|
-
addEventListener,
|
|
73
|
-
}}>
|
|
74
|
-
<ModalsRenderer_1.ModalsRenderer modalConfigs={modalConfigs} onDismissed={(id) => {
|
|
75
|
-
closeModal(id);
|
|
76
|
-
}} onShow={emitShowEvent}>
|
|
77
|
-
{children}
|
|
78
|
-
</ModalsRenderer_1.ModalsRenderer>
|
|
79
|
-
</ModalContext.Provider>);
|
|
80
|
-
};
|
|
81
|
-
exports.ModalContextProvider = ModalContextProvider;
|
|
82
|
-
const useModalContext = () => {
|
|
83
|
-
const context = (0, react_1.use)(ModalContext);
|
|
84
|
-
if (!context) {
|
|
85
|
-
throw new Error('useModalContext must be used within a ModalContextProvider');
|
|
86
|
-
}
|
|
87
|
-
return context;
|
|
88
|
-
};
|
|
89
|
-
exports.useModalContext = useModalContext;
|
|
90
|
-
//# sourceMappingURL=ModalContext.js.map
|
|
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,aAAa,CAAC,CACtB;QAAA,CAAC,QAAQ,CACX;MAAA,EAAE,+BAAc,CAClB;IAAA,EAAE,YAAY,CAAC,QAAQ,CAAC,CACzB,CAAC;AACJ,CAAC,CAAC;AA1FW,QAAA,oBAAoB,wBA0F/B;AAEK,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,OAAO,GAAG,IAAA,WAAG,EAAC,YAAY,CAAC,CAAC;IAClC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AANW,QAAA,eAAe,mBAM1B","sourcesContent":["'use client';\n\nimport {\n createContext,\n use,\n useCallback,\n useEffect,\n useRef,\n useState,\n type PropsWithChildren,\n} from 'react';\n\nimport { ModalsRenderer } from './ModalsRenderer';\nimport { type ModalConfig } from './types';\n\nexport { type ModalConfig };\n\nconst ALLOWED_EVENT_TYPE_LISTENERS = ['close', 'show'] as const;\ntype AllowedEventTypeListeners = (typeof ALLOWED_EVENT_TYPE_LISTENERS)[number];\n\nexport interface ModalContextType {\n modalConfigs: ModalConfig[];\n openModal: (config: ModalConfig) => void;\n updateModal: (id: string, config: Omit<Partial<ModalConfig>, 'uniqueId'>) => void;\n closeModal: (id: string) => void;\n addEventListener: (type: AllowedEventTypeListeners, callback: (id: string) => void) => () => void;\n}\n\nconst ModalContext = createContext<ModalContextType | undefined>(undefined);\n\nexport const ModalContextProvider = ({ children }: PropsWithChildren) => {\n const [modalConfigs, setModalConfigs] = useState<ModalConfig[]>([]);\n const eventListeners = useRef<Record<AllowedEventTypeListeners, Set<(id: string) => void>>>({\n close: new Set(),\n show: new Set(),\n });\n const prevModalConfigs = useRef<ModalConfig[]>([]);\n\n useEffect(() => {\n if (prevModalConfigs.current !== modalConfigs) {\n prevModalConfigs.current.forEach((config) => {\n if (!modalConfigs.find((c) => c.uniqueId === config.uniqueId)) {\n emitCloseEvent(config.uniqueId);\n }\n });\n prevModalConfigs.current = modalConfigs;\n }\n }, [modalConfigs]);\n\n const openModal = useCallback((config: ModalConfig) => {\n setModalConfigs((prev) => [...prev, config]);\n }, []);\n\n const updateModal = useCallback((id: string, config: Omit<Partial<ModalConfig>, 'uniqueId'>) => {\n setModalConfigs((prev) => {\n const index = prev.findIndex((c) => c.uniqueId === id);\n if (index >= 0) {\n const updatedConfigs = [...prev];\n updatedConfigs[index] = { ...updatedConfigs[index], ...config };\n return updatedConfigs;\n }\n return prev;\n });\n }, []);\n\n const emitCloseEvent = useCallback((id: string) => {\n eventListeners.current.close.forEach((callback) => callback(id));\n }, []);\n\n const emitShowEvent = useCallback((id: string) => {\n eventListeners.current.show.forEach((callback) => callback(id));\n }, []);\n\n const closeModal = useCallback((id: string) => {\n setModalConfigs((prev) => {\n const modalIndex = prev.findIndex((config) => config.uniqueId === id);\n if (modalIndex >= 0) {\n return prev.filter((_, index) => index < modalIndex);\n }\n return prev;\n });\n }, []);\n\n const addEventListener = useCallback(\n (type: AllowedEventTypeListeners, callback: (id: string) => void) => {\n if (!ALLOWED_EVENT_TYPE_LISTENERS.includes(type)) return () => {};\n\n if (!callback) {\n console.warn('Passing undefined as a callback to addEventListener is forbidden');\n return () => {};\n }\n\n eventListeners.current[type].add(callback);\n\n return () => {\n eventListeners.current[type].delete(callback);\n };\n },\n []\n );\n\n return (\n <ModalContext.Provider\n value={{\n modalConfigs,\n openModal,\n closeModal,\n updateModal,\n addEventListener,\n }}>\n <ModalsRenderer\n modalConfigs={modalConfigs}\n onDismissed={(id) => {\n closeModal(id);\n }}\n onShow={emitShowEvent}>\n {children}\n </ModalsRenderer>\n </ModalContext.Provider>\n );\n};\n\nexport const useModalContext = () => {\n const context = use(ModalContext);\n if (!context) {\n throw new Error('useModalContext must be used within a ModalContextProvider');\n }\n return context;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalsRenderer.d.ts","sourceRoot":"","sources":["../../src/modal/ModalsRenderer.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAGnD,eAAO,MAAM,cAAc,GAAI,kDAK5B,mBAAmB,gCAmDrB,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ModalsRenderer = void 0;
|
|
5
|
-
const non_secure_1 = require("nanoid/non-secure");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const react_native_1 = require("react-native");
|
|
8
|
-
const react_native_screens_1 = require("react-native-screens");
|
|
9
|
-
const ModalComponent_1 = require("./ModalComponent");
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
const ModalsRenderer = ({ children, modalConfigs, onDismissed, onShow, }) => {
|
|
12
|
-
const rootId = (0, react_1.useRef)((0, non_secure_1.nanoid)());
|
|
13
|
-
return (<react_native_screens_1.ScreenStack style={styles.stackContainer}>
|
|
14
|
-
<react_native_screens_1.ScreenStackItem screenId={rootId.current} activityState={2} style={react_native_1.StyleSheet.absoluteFill} headerConfig={{
|
|
15
|
-
hidden: true,
|
|
16
|
-
}}>
|
|
17
|
-
{children}
|
|
18
|
-
</react_native_screens_1.ScreenStackItem>
|
|
19
|
-
{modalConfigs.map((config) => (<react_native_screens_1.ScreenStackItem key={config.uniqueId} {...config.viewProps} screenId={`${rootId.current}${config.uniqueId}`} activityState={2} stackPresentation={(0, utils_1.getStackPresentationType)(config)} stackAnimation={(0, utils_1.getStackAnimationType)(config)} nativeBackButtonDismissalEnabled headerConfig={{
|
|
20
|
-
hidden: true,
|
|
21
|
-
}} contentStyle={[
|
|
22
|
-
{
|
|
23
|
-
flex: config.presentationStyle !== 'formSheet' ? 1 : undefined,
|
|
24
|
-
backgroundColor: config.transparent ? 'transparent' : 'white',
|
|
25
|
-
},
|
|
26
|
-
config.viewProps?.style,
|
|
27
|
-
]} sheetAllowedDetents={config.detents} style={[
|
|
28
|
-
react_native_1.StyleSheet.absoluteFill,
|
|
29
|
-
{
|
|
30
|
-
backgroundColor: config.transparent ? 'transparent' : 'white',
|
|
31
|
-
},
|
|
32
|
-
]} onDismissed={() => {
|
|
33
|
-
onDismissed?.(config.uniqueId);
|
|
34
|
-
}} onAppear={() => {
|
|
35
|
-
onShow?.(config.uniqueId);
|
|
36
|
-
}}>
|
|
37
|
-
<ModalComponent_1.ModalComponent modalConfig={config}/>
|
|
38
|
-
</react_native_screens_1.ScreenStackItem>))}
|
|
39
|
-
</react_native_screens_1.ScreenStack>);
|
|
40
|
-
};
|
|
41
|
-
exports.ModalsRenderer = ModalsRenderer;
|
|
42
|
-
const styles = react_native_1.StyleSheet.create({
|
|
43
|
-
stackContainer: {
|
|
44
|
-
flex: 1,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
//# sourceMappingURL=ModalsRenderer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalsRenderer.js","sourceRoot":"","sources":["../../src/modal/ModalsRenderer.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AAEb,kDAA2C;AAC3C,iCAA+B;AAC/B,+CAA0C;AAC1C,+DAAoE;AAEpE,qDAAkD;AAElD,mCAA0E;AAEnE,MAAM,cAAc,GAAG,CAAC,EAC7B,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,MAAM,GACc,EAAE,EAAE;IACxB,MAAM,MAAM,GAAG,IAAA,cAAM,EAAC,IAAA,mBAAM,GAAE,CAAC,CAAC;IAEhC,OAAO,CACL,CAAC,kCAAW,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CACxC;MAAA,CAAC,sCAAe,CACd,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CACzB,aAAa,CAAC,CAAC,CAAC,CAAC,CACjB,KAAK,CAAC,CAAC,yBAAU,CAAC,YAAY,CAAC,CA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AE;gBACb,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC5B,CAAC,CAAC,CACF;UAAA,CAAC,+BAAc,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,EACtC;QAAA,EAAE,sCAAe,CAAC,CACnB,CAAC,CACJ;IAAA,EAAE,kCAAW,CAAC,CACf,CAAC;AACJ,CAAC,CAAC;AAxDW,QAAA,cAAc,kBAwDzB;AAEF,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,cAAc,EAAE;QACd,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC","sourcesContent":["'use client';\n\nimport { nanoid } from 'nanoid/non-secure';\nimport { useRef } from 'react';\nimport { StyleSheet } from 'react-native';\nimport { ScreenStack, ScreenStackItem } from 'react-native-screens';\n\nimport { ModalComponent } from './ModalComponent';\nimport type { ModalsRendererProps } from './types';\nimport { getStackAnimationType, getStackPresentationType } from './utils';\n\nexport const ModalsRenderer = ({\n children,\n modalConfigs,\n onDismissed,\n onShow,\n}: ModalsRendererProps) => {\n const rootId = useRef(nanoid());\n\n return (\n <ScreenStack style={styles.stackContainer}>\n <ScreenStackItem\n screenId={rootId.current}\n activityState={2}\n style={StyleSheet.absoluteFill}\n headerConfig={{\n hidden: true,\n }}>\n {children}\n </ScreenStackItem>\n {modalConfigs.map((config) => (\n <ScreenStackItem\n key={config.uniqueId}\n {...config.viewProps}\n screenId={`${rootId.current}${config.uniqueId}`}\n activityState={2}\n stackPresentation={getStackPresentationType(config)}\n stackAnimation={getStackAnimationType(config)}\n nativeBackButtonDismissalEnabled\n headerConfig={{\n hidden: true,\n }}\n contentStyle={[\n {\n flex: config.presentationStyle !== 'formSheet' ? 1 : undefined,\n backgroundColor: config.transparent ? 'transparent' : 'white',\n },\n config.viewProps?.style,\n ]}\n sheetAllowedDetents={config.detents}\n style={[\n StyleSheet.absoluteFill,\n {\n backgroundColor: config.transparent ? 'transparent' : 'white',\n },\n ]}\n onDismissed={() => {\n onDismissed?.(config.uniqueId);\n }}\n onAppear={() => {\n onShow?.(config.uniqueId);\n }}>\n <ModalComponent modalConfig={config} />\n </ScreenStackItem>\n ))}\n </ScreenStack>\n );\n};\n\nconst styles = StyleSheet.create({\n stackContainer: {\n flex: 1,\n },\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalsRenderer.web.d.ts","sourceRoot":"","sources":["../../src/modal/ModalsRenderer.web.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAe,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAMhE,eAAO,MAAM,cAAc,GAAI,kDAK5B,mBAAmB,gCAarB,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ModalsRenderer = void 0;
|
|
5
|
-
const native_1 = require("@react-navigation/native");
|
|
6
|
-
const react_native_1 = require("react-native");
|
|
7
|
-
const ModalComponent_1 = require("./ModalComponent");
|
|
8
|
-
const utils_1 = require("./utils");
|
|
9
|
-
const ModalStackRouteDrawer_1 = require("./web/ModalStackRouteDrawer");
|
|
10
|
-
const TransparentModalStackRouteDrawer_1 = require("./web/TransparentModalStackRouteDrawer");
|
|
11
|
-
const utils_2 = require("./web/utils");
|
|
12
|
-
const ModalsRenderer = ({ children, modalConfigs, onDismissed, onShow, }) => {
|
|
13
|
-
return (<div style={{ flex: 1, display: 'flex' }}>
|
|
14
|
-
{children}
|
|
15
|
-
{modalConfigs.map((config) => (<Modal key={config.uniqueId} config={config} onDismissed={() => onDismissed?.(config.uniqueId)}/>))}
|
|
16
|
-
</div>);
|
|
17
|
-
};
|
|
18
|
-
exports.ModalsRenderer = ModalsRenderer;
|
|
19
|
-
function Modal({ config, onDismissed }) {
|
|
20
|
-
const { colors } = (0, native_1.useTheme)();
|
|
21
|
-
const presentation = (0, utils_1.getStackPresentationType)(config);
|
|
22
|
-
const isTransparentModal = (0, utils_2.isTransparentModalPresentation)({ presentation });
|
|
23
|
-
const SelectedModalComponent = isTransparentModal
|
|
24
|
-
? TransparentModalStackRouteDrawer_1.TransparentModalStackRouteDrawer
|
|
25
|
-
: ModalStackRouteDrawer_1.ModalStackRouteDrawer;
|
|
26
|
-
return (<SelectedModalComponent routeKey={config.uniqueId} onDismiss={onDismissed} themeColors={colors} key={config.uniqueId} options={{
|
|
27
|
-
presentation,
|
|
28
|
-
animation: (0, utils_1.getStackAnimationType)(config),
|
|
29
|
-
headerShown: false,
|
|
30
|
-
sheetAllowedDetents: config.detents,
|
|
31
|
-
}} renderScreen={() => (<react_native_1.View style={{ flex: 1 }}>
|
|
32
|
-
<react_native_1.View {...config.viewProps} style={[{ flex: 1 }, config.viewProps?.style]}>
|
|
33
|
-
<ModalComponent_1.ModalComponent modalConfig={config}/>
|
|
34
|
-
</react_native_1.View>
|
|
35
|
-
</react_native_1.View>)}/>);
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=ModalsRenderer.web.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalsRenderer.web.js","sourceRoot":"","sources":["../../src/modal/ModalsRenderer.web.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AAEb,qDAAoD;AACpD,+CAAoC;AAEpC,qDAAkD;AAElD,mCAA0E;AAC1E,uEAAoE;AACpE,6FAA0F;AAC1F,uCAA6D;AAEtD,MAAM,cAAc,GAAG,CAAC,EAC7B,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,MAAM,GACc,EAAE,EAAE;IACxB,OAAO,CACL,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CACvC;MAAA,CAAC,QAAQ,CACT;MAAA,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC5B,CAAC,KAAK,CAC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,EAAE,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CACxE;YAAA,CAAC,+BAAc,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,EACtC;UAAA,EAAE,mBAAI,CACR;QAAA,EAAE,mBAAI,CAAC,CACR,CAAC,EACF,CACH,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { useTheme } from '@react-navigation/native';\nimport { View } from 'react-native';\n\nimport { ModalComponent } from './ModalComponent';\nimport type { ModalConfig, ModalsRendererProps } from './types';\nimport { getStackAnimationType, getStackPresentationType } from './utils';\nimport { ModalStackRouteDrawer } from './web/ModalStackRouteDrawer';\nimport { TransparentModalStackRouteDrawer } from './web/TransparentModalStackRouteDrawer';\nimport { isTransparentModalPresentation } from './web/utils';\n\nexport const ModalsRenderer = ({\n children,\n modalConfigs,\n onDismissed,\n onShow,\n}: ModalsRendererProps) => {\n return (\n <div style={{ flex: 1, display: 'flex' }}>\n {children}\n {modalConfigs.map((config) => (\n <Modal\n key={config.uniqueId}\n config={config}\n onDismissed={() => onDismissed?.(config.uniqueId)}\n />\n ))}\n </div>\n );\n};\n\ninterface ModalProps {\n config: ModalConfig;\n onDismissed: () => void;\n}\n\nfunction Modal({ config, onDismissed }: ModalProps) {\n const { colors } = useTheme();\n\n const presentation = getStackPresentationType(config);\n const isTransparentModal = isTransparentModalPresentation({ presentation });\n\n const SelectedModalComponent = isTransparentModal\n ? TransparentModalStackRouteDrawer\n : ModalStackRouteDrawer;\n\n return (\n <SelectedModalComponent\n routeKey={config.uniqueId}\n onDismiss={onDismissed}\n themeColors={colors}\n key={config.uniqueId}\n options={{\n presentation,\n animation: getStackAnimationType(config),\n headerShown: false,\n sheetAllowedDetents: config.detents,\n }}\n renderScreen={() => (\n <View style={{ flex: 1 }}>\n <View {...config.viewProps} style={[{ flex: 1 }, config.viewProps?.style]}>\n <ModalComponent modalConfig={config} />\n </View>\n </View>\n )}\n />\n );\n}\n"]}
|
package/build/modal/types.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { NavigationProp, ParamListBase } from '@react-navigation/native';
|
|
2
|
-
import { type ViewProps } from 'react-native';
|
|
3
|
-
export interface ModalConfig {
|
|
4
|
-
component: React.ReactNode;
|
|
5
|
-
parentNavigationProp: NavigationProp<ParamListBase>;
|
|
6
|
-
uniqueId: string;
|
|
7
|
-
animationType?: 'slide' | 'fade' | 'none';
|
|
8
|
-
presentationStyle?: 'fullScreen' | 'overFullScreen' | 'pageSheet' | 'formSheet';
|
|
9
|
-
transparent?: boolean;
|
|
10
|
-
viewProps?: ViewProps;
|
|
11
|
-
detents?: number[] | 'fitToContents';
|
|
12
|
-
}
|
|
13
|
-
export interface ModalsRendererProps {
|
|
14
|
-
children?: React.ReactNode;
|
|
15
|
-
modalConfigs: ModalConfig[];
|
|
16
|
-
onDismissed?: (id: string) => void;
|
|
17
|
-
onShow?: (id: string) => void;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/modal/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,oBAAoB,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAC1C,iBAAiB,CAAC,EAAE,YAAY,GAAG,gBAAgB,GAAG,WAAW,GAAG,WAAW,CAAC;IAChF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;CACtC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/B"}
|
package/build/modal/types.js
DELETED
package/build/modal/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/modal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { NavigationProp, ParamListBase } from '@react-navigation/native';\nimport { type ViewProps } from 'react-native';\n\nexport interface ModalConfig {\n component: React.ReactNode;\n parentNavigationProp: NavigationProp<ParamListBase>;\n uniqueId: string;\n animationType?: 'slide' | 'fade' | 'none';\n presentationStyle?: 'fullScreen' | 'overFullScreen' | 'pageSheet' | 'formSheet';\n transparent?: boolean;\n viewProps?: ViewProps;\n detents?: number[] | 'fitToContents';\n}\n\nexport interface ModalsRendererProps {\n children?: React.ReactNode;\n modalConfigs: ModalConfig[];\n onDismissed?: (id: string) => void;\n onShow?: (id: string) => void;\n}\n"]}
|
package/build/modal/utils.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { StackAnimationTypes } from 'react-native-screens';
|
|
2
|
-
import type { ModalProps } from './Modal';
|
|
3
|
-
import type { ModalConfig } from './types';
|
|
4
|
-
export declare function areDetentsValid(detents: ModalProps['detents']): boolean;
|
|
5
|
-
export declare function getStackAnimationType(config: ModalConfig): StackAnimationTypes | undefined;
|
|
6
|
-
export declare function getStackPresentationType(config: ModalConfig): "transparentModal" | "fullScreenModal" | "formSheet" | "pageSheet";
|
|
7
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/modal/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,OAAO,CAcvE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,GAAG,mBAAmB,GAAG,SAAS,CAU1F;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,WAAW,sEAgC3D"}
|
package/build/modal/utils.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.areDetentsValid = areDetentsValid;
|
|
4
|
-
exports.getStackAnimationType = getStackAnimationType;
|
|
5
|
-
exports.getStackPresentationType = getStackPresentationType;
|
|
6
|
-
function areDetentsValid(detents) {
|
|
7
|
-
if (Array.isArray(detents)) {
|
|
8
|
-
return (!!detents.length &&
|
|
9
|
-
detents.every((detent, index, arr) => typeof detent === 'number' &&
|
|
10
|
-
detent >= 0 &&
|
|
11
|
-
detent <= 1 &&
|
|
12
|
-
detent >= (arr[index - 1] ?? 0)));
|
|
13
|
-
}
|
|
14
|
-
return detents === 'fitToContents' || detents === undefined || detents === null;
|
|
15
|
-
}
|
|
16
|
-
function getStackAnimationType(config) {
|
|
17
|
-
switch (config.animationType) {
|
|
18
|
-
case 'fade':
|
|
19
|
-
return 'fade';
|
|
20
|
-
case 'none':
|
|
21
|
-
return 'none';
|
|
22
|
-
case 'slide':
|
|
23
|
-
default:
|
|
24
|
-
return 'slide_from_bottom';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function getStackPresentationType(config) {
|
|
28
|
-
if (process.env.EXPO_OS === 'android') {
|
|
29
|
-
if (config.transparent) {
|
|
30
|
-
return 'transparentModal';
|
|
31
|
-
}
|
|
32
|
-
switch (config.presentationStyle) {
|
|
33
|
-
case 'fullScreen':
|
|
34
|
-
return 'fullScreenModal';
|
|
35
|
-
case 'overFullScreen':
|
|
36
|
-
return 'transparentModal';
|
|
37
|
-
case 'pageSheet':
|
|
38
|
-
return 'pageSheet';
|
|
39
|
-
case 'formSheet':
|
|
40
|
-
return 'formSheet';
|
|
41
|
-
default:
|
|
42
|
-
return 'fullScreenModal';
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
switch (config.presentationStyle) {
|
|
46
|
-
case 'overFullScreen':
|
|
47
|
-
return 'transparentModal';
|
|
48
|
-
case 'pageSheet':
|
|
49
|
-
return 'pageSheet';
|
|
50
|
-
case 'formSheet':
|
|
51
|
-
return 'formSheet';
|
|
52
|
-
case 'fullScreen':
|
|
53
|
-
default:
|
|
54
|
-
if (config.transparent) {
|
|
55
|
-
return 'transparentModal';
|
|
56
|
-
}
|
|
57
|
-
return 'fullScreenModal';
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=utils.js.map
|
package/build/modal/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/modal/utils.ts"],"names":[],"mappings":";;AAKA,0CAcC;AAED,sDAUC;AAED,4DAgCC;AA5DD,SAAgB,eAAe,CAAC,OAA8B;IAC5D,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,CACL,CAAC,CAAC,OAAO,CAAC,MAAM;YAChB,OAAO,CAAC,KAAK,CACX,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CACrB,OAAO,MAAM,KAAK,QAAQ;gBAC1B,MAAM,IAAI,CAAC;gBACX,MAAM,IAAI,CAAC;gBACX,MAAM,IAAI,CAAC,GAAG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ypes } from 'react-native-screens';\n\nimport type { ModalProps } from './Modal';\nimport type { ModalConfig } from './types';\n\nexport function areDetentsValid(detents: ModalProps['detents']): boolean {\n if (Array.isArray(detents)) {\n return (\n !!detents.length &&\n detents.every(\n (detent, index, arr) =>\n typeof detent === 'number' &&\n detent >= 0 &&\n detent <= 1 &&\n detent >= (arr[index - 1] ?? 0)\n )\n );\n }\n return detents === 'fitToContents' || detents === undefined || detents === null;\n}\n\nexport function getStackAnimationType(config: ModalConfig): StackAnimationTypes | undefined {\n switch (config.animationType) {\n case 'fade':\n return 'fade';\n case 'none':\n return 'none';\n case 'slide':\n default:\n return 'slide_from_bottom';\n }\n}\n\nexport function getStackPresentationType(config: ModalConfig) {\n if (process.env.EXPO_OS === 'android') {\n if (config.transparent) {\n return 'transparentModal';\n }\n switch (config.presentationStyle) {\n case 'fullScreen':\n return 'fullScreenModal';\n case 'overFullScreen':\n return 'transparentModal';\n case 'pageSheet':\n return 'pageSheet';\n case 'formSheet':\n return 'formSheet';\n default:\n return 'fullScreenModal';\n }\n }\n switch (config.presentationStyle) {\n case 'overFullScreen':\n return 'transparentModal';\n case 'pageSheet':\n return 'pageSheet';\n case 'formSheet':\n return 'formSheet';\n case 'fullScreen':\n default:\n if (config.transparent) {\n return 'transparentModal';\n }\n return 'fullScreenModal';\n }\n}\n"]}
|