@oxyhq/bloom 1.7.0 → 1.8.0
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/docs/teleport.mdx +72 -0
- package/lib/commonjs/teleport/Portal.js +109 -0
- package/lib/commonjs/teleport/Portal.js.map +1 -0
- package/lib/commonjs/teleport/PortalHost.js +75 -0
- package/lib/commonjs/teleport/PortalHost.js.map +1 -0
- package/lib/commonjs/teleport/PortalHostView.js +40 -0
- package/lib/commonjs/teleport/PortalHostView.js.map +1 -0
- package/lib/commonjs/teleport/PortalHostView.native.js +24 -0
- package/lib/commonjs/teleport/PortalHostView.native.js.map +1 -0
- package/lib/commonjs/teleport/PortalProvider.js +57 -0
- package/lib/commonjs/teleport/PortalProvider.js.map +1 -0
- package/lib/commonjs/teleport/PortalProviderView.js +59 -0
- package/lib/commonjs/teleport/PortalProviderView.js.map +1 -0
- package/lib/commonjs/teleport/PortalProviderView.native.js +19 -0
- package/lib/commonjs/teleport/PortalProviderView.native.js.map +1 -0
- package/lib/commonjs/teleport/PortalView.js +83 -0
- package/lib/commonjs/teleport/PortalView.js.map +1 -0
- package/lib/commonjs/teleport/PortalView.native.js +14 -0
- package/lib/commonjs/teleport/PortalView.native.js.map +1 -0
- package/lib/commonjs/teleport/index.js +35 -0
- package/lib/commonjs/teleport/index.js.map +1 -0
- package/lib/commonjs/teleport/portal-manager.js +40 -0
- package/lib/commonjs/teleport/portal-manager.js.map +1 -0
- package/lib/commonjs/teleport/portal-registry.js +24 -0
- package/lib/commonjs/teleport/portal-registry.js.map +1 -0
- package/lib/commonjs/teleport/reducer.js +86 -0
- package/lib/commonjs/teleport/reducer.js.map +1 -0
- package/lib/commonjs/teleport/scroll-view-context/context.js +17 -0
- package/lib/commonjs/teleport/scroll-view-context/context.js.map +1 -0
- package/lib/commonjs/teleport/scroll-view-context/context.native.js +22 -0
- package/lib/commonjs/teleport/scroll-view-context/context.native.js.map +1 -0
- package/lib/commonjs/teleport/scroll-view-context/types.js +2 -0
- package/lib/commonjs/teleport/scroll-view-context/types.js.map +1 -0
- package/lib/commonjs/teleport/specs/PortalHostViewNativeComponent.js +17 -0
- package/lib/commonjs/teleport/specs/PortalHostViewNativeComponent.js.map +1 -0
- package/lib/commonjs/teleport/specs/PortalViewNativeComponent.js +17 -0
- package/lib/commonjs/teleport/specs/PortalViewNativeComponent.js.map +1 -0
- package/lib/commonjs/teleport/teleport-global.d.js +2 -0
- package/lib/commonjs/teleport/teleport-global.d.js.map +1 -0
- package/lib/commonjs/teleport/types.js +6 -0
- package/lib/commonjs/teleport/types.js.map +1 -0
- package/lib/commonjs/teleport/use-id.js +24 -0
- package/lib/commonjs/teleport/use-id.js.map +1 -0
- package/lib/commonjs/teleport/use-portal.js +59 -0
- package/lib/commonjs/teleport/use-portal.js.map +1 -0
- package/lib/module/teleport/Portal.js +103 -0
- package/lib/module/teleport/Portal.js.map +1 -0
- package/lib/module/teleport/PortalHost.js +71 -0
- package/lib/module/teleport/PortalHost.js.map +1 -0
- package/lib/module/teleport/PortalHostView.js +35 -0
- package/lib/module/teleport/PortalHostView.js.map +1 -0
- package/lib/module/teleport/PortalHostView.native.js +18 -0
- package/lib/module/teleport/PortalHostView.native.js.map +1 -0
- package/lib/module/teleport/PortalProvider.js +51 -0
- package/lib/module/teleport/PortalProvider.js.map +1 -0
- package/lib/module/teleport/PortalProviderView.js +54 -0
- package/lib/module/teleport/PortalProviderView.js.map +1 -0
- package/lib/module/teleport/PortalProviderView.native.js +15 -0
- package/lib/module/teleport/PortalProviderView.native.js.map +1 -0
- package/lib/module/teleport/PortalView.js +79 -0
- package/lib/module/teleport/PortalView.js.map +1 -0
- package/lib/module/teleport/PortalView.native.js +10 -0
- package/lib/module/teleport/PortalView.native.js.map +1 -0
- package/lib/module/teleport/index.js +30 -0
- package/lib/module/teleport/index.js.map +1 -0
- package/lib/module/teleport/portal-manager.js +33 -0
- package/lib/module/teleport/portal-manager.js.map +1 -0
- package/lib/module/teleport/portal-registry.js +18 -0
- package/lib/module/teleport/portal-registry.js.map +1 -0
- package/lib/module/teleport/reducer.js +81 -0
- package/lib/module/teleport/reducer.js.map +1 -0
- package/lib/module/teleport/scroll-view-context/context.js +12 -0
- package/lib/module/teleport/scroll-view-context/context.js.map +1 -0
- package/lib/module/teleport/scroll-view-context/context.native.js +18 -0
- package/lib/module/teleport/scroll-view-context/context.native.js.map +1 -0
- package/lib/module/teleport/scroll-view-context/types.js +2 -0
- package/lib/module/teleport/scroll-view-context/types.js.map +1 -0
- package/lib/module/teleport/specs/PortalHostViewNativeComponent.js +13 -0
- package/lib/module/teleport/specs/PortalHostViewNativeComponent.js.map +1 -0
- package/lib/module/teleport/specs/PortalViewNativeComponent.js +13 -0
- package/lib/module/teleport/specs/PortalViewNativeComponent.js.map +1 -0
- package/lib/module/teleport/teleport-global.d.js +2 -0
- package/lib/module/teleport/teleport-global.d.js.map +1 -0
- package/lib/module/teleport/types.js +4 -0
- package/lib/module/teleport/types.js.map +1 -0
- package/lib/module/teleport/use-id.js +19 -0
- package/lib/module/teleport/use-id.js.map +1 -0
- package/lib/module/teleport/use-portal.js +55 -0
- package/lib/module/teleport/use-portal.js.map +1 -0
- package/lib/typescript/commonjs/teleport/Portal.d.ts +48 -0
- package/lib/typescript/commonjs/teleport/Portal.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalHost.d.ts +25 -0
- package/lib/typescript/commonjs/teleport/PortalHost.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalHostView.d.ts +5 -0
- package/lib/typescript/commonjs/teleport/PortalHostView.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalHostView.native.d.ts +4 -0
- package/lib/typescript/commonjs/teleport/PortalHostView.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalProvider.d.ts +23 -0
- package/lib/typescript/commonjs/teleport/PortalProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalProviderView.d.ts +3 -0
- package/lib/typescript/commonjs/teleport/PortalProviderView.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalProviderView.native.d.ts +9 -0
- package/lib/typescript/commonjs/teleport/PortalProviderView.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalView.d.ts +9 -0
- package/lib/typescript/commonjs/teleport/PortalView.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/PortalView.native.d.ts +8 -0
- package/lib/typescript/commonjs/teleport/PortalView.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/index.d.ts +29 -0
- package/lib/typescript/commonjs/teleport/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/portal-manager.d.ts +16 -0
- package/lib/typescript/commonjs/teleport/portal-manager.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/portal-registry.d.ts +10 -0
- package/lib/typescript/commonjs/teleport/portal-registry.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/reducer.d.ts +40 -0
- package/lib/typescript/commonjs/teleport/reducer.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/scroll-view-context/context.d.ts +4 -0
- package/lib/typescript/commonjs/teleport/scroll-view-context/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/scroll-view-context/context.native.d.ts +13 -0
- package/lib/typescript/commonjs/teleport/scroll-view-context/context.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/scroll-view-context/types.d.ts +10 -0
- package/lib/typescript/commonjs/teleport/scroll-view-context/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/specs/PortalHostViewNativeComponent.d.ts +13 -0
- package/lib/typescript/commonjs/teleport/specs/PortalHostViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/specs/PortalViewNativeComponent.d.ts +14 -0
- package/lib/typescript/commonjs/teleport/specs/PortalViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/types.d.ts +22 -0
- package/lib/typescript/commonjs/teleport/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/use-id.d.ts +2 -0
- package/lib/typescript/commonjs/teleport/use-id.d.ts.map +1 -0
- package/lib/typescript/commonjs/teleport/use-portal.d.ts +35 -0
- package/lib/typescript/commonjs/teleport/use-portal.d.ts.map +1 -0
- package/lib/typescript/module/teleport/Portal.d.ts +48 -0
- package/lib/typescript/module/teleport/Portal.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalHost.d.ts +25 -0
- package/lib/typescript/module/teleport/PortalHost.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalHostView.d.ts +5 -0
- package/lib/typescript/module/teleport/PortalHostView.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalHostView.native.d.ts +4 -0
- package/lib/typescript/module/teleport/PortalHostView.native.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalProvider.d.ts +23 -0
- package/lib/typescript/module/teleport/PortalProvider.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalProviderView.d.ts +3 -0
- package/lib/typescript/module/teleport/PortalProviderView.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalProviderView.native.d.ts +9 -0
- package/lib/typescript/module/teleport/PortalProviderView.native.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalView.d.ts +9 -0
- package/lib/typescript/module/teleport/PortalView.d.ts.map +1 -0
- package/lib/typescript/module/teleport/PortalView.native.d.ts +8 -0
- package/lib/typescript/module/teleport/PortalView.native.d.ts.map +1 -0
- package/lib/typescript/module/teleport/index.d.ts +29 -0
- package/lib/typescript/module/teleport/index.d.ts.map +1 -0
- package/lib/typescript/module/teleport/portal-manager.d.ts +16 -0
- package/lib/typescript/module/teleport/portal-manager.d.ts.map +1 -0
- package/lib/typescript/module/teleport/portal-registry.d.ts +10 -0
- package/lib/typescript/module/teleport/portal-registry.d.ts.map +1 -0
- package/lib/typescript/module/teleport/reducer.d.ts +40 -0
- package/lib/typescript/module/teleport/reducer.d.ts.map +1 -0
- package/lib/typescript/module/teleport/scroll-view-context/context.d.ts +4 -0
- package/lib/typescript/module/teleport/scroll-view-context/context.d.ts.map +1 -0
- package/lib/typescript/module/teleport/scroll-view-context/context.native.d.ts +13 -0
- package/lib/typescript/module/teleport/scroll-view-context/context.native.d.ts.map +1 -0
- package/lib/typescript/module/teleport/scroll-view-context/types.d.ts +10 -0
- package/lib/typescript/module/teleport/scroll-view-context/types.d.ts.map +1 -0
- package/lib/typescript/module/teleport/specs/PortalHostViewNativeComponent.d.ts +13 -0
- package/lib/typescript/module/teleport/specs/PortalHostViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/teleport/specs/PortalViewNativeComponent.d.ts +14 -0
- package/lib/typescript/module/teleport/specs/PortalViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/teleport/types.d.ts +22 -0
- package/lib/typescript/module/teleport/types.d.ts.map +1 -0
- package/lib/typescript/module/teleport/use-id.d.ts +2 -0
- package/lib/typescript/module/teleport/use-id.d.ts.map +1 -0
- package/lib/typescript/module/teleport/use-portal.d.ts +35 -0
- package/lib/typescript/module/teleport/use-portal.d.ts.map +1 -0
- package/package.json +15 -1
- package/src/teleport/Portal.tsx +97 -0
- package/src/teleport/PortalHost.tsx +61 -0
- package/src/teleport/PortalHostView.native.tsx +14 -0
- package/src/teleport/PortalHostView.tsx +30 -0
- package/src/teleport/PortalProvider.tsx +51 -0
- package/src/teleport/PortalProviderView.native.tsx +11 -0
- package/src/teleport/PortalProviderView.tsx +67 -0
- package/src/teleport/PortalView.native.tsx +7 -0
- package/src/teleport/PortalView.tsx +94 -0
- package/src/teleport/index.ts +32 -0
- package/src/teleport/portal-manager.tsx +48 -0
- package/src/teleport/portal-registry.ts +27 -0
- package/src/teleport/reducer.ts +94 -0
- package/src/teleport/scroll-view-context/context.native.ts +19 -0
- package/src/teleport/scroll-view-context/context.ts +12 -0
- package/src/teleport/scroll-view-context/types.ts +7 -0
- package/src/teleport/specs/PortalHostViewNativeComponent.ts +15 -0
- package/src/teleport/specs/PortalViewNativeComponent.ts +16 -0
- package/src/teleport/teleport-global.d.ts +11 -0
- package/src/teleport/types.ts +22 -0
- package/src/teleport/use-id.ts +18 -0
- package/src/teleport/use-portal.ts +47 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePortalManagerContext = exports.PortalManagerProvider = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reducer = require("./reducer.js");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
/**
|
|
11
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/contexts/PortalManager.tsx`
|
|
12
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
13
|
+
*
|
|
14
|
+
* Changed: import paths only, for this flat directory.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const PortalManagerContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
18
|
+
const PortalManagerProvider = ({
|
|
19
|
+
children
|
|
20
|
+
}) => {
|
|
21
|
+
const [state, dispatch] = (0, _react.useReducer)(_reducer.reducer, _reducer.initialState);
|
|
22
|
+
const context = (0, _react.useMemo)(() => ({
|
|
23
|
+
state,
|
|
24
|
+
dispatch
|
|
25
|
+
}), [state, dispatch]);
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PortalManagerContext.Provider, {
|
|
27
|
+
value: context,
|
|
28
|
+
children: children
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
exports.PortalManagerProvider = PortalManagerProvider;
|
|
32
|
+
const usePortalManagerContext = () => {
|
|
33
|
+
const context = (0, _react.useContext)(PortalManagerContext);
|
|
34
|
+
if (!context) {
|
|
35
|
+
throw new Error("usePortalContext must be used within PortalProvider");
|
|
36
|
+
}
|
|
37
|
+
return context;
|
|
38
|
+
};
|
|
39
|
+
exports.usePortalManagerContext = usePortalManagerContext;
|
|
40
|
+
//# sourceMappingURL=portal-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reducer","_jsxRuntime","PortalManagerContext","createContext","undefined","PortalManagerProvider","children","state","dispatch","useReducer","reducer","initialState","context","useMemo","jsx","Provider","value","exports","usePortalManagerContext","useContext","Error"],"sourceRoot":"../../../src","sources":["teleport/portal-manager.tsx"],"mappings":";;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AAOA,IAAAC,QAAA,GAAAD,OAAA;AAKmB,IAAAE,WAAA,GAAAF,OAAA;AAlBnB;AACA;AACA;AACA;AACA;AACA;;AAeA,MAAMG,oBAAoB,gBAAG,IAAAC,oBAAa,EAExCC,SAAS,CAAC;AAEL,MAAMC,qBAAqB,GAAGA,CAAC;EACpCC;AAGF,CAAC,KAAK;EACJ,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,iBAAU,EAACC,gBAAO,EAAEC,qBAAY,CAAC;EAC3D,MAAMC,OAAO,GAAG,IAAAC,cAAO,EAAC,OAAO;IAAEN,KAAK;IAAEC;EAAS,CAAC,CAAC,EAAE,CAACD,KAAK,EAAEC,QAAQ,CAAC,CAAC;EAEvE,oBACE,IAAAP,WAAA,CAAAa,GAAA,EAACZ,oBAAoB,CAACa,QAAQ;IAACC,KAAK,EAAEJ,OAAQ;IAAAN,QAAA,EAC3CA;EAAQ,CACoB,CAAC;AAEpC,CAAC;AAACW,OAAA,CAAAZ,qBAAA,GAAAA,qBAAA;AAEK,MAAMa,uBAAuB,GAAGA,CAAA,KAAM;EAC3C,MAAMN,OAAO,GAAG,IAAAO,iBAAU,EAACjB,oBAAoB,CAAC;EAEhD,IAAI,CAACU,OAAO,EAAE;IACZ,MAAM,IAAIQ,KAAK,CAAC,qDAAqD,CAAC;EACxE;EAEA,OAAOR,OAAO;AAChB,CAAC;AAACK,OAAA,CAAAC,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PortalRegistryContext = void 0;
|
|
7
|
+
exports.usePortalRegistryContext = usePortalRegistryContext;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
/**
|
|
10
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/contexts/PortalRegistry.ts`
|
|
11
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
12
|
+
*
|
|
13
|
+
* Changed: nothing — byte-for-byte, only its path.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const PortalRegistryContext = exports.PortalRegistryContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
17
|
+
function usePortalRegistryContext() {
|
|
18
|
+
const context = (0, _react.useContext)(PortalRegistryContext);
|
|
19
|
+
if (!context) {
|
|
20
|
+
throw new Error("usePortalRegistryContext must be used within a PortalRegistryContext");
|
|
21
|
+
}
|
|
22
|
+
return context;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=portal-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","PortalRegistryContext","exports","createContext","usePortalRegistryContext","context","useContext","Error"],"sourceRoot":"../../../src","sources":["teleport/portal-registry.ts"],"mappings":";;;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;AACA;;AAUO,MAAMC,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,gBAChC,IAAAE,oBAAa,EAAmC,IAAI,CAAC;AAEhD,SAASC,wBAAwBA,CAAA,EAAG;EACzC,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACL,qBAAqB,CAAC;EACjD,IAAI,CAACI,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CACb,sEACF,CAAC;EACH;EACA,OAAOF,OAAO;AAChB","ignoreList":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.reducer = exports.initialState = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/state/reducer.ts`
|
|
9
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
10
|
+
*
|
|
11
|
+
* Changed: nothing — byte-for-byte, only its path.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const initialState = exports.initialState = {
|
|
15
|
+
removed: {},
|
|
16
|
+
hosts: {},
|
|
17
|
+
hostScrollViewContexts: {}
|
|
18
|
+
};
|
|
19
|
+
const reducer = (state, action) => {
|
|
20
|
+
const cloned = {
|
|
21
|
+
...state,
|
|
22
|
+
removed: {
|
|
23
|
+
...state.removed
|
|
24
|
+
},
|
|
25
|
+
hostScrollViewContexts: {
|
|
26
|
+
...state.hostScrollViewContexts
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const hostRemoved = "name" in action ? cloned.removed[action.hostName] || {} : {};
|
|
30
|
+
cloned.removed[action.hostName] = hostRemoved;
|
|
31
|
+
const nameRemoved = "name" in action ? hostRemoved[action.name] || {} : {};
|
|
32
|
+
if ("name" in action) {
|
|
33
|
+
hostRemoved[action.name] = nameRemoved;
|
|
34
|
+
}
|
|
35
|
+
switch (action.type) {
|
|
36
|
+
case "REGISTER_HOST":
|
|
37
|
+
{
|
|
38
|
+
const hosts = {
|
|
39
|
+
...cloned.hosts
|
|
40
|
+
};
|
|
41
|
+
hosts[action.hostName] = (hosts[action.hostName] || 0) + 1;
|
|
42
|
+
return {
|
|
43
|
+
...cloned,
|
|
44
|
+
hosts
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
case "UNREGISTER_HOST":
|
|
48
|
+
{
|
|
49
|
+
const hosts = {
|
|
50
|
+
...cloned.hosts
|
|
51
|
+
};
|
|
52
|
+
const count = (hosts[action.hostName] || 0) - 1;
|
|
53
|
+
if (count <= 0) {
|
|
54
|
+
delete hosts[action.hostName];
|
|
55
|
+
delete cloned.hostScrollViewContexts[action.hostName];
|
|
56
|
+
} else {
|
|
57
|
+
hosts[action.hostName] = count;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
...cloned,
|
|
61
|
+
hosts
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
case "SET_HOST_SCROLL_VIEW_CONTEXT":
|
|
65
|
+
cloned.hostScrollViewContexts[action.hostName] = action.value;
|
|
66
|
+
return cloned;
|
|
67
|
+
case "REGISTER_PORTAL":
|
|
68
|
+
if (!nameRemoved[action.instanceId]) {
|
|
69
|
+
nameRemoved[action.instanceId] = false;
|
|
70
|
+
}
|
|
71
|
+
return cloned;
|
|
72
|
+
case "REMOVE_PORTAL":
|
|
73
|
+
Object.keys(nameRemoved).forEach(id => nameRemoved[id] = true);
|
|
74
|
+
return cloned;
|
|
75
|
+
case "CLEAR_REMOVED_ON_UNMOUNT":
|
|
76
|
+
delete nameRemoved[action.instanceId];
|
|
77
|
+
if (Object.keys(nameRemoved).length === 0) {
|
|
78
|
+
delete hostRemoved[action.name];
|
|
79
|
+
}
|
|
80
|
+
return cloned;
|
|
81
|
+
default:
|
|
82
|
+
return state;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
exports.reducer = reducer;
|
|
86
|
+
//# sourceMappingURL=reducer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["initialState","exports","removed","hosts","hostScrollViewContexts","reducer","state","action","cloned","hostRemoved","hostName","nameRemoved","name","type","count","value","instanceId","Object","keys","forEach","id","length"],"sourceRoot":"../../../src","sources":["teleport/reducer.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/**
|
|
9
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/contexts/ScrollViewContext/index.ts`
|
|
10
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
11
|
+
*
|
|
12
|
+
* Changed: import paths only, for this flat directory.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const ScrollViewContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
16
|
+
var _default = exports.default = ScrollViewContext;
|
|
17
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","ScrollViewContext","createContext","_default","exports","default"],"sourceRoot":"../../../../src","sources":["teleport/scroll-view-context/context.ts"],"mappings":";;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;AACA;;AAIA,MAAMC,iBAAiB,gBAAG,IAAAC,oBAAa,EAAyB,IAAI,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEvDJ,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
/**
|
|
9
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/contexts/ScrollViewContext/index.native.ts`
|
|
10
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
11
|
+
*
|
|
12
|
+
* Changed: import paths, and `ScrollView.Context` is reached through a cast
|
|
13
|
+
* because Bloom does not compile with their `react-native-strict-api` condition,
|
|
14
|
+
* which is the only place that property is declared.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// Bloom does not compile with their `react-native-strict-api` condition, and
|
|
18
|
+
// `ScrollView.Context` is only declared there. Reached through the shape it has
|
|
19
|
+
// at runtime instead; the value and the behaviour are theirs, unchanged.
|
|
20
|
+
const ScrollViewContext = _reactNative.ScrollView.Context;
|
|
21
|
+
var _default = exports.default = ScrollViewContext;
|
|
22
|
+
//# sourceMappingURL=context.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","ScrollViewContext","ScrollView","Context","_default","exports","default"],"sourceRoot":"../../../../src","sources":["teleport/scroll-view-context/context.native.ts"],"mappings":";;;;;;AASA,IAAAA,YAAA,GAAAC,OAAA;AATA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAIC,uBAAU,CAClCC,OAAO;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEIL,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["teleport/scroll-view-context/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
/**
|
|
9
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/specs/PortalHostViewNativeComponent.ts`
|
|
10
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
11
|
+
*
|
|
12
|
+
* Changed: nothing — byte-for-byte, only its path.
|
|
13
|
+
*/
|
|
14
|
+
var _default = exports.default = (0, _reactNative.codegenNativeComponent)("PortalHostView", {
|
|
15
|
+
interfaceOnly: true
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=PortalHostViewNativeComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","codegenNativeComponent","interfaceOnly"],"sourceRoot":"../../../../src","sources":["teleport/specs/PortalHostViewNativeComponent.ts"],"mappings":";;;;;;AAMA,IAAAA,YAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;AACA;AALA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAYe,IAAAC,mCAAsB,EAAc,gBAAgB,EAAE;EACnEC,aAAa,EAAE;AACjB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
/**
|
|
9
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/specs/PortalViewNativeComponent.ts`
|
|
10
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
11
|
+
*
|
|
12
|
+
* Changed: nothing — byte-for-byte, only its path.
|
|
13
|
+
*/
|
|
14
|
+
var _default = exports.default = (0, _reactNative.codegenNativeComponent)("PortalView", {
|
|
15
|
+
interfaceOnly: true
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=PortalViewNativeComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","codegenNativeComponent","interfaceOnly"],"sourceRoot":"../../../../src","sources":["teleport/specs/PortalViewNativeComponent.ts"],"mappings":";;;;;;AAMA,IAAAA,YAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;AACA;AALA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAae,IAAAC,mCAAsB,EAAc,YAAY,EAAE;EAC/DC,aAAa,EAAE;AACjB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["teleport/teleport-global.d.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["teleport/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useId;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/**
|
|
9
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/hooks/useId.ts`
|
|
10
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
11
|
+
*
|
|
12
|
+
* Changed: nothing — byte-for-byte, only its path.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
let __idCounter = 0;
|
|
16
|
+
function useId(prefix = "uid") {
|
|
17
|
+
const idRef = (0, _react.useRef)("");
|
|
18
|
+
if (!idRef.current) {
|
|
19
|
+
const n = ++__idCounter;
|
|
20
|
+
idRef.current = `${prefix}-${n}`;
|
|
21
|
+
}
|
|
22
|
+
return idRef.current;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=use-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","__idCounter","useId","prefix","idRef","useRef","current","n"],"sourceRoot":"../../../src","sources":["teleport/use-id.ts"],"mappings":";;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;AACA;;AAGA,IAAIC,WAAW,GAAG,CAAC;AAEJ,SAASC,KAAKA,CAACC,MAAM,GAAG,KAAK,EAAU;EACpD,MAAMC,KAAK,GAAG,IAAAC,aAAM,EAAS,EAAE,CAAC;EAChC,IAAI,CAACD,KAAK,CAACE,OAAO,EAAE;IAClB,MAAMC,CAAC,GAAG,EAAEN,WAAW;IACvBG,KAAK,CAACE,OAAO,GAAG,GAAGH,MAAM,IAAII,CAAC,EAAE;EAClC;EACA,OAAOH,KAAK,CAACE,OAAO;AACtB","ignoreList":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = usePortal;
|
|
7
|
+
var _portalManager = require("./portal-manager.js");
|
|
8
|
+
/**
|
|
9
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/hooks/usePortal.ts`
|
|
10
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
11
|
+
*
|
|
12
|
+
* Changed: import paths only, for this flat directory.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The `usePortal` hook allows you to manage portals in imperative way.
|
|
17
|
+
*
|
|
18
|
+
* @category hooks
|
|
19
|
+
* @param `hostName` - `name` of the `<PortalHost />` component
|
|
20
|
+
* @returns an object that helps to manipulate portals
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { usePortal } from "react-native-teleport";
|
|
24
|
+
* export default function App() {
|
|
25
|
+
* const { removePortal, isHostAvailable } = usePortal("root");
|
|
26
|
+
* return (
|
|
27
|
+
* <View style={{ flex: 1 }}>
|
|
28
|
+
* <Text>{isHostAvailable ? "Host is available" : "Host is not available"}</Text>
|
|
29
|
+
* <Button title="Remove" onPress={() => removePortal("portal")} />
|
|
30
|
+
* </View>
|
|
31
|
+
* );
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function usePortal(hostName = "root") {
|
|
36
|
+
const {
|
|
37
|
+
state,
|
|
38
|
+
dispatch
|
|
39
|
+
} = (0, _portalManager.usePortalManagerContext)();
|
|
40
|
+
return {
|
|
41
|
+
/**
|
|
42
|
+
* Whether a `<PortalHost />` with the given `hostName` is currently mounted.
|
|
43
|
+
*/
|
|
44
|
+
isHostAvailable: (state.hosts[hostName] ?? 0) > 0,
|
|
45
|
+
/**
|
|
46
|
+
* Remove portal from host container. Subsequent re-renders will not restore portal,
|
|
47
|
+
* but if you mount a new portal with the same name it will be shown (i. e. hook doesn't
|
|
48
|
+
* prevent new portal from being added).
|
|
49
|
+
*
|
|
50
|
+
* @param name - `name` of `<Portal />` component.
|
|
51
|
+
*/
|
|
52
|
+
removePortal: name => dispatch({
|
|
53
|
+
type: "REMOVE_PORTAL",
|
|
54
|
+
hostName,
|
|
55
|
+
name
|
|
56
|
+
})
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=use-portal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_portalManager","require","usePortal","hostName","state","dispatch","usePortalManagerContext","isHostAvailable","hosts","removePortal","name","type"],"sourceRoot":"../../../src","sources":["teleport/use-portal.ts"],"mappings":";;;;;;AAMA,IAAAA,cAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,SAASA,CAACC,QAAgB,GAAG,MAAM,EAAE;EAC3D,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAG,IAAAC,sCAAuB,EAAC,CAAC;EAErD,OAAO;IACL;AACJ;AACA;IACIC,eAAe,EAAE,CAACH,KAAK,CAACI,KAAK,CAACL,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;IACjD;AACJ;AACA;AACA;AACA;AACA;AACA;IACIM,YAAY,EAAGC,IAAY,IACzBL,QAAQ,CAAC;MAAEM,IAAI,EAAE,eAAe;MAAER,QAAQ;MAAEO;IAAK,CAAC;EACtD,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/components/Portal.tsx`
|
|
5
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
6
|
+
*
|
|
7
|
+
* Changed: import paths only, for this flat directory.
|
|
8
|
+
*/
|
|
9
|
+
import { useContext, useEffect } from "react";
|
|
10
|
+
import { usePortalManagerContext } from "./portal-manager.js";
|
|
11
|
+
import ScrollViewContext from "./scroll-view-context/context";
|
|
12
|
+
import PortalView from "./PortalView";
|
|
13
|
+
import useId from "./use-id.js";
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
/**
|
|
16
|
+
* Portal helps you to render a component in a different place in the view hierarchy.
|
|
17
|
+
* This is useful when you need a view to visually “break out” of its parent container (for example: modals, toasts, floating UI, popovers).
|
|
18
|
+
*
|
|
19
|
+
* @category components
|
|
20
|
+
* @param hostName - The `name` of the `PortalHost`. It's used to identify the host where the content should be rendered.
|
|
21
|
+
* @param name - The name of the portal. It's used to identify the portal.
|
|
22
|
+
* @param children - The content that should be rendered in the portal.
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* import { useState } from "react";
|
|
26
|
+
* import { View, StyleSheet, Button } from "react-native";
|
|
27
|
+
* import { Portal } from "react-native-teleport";
|
|
28
|
+
* export default function InstantRootExample() {
|
|
29
|
+
* const [shouldBeTeleported, setTeleported] = useState(true);
|
|
30
|
+
* return (
|
|
31
|
+
* <View style={styles.container}>
|
|
32
|
+
* {shouldBeTeleported && (
|
|
33
|
+
* <Portal hostName={"overlay"}>
|
|
34
|
+
* <View style={styles.box} />
|
|
35
|
+
* </Portal>
|
|
36
|
+
* )}
|
|
37
|
+
* <Button
|
|
38
|
+
* title={shouldBeTeleported ? "Hide" : "Show"}
|
|
39
|
+
* onPress={() => setTeleported((t) => !t)}
|
|
40
|
+
* />
|
|
41
|
+
* </View>
|
|
42
|
+
* );
|
|
43
|
+
* }
|
|
44
|
+
* const styles = StyleSheet.create({
|
|
45
|
+
* container: {
|
|
46
|
+
* flex: 1,
|
|
47
|
+
* alignItems: "center",
|
|
48
|
+
* justifyContent: "center",
|
|
49
|
+
* },
|
|
50
|
+
* box: {
|
|
51
|
+
* width: 160,
|
|
52
|
+
* height: 160,
|
|
53
|
+
* marginVertical: 20,
|
|
54
|
+
* backgroundColor: "blue",
|
|
55
|
+
* },
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
const PortalComponent = ({
|
|
60
|
+
hostName,
|
|
61
|
+
name,
|
|
62
|
+
style,
|
|
63
|
+
children
|
|
64
|
+
}) => {
|
|
65
|
+
const sourceScrollViewContext = useContext(ScrollViewContext);
|
|
66
|
+
const {
|
|
67
|
+
state,
|
|
68
|
+
dispatch
|
|
69
|
+
} = usePortalManagerContext();
|
|
70
|
+
const instanceId = useId();
|
|
71
|
+
const scrollViewContext = hostName && state.hosts[hostName] ? state.hostScrollViewContexts[hostName] ?? null : sourceScrollViewContext;
|
|
72
|
+
const isRemoved = hostName && name ? state.removed[hostName]?.[name]?.[instanceId] : false;
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!hostName || !name) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
dispatch({
|
|
78
|
+
type: "REGISTER_PORTAL",
|
|
79
|
+
hostName,
|
|
80
|
+
name,
|
|
81
|
+
instanceId
|
|
82
|
+
});
|
|
83
|
+
return () => {
|
|
84
|
+
dispatch({
|
|
85
|
+
type: "CLEAR_REMOVED_ON_UNMOUNT",
|
|
86
|
+
hostName,
|
|
87
|
+
name,
|
|
88
|
+
instanceId
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
}, [dispatch, hostName, name, instanceId]);
|
|
92
|
+
return /*#__PURE__*/_jsx(ScrollViewContext.Provider, {
|
|
93
|
+
value: scrollViewContext,
|
|
94
|
+
children: /*#__PURE__*/_jsx(PortalView, {
|
|
95
|
+
hostName: hostName,
|
|
96
|
+
name: name,
|
|
97
|
+
style: style,
|
|
98
|
+
children: isRemoved ? null : children
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
export default PortalComponent;
|
|
103
|
+
//# sourceMappingURL=Portal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useContext","useEffect","usePortalManagerContext","ScrollViewContext","PortalView","useId","jsx","_jsx","PortalComponent","hostName","name","style","children","sourceScrollViewContext","state","dispatch","instanceId","scrollViewContext","hosts","hostScrollViewContexts","isRemoved","removed","type","Provider","value"],"sourceRoot":"../../../src","sources":["teleport/Portal.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,SAAS,QAAQ,OAAO;AAC7C,SAASC,uBAAuB,QAAQ,qBAAkB;AAC1D,OAAOC,iBAAiB,MAAM,+BAA+B;AAC7D,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,KAAK,MAAM,aAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAGA,CAAC;EAAEC,QAAQ;EAAEC,IAAI;EAAEC,KAAK;EAAEC;AAAsB,CAAC,KAAK;EAC5E,MAAMC,uBAAuB,GAAGb,UAAU,CAACG,iBAAiB,CAAC;EAC7D,MAAM;IAAEW,KAAK;IAAEC;EAAS,CAAC,GAAGb,uBAAuB,CAAC,CAAC;EACrD,MAAMc,UAAU,GAAGX,KAAK,CAAC,CAAC;EAE1B,MAAMY,iBAAiB,GACrBR,QAAQ,IAAIK,KAAK,CAACI,KAAK,CAACT,QAAQ,CAAC,GAC5BK,KAAK,CAACK,sBAAsB,CAACV,QAAQ,CAAC,IAAI,IAAI,GAC/CI,uBAAuB;EAE7B,MAAMO,SAAS,GACbX,QAAQ,IAAIC,IAAI,GAAGI,KAAK,CAACO,OAAO,CAACZ,QAAQ,CAAC,GAAGC,IAAI,CAAC,GAAGM,UAAU,CAAC,GAAG,KAAK;EAE1Ef,SAAS,CAAC,MAAM;IACd,IAAI,CAACQ,QAAQ,IAAI,CAACC,IAAI,EAAE;MACtB;IACF;IAEAK,QAAQ,CAAC;MAAEO,IAAI,EAAE,iBAAiB;MAAEb,QAAQ;MAAEC,IAAI;MAAEM;IAAW,CAAC,CAAC;IAEjE,OAAO,MAAM;MACXD,QAAQ,CAAC;QACPO,IAAI,EAAE,0BAA0B;QAChCb,QAAQ;QACRC,IAAI;QACJM;MACF,CAAC,CAAC;IACJ,CAAC;EACH,CAAC,EAAE,CAACD,QAAQ,EAAEN,QAAQ,EAAEC,IAAI,EAAEM,UAAU,CAAC,CAAC;EAE1C,oBACET,IAAA,CAACJ,iBAAiB,CAACoB,QAAQ;IAACC,KAAK,EAAEP,iBAAkB;IAAAL,QAAA,eACnDL,IAAA,CAACH,UAAU;MAACK,QAAQ,EAAEA,QAAS;MAACC,IAAI,EAAEA,IAAK;MAACC,KAAK,EAAEA,KAAM;MAAAC,QAAA,EACtDQ,SAAS,GAAG,IAAI,GAAGR;IAAQ,CAClB;EAAC,CACa,CAAC;AAEjC,CAAC;AAED,eAAeJ,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/components/PortalHost.tsx`
|
|
5
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
6
|
+
*
|
|
7
|
+
* Changed: import paths only, for this flat directory.
|
|
8
|
+
*/
|
|
9
|
+
import { useContext, useEffect } from "react";
|
|
10
|
+
import { usePortalManagerContext } from "./portal-manager.js";
|
|
11
|
+
import ScrollViewContext from "./scroll-view-context/context";
|
|
12
|
+
import PortalHost from "./PortalHostView";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* PortalHost is a component that acts as an anchor for the portals.
|
|
16
|
+
* You can define multiple portal hosts in your app and use them to render different portals.
|
|
17
|
+
* Each portal host has a unique name that you can use to identify a necessary one among the others.
|
|
18
|
+
*
|
|
19
|
+
* @category components
|
|
20
|
+
* @param name - The name of the portal host. It's used by `<Portal />` component to identify the host.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* import { StyleSheet, View } from "react-native";
|
|
25
|
+
* import { PortalHost, PortalProvider } from "react-native-teleport";
|
|
26
|
+
* export default function App() {
|
|
27
|
+
* return (
|
|
28
|
+
* <PortalProvider>
|
|
29
|
+
* <PortalHost style={StyleSheet.absoluteFillObject} name="overlay" />
|
|
30
|
+
* </PortalProvider>
|
|
31
|
+
* );
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
36
|
+
const PortalHostComponent = ({
|
|
37
|
+
name,
|
|
38
|
+
children,
|
|
39
|
+
style
|
|
40
|
+
}) => {
|
|
41
|
+
const {
|
|
42
|
+
dispatch
|
|
43
|
+
} = usePortalManagerContext();
|
|
44
|
+
const scrollViewContext = useContext(ScrollViewContext);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
dispatch({
|
|
47
|
+
type: "REGISTER_HOST",
|
|
48
|
+
hostName: name
|
|
49
|
+
});
|
|
50
|
+
return () => {
|
|
51
|
+
dispatch({
|
|
52
|
+
type: "UNREGISTER_HOST",
|
|
53
|
+
hostName: name
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
}, [name, dispatch]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
dispatch({
|
|
59
|
+
type: "SET_HOST_SCROLL_VIEW_CONTEXT",
|
|
60
|
+
hostName: name,
|
|
61
|
+
value: scrollViewContext
|
|
62
|
+
});
|
|
63
|
+
}, [name, dispatch, scrollViewContext]);
|
|
64
|
+
return /*#__PURE__*/_jsx(PortalHost, {
|
|
65
|
+
name: name,
|
|
66
|
+
style: style,
|
|
67
|
+
children: children
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
export default PortalHostComponent;
|
|
71
|
+
//# sourceMappingURL=PortalHost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useContext","useEffect","usePortalManagerContext","ScrollViewContext","PortalHost","jsx","_jsx","PortalHostComponent","name","children","style","dispatch","scrollViewContext","type","hostName","value"],"sourceRoot":"../../../src","sources":["teleport/PortalHost.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,SAAS,QAAQ,OAAO;AAC7C,SAASC,uBAAuB,QAAQ,qBAAkB;AAC1D,OAAOC,iBAAiB,MAAM,+BAA+B;AAE7D,OAAOC,UAAU,MAAM,kBAAkB;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AApBA,SAAAC,GAAA,IAAAC,IAAA;AAqBA,MAAMC,mBAAmB,GAAGA,CAAC;EAAEC,IAAI;EAAEC,QAAQ;EAAEC;AAAuB,CAAC,KAAK;EAC1E,MAAM;IAAEC;EAAS,CAAC,GAAGT,uBAAuB,CAAC,CAAC;EAC9C,MAAMU,iBAAiB,GAAGZ,UAAU,CAACG,iBAAiB,CAAC;EAEvDF,SAAS,CAAC,MAAM;IACdU,QAAQ,CAAC;MAAEE,IAAI,EAAE,eAAe;MAAEC,QAAQ,EAAEN;IAAK,CAAC,CAAC;IAEnD,OAAO,MAAM;MACXG,QAAQ,CAAC;QAAEE,IAAI,EAAE,iBAAiB;QAAEC,QAAQ,EAAEN;MAAK,CAAC,CAAC;IACvD,CAAC;EACH,CAAC,EAAE,CAACA,IAAI,EAAEG,QAAQ,CAAC,CAAC;EAEpBV,SAAS,CAAC,MAAM;IACdU,QAAQ,CAAC;MACPE,IAAI,EAAE,8BAA8B;MACpCC,QAAQ,EAAEN,IAAI;MACdO,KAAK,EAAEH;IACT,CAAC,CAAC;EACJ,CAAC,EAAE,CAACJ,IAAI,EAAEG,QAAQ,EAAEC,iBAAiB,CAAC,CAAC;EAEvC,oBACEN,IAAA,CAACF,UAAU;IAACI,IAAI,EAAEA,IAAK;IAACE,KAAK,EAAEA,KAAM;IAAAD,QAAA,EAClCA;EAAQ,CACC,CAAC;AAEjB,CAAC;AAED,eAAeF,mBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/views/PortalHost/index.tsx`
|
|
5
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
6
|
+
*
|
|
7
|
+
* Changed: import paths only, for this flat directory.
|
|
8
|
+
*/
|
|
9
|
+
import { memo, useEffect } from "react";
|
|
10
|
+
import { usePortalRegistryContext } from "./portal-registry.js";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
function PortalHost({
|
|
13
|
+
name,
|
|
14
|
+
children,
|
|
15
|
+
style
|
|
16
|
+
}) {
|
|
17
|
+
const {
|
|
18
|
+
registerHost
|
|
19
|
+
} = usePortalRegistryContext();
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
return () => {
|
|
22
|
+
registerHost(name, null);
|
|
23
|
+
};
|
|
24
|
+
}, [name, registerHost]);
|
|
25
|
+
return /*#__PURE__*/_jsx("div", {
|
|
26
|
+
style: {
|
|
27
|
+
...style,
|
|
28
|
+
pointerEvents: "none"
|
|
29
|
+
},
|
|
30
|
+
ref: ref => registerHost(name, ref),
|
|
31
|
+
children: children
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export default /*#__PURE__*/memo(PortalHost);
|
|
35
|
+
//# sourceMappingURL=PortalHostView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["memo","useEffect","usePortalRegistryContext","jsx","_jsx","PortalHost","name","children","style","registerHost","pointerEvents","ref"],"sourceRoot":"../../../src","sources":["teleport/PortalHostView.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,SAAS,QAAQ,OAAO;AACvC,SAASC,wBAAwB,QAAQ,sBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG7D,SAASC,UAAUA,CAAC;EAAEC,IAAI;EAAEC,QAAQ;EAAEC;AAAuB,CAAC,EAAE;EAC9D,MAAM;IAAEC;EAAa,CAAC,GAAGP,wBAAwB,CAAC,CAAC;EAEnDD,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXQ,YAAY,CAACH,IAAI,EAAE,IAAI,CAAC;IAC1B,CAAC;EACH,CAAC,EAAE,CAACA,IAAI,EAAEG,YAAY,CAAC,CAAC;EAExB,oBACEL,IAAA;IACEI,KAAK,EAAE;MAAE,GAAGA,KAAK;MAAEE,aAAa,EAAE;IAAO,CAAyB;IAClEC,GAAG,EAAGA,GAAG,IAAKF,YAAY,CAACH,IAAI,EAAEK,GAAG,CAAE;IAAAJ,QAAA,EAErCA;EAAQ,CACN,CAAC;AAEV;AAEA,4BAAeP,IAAI,CAACK,UAAU,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* COPIED FROM react-native-teleport 1.2.0 — `src/views/PortalHost/index.native.tsx`
|
|
5
|
+
* MIT, Copyright (c) 2025 Kiryl Ziusko. Full licence in `NOTICE` at the root.
|
|
6
|
+
*
|
|
7
|
+
* Changed: import paths only, for this flat directory.
|
|
8
|
+
*/
|
|
9
|
+
import PortalHostNativeComponent from "./specs/PortalHostViewNativeComponent.js";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
const PortalHost = props => {
|
|
12
|
+
return /*#__PURE__*/_jsx(PortalHostNativeComponent, {
|
|
13
|
+
pointerEvents: "box-none",
|
|
14
|
+
...props
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export default PortalHost;
|
|
18
|
+
//# sourceMappingURL=PortalHostView.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PortalHostNativeComponent","jsx","_jsx","PortalHost","props","pointerEvents"],"sourceRoot":"../../../src","sources":["teleport/PortalHostView.native.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,yBAAyB,MAAM,0CAAuC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG9E,MAAMC,UAAU,GAAIC,KAAsB,IAAK;EAC7C,oBAAOF,IAAA,CAACF,yBAAyB;IAACK,aAAa,EAAC,UAAU;IAAA,GAAKD;EAAK,CAAG,CAAC;AAC1E,CAAC;AAED,eAAeD,UAAU","ignoreList":[]}
|