@tamagui/portal 1.13.2 → 1.13.4
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 +1 -270
- package/dist/cjs/GorhomPortal.js.map +2 -2
- package/dist/cjs/Portal.js +1 -65
- package/dist/cjs/Portal.js.map +2 -2
- package/dist/cjs/Portal.native.js +1 -69
- package/dist/cjs/Portal.native.js.map +2 -2
- package/dist/cjs/PortalProps.js +1 -16
- package/dist/cjs/PortalProps.js.map +2 -2
- package/dist/cjs/index.js +1 -20
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/GorhomPortal.js +1 -241
- package/dist/esm/GorhomPortal.js.map +2 -2
- package/dist/esm/GorhomPortal.mjs +1 -241
- package/dist/esm/GorhomPortal.mjs.map +2 -2
- package/dist/esm/Portal.js +1 -31
- package/dist/esm/Portal.js.map +2 -2
- package/dist/esm/Portal.mjs +1 -31
- package/dist/esm/Portal.mjs.map +2 -2
- package/dist/esm/Portal.native.js +1 -35
- package/dist/esm/Portal.native.js.map +2 -2
- package/dist/esm/Portal.native.mjs +1 -35
- package/dist/esm/Portal.native.mjs.map +2 -2
- package/dist/esm/index.js +1 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -3
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/esm/GorhomPortal.js
CHANGED
|
@@ -1,242 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useDidFinishSSR, useEvent, useIsomorphicLayoutEffect } from "@tamagui/core";
|
|
3
|
-
import React, {
|
|
4
|
-
createContext,
|
|
5
|
-
memo,
|
|
6
|
-
startTransition,
|
|
7
|
-
useCallback,
|
|
8
|
-
useContext,
|
|
9
|
-
useEffect,
|
|
10
|
-
useId,
|
|
11
|
-
useMemo,
|
|
12
|
-
useReducer
|
|
13
|
-
} from "react";
|
|
14
|
-
var ACTIONS = /* @__PURE__ */ ((ACTIONS2) => {
|
|
15
|
-
ACTIONS2[ACTIONS2["REGISTER_HOST"] = 0] = "REGISTER_HOST";
|
|
16
|
-
ACTIONS2[ACTIONS2["DEREGISTER_HOST"] = 1] = "DEREGISTER_HOST";
|
|
17
|
-
ACTIONS2[ACTIONS2["ADD_UPDATE_PORTAL"] = 2] = "ADD_UPDATE_PORTAL";
|
|
18
|
-
ACTIONS2[ACTIONS2["REMOVE_PORTAL"] = 3] = "REMOVE_PORTAL";
|
|
19
|
-
return ACTIONS2;
|
|
20
|
-
})(ACTIONS || {});
|
|
21
|
-
const INITIAL_STATE = {};
|
|
22
|
-
const registerHost = (state, hostName) => {
|
|
23
|
-
if (!(hostName in state)) {
|
|
24
|
-
state[hostName] = [];
|
|
25
|
-
}
|
|
26
|
-
return state;
|
|
27
|
-
};
|
|
28
|
-
const deregisterHost = (state, hostName) => {
|
|
29
|
-
delete state[hostName];
|
|
30
|
-
return state;
|
|
31
|
-
};
|
|
32
|
-
const addUpdatePortal = (state, hostName, portalName, node) => {
|
|
33
|
-
if (!(hostName in state)) {
|
|
34
|
-
state = registerHost(state, hostName);
|
|
35
|
-
}
|
|
36
|
-
const index = state[hostName].findIndex((item) => item.name === portalName);
|
|
37
|
-
if (index !== -1) {
|
|
38
|
-
state[hostName][index].node = node;
|
|
39
|
-
} else {
|
|
40
|
-
state[hostName].push({
|
|
41
|
-
name: portalName,
|
|
42
|
-
node
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return state;
|
|
46
|
-
};
|
|
47
|
-
const removePortal = (state, hostName, portalName) => {
|
|
48
|
-
if (!(hostName in state)) {
|
|
49
|
-
console.log(
|
|
50
|
-
`Failed to remove portal '${portalName}', '${hostName}' was not registered!`
|
|
51
|
-
);
|
|
52
|
-
return state;
|
|
53
|
-
}
|
|
54
|
-
const index = state[hostName].findIndex((item) => item.name === portalName);
|
|
55
|
-
if (index !== -1)
|
|
56
|
-
state[hostName].splice(index, 1);
|
|
57
|
-
return state;
|
|
58
|
-
};
|
|
59
|
-
const reducer = (state, action) => {
|
|
60
|
-
const { type } = action;
|
|
61
|
-
switch (type) {
|
|
62
|
-
case 0 /* REGISTER_HOST */:
|
|
63
|
-
return registerHost({ ...state }, action.hostName);
|
|
64
|
-
case 1 /* DEREGISTER_HOST */:
|
|
65
|
-
return deregisterHost({ ...state }, action.hostName);
|
|
66
|
-
case 2 /* ADD_UPDATE_PORTAL */:
|
|
67
|
-
return addUpdatePortal(
|
|
68
|
-
{ ...state },
|
|
69
|
-
action.hostName,
|
|
70
|
-
action.portalName,
|
|
71
|
-
action.node
|
|
72
|
-
);
|
|
73
|
-
case 3 /* REMOVE_PORTAL */:
|
|
74
|
-
return removePortal(
|
|
75
|
-
{ ...state },
|
|
76
|
-
action.hostName,
|
|
77
|
-
action.portalName
|
|
78
|
-
);
|
|
79
|
-
default:
|
|
80
|
-
return state;
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const PortalStateContext = createContext(null);
|
|
84
|
-
const PortalDispatchContext = createContext(null);
|
|
85
|
-
const usePortalState = (hostName) => {
|
|
86
|
-
const state = useContext(PortalStateContext);
|
|
87
|
-
if (state === null) {
|
|
88
|
-
throw new Error(
|
|
89
|
-
"'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component."
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
return state[hostName] || [];
|
|
93
|
-
};
|
|
94
|
-
const usePortal = (hostName = "root") => {
|
|
95
|
-
const dispatch = useContext(PortalDispatchContext);
|
|
96
|
-
if (dispatch === null) {
|
|
97
|
-
throw new Error(
|
|
98
|
-
"'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component."
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
const registerHost2 = useCallback(() => {
|
|
102
|
-
dispatch({
|
|
103
|
-
type: 0 /* REGISTER_HOST */,
|
|
104
|
-
hostName
|
|
105
|
-
});
|
|
106
|
-
}, []);
|
|
107
|
-
const deregisterHost2 = useCallback(() => {
|
|
108
|
-
dispatch({
|
|
109
|
-
type: 1 /* DEREGISTER_HOST */,
|
|
110
|
-
hostName
|
|
111
|
-
});
|
|
112
|
-
}, []);
|
|
113
|
-
const addUpdatePortal2 = useCallback((name, node) => {
|
|
114
|
-
dispatch({
|
|
115
|
-
type: 2 /* ADD_UPDATE_PORTAL */,
|
|
116
|
-
hostName,
|
|
117
|
-
portalName: name,
|
|
118
|
-
node
|
|
119
|
-
});
|
|
120
|
-
}, []);
|
|
121
|
-
const removePortal2 = useCallback((name) => {
|
|
122
|
-
dispatch({
|
|
123
|
-
type: 3 /* REMOVE_PORTAL */,
|
|
124
|
-
hostName,
|
|
125
|
-
portalName: name
|
|
126
|
-
});
|
|
127
|
-
}, []);
|
|
128
|
-
return {
|
|
129
|
-
registerHost: registerHost2,
|
|
130
|
-
deregisterHost: deregisterHost2,
|
|
131
|
-
addPortal: addUpdatePortal2,
|
|
132
|
-
updatePortal: addUpdatePortal2,
|
|
133
|
-
removePortal: removePortal2
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
const PortalProviderComponent = ({
|
|
137
|
-
rootHostName = "root",
|
|
138
|
-
shouldAddRootHost = true,
|
|
139
|
-
children
|
|
140
|
-
}) => {
|
|
141
|
-
const [state, dispatch] = useReducer(reducer, INITIAL_STATE);
|
|
142
|
-
const transitionDispatch = useMemo(() => {
|
|
143
|
-
const next = (value) => {
|
|
144
|
-
startTransition(() => {
|
|
145
|
-
dispatch(value);
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
return next;
|
|
149
|
-
}, [dispatch]);
|
|
150
|
-
return /* @__PURE__ */ jsx(PortalDispatchContext.Provider, { value: transitionDispatch, children: /* @__PURE__ */ jsxs(PortalStateContext.Provider, { value: state, children: [
|
|
151
|
-
children,
|
|
152
|
-
shouldAddRootHost && /* @__PURE__ */ jsx(PortalHost, { name: rootHostName })
|
|
153
|
-
] }) });
|
|
154
|
-
};
|
|
155
|
-
const PortalProvider = memo(PortalProviderComponent);
|
|
156
|
-
PortalProvider.displayName = "PortalProvider";
|
|
157
|
-
const defaultRenderer = (children) => /* @__PURE__ */ jsx(Fragment, { children });
|
|
158
|
-
const PortalHostComponent = (props) => {
|
|
159
|
-
const { name, forwardProps, render = defaultRenderer } = props;
|
|
160
|
-
const isServer = !useDidFinishSSR();
|
|
161
|
-
const state = usePortalState(name);
|
|
162
|
-
const { registerHost: registerHost2, deregisterHost: deregisterHost2 } = usePortal(props.name);
|
|
163
|
-
useEffect(() => {
|
|
164
|
-
if (isServer)
|
|
165
|
-
return;
|
|
166
|
-
registerHost2();
|
|
167
|
-
return () => {
|
|
168
|
-
deregisterHost2();
|
|
169
|
-
};
|
|
170
|
-
}, [isServer]);
|
|
171
|
-
if (forwardProps) {
|
|
172
|
-
return render(
|
|
173
|
-
state.map((item) => {
|
|
174
|
-
let next = item.node;
|
|
175
|
-
if (forwardProps) {
|
|
176
|
-
return React.Children.map(next, (child) => {
|
|
177
|
-
return React.isValidElement(child) ? React.cloneElement(child, { key: child.key, ...forwardProps }) : child;
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
return next;
|
|
181
|
-
})
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
return render(state.map((item) => item.node));
|
|
185
|
-
};
|
|
186
|
-
const PortalHost = memo(PortalHostComponent);
|
|
187
|
-
PortalHost.displayName = "PortalHost";
|
|
188
|
-
const PortalComponent = (props) => {
|
|
189
|
-
const {
|
|
190
|
-
name: _providedName,
|
|
191
|
-
hostName,
|
|
192
|
-
handleOnMount: _providedHandleOnMount,
|
|
193
|
-
handleOnUnmount: _providedHandleOnUnmount,
|
|
194
|
-
handleOnUpdate: _providedHandleOnUpdate,
|
|
195
|
-
children
|
|
196
|
-
} = props;
|
|
197
|
-
const { addPortal: addUpdatePortal2, removePortal: removePortal2 } = usePortal(hostName);
|
|
198
|
-
const id = useId();
|
|
199
|
-
const name = _providedName || id;
|
|
200
|
-
const handleOnMount = useEvent(() => {
|
|
201
|
-
if (_providedHandleOnMount) {
|
|
202
|
-
_providedHandleOnMount(() => addUpdatePortal2(name, children));
|
|
203
|
-
} else {
|
|
204
|
-
addUpdatePortal2(name, children);
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
const handleOnUnmount = useEvent(() => {
|
|
208
|
-
if (_providedHandleOnUnmount) {
|
|
209
|
-
_providedHandleOnUnmount(() => removePortal2(name));
|
|
210
|
-
} else {
|
|
211
|
-
removePortal2(name);
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
const handleOnUpdate = useEvent(() => {
|
|
215
|
-
if (_providedHandleOnUpdate) {
|
|
216
|
-
_providedHandleOnUpdate(() => addUpdatePortal2(name, children));
|
|
217
|
-
} else {
|
|
218
|
-
addUpdatePortal2(name, children);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
useIsomorphicLayoutEffect(() => {
|
|
222
|
-
handleOnMount();
|
|
223
|
-
return () => {
|
|
224
|
-
handleOnUnmount();
|
|
225
|
-
};
|
|
226
|
-
}, []);
|
|
227
|
-
useEffect(() => {
|
|
228
|
-
handleOnUpdate();
|
|
229
|
-
}, [children]);
|
|
230
|
-
return null;
|
|
231
|
-
};
|
|
232
|
-
const PortalItem = memo(PortalComponent);
|
|
233
|
-
PortalItem.displayName = "Portal";
|
|
234
|
-
export {
|
|
235
|
-
ACTIONS,
|
|
236
|
-
INITIAL_STATE,
|
|
237
|
-
PortalHost,
|
|
238
|
-
PortalItem,
|
|
239
|
-
PortalProvider,
|
|
240
|
-
usePortal
|
|
241
|
-
};
|
|
1
|
+
import{Fragment as K,jsx as R,jsxs as J}from"react/jsx-runtime";import{useDidFinishSSR as I,useEvent as P,useIsomorphicLayoutEffect as U}from"@tamagui/core";import u,{createContext as A,memo as m,startTransition as _,useCallback as p,useContext as g,useEffect as T,useId as D,useMemo as C,useReducer as w}from"react";var y=(r=>(r[r.REGISTER_HOST=0]="REGISTER_HOST",r[r.DEREGISTER_HOST=1]="DEREGISTER_HOST",r[r.ADD_UPDATE_PORTAL=2]="ADD_UPDATE_PORTAL",r[r.REMOVE_PORTAL=3]="REMOVE_PORTAL",r))(y||{});const f={},E=(e,t)=>(t in e||(e[t]=[]),e),L=(e,t)=>(delete e[t],e),M=(e,t,o,n)=>{t in e||(e=E(e,t));const r=e[t].findIndex(s=>s.name===o);return r!==-1?e[t][r].node=n:e[t].push({name:o,node:n}),e},G=(e,t,o)=>{if(!(t in e))return console.log(`Failed to remove portal '${o}', '${t}' was not registered!`),e;const n=e[t].findIndex(r=>r.name===o);return n!==-1&&e[t].splice(n,1),e},b=(e,t)=>{const{type:o}=t;switch(o){case 0:return E({...e},t.hostName);case 1:return L({...e},t.hostName);case 2:return M({...e},t.hostName,t.portalName,t.node);case 3:return G({...e},t.hostName,t.portalName);default:return e}},v=A(null),O=A(null),V=e=>{const t=g(v);if(t===null)throw new Error("'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component.");return t[e]||[]},h=(e="root")=>{const t=g(O);if(t===null)throw new Error("'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component.");const o=p(()=>{t({type:0,hostName:e})},[]),n=p(()=>{t({type:1,hostName:e})},[]),r=p((a,i)=>{t({type:2,hostName:e,portalName:a,node:i})},[]),s=p(a=>{t({type:3,hostName:e,portalName:a})},[]);return{registerHost:o,deregisterHost:n,addPortal:r,updatePortal:r,removePortal:s}},k=({rootHostName:e="root",shouldAddRootHost:t=!0,children:o})=>{const[n,r]=w(b,f),s=C(()=>i=>{_(()=>{r(i)})},[r]);return R(O.Provider,{value:s,children:J(v.Provider,{value:n,children:[o,t&&R(x,{name:e})]})})},F=m(k);F.displayName="PortalProvider";const $=e=>R(K,{children:e}),q=e=>{const{name:t,forwardProps:o,render:n=$}=e,r=!I(),s=V(t),{registerHost:a,deregisterHost:i}=h(e.name);return T(()=>{if(!r)return a(),()=>{i()}},[r]),n(o?s.map(l=>{let c=l.node;return o?u.Children.map(c,d=>u.isValidElement(d)?u.cloneElement(d,{key:d.key,...o}):d):c}):s.map(l=>l.node))},x=m(q);x.displayName="PortalHost";const z=e=>{const{name:t,hostName:o,handleOnMount:n,handleOnUnmount:r,handleOnUpdate:s,children:a}=e,{addPortal:i,removePortal:l}=h(o),c=D(),d=t||c,H=P(()=>{n?n(()=>i(d,a)):i(d,a)}),N=P(()=>{r?r(()=>l(d)):l(d)}),S=P(()=>{s?s(()=>i(d,a)):i(d,a)});return U(()=>(H(),()=>{N()}),[]),T(()=>{S()},[a]),null},B=m(z);B.displayName="Portal";export{y as ACTIONS,f as INITIAL_STATE,x as PortalHost,B as PortalItem,F as PortalProvider,h as usePortal};
|
|
242
2
|
//# sourceMappingURL=GorhomPortal.js.map
|
|
@@ -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\nimport { useDidFinishSSR, useEvent, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport React, {\n ReactNode,\n createContext,\n memo,\n startTransition,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useReducer,\n} 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 // eslint-disable-next-line no-console\n console.log(\n `Failed to remove portal '${portalName}', '${hostName}' was not registered!`\n )\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(\n { ...state },\n action.hostName,\n (action as RemovePortalAction).portalName\n )\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\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 forwardProps?: Record<string, any>\n\n /**\n * Useful when trying to animate children with AnimatePresence.\n *\n * Not a part of gorhom/react-native-portal\n */\n render?: (children: React.ReactNode) => React.ReactElement\n}\nconst defaultRenderer: PortalHostProps['render'] = (children) => <>{children}</>\n\nconst PortalHostComponent = (props: PortalHostProps) => {\n const { name, forwardProps, render = defaultRenderer } = props\n const isServer = !useDidFinishSSR()\n const state = usePortalState(name)\n const { registerHost, deregisterHost } = usePortal(props.name)\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 if (forwardProps) {\n return render(\n state.map((item) => {\n let next = item.node\n\n if (forwardProps) {\n return React.Children.map(next, (child) => {\n return React.isValidElement(child)\n ? React.cloneElement(child, { key: child.key, ...forwardProps })\n : child\n })\n }\n\n return next\n })\n )\n }\n\n //#region render\n return render(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 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 = (props: PortalItemProps) => {\n const {\n name: _providedName,\n hostName,\n handleOnMount: _providedHandleOnMount,\n handleOnUnmount: _providedHandleOnUnmount,\n handleOnUpdate: _providedHandleOnUpdate,\n children,\n } = props\n const { addPortal: addUpdatePortal, removePortal } = usePortal(hostName)\n const id = useId()\n const name = _providedName || id\n\n const handleOnMount = useEvent(() => {\n if (_providedHandleOnMount) {\n _providedHandleOnMount(() => addUpdatePortal(name, children))\n } else {\n addUpdatePortal(name, children)\n }\n })\n\n const handleOnUnmount = useEvent(() => {\n if (_providedHandleOnUnmount) {\n _providedHandleOnUnmount(() => removePortal(name))\n } else {\n removePortal(name)\n }\n })\n\n const handleOnUpdate = useEvent(() => {\n if (_providedHandleOnUpdate) {\n _providedHandleOnUpdate(() => addUpdatePortal(name, children))\n } else {\n addUpdatePortal(name, children)\n }\n })\n\n useIsomorphicLayoutEffect(() => {\n handleOnMount()\n return () => {\n handleOnUnmount()\n }\n }, [])\n\n useEffect(() => {\n handleOnUpdate()\n }, [children])\n\n return null\n}\n\nexport const PortalItem = memo(PortalComponent)\nPortalItem.displayName = 'Portal'\n"],
|
|
5
|
-
"mappings": "AAyPM,
|
|
6
|
-
"names": ["ACTIONS", "registerHost", "deregisterHost", "addUpdatePortal", "removePortal"]
|
|
5
|
+
"mappings": "AAyPM,OA2B2D,YAAAA,EAzBnC,OAAAC,EAFxB,QAAAC,MAAA,oBAtPN,OAAS,mBAAAC,EAAiB,YAAAC,EAAU,6BAAAC,MAAiC,gBACrE,OAAOC,GAEL,iBAAAC,EACA,QAAAC,EACA,mBAAAC,EACA,eAAAC,EACA,cAAAC,EACA,aAAAC,EACA,SAAAC,EACA,WAAAC,EACA,cAAAC,MACK,QAOP,IAAKC,OACHA,IAAA,iCACAA,IAAA,qCACAA,IAAA,yCACAA,IAAA,iCAJGA,OAAA,IAOL,MA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E5DlB,EAAgBc,EAAMI,CAAQ,CAElC,CAAC,EAEKoB,EAAkBxD,EAAS,IAAM,CACjCoD,EACFA,EAAyB,IAAM7B,EAAaS,CAAI,CAAC,EAEjDT,EAAaS,CAAI,CAErB,CAAC,EAEKyB,EAAiBzD,EAAS,IAAM,CAChCqD,EACFA,EAAwB,IAAMnC,EAAgBc,EAAMI,CAAQ,CAAC,EAE7DlB,EAAgBc,EAAMI,CAAQ,CAElC,CAAC,EAED,OAAAnC,EAA0B,KACxBsD,EAAc,EACP,IAAM,CACXC,EAAgB,CAClB,GACC,CAAC,CAAC,EAELhD,EAAU,IAAM,CACdiD,EAAe,CACjB,EAAG,CAACrB,CAAQ,CAAC,EAEN,IACT,EAEasB,EAAatD,EAAK6C,CAAe,EAC9CS,EAAW,YAAc",
|
|
6
|
+
"names": ["Fragment", "jsx", "jsxs", "useDidFinishSSR", "useEvent", "useIsomorphicLayoutEffect", "React", "createContext", "memo", "startTransition", "useCallback", "useContext", "useEffect", "useId", "useMemo", "useReducer", "ACTIONS", "INITIAL_STATE", "registerHost", "state", "hostName", "deregisterHost", "addUpdatePortal", "portalName", "node", "index", "item", "removePortal", "reducer", "action", "type", "PortalStateContext", "PortalDispatchContext", "usePortalState", "usePortal", "dispatch", "name", "PortalProviderComponent", "rootHostName", "shouldAddRootHost", "children", "transitionDispatch", "value", "PortalHost", "PortalProvider", "defaultRenderer", "PortalHostComponent", "props", "forwardProps", "render", "isServer", "next", "child", "PortalComponent", "_providedName", "_providedHandleOnMount", "_providedHandleOnUnmount", "_providedHandleOnUpdate", "id", "handleOnMount", "handleOnUnmount", "handleOnUpdate", "PortalItem"]
|
|
7
7
|
}
|
|
@@ -1,242 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useDidFinishSSR, useEvent, useIsomorphicLayoutEffect } from "@tamagui/core";
|
|
3
|
-
import React, {
|
|
4
|
-
createContext,
|
|
5
|
-
memo,
|
|
6
|
-
startTransition,
|
|
7
|
-
useCallback,
|
|
8
|
-
useContext,
|
|
9
|
-
useEffect,
|
|
10
|
-
useId,
|
|
11
|
-
useMemo,
|
|
12
|
-
useReducer
|
|
13
|
-
} from "react";
|
|
14
|
-
var ACTIONS = /* @__PURE__ */ ((ACTIONS2) => {
|
|
15
|
-
ACTIONS2[ACTIONS2["REGISTER_HOST"] = 0] = "REGISTER_HOST";
|
|
16
|
-
ACTIONS2[ACTIONS2["DEREGISTER_HOST"] = 1] = "DEREGISTER_HOST";
|
|
17
|
-
ACTIONS2[ACTIONS2["ADD_UPDATE_PORTAL"] = 2] = "ADD_UPDATE_PORTAL";
|
|
18
|
-
ACTIONS2[ACTIONS2["REMOVE_PORTAL"] = 3] = "REMOVE_PORTAL";
|
|
19
|
-
return ACTIONS2;
|
|
20
|
-
})(ACTIONS || {});
|
|
21
|
-
const INITIAL_STATE = {};
|
|
22
|
-
const registerHost = (state, hostName) => {
|
|
23
|
-
if (!(hostName in state)) {
|
|
24
|
-
state[hostName] = [];
|
|
25
|
-
}
|
|
26
|
-
return state;
|
|
27
|
-
};
|
|
28
|
-
const deregisterHost = (state, hostName) => {
|
|
29
|
-
delete state[hostName];
|
|
30
|
-
return state;
|
|
31
|
-
};
|
|
32
|
-
const addUpdatePortal = (state, hostName, portalName, node) => {
|
|
33
|
-
if (!(hostName in state)) {
|
|
34
|
-
state = registerHost(state, hostName);
|
|
35
|
-
}
|
|
36
|
-
const index = state[hostName].findIndex((item) => item.name === portalName);
|
|
37
|
-
if (index !== -1) {
|
|
38
|
-
state[hostName][index].node = node;
|
|
39
|
-
} else {
|
|
40
|
-
state[hostName].push({
|
|
41
|
-
name: portalName,
|
|
42
|
-
node
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return state;
|
|
46
|
-
};
|
|
47
|
-
const removePortal = (state, hostName, portalName) => {
|
|
48
|
-
if (!(hostName in state)) {
|
|
49
|
-
console.log(
|
|
50
|
-
`Failed to remove portal '${portalName}', '${hostName}' was not registered!`
|
|
51
|
-
);
|
|
52
|
-
return state;
|
|
53
|
-
}
|
|
54
|
-
const index = state[hostName].findIndex((item) => item.name === portalName);
|
|
55
|
-
if (index !== -1)
|
|
56
|
-
state[hostName].splice(index, 1);
|
|
57
|
-
return state;
|
|
58
|
-
};
|
|
59
|
-
const reducer = (state, action) => {
|
|
60
|
-
const { type } = action;
|
|
61
|
-
switch (type) {
|
|
62
|
-
case 0 /* REGISTER_HOST */:
|
|
63
|
-
return registerHost({ ...state }, action.hostName);
|
|
64
|
-
case 1 /* DEREGISTER_HOST */:
|
|
65
|
-
return deregisterHost({ ...state }, action.hostName);
|
|
66
|
-
case 2 /* ADD_UPDATE_PORTAL */:
|
|
67
|
-
return addUpdatePortal(
|
|
68
|
-
{ ...state },
|
|
69
|
-
action.hostName,
|
|
70
|
-
action.portalName,
|
|
71
|
-
action.node
|
|
72
|
-
);
|
|
73
|
-
case 3 /* REMOVE_PORTAL */:
|
|
74
|
-
return removePortal(
|
|
75
|
-
{ ...state },
|
|
76
|
-
action.hostName,
|
|
77
|
-
action.portalName
|
|
78
|
-
);
|
|
79
|
-
default:
|
|
80
|
-
return state;
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const PortalStateContext = createContext(null);
|
|
84
|
-
const PortalDispatchContext = createContext(null);
|
|
85
|
-
const usePortalState = (hostName) => {
|
|
86
|
-
const state = useContext(PortalStateContext);
|
|
87
|
-
if (state === null) {
|
|
88
|
-
throw new Error(
|
|
89
|
-
"'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component."
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
return state[hostName] || [];
|
|
93
|
-
};
|
|
94
|
-
const usePortal = (hostName = "root") => {
|
|
95
|
-
const dispatch = useContext(PortalDispatchContext);
|
|
96
|
-
if (dispatch === null) {
|
|
97
|
-
throw new Error(
|
|
98
|
-
"'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component."
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
const registerHost2 = useCallback(() => {
|
|
102
|
-
dispatch({
|
|
103
|
-
type: 0 /* REGISTER_HOST */,
|
|
104
|
-
hostName
|
|
105
|
-
});
|
|
106
|
-
}, []);
|
|
107
|
-
const deregisterHost2 = useCallback(() => {
|
|
108
|
-
dispatch({
|
|
109
|
-
type: 1 /* DEREGISTER_HOST */,
|
|
110
|
-
hostName
|
|
111
|
-
});
|
|
112
|
-
}, []);
|
|
113
|
-
const addUpdatePortal2 = useCallback((name, node) => {
|
|
114
|
-
dispatch({
|
|
115
|
-
type: 2 /* ADD_UPDATE_PORTAL */,
|
|
116
|
-
hostName,
|
|
117
|
-
portalName: name,
|
|
118
|
-
node
|
|
119
|
-
});
|
|
120
|
-
}, []);
|
|
121
|
-
const removePortal2 = useCallback((name) => {
|
|
122
|
-
dispatch({
|
|
123
|
-
type: 3 /* REMOVE_PORTAL */,
|
|
124
|
-
hostName,
|
|
125
|
-
portalName: name
|
|
126
|
-
});
|
|
127
|
-
}, []);
|
|
128
|
-
return {
|
|
129
|
-
registerHost: registerHost2,
|
|
130
|
-
deregisterHost: deregisterHost2,
|
|
131
|
-
addPortal: addUpdatePortal2,
|
|
132
|
-
updatePortal: addUpdatePortal2,
|
|
133
|
-
removePortal: removePortal2
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
const PortalProviderComponent = ({
|
|
137
|
-
rootHostName = "root",
|
|
138
|
-
shouldAddRootHost = true,
|
|
139
|
-
children
|
|
140
|
-
}) => {
|
|
141
|
-
const [state, dispatch] = useReducer(reducer, INITIAL_STATE);
|
|
142
|
-
const transitionDispatch = useMemo(() => {
|
|
143
|
-
const next = (value) => {
|
|
144
|
-
startTransition(() => {
|
|
145
|
-
dispatch(value);
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
return next;
|
|
149
|
-
}, [dispatch]);
|
|
150
|
-
return /* @__PURE__ */ jsx(PortalDispatchContext.Provider, { value: transitionDispatch, children: /* @__PURE__ */ jsxs(PortalStateContext.Provider, { value: state, children: [
|
|
151
|
-
children,
|
|
152
|
-
shouldAddRootHost && /* @__PURE__ */ jsx(PortalHost, { name: rootHostName })
|
|
153
|
-
] }) });
|
|
154
|
-
};
|
|
155
|
-
const PortalProvider = memo(PortalProviderComponent);
|
|
156
|
-
PortalProvider.displayName = "PortalProvider";
|
|
157
|
-
const defaultRenderer = (children) => /* @__PURE__ */ jsx(Fragment, { children });
|
|
158
|
-
const PortalHostComponent = (props) => {
|
|
159
|
-
const { name, forwardProps, render = defaultRenderer } = props;
|
|
160
|
-
const isServer = !useDidFinishSSR();
|
|
161
|
-
const state = usePortalState(name);
|
|
162
|
-
const { registerHost: registerHost2, deregisterHost: deregisterHost2 } = usePortal(props.name);
|
|
163
|
-
useEffect(() => {
|
|
164
|
-
if (isServer)
|
|
165
|
-
return;
|
|
166
|
-
registerHost2();
|
|
167
|
-
return () => {
|
|
168
|
-
deregisterHost2();
|
|
169
|
-
};
|
|
170
|
-
}, [isServer]);
|
|
171
|
-
if (forwardProps) {
|
|
172
|
-
return render(
|
|
173
|
-
state.map((item) => {
|
|
174
|
-
let next = item.node;
|
|
175
|
-
if (forwardProps) {
|
|
176
|
-
return React.Children.map(next, (child) => {
|
|
177
|
-
return React.isValidElement(child) ? React.cloneElement(child, { key: child.key, ...forwardProps }) : child;
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
return next;
|
|
181
|
-
})
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
return render(state.map((item) => item.node));
|
|
185
|
-
};
|
|
186
|
-
const PortalHost = memo(PortalHostComponent);
|
|
187
|
-
PortalHost.displayName = "PortalHost";
|
|
188
|
-
const PortalComponent = (props) => {
|
|
189
|
-
const {
|
|
190
|
-
name: _providedName,
|
|
191
|
-
hostName,
|
|
192
|
-
handleOnMount: _providedHandleOnMount,
|
|
193
|
-
handleOnUnmount: _providedHandleOnUnmount,
|
|
194
|
-
handleOnUpdate: _providedHandleOnUpdate,
|
|
195
|
-
children
|
|
196
|
-
} = props;
|
|
197
|
-
const { addPortal: addUpdatePortal2, removePortal: removePortal2 } = usePortal(hostName);
|
|
198
|
-
const id = useId();
|
|
199
|
-
const name = _providedName || id;
|
|
200
|
-
const handleOnMount = useEvent(() => {
|
|
201
|
-
if (_providedHandleOnMount) {
|
|
202
|
-
_providedHandleOnMount(() => addUpdatePortal2(name, children));
|
|
203
|
-
} else {
|
|
204
|
-
addUpdatePortal2(name, children);
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
const handleOnUnmount = useEvent(() => {
|
|
208
|
-
if (_providedHandleOnUnmount) {
|
|
209
|
-
_providedHandleOnUnmount(() => removePortal2(name));
|
|
210
|
-
} else {
|
|
211
|
-
removePortal2(name);
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
const handleOnUpdate = useEvent(() => {
|
|
215
|
-
if (_providedHandleOnUpdate) {
|
|
216
|
-
_providedHandleOnUpdate(() => addUpdatePortal2(name, children));
|
|
217
|
-
} else {
|
|
218
|
-
addUpdatePortal2(name, children);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
useIsomorphicLayoutEffect(() => {
|
|
222
|
-
handleOnMount();
|
|
223
|
-
return () => {
|
|
224
|
-
handleOnUnmount();
|
|
225
|
-
};
|
|
226
|
-
}, []);
|
|
227
|
-
useEffect(() => {
|
|
228
|
-
handleOnUpdate();
|
|
229
|
-
}, [children]);
|
|
230
|
-
return null;
|
|
231
|
-
};
|
|
232
|
-
const PortalItem = memo(PortalComponent);
|
|
233
|
-
PortalItem.displayName = "Portal";
|
|
234
|
-
export {
|
|
235
|
-
ACTIONS,
|
|
236
|
-
INITIAL_STATE,
|
|
237
|
-
PortalHost,
|
|
238
|
-
PortalItem,
|
|
239
|
-
PortalProvider,
|
|
240
|
-
usePortal
|
|
241
|
-
};
|
|
1
|
+
import{Fragment as K,jsx as R,jsxs as J}from"react/jsx-runtime";import{useDidFinishSSR as I,useEvent as P,useIsomorphicLayoutEffect as U}from"@tamagui/core";import u,{createContext as A,memo as m,startTransition as _,useCallback as p,useContext as g,useEffect as T,useId as D,useMemo as C,useReducer as w}from"react";var y=(r=>(r[r.REGISTER_HOST=0]="REGISTER_HOST",r[r.DEREGISTER_HOST=1]="DEREGISTER_HOST",r[r.ADD_UPDATE_PORTAL=2]="ADD_UPDATE_PORTAL",r[r.REMOVE_PORTAL=3]="REMOVE_PORTAL",r))(y||{});const f={},E=(e,t)=>(t in e||(e[t]=[]),e),L=(e,t)=>(delete e[t],e),M=(e,t,o,n)=>{t in e||(e=E(e,t));const r=e[t].findIndex(s=>s.name===o);return r!==-1?e[t][r].node=n:e[t].push({name:o,node:n}),e},G=(e,t,o)=>{if(!(t in e))return console.log(`Failed to remove portal '${o}', '${t}' was not registered!`),e;const n=e[t].findIndex(r=>r.name===o);return n!==-1&&e[t].splice(n,1),e},b=(e,t)=>{const{type:o}=t;switch(o){case 0:return E({...e},t.hostName);case 1:return L({...e},t.hostName);case 2:return M({...e},t.hostName,t.portalName,t.node);case 3:return G({...e},t.hostName,t.portalName);default:return e}},v=A(null),O=A(null),V=e=>{const t=g(v);if(t===null)throw new Error("'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component.");return t[e]||[]},h=(e="root")=>{const t=g(O);if(t===null)throw new Error("'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component.");const o=p(()=>{t({type:0,hostName:e})},[]),n=p(()=>{t({type:1,hostName:e})},[]),r=p((a,i)=>{t({type:2,hostName:e,portalName:a,node:i})},[]),s=p(a=>{t({type:3,hostName:e,portalName:a})},[]);return{registerHost:o,deregisterHost:n,addPortal:r,updatePortal:r,removePortal:s}},k=({rootHostName:e="root",shouldAddRootHost:t=!0,children:o})=>{const[n,r]=w(b,f),s=C(()=>i=>{_(()=>{r(i)})},[r]);return R(O.Provider,{value:s,children:J(v.Provider,{value:n,children:[o,t&&R(x,{name:e})]})})},F=m(k);F.displayName="PortalProvider";const $=e=>R(K,{children:e}),q=e=>{const{name:t,forwardProps:o,render:n=$}=e,r=!I(),s=V(t),{registerHost:a,deregisterHost:i}=h(e.name);return T(()=>{if(!r)return a(),()=>{i()}},[r]),n(o?s.map(l=>{let c=l.node;return o?u.Children.map(c,d=>u.isValidElement(d)?u.cloneElement(d,{key:d.key,...o}):d):c}):s.map(l=>l.node))},x=m(q);x.displayName="PortalHost";const z=e=>{const{name:t,hostName:o,handleOnMount:n,handleOnUnmount:r,handleOnUpdate:s,children:a}=e,{addPortal:i,removePortal:l}=h(o),c=D(),d=t||c,H=P(()=>{n?n(()=>i(d,a)):i(d,a)}),N=P(()=>{r?r(()=>l(d)):l(d)}),S=P(()=>{s?s(()=>i(d,a)):i(d,a)});return U(()=>(H(),()=>{N()}),[]),T(()=>{S()},[a]),null},B=m(z);B.displayName="Portal";export{y as ACTIONS,f as INITIAL_STATE,x as PortalHost,B as PortalItem,F as PortalProvider,h as usePortal};
|
|
242
2
|
//# sourceMappingURL=GorhomPortal.mjs.map
|
|
@@ -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\nimport { useDidFinishSSR, useEvent, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport React, {\n ReactNode,\n createContext,\n memo,\n startTransition,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useReducer,\n} 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 // eslint-disable-next-line no-console\n console.log(\n `Failed to remove portal '${portalName}', '${hostName}' was not registered!`\n )\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(\n { ...state },\n action.hostName,\n (action as RemovePortalAction).portalName\n )\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\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 forwardProps?: Record<string, any>\n\n /**\n * Useful when trying to animate children with AnimatePresence.\n *\n * Not a part of gorhom/react-native-portal\n */\n render?: (children: React.ReactNode) => React.ReactElement\n}\nconst defaultRenderer: PortalHostProps['render'] = (children) => <>{children}</>\n\nconst PortalHostComponent = (props: PortalHostProps) => {\n const { name, forwardProps, render = defaultRenderer } = props\n const isServer = !useDidFinishSSR()\n const state = usePortalState(name)\n const { registerHost, deregisterHost } = usePortal(props.name)\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 if (forwardProps) {\n return render(\n state.map((item) => {\n let next = item.node\n\n if (forwardProps) {\n return React.Children.map(next, (child) => {\n return React.isValidElement(child)\n ? React.cloneElement(child, { key: child.key, ...forwardProps })\n : child\n })\n }\n\n return next\n })\n )\n }\n\n //#region render\n return render(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 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 = (props: PortalItemProps) => {\n const {\n name: _providedName,\n hostName,\n handleOnMount: _providedHandleOnMount,\n handleOnUnmount: _providedHandleOnUnmount,\n handleOnUpdate: _providedHandleOnUpdate,\n children,\n } = props\n const { addPortal: addUpdatePortal, removePortal } = usePortal(hostName)\n const id = useId()\n const name = _providedName || id\n\n const handleOnMount = useEvent(() => {\n if (_providedHandleOnMount) {\n _providedHandleOnMount(() => addUpdatePortal(name, children))\n } else {\n addUpdatePortal(name, children)\n }\n })\n\n const handleOnUnmount = useEvent(() => {\n if (_providedHandleOnUnmount) {\n _providedHandleOnUnmount(() => removePortal(name))\n } else {\n removePortal(name)\n }\n })\n\n const handleOnUpdate = useEvent(() => {\n if (_providedHandleOnUpdate) {\n _providedHandleOnUpdate(() => addUpdatePortal(name, children))\n } else {\n addUpdatePortal(name, children)\n }\n })\n\n useIsomorphicLayoutEffect(() => {\n handleOnMount()\n return () => {\n handleOnUnmount()\n }\n }, [])\n\n useEffect(() => {\n handleOnUpdate()\n }, [children])\n\n return null\n}\n\nexport const PortalItem = memo(PortalComponent)\nPortalItem.displayName = 'Portal'\n"],
|
|
5
|
-
"mappings": "AAyPM,
|
|
6
|
-
"names": ["ACTIONS", "registerHost", "deregisterHost", "addUpdatePortal", "removePortal"]
|
|
5
|
+
"mappings": "AAyPM,OA2B2D,YAAAA,EAzBnC,OAAAC,EAFxB,QAAAC,MAAA,oBAtPN,OAAS,mBAAAC,EAAiB,YAAAC,EAAU,6BAAAC,MAAiC,gBACrE,OAAOC,GAEL,iBAAAC,EACA,QAAAC,EACA,mBAAAC,E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Aa,EAAIO,EAAUd,CAAQ,EACjEsC,EAAK7C,EAAM,EACXuB,EAAOkB,GAAiBI,EAExBC,EAAgBvD,EAAS,IAAM,CAC/BmD,EACFA,EAAuB,IAAMjC,EAAgBc,EAAMI,CAAQ,CAAC,EAE5DlB,EAAgBc,EAAMI,CAAQ,CAElC,CAAC,EAEKoB,EAAkBxD,EAAS,IAAM,CACjCoD,EACFA,EAAyB,IAAM7B,EAAaS,CAAI,CAAC,EAEjDT,EAAaS,CAAI,CAErB,CAAC,EAEKyB,EAAiBzD,EAAS,IAAM,CAChCqD,EACFA,EAAwB,IAAMnC,EAAgBc,EAAMI,CAAQ,CAAC,EAE7DlB,EAAgBc,EAAMI,CAAQ,CAElC,CAAC,EAED,OAAAnC,EAA0B,KACxBsD,EAAc,EACP,IAAM,CACXC,EAAgB,CAClB,GACC,CAAC,CAAC,EAELhD,EAAU,IAAM,CACdiD,EAAe,CACjB,EAAG,CAACrB,CAAQ,CAAC,EAEN,IACT,EAEasB,EAAatD,EAAK6C,CAAe,EAC9CS,EAAW,YAAc",
|
|
6
|
+
"names": ["Fragment", "jsx", "jsxs", "useDidFinishSSR", "useEvent", "useIsomorphicLayoutEffect", "React", "createContext", "memo", "startTransition", "useCallback", "useContext", "useEffect", "useId", "useMemo", "useReducer", "ACTIONS", "INITIAL_STATE", "registerHost", "state", "hostName", "deregisterHost", "addUpdatePortal", "portalName", "node", "index", "item", "removePortal", "reducer", "action", "type", "PortalStateContext", "PortalDispatchContext", "usePortalState", "usePortal", "dispatch", "name", "PortalProviderComponent", "rootHostName", "shouldAddRootHost", "children", "transitionDispatch", "value", "PortalHost", "PortalProvider", "defaultRenderer", "PortalHostComponent", "props", "forwardProps", "render", "isServer", "next", "child", "PortalComponent", "_providedName", "_providedHandleOnMount", "_providedHandleOnUnmount", "_providedHandleOnUpdate", "id", "handleOnMount", "handleOnUnmount", "handleOnUpdate", "PortalItem"]
|
|
7
7
|
}
|