@tamagui/portal 1.0.10 → 1.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/portal",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -19,9 +19,9 @@
19
19
  "clean:build": "tamagui-build clean:build"
20
20
  },
21
21
  "dependencies": {
22
- "@tamagui/core": "^1.0.10",
23
- "@tamagui/stacks": "^1.0.10",
24
- "@tamagui/use-event": "^1.0.10"
22
+ "@tamagui/core": "^1.0.12",
23
+ "@tamagui/stacks": "^1.0.12",
24
+ "@tamagui/use-event": "^1.0.12"
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.10",
32
+ "@tamagui/build": "^1.0.12",
33
33
  "react": "^18.2.0",
34
34
  "react-dom": "^18.2.0",
35
35
  "react-native": "*"
@@ -1,213 +0,0 @@
1
- import { startTransition, useIsSSR } from "@tamagui/core";
2
- import { nanoid } from "nanoid/non-secure";
3
- import { useMemo, useRef } from "react";
4
- import { createContext, memo, useCallback, useContext, useEffect, useReducer } from "react";
5
- var ACTIONS = /* @__PURE__ */ ((ACTIONS2) => {
6
- ACTIONS2[ACTIONS2["REGISTER_HOST"] = 0] = "REGISTER_HOST";
7
- ACTIONS2[ACTIONS2["DEREGISTER_HOST"] = 1] = "DEREGISTER_HOST";
8
- ACTIONS2[ACTIONS2["ADD_UPDATE_PORTAL"] = 2] = "ADD_UPDATE_PORTAL";
9
- ACTIONS2[ACTIONS2["REMOVE_PORTAL"] = 3] = "REMOVE_PORTAL";
10
- return ACTIONS2;
11
- })(ACTIONS || {});
12
- const INITIAL_STATE = {};
13
- const registerHost = (state, hostName) => {
14
- if (!(hostName in state)) {
15
- state[hostName] = [];
16
- }
17
- return state;
18
- };
19
- const deregisterHost = (state, hostName) => {
20
- delete state[hostName];
21
- return state;
22
- };
23
- const addUpdatePortal = (state, hostName, portalName, node) => {
24
- if (!(hostName in state)) {
25
- state = registerHost(state, hostName);
26
- }
27
- const index = state[hostName].findIndex((item) => item.name === portalName);
28
- if (index !== -1) {
29
- state[hostName][index].node = node;
30
- } else {
31
- state[hostName].push({
32
- name: portalName,
33
- node
34
- });
35
- }
36
- return state;
37
- };
38
- const removePortal = (state, hostName, portalName) => {
39
- if (!(hostName in state)) {
40
- console.log(`Failed to remove portal '${portalName}', '${hostName}' was not registered!`);
41
- return state;
42
- }
43
- const index = state[hostName].findIndex((item) => item.name === portalName);
44
- if (index !== -1)
45
- state[hostName].splice(index, 1);
46
- return state;
47
- };
48
- const reducer = (state, action) => {
49
- const { type } = action;
50
- switch (type) {
51
- case 0 /* REGISTER_HOST */:
52
- return registerHost({ ...state }, action.hostName);
53
- case 1 /* DEREGISTER_HOST */:
54
- return deregisterHost({ ...state }, action.hostName);
55
- case 2 /* ADD_UPDATE_PORTAL */:
56
- return addUpdatePortal({ ...state }, action.hostName, action.portalName, action.node);
57
- case 3 /* REMOVE_PORTAL */:
58
- return removePortal({ ...state }, action.hostName, action.portalName);
59
- default:
60
- return state;
61
- }
62
- };
63
- const PortalStateContext = createContext(null);
64
- const PortalDispatchContext = createContext(null);
65
- const usePortalState = (hostName) => {
66
- const state = useContext(PortalStateContext);
67
- if (state === null) {
68
- throw new Error("'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component.");
69
- }
70
- return state[hostName] || [];
71
- };
72
- const usePortal = (hostName = "root") => {
73
- const dispatch = useContext(PortalDispatchContext);
74
- if (dispatch === null) {
75
- throw new Error("'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component.");
76
- }
77
- const registerHost2 = useCallback(() => {
78
- dispatch({
79
- type: 0 /* REGISTER_HOST */,
80
- hostName
81
- });
82
- }, []);
83
- const deregisterHost2 = useCallback(() => {
84
- dispatch({
85
- type: 1 /* DEREGISTER_HOST */,
86
- hostName
87
- });
88
- }, []);
89
- const addUpdatePortal2 = useCallback((name, node) => {
90
- dispatch({
91
- type: 2 /* ADD_UPDATE_PORTAL */,
92
- hostName,
93
- portalName: name,
94
- node
95
- });
96
- }, []);
97
- const removePortal2 = useCallback((name) => {
98
- dispatch({
99
- type: 3 /* REMOVE_PORTAL */,
100
- hostName,
101
- portalName: name
102
- });
103
- }, []);
104
- return {
105
- registerHost: registerHost2,
106
- deregisterHost: deregisterHost2,
107
- addPortal: addUpdatePortal2,
108
- updatePortal: addUpdatePortal2,
109
- removePortal: removePortal2
110
- };
111
- };
112
- const PortalProviderComponent = ({
113
- rootHostName = "root",
114
- shouldAddRootHost = true,
115
- children
116
- }) => {
117
- const [state, dispatch] = useReducer(reducer, INITIAL_STATE);
118
- const transitionDispatch = useMemo(() => {
119
- const next = (value) => {
120
- startTransition(() => {
121
- dispatch(value);
122
- });
123
- };
124
- return next;
125
- }, [dispatch]);
126
- return <PortalDispatchContext.Provider value={transitionDispatch}><PortalStateContext.Provider value={state}>
127
- {children}
128
- {shouldAddRootHost && <PortalHost name={rootHostName} />}
129
- </PortalStateContext.Provider></PortalDispatchContext.Provider>;
130
- };
131
- const PortalProvider = memo(PortalProviderComponent);
132
- PortalProvider.displayName = "PortalProvider";
133
- const PortalHostComponent = ({ name }) => {
134
- const isServer = useIsSSR();
135
- const state = usePortalState(name);
136
- const { registerHost: registerHost2, deregisterHost: deregisterHost2 } = usePortal(name);
137
- useEffect(() => {
138
- if (isServer)
139
- return;
140
- registerHost2();
141
- return () => {
142
- deregisterHost2();
143
- };
144
- }, [isServer]);
145
- return <>{state.map((item) => item.node)}</>;
146
- };
147
- const PortalHost = memo(PortalHostComponent);
148
- PortalHost.displayName = "PortalHost";
149
- const PortalComponent = ({
150
- name: _providedName,
151
- hostName,
152
- handleOnMount: _providedHandleOnMount,
153
- handleOnUnmount: _providedHandleOnUnmount,
154
- handleOnUpdate: _providedHandleOnUpdate,
155
- children
156
- }) => {
157
- const { addPortal: addUpdatePortal2, removePortal: removePortal2 } = usePortal(hostName);
158
- const name = useMemo(() => _providedName || nanoid(), [_providedName]);
159
- const handleOnMountRef = useRef();
160
- const handleOnUnmountRef = useRef();
161
- const handleOnUpdateRef = useRef();
162
- const handleOnMount = useCallback(() => {
163
- if (_providedHandleOnMount) {
164
- _providedHandleOnMount(() => addUpdatePortal2(name, children));
165
- } else {
166
- addUpdatePortal2(name, children);
167
- }
168
- }, [_providedHandleOnMount, addUpdatePortal2]);
169
- handleOnMountRef.current = handleOnMount;
170
- const handleOnUnmount = useCallback(() => {
171
- if (_providedHandleOnUnmount) {
172
- _providedHandleOnUnmount(() => removePortal2(name));
173
- } else {
174
- removePortal2(name);
175
- }
176
- }, [_providedHandleOnUnmount, removePortal2]);
177
- handleOnUnmountRef.current = handleOnUnmount;
178
- const handleOnUpdate = useCallback(() => {
179
- if (_providedHandleOnUpdate) {
180
- _providedHandleOnUpdate(() => addUpdatePortal2(name, children));
181
- } else {
182
- addUpdatePortal2(name, children);
183
- }
184
- }, [_providedHandleOnUpdate, addUpdatePortal2, children]);
185
- handleOnUpdateRef.current = handleOnUpdate;
186
- useEffect(() => {
187
- var _a;
188
- (_a = handleOnMountRef.current) == null ? void 0 : _a.call(handleOnMountRef);
189
- return () => {
190
- var _a2;
191
- (_a2 = handleOnUnmountRef.current) == null ? void 0 : _a2.call(handleOnUnmountRef);
192
- handleOnMountRef.current = void 0;
193
- handleOnUnmountRef.current = void 0;
194
- handleOnUpdateRef.current = void 0;
195
- };
196
- }, []);
197
- useEffect(() => {
198
- var _a;
199
- (_a = handleOnUpdateRef.current) == null ? void 0 : _a.call(handleOnUpdateRef);
200
- }, [children]);
201
- return null;
202
- };
203
- const PortalItem = memo(PortalComponent);
204
- PortalItem.displayName = "Portal";
205
- export {
206
- ACTIONS,
207
- INITIAL_STATE,
208
- PortalHost,
209
- PortalItem,
210
- PortalProvider,
211
- usePortal
212
- };
213
- //# sourceMappingURL=GorhomPortal.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/GorhomPortal.tsx"],
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 { nanoid } from 'nanoid/non-secure'\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 //#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": "AAIA;AACA;AACA;AACA;AAOA,IAAK,UAAL,kBAAK,aAAL;AACE;AACA;AACA;AACA;AAJG;AAAA;AAOL,MAAM,gBAAgB,CAAC;AAiCvB,MAAM,eAAe,CAAC,OAA0C,aAAqB;AACnF,MAAI,CAAE,aAAY,QAAQ;AACxB,UAAM,YAAY,CAAC;AAAA,EACrB;AACA,SAAO;AACT;AAEA,MAAM,iBAAiB,CAAC,OAA0C,aAAqB;AACrF,SAAO,MAAM;AACb,SAAO;AACT;AAEA,MAAM,kBAAkB,CACtB,OACA,UACA,YACA,SACG;AACH,MAAI,CAAE,aAAY,QAAQ;AACxB,YAAQ,aAAa,OAAO,QAAQ;AAAA,EACtC;AAKA,QAAM,QAAQ,MAAM,UAAU,UAAU,CAAC,SAAS,KAAK,SAAS,UAAU;AAC1E,MAAI,UAAU,IAAI;AAChB,UAAM,UAAU,OAAO,OAAO;AAAA,EAChC,OAAO;AACL,UAAM,UAAU,KAAK;AAAA,MACnB,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH;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AAwXI,2BAAiB,YAAjB;AACA,WAAO,MAAM;AAzXjB;AA0XM,gCAAmB,YAAnB;AAGA,uBAAiB,UAAU;AAC3B,yBAAmB,UAAU;AAC7B,wBAAkB,UAAU;AAAA,IAC9B;AAAA,EACF,GAAG,CAAC,CAAC;AACL,YAAU,MAAM;AAlYlB;AAmYI,4BAAkB,YAAlB;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAGb,SAAO;AACT;AAEO,MAAM,aAAa,KAAK,eAAe;AAC9C,WAAW,cAAc;",
6
- "names": []
7
- }
@@ -1,20 +0,0 @@
1
- import "@tamagui/polyfill-dev";
2
- import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/core";
3
- import { YStack } from "@tamagui/stacks";
4
- import * as React from "react";
5
- import { createPortal } from "react-dom";
6
- const Portal = ({ host = ((_a) => (_a = globalThis.document) == null ? void 0 : _a.body)(), ...props }) => {
7
- const contents = <YStack pointerEvents="box-none" fullscreen position={isWeb ? "fixed" : "absolute"} maxWidth={isWeb ? "100vw" : "100%"} maxHeight={isWeb ? "100vh" : "100%"} {...props} />;
8
- const [hostElement, setHostElement] = React.useState(null);
9
- useIsomorphicLayoutEffect(() => {
10
- setHostElement(host);
11
- }, [host]);
12
- if (hostElement) {
13
- return createPortal(contents, hostElement);
14
- }
15
- return null;
16
- };
17
- export {
18
- Portal
19
- };
20
- //# sourceMappingURL=Portal.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/Portal.tsx"],
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 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;AAEA;AACA;AACA;AACA;AAMO,MAAM,SAAS,CAAC,EAAE,OAAO,0BAAW,aAAX,mBAAqB,YAAS,YAAyB;AACrF,QAAM,WACJ,CAAC,OACC,cAAc,WACd,WAEA,UAAU,QAAQ,UAAU,YAC5B,UAAU,QAAQ,UAAU,QAC5B,WAAW,QAAQ,UAAU,YACzB,OACN;AAGF,QAAM,CAAC,aAAa,kBAAkB,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
- "names": []
7
- }
@@ -1,21 +0,0 @@
1
- import { YStack } from "@tamagui/stacks";
2
- import { AppRegistry } from "react-native";
3
- import { createPortal } from "react-native/Libraries/Renderer/shims/ReactNative";
4
- let root = 0;
5
- const og = AppRegistry.runApplication.bind(AppRegistry);
6
- AppRegistry.runApplication = function(...args) {
7
- var _a;
8
- root = (_a = args[1]) == null ? void 0 : _a.rootTag;
9
- return og(...args);
10
- };
11
- const Portal = (props) => {
12
- const contents = <YStack pointerEvents="box-none" fullscreen position="absolute" maxWidth="100%" zIndex={1e5} {...props} />;
13
- if (root) {
14
- return createPortal(contents, root);
15
- }
16
- return null;
17
- };
18
- export {
19
- Portal
20
- };
21
- //# sourceMappingURL=Portal.native.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/Portal.native.tsx"],
4
- "sourcesContent": ["import { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { AppRegistry } from 'react-native'\nimport { createPortal } from 'react-native/Libraries/Renderer/shims/ReactNative'\n\nexport type PortalProps = YStackProps\n\nlet root = 0\nconst og = AppRegistry.runApplication.bind(AppRegistry)\nAppRegistry.runApplication = function (...args) {\n root = args[1]?.rootTag\n return og(...args)\n}\n\nexport const Portal = (props: PortalProps) => {\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 (root) {\n return createPortal(contents, root)\n }\n\n return null\n}\n"],
5
- "mappings": "AAAA;AAEA;AACA;AAIA,IAAI,OAAO;AACX,MAAM,KAAK,YAAY,eAAe,KAAK,WAAW;AACtD,YAAY,iBAAiB,YAAa,MAAM;AAThD;AAUE,SAAO,WAAK,OAAL,mBAAS;AAChB,SAAO,GAAG,GAAG,IAAI;AACnB;AAEO,MAAM,SAAS,CAAC,UAAuB;AAC5C,QAAM,WACJ,CAAC,OACC,cAAc,WACd,WACA,SAAS,WACT,SAAS,OACT,QAAQ,SACJ,OACN;AAGF,MAAI,MAAM;AACR,WAAO,aAAa,UAAU,IAAI;AAAA,EACpC;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=PortalProps.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
package/dist/jsx/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from "./Portal";
2
- export * from "./GorhomPortal";
3
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.tsx"],
4
- "sourcesContent": ["export * from './Portal'\nexport * from './GorhomPortal'\n"],
5
- "mappings": "AAAA;AACA;",
6
- "names": []
7
- }