react-frame-component 5.2.3-alpha.0 → 5.2.4
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.
- package/index.d.ts +30 -1
- package/lib/Frame.js +6 -18
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -1 +1,30 @@
|
|
|
1
|
-
declare module 'react-frame-component'
|
|
1
|
+
declare module 'react-frame-component' {
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
export interface FrameComponentProps
|
|
5
|
+
extends React.IframeHTMLAttributes<HTMLIFrameElement>,
|
|
6
|
+
React.RefAttributes<HTMLIFrameElement> {
|
|
7
|
+
head?: React.ReactNode | undefined;
|
|
8
|
+
mountTarget?: string | undefined;
|
|
9
|
+
initialContent?: string | undefined;
|
|
10
|
+
contentDidMount?: (() => void) | undefined;
|
|
11
|
+
contentDidUpdate?: (() => void) | undefined;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const FrameComponent: React.ForwardRefExoticComponent<FrameComponentProps>;
|
|
16
|
+
export default FrameComponent;
|
|
17
|
+
|
|
18
|
+
export interface FrameContextProps {
|
|
19
|
+
document?: HTMLDocument;
|
|
20
|
+
window?: Window;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const FrameContext: React.Context<FrameContextProps>;
|
|
24
|
+
|
|
25
|
+
export const FrameContextProvider: React.Provider<FrameContextProps>;
|
|
26
|
+
|
|
27
|
+
export const FrameContextConsumer: React.Consumer<FrameContextProps>;
|
|
28
|
+
|
|
29
|
+
export function useFrame(): FrameContextProps;
|
|
30
|
+
}
|
package/lib/Frame.js
CHANGED
|
@@ -60,17 +60,9 @@ var Frame = exports.Frame = function (_Component) {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
_this.handleLoad = function () {
|
|
63
|
-
|
|
64
|
-
// Bail update as some browsers will trigger on both DOMContentLoaded & onLoad ala firefox
|
|
65
|
-
if (!_this.state.iframeLoaded) {
|
|
66
|
-
_this.setState({ iframeLoaded: true });
|
|
67
|
-
}
|
|
63
|
+
_this.setState({ iframeLoaded: true });
|
|
68
64
|
};
|
|
69
65
|
|
|
70
|
-
_this.loadCheck = setInterval(function loadCheckCallback() {
|
|
71
|
-
this.handleLoad();
|
|
72
|
-
}, 500);
|
|
73
|
-
|
|
74
66
|
_this._isMounted = false;
|
|
75
67
|
_this.nodeRef = _react2.default.createRef();
|
|
76
68
|
_this.state = { iframeLoaded: false };
|
|
@@ -83,9 +75,10 @@ var Frame = exports.Frame = function (_Component) {
|
|
|
83
75
|
this._isMounted = true;
|
|
84
76
|
|
|
85
77
|
var doc = this.getDoc();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
78
|
+
if (doc && doc.readyState === 'complete') {
|
|
79
|
+
this.forceUpdate();
|
|
80
|
+
} else {
|
|
81
|
+
this.nodeRef.current.addEventListener('load', this.handleLoad);
|
|
89
82
|
}
|
|
90
83
|
}
|
|
91
84
|
}, {
|
|
@@ -93,7 +86,7 @@ var Frame = exports.Frame = function (_Component) {
|
|
|
93
86
|
value: function componentWillUnmount() {
|
|
94
87
|
this._isMounted = false;
|
|
95
88
|
|
|
96
|
-
this.nodeRef.current.removeEventListener('
|
|
89
|
+
this.nodeRef.current.removeEventListener('load', this.handleLoad);
|
|
97
90
|
}
|
|
98
91
|
}, {
|
|
99
92
|
key: 'getDoc',
|
|
@@ -109,10 +102,6 @@ var Frame = exports.Frame = function (_Component) {
|
|
|
109
102
|
}
|
|
110
103
|
return doc.body.children[0];
|
|
111
104
|
}
|
|
112
|
-
|
|
113
|
-
// In certain situations on a cold cache DOMContentLoaded never gets called
|
|
114
|
-
// fallback to an interval to check if that's the case
|
|
115
|
-
|
|
116
105
|
}, {
|
|
117
106
|
key: 'renderFrameContents',
|
|
118
107
|
value: function renderFrameContents() {
|
|
@@ -164,7 +153,6 @@ var Frame = exports.Frame = function (_Component) {
|
|
|
164
153
|
delete props.contentDidMount;
|
|
165
154
|
delete props.contentDidUpdate;
|
|
166
155
|
delete props.forwardedRef;
|
|
167
|
-
|
|
168
156
|
return _react2.default.createElement(
|
|
169
157
|
'iframe',
|
|
170
158
|
_extends({}, props, { ref: this.setRef, onLoad: this.handleLoad }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-frame-component",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.4",
|
|
4
4
|
"description": "React component to wrap your application or component in an iFrame for encapsulation purposes",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"gh-pages": "^1.1.0",
|
|
63
63
|
"html-webpack-plugin": "^2.28.0",
|
|
64
64
|
"husky": "^0.14.3",
|
|
65
|
-
"karma": "^
|
|
65
|
+
"karma": "^6.3.16",
|
|
66
66
|
"karma-chrome-launcher": "^2.0.0",
|
|
67
67
|
"karma-mocha": "^1.3.0",
|
|
68
68
|
"karma-osx-reporter": "^0.2.1",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"react-dom": "^17.0.1",
|
|
81
81
|
"rimraf": "^2.5.4",
|
|
82
82
|
"sinon": "2.0.0-pre",
|
|
83
|
-
"wallaby-webpack": "^
|
|
83
|
+
"wallaby-webpack": "^3.9.16",
|
|
84
84
|
"webpack": "1.x",
|
|
85
85
|
"webpack-dev-server": "^1.16.3"
|
|
86
86
|
},
|