@radix-ui/react-portal 0.1.5-rc.8 → 1.0.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/dist/index.d.ts CHANGED
@@ -3,13 +3,9 @@ import * as Radix from "@radix-ui/react-primitive";
3
3
  import { Primitive } from "@radix-ui/react-primitive";
4
4
  type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
5
5
  export interface PortalProps extends PrimitiveDivProps {
6
- containerRef?: React.RefObject<HTMLElement>;
7
- }
8
- export const Portal: React.ForwardRefExoticComponent<PortalProps & React.RefAttributes<HTMLDivElement>>;
9
- export interface UnstablePortalProps extends PrimitiveDivProps {
10
6
  container?: HTMLElement | null;
11
7
  }
12
- export const UnstablePortal: React.ForwardRefExoticComponent<UnstablePortalProps & React.RefAttributes<HTMLDivElement>>;
8
+ export const Portal: React.ForwardRefExoticComponent<PortalProps & React.RefAttributes<HTMLDivElement>>;
13
9
  export const Root: React.ForwardRefExoticComponent<PortalProps & React.RefAttributes<HTMLDivElement>>;
14
10
 
15
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"mappings":";;;AAgBA,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,4BAAsB,SAAQ,iBAAiB;IAC7C,YAAY,CAAC,EAAE,MAAM,SAAS,CAAC,WAAW,CAAC,CAAC;CAC7C;AAED,OAAA,MAAM,0FA2CJ,CAAC;AAWH,oCAA8B,SAAQ,iBAAiB;IACrD,SAAS,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAChC;AAED,OAAA,MAAM,0GAOL,CAAC;AAMF,OAAA,MAAM,wFAAa,CAAC","sources":["packages/react/portal/src/packages/react/portal/src/Portal.tsx","packages/react/portal/src/packages/react/portal/src/index.ts","packages/react/portal/src/index.ts"],"sourcesContent":[null,null,"export * from './Portal';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
1
+ {"mappings":";;;AAaA,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,4BAAsB,SAAQ,iBAAiB;IAC7C,SAAS,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAChC;AAED,OAAA,MAAM,0FAKJ,CAAC;AAMH,OAAA,MAAM,wFAAa,CAAC","sources":["packages/react/portal/src/packages/react/portal/src/Portal.tsx","packages/react/portal/src/packages/react/portal/src/index.ts","packages/react/portal/src/index.ts"],"sourcesContent":[null,null,"export {\n Portal,\n //\n Root,\n} from './Portal';\nexport type { PortalProps } from './Portal';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
package/dist/index.js CHANGED
@@ -1,96 +1,37 @@
1
1
  var $amzHf$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
2
2
  var $amzHf$react = require("react");
3
3
  var $amzHf$reactdom = require("react-dom");
4
- var $amzHf$radixuireactuselayouteffect = require("@radix-ui/react-use-layout-effect");
5
4
  var $amzHf$radixuireactprimitive = require("@radix-ui/react-primitive");
6
5
 
7
- function $parcel$exportWildcard(dest, source) {
8
- Object.keys(source).forEach(function(key) {
9
- if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
10
- return;
11
- }
12
-
13
- Object.defineProperty(dest, key, {
14
- enumerable: true,
15
- get: function get() {
16
- return source[key];
17
- }
18
- });
19
- });
20
-
21
- return dest;
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
22
8
  }
23
9
  function $parcel$interopDefault(a) {
24
10
  return a && a.__esModule ? a.default : a;
25
11
  }
26
- function $parcel$export(e, n, v, s) {
27
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
28
- }
29
- var $913a70b877676c16$exports = {};
30
-
31
- $parcel$export($913a70b877676c16$exports, "Portal", () => $913a70b877676c16$export$602eac185826482c);
32
- $parcel$export($913a70b877676c16$exports, "UnstablePortal", () => $913a70b877676c16$export$aa829b6eed785496);
33
- $parcel$export($913a70b877676c16$exports, "Root", () => $913a70b877676c16$export$be92b6f5f03c0fe9);
34
12
 
13
+ $parcel$export(module.exports, "Portal", () => $913a70b877676c16$export$602eac185826482c);
14
+ $parcel$export(module.exports, "Root", () => $913a70b877676c16$export$be92b6f5f03c0fe9);
35
15
 
36
16
 
37
17
 
38
18
 
39
- const $913a70b877676c16$var$MAX_Z_INDEX = 2147483647;
40
19
  /* -------------------------------------------------------------------------------------------------
41
20
  * Portal
42
21
  * -----------------------------------------------------------------------------------------------*/ const $913a70b877676c16$var$PORTAL_NAME = 'Portal';
43
22
  const $913a70b877676c16$export$602eac185826482c = /*#__PURE__*/ $amzHf$react.forwardRef((props, forwardedRef)=>{
44
- var _containerRef$current, _globalThis$document;
45
- const { containerRef: containerRef , style: style , ...portalProps } = props;
46
- const hostElement = (_containerRef$current = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) !== null && _containerRef$current !== void 0 ? _containerRef$current : globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body;
47
- const [, forceUpdate] = $amzHf$react.useState({});
48
- /**
49
- * containerRef.current won't be set on first render, so we force a re-render.
50
- * Because we do this in `useLayoutEffect`, we still avoid a flash.
51
- */ $amzHf$radixuireactuselayouteffect.useLayoutEffect(()=>{
52
- forceUpdate({});
53
- }, []);
54
- if (hostElement) return /*#__PURE__*/ ($parcel$interopDefault($amzHf$reactdom)).createPortal(/*#__PURE__*/ $amzHf$react.createElement($amzHf$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($amzHf$babelruntimehelpersextends))({
55
- "data-radix-portal": ""
56
- }, portalProps, {
57
- ref: forwardedRef,
58
- style: /**
59
- * If the Portal is injected in `body`, we assume we want whatever is portalled
60
- * to appear on top of everything. Ideally this would be handled by making sure the
61
- * app root creates a new stacking context, however this is quite hard to automate.
62
- * For this reason, we have opted for setting the max z-index on the portal itself.
63
- */ hostElement === document.body ? {
64
- position: 'absolute',
65
- top: 0,
66
- left: 0,
67
- zIndex: $913a70b877676c16$var$MAX_Z_INDEX,
68
- ...style
69
- } : undefined
70
- })), hostElement);
71
- // bail out of ssr
72
- return null;
73
- });
74
- /*#__PURE__*/ Object.assign($913a70b877676c16$export$602eac185826482c, {
75
- displayName: $913a70b877676c16$var$PORTAL_NAME
76
- });
77
- /* -------------------------------------------------------------------------------------------------
78
- * UnstablePortal
79
- * -----------------------------------------------------------------------------------------------*/ const $913a70b877676c16$var$UNSTABLE_PORTAL_NAME = 'Portal';
80
- const $913a70b877676c16$export$aa829b6eed785496 = /*#__PURE__*/ $amzHf$react.forwardRef((props, forwardedRef)=>{
81
- var _globalThis$document2;
82
- const { container: container = globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document2 = globalThis.document) === null || _globalThis$document2 === void 0 ? void 0 : _globalThis$document2.body , ...portalProps } = props;
23
+ var _globalThis$document;
24
+ const { container: container = globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body , ...portalProps } = props;
83
25
  return container ? /*#__PURE__*/ ($parcel$interopDefault($amzHf$reactdom)).createPortal(/*#__PURE__*/ $amzHf$react.createElement($amzHf$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($amzHf$babelruntimehelpersextends))({}, portalProps, {
84
26
  ref: forwardedRef
85
27
  })), container) : null;
86
28
  });
87
- /*#__PURE__*/ Object.assign($913a70b877676c16$export$aa829b6eed785496, {
88
- displayName: $913a70b877676c16$var$UNSTABLE_PORTAL_NAME
29
+ /*#__PURE__*/ Object.assign($913a70b877676c16$export$602eac185826482c, {
30
+ displayName: $913a70b877676c16$var$PORTAL_NAME
89
31
  });
90
32
  /* -----------------------------------------------------------------------------------------------*/ const $913a70b877676c16$export$be92b6f5f03c0fe9 = $913a70b877676c16$export$602eac185826482c;
91
33
 
92
34
 
93
- $parcel$exportWildcard(module.exports, $913a70b877676c16$exports);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AAGH,aAAA,CAAA,MAAA,CAAA,MAAA,CAAA,yCAAA,EAAA;IAAA,WAAA,EAAA,0CAAA;CAAA,CAAA,CAAA;AAEA,oGAAA,CAEA,MAAMC,yCAAI,GAAGvB,yCAAb,AAAA;;AD5FA","sources":["packages/react/portal/src/index.ts","packages/react/portal/src/Portal.tsx"],"sourcesContent":["export * from './Portal';\n","import * as React from 'react';\nimport ReactDOM from 'react-dom';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\nconst MAX_Z_INDEX = 2147483647;\n\n/* -------------------------------------------------------------------------------------------------\n * Portal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'Portal';\n\ntype PortalElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface PortalProps extends PrimitiveDivProps {\n containerRef?: React.RefObject<HTMLElement>;\n}\n\nconst Portal = React.forwardRef<PortalElement, PortalProps>((props, forwardedRef) => {\n const { containerRef, style, ...portalProps } = props;\n const hostElement = containerRef?.current ?? globalThis?.document?.body;\n const [, forceUpdate] = React.useState({});\n\n /**\n * containerRef.current won't be set on first render, so we force a re-render.\n * Because we do this in `useLayoutEffect`, we still avoid a flash.\n */\n useLayoutEffect(() => {\n forceUpdate({});\n }, []);\n\n if (hostElement) {\n return ReactDOM.createPortal(\n <Primitive.div\n data-radix-portal=\"\"\n {...portalProps}\n ref={forwardedRef}\n style={\n /**\n * If the Portal is injected in `body`, we assume we want whatever is portalled\n * to appear on top of everything. Ideally this would be handled by making sure the\n * app root creates a new stacking context, however this is quite hard to automate.\n * For this reason, we have opted for setting the max z-index on the portal itself.\n */\n hostElement === document.body\n ? {\n position: 'absolute',\n top: 0,\n left: 0,\n zIndex: MAX_Z_INDEX,\n ...style,\n }\n : undefined\n }\n />,\n hostElement\n );\n }\n\n // bail out of ssr\n return null;\n});\n\nPortal.displayName = PORTAL_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * UnstablePortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst UNSTABLE_PORTAL_NAME = 'Portal';\n\ntype UnstablePortalElement = React.ElementRef<typeof Primitive.div>;\ninterface UnstablePortalProps extends PrimitiveDivProps {\n container?: HTMLElement | null;\n}\n\nconst UnstablePortal = React.forwardRef<UnstablePortalElement, UnstablePortalProps>(\n (props, forwardedRef) => {\n const { container = globalThis?.document?.body, ...portalProps } = props;\n return container\n ? ReactDOM.createPortal(<Primitive.div {...portalProps} ref={forwardedRef} />, container)\n : null;\n }\n);\n\nUnstablePortal.displayName = UNSTABLE_PORTAL_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = Portal;\n\nexport {\n Portal,\n UnstablePortal,\n //\n Root,\n};\nexport type { PortalProps, UnstablePortalProps };\n"],"names":["React","ReactDOM","useLayoutEffect","Primitive","MAX_Z_INDEX","PORTAL_NAME","Portal","forwardRef","props","forwardedRef","containerRef","style","portalProps","hostElement","current","globalThis","document","body","forceUpdate","useState","createPortal","position","top","left","zIndex","undefined","UNSTABLE_PORTAL_NAME","UnstablePortal","container","Root"],"version":3,"file":"index.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;A;;;;ACMA;;oGAEA,CAEA,MAAMK,iCAAW,GAAG,QAApB,AAAA;AAQA,MAAML,yCAAM,GAAA,aAAGE,CAAAA,uBAAA,CAA6C,CAACK,KAAD,EAAQC,YAAR,GAAyB;IAAA,IAAA,oBAAA,AAAA;IACnF,MAAM,aAAEC,SAAS,GAAGC,UAAH,KAAA,IAAA,IAAGA,UAAH,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,AAAA,CAAA,oBAAA,GAAGA,UAAU,CAAEC,QAAf,CAAA,KAAA,IAAA,IAAA,oBAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAG,oBAAA,CAAsBC,IAApC,GAA0C,GAAGC,WAAH,EAA1C,GAA6DN,KAAnE,AAAM;IACN,OAAOE,SAAS,GAAA,aACZN,CAAAA,yCAAQ,CAACW,YAAT,CAAA,aAAsB,CAAA,0BAAA,CAAC,sCAAD,CAAW,GAAX,EAAA,2DAAA,CAAA,EAAA,EAAmBD,WAAnB,EAD1B;QAC0D,GAAG,EAAEL,YAAL;KAAhC,CAAA,CAAtB,EAA6EC,SAA7E,CADY,GAEZ,IAFJ,CAC0B;CAHb,CAAf,AAKC;AAED,aAAA,CAAA,MAAA,CAAA,MAAA,CAAA,yCAAA,EAAA;IAAA,WAAA,EAAA,iCAAA;CAAA,CAAA,CAAA;AAEA,oGAAA,CAEA,MAAMR,yCAAI,GAAGD,yCAAb,AAAA;;AD7BA","sources":["packages/react/portal/src/index.ts","packages/react/portal/src/Portal.tsx"],"sourcesContent":["export {\n Portal,\n //\n Root,\n} from './Portal';\nexport type { PortalProps } from './Portal';\n","import * as React from 'react';\nimport ReactDOM from 'react-dom';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * Portal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'Portal';\n\ntype PortalElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface PortalProps extends PrimitiveDivProps {\n container?: HTMLElement | null;\n}\n\nconst Portal = React.forwardRef<PortalElement, PortalProps>((props, forwardedRef) => {\n const { container = globalThis?.document?.body, ...portalProps } = props;\n return container\n ? ReactDOM.createPortal(<Primitive.div {...portalProps} ref={forwardedRef} />, container)\n : null;\n});\n\nPortal.displayName = PORTAL_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = Portal;\n\nexport {\n Portal,\n //\n Root,\n};\nexport type { PortalProps };\n"],"names":["Portal","Root","React","ReactDOM","Primitive","PORTAL_NAME","forwardRef","props","forwardedRef","container","globalThis","document","body","portalProps","createPortal"],"version":3,"file":"index.js.map"}
@@ -1,77 +1,29 @@
1
1
  import $7SXl2$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
2
- import {forwardRef as $7SXl2$forwardRef, useState as $7SXl2$useState, createElement as $7SXl2$createElement} from "react";
2
+ import {forwardRef as $7SXl2$forwardRef, createElement as $7SXl2$createElement} from "react";
3
3
  import $7SXl2$reactdom from "react-dom";
4
- import {useLayoutEffect as $7SXl2$useLayoutEffect} from "@radix-ui/react-use-layout-effect";
5
4
  import {Primitive as $7SXl2$Primitive} from "@radix-ui/react-primitive";
6
5
 
7
- function $parcel$export(e, n, v, s) {
8
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
- }
10
- var $f1701beae083dbae$exports = {};
11
6
 
12
- $parcel$export($f1701beae083dbae$exports, "Portal", () => $f1701beae083dbae$export$602eac185826482c);
13
- $parcel$export($f1701beae083dbae$exports, "UnstablePortal", () => $f1701beae083dbae$export$aa829b6eed785496);
14
- $parcel$export($f1701beae083dbae$exports, "Root", () => $f1701beae083dbae$export$be92b6f5f03c0fe9);
15
7
 
16
8
 
17
9
 
18
-
19
-
20
- const $f1701beae083dbae$var$MAX_Z_INDEX = 2147483647;
21
10
  /* -------------------------------------------------------------------------------------------------
22
11
  * Portal
23
12
  * -----------------------------------------------------------------------------------------------*/ const $f1701beae083dbae$var$PORTAL_NAME = 'Portal';
24
13
  const $f1701beae083dbae$export$602eac185826482c = /*#__PURE__*/ $7SXl2$forwardRef((props, forwardedRef)=>{
25
- var _containerRef$current, _globalThis$document;
26
- const { containerRef: containerRef , style: style , ...portalProps } = props;
27
- const hostElement = (_containerRef$current = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) !== null && _containerRef$current !== void 0 ? _containerRef$current : globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body;
28
- const [, forceUpdate] = $7SXl2$useState({});
29
- /**
30
- * containerRef.current won't be set on first render, so we force a re-render.
31
- * Because we do this in `useLayoutEffect`, we still avoid a flash.
32
- */ $7SXl2$useLayoutEffect(()=>{
33
- forceUpdate({});
34
- }, []);
35
- if (hostElement) return /*#__PURE__*/ $7SXl2$reactdom.createPortal(/*#__PURE__*/ $7SXl2$createElement($7SXl2$Primitive.div, $7SXl2$babelruntimehelpersesmextends({
36
- "data-radix-portal": ""
37
- }, portalProps, {
38
- ref: forwardedRef,
39
- style: /**
40
- * If the Portal is injected in `body`, we assume we want whatever is portalled
41
- * to appear on top of everything. Ideally this would be handled by making sure the
42
- * app root creates a new stacking context, however this is quite hard to automate.
43
- * For this reason, we have opted for setting the max z-index on the portal itself.
44
- */ hostElement === document.body ? {
45
- position: 'absolute',
46
- top: 0,
47
- left: 0,
48
- zIndex: $f1701beae083dbae$var$MAX_Z_INDEX,
49
- ...style
50
- } : undefined
51
- })), hostElement);
52
- // bail out of ssr
53
- return null;
54
- });
55
- /*#__PURE__*/ Object.assign($f1701beae083dbae$export$602eac185826482c, {
56
- displayName: $f1701beae083dbae$var$PORTAL_NAME
57
- });
58
- /* -------------------------------------------------------------------------------------------------
59
- * UnstablePortal
60
- * -----------------------------------------------------------------------------------------------*/ const $f1701beae083dbae$var$UNSTABLE_PORTAL_NAME = 'Portal';
61
- const $f1701beae083dbae$export$aa829b6eed785496 = /*#__PURE__*/ $7SXl2$forwardRef((props, forwardedRef)=>{
62
- var _globalThis$document2;
63
- const { container: container = globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document2 = globalThis.document) === null || _globalThis$document2 === void 0 ? void 0 : _globalThis$document2.body , ...portalProps } = props;
14
+ var _globalThis$document;
15
+ const { container: container = globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body , ...portalProps } = props;
64
16
  return container ? /*#__PURE__*/ $7SXl2$reactdom.createPortal(/*#__PURE__*/ $7SXl2$createElement($7SXl2$Primitive.div, $7SXl2$babelruntimehelpersesmextends({}, portalProps, {
65
17
  ref: forwardedRef
66
18
  })), container) : null;
67
19
  });
68
- /*#__PURE__*/ Object.assign($f1701beae083dbae$export$aa829b6eed785496, {
69
- displayName: $f1701beae083dbae$var$UNSTABLE_PORTAL_NAME
20
+ /*#__PURE__*/ Object.assign($f1701beae083dbae$export$602eac185826482c, {
21
+ displayName: $f1701beae083dbae$var$PORTAL_NAME
70
22
  });
71
23
  /* -----------------------------------------------------------------------------------------------*/ const $f1701beae083dbae$export$be92b6f5f03c0fe9 = $f1701beae083dbae$export$602eac185826482c;
72
24
 
73
25
 
74
26
 
75
27
 
76
- export {$f1701beae083dbae$export$602eac185826482c as Portal, $f1701beae083dbae$export$aa829b6eed785496 as UnstablePortal, $f1701beae083dbae$export$be92b6f5f03c0fe9 as Root};
28
+ export {$f1701beae083dbae$export$602eac185826482c as Portal, $f1701beae083dbae$export$be92b6f5f03c0fe9 as Root};
77
29
  //# sourceMappingURL=index.module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;A;;;;;ACOA,MAAMI,iCAAW,GAAG,UAApB,AAAA;AAEA;;oGAEA,CAEA,MAAMC,iCAAW,GAAG,QAApB,AAAA;AAQA,MAAMC,yCAAM,GAAA,aAAGN,CAAAA,iBAAA,CAA6C,CAACQ,KAAD,EAAQC,YAAR,GAAyB;IAAA,IAAA,qBAAA,EAAA,oBAAA,AAAA;IACnF,MAAM,E,cAAEC,YAAF,CAAA,E,OAAgBC,KAAhB,CAAA,EAAuB,GAAGC,WAAH,EAAvB,GAA0CJ,KAAhD,AAAM;IACN,MAAMK,WAAW,GAAA,AAAA,CAAA,qBAAA,GAAGH,YAAH,KAAA,IAAA,IAAGA,YAAH,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAGA,YAAY,CAAEI,OAAjB,CAAA,KAAA,IAAA,IAAA,qBAAA,KAAA,KAAA,CAAA,GAAA,qBAAA,GAA4BC,UAA5B,KAAA,IAAA,IAA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AAA,IAAA,IAAGA,UAAH,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,AAAA,CAAA,qBAAA,GAAGA,UAAU,CAAEC,QAAf,CAAA,KAAA,IAAA,IAAA,qBAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAG,qBAAA,CAAsBC,IAApC,GAA0C,GAAGL,WAAH,EAA1C,GAA6DJ,KAAnE,AAAM;IACN,OAAOoB,SAAS,GAAA,aACZ3B,CAAAA,eAAQ,CAACmB,YAAT,CAAA,aAAsB,CAAA,oBAAA,CAAC,gBAAD,CAAW,GAAX,EAAA,oCAAA,CAAA,EAAA,EAAmBR,WAAnB,EAD1B;QAC0D,GAAG,EAAEH,YAAL;KAAhC,CAAA,CAAtB,EAA6EmB,SAA7E,CADY,GAEZ,IAFJ,CAC0B;CAJP,CAAvB,AAMG;AAGH,aAAA,CAAA,MAAA,CAAA,MAAA,CAAA,yCAAA,EAAA;IAAA,WAAA,EAAA,0CAAA;CAAA,CAAA,CAAA;AAEA,oGAAA,CAEA,MAAMC,yCAAI,GAAGvB,yCAAb,AAAA;;AD5FA","sources":["packages/react/portal/src/index.ts","packages/react/portal/src/Portal.tsx"],"sourcesContent":["export * from './Portal';\n","import * as React from 'react';\nimport ReactDOM from 'react-dom';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\nconst MAX_Z_INDEX = 2147483647;\n\n/* -------------------------------------------------------------------------------------------------\n * Portal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'Portal';\n\ntype PortalElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface PortalProps extends PrimitiveDivProps {\n containerRef?: React.RefObject<HTMLElement>;\n}\n\nconst Portal = React.forwardRef<PortalElement, PortalProps>((props, forwardedRef) => {\n const { containerRef, style, ...portalProps } = props;\n const hostElement = containerRef?.current ?? globalThis?.document?.body;\n const [, forceUpdate] = React.useState({});\n\n /**\n * containerRef.current won't be set on first render, so we force a re-render.\n * Because we do this in `useLayoutEffect`, we still avoid a flash.\n */\n useLayoutEffect(() => {\n forceUpdate({});\n }, []);\n\n if (hostElement) {\n return ReactDOM.createPortal(\n <Primitive.div\n data-radix-portal=\"\"\n {...portalProps}\n ref={forwardedRef}\n style={\n /**\n * If the Portal is injected in `body`, we assume we want whatever is portalled\n * to appear on top of everything. Ideally this would be handled by making sure the\n * app root creates a new stacking context, however this is quite hard to automate.\n * For this reason, we have opted for setting the max z-index on the portal itself.\n */\n hostElement === document.body\n ? {\n position: 'absolute',\n top: 0,\n left: 0,\n zIndex: MAX_Z_INDEX,\n ...style,\n }\n : undefined\n }\n />,\n hostElement\n );\n }\n\n // bail out of ssr\n return null;\n});\n\nPortal.displayName = PORTAL_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * UnstablePortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst UNSTABLE_PORTAL_NAME = 'Portal';\n\ntype UnstablePortalElement = React.ElementRef<typeof Primitive.div>;\ninterface UnstablePortalProps extends PrimitiveDivProps {\n container?: HTMLElement | null;\n}\n\nconst UnstablePortal = React.forwardRef<UnstablePortalElement, UnstablePortalProps>(\n (props, forwardedRef) => {\n const { container = globalThis?.document?.body, ...portalProps } = props;\n return container\n ? ReactDOM.createPortal(<Primitive.div {...portalProps} ref={forwardedRef} />, container)\n : null;\n }\n);\n\nUnstablePortal.displayName = UNSTABLE_PORTAL_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = Portal;\n\nexport {\n Portal,\n UnstablePortal,\n //\n Root,\n};\nexport type { PortalProps, UnstablePortalProps };\n"],"names":["React","ReactDOM","useLayoutEffect","Primitive","MAX_Z_INDEX","PORTAL_NAME","Portal","forwardRef","props","forwardedRef","containerRef","style","portalProps","hostElement","current","globalThis","document","body","forceUpdate","useState","createPortal","position","top","left","zIndex","undefined","UNSTABLE_PORTAL_NAME","UnstablePortal","container","Root"],"version":3,"file":"index.module.js.map"}
1
+ {"mappings":";;;;;A;;;;ACMA;;oGAEA,CAEA,MAAMK,iCAAW,GAAG,QAApB,AAAA;AAQA,MAAML,yCAAM,GAAA,aAAGE,CAAAA,iBAAA,CAA6C,CAACK,KAAD,EAAQC,YAAR,GAAyB;IAAA,IAAA,oBAAA,AAAA;IACnF,MAAM,aAAEC,SAAS,GAAGC,UAAH,KAAA,IAAA,IAAGA,UAAH,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,AAAA,CAAA,oBAAA,GAAGA,UAAU,CAAEC,QAAf,CAAA,KAAA,IAAA,IAAA,oBAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAG,oBAAA,CAAsBC,IAApC,GAA0C,GAAGC,WAAH,EAA1C,GAA6DN,KAAnE,AAAM;IACN,OAAOE,SAAS,GAAA,aACZN,CAAAA,eAAQ,CAACW,YAAT,CAAA,aAAsB,CAAA,oBAAA,CAAC,gBAAD,CAAW,GAAX,EAAA,oCAAA,CAAA,EAAA,EAAmBD,WAAnB,EAD1B;QAC0D,GAAG,EAAEL,YAAL;KAAhC,CAAA,CAAtB,EAA6EC,SAA7E,CADY,GAEZ,IAFJ,CAC0B;CAHb,CAAf,AAKC;AAED,aAAA,CAAA,MAAA,CAAA,MAAA,CAAA,yCAAA,EAAA;IAAA,WAAA,EAAA,iCAAA;CAAA,CAAA,CAAA;AAEA,oGAAA,CAEA,MAAMR,yCAAI,GAAGD,yCAAb,AAAA;;AD7BA","sources":["packages/react/portal/src/index.ts","packages/react/portal/src/Portal.tsx"],"sourcesContent":["export {\n Portal,\n //\n Root,\n} from './Portal';\nexport type { PortalProps } from './Portal';\n","import * as React from 'react';\nimport ReactDOM from 'react-dom';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * Portal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'Portal';\n\ntype PortalElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface PortalProps extends PrimitiveDivProps {\n container?: HTMLElement | null;\n}\n\nconst Portal = React.forwardRef<PortalElement, PortalProps>((props, forwardedRef) => {\n const { container = globalThis?.document?.body, ...portalProps } = props;\n return container\n ? ReactDOM.createPortal(<Primitive.div {...portalProps} ref={forwardedRef} />, container)\n : null;\n});\n\nPortal.displayName = PORTAL_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = Portal;\n\nexport {\n Portal,\n //\n Root,\n};\nexport type { PortalProps };\n"],"names":["Portal","Root","React","ReactDOM","Primitive","PORTAL_NAME","forwardRef","props","forwardedRef","container","globalThis","document","body","portalProps","createPortal"],"version":3,"file":"index.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-portal",
3
- "version": "0.1.5-rc.8",
3
+ "version": "1.0.0",
4
4
  "license": "MIT",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -17,8 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@babel/runtime": "^7.13.10",
20
- "@radix-ui/react-primitive": "0.1.5-rc.8",
21
- "@radix-ui/react-use-layout-effect": "0.1.1-rc.8"
20
+ "@radix-ui/react-primitive": "1.0.0"
22
21
  },
23
22
  "peerDependencies": {
24
23
  "react": "^16.8 || ^17.0 || ^18.0",
@@ -31,6 +30,5 @@
31
30
  },
32
31
  "bugs": {
33
32
  "url": "https://github.com/radix-ui/primitives/issues"
34
- },
35
- "stableVersion": "0.1.4"
33
+ }
36
34
  }