@mpxjs/webpack-plugin 2.9.69-beta.10 → 2.9.69-beta.12
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.
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { PortalContext, VarContext } from './context';
|
|
2
3
|
import PortalConsumer from './mpx-portal/portal-consumer';
|
|
3
4
|
import PortalHost, { portal } from './mpx-portal/portal-host';
|
|
4
5
|
const Portal = ({ children }) => {
|
|
6
|
+
const varContext = useContext(VarContext);
|
|
7
|
+
if (varContext) {
|
|
8
|
+
children = (<VarContext.Provider value={varContext} key='varContextWrap'>{children}</VarContext.Provider>);
|
|
9
|
+
}
|
|
5
10
|
return (<PortalContext.Consumer>
|
|
6
11
|
{(manager) => (<PortalConsumer manager={manager}>{children}</PortalConsumer>)}
|
|
7
12
|
</PortalContext.Consumer>);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactNode } from 'react'
|
|
2
|
-
import { PortalContext, PortalContextValue } from './context'
|
|
1
|
+
import { ReactNode, useContext } from 'react'
|
|
2
|
+
import { PortalContext, PortalContextValue, VarContext } from './context'
|
|
3
3
|
import PortalConsumer from './mpx-portal/portal-consumer'
|
|
4
4
|
import PortalHost, { portal } from './mpx-portal/portal-host'
|
|
5
5
|
|
|
@@ -9,10 +9,15 @@ export type PortalProps = {
|
|
|
9
9
|
*/
|
|
10
10
|
children?: ReactNode
|
|
11
11
|
key?: string
|
|
12
|
-
manager?: PortalContextValue
|
|
12
|
+
manager?: PortalContextValue,
|
|
13
|
+
varContext?: Record<string, any> | undefined
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const Portal = ({ children }:PortalProps): JSX.Element => {
|
|
17
|
+
const varContext = useContext(VarContext)
|
|
18
|
+
if (varContext) {
|
|
19
|
+
children = (<VarContext.Provider value={varContext} key='varContextWrap'>{children}</VarContext.Provider>)
|
|
20
|
+
}
|
|
16
21
|
return (
|
|
17
22
|
<PortalContext.Consumer>
|
|
18
23
|
{(manager) => (
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { ReactNode, createElement, Fragment } from 'react'
|
|
5
5
|
import Portal from './mpx-portal'
|
|
6
6
|
import { warn } from '@mpxjs/utils'
|
|
7
|
+
import { VarContext } from './context'
|
|
7
8
|
interface RootPortalProps {
|
|
8
9
|
enable?: boolean
|
|
9
10
|
children: ReactNode
|
|
@@ -15,6 +16,7 @@ const _RootPortal = (props: RootPortalProps) => {
|
|
|
15
16
|
if (props.style) {
|
|
16
17
|
warn('The root-portal component does not support the style prop.')
|
|
17
18
|
}
|
|
19
|
+
|
|
18
20
|
return enable
|
|
19
21
|
? createElement(Portal, null, children)
|
|
20
22
|
: createElement(Fragment, null, children)
|