piral-core 0.15.0-alpha.3804 → 0.15.0-alpha.3905

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.
@@ -7,6 +7,7 @@ interface ForeignComponentContainerProps<T> {
7
7
  innerProps: T & BaseComponentProps;
8
8
  }
9
9
  export declare class ForeignComponentContainer<T> extends React.Component<ForeignComponentContainerProps<T>> {
10
+ private locals?;
10
11
  private current?;
11
12
  private previous?;
12
13
  private handler;
@@ -3,6 +3,7 @@ import { isfunc } from 'piral-base';
3
3
  export class ForeignComponentContainer extends React.Component {
4
4
  constructor() {
5
5
  super(...arguments);
6
+ this.locals = {};
6
7
  this.handler = (ev) => {
7
8
  const { innerProps } = this.props;
8
9
  ev.stopPropagation();
@@ -17,7 +18,7 @@ export class ForeignComponentContainer extends React.Component {
17
18
  const { $component, $context, innerProps } = this.props;
18
19
  const { mount } = $component;
19
20
  if (node && isfunc(mount)) {
20
- mount(node, innerProps, $context);
21
+ mount(node, innerProps, $context, this.locals);
21
22
  node.addEventListener('render-html', this.handler, false);
22
23
  }
23
24
  this.previous = node;
@@ -31,7 +32,7 @@ export class ForeignComponentContainer extends React.Component {
31
32
  current && this.componentDidMount();
32
33
  }
33
34
  else if (isfunc(update)) {
34
- update(current, innerProps, $context);
35
+ update(current, innerProps, $context, this.locals);
35
36
  }
36
37
  }
37
38
  componentWillUnmount() {
@@ -39,7 +40,7 @@ export class ForeignComponentContainer extends React.Component {
39
40
  const { $component } = this.props;
40
41
  const { unmount } = $component;
41
42
  if (node && isfunc(unmount)) {
42
- unmount(node);
43
+ unmount(node, this.locals);
43
44
  node.removeEventListener('render-html', this.handler, false);
44
45
  }
45
46
  this.previous = undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"ForeignComponentContainer.js","sourceRoot":"","sources":["../../src/components/ForeignComponentContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MA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,IAAI,CAAC,QAAQ,CAAC;QAC3B,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAClC,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;QAE/B,IAAI,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE;YAC3B,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3B,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;SAC9D;QAED,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,MAAM;QACJ,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACjC,OAAO,+CAAqB,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,GAAI,CAAC;IAC/D,CAAC;CACF"}
@@ -41,20 +41,23 @@ export interface ForeignComponent<TProps> {
41
41
  * @param element The container hosting the element.
42
42
  * @param props The props to transport.
43
43
  * @param ctx The associated context.
44
+ * @param locals The local state of this component instance.
44
45
  */
45
- mount(element: HTMLElement, props: TProps, ctx: ComponentContext): void;
46
+ mount(element: HTMLElement, props: TProps, ctx: ComponentContext, locals: Record<string, any>): void;
46
47
  /**
47
48
  * Called when the component should be updated.
48
49
  * @param element The container hosting the element.
49
50
  * @param props The props to transport.
50
51
  * @param ctx The associated context.
52
+ * @param locals The local state of this component instance.
51
53
  */
52
- update?(element: HTMLElement, props: TProps, ctx: ComponentContext): void;
54
+ update?(element: HTMLElement, props: TProps, ctx: ComponentContext, locals: Record<string, any>): void;
53
55
  /**
54
56
  * Called when a component is unmounted.
55
57
  * @param element The container that was hosting the element.
58
+ * @param locals The local state of this component instance.
56
59
  */
57
- unmount?(element: HTMLElement): void;
60
+ unmount?(element: HTMLElement, locals: Record<string, any>): void;
58
61
  }
59
62
  /**
60
63
  * Possible shapes for a component.
@@ -7,6 +7,7 @@ interface ForeignComponentContainerProps<T> {
7
7
  innerProps: T & BaseComponentProps;
8
8
  }
9
9
  export declare class ForeignComponentContainer<T> extends React.Component<ForeignComponentContainerProps<T>> {
10
+ private locals?;
10
11
  private current?;
11
12
  private previous?;
12
13
  private handler;
@@ -6,6 +6,7 @@ const piral_base_1 = require("piral-base");
6
6
  class ForeignComponentContainer extends React.Component {
7
7
  constructor() {
8
8
  super(...arguments);
9
+ this.locals = {};
9
10
  this.handler = (ev) => {
10
11
  const { innerProps } = this.props;
11
12
  ev.stopPropagation();
@@ -20,7 +21,7 @@ class ForeignComponentContainer extends React.Component {
20
21
  const { $component, $context, innerProps } = this.props;
21
22
  const { mount } = $component;
22
23
  if (node && (0, piral_base_1.isfunc)(mount)) {
23
- mount(node, innerProps, $context);
24
+ mount(node, innerProps, $context, this.locals);
24
25
  node.addEventListener('render-html', this.handler, false);
25
26
  }
26
27
  this.previous = node;
@@ -34,7 +35,7 @@ class ForeignComponentContainer extends React.Component {
34
35
  current && this.componentDidMount();
35
36
  }
36
37
  else if ((0, piral_base_1.isfunc)(update)) {
37
- update(current, innerProps, $context);
38
+ update(current, innerProps, $context, this.locals);
38
39
  }
39
40
  }
40
41
  componentWillUnmount() {
@@ -42,7 +43,7 @@ class ForeignComponentContainer extends React.Component {
42
43
  const { $component } = this.props;
43
44
  const { unmount } = $component;
44
45
  if (node && (0, piral_base_1.isfunc)(unmount)) {
45
- unmount(node);
46
+ unmount(node, this.locals);
46
47
  node.removeEventListener('render-html', this.handler, false);
47
48
  }
48
49
  this.previous = undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"ForeignComponentContainer.js","sourceRoot":"","sources":["../../src/components/ForeignComponentContainer.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2CAAoC;AAWpC,MAAa,yBAA6B,SAAQ,KAAK,CAAC,SAA4C;IAApG;;QAGU,YAAO,GAAG,CAAC,EAAe,EAAE,EAAE;YACpC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,C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AAC,EAAE;YAC3B,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3B,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;SAC9D;QAED,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,MAAM;QACJ,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACjC,OAAO,+CAAqB,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,GAAI,CAAC;IAC/D,CAAC;CACF;AAzDD,8DAyDC"}
@@ -41,20 +41,23 @@ export interface ForeignComponent<TProps> {
41
41
  * @param element The container hosting the element.
42
42
  * @param props The props to transport.
43
43
  * @param ctx The associated context.
44
+ * @param locals The local state of this component instance.
44
45
  */
45
- mount(element: HTMLElement, props: TProps, ctx: ComponentContext): void;
46
+ mount(element: HTMLElement, props: TProps, ctx: ComponentContext, locals: Record<string, any>): void;
46
47
  /**
47
48
  * Called when the component should be updated.
48
49
  * @param element The container hosting the element.
49
50
  * @param props The props to transport.
50
51
  * @param ctx The associated context.
52
+ * @param locals The local state of this component instance.
51
53
  */
52
- update?(element: HTMLElement, props: TProps, ctx: ComponentContext): void;
54
+ update?(element: HTMLElement, props: TProps, ctx: ComponentContext, locals: Record<string, any>): void;
53
55
  /**
54
56
  * Called when a component is unmounted.
55
57
  * @param element The container that was hosting the element.
58
+ * @param locals The local state of this component instance.
56
59
  */
57
- unmount?(element: HTMLElement): void;
60
+ unmount?(element: HTMLElement, locals: Record<string, any>): void;
58
61
  }
59
62
  /**
60
63
  * Possible shapes for a component.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-core",
3
- "version": "0.15.0-alpha.3804",
3
+ "version": "0.15.0-alpha.3905",
4
4
  "description": "The core library for creating a Piral instance.",
5
5
  "keywords": [
6
6
  "portal",
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@dbeining/react-atom": "^4.0.0",
51
- "piral-base": "0.15.0-alpha.3804",
52
- "piral-debug-utils": "0.15.0-alpha.3804"
51
+ "piral-base": "0.15.0-alpha.3905",
52
+ "piral-debug-utils": "0.15.0-alpha.3905"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "react": ">=16.8.0",
@@ -79,5 +79,5 @@
79
79
  "@libre/atom",
80
80
  "@dbeining/react-atom"
81
81
  ],
82
- "gitHead": "a053a21f6195fe292edd35301ea19d5602129c79"
82
+ "gitHead": "533d09963cfd8c901df797958ca386dbae0286e1"
83
83
  }
@@ -11,6 +11,7 @@ interface ForeignComponentContainerProps<T> {
11
11
  }
12
12
 
13
13
  export class ForeignComponentContainer<T> extends React.Component<ForeignComponentContainerProps<T>> {
14
+ private locals?: Record<string, any> = {};
14
15
  private current?: HTMLElement;
15
16
  private previous?: HTMLElement;
16
17
  private handler = (ev: CustomEvent) => {
@@ -29,7 +30,7 @@ export class ForeignComponentContainer<T> extends React.Component<ForeignCompone
29
30
  const { mount } = $component;
30
31
 
31
32
  if (node && isfunc(mount)) {
32
- mount(node, innerProps, $context);
33
+ mount(node, innerProps, $context, this.locals);
33
34
  node.addEventListener('render-html', this.handler, false);
34
35
  }
35
36
 
@@ -45,7 +46,7 @@ export class ForeignComponentContainer<T> extends React.Component<ForeignCompone
45
46
  previous && this.componentWillUnmount();
46
47
  current && this.componentDidMount();
47
48
  } else if (isfunc(update)) {
48
- update(current, innerProps, $context);
49
+ update(current, innerProps, $context, this.locals);
49
50
  }
50
51
  }
51
52
 
@@ -55,7 +56,7 @@ export class ForeignComponentContainer<T> extends React.Component<ForeignCompone
55
56
  const { unmount } = $component;
56
57
 
57
58
  if (node && isfunc(unmount)) {
58
- unmount(node);
59
+ unmount(node, this.locals);
59
60
  node.removeEventListener('render-html', this.handler, false);
60
61
  }
61
62
 
@@ -45,20 +45,23 @@ export interface ForeignComponent<TProps> {
45
45
  * @param element The container hosting the element.
46
46
  * @param props The props to transport.
47
47
  * @param ctx The associated context.
48
+ * @param locals The local state of this component instance.
48
49
  */
49
- mount(element: HTMLElement, props: TProps, ctx: ComponentContext): void;
50
+ mount(element: HTMLElement, props: TProps, ctx: ComponentContext, locals: Record<string, any>): void;
50
51
  /**
51
52
  * Called when the component should be updated.
52
53
  * @param element The container hosting the element.
53
54
  * @param props The props to transport.
54
55
  * @param ctx The associated context.
56
+ * @param locals The local state of this component instance.
55
57
  */
56
- update?(element: HTMLElement, props: TProps, ctx: ComponentContext): void;
58
+ update?(element: HTMLElement, props: TProps, ctx: ComponentContext, locals: Record<string, any>): void;
57
59
  /**
58
60
  * Called when a component is unmounted.
59
61
  * @param element The container that was hosting the element.
62
+ * @param locals The local state of this component instance.
60
63
  */
61
- unmount?(element: HTMLElement): void;
64
+ unmount?(element: HTMLElement, locals: Record<string, any>): void;
62
65
  }
63
66
 
64
67
  /**