@tamagui/portal 1.0.1-beta.149 → 1.0.1-beta.152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/GorhomPortal.js +29 -15
- package/dist/cjs/GorhomPortal.js.map +2 -2
- package/dist/cjs/Portal.js +6 -2
- package/dist/cjs/Portal.js.map +1 -1
- package/dist/cjs/Portal.native.js +6 -2
- package/dist/cjs/Portal.native.js.map +1 -1
- package/dist/esm/GorhomPortal.js +29 -12
- package/dist/esm/GorhomPortal.js.map +2 -2
- package/dist/esm/Portal.js +2 -1
- package/dist/esm/Portal.js.map +1 -1
- package/dist/esm/Portal.native.js +2 -1
- package/dist/esm/Portal.native.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/jsx/GorhomPortal.js +12 -3
- package/dist/jsx/GorhomPortal.js.map +2 -2
- package/dist/jsx/Portal.js.map +1 -1
- package/dist/jsx/Portal.native.js.map +1 -1
- package/dist/jsx/index.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/GorhomPortal.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,7 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
19
|
var GorhomPortal_exports = {};
|
|
23
20
|
__export(GorhomPortal_exports, {
|
|
@@ -29,9 +26,10 @@ __export(GorhomPortal_exports, {
|
|
|
29
26
|
usePortal: () => usePortal
|
|
30
27
|
});
|
|
31
28
|
module.exports = __toCommonJS(GorhomPortal_exports);
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
30
|
var import_core = require("@tamagui/core");
|
|
33
31
|
var import_react = require("react");
|
|
34
|
-
var import_react2 =
|
|
32
|
+
var import_react2 = require("react");
|
|
35
33
|
var ACTIONS = /* @__PURE__ */ ((ACTIONS2) => {
|
|
36
34
|
ACTIONS2[ACTIONS2["REGISTER_HOST"] = 0] = "REGISTER_HOST";
|
|
37
35
|
ACTIONS2[ACTIONS2["DEREGISTER_HOST"] = 1] = "DEREGISTER_HOST";
|
|
@@ -83,7 +81,12 @@ const reducer = (state, action) => {
|
|
|
83
81
|
case 1 /* DEREGISTER_HOST */:
|
|
84
82
|
return deregisterHost({ ...state }, action.hostName);
|
|
85
83
|
case 2 /* ADD_UPDATE_PORTAL */:
|
|
86
|
-
return addUpdatePortal(
|
|
84
|
+
return addUpdatePortal(
|
|
85
|
+
{ ...state },
|
|
86
|
+
action.hostName,
|
|
87
|
+
action.portalName,
|
|
88
|
+
action.node
|
|
89
|
+
);
|
|
87
90
|
case 3 /* REMOVE_PORTAL */:
|
|
88
91
|
return removePortal({ ...state }, action.hostName, action.portalName);
|
|
89
92
|
default:
|
|
@@ -95,14 +98,18 @@ const PortalDispatchContext = (0, import_react2.createContext)(null);
|
|
|
95
98
|
const usePortalState = (hostName) => {
|
|
96
99
|
const state = (0, import_react2.useContext)(PortalStateContext);
|
|
97
100
|
if (state === null) {
|
|
98
|
-
throw new Error(
|
|
101
|
+
throw new Error(
|
|
102
|
+
"'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component."
|
|
103
|
+
);
|
|
99
104
|
}
|
|
100
105
|
return state[hostName] || [];
|
|
101
106
|
};
|
|
102
107
|
const usePortal = (hostName = "root") => {
|
|
103
108
|
const dispatch = (0, import_react2.useContext)(PortalDispatchContext);
|
|
104
109
|
if (dispatch === null) {
|
|
105
|
-
throw new Error(
|
|
110
|
+
throw new Error(
|
|
111
|
+
"'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component."
|
|
112
|
+
);
|
|
106
113
|
}
|
|
107
114
|
const registerHost2 = (0, import_react2.useCallback)(() => {
|
|
108
115
|
dispatch({
|
|
@@ -153,13 +160,18 @@ const PortalProviderComponent = ({
|
|
|
153
160
|
};
|
|
154
161
|
return next;
|
|
155
162
|
}, [dispatch]);
|
|
156
|
-
return /* @__PURE__ */
|
|
157
|
-
value: transitionDispatch
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalDispatchContext.Provider, {
|
|
164
|
+
value: transitionDispatch,
|
|
165
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PortalStateContext.Provider, {
|
|
166
|
+
value: state,
|
|
167
|
+
children: [
|
|
168
|
+
children,
|
|
169
|
+
shouldAddRootHost && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalHost, {
|
|
170
|
+
name: rootHostName
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
})
|
|
174
|
+
});
|
|
163
175
|
};
|
|
164
176
|
const PortalProvider = (0, import_react2.memo)(PortalProviderComponent);
|
|
165
177
|
PortalProvider.displayName = "PortalProvider";
|
|
@@ -175,7 +187,9 @@ const PortalHostComponent = ({ name }) => {
|
|
|
175
187
|
deregisterHost2();
|
|
176
188
|
};
|
|
177
189
|
}, [isServer]);
|
|
178
|
-
return /* @__PURE__ */
|
|
190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
191
|
+
children: state.map((item) => item.node)
|
|
192
|
+
});
|
|
179
193
|
};
|
|
180
194
|
const PortalHost = (0, import_react2.memo)(PortalHostComponent);
|
|
181
195
|
PortalHost.displayName = "PortalHost";
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/GorhomPortal.tsx"],
|
|
4
4
|
"sourcesContent": ["// from https://github.com/gorhom/react-native-portal\n// MIT License Copyright (c) 2020 Mo Gorhom\n// fixing SSR issue\n\nimport { startTransition, useIsSSR } from '@tamagui/core'\nimport { ReactNode, useMemo, useRef } from 'react'\nimport React, { createContext, memo, useCallback, useContext, useEffect, useReducer } from 'react'\n\ninterface PortalType {\n name: string\n node: ReactNode\n}\n\nenum ACTIONS {\n REGISTER_HOST,\n DEREGISTER_HOST,\n ADD_UPDATE_PORTAL,\n REMOVE_PORTAL,\n}\n\nconst INITIAL_STATE = {}\n\nexport { ACTIONS, INITIAL_STATE }\n\nexport interface AddUpdatePortalAction {\n type: ACTIONS\n hostName: string\n portalName: string\n node: ReactNode\n}\n\nexport interface RemovePortalAction {\n type: ACTIONS\n hostName: string\n portalName: string\n}\n\nexport interface RegisterHostAction {\n type: ACTIONS\n hostName: string\n}\n\nexport interface UnregisterHostAction {\n type: ACTIONS\n hostName: string\n}\n\nexport type ActionTypes =\n | AddUpdatePortalAction\n | RemovePortalAction\n | RegisterHostAction\n | UnregisterHostAction\n\nconst registerHost = (state: Record<string, Array<PortalType>>, hostName: string) => {\n if (!(hostName in state)) {\n state[hostName] = []\n }\n return state\n}\n\nconst deregisterHost = (state: Record<string, Array<PortalType>>, hostName: string) => {\n delete state[hostName]\n return state\n}\n\nconst addUpdatePortal = (\n state: Record<string, Array<PortalType>>,\n hostName: string,\n portalName: string,\n node: any\n) => {\n if (!(hostName in state)) {\n state = registerHost(state, hostName)\n }\n\n /**\n * updated portal, if it was already added.\n */\n const index = state[hostName].findIndex((item) => item.name === portalName)\n if (index !== -1) {\n state[hostName][index].node = node\n } else {\n state[hostName].push({\n name: portalName,\n node,\n })\n }\n return state\n}\n\nconst removePortal = (\n state: Record<string, Array<PortalType>>,\n hostName: string,\n portalName: string\n) => {\n if (!(hostName in state)) {\n console.log(`Failed to remove portal '${portalName}', '${hostName}' was not registered!`)\n return state\n }\n\n const index = state[hostName].findIndex((item) => item.name === portalName)\n if (index !== -1) state[hostName].splice(index, 1)\n return state\n}\n\nconst reducer = (state: Record<string, Array<PortalType>>, action: ActionTypes) => {\n const { type } = action\n switch (type) {\n case ACTIONS.REGISTER_HOST:\n return registerHost({ ...state }, action.hostName)\n case ACTIONS.DEREGISTER_HOST:\n return deregisterHost({ ...state }, action.hostName)\n case ACTIONS.ADD_UPDATE_PORTAL:\n return addUpdatePortal(\n { ...state },\n action.hostName,\n (action as AddUpdatePortalAction).portalName,\n (action as AddUpdatePortalAction).node\n )\n case ACTIONS.REMOVE_PORTAL:\n return removePortal({ ...state }, action.hostName, (action as RemovePortalAction).portalName)\n default:\n return state\n }\n}\n\nconst PortalStateContext = createContext<Record<string, Array<PortalType>> | null>(null)\nconst PortalDispatchContext = createContext<React.Dispatch<ActionTypes> | null>(null)\n\nconst usePortalState = (hostName: string) => {\n const state = useContext(PortalStateContext)\n\n if (state === null) {\n throw new Error(\n \"'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component.\"\n )\n }\n\n return state[hostName] || []\n}\n\nexport const usePortal = (hostName = 'root') => {\n const dispatch = useContext(PortalDispatchContext)\n\n if (dispatch === null) {\n throw new Error(\n \"'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component.\"\n )\n }\n\n //#region methods\n const registerHost = useCallback(() => {\n dispatch({\n type: ACTIONS.REGISTER_HOST,\n hostName: hostName,\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const deregisterHost = useCallback(() => {\n dispatch({\n type: ACTIONS.DEREGISTER_HOST,\n hostName: hostName,\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const addUpdatePortal = useCallback((name: string, node: ReactNode) => {\n dispatch({\n type: ACTIONS.ADD_UPDATE_PORTAL,\n hostName,\n portalName: name,\n node,\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const removePortal = useCallback((name: string) => {\n dispatch({\n type: ACTIONS.REMOVE_PORTAL,\n hostName,\n portalName: name,\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n //#endregion\n\n return {\n registerHost,\n deregisterHost,\n addPortal: addUpdatePortal,\n updatePortal: addUpdatePortal,\n removePortal,\n }\n}\n\nexport interface PortalProviderProps {\n /**\n * Defines whether to add a default root host or not.\n *\n * @default true\n * @type boolean\n */\n shouldAddRootHost?: boolean\n\n /**\n * Defines the root portal host name.\n *\n * @default \"root\"\n * @type string\n */\n rootHostName?: string\n\n children: ReactNode | ReactNode[]\n}\n\nconst PortalProviderComponent = ({\n rootHostName = 'root',\n shouldAddRootHost = true,\n children,\n}: PortalProviderProps) => {\n const [state, dispatch] = useReducer(reducer, INITIAL_STATE)\n const transitionDispatch = useMemo(() => {\n const next = (value: any) => {\n startTransition(() => {\n dispatch(value)\n })\n }\n return next as typeof dispatch\n }, [dispatch])\n return (\n <PortalDispatchContext.Provider value={transitionDispatch}>\n <PortalStateContext.Provider value={state}>\n {children}\n {shouldAddRootHost && <PortalHost name={rootHostName} />}\n </PortalStateContext.Provider>\n </PortalDispatchContext.Provider>\n )\n}\n\nexport const PortalProvider = memo(PortalProviderComponent)\nPortalProvider.displayName = 'PortalProvider'\n\nexport interface PortalHostProps {\n /**\n * Host's key or name to be used as an identifier.\n * @type string\n */\n name: string\n}\n\nconst PortalHostComponent = ({ name }: PortalHostProps) => {\n //#region hooks\n const isServer = useIsSSR()\n const state = usePortalState(name)\n const { registerHost, deregisterHost } = usePortal(name)\n //#endregion\n\n //#region effects\n useEffect(() => {\n if (isServer) return\n registerHost()\n return () => {\n deregisterHost()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isServer])\n //#endregion\n\n //#region render\n return <>{state.map((item) => item.node)}</>\n //#endregion\n}\n\nexport const PortalHost = memo(PortalHostComponent)\nPortalHost.displayName = 'PortalHost'\n\nexport interface PortalItemProps {\n /**\n * Portal's key or name to be used as an identifier.\n * @type string\n * @default nanoid generated unique key.\n */\n name?: string\n /**\n * Host's name to teleport the portal content to.\n * @type string\n * @default 'root'\n */\n hostName?: string\n /**\n * Override internal mounting functionality, this is useful\n * if you want to trigger any action before mounting the portal content.\n * @type (mount?: () => void) => void\n * @default undefined\n */\n handleOnMount?: (mount: () => void) => void\n /**\n * Override internal un-mounting functionality, this is useful\n * if you want to trigger any action before un-mounting the portal content.\n * @type (unmount?: () => void) => void\n * @default undefined\n */\n handleOnUnmount?: (unmount: () => void) => void\n /**\n * Override internal updating functionality, this is useful\n * if you want to trigger any action before updating the portal content.\n * @type (update?: () => void) => void\n * @default undefined\n */\n handleOnUpdate?: (update: () => void) => void\n /**\n * Portal's content.\n * @type ReactNode\n * @default undefined\n */\n children?: ReactNode | ReactNode[]\n}\n\nconst PortalComponent = ({\n name: _providedName,\n hostName,\n handleOnMount: _providedHandleOnMount,\n handleOnUnmount: _providedHandleOnUnmount,\n handleOnUpdate: _providedHandleOnUpdate,\n children,\n}: PortalItemProps) => {\n //#region hooks\n const { addPortal: addUpdatePortal, removePortal } = usePortal(hostName)\n //#endregion\n\n let id = 0\n const nanoid = () => {\n id = (id + 1) % Number.MAX_SAFE_INTEGER\n return `${id}`\n }\n\n //#region variables\n const name = useMemo(() => _providedName || nanoid(), [_providedName])\n //#endregion\n\n //#region refs\n const handleOnMountRef = useRef<Function>()\n const handleOnUnmountRef = useRef<Function>()\n const handleOnUpdateRef = useRef<Function>()\n //#endregion\n\n //#region callbacks\n const handleOnMount = useCallback(() => {\n if (_providedHandleOnMount) {\n _providedHandleOnMount(() => addUpdatePortal(name, children))\n } else {\n addUpdatePortal(name, children)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [_providedHandleOnMount, addUpdatePortal])\n handleOnMountRef.current = handleOnMount\n\n const handleOnUnmount = useCallback(() => {\n if (_providedHandleOnUnmount) {\n _providedHandleOnUnmount(() => removePortal(name))\n } else {\n removePortal(name)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [_providedHandleOnUnmount, removePortal])\n handleOnUnmountRef.current = handleOnUnmount\n\n const handleOnUpdate = useCallback(() => {\n if (_providedHandleOnUpdate) {\n _providedHandleOnUpdate(() => addUpdatePortal(name, children))\n } else {\n addUpdatePortal(name, children)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [_providedHandleOnUpdate, addUpdatePortal, children])\n handleOnUpdateRef.current = handleOnUpdate\n //#endregion\n\n //#region effects\n useEffect(() => {\n handleOnMountRef.current?.()\n return () => {\n handleOnUnmountRef.current?.()\n\n // remove callbacks refs\n handleOnMountRef.current = undefined\n handleOnUnmountRef.current = undefined\n handleOnUpdateRef.current = undefined\n }\n }, [])\n useEffect(() => {\n handleOnUpdateRef.current?.()\n }, [children])\n //#endregion\n\n return null\n}\n\nexport const PortalItem = memo(PortalComponent)\nPortalItem.displayName = 'Portal'\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwOM;AApON,kBAA0C;AAC1C,mBAA2C;AAC3C,IAAAA,gBAA2F;AAO3F,IAAK,UAAL,kBAAKC,aAAL;AACE,EAAAA,kBAAA;AACA,EAAAA,kBAAA;AACA,EAAAA,kBAAA;AACA,EAAAA,kBAAA;AAJG,SAAAA;AAAA,GAAA;AAOL,MAAM,gBAAgB,CAAC;AAiCvB,MAAM,eAAe,CAAC,OAA0C,aAAqB;AACnF,MAAI,EAAE,YAAY,QAAQ;AACxB,UAAM,YAAY,CAAC;AAAA,EACrB;AACA,SAAO;AACT;AAEA,MAAM,iBAAiB,CAAC,OAA0C,aAAqB;AACr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__copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var Portal_exports = {};
|
|
23
26
|
__export(Portal_exports, {
|
|
24
27
|
Portal: () => Portal
|
|
25
28
|
});
|
|
26
29
|
module.exports = __toCommonJS(Portal_exports);
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
31
|
var import_polyfill_dev = require("@tamagui/polyfill-dev");
|
|
28
32
|
var import_core = require("@tamagui/core");
|
|
29
33
|
var import_stacks = require("@tamagui/stacks");
|
|
30
34
|
var React = __toESM(require("react"));
|
|
31
35
|
var import_react_dom = require("react-dom");
|
|
32
36
|
const Portal = ({ host = ((_a) => (_a = globalThis.document) == null ? void 0 : _a.body)(), ...props }) => {
|
|
33
|
-
const contents = /* @__PURE__ */
|
|
37
|
+
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
34
38
|
pointerEvents: "box-none",
|
|
35
39
|
contain: "strict",
|
|
36
40
|
fullscreen: true,
|
package/dist/cjs/Portal.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Portal.tsx"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport '@tamagui/polyfill-dev'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nexport type PortalProps = YStackProps & {\n host?: any // element\n}\n\nexport const Portal = ({ host = globalThis.document?.body, ...props }: PortalProps) => {\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n contain=\"strict\"\n fullscreen\n // @ts-expect-error ok on web\n position={isWeb ? 'fixed' : 'absolute'}\n maxWidth={isWeb ? '100vw' : '100%'}\n maxHeight={isWeb ? '100vh' : '100%'}\n {...props}\n />\n )\n\n const [hostElement, setHostElement] = React.useState<any>(null)\n\n useIsomorphicLayoutEffect(() => {\n setHostElement(host)\n }, [host])\n\n if (hostElement) {\n return createPortal(contents, hostElement)\n }\n\n // ssr return null\n return null\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcI;AAbJ,0BAAO;AAEP,kBAAiD;AACjD,oBAAoC;AACpC,YAAuB;AACvB,uBAA6B;AAMtB,MAAM,SAAS,CAAC,EAAE,QAAO,yBAAW,aAAX,mBAAqB,YAAS,MAAM,MAAmB;AACrF,QAAM,WACJ,4CAAC;AAAA,IACC,eAAc;AAAA,IACd,SAAQ;AAAA,IACR,YAAU;AAAA,IAEV,UAAU,oBAAQ,UAAU;AAAA,IAC5B,UAAU,oBAAQ,UAAU;AAAA,IAC5B,WAAW,oBAAQ,UAAU;AAAA,IAC5B,GAAG;AAAA,GACN;AAGF,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAc,IAAI;AAE9D,6CAA0B,MAAM;AAC9B,mBAAe,IAAI;AAAA,EACrB,GAAG,CAAC,IAAI,CAAC;AAET,MAAI,aAAa;AACf,eAAO,+BAAa,UAAU,WAAW;AAAA,EAC3C;AAGA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,20 +17,24 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var Portal_native_exports = {};
|
|
23
26
|
__export(Portal_native_exports, {
|
|
24
27
|
Portal: () => Portal
|
|
25
28
|
});
|
|
26
29
|
module.exports = __toCommonJS(Portal_native_exports);
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
31
|
var import_stacks = require("@tamagui/stacks");
|
|
28
32
|
var React = __toESM(require("react"));
|
|
29
33
|
var import_react_native = require("react-native");
|
|
30
34
|
var import_ReactNative = require("react-native/Libraries/Renderer/shims/ReactNative");
|
|
31
35
|
const Portal = (props) => {
|
|
32
36
|
const rootTag = React.useContext(import_react_native.RootTagContext);
|
|
33
|
-
const contents = /* @__PURE__ */
|
|
37
|
+
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
34
38
|
pointerEvents: "box-none",
|
|
35
39
|
fullscreen: true,
|
|
36
40
|
position: "absolute",
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Portal.native.tsx"],
|
|
4
4
|
"sourcesContent": ["import { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\n// @ts-ignore\nimport { RootTagContext } from 'react-native'\nimport { createPortal } from 'react-native/Libraries/Renderer/shims/ReactNative'\n\nexport type PortalProps = YStackProps\n\nexport const Portal = (props: PortalProps) => {\n const rootTag = React.useContext(RootTagContext)\n\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n fullscreen\n position=\"absolute\"\n maxWidth=\"100%\"\n zIndex={100000}\n {...props}\n />\n )\n\n if (rootTag) {\n return createPortal(contents, rootTag)\n }\n\n return null\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYI;AAZJ,oBAAoC;AACpC,YAAuB;AAEvB,0BAA+B;AAC/B,yBAA6B;AAItB,MAAM,SAAS,CAAC,UAAuB;AAC5C,QAAM,UAAU,MAAM,WAAW,kCAAc;AAE/C,QAAM,WACJ,4CAAC;AAAA,IACC,eAAc;AAAA,IACd,YAAU;AAAA,IACV,UAAS;AAAA,IACT,UAAS;AAAA,IACT,QAAQ;AAAA,IACP,GAAG;AAAA,GACN;AAGF,MAAI,SAAS;AACX,eAAO,iCAAa,UAAU,OAAO;AAAA,EACvC;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/GorhomPortal.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
1
2
|
import { startTransition, useIsSSR } from "@tamagui/core";
|
|
2
3
|
import { useMemo, useRef } from "react";
|
|
3
|
-
import
|
|
4
|
+
import { createContext, memo, useCallback, useContext, useEffect, useReducer } from "react";
|
|
4
5
|
var ACTIONS = /* @__PURE__ */ ((ACTIONS2) => {
|
|
5
6
|
ACTIONS2[ACTIONS2["REGISTER_HOST"] = 0] = "REGISTER_HOST";
|
|
6
7
|
ACTIONS2[ACTIONS2["DEREGISTER_HOST"] = 1] = "DEREGISTER_HOST";
|
|
@@ -52,7 +53,12 @@ const reducer = (state, action) => {
|
|
|
52
53
|
case 1 /* DEREGISTER_HOST */:
|
|
53
54
|
return deregisterHost({ ...state }, action.hostName);
|
|
54
55
|
case 2 /* ADD_UPDATE_PORTAL */:
|
|
55
|
-
return addUpdatePortal(
|
|
56
|
+
return addUpdatePortal(
|
|
57
|
+
{ ...state },
|
|
58
|
+
action.hostName,
|
|
59
|
+
action.portalName,
|
|
60
|
+
action.node
|
|
61
|
+
);
|
|
56
62
|
case 3 /* REMOVE_PORTAL */:
|
|
57
63
|
return removePortal({ ...state }, action.hostName, action.portalName);
|
|
58
64
|
default:
|
|
@@ -64,14 +70,18 @@ const PortalDispatchContext = createContext(null);
|
|
|
64
70
|
const usePortalState = (hostName) => {
|
|
65
71
|
const state = useContext(PortalStateContext);
|
|
66
72
|
if (state === null) {
|
|
67
|
-
throw new Error(
|
|
73
|
+
throw new Error(
|
|
74
|
+
"'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component."
|
|
75
|
+
);
|
|
68
76
|
}
|
|
69
77
|
return state[hostName] || [];
|
|
70
78
|
};
|
|
71
79
|
const usePortal = (hostName = "root") => {
|
|
72
80
|
const dispatch = useContext(PortalDispatchContext);
|
|
73
81
|
if (dispatch === null) {
|
|
74
|
-
throw new Error(
|
|
82
|
+
throw new Error(
|
|
83
|
+
"'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component."
|
|
84
|
+
);
|
|
75
85
|
}
|
|
76
86
|
const registerHost2 = useCallback(() => {
|
|
77
87
|
dispatch({
|
|
@@ -122,13 +132,18 @@ const PortalProviderComponent = ({
|
|
|
122
132
|
};
|
|
123
133
|
return next;
|
|
124
134
|
}, [dispatch]);
|
|
125
|
-
return /* @__PURE__ */
|
|
126
|
-
value: transitionDispatch
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
135
|
+
return /* @__PURE__ */ jsx(PortalDispatchContext.Provider, {
|
|
136
|
+
value: transitionDispatch,
|
|
137
|
+
children: /* @__PURE__ */ jsxs(PortalStateContext.Provider, {
|
|
138
|
+
value: state,
|
|
139
|
+
children: [
|
|
140
|
+
children,
|
|
141
|
+
shouldAddRootHost && /* @__PURE__ */ jsx(PortalHost, {
|
|
142
|
+
name: rootHostName
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
})
|
|
146
|
+
});
|
|
132
147
|
};
|
|
133
148
|
const PortalProvider = memo(PortalProviderComponent);
|
|
134
149
|
PortalProvider.displayName = "PortalProvider";
|
|
@@ -144,7 +159,9 @@ const PortalHostComponent = ({ name }) => {
|
|
|
144
159
|
deregisterHost2();
|
|
145
160
|
};
|
|
146
161
|
}, [isServer]);
|
|
147
|
-
return /* @__PURE__ */
|
|
162
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
163
|
+
children: state.map((item) => item.node)
|
|
164
|
+
});
|
|
148
165
|
};
|
|
149
166
|
const PortalHost = memo(PortalHostComponent);
|
|
150
167
|
PortalHost.displayName = "PortalHost";
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/GorhomPortal.tsx"],
|
|
4
4
|
"sourcesContent": ["// from https://github.com/gorhom/react-native-portal\n// MIT License Copyright (c) 2020 Mo Gorhom\n// fixing SSR issue\n\nimport { startTransition, useIsSSR } from '@tamagui/core'\nimport { ReactNode, useMemo, useRef } from 'react'\nimport React, { createContext, memo, useCallback, useContext, useEffect, useReducer } from 'react'\n\ninterface PortalType {\n name: string\n node: ReactNode\n}\n\nenum ACTIONS {\n REGISTER_HOST,\n DEREGISTER_HOST,\n ADD_UPDATE_PORTAL,\n REMOVE_PORTAL,\n}\n\nconst INITIAL_STATE = {}\n\nexport { ACTIONS, INITIAL_STATE }\n\nexport interface AddUpdatePortalAction {\n type: ACTIONS\n hostName: string\n portalName: string\n node: ReactNode\n}\n\nexport interface RemovePortalAction {\n type: ACTIONS\n hostName: string\n portalName: string\n}\n\nexport interface RegisterHostAction {\n type: ACTIONS\n hostName: string\n}\n\nexport interface UnregisterHostAction {\n type: ACTIONS\n hostName: string\n}\n\nexport type ActionTypes =\n | AddUpdatePortalAction\n | RemovePortalAction\n | RegisterHostAction\n | UnregisterHostAction\n\nconst registerHost = (state: Record<string, Array<PortalType>>, hostName: string) => {\n if (!(hostName in state)) {\n state[hostName] = []\n }\n return state\n}\n\nconst deregisterHost = (state: Record<string, Array<PortalType>>, hostName: string) => {\n delete state[hostName]\n return state\n}\n\nconst addUpdatePortal = (\n state: Record<string, Array<PortalType>>,\n hostName: string,\n portalName: string,\n node: any\n) => {\n if (!(hostName in state)) {\n state = registerHost(state, hostName)\n }\n\n /**\n * updated portal, if it was already added.\n */\n const index = state[hostName].findIndex((item) => item.name === portalName)\n if (index !== -1) {\n state[hostName][index].node = node\n } else {\n state[hostName].push({\n name: portalName,\n node,\n })\n }\n return state\n}\n\nconst removePortal = (\n state: Record<string, Array<PortalType>>,\n hostName: string,\n portalName: string\n) => {\n if (!(hostName in state)) {\n console.log(`Failed to remove portal '${portalName}', '${hostName}' was not registered!`)\n return state\n }\n\n const index = state[hostName].findIndex((item) => item.name === portalName)\n if (index !== -1) state[hostName].splice(index, 1)\n return state\n}\n\nconst reducer = (state: Record<string, Array<PortalType>>, action: ActionTypes) => {\n const { type } = action\n switch (type) {\n case ACTIONS.REGISTER_HOST:\n return registerHost({ ...state }, action.hostName)\n case ACTIONS.DEREGISTER_HOST:\n return deregisterHost({ ...state }, action.hostName)\n case ACTIONS.ADD_UPDATE_PORTAL:\n return addUpdatePortal(\n { ...state },\n action.hostName,\n (action as AddUpdatePortalAction).portalName,\n (action as AddUpdatePortalAction).node\n )\n case ACTIONS.REMOVE_PORTAL:\n return removePortal({ ...state }, action.hostName, (action as RemovePortalAction).portalName)\n default:\n return state\n }\n}\n\nconst PortalStateContext = createContext<Record<string, Array<PortalType>> | null>(null)\nconst PortalDispatchContext = createContext<React.Dispatch<ActionTypes> | null>(null)\n\nconst usePortalState = (hostName: string) => {\n const state = useContext(PortalStateContext)\n\n if (state === null) {\n throw new Error(\n \"'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component.\"\n )\n }\n\n return state[hostName] || []\n}\n\nexport const usePortal = (hostName = 'root') => {\n const dispatch = useContext(PortalDispatchContext)\n\n if (dispatch === null) {\n throw new Error(\n \"'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component.\"\n )\n }\n\n //#region methods\n const registerHost = useCallback(() => {\n dispatch({\n type: ACTIONS.REGISTER_HOST,\n hostName: hostName,\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const deregisterHost = useCallback(() => {\n dispatch({\n type: ACTIONS.DEREGISTER_HOST,\n hostName: hostName,\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const addUpdatePortal = useCallback((name: string, node: ReactNode) => {\n dispatch({\n type: ACTIONS.ADD_UPDATE_PORTAL,\n hostName,\n portalName: name,\n node,\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const removePortal = useCallback((name: string) => {\n dispatch({\n type: ACTIONS.REMOVE_PORTAL,\n hostName,\n portalName: name,\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n //#endregion\n\n return {\n registerHost,\n deregisterHost,\n addPortal: addUpdatePortal,\n updatePortal: addUpdatePortal,\n removePortal,\n }\n}\n\nexport interface PortalProviderProps {\n /**\n * Defines whether to add a default root host or not.\n *\n * @default true\n * @type boolean\n */\n shouldAddRootHost?: boolean\n\n /**\n * Defines the root portal host name.\n *\n * @default \"root\"\n * @type string\n */\n rootHostName?: string\n\n children: ReactNode | ReactNode[]\n}\n\nconst PortalProviderComponent = ({\n rootHostName = 'root',\n shouldAddRootHost = true,\n children,\n}: PortalProviderProps) => {\n const [state, dispatch] = useReducer(reducer, INITIAL_STATE)\n const transitionDispatch = useMemo(() => {\n const next = (value: any) => {\n startTransition(() => {\n dispatch(value)\n })\n }\n return next as typeof dispatch\n }, [dispatch])\n return (\n <PortalDispatchContext.Provider value={transitionDispatch}>\n <PortalStateContext.Provider value={state}>\n {children}\n {shouldAddRootHost && <PortalHost name={rootHostName} />}\n </PortalStateContext.Provider>\n </PortalDispatchContext.Provider>\n )\n}\n\nexport const PortalProvider = memo(PortalProviderComponent)\nPortalProvider.displayName = 'PortalProvider'\n\nexport interface PortalHostProps {\n /**\n * Host's key or name to be used as an identifier.\n * @type string\n */\n name: string\n}\n\nconst PortalHostComponent = ({ name }: PortalHostProps) => {\n //#region hooks\n const isServer = useIsSSR()\n const state = usePortalState(name)\n const { registerHost, deregisterHost } = usePortal(name)\n //#endregion\n\n //#region effects\n useEffect(() => {\n if (isServer) return\n registerHost()\n return () => {\n deregisterHost()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isServer])\n //#endregion\n\n //#region render\n return <>{state.map((item) => item.node)}</>\n //#endregion\n}\n\nexport const PortalHost = memo(PortalHostComponent)\nPortalHost.displayName = 'PortalHost'\n\nexport interface PortalItemProps {\n /**\n * Portal's key or name to be used as an identifier.\n * @type string\n * @default nanoid generated unique key.\n */\n name?: string\n /**\n * Host's name to teleport the portal content to.\n * @type string\n * @default 'root'\n */\n hostName?: string\n /**\n * Override internal mounting functionality, this is useful\n * if you want to trigger any action before mounting the portal content.\n * @type (mount?: () => void) => void\n * @default undefined\n */\n handleOnMount?: (mount: () => void) => void\n /**\n * Override internal un-mounting functionality, this is useful\n * if you want to trigger any action before un-mounting the portal content.\n * @type (unmount?: () => void) => void\n * @default undefined\n */\n handleOnUnmount?: (unmount: () => void) => void\n /**\n * Override internal updating functionality, this is useful\n * if you want to trigger any action before updating the portal content.\n * @type (update?: () => void) => void\n * @default undefined\n */\n handleOnUpdate?: (update: () => void) => void\n /**\n * Portal's content.\n * @type ReactNode\n * @default undefined\n */\n children?: ReactNode | ReactNode[]\n}\n\nconst PortalComponent = ({\n name: _providedName,\n hostName,\n handleOnMount: _providedHandleOnMount,\n handleOnUnmount: _providedHandleOnUnmount,\n handleOnUpdate: _providedHandleOnUpdate,\n children,\n}: PortalItemProps) => {\n //#region hooks\n const { addPortal: addUpdatePortal, removePortal } = usePortal(hostName)\n //#endregion\n\n let id = 0\n const nanoid = () => {\n id = (id + 1) % Number.MAX_SAFE_INTEGER\n return `${id}`\n }\n\n //#region variables\n const name = useMemo(() => _providedName || nanoid(), [_providedName])\n //#endregion\n\n //#region refs\n const handleOnMountRef = useRef<Function>()\n const handleOnUnmountRef = useRef<Function>()\n const handleOnUpdateRef = useRef<Function>()\n //#endregion\n\n //#region callbacks\n const handleOnMount = useCallback(() => {\n if (_providedHandleOnMount) {\n _providedHandleOnMount(() => addUpdatePortal(name, children))\n } else {\n addUpdatePortal(name, children)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [_providedHandleOnMount, addUpdatePortal])\n handleOnMountRef.current = handleOnMount\n\n const handleOnUnmount = useCallback(() => {\n if (_providedHandleOnUnmount) {\n _providedHandleOnUnmount(() => removePortal(name))\n } else {\n removePortal(name)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [_providedHandleOnUnmount, removePortal])\n handleOnUnmountRef.current = handleOnUnmount\n\n const handleOnUpdate = useCallback(() => {\n if (_providedHandleOnUpdate) {\n _providedHandleOnUpdate(() => addUpdatePortal(name, children))\n } else {\n addUpdatePortal(name, children)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [_providedHandleOnUpdate, addUpdatePortal, children])\n handleOnUpdateRef.current = handleOnUpdate\n //#endregion\n\n //#region effects\n useEffect(() => {\n handleOnMountRef.current?.()\n return () => {\n handleOnUnmountRef.current?.()\n\n // remove callbacks refs\n handleOnMountRef.current = undefined\n handleOnUnmountRef.current = undefined\n handleOnUpdateRef.current = undefined\n }\n }, [])\n useEffect(() => {\n handleOnUpdateRef.current?.()\n }, [children])\n //#endregion\n\n return null\n}\n\nexport const PortalItem = memo(PortalComponent)\nPortalItem.displayName = 'Portal'\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAwOM,SAsCG,UApCqB,KAFxB;AApON,SAAS,iBAAiB,gBAAgB;AAC1C,SAAoB,SAAS,cAAc;AAC3C,SAAgB,eAAe,MAAM,aAAa,YAAY,WAAW,kBAAkB;AAO3F,IAAK,UAAL,kBA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AAvYlB;AAwYI,4BAAkB,YAAlB;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAGb,SAAO;AACT;AAEO,MAAM,aAAa,KAAK,eAAe;AAC9C,WAAW,cAAc;",
|
|
6
|
+
"names": ["ACTIONS", "registerHost", "deregisterHost", "addUpdatePortal", "removePortal", "_a"]
|
|
7
7
|
}
|
package/dist/esm/Portal.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
import "@tamagui/polyfill-dev";
|
|
2
3
|
import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/core";
|
|
3
4
|
import { YStack } from "@tamagui/stacks";
|
|
4
5
|
import * as React from "react";
|
|
5
6
|
import { createPortal } from "react-dom";
|
|
6
7
|
const Portal = ({ host = ((_a) => (_a = globalThis.document) == null ? void 0 : _a.body)(), ...props }) => {
|
|
7
|
-
const contents = /* @__PURE__ */
|
|
8
|
+
const contents = /* @__PURE__ */ jsx(YStack, {
|
|
8
9
|
pointerEvents: "box-none",
|
|
9
10
|
contain: "strict",
|
|
10
11
|
fullscreen: true,
|
package/dist/esm/Portal.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Portal.tsx"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport '@tamagui/polyfill-dev'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nexport type PortalProps = YStackProps & {\n host?: any // element\n}\n\nexport const Portal = ({ host = globalThis.document?.body, ...props }: PortalProps) => {\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n contain=\"strict\"\n fullscreen\n // @ts-expect-error ok on web\n position={isWeb ? 'fixed' : 'absolute'}\n maxWidth={isWeb ? '100vw' : '100%'}\n maxHeight={isWeb ? '100vh' : '100%'}\n {...props}\n />\n )\n\n const [hostElement, setHostElement] = React.useState<any>(null)\n\n useIsomorphicLayoutEffect(() => {\n setHostElement(host)\n }, [host])\n\n if (hostElement) {\n return createPortal(contents, hostElement)\n }\n\n // ssr return null\n return null\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAcI;AAbJ,OAAO;AAEP,SAAS,OAAO,iCAAiC;AACjD,SAAS,cAA2B;AACpC,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAMtB,MAAM,SAAS,CAAC,EAAE,QAAO,yBAAW,aAAX,mBAAqB,YAAS,MAAM,MAAmB;AACrF,QAAM,WACJ,oBAAC;AAAA,IACC,eAAc;AAAA,IACd,SAAQ;AAAA,IACR,YAAU;AAAA,IAEV,UAAU,QAAQ,UAAU;AAAA,IAC5B,UAAU,QAAQ,UAAU;AAAA,IAC5B,WAAW,QAAQ,UAAU;AAAA,IAC5B,GAAG;AAAA,GACN;AAGF,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAc,IAAI;AAE9D,4BAA0B,MAAM;AAC9B,mBAAe,IAAI;AAAA,EACrB,GAAG,CAAC,IAAI,CAAC;AAET,MAAI,aAAa;AACf,WAAO,aAAa,UAAU,WAAW;AAAA,EAC3C;AAGA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
import { YStack } from "@tamagui/stacks";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
import { RootTagContext } from "react-native";
|
|
4
5
|
import { createPortal } from "react-native/Libraries/Renderer/shims/ReactNative";
|
|
5
6
|
const Portal = (props) => {
|
|
6
7
|
const rootTag = React.useContext(RootTagContext);
|
|
7
|
-
const contents = /* @__PURE__ */
|
|
8
|
+
const contents = /* @__PURE__ */ jsx(YStack, {
|
|
8
9
|
pointerEvents: "box-none",
|
|
9
10
|
fullscreen: true,
|
|
10
11
|
position: "absolute",
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Portal.native.tsx"],
|
|
4
4
|
"sourcesContent": ["import { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\n// @ts-ignore\nimport { RootTagContext } from 'react-native'\nimport { createPortal } from 'react-native/Libraries/Renderer/shims/ReactNative'\n\nexport type PortalProps = YStackProps\n\nexport const Portal = (props: PortalProps) => {\n const rootTag = React.useContext(RootTagContext)\n\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n fullscreen\n position=\"absolute\"\n maxWidth=\"100%\"\n zIndex={100000}\n {...props}\n />\n )\n\n if (rootTag) {\n return createPortal(contents, rootTag)\n }\n\n return null\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAYI;AAZJ,SAAS,cAA2B;AACpC,YAAY,WAAW;AAEvB,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAItB,MAAM,SAAS,CAAC,UAAuB;AAC5C,QAAM,UAAU,MAAM,WAAW,cAAc;AAE/C,QAAM,WACJ,oBAAC;AAAA,IACC,eAAc;AAAA,IACd,YAAU;AAAA,IACV,UAAS;AAAA,IACT,UAAS;AAAA,IACT,QAAQ;AAAA,IACP,GAAG;AAAA,GACN;AAGF,MAAI,SAAS;AACX,WAAO,aAAa,UAAU,OAAO;AAAA,EACvC;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js.map
CHANGED
package/dist/jsx/GorhomPortal.js
CHANGED
|
@@ -52,7 +52,12 @@ const reducer = (state, action) => {
|
|
|
52
52
|
case 1 /* DEREGISTER_HOST */:
|
|
53
53
|
return deregisterHost({ ...state }, action.hostName);
|
|
54
54
|
case 2 /* ADD_UPDATE_PORTAL */:
|
|
55
|
-
return addUpdatePortal(
|
|
55
|
+
return addUpdatePortal(
|
|
56
|
+
{ ...state },
|
|
57
|
+
action.hostName,
|
|
58
|
+
action.portalName,
|
|
59
|
+
action.node
|
|
60
|
+
);
|
|
56
61
|
case 3 /* REMOVE_PORTAL */:
|
|
57
62
|
return removePortal({ ...state }, action.hostName, action.portalName);
|
|
58
63
|
default:
|
|
@@ -64,14 +69,18 @@ const PortalDispatchContext = createContext(null);
|
|
|
64
69
|
const usePortalState = (hostName) => {
|
|
65
70
|
const state = useContext(PortalStateContext);
|
|
66
71
|
if (state === null) {
|
|
67
|
-
throw new Error(
|
|
72
|
+
throw new Error(
|
|
73
|
+
"'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component."
|
|
74
|
+
);
|
|
68
75
|
}
|
|
69
76
|
return state[hostName] || [];
|
|
70
77
|
};
|
|
71
78
|
const usePortal = (hostName = "root") => {
|
|
72
79
|
const dispatch = useContext(PortalDispatchContext);
|
|
73
80
|
if (dispatch === null) {
|
|
74
|
-
throw new Error(
|
|
81
|
+
throw new Error(
|
|
82
|
+
"'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component."
|
|
83
|
+
);
|
|
75
84
|
}
|
|
76
85
|
const registerHost2 = useCallback(() => {
|
|
77
86
|
dispatch({
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/GorhomPortal.tsx"],
|
|
4
4
|
"sourcesContent": ["// from https://github.com/gorhom/react-native-portal\n// MIT License Copyright (c) 2020 Mo Gorhom\n// fixing SSR issue\n\nimport { startTransition, useIsSSR } from '@tamagui/core'\nimport { ReactNode, useMemo, useRef } from 'react'\nimport React, { createContext, memo, useCallback, useContext, useEffect, useReducer } from 'react'\n\ninterface PortalType {\n name: string\n node: ReactNode\n}\n\nenum ACTIONS {\n REGISTER_HOST,\n DEREGISTER_HOST,\n ADD_UPDATE_PORTAL,\n REMOVE_PORTAL,\n}\n\nconst INITIAL_STATE = {}\n\nexport { ACTIONS, INITIAL_STATE }\n\nexport interface AddUpdatePortalAction {\n type: ACTIONS\n hostName: string\n portalName: string\n node: ReactNode\n}\n\nexport interface RemovePortalAction {\n type: ACTIONS\n hostName: string\n portalName: string\n}\n\nexport interface RegisterHostAction {\n type: ACTIONS\n hostName: string\n}\n\nexport interface UnregisterHostAction {\n type: ACTIONS\n hostName: string\n}\n\nexport type ActionTypes =\n | AddUpdatePortalAction\n | RemovePortalAction\n | RegisterHostAction\n | UnregisterHostAction\n\nconst registerHost = (state: Record<string, Array<PortalType>>, hostName: string) => {\n if (!(hostName in state)) {\n state[hostName] = []\n }\n return state\n}\n\nconst deregisterHost = (state: Record<string, Array<PortalType>>, hostName: string) => {\n delete state[hostName]\n return state\n}\n\nconst addUpdatePortal = (\n state: Record<string, Array<PortalType>>,\n hostName: string,\n portalName: string,\n node: any\n) => {\n if (!(hostName in state)) {\n state = registerHost(state, hostName)\n }\n\n /**\n * updated portal, if it was already added.\n */\n const index = state[hostName].findIndex((item) => item.name === portalName)\n if (index !== -1) {\n state[hostName][index].node = node\n } else {\n state[hostName].push({\n name: portalName,\n node,\n })\n }\n return state\n}\n\nconst removePortal = (\n state: Record<string, Array<PortalType>>,\n hostName: string,\n portalName: string\n) => {\n if (!(hostName in state)) {\n console.log(`Failed to remove portal '${portalName}', '${hostName}' was not registered!`)\n return state\n }\n\n const index = state[hostName].findIndex((item) => item.name === portalName)\n if (index !== -1) state[hostName].splice(index, 1)\n return state\n}\n\nconst reducer = (state: Record<string, Array<PortalType>>, action: ActionTypes) => {\n const { type } = action\n switch (type) {\n case ACTIONS.REGISTER_HOST:\n return registerHost({ ...state }, action.hostName)\n case ACTIONS.DEREGISTER_HOST:\n return deregisterHost({ ...state }, action.hostName)\n case ACTIONS.ADD_UPDATE_PORTAL:\n return addUpdatePortal(\n { ...state },\n action.hostName,\n (action as AddUpdatePortalAction).portalName,\n (action as AddUpdatePortalAction).node\n )\n case ACTIONS.REMOVE_PORTAL:\n return removePortal({ ...state }, action.hostName, (action as RemovePortalAction).portalName)\n default:\n return state\n }\n}\n\nconst PortalStateContext = createContext<Record<string, Array<PortalType>> | null>(null)\nconst PortalDispatchContext = createContext<React.Dispatch<ActionTypes> | null>(null)\n\nconst usePortalState = (hostName: string) => {\n const state = useContext(PortalStateContext)\n\n if (state === null) {\n throw new Error(\n \"'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component.\"\n )\n }\n\n return state[hostName] || []\n}\n\nexport const usePortal = (hostName = 'root') => {\n const dispatch = useContext(PortalDispatchContext)\n\n if (dispatch === null) {\n throw new Error(\n \"'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component.\"\n )\n }\n\n //#region methods\n const registerHost = useCallback(() => {\n dispatch({\n type: ACTIONS.REGISTER_HOST,\n hostName: hostName,\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const deregisterHost = useCallback(() => {\n dispatch({\n type: ACTIONS.DEREGISTER_HOST,\n hostName: hostName,\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const addUpdatePortal = useCallback((name: string, node: ReactNode) => {\n dispatch({\n type: ACTIONS.ADD_UPDATE_PORTAL,\n hostName,\n portalName: name,\n node,\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const removePortal = useCallback((name: string) => {\n dispatch({\n type: ACTIONS.REMOVE_PORTAL,\n hostName,\n portalName: name,\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n //#endregion\n\n return {\n registerHost,\n deregisterHost,\n addPortal: addUpdatePortal,\n updatePortal: addUpdatePortal,\n removePortal,\n }\n}\n\nexport interface PortalProviderProps {\n /**\n * Defines whether to add a default root host or not.\n *\n * @default true\n * @type boolean\n */\n shouldAddRootHost?: boolean\n\n /**\n * Defines the root portal host name.\n *\n * @default \"root\"\n * @type string\n */\n rootHostName?: string\n\n children: ReactNode | ReactNode[]\n}\n\nconst PortalProviderComponent = ({\n rootHostName = 'root',\n shouldAddRootHost = true,\n children,\n}: PortalProviderProps) => {\n const [state, dispatch] = useReducer(reducer, INITIAL_STATE)\n const transitionDispatch = useMemo(() => {\n const next = (value: any) => {\n startTransition(() => {\n dispatch(value)\n })\n }\n return next as typeof dispatch\n }, [dispatch])\n return (\n <PortalDispatchContext.Provider value={transitionDispatch}>\n <PortalStateContext.Provider value={state}>\n {children}\n {shouldAddRootHost && <PortalHost name={rootHostName} />}\n </PortalStateContext.Provider>\n </PortalDispatchContext.Provider>\n )\n}\n\nexport const PortalProvider = memo(PortalProviderComponent)\nPortalProvider.displayName = 'PortalProvider'\n\nexport interface PortalHostProps {\n /**\n * Host's key or name to be used as an identifier.\n * @type string\n */\n name: string\n}\n\nconst PortalHostComponent = ({ name }: PortalHostProps) => {\n //#region hooks\n const isServer = useIsSSR()\n const state = usePortalState(name)\n const { registerHost, deregisterHost } = usePortal(name)\n //#endregion\n\n //#region effects\n useEffect(() => {\n if (isServer) return\n registerHost()\n return () => {\n deregisterHost()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isServer])\n //#endregion\n\n //#region render\n return <>{state.map((item) => item.node)}</>\n //#endregion\n}\n\nexport const PortalHost = memo(PortalHostComponent)\nPortalHost.displayName = 'PortalHost'\n\nexport interface PortalItemProps {\n /**\n * Portal's key or name to be used as an identifier.\n * @type string\n * @default nanoid generated unique key.\n */\n name?: string\n /**\n * Host's name to teleport the portal content to.\n * @type string\n * @default 'root'\n */\n hostName?: string\n /**\n * Override internal mounting functionality, this is useful\n * if you want to trigger any action before mounting the portal content.\n * @type (mount?: () => void) => void\n * @default undefined\n */\n handleOnMount?: (mount: () => void) => void\n /**\n * Override internal un-mounting functionality, this is useful\n * if you want to trigger any action before un-mounting the portal content.\n * @type (unmount?: () => void) => void\n * @default undefined\n */\n handleOnUnmount?: (unmount: () => void) => void\n /**\n * Override internal updating functionality, this is useful\n * if you want to trigger any action before updating the portal content.\n * @type (update?: () => void) => void\n * @default undefined\n */\n handleOnUpdate?: (update: () => void) => void\n /**\n * Portal's content.\n * @type ReactNode\n * @default undefined\n */\n children?: ReactNode | ReactNode[]\n}\n\nconst PortalComponent = ({\n name: _providedName,\n hostName,\n handleOnMount: _providedHandleOnMount,\n handleOnUnmount: _providedHandleOnUnmount,\n handleOnUpdate: _providedHandleOnUpdate,\n children,\n}: PortalItemProps) => {\n //#region hooks\n const { addPortal: addUpdatePortal, removePortal } = usePortal(hostName)\n //#endregion\n\n let id = 0\n const nanoid = () => {\n id = (id + 1) % Number.MAX_SAFE_INTEGER\n return `${id}`\n }\n\n //#region variables\n const name = useMemo(() => _providedName || nanoid(), [_providedName])\n //#endregion\n\n //#region refs\n const handleOnMountRef = useRef<Function>()\n const handleOnUnmountRef = useRef<Function>()\n const handleOnUpdateRef = useRef<Function>()\n //#endregion\n\n //#region callbacks\n const handleOnMount = useCallback(() => {\n if (_providedHandleOnMount) {\n _providedHandleOnMount(() => addUpdatePortal(name, children))\n } else {\n addUpdatePortal(name, children)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [_providedHandleOnMount, addUpdatePortal])\n handleOnMountRef.current = handleOnMount\n\n const handleOnUnmount = useCallback(() => {\n if (_providedHandleOnUnmount) {\n _providedHandleOnUnmount(() => removePortal(name))\n } else {\n removePortal(name)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [_providedHandleOnUnmount, removePortal])\n handleOnUnmountRef.current = handleOnUnmount\n\n const handleOnUpdate = useCallback(() => {\n if (_providedHandleOnUpdate) {\n _providedHandleOnUpdate(() => addUpdatePortal(name, children))\n } else {\n addUpdatePortal(name, children)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [_providedHandleOnUpdate, addUpdatePortal, children])\n handleOnUpdateRef.current = handleOnUpdate\n //#endregion\n\n //#region effects\n useEffect(() => {\n handleOnMountRef.current?.()\n return () => {\n handleOnUnmountRef.current?.()\n\n // remove callbacks refs\n handleOnMountRef.current = undefined\n handleOnUnmountRef.current = undefined\n handleOnUpdateRef.current = undefined\n }\n }, [])\n useEffect(() => {\n handleOnUpdateRef.current?.()\n }, [children])\n //#endregion\n\n return null\n}\n\nexport const PortalItem = memo(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AAG7B,uBAAiB,UAAU;AAC3B,yBAAmB,UAAU;AAC7B,wBAAkB,UAAU;AAAA,IAC9B;AAAA,EACF,GAAG,CAAC,CAAC;AACL,YAAU,MAAM;AACd,sBAAkB,UAAU;AAAA,EAC9B,GAAG,CAAC,QAAQ,CAAC;AAGb,SAAO;AACT;AAEO,MAAM,aAAa,KAAK,eAAe;AAC9C,WAAW,cAAc;",
|
|
6
|
+
"names": ["ACTIONS", "registerHost", "deregisterHost", "addUpdatePortal", "removePortal"]
|
|
7
7
|
}
|
package/dist/jsx/Portal.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Portal.tsx"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport '@tamagui/polyfill-dev'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nexport type PortalProps = YStackProps & {\n host?: any // element\n}\n\nexport const Portal = ({ host = globalThis.document?.body, ...props }: PortalProps) => {\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n contain=\"strict\"\n fullscreen\n // @ts-expect-error ok on web\n position={isWeb ? 'fixed' : 'absolute'}\n maxWidth={isWeb ? '100vw' : '100%'}\n maxHeight={isWeb ? '100vh' : '100%'}\n {...props}\n />\n )\n\n const [hostElement, setHostElement] = React.useState<any>(null)\n\n useIsomorphicLayoutEffect(() => {\n setHostElement(host)\n }, [host])\n\n if (hostElement) {\n return createPortal(contents, hostElement)\n }\n\n // ssr return null\n return null\n}\n"],
|
|
5
|
-
"mappings": "AACA;
|
|
5
|
+
"mappings": "AACA,OAAO;AAEP,SAAS,OAAO,iCAAiC;AACjD,SAAS,cAA2B;AACpC,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAMtB,MAAM,SAAS,CAAC,EAAE,OAAO,WAAW,UAAU,SAAS,MAAM,MAAmB;AACrF,QAAM,WACJ,CAAC,OACC,cAAc,WACd,QAAQ,SACR,WAEA,UAAU,QAAQ,UAAU,YAC5B,UAAU,QAAQ,UAAU,QAC5B,WAAW,QAAQ,UAAU,YACzB,OACN;AAGF,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAc,IAAI;AAE9D,4BAA0B,MAAM;AAC9B,mBAAe,IAAI;AAAA,EACrB,GAAG,CAAC,IAAI,CAAC;AAET,MAAI,aAAa;AACf,WAAO,aAAa,UAAU,WAAW;AAAA,EAC3C;AAGA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Portal.native.tsx"],
|
|
4
4
|
"sourcesContent": ["import { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\n// @ts-ignore\nimport { RootTagContext } from 'react-native'\nimport { createPortal } from 'react-native/Libraries/Renderer/shims/ReactNative'\n\nexport type PortalProps = YStackProps\n\nexport const Portal = (props: PortalProps) => {\n const rootTag = React.useContext(RootTagContext)\n\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n fullscreen\n position=\"absolute\"\n maxWidth=\"100%\"\n zIndex={100000}\n {...props}\n />\n )\n\n if (rootTag) {\n return createPortal(contents, rootTag)\n }\n\n return null\n}\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,SAAS,cAA2B;AACpC,YAAY,WAAW;AAEvB,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAItB,MAAM,SAAS,CAAC,UAAuB;AAC5C,QAAM,UAAU,MAAM,WAAW,cAAc;AAE/C,QAAM,WACJ,CAAC,OACC,cAAc,WACd,WACA,SAAS,WACT,SAAS,OACT,QAAQ,SACJ,OACN;AAGF,MAAI,SAAS;AACX,WAAO,aAAa,UAAU,OAAO;AAAA,EACvC;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/index.js.map
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/portal",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.152",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"clean:build": "tamagui-build clean:build"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tamagui/core": "^1.0.1-beta.
|
|
24
|
-
"@tamagui/stacks": "^1.0.1-beta.
|
|
23
|
+
"@tamagui/core": "^1.0.1-beta.152",
|
|
24
|
+
"@tamagui/stacks": "^1.0.1-beta.152"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": "*",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"react-native": "*"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
32
|
+
"@tamagui/build": "^1.0.1-beta.152",
|
|
33
33
|
"@types/react-native": "^0.69.2",
|
|
34
34
|
"react": "*",
|
|
35
35
|
"react-dom": "*",
|