@iframe-resizer/react 5.1.3 → 5.2.0-beta.1
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/README.md +1 -1
- package/iframe-resizer.react.d.ts +46 -50
- package/index.cjs.js +88 -2
- package/index.esm.js +86 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,62 +7,58 @@
|
|
|
7
7
|
declare module '@iframe-resizer/react' {
|
|
8
8
|
import * as React from 'react'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface IFrameComponent extends HTMLIFrameElement {
|
|
18
|
-
iFrameResizer: IFrameObject
|
|
19
|
-
}
|
|
10
|
+
export type IFrameObject = {
|
|
11
|
+
moveToAnchor: (anchor: string) => void
|
|
12
|
+
resize: () => void
|
|
13
|
+
sendMessage: (message: string, targetOrigin?: string) => void
|
|
14
|
+
}
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
16
|
+
export interface IFrameComponent extends HTMLIFrameElement {
|
|
17
|
+
iFrameResizer: IFrameObject
|
|
18
|
+
}
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
export type IFrameForwardRef = Omit<IFrameObject, 'close' | 'disconnect'> & {
|
|
21
|
+
getElement: () => IFrameComponent
|
|
22
|
+
getRef: () => any
|
|
23
|
+
}
|
|
30
24
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
checkOrigin?: boolean | string[]
|
|
36
|
-
direction?: 'vertical' | 'horizontal' | 'none'
|
|
37
|
-
forwardRef?: any
|
|
38
|
-
inPageLinks?: boolean
|
|
39
|
-
license: string
|
|
40
|
-
offset?: number
|
|
41
|
-
scrolling?: boolean | 'omit'
|
|
42
|
-
tolerance?: number
|
|
43
|
-
warningTimeout?: number
|
|
44
|
-
}
|
|
25
|
+
export type IframeProps = React.DetailedHTMLProps<
|
|
26
|
+
React.IframeHTMLAttributes<HTMLIFrameElement>,
|
|
27
|
+
HTMLIFrameElement
|
|
28
|
+
>
|
|
45
29
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
30
|
+
export type ResizerOptions = {
|
|
31
|
+
bodyBackground?: string | null
|
|
32
|
+
bodyMargin?: string | number | null
|
|
33
|
+
bodyPadding?: string | number | null
|
|
34
|
+
checkOrigin?: boolean | string[]
|
|
35
|
+
direction?: 'vertical' | 'horizontal' | 'none'
|
|
36
|
+
forwardRef?: any
|
|
37
|
+
inPageLinks?: boolean
|
|
38
|
+
license: string
|
|
39
|
+
offset?: number
|
|
40
|
+
scrolling?: boolean | 'omit'
|
|
41
|
+
tolerance?: number
|
|
42
|
+
warningTimeout?: number
|
|
43
|
+
}
|
|
57
44
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
45
|
+
export type ResizerEvents = {
|
|
46
|
+
onInit?: (iframe: IFrameComponent) => void
|
|
47
|
+
onMessage?: (ev: { iframe: IFrameComponent; message: any }) => void
|
|
48
|
+
onResized?: (ev: {
|
|
49
|
+
iframe: IFrameComponent
|
|
50
|
+
height: number
|
|
51
|
+
width: number
|
|
52
|
+
type: string
|
|
53
|
+
}) => void
|
|
54
|
+
onScroll?: (ev: { x: number; y: number }) => boolean
|
|
61
55
|
}
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
export type IframeResizerProps = Omit<IframeProps, 'scrolling'> &
|
|
58
|
+
ResizerOptions &
|
|
59
|
+
ResizerEvents
|
|
60
|
+
|
|
61
|
+
function IframeResizer(props: IframeResizerProps): React.ReactElement
|
|
66
62
|
|
|
67
|
-
export
|
|
63
|
+
export default IframeResizer
|
|
68
64
|
}
|
package/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @preserve
|
|
3
3
|
*
|
|
4
|
-
* @module iframe-resizer/react 5.1
|
|
4
|
+
* @module iframe-resizer/react 5.2.0-beta.1 (cjs) - 2024-07-02
|
|
5
5
|
*
|
|
6
6
|
* @license GPL-3.0 for non-commercial use only.
|
|
7
7
|
* For commercial use, you must purchase a license from
|
|
@@ -17,4 +17,90 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
'use strict';
|
|
21
|
+
|
|
22
|
+
const _extends = require('@babel/runtime/helpers/extends');
|
|
23
|
+
const _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
24
|
+
const _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
25
|
+
const connectResizer = require('@iframe-resizer/core');
|
|
26
|
+
const React = require('react');
|
|
27
|
+
const warning = require('warning');
|
|
28
|
+
|
|
29
|
+
var _excluded$1 = ["license", "bodyBackground", "bodyMargin", "bodyPadding", "checkOrigin", "direction", "inPageLinks", "offset", "offsetHeight", "offsetWidth", "scrolling", "tolerance", "warningTimeout", "onClosed", "onReady", "onMessage", "onResized"];
|
|
30
|
+
const filterIframeAttribs = (function (props) {
|
|
31
|
+
props.license;
|
|
32
|
+
props.bodyBackground;
|
|
33
|
+
props.bodyMargin;
|
|
34
|
+
props.bodyPadding;
|
|
35
|
+
props.checkOrigin;
|
|
36
|
+
props.direction;
|
|
37
|
+
props.inPageLinks;
|
|
38
|
+
props.offset;
|
|
39
|
+
props.offsetHeight;
|
|
40
|
+
props.offsetWidth;
|
|
41
|
+
props.scrolling;
|
|
42
|
+
props.tolerance;
|
|
43
|
+
props.warningTimeout;
|
|
44
|
+
props.onClosed;
|
|
45
|
+
props.onReady;
|
|
46
|
+
props.onMessage;
|
|
47
|
+
props.onResized;
|
|
48
|
+
var iframeProps = _objectWithoutProperties(props, _excluded$1);
|
|
49
|
+
return iframeProps;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
var _excluded = ["title", "forwardRef"];
|
|
53
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
54
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
55
|
+
function IframeResizer(props) {
|
|
56
|
+
// eslint-disable-next-line react/prop-types
|
|
57
|
+
var title = props.title,
|
|
58
|
+
forwardRef = props.forwardRef,
|
|
59
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
60
|
+
var filteredProps = filterIframeAttribs(rest);
|
|
61
|
+
var iframeRef = React.useRef(null);
|
|
62
|
+
var onClose = function onClose() {
|
|
63
|
+
var _iframeRef$current;
|
|
64
|
+
warning(!iframeRef.current, "[iframe-resizer/react][".concat(iframeRef === null || iframeRef === void 0 || (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : _iframeRef$current.id, "] Close event ignored, to remove the iframe update your React component."));
|
|
65
|
+
return !iframeRef.current; // Allow React to close this
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// This hook is only run once, as once iframe-resizer is bound, it will
|
|
69
|
+
// deal with changes to the element and does not need recalling
|
|
70
|
+
React.useEffect(function () {
|
|
71
|
+
var iframe = iframeRef.current;
|
|
72
|
+
var resizer = connectResizer(_objectSpread(_objectSpread({}, rest), {}, {
|
|
73
|
+
onClose: onClose
|
|
74
|
+
}))(iframe);
|
|
75
|
+
return function () {
|
|
76
|
+
return resizer === null || resizer === void 0 ? void 0 : resizer.disconnect();
|
|
77
|
+
};
|
|
78
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
79
|
+
|
|
80
|
+
React.useImperativeHandle(forwardRef, function () {
|
|
81
|
+
return {
|
|
82
|
+
getRef: function getRef() {
|
|
83
|
+
return iframeRef;
|
|
84
|
+
},
|
|
85
|
+
getElement: function getElement() {
|
|
86
|
+
return iframeRef.current;
|
|
87
|
+
},
|
|
88
|
+
resize: function resize() {
|
|
89
|
+
return iframeRef.current.iframeResizer.resize();
|
|
90
|
+
},
|
|
91
|
+
moveToAnchor: function moveToAnchor(anchor) {
|
|
92
|
+
return iframeRef.current.iframeResizer.moveToAnchor(anchor);
|
|
93
|
+
},
|
|
94
|
+
sendMessage: function sendMessage(message, targetOrigin) {
|
|
95
|
+
iframeRef.current.iframeResizer.sendMessage(message, targetOrigin);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
return /*#__PURE__*/React.createElement("iframe", _extends({
|
|
100
|
+
title: title
|
|
101
|
+
}, filteredProps, {
|
|
102
|
+
ref: iframeRef
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
module.exports = IframeResizer;
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @preserve
|
|
3
3
|
*
|
|
4
|
-
* @module iframe-resizer/react 5.1
|
|
4
|
+
* @module iframe-resizer/react 5.2.0-beta.1 (esm) - 2024-07-02
|
|
5
5
|
*
|
|
6
6
|
* @license GPL-3.0 for non-commercial use only.
|
|
7
7
|
* For commercial use, you must purchase a license from
|
|
@@ -17,4 +17,88 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
import
|
|
20
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
21
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
22
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
23
|
+
import connectResizer from '@iframe-resizer/core';
|
|
24
|
+
import React, { useRef, useEffect, useImperativeHandle } from 'react';
|
|
25
|
+
import warning from 'warning';
|
|
26
|
+
|
|
27
|
+
var _excluded$1 = ["license", "bodyBackground", "bodyMargin", "bodyPadding", "checkOrigin", "direction", "inPageLinks", "offset", "offsetHeight", "offsetWidth", "scrolling", "tolerance", "warningTimeout", "onClosed", "onReady", "onMessage", "onResized"];
|
|
28
|
+
const filterIframeAttribs = (function (props) {
|
|
29
|
+
props.license;
|
|
30
|
+
props.bodyBackground;
|
|
31
|
+
props.bodyMargin;
|
|
32
|
+
props.bodyPadding;
|
|
33
|
+
props.checkOrigin;
|
|
34
|
+
props.direction;
|
|
35
|
+
props.inPageLinks;
|
|
36
|
+
props.offset;
|
|
37
|
+
props.offsetHeight;
|
|
38
|
+
props.offsetWidth;
|
|
39
|
+
props.scrolling;
|
|
40
|
+
props.tolerance;
|
|
41
|
+
props.warningTimeout;
|
|
42
|
+
props.onClosed;
|
|
43
|
+
props.onReady;
|
|
44
|
+
props.onMessage;
|
|
45
|
+
props.onResized;
|
|
46
|
+
var iframeProps = _objectWithoutProperties(props, _excluded$1);
|
|
47
|
+
return iframeProps;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
var _excluded = ["title", "forwardRef"];
|
|
51
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
52
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
53
|
+
function IframeResizer(props) {
|
|
54
|
+
// eslint-disable-next-line react/prop-types
|
|
55
|
+
var title = props.title,
|
|
56
|
+
forwardRef = props.forwardRef,
|
|
57
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
58
|
+
var filteredProps = filterIframeAttribs(rest);
|
|
59
|
+
var iframeRef = useRef(null);
|
|
60
|
+
var onClose = function onClose() {
|
|
61
|
+
var _iframeRef$current;
|
|
62
|
+
warning(!iframeRef.current, "[iframe-resizer/react][".concat(iframeRef === null || iframeRef === void 0 || (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : _iframeRef$current.id, "] Close event ignored, to remove the iframe update your React component."));
|
|
63
|
+
return !iframeRef.current; // Allow React to close this
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// This hook is only run once, as once iframe-resizer is bound, it will
|
|
67
|
+
// deal with changes to the element and does not need recalling
|
|
68
|
+
useEffect(function () {
|
|
69
|
+
var iframe = iframeRef.current;
|
|
70
|
+
var resizer = connectResizer(_objectSpread(_objectSpread({}, rest), {}, {
|
|
71
|
+
onClose: onClose
|
|
72
|
+
}))(iframe);
|
|
73
|
+
return function () {
|
|
74
|
+
return resizer === null || resizer === void 0 ? void 0 : resizer.disconnect();
|
|
75
|
+
};
|
|
76
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
77
|
+
|
|
78
|
+
useImperativeHandle(forwardRef, function () {
|
|
79
|
+
return {
|
|
80
|
+
getRef: function getRef() {
|
|
81
|
+
return iframeRef;
|
|
82
|
+
},
|
|
83
|
+
getElement: function getElement() {
|
|
84
|
+
return iframeRef.current;
|
|
85
|
+
},
|
|
86
|
+
resize: function resize() {
|
|
87
|
+
return iframeRef.current.iframeResizer.resize();
|
|
88
|
+
},
|
|
89
|
+
moveToAnchor: function moveToAnchor(anchor) {
|
|
90
|
+
return iframeRef.current.iframeResizer.moveToAnchor(anchor);
|
|
91
|
+
},
|
|
92
|
+
sendMessage: function sendMessage(message, targetOrigin) {
|
|
93
|
+
iframeRef.current.iframeResizer.sendMessage(message, targetOrigin);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
return /*#__PURE__*/React.createElement("iframe", _extends({
|
|
98
|
+
title: title
|
|
99
|
+
}, filteredProps, {
|
|
100
|
+
ref: iframeRef
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { IframeResizer as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iframe-resizer/react",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.0-beta.1",
|
|
4
4
|
"license": "GPL-3.0",
|
|
5
5
|
"homepage": "https://iframe-resizer.com",
|
|
6
6
|
"author": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"react"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@iframe-resizer/core": "5.1
|
|
46
|
+
"@iframe-resizer/core": "5.2.0-beta.1",
|
|
47
47
|
"warning": "^4.0.3"
|
|
48
48
|
}
|
|
49
49
|
}
|