@antscorp/antsomi-ui 1.3.5-beta.580 → 1.3.5-beta.582

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.
@@ -18,12 +18,20 @@ import { globalToken } from '@antscorp/antsomi-ui/es/constants';
18
18
  import styled from 'styled-components';
19
19
  const StyledIframe = styled.iframe `
20
20
  border: none;
21
+ opacity: 0;
21
22
  `;
22
23
  export const Iframe = props => {
23
- const { children, className } = props, restProps = __rest(props, ["children", "className"]);
24
+ const { children, className, src, srcDoc } = props, restProps = __rest(props, ["children", "className", "src", "srcDoc"]);
24
25
  // Ref
25
26
  const iframeRef = useRef(null);
26
27
  // Effects
28
+ useEffect(() =>
29
+ // Handle hide iframe until iframe is loaded
30
+ () => {
31
+ if (iframeRef.current) {
32
+ iframeRef.current.style.opacity = '0';
33
+ }
34
+ }, [src, srcDoc]);
27
35
  useEffect(() => {
28
36
  const iframe = iframeRef.current;
29
37
  const handleLoad = () => {
@@ -46,8 +54,9 @@ export const Iframe = props => {
46
54
  }
47
55
  }
48
56
  `;
49
- if (iframeDoc) {
57
+ if (iframeDoc && iframeRef.current) {
50
58
  iframeDoc.head.appendChild(style);
59
+ iframeRef.current.style.opacity = '1';
51
60
  }
52
61
  };
53
62
  if (iframe) {
@@ -59,5 +68,5 @@ export const Iframe = props => {
59
68
  }
60
69
  };
61
70
  }, []);
62
- return (React.createElement(StyledIframe, Object.assign({}, restProps, { className: clsx('antsomi-iframe', className), ref: iframeRef })));
71
+ return (React.createElement(StyledIframe, Object.assign({}, restProps, { src: src, srcDoc: srcDoc, className: clsx('antsomi-iframe', className), ref: iframeRef })));
63
72
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.580",
3
+ "version": "1.3.5-beta.582",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",