@iframe-resizer/react 5.2.1 → 5.2.2-beta.2

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 CHANGED
@@ -22,4 +22,4 @@ yarn add @iframe-resizer/react
22
22
 
23
23
  ---
24
24
 
25
- _iframe-resizer version 5.2.1 2024-07-16 - 19:19:47.416Z_
25
+ _iframe-resizer version 5.2.2-beta.2 2024-07-18 - 14:09:44.747Z_
package/index.cjs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/react 5.2.1 (cjs) - 2024-07-16
4
+ * @module iframe-resizer/react 5.2.2-beta.2 (cjs) - 2024-07-18
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -20,83 +20,69 @@
20
20
  'use strict';
21
21
 
22
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
23
  const connectResizer = require('@iframe-resizer/core');
26
24
  const React = require('react');
27
25
  const warning = require('warning');
28
26
 
29
- var _excluded$1 = ["license", "bodyBackground", "bodyMargin", "bodyPadding", "checkOrigin", "direction", "inPageLinks", "offset", "offsetHeight", "offsetWidth", "scrolling", "tolerance", "warningTimeout", "waitForLoad", "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.waitForLoad;
45
- props.onClosed;
46
- props.onReady;
47
- props.onMessage;
48
- props.onResized;
49
- var iframeProps = _objectWithoutProperties(props, _excluded$1);
27
+ const filterIframeAttribs = (props => {
28
+ const {
29
+ license,
30
+ bodyBackground,
31
+ bodyMargin,
32
+ bodyPadding,
33
+ checkOrigin,
34
+ direction,
35
+ inPageLinks,
36
+ offset,
37
+ offsetHeight,
38
+ offsetWidth,
39
+ scrolling,
40
+ tolerance,
41
+ warningTimeout,
42
+ waitForLoad,
43
+ onClosed,
44
+ onReady,
45
+ onMessage,
46
+ onResized,
47
+ ...iframeProps
48
+ } = props;
50
49
  return iframeProps;
51
50
  });
52
51
 
53
- var _excluded = ["title", "forwardRef"];
54
- 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; }
55
- 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; }
56
52
  function IframeResizer(props) {
57
53
  // eslint-disable-next-line react/prop-types
58
- var title = props.title,
59
- forwardRef = props.forwardRef,
60
- rest = _objectWithoutProperties(props, _excluded);
61
- var filteredProps = filterIframeAttribs(rest);
62
- var iframeRef = React.useRef(null);
63
- var onClose = function onClose() {
64
- var _iframeRef$current;
65
- 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."));
54
+ const {
55
+ title,
56
+ forwardRef,
57
+ ...rest
58
+ } = props;
59
+ const filteredProps = filterIframeAttribs(rest);
60
+ const iframeRef = React.useRef(null);
61
+ const onClose = () => {
62
+ warning(!iframeRef.current, `[iframe-resizer/react][${iframeRef?.current?.id}] Close event ignored, to remove the iframe update your React component.`);
66
63
  return !iframeRef.current; // Allow React to close this
67
64
  };
68
65
 
69
66
  // This hook is only run once, as once iframe-resizer is bound, it will
70
67
  // deal with changes to the element and does not need recalling
71
- React.useEffect(function () {
72
- var iframe = iframeRef.current;
73
- var resizer = connectResizer(_objectSpread(_objectSpread({}, rest), {}, {
74
- onClose: onClose
75
- }))(iframe);
76
- return function () {
77
- return resizer === null || resizer === void 0 ? void 0 : resizer.disconnect();
78
- };
68
+ React.useEffect(() => {
69
+ const iframe = iframeRef.current;
70
+ const resizer = connectResizer({
71
+ ...rest,
72
+ onClose
73
+ })(iframe);
74
+ return () => resizer?.disconnect();
79
75
  }, []); // eslint-disable-line react-hooks/exhaustive-deps
80
76
 
81
- React.useImperativeHandle(forwardRef, function () {
82
- return {
83
- getRef: function getRef() {
84
- return iframeRef;
85
- },
86
- getElement: function getElement() {
87
- return iframeRef.current;
88
- },
89
- resize: function resize() {
90
- return iframeRef.current.iframeResizer.resize();
91
- },
92
- moveToAnchor: function moveToAnchor(anchor) {
93
- return iframeRef.current.iframeResizer.moveToAnchor(anchor);
94
- },
95
- sendMessage: function sendMessage(message, targetOrigin) {
96
- iframeRef.current.iframeResizer.sendMessage(message, targetOrigin);
97
- }
98
- };
99
- });
77
+ React.useImperativeHandle(forwardRef, () => ({
78
+ getRef: () => iframeRef,
79
+ getElement: () => iframeRef.current,
80
+ resize: () => iframeRef.current.iframeResizer.resize(),
81
+ moveToAnchor: anchor => iframeRef.current.iframeResizer.moveToAnchor(anchor),
82
+ sendMessage: (message, targetOrigin) => {
83
+ iframeRef.current.iframeResizer.sendMessage(message, targetOrigin);
84
+ }
85
+ }));
100
86
  return /*#__PURE__*/React.createElement("iframe", _extends({
101
87
  title: title
102
88
  }, filteredProps, {
package/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/react 5.2.1 (esm) - 2024-07-16
4
+ * @module iframe-resizer/react 5.2.2-beta.2 (esm) - 2024-07-18
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -18,83 +18,69 @@
18
18
 
19
19
 
20
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
21
  import connectResizer from '@iframe-resizer/core';
24
22
  import React, { useRef, useEffect, useImperativeHandle } from 'react';
25
23
  import warning from 'warning';
26
24
 
27
- var _excluded$1 = ["license", "bodyBackground", "bodyMargin", "bodyPadding", "checkOrigin", "direction", "inPageLinks", "offset", "offsetHeight", "offsetWidth", "scrolling", "tolerance", "warningTimeout", "waitForLoad", "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.waitForLoad;
43
- props.onClosed;
44
- props.onReady;
45
- props.onMessage;
46
- props.onResized;
47
- var iframeProps = _objectWithoutProperties(props, _excluded$1);
25
+ const filterIframeAttribs = (props => {
26
+ const {
27
+ license,
28
+ bodyBackground,
29
+ bodyMargin,
30
+ bodyPadding,
31
+ checkOrigin,
32
+ direction,
33
+ inPageLinks,
34
+ offset,
35
+ offsetHeight,
36
+ offsetWidth,
37
+ scrolling,
38
+ tolerance,
39
+ warningTimeout,
40
+ waitForLoad,
41
+ onClosed,
42
+ onReady,
43
+ onMessage,
44
+ onResized,
45
+ ...iframeProps
46
+ } = props;
48
47
  return iframeProps;
49
48
  });
50
49
 
51
- var _excluded = ["title", "forwardRef"];
52
- 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; }
53
- 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; }
54
50
  function IframeResizer(props) {
55
51
  // eslint-disable-next-line react/prop-types
56
- var title = props.title,
57
- forwardRef = props.forwardRef,
58
- rest = _objectWithoutProperties(props, _excluded);
59
- var filteredProps = filterIframeAttribs(rest);
60
- var iframeRef = useRef(null);
61
- var onClose = function onClose() {
62
- var _iframeRef$current;
63
- 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."));
52
+ const {
53
+ title,
54
+ forwardRef,
55
+ ...rest
56
+ } = props;
57
+ const filteredProps = filterIframeAttribs(rest);
58
+ const iframeRef = useRef(null);
59
+ const onClose = () => {
60
+ warning(!iframeRef.current, `[iframe-resizer/react][${iframeRef?.current?.id}] Close event ignored, to remove the iframe update your React component.`);
64
61
  return !iframeRef.current; // Allow React to close this
65
62
  };
66
63
 
67
64
  // This hook is only run once, as once iframe-resizer is bound, it will
68
65
  // deal with changes to the element and does not need recalling
69
- useEffect(function () {
70
- var iframe = iframeRef.current;
71
- var resizer = connectResizer(_objectSpread(_objectSpread({}, rest), {}, {
72
- onClose: onClose
73
- }))(iframe);
74
- return function () {
75
- return resizer === null || resizer === void 0 ? void 0 : resizer.disconnect();
76
- };
66
+ useEffect(() => {
67
+ const iframe = iframeRef.current;
68
+ const resizer = connectResizer({
69
+ ...rest,
70
+ onClose
71
+ })(iframe);
72
+ return () => resizer?.disconnect();
77
73
  }, []); // eslint-disable-line react-hooks/exhaustive-deps
78
74
 
79
- useImperativeHandle(forwardRef, function () {
80
- return {
81
- getRef: function getRef() {
82
- return iframeRef;
83
- },
84
- getElement: function getElement() {
85
- return iframeRef.current;
86
- },
87
- resize: function resize() {
88
- return iframeRef.current.iframeResizer.resize();
89
- },
90
- moveToAnchor: function moveToAnchor(anchor) {
91
- return iframeRef.current.iframeResizer.moveToAnchor(anchor);
92
- },
93
- sendMessage: function sendMessage(message, targetOrigin) {
94
- iframeRef.current.iframeResizer.sendMessage(message, targetOrigin);
95
- }
96
- };
97
- });
75
+ useImperativeHandle(forwardRef, () => ({
76
+ getRef: () => iframeRef,
77
+ getElement: () => iframeRef.current,
78
+ resize: () => iframeRef.current.iframeResizer.resize(),
79
+ moveToAnchor: anchor => iframeRef.current.iframeResizer.moveToAnchor(anchor),
80
+ sendMessage: (message, targetOrigin) => {
81
+ iframeRef.current.iframeResizer.sendMessage(message, targetOrigin);
82
+ }
83
+ }));
98
84
  return /*#__PURE__*/React.createElement("iframe", _extends({
99
85
  title: title
100
86
  }, filteredProps, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iframe-resizer/react",
3
- "version": "5.2.1",
3
+ "version": "5.2.2-beta.2",
4
4
  "license": "GPL-3.0",
5
5
  "homepage": "https://iframe-resizer.com",
6
6
  "author": {
@@ -43,8 +43,8 @@
43
43
  "react"
44
44
  ],
45
45
  "dependencies": {
46
- "@babel/runtime": "^7.24.7",
47
- "@iframe-resizer/core": "5.2.1",
46
+ "@babel/runtime": "^7.0.0",
47
+ "@iframe-resizer/core": "5.2.2-beta.2",
48
48
  "warning": "^4.0.3"
49
49
  }
50
50
  }