@tamagui/portal 1.0.1-beta.112 → 1.0.1-beta.113

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.
@@ -29,8 +29,7 @@ var import_core = require("@tamagui/core");
29
29
  var import_stacks = require("@tamagui/stacks");
30
30
  var React = __toESM(require("react"));
31
31
  var import_react_dom = require("react-dom");
32
- var import_react_native = require("react-native");
33
- const Portal = ({ visible, ...props }) => {
32
+ const Portal = ({ host = ((_a) => (_a = globalThis.document) == null ? void 0 : _a.body)(), ...props }) => {
34
33
  const contents = /* @__PURE__ */ React.createElement(import_stacks.YStack, {
35
34
  pointerEvents: "box-none",
36
35
  fullscreen: true,
@@ -38,20 +37,10 @@ const Portal = ({ visible, ...props }) => {
38
37
  maxWidth: import_core.isWeb ? "100vw" : "100%",
39
38
  ...props
40
39
  });
41
- if (!import_core.isWeb) {
42
- return /* @__PURE__ */ React.createElement(import_react_native.Modal, {
43
- presentationStyle: "overFullScreen",
44
- hardwareAccelerated: true,
45
- visible,
46
- transparent: true,
47
- pointerEvents: "box-none"
48
- }, contents);
49
- }
50
40
  const [hostElement, setHostElement] = React.useState(null);
51
41
  (0, import_core.useIsomorphicLayoutEffect)(() => {
52
- var _a;
53
- setHostElement((_a = globalThis.document) == null ? void 0 : _a.body);
54
- }, []);
42
+ setHostElement(host);
43
+ }, [host]);
55
44
  if (hostElement) {
56
45
  return (0, import_react_dom.createPortal)(contents, hostElement);
57
46
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Portal.tsx"],
4
- "sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport '@tamagui/polyfill-dev'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\nimport { Modal } from 'react-native'\n\nexport type PortalProps = YStackProps & {\n visible?: boolean\n}\n\nexport const Portal = ({ visible, ...props }: PortalProps) => {\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n fullscreen\n // @ts-expect-error ok on web\n position={isWeb ? 'fixed' : 'absolute'}\n maxWidth={isWeb ? '100vw' : '100%'}\n {...props}\n />\n )\n\n if (!isWeb) {\n // check if theme stays in context here\n return (\n <Modal\n presentationStyle=\"overFullScreen\"\n hardwareAccelerated\n visible={visible}\n transparent\n pointerEvents=\"box-none\"\n >\n {contents}\n </Modal>\n )\n }\n\n const [hostElement, setHostElement] = React.useState<any>(null)\n\n useIsomorphicLayoutEffect(() => {\n setHostElement(globalThis.document?.body)\n }, [])\n\n if (hostElement) {\n return createPortal(contents, hostElement)\n }\n\n // ssr return null\n return null\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAO;AAEP,kBAAiD;AACjD,oBAAoC;AACpC,YAAuB;AACvB,uBAA6B;AAC7B,0BAAsB;AAMf,MAAM,SAAS,CAAC,EAAE,YAAY,YAAyB;AAC5D,QAAM,WACJ,oCAAC;AAAA,IACC,eAAc;AAAA,IACd,YAAU;AAAA,IAEV,UAAU,oBAAQ,UAAU;AAAA,IAC5B,UAAU,oBAAQ,UAAU;AAAA,IAC3B,GAAG;AAAA,GACN;AAGF,MAAI,CAAC,mBAAO;AAEV,WACE,oCAAC;AAAA,MACC,mBAAkB;AAAA,MAClB,qBAAmB;AAAA,MACnB;AAAA,MACA,aAAW;AAAA,MACX,eAAc;AAAA,OAEb,QACH;AAAA,EAEJ;AAEA,QAAM,CAAC,aAAa,kBAAkB,MAAM,SAAc,IAAI;AAE9D,6CAA0B,MAAM;AA1ClC;AA2CI,mBAAe,iBAAW,aAAX,mBAAqB,IAAI;AAAA,EAC1C,GAAG,CAAC,CAAC;AAEL,MAAI,aAAa;AACf,WAAO,mCAAa,UAAU,WAAW;AAAA,EAC3C;AAGA,SAAO;AACT;",
4
+ "sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport '@tamagui/polyfill-dev'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nexport type PortalProps = YStackProps & {\n host?: any // element\n}\n\nexport const Portal = ({ host = globalThis.document?.body, ...props }: PortalProps) => {\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n fullscreen\n // @ts-expect-error ok on web\n position={isWeb ? 'fixed' : 'absolute'}\n maxWidth={isWeb ? '100vw' : '100%'}\n {...props}\n />\n )\n\n const [hostElement, setHostElement] = React.useState<any>(null)\n\n useIsomorphicLayoutEffect(() => {\n setHostElement(host)\n }, [host])\n\n if (hostElement) {\n return createPortal(contents, hostElement)\n }\n\n // ssr return null\n return null\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAO;AAEP,kBAAiD;AACjD,oBAAoC;AACpC,YAAuB;AACvB,uBAA6B;AAMtB,MAAM,SAAS,CAAC,EAAE,OAAO,0BAAW,aAAX,mBAAqB,YAAS,YAAyB;AACrF,QAAM,WACJ,oCAAC;AAAA,IACC,eAAc;AAAA,IACd,YAAU;AAAA,IAEV,UAAU,oBAAQ,UAAU;AAAA,IAC5B,UAAU,oBAAQ,UAAU;AAAA,IAC3B,GAAG;AAAA,GACN;AAGF,QAAM,CAAC,aAAa,kBAAkB,MAAM,SAAc,IAAI;AAE9D,6CAA0B,MAAM;AAC9B,mBAAe,IAAI;AAAA,EACrB,GAAG,CAAC,IAAI,CAAC;AAET,MAAI,aAAa;AACf,WAAO,mCAAa,UAAU,WAAW;AAAA,EAC3C;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var Portal_native_exports = {};
23
+ __export(Portal_native_exports, {
24
+ Portal: () => Portal
25
+ });
26
+ module.exports = __toCommonJS(Portal_native_exports);
27
+ var import_stacks = require("@tamagui/stacks");
28
+ var React = __toESM(require("react"));
29
+ var import_react_native = require("react-native");
30
+ var import_ReactNative = require("react-native/Libraries/Renderer/shims/ReactNative");
31
+ let root = 0;
32
+ const og = import_react_native.AppRegistry.runApplication.bind(import_react_native.AppRegistry);
33
+ import_react_native.AppRegistry.runApplication = function(...args) {
34
+ var _a;
35
+ root = (_a = args[1]) == null ? void 0 : _a.rootTag;
36
+ return og(...args);
37
+ };
38
+ const Portal = (props) => {
39
+ const contents = /* @__PURE__ */ React.createElement(import_stacks.YStack, {
40
+ pointerEvents: "box-none",
41
+ fullscreen: true,
42
+ position: "absolute",
43
+ maxWidth: "100%",
44
+ zIndex: 1e5,
45
+ ...props
46
+ });
47
+ if (root) {
48
+ return (0, import_ReactNative.createPortal)(contents, root);
49
+ }
50
+ return null;
51
+ };
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ Portal
55
+ });
56
+ //# sourceMappingURL=Portal.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Portal.native.tsx"],
4
+ "sourcesContent": ["import { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { AppRegistry } from 'react-native'\nimport { createPortal } from 'react-native/Libraries/Renderer/shims/ReactNative'\n\nexport type PortalProps = YStackProps\n\nlet root = 0\nconst og = AppRegistry.runApplication.bind(AppRegistry)\nAppRegistry.runApplication = function (...args) {\n root = args[1]?.rootTag\n return og(...args)\n}\n\nexport const Portal = (props: PortalProps) => {\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n fullscreen\n position=\"absolute\"\n maxWidth=\"100%\"\n zIndex={100000}\n {...props}\n />\n )\n\n if (root) {\n return createPortal(contents, root)\n }\n\n return null\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAoC;AACpC,YAAuB;AACvB,0BAA4B;AAC5B,yBAA6B;AAI7B,IAAI,OAAO;AACX,MAAM,KAAK,gCAAY,eAAe,KAAK,+BAAW;AACtD,gCAAY,iBAAiB,YAAa,MAAM;AAThD;AAUE,SAAO,WAAK,OAAL,mBAAS;AAChB,SAAO,GAAG,GAAG,IAAI;AACnB;AAEO,MAAM,SAAS,CAAC,UAAuB;AAC5C,QAAM,WACJ,oCAAC;AAAA,IACC,eAAc;AAAA,IACd,YAAU;AAAA,IACV,UAAS;AAAA,IACT,UAAS;AAAA,IACT,QAAQ;AAAA,IACP,GAAG;AAAA,GACN;AAGF,MAAI,MAAM;AACR,WAAO,qCAAa,UAAU,IAAI;AAAA,EACpC;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -3,8 +3,7 @@ import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/core";
3
3
  import { YStack } from "@tamagui/stacks";
4
4
  import * as React from "react";
5
5
  import { createPortal } from "react-dom";
6
- import { Modal } from "react-native";
7
- const Portal = ({ visible, ...props }) => {
6
+ const Portal = ({ host = ((_a) => (_a = globalThis.document) == null ? void 0 : _a.body)(), ...props }) => {
8
7
  const contents = /* @__PURE__ */ React.createElement(YStack, {
9
8
  pointerEvents: "box-none",
10
9
  fullscreen: true,
@@ -12,20 +11,10 @@ const Portal = ({ visible, ...props }) => {
12
11
  maxWidth: isWeb ? "100vw" : "100%",
13
12
  ...props
14
13
  });
15
- if (!isWeb) {
16
- return /* @__PURE__ */ React.createElement(Modal, {
17
- presentationStyle: "overFullScreen",
18
- hardwareAccelerated: true,
19
- visible,
20
- transparent: true,
21
- pointerEvents: "box-none"
22
- }, contents);
23
- }
24
14
  const [hostElement, setHostElement] = React.useState(null);
25
15
  useIsomorphicLayoutEffect(() => {
26
- var _a;
27
- setHostElement((_a = globalThis.document) == null ? void 0 : _a.body);
28
- }, []);
16
+ setHostElement(host);
17
+ }, [host]);
29
18
  if (hostElement) {
30
19
  return createPortal(contents, hostElement);
31
20
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Portal.tsx"],
4
- "sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport '@tamagui/polyfill-dev'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\nimport { Modal } from 'react-native'\n\nexport type PortalProps = YStackProps & {\n visible?: boolean\n}\n\nexport const Portal = ({ visible, ...props }: PortalProps) => {\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n fullscreen\n // @ts-expect-error ok on web\n position={isWeb ? 'fixed' : 'absolute'}\n maxWidth={isWeb ? '100vw' : '100%'}\n {...props}\n />\n )\n\n if (!isWeb) {\n // check if theme stays in context here\n return (\n <Modal\n presentationStyle=\"overFullScreen\"\n hardwareAccelerated\n visible={visible}\n transparent\n pointerEvents=\"box-none\"\n >\n {contents}\n </Modal>\n )\n }\n\n const [hostElement, setHostElement] = React.useState<any>(null)\n\n useIsomorphicLayoutEffect(() => {\n setHostElement(globalThis.document?.body)\n }, [])\n\n if (hostElement) {\n return createPortal(contents, hostElement)\n }\n\n // ssr return null\n return null\n}\n"],
5
- "mappings": "AACA;AAEA;AACA;AACA;AACA;AACA;AAMO,MAAM,SAAS,CAAC,EAAE,YAAY,YAAyB;AAC5D,QAAM,WACJ,oCAAC;AAAA,IACC,eAAc;AAAA,IACd,YAAU;AAAA,IAEV,UAAU,QAAQ,UAAU;AAAA,IAC5B,UAAU,QAAQ,UAAU;AAAA,IAC3B,GAAG;AAAA,GACN;AAGF,MAAI,CAAC,OAAO;AAEV,WACE,oCAAC;AAAA,MACC,mBAAkB;AAAA,MAClB,qBAAmB;AAAA,MACnB;AAAA,MACA,aAAW;AAAA,MACX,eAAc;AAAA,OAEb,QACH;AAAA,EAEJ;AAEA,QAAM,CAAC,aAAa,kBAAkB,MAAM,SAAc,IAAI;AAE9D,4BAA0B,MAAM;AA1ClC;AA2CI,mBAAe,iBAAW,aAAX,mBAAqB,IAAI;AAAA,EAC1C,GAAG,CAAC,CAAC;AAEL,MAAI,aAAa;AACf,WAAO,aAAa,UAAU,WAAW;AAAA,EAC3C;AAGA,SAAO;AACT;",
4
+ "sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport '@tamagui/polyfill-dev'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nexport type PortalProps = YStackProps & {\n host?: any // element\n}\n\nexport const Portal = ({ host = globalThis.document?.body, ...props }: PortalProps) => {\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n fullscreen\n // @ts-expect-error ok on web\n position={isWeb ? 'fixed' : 'absolute'}\n maxWidth={isWeb ? '100vw' : '100%'}\n {...props}\n />\n )\n\n const [hostElement, setHostElement] = React.useState<any>(null)\n\n useIsomorphicLayoutEffect(() => {\n setHostElement(host)\n }, [host])\n\n if (hostElement) {\n return createPortal(contents, hostElement)\n }\n\n // ssr return null\n return null\n}\n"],
5
+ "mappings": "AACA;AAEA;AACA;AACA;AACA;AAMO,MAAM,SAAS,CAAC,EAAE,OAAO,0BAAW,aAAX,mBAAqB,YAAS,YAAyB;AACrF,QAAM,WACJ,oCAAC;AAAA,IACC,eAAc;AAAA,IACd,YAAU;AAAA,IAEV,UAAU,QAAQ,UAAU;AAAA,IAC5B,UAAU,QAAQ,UAAU;AAAA,IAC3B,GAAG;AAAA,GACN;AAGF,QAAM,CAAC,aAAa,kBAAkB,MAAM,SAAc,IAAI;AAE9D,4BAA0B,MAAM;AAC9B,mBAAe,IAAI;AAAA,EACrB,GAAG,CAAC,IAAI,CAAC;AAET,MAAI,aAAa;AACf,WAAO,aAAa,UAAU,WAAW;AAAA,EAC3C;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,29 @@
1
+ import { YStack } from "@tamagui/stacks";
2
+ import * as React from "react";
3
+ import { AppRegistry } from "react-native";
4
+ import { createPortal } from "react-native/Libraries/Renderer/shims/ReactNative";
5
+ let root = 0;
6
+ const og = AppRegistry.runApplication.bind(AppRegistry);
7
+ AppRegistry.runApplication = function(...args) {
8
+ var _a;
9
+ root = (_a = args[1]) == null ? void 0 : _a.rootTag;
10
+ return og(...args);
11
+ };
12
+ const Portal = (props) => {
13
+ const contents = /* @__PURE__ */ React.createElement(YStack, {
14
+ pointerEvents: "box-none",
15
+ fullscreen: true,
16
+ position: "absolute",
17
+ maxWidth: "100%",
18
+ zIndex: 1e5,
19
+ ...props
20
+ });
21
+ if (root) {
22
+ return createPortal(contents, root);
23
+ }
24
+ return null;
25
+ };
26
+ export {
27
+ Portal
28
+ };
29
+ //# sourceMappingURL=Portal.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Portal.native.tsx"],
4
+ "sourcesContent": ["import { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { AppRegistry } from 'react-native'\nimport { createPortal } from 'react-native/Libraries/Renderer/shims/ReactNative'\n\nexport type PortalProps = YStackProps\n\nlet root = 0\nconst og = AppRegistry.runApplication.bind(AppRegistry)\nAppRegistry.runApplication = function (...args) {\n root = args[1]?.rootTag\n return og(...args)\n}\n\nexport const Portal = (props: PortalProps) => {\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n fullscreen\n position=\"absolute\"\n maxWidth=\"100%\"\n zIndex={100000}\n {...props}\n />\n )\n\n if (root) {\n return createPortal(contents, root)\n }\n\n return null\n}\n"],
5
+ "mappings": "AAAA;AACA;AACA;AACA;AAIA,IAAI,OAAO;AACX,MAAM,KAAK,YAAY,eAAe,KAAK,WAAW;AACtD,YAAY,iBAAiB,YAAa,MAAM;AAThD;AAUE,SAAO,WAAK,OAAL,mBAAS;AAChB,SAAO,GAAG,GAAG,IAAI;AACnB;AAEO,MAAM,SAAS,CAAC,UAAuB;AAC5C,QAAM,WACJ,oCAAC;AAAA,IACC,eAAc;AAAA,IACd,YAAU;AAAA,IACV,UAAS;AAAA,IACT,UAAS;AAAA,IACT,QAAQ;AAAA,IACP,GAAG;AAAA,GACN;AAGF,MAAI,MAAM;AACR,WAAO,aAAa,UAAU,IAAI;AAAA,EACpC;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -3,17 +3,12 @@ import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/core";
3
3
  import { YStack } from "@tamagui/stacks";
4
4
  import * as React from "react";
5
5
  import { createPortal } from "react-dom";
6
- import { Modal } from "react-native";
7
- const Portal = ({ visible, ...props }) => {
6
+ const Portal = ({ host = ((_a) => (_a = globalThis.document) == null ? void 0 : _a.body)(), ...props }) => {
8
7
  const contents = <YStack pointerEvents="box-none" fullscreen position={isWeb ? "fixed" : "absolute"} maxWidth={isWeb ? "100vw" : "100%"} {...props} />;
9
- if (!isWeb) {
10
- return <Modal presentationStyle="overFullScreen" hardwareAccelerated visible={visible} transparent pointerEvents="box-none">{contents}</Modal>;
11
- }
12
8
  const [hostElement, setHostElement] = React.useState(null);
13
9
  useIsomorphicLayoutEffect(() => {
14
- var _a;
15
- setHostElement((_a = globalThis.document) == null ? void 0 : _a.body);
16
- }, []);
10
+ setHostElement(host);
11
+ }, [host]);
17
12
  if (hostElement) {
18
13
  return createPortal(contents, hostElement);
19
14
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Portal.tsx"],
4
- "sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport '@tamagui/polyfill-dev'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\nimport { Modal } from 'react-native'\n\nexport type PortalProps = YStackProps & {\n visible?: boolean\n}\n\nexport const Portal = ({ visible, ...props }: PortalProps) => {\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n fullscreen\n // @ts-expect-error ok on web\n position={isWeb ? 'fixed' : 'absolute'}\n maxWidth={isWeb ? '100vw' : '100%'}\n {...props}\n />\n )\n\n if (!isWeb) {\n // check if theme stays in context here\n return (\n <Modal\n presentationStyle=\"overFullScreen\"\n hardwareAccelerated\n visible={visible}\n transparent\n pointerEvents=\"box-none\"\n >\n {contents}\n </Modal>\n )\n }\n\n const [hostElement, setHostElement] = React.useState<any>(null)\n\n useIsomorphicLayoutEffect(() => {\n setHostElement(globalThis.document?.body)\n }, [])\n\n if (hostElement) {\n return createPortal(contents, hostElement)\n }\n\n // ssr return null\n return null\n}\n"],
5
- "mappings": "AACA;AAEA;AACA;AACA;AACA;AACA;AAMO,MAAM,SAAS,CAAC,EAAE,YAAY,YAAyB;AAC5D,QAAM,WACJ,CAAC,OACC,cAAc,WACd,WAEA,UAAU,QAAQ,UAAU,YAC5B,UAAU,QAAQ,UAAU,YACxB,OACN;AAGF,MAAI,CAAC,OAAO;AAEV,WACE,CAAC,MACC,kBAAkB,iBAClB,oBACA,SAAS,SACT,YACA,cAAc,YAEb,SACH,EARC;AAAA,EAUL;AAEA,QAAM,CAAC,aAAa,kBAAkB,MAAM,SAAc,IAAI;AAE9D,4BAA0B,MAAM;AA1ClC;AA2CI,mBAAe,iBAAW,aAAX,mBAAqB,IAAI;AAAA,EAC1C,GAAG,CAAC,CAAC;AAEL,MAAI,aAAa;AACf,WAAO,aAAa,UAAU,WAAW;AAAA,EAC3C;AAGA,SAAO;AACT;",
4
+ "sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport '@tamagui/polyfill-dev'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '@tamagui/core'\nimport { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nexport type PortalProps = YStackProps & {\n host?: any // element\n}\n\nexport const Portal = ({ host = globalThis.document?.body, ...props }: PortalProps) => {\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n fullscreen\n // @ts-expect-error ok on web\n position={isWeb ? 'fixed' : 'absolute'}\n maxWidth={isWeb ? '100vw' : '100%'}\n {...props}\n />\n )\n\n const [hostElement, setHostElement] = React.useState<any>(null)\n\n useIsomorphicLayoutEffect(() => {\n setHostElement(host)\n }, [host])\n\n if (hostElement) {\n return createPortal(contents, hostElement)\n }\n\n // ssr return null\n return null\n}\n"],
5
+ "mappings": "AACA;AAEA;AACA;AACA;AACA;AAMO,MAAM,SAAS,CAAC,EAAE,OAAO,0BAAW,aAAX,mBAAqB,YAAS,YAAyB;AACrF,QAAM,WACJ,CAAC,OACC,cAAc,WACd,WAEA,UAAU,QAAQ,UAAU,YAC5B,UAAU,QAAQ,UAAU,YACxB,OACN;AAGF,QAAM,CAAC,aAAa,kBAAkB,MAAM,SAAc,IAAI;AAE9D,4BAA0B,MAAM;AAC9B,mBAAe,IAAI;AAAA,EACrB,GAAG,CAAC,IAAI,CAAC;AAET,MAAI,aAAa;AACf,WAAO,aAAa,UAAU,WAAW;AAAA,EAC3C;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,21 @@
1
+ import { YStack } from "@tamagui/stacks";
2
+ import { AppRegistry } from "react-native";
3
+ import { createPortal } from "react-native/Libraries/Renderer/shims/ReactNative";
4
+ let root = 0;
5
+ const og = AppRegistry.runApplication.bind(AppRegistry);
6
+ AppRegistry.runApplication = function(...args) {
7
+ var _a;
8
+ root = (_a = args[1]) == null ? void 0 : _a.rootTag;
9
+ return og(...args);
10
+ };
11
+ const Portal = (props) => {
12
+ const contents = <YStack pointerEvents="box-none" fullscreen position="absolute" maxWidth="100%" zIndex={1e5} {...props} />;
13
+ if (root) {
14
+ return createPortal(contents, root);
15
+ }
16
+ return null;
17
+ };
18
+ export {
19
+ Portal
20
+ };
21
+ //# sourceMappingURL=Portal.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Portal.native.tsx"],
4
+ "sourcesContent": ["import { YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { AppRegistry } from 'react-native'\nimport { createPortal } from 'react-native/Libraries/Renderer/shims/ReactNative'\n\nexport type PortalProps = YStackProps\n\nlet root = 0\nconst og = AppRegistry.runApplication.bind(AppRegistry)\nAppRegistry.runApplication = function (...args) {\n root = args[1]?.rootTag\n return og(...args)\n}\n\nexport const Portal = (props: PortalProps) => {\n const contents = (\n <YStack\n pointerEvents=\"box-none\"\n fullscreen\n position=\"absolute\"\n maxWidth=\"100%\"\n zIndex={100000}\n {...props}\n />\n )\n\n if (root) {\n return createPortal(contents, root)\n }\n\n return null\n}\n"],
5
+ "mappings": "AAAA;AAEA;AACA;AAIA,IAAI,OAAO;AACX,MAAM,KAAK,YAAY,eAAe,KAAK,WAAW;AACtD,YAAY,iBAAiB,YAAa,MAAM;AAThD;AAUE,SAAO,WAAK,OAAL,mBAAS;AAChB,SAAO,GAAG,GAAG,IAAI;AACnB;AAEO,MAAM,SAAS,CAAC,UAAuB;AAC5C,QAAM,WACJ,CAAC,OACC,cAAc,WACd,WACA,SAAS,WACT,SAAS,OACT,QAAQ,SACJ,OACN;AAGF,MAAI,MAAM;AACR,WAAO,aAAa,UAAU,IAAI;AAAA,EACpC;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/portal",
3
- "version": "1.0.1-beta.112",
3
+ "version": "1.0.1-beta.113",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -18,8 +18,8 @@
18
18
  "clean:build": "tamagui-build clean:build"
19
19
  },
20
20
  "dependencies": {
21
- "@tamagui/core": "^1.0.1-beta.112",
22
- "@tamagui/stacks": "^1.0.1-beta.112"
21
+ "@tamagui/core": "^1.0.1-beta.113",
22
+ "@tamagui/stacks": "^1.0.1-beta.113"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": "*",
@@ -27,7 +27,7 @@
27
27
  "react-native": "*"
28
28
  },
29
29
  "devDependencies": {
30
- "@tamagui/build": "^1.0.1-beta.112",
30
+ "@tamagui/build": "^1.0.1-beta.113",
31
31
  "@types/react-native": "^0.69.2",
32
32
  "react": "*",
33
33
  "react-dom": "*",
@@ -0,0 +1,32 @@
1
+ import { YStack, YStackProps } from '@tamagui/stacks'
2
+ import * as React from 'react'
3
+ import { AppRegistry } from 'react-native'
4
+ import { createPortal } from 'react-native/Libraries/Renderer/shims/ReactNative'
5
+
6
+ export type PortalProps = YStackProps
7
+
8
+ let root = 0
9
+ const og = AppRegistry.runApplication.bind(AppRegistry)
10
+ AppRegistry.runApplication = function (...args) {
11
+ root = args[1]?.rootTag
12
+ return og(...args)
13
+ }
14
+
15
+ export const Portal = (props: PortalProps) => {
16
+ const contents = (
17
+ <YStack
18
+ pointerEvents="box-none"
19
+ fullscreen
20
+ position="absolute"
21
+ maxWidth="100%"
22
+ zIndex={100000}
23
+ {...props}
24
+ />
25
+ )
26
+
27
+ if (root) {
28
+ return createPortal(contents, root)
29
+ }
30
+
31
+ return null
32
+ }
package/src/Portal.tsx CHANGED
@@ -5,13 +5,12 @@ import { isWeb, useIsomorphicLayoutEffect } from '@tamagui/core'
5
5
  import { YStack, YStackProps } from '@tamagui/stacks'
6
6
  import * as React from 'react'
7
7
  import { createPortal } from 'react-dom'
8
- import { Modal } from 'react-native'
9
8
 
10
9
  export type PortalProps = YStackProps & {
11
- visible?: boolean
10
+ host?: any // element
12
11
  }
13
12
 
14
- export const Portal = ({ visible, ...props }: PortalProps) => {
13
+ export const Portal = ({ host = globalThis.document?.body, ...props }: PortalProps) => {
15
14
  const contents = (
16
15
  <YStack
17
16
  pointerEvents="box-none"
@@ -23,26 +22,11 @@ export const Portal = ({ visible, ...props }: PortalProps) => {
23
22
  />
24
23
  )
25
24
 
26
- if (!isWeb) {
27
- // check if theme stays in context here
28
- return (
29
- <Modal
30
- presentationStyle="overFullScreen"
31
- hardwareAccelerated
32
- visible={visible}
33
- transparent
34
- pointerEvents="box-none"
35
- >
36
- {contents}
37
- </Modal>
38
- )
39
- }
40
-
41
25
  const [hostElement, setHostElement] = React.useState<any>(null)
42
26
 
43
27
  useIsomorphicLayoutEffect(() => {
44
- setHostElement(globalThis.document?.body)
45
- }, [])
28
+ setHostElement(host)
29
+ }, [host])
46
30
 
47
31
  if (hostElement) {
48
32
  return createPortal(contents, hostElement)
package/types/Portal.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import '@tamagui/polyfill-dev';
2
2
  import { YStackProps } from '@tamagui/stacks';
3
+ import * as React from 'react';
3
4
  export declare type PortalProps = YStackProps & {
4
- visible?: boolean;
5
+ host?: any;
5
6
  };
6
- export declare const Portal: ({ visible, ...props }: PortalProps) => JSX.Element | null;
7
+ export declare const Portal: ({ host, ...props }: PortalProps) => React.ReactPortal | null;
7
8
  //# sourceMappingURL=Portal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../src/Portal.tsx"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAA;AAG9B,OAAO,EAAU,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAKrD,oBAAY,WAAW,GAAG,WAAW,GAAG;IACtC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,MAAM,0BAA2B,WAAW,uBAuCxD,CAAA"}
1
+ {"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../src/Portal.tsx"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAA;AAG9B,OAAO,EAAU,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,oBAAY,WAAW,GAAG,WAAW,GAAG;IACtC,IAAI,CAAC,EAAE,GAAG,CAAA;CACX,CAAA;AAED,eAAO,MAAM,MAAM,uBAAoD,WAAW,6BAwBjF,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { YStackProps } from '@tamagui/stacks';
2
+ export declare type PortalProps = YStackProps;
3
+ export declare const Portal: (props: PortalProps) => any;
4
+ //# sourceMappingURL=Portal.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Portal.native.d.ts","sourceRoot":"","sources":["../src/Portal.native.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAU,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAKrD,oBAAY,WAAW,GAAG,WAAW,CAAA;AASrC,eAAO,MAAM,MAAM,UAAW,WAAW,QAiBxC,CAAA"}