@heartlandone/vega-react 1.26.0 → 1.27.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.
@@ -5,6 +5,7 @@ export declare const VegaAppFooter: import("react").ForwardRefExoticComponent<JS
5
5
  export declare const VegaAppHeaderButton: import("react").ForwardRefExoticComponent<JSX.VegaAppHeaderButton & Omit<import("react").HTMLAttributes<HTMLVegaAppHeaderButtonElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLVegaAppHeaderButtonElement>>;
6
6
  export declare const VegaBadge: import("react").ForwardRefExoticComponent<JSX.VegaBadge & Omit<import("react").HTMLAttributes<HTMLVegaBadgeElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLVegaBadgeElement>>;
7
7
  export declare const VegaBanner: import("react").ForwardRefExoticComponent<JSX.VegaBanner & Omit<import("react").HTMLAttributes<HTMLVegaBannerElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLVegaBannerElement>>;
8
+ export declare const VegaBox: import("react").ForwardRefExoticComponent<JSX.VegaBox & Omit<import("react").HTMLAttributes<HTMLVegaBoxElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLVegaBoxElement>>;
8
9
  export declare const VegaButton: import("react").ForwardRefExoticComponent<JSX.VegaButton & Omit<import("react").HTMLAttributes<HTMLVegaButtonElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLVegaButtonElement>>;
9
10
  export declare const VegaButtonCircle: import("react").ForwardRefExoticComponent<JSX.VegaButtonCircle & Omit<import("react").HTMLAttributes<HTMLVegaButtonCircleElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLVegaButtonCircleElement>>;
10
11
  export declare const VegaButtonLink: import("react").ForwardRefExoticComponent<JSX.VegaButtonLink & Omit<import("react").HTMLAttributes<HTMLVegaButtonLinkElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLVegaButtonLinkElement>>;
@@ -9,6 +9,7 @@ export const VegaAppFooter = /*@__PURE__*/ createReactComponent('vega-app-footer
9
9
  export const VegaAppHeaderButton = /*@__PURE__*/ createReactComponent('vega-app-header-button');
10
10
  export const VegaBadge = /*@__PURE__*/ createReactComponent('vega-badge');
11
11
  export const VegaBanner = /*@__PURE__*/ createReactComponent('vega-banner');
12
+ export const VegaBox = /*@__PURE__*/ createReactComponent('vega-box');
12
13
  export const VegaButton = /*@__PURE__*/ createReactComponent('vega-button');
13
14
  export const VegaButtonCircle = /*@__PURE__*/ createReactComponent('vega-button-circle');
14
15
  export const VegaButtonLink = /*@__PURE__*/ createReactComponent('vega-button-link');
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import React, { createElement } from 'react';
13
13
  import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs, } from './utils';
14
+ import { FeatureFlag } from '@heartlandone/vega';
14
15
  export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
15
16
  if (defineCustomElement !== undefined) {
16
17
  defineCustomElement();
@@ -22,9 +23,19 @@ export const createReactComponent = (tagName, ReactComponentContext, manipulateP
22
23
  this.setComponentElRef = (element) => {
23
24
  this.componentEl = element;
24
25
  };
26
+ /**
27
+ * While VEGA components use some keyword like `widnow` which only for browser environment, the SSR will not work as expect.
28
+ * To skip compare for SSR and CSR in Hydation we use same temporary dom. that will avoid Hydation failed and emit error messages.
29
+ * The `canRender` state is work for this, while it false we return the temporary dom for both SSR and CSR to skip Hydation check,
30
+ * while component did mount, we set it as true and then we can realy render the component.
31
+ */
32
+ this.state = { canRender: false };
25
33
  }
26
34
  componentDidMount() {
27
35
  this.componentDidUpdate(this.props);
36
+ if (FeatureFlag.isEnabled('VEGA_REACT.PREVENT_SSR')) {
37
+ this.setState({ canRender: true });
38
+ }
28
39
  }
29
40
  componentDidUpdate(prevProps) {
30
41
  attachProps(this.componentEl, this.props, prevProps);
@@ -60,7 +71,7 @@ export const createReactComponent = (tagName, ReactComponentContext, manipulateP
60
71
  * React.createElement causes all elements to be rendered
61
72
  * as <tagname> instead of the actual Web Component.
62
73
  */
63
- return createElement(tagName, newProps, children);
74
+ return (!FeatureFlag.isEnabled('VEGA_REACT.PREVENT_SSR') || this.state.canRender) ? createElement(tagName, newProps, children) : React.createElement(React.Fragment, null);
64
75
  }
65
76
  static get displayName() {
66
77
  return displayName;
@@ -24,11 +24,13 @@ export const attachProps = (node, newProps, oldProps = {}) => {
24
24
  }
25
25
  }
26
26
  else {
27
- node[name] = newProps[name];
28
- const propType = typeof newProps[name];
29
- if (propType === 'string') {
30
- node.setAttribute(camelToDashCase(name), newProps[name]);
31
- }
27
+ node.componentOnReady().then(() => {
28
+ node[name] = newProps[name];
29
+ const propType = typeof newProps[name];
30
+ if (propType === 'string') {
31
+ node.setAttribute(camelToDashCase(name), newProps[name]);
32
+ }
33
+ });
32
34
  }
33
35
  });
34
36
  }
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@heartlandone/vega-react",
3
3
  "sideEffects": false,
4
- "version": "1.26.0",
4
+ "version": "1.27.0",
5
5
  "description": "React specific wrapper for @heartlandone/vega",
6
6
  "scripts": {
7
+ "stencil-postbuild": "node ./src/scripts/stencil-post-build-script.js",
7
8
  "build": "npm run clean && npm run compile",
8
9
  "clean": "rm -rf dist",
9
10
  "compile": "npm run tsc",
@@ -37,7 +38,7 @@
37
38
  "typescript": "^4.0.0"
38
39
  },
39
40
  "dependencies": {
40
- "@heartlandone/vega": "1.26.0"
41
+ "@heartlandone/vega": "1.27.0"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "react": ">=16.7.0",