@tamagui/portal 1.101.1 → 1.101.2

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.
@@ -25,24 +25,24 @@ __export(Portal_exports, {
25
25
  Portal: () => Portal
26
26
  });
27
27
  module.exports = __toCommonJS(Portal_exports);
28
- var import_polyfill_dev = require("@tamagui/polyfill-dev"), import_constants = require("@tamagui/constants"), import_stacks = require("@tamagui/stacks"), React = __toESM(require("react")), import_react_dom = require("react-dom"), import_jsx_runtime = require("react/jsx-runtime");
28
+ var import_polyfill_dev = require("@tamagui/polyfill-dev"), import_constants = require("@tamagui/constants"), import_stacks = require("@tamagui/stacks"), React = __toESM(require("react")), import_react_dom = require("react-dom"), import_use_did_finish_ssr = require("@tamagui/use-did-finish-ssr"), import_jsx_runtime = require("react/jsx-runtime");
29
29
  const Portal = React.memo(
30
30
  ({ host = globalThis.document?.body, ...props }) => {
31
- const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
31
+ if (import_constants.isServer)
32
+ return null;
33
+ const didFinishSSR = (0, import_use_did_finish_ssr.useDidFinishSSR)(), contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
32
34
  import_stacks.YStack,
33
35
  {
34
36
  contain: "strict",
35
37
  fullscreen: !0,
36
- position: import_constants.isWeb ? "fixed" : "absolute",
37
- maxWidth: import_constants.isWeb ? "100vw" : "100%",
38
- maxHeight: import_constants.isWeb ? "100vh" : "100%",
38
+ position: "fixed",
39
+ maxWidth: "100vw",
40
+ maxHeight: "100vh",
39
41
  pointerEvents: "none",
40
42
  ...props
41
43
  }
42
- ), [hostElement, setHostElement] = React.useState(null);
43
- return React.useEffect(() => {
44
- setHostElement(host);
45
- }, [host]), hostElement && props.children ? (0, import_react_dom.createPortal)(contents, hostElement) : null;
44
+ );
45
+ return (0, import_react_dom.createPortal)(didFinishSSR ? contents : null, host);
46
46
  }
47
47
  );
48
48
  //# sourceMappingURL=Portal.js.map
@@ -1,6 +1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eAAe,WAAW,MAAM,IAAI;AAAA,EAC1D;AACF;",
5
5
  "names": []
6
6
  }
@@ -1,26 +1,27 @@
1
1
  import "@tamagui/polyfill-dev";
2
- import { isWeb } from "@tamagui/constants";
2
+ import { isServer } from "@tamagui/constants";
3
3
  import { YStack } from "@tamagui/stacks";
4
4
  import * as React from "react";
5
5
  import { createPortal } from "react-dom";
6
+ import { useDidFinishSSR } from "@tamagui/use-did-finish-ssr";
6
7
  import { jsx } from "react/jsx-runtime";
7
8
  const Portal = React.memo(
8
9
  ({ host = globalThis.document?.body, ...props }) => {
9
- const contents = /* @__PURE__ */ jsx(
10
+ if (isServer)
11
+ return null;
12
+ const didFinishSSR = useDidFinishSSR(), contents = /* @__PURE__ */ jsx(
10
13
  YStack,
11
14
  {
12
15
  contain: "strict",
13
16
  fullscreen: !0,
14
- position: isWeb ? "fixed" : "absolute",
15
- maxWidth: isWeb ? "100vw" : "100%",
16
- maxHeight: isWeb ? "100vh" : "100%",
17
+ position: "fixed",
18
+ maxWidth: "100vw",
19
+ maxHeight: "100vh",
17
20
  pointerEvents: "none",
18
21
  ...props
19
22
  }
20
- ), [hostElement, setHostElement] = React.useState(null);
21
- return React.useEffect(() => {
22
- setHostElement(host);
23
- }, [host]), hostElement && props.children ? createPortal(contents, hostElement) : null;
23
+ );
24
+ return createPortal(didFinishSSR ? contents : null, host);
24
25
  }
25
26
  );
26
27
  export {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Portal.tsx"],
4
- "mappings": "AAAA,OAAO;AAEP,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAOvB;AAHC,MAAM,SAAS,MAAM;AAAA,EAC1B,CAAC,EAAE,OAAO,WAAW,UAAU,MAAM,GAAG,MAAM,MAAmB;AAC/D,UAAM,WACJ;AAAA,MAAC;AAAA;AAAA,QACC,SAAQ;AAAA,QACR,YAAU;AAAA,QAEV,UAAU,QAAQ,UAAU;AAAA,QAC5B,UAAU,QAAQ,UAAU;AAAA,QAC5B,WAAW,QAAQ,UAAU;AAAA,QAC7B,eAAc;AAAA,QACb,GAAG;AAAA;AAAA,IACN,GAGI,CAAC,aAAa,cAAc,IAAI,MAAM,SAAc,IAAI;AAQ9D,WANA,MAAM,UAAU,MAAM;AAEpB,qBAAe,IAAI;AAAA,IAErB,GAAG,CAAC,IAAI,CAAC,GAEL,eAAe,MAAM,WAChB,aAAa,UAAU,WAAW,IAIpC;AAAA,EACT;AACF;",
4
+ "mappings": "AAAA,OAAO;AAEP,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAE7B,SAAS,uBAAuB;AAc1B;AATC,MAAM,SAAS,MAAM;AAAA,EAC1B,CAAC,EAAE,OAAO,WAAW,UAAU,MAAM,GAAG,MAAM,MAAmB;AAC/D,QAAI;AACF,aAAO;AAGT,UAAM,eAAe,gBAAgB,GAE/B,WACJ;AAAA,MAAC;AAAA;AAAA,QACC,SAAQ;AAAA,QACR,YAAU;AAAA,QAEV,UAAS;AAAA,QACT,UAAS;AAAA,QACT,WAAU;AAAA,QACV,eAAc;AAAA,QACb,GAAG;AAAA;AAAA,IACN;AAGF,WAAO,aAAa,eAAe,WAAW,MAAM,IAAI;AAAA,EAC1D;AACF;",
5
5
  "names": []
6
6
  }
@@ -1,25 +1,25 @@
1
1
  import "@tamagui/polyfill-dev";
2
- import { isWeb } from "@tamagui/constants";
2
+ import { isServer } from "@tamagui/constants";
3
3
  import { YStack } from "@tamagui/stacks";
4
4
  import * as React from "react";
5
5
  import { createPortal } from "react-dom";
6
+ import { useDidFinishSSR } from "@tamagui/use-did-finish-ssr";
6
7
  import { jsx } from "react/jsx-runtime";
7
8
  const Portal = React.memo(({
8
9
  host = globalThis.document?.body,
9
10
  ...props
10
11
  }) => {
11
- const contents = /* @__PURE__ */jsx(YStack, {
12
+ if (isServer) return null;
13
+ const didFinishSSR = useDidFinishSSR(),
14
+ contents = /* @__PURE__ */jsx(YStack, {
12
15
  contain: "strict",
13
16
  fullscreen: !0,
14
- position: isWeb ? "fixed" : "absolute",
15
- maxWidth: isWeb ? "100vw" : "100%",
16
- maxHeight: isWeb ? "100vh" : "100%",
17
+ position: "fixed",
18
+ maxWidth: "100vw",
19
+ maxHeight: "100vh",
17
20
  pointerEvents: "none",
18
21
  ...props
19
- }),
20
- [hostElement, setHostElement] = React.useState(null);
21
- return React.useEffect(() => {
22
- setHostElement(host);
23
- }, [host]), hostElement && props.children ? createPortal(contents, hostElement) : null;
22
+ });
23
+ return createPortal(didFinishSSR ? contents : null, host);
24
24
  });
25
25
  export { Portal };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/portal",
3
- "version": "1.101.1",
3
+ "version": "1.101.2",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -28,17 +28,17 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@tamagui/constants": "1.101.1",
32
- "@tamagui/core": "1.101.1",
33
- "@tamagui/stacks": "1.101.1",
34
- "@tamagui/use-did-finish-ssr": "1.101.1",
35
- "@tamagui/use-event": "1.101.1"
31
+ "@tamagui/constants": "1.101.2",
32
+ "@tamagui/core": "1.101.2",
33
+ "@tamagui/stacks": "1.101.2",
34
+ "@tamagui/use-did-finish-ssr": "1.101.2",
35
+ "@tamagui/use-event": "1.101.2"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": "*"
39
39
  },
40
40
  "devDependencies": {
41
- "@tamagui/build": "1.101.1",
41
+ "@tamagui/build": "1.101.2",
42
42
  "react": "^18.2.0",
43
43
  "react-native": "0.74.1"
44
44
  },
package/src/Portal.tsx CHANGED
@@ -1,40 +1,36 @@
1
1
  import '@tamagui/polyfill-dev'
2
2
 
3
- import { isWeb } from '@tamagui/constants'
3
+ import { isServer } from '@tamagui/constants'
4
4
  import { YStack } from '@tamagui/stacks'
5
5
  import * as React from 'react'
6
6
  import { createPortal } from 'react-dom'
7
7
 
8
+ import { useDidFinishSSR } from '@tamagui/use-did-finish-ssr'
8
9
  import type { PortalProps } from './PortalProps'
9
10
 
11
+ // web only version
12
+
10
13
  export const Portal = React.memo(
11
14
  ({ host = globalThis.document?.body, ...props }: PortalProps) => {
15
+ if (isServer) {
16
+ return null
17
+ }
18
+
19
+ const didFinishSSR = useDidFinishSSR()
20
+
12
21
  const contents = (
13
22
  <YStack
14
23
  contain="strict"
15
24
  fullscreen
16
25
  // @ts-expect-error ok on web
17
- position={isWeb ? 'fixed' : 'absolute'}
18
- maxWidth={isWeb ? '100vw' : '100%'}
19
- maxHeight={isWeb ? '100vh' : '100%'}
26
+ position="fixed"
27
+ maxWidth="100vw"
28
+ maxHeight="100vh"
20
29
  pointerEvents="none"
21
30
  {...props}
22
31
  />
23
32
  )
24
33
 
25
- const [hostElement, setHostElement] = React.useState<any>(null)
26
-
27
- React.useEffect(() => {
28
- // React.startTransition(() => {
29
- setHostElement(host)
30
- // })
31
- }, [host])
32
-
33
- if (hostElement && props.children) {
34
- return createPortal(contents, hostElement) as any
35
- }
36
-
37
- // ssr return null
38
- return null
34
+ return createPortal(didFinishSSR ? contents : null, host) as any
39
35
  }
40
36
  )
@@ -1 +1 @@
1
- {"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../src/Portal.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAI9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,eAAO,MAAM,MAAM,iDACgC,WAAW,SA6B7D,CAAA"}
1
+ {"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../src/Portal.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAI9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAIhD,eAAO,MAAM,MAAM,iDACgC,WAAW,SAsB7D,CAAA"}