@radix-ui/react-portal 0.1.4-rc.9 → 0.1.5-rc.10
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.map +1 -1
- package/dist/index.js +95 -1
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +76 -1
- package/dist/index.module.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
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"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,96 @@
|
|
|
1
|
-
var
|
|
1
|
+
var $amzHf$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
|
|
2
|
+
var $amzHf$react = require("react");
|
|
3
|
+
var $amzHf$reactdom = require("react-dom");
|
|
4
|
+
var $amzHf$radixuireactuselayouteffect = require("@radix-ui/react-use-layout-effect");
|
|
5
|
+
var $amzHf$radixuireactprimitive = require("@radix-ui/react-primitive");
|
|
6
|
+
|
|
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;
|
|
22
|
+
}
|
|
23
|
+
function $parcel$interopDefault(a) {
|
|
24
|
+
return a && a.__esModule ? a.default : a;
|
|
25
|
+
}
|
|
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
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
const $913a70b877676c16$var$MAX_Z_INDEX = 2147483647;
|
|
40
|
+
/* -------------------------------------------------------------------------------------------------
|
|
41
|
+
* Portal
|
|
42
|
+
* -----------------------------------------------------------------------------------------------*/ const $913a70b877676c16$var$PORTAL_NAME = 'Portal';
|
|
43
|
+
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;
|
|
83
|
+
return container ? /*#__PURE__*/ ($parcel$interopDefault($amzHf$reactdom)).createPortal(/*#__PURE__*/ $amzHf$react.createElement($amzHf$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($amzHf$babelruntimehelpersextends))({}, portalProps, {
|
|
84
|
+
ref: forwardedRef
|
|
85
|
+
})), container) : null;
|
|
86
|
+
});
|
|
87
|
+
/*#__PURE__*/ Object.assign($913a70b877676c16$export$aa829b6eed785496, {
|
|
88
|
+
displayName: $913a70b877676c16$var$UNSTABLE_PORTAL_NAME
|
|
89
|
+
});
|
|
90
|
+
/* -----------------------------------------------------------------------------------------------*/ const $913a70b877676c16$export$be92b6f5f03c0fe9 = $913a70b877676c16$export$602eac185826482c;
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
$parcel$exportWildcard(module.exports, $913a70b877676c16$exports);
|
|
94
|
+
|
|
95
|
+
|
|
2
96
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;ACOA,MAAMI,iCAAW,GAAG,UAApB,AAAA;AAEA;;oGAEA,CAEA,MAAMC,iCAAW,GAAG,QAApB,AAAA;AAQA,MAAMC,yCAAM,GAAA,aAAGN,CAAAA,uBAAA,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,EAAv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yCAAA,EAAA;IAAA,WAAA,EAAA,iCAAA;CAAA,CAAA,CAAA;AAEA;;oGAEA,CAEA,MAAMa,0CAAoB,GAAG,QAA7B,AAAA;AAOA,MAAMC,yCAAc,GAAA,aAAG3B,CAAAA,uBAAA,CACrB,CAACQ,KAAD,EAAQC,YAAR,GAAyB;IAAA,IAAA,qBAAA,AAAA;IACvB,MAAM,aAAEmB,SAAS,GAAGb,UAAH,KAAA,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,yCAAQ,CAACmB,YAAT,CAAA,aAAsB,CAAA,0BAAA,CAAC,sCAAD,CAAW,GAAX,EAAA,2DAAA,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.js.map"}
|
package/dist/index.module.js
CHANGED
|
@@ -1,2 +1,77 @@
|
|
|
1
|
-
import
|
|
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";
|
|
3
|
+
import $7SXl2$reactdom from "react-dom";
|
|
4
|
+
import {useLayoutEffect as $7SXl2$useLayoutEffect} from "@radix-ui/react-use-layout-effect";
|
|
5
|
+
import {Primitive as $7SXl2$Primitive} from "@radix-ui/react-primitive";
|
|
6
|
+
|
|
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
|
+
|
|
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
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const $f1701beae083dbae$var$MAX_Z_INDEX = 2147483647;
|
|
21
|
+
/* -------------------------------------------------------------------------------------------------
|
|
22
|
+
* Portal
|
|
23
|
+
* -----------------------------------------------------------------------------------------------*/ const $f1701beae083dbae$var$PORTAL_NAME = 'Portal';
|
|
24
|
+
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;
|
|
64
|
+
return container ? /*#__PURE__*/ $7SXl2$reactdom.createPortal(/*#__PURE__*/ $7SXl2$createElement($7SXl2$Primitive.div, $7SXl2$babelruntimehelpersesmextends({}, portalProps, {
|
|
65
|
+
ref: forwardedRef
|
|
66
|
+
})), container) : null;
|
|
67
|
+
});
|
|
68
|
+
/*#__PURE__*/ Object.assign($f1701beae083dbae$export$aa829b6eed785496, {
|
|
69
|
+
displayName: $f1701beae083dbae$var$UNSTABLE_PORTAL_NAME
|
|
70
|
+
});
|
|
71
|
+
/* -----------------------------------------------------------------------------------------------*/ const $f1701beae083dbae$export$be92b6f5f03c0fe9 = $f1701beae083dbae$export$602eac185826482c;
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
export {$f1701beae083dbae$export$602eac185826482c as Portal, $f1701beae083dbae$export$aa829b6eed785496 as UnstablePortal, $f1701beae083dbae$export$be92b6f5f03c0fe9 as Root};
|
|
2
77
|
//# sourceMappingURL=index.module.js.map
|
package/dist/index.module.js.map
CHANGED
|
@@ -1 +1 @@
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AA,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-portal",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5-rc.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime": "^7.13.10",
|
|
20
|
-
"@radix-ui/react-primitive": "0.1.
|
|
21
|
-
"@radix-ui/react-use-layout-effect": "0.1.
|
|
20
|
+
"@radix-ui/react-primitive": "0.1.5-rc.10",
|
|
21
|
+
"@radix-ui/react-use-layout-effect": "0.1.1-rc.10"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"react": "^16.8 || ^17.0",
|
|
25
|
-
"react-dom": "^16.8 || ^17.0"
|
|
24
|
+
"react": "^16.8 || ^17.0 || ^18.0",
|
|
25
|
+
"react-dom": "^16.8 || ^17.0 || ^18.0"
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://radix-ui.com/primitives",
|
|
28
28
|
"repository": {
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"bugs": {
|
|
33
33
|
"url": "https://github.com/radix-ui/primitives/issues"
|
|
34
34
|
},
|
|
35
|
-
"stableVersion": "0.1.
|
|
35
|
+
"stableVersion": "0.1.4"
|
|
36
36
|
}
|