@mpxjs/webpack-plugin 2.9.69-beta.10 → 2.9.69-beta.11

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,11 @@
1
- import { PortalContext } from './context';
1
+ import { PortalContext, VarContext } from './context';
2
2
  import PortalConsumer from './mpx-portal/portal-consumer';
3
3
  import PortalHost, { portal } from './mpx-portal/portal-host';
4
- const Portal = ({ children }) => {
4
+ const Portal = ({ children, varContext }) => {
5
+ const hasVarContext = varContext && Object.keys(varContext).length;
6
+ if (hasVarContext) {
7
+ children = (<VarContext.Provider value={varContext} key='varContextWrap'>{children}</VarContext.Provider>);
8
+ }
5
9
  return (<PortalContext.Consumer>
6
10
  {(manager) => (<PortalConsumer manager={manager}>{children}</PortalConsumer>)}
7
11
  </PortalContext.Consumer>);
@@ -1,16 +1,18 @@
1
1
  /**
2
2
  * ✔ enable
3
3
  */
4
- import { createElement, Fragment } from 'react';
4
+ import { createElement, Fragment, useContext } from 'react';
5
5
  import Portal from './mpx-portal';
6
6
  import { warn } from '@mpxjs/utils';
7
+ import { VarContext } from './context';
7
8
  const _RootPortal = (props) => {
8
9
  const { children, enable = true } = props;
9
10
  if (props.style) {
10
11
  warn('The root-portal component does not support the style prop.');
11
12
  }
13
+ const varContext = useContext(VarContext);
12
14
  return enable
13
- ? createElement(Portal, null, children)
15
+ ? createElement(Portal, { varContext }, children)
14
16
  : createElement(Fragment, null, children);
15
17
  };
16
18
  _RootPortal.displayName = 'MpxRootPortal';
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react'
2
- import { PortalContext, PortalContextValue } from './context'
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
- const Portal = ({ children }:PortalProps): JSX.Element => {
16
+ const Portal = ({ children, varContext }:PortalProps): JSX.Element => {
17
+ const hasVarContext = varContext && Object.keys(varContext).length
18
+ if (hasVarContext) {
19
+ children = (<VarContext.Provider value={varContext} key='varContextWrap'>{children}</VarContext.Provider>)
20
+ }
16
21
  return (
17
22
  <PortalContext.Consumer>
18
23
  {(manager) => (
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * ✔ enable
3
3
  */
4
- import { ReactNode, createElement, Fragment } from 'react'
4
+ import { ReactNode, createElement, Fragment, useContext } 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,8 +16,9 @@ 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
+ const varContext = useContext(VarContext)
18
20
  return enable
19
- ? createElement(Portal, null, children)
21
+ ? createElement(Portal, { varContext }, children)
20
22
  : createElement(Fragment, null, children)
21
23
  }
22
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.9.69-beta.10",
3
+ "version": "2.9.69-beta.11",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"