@iframe-resizer/react 5.5.9 → 6.0.0-beta.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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- Iframe Resizer Version 5
1
+ Iframe Resizer Version 6
2
2
 
3
- This JavaScript library is Copyright © 2013-2025 David J. Bradshaw and is dual-licensed, either under GPL V3, or a commercial license that is available for purchase upon request.
3
+ This JavaScript library is Copyright © 2013-2026 David J. Bradshaw and is dual-licensed, either under GPL V3 for compliant sites (Fully published front and backend source code). Or alternatively it is available under a commercial license for sites that do not wish to use the GPL.
4
4
 
5
5
  For more information on commercial licensing see https://iframe-resizer.com/pricing/
6
6
 
package/README.md CHANGED
@@ -25,4 +25,4 @@ yarn add @iframe-resizer/react
25
25
 
26
26
  ---
27
27
 
28
- _iframe-resizer version 5.5.9 2026-02-06 - 10:22:50.790Z_
28
+ _iframe-resizer version 6.0.0-beta.0 2026-02-23 - 11:30:21.834Z_
@@ -0,0 +1,4 @@
1
+ declare const _default: ({ license, bodyBackground, bodyMargin, bodyPadding, checkOrigin, direction, inPageLinks, log, offset, offsetHeight, offsetWidth, scrolling, tolerance, warningTimeout, waitForLoad, onAfterClose, onReady, onMessage, onResized, ...iframeProps }: Record<string, unknown>) => {
2
+ [x: string]: unknown;
3
+ };
4
+ export default _default;
package/index.cjs.js CHANGED
@@ -1,106 +1,2 @@
1
- /*!
2
- * @preserve
3
- *
4
- * @module iframe-resizer/react 5.5.9 (cjs) - 2026-02-06
5
- *
6
- * @license GPL-3.0 for non-commercial use only.
7
- * For commercial use, you must purchase a license from
8
- * https://iframe-resizer.com/pricing
9
- *
10
- * @description Keep same and cross domain iFrames sized to their content
11
- *
12
- * @author David J. Bradshaw <info@iframe-resizer.com>
13
- *
14
- * @see {@link https://iframe-resizer.com}
15
- *
16
- * @copyright (c) 2013 - 2026, David J. Bradshaw. All rights reserved.
17
- */
18
-
19
-
20
- 'use strict';
21
-
22
- const _extends = require('@babel/runtime/helpers/extends');
23
- const connectResizer = require('@iframe-resizer/core');
24
- const acg = require('auto-console-group');
25
- const React = require('react');
26
-
27
- const filterIframeAttribs = ({
28
- license,
29
- bodyBackground,
30
- bodyMargin,
31
- bodyPadding,
32
- checkOrigin,
33
- direction,
34
- inPageLinks,
35
- log,
36
- offset,
37
- offsetHeight,
38
- offsetWidth,
39
- scrolling,
40
- tolerance,
41
- warningTimeout,
42
- waitForLoad,
43
- onAfterClose,
44
- onReady,
45
- onMessage,
46
- onResized,
47
- ...iframeProps
48
- }) => iframeProps;
49
-
50
- const esModuleInterop = mod =>
51
- // eslint-disable-next-line no-underscore-dangle
52
- mod?.__esModule ? mod.default : mod;
53
-
54
- // Deal with UMD not converting default exports to named exports
55
- const createAutoConsoleGroup = esModuleInterop(acg);
56
-
57
- // TODO: Add support for React.forwardRef() in next major version (Breaking change)
58
- function IframeResizer({
59
- forwardRef,
60
- ...props
61
- }) {
62
- const filteredProps = filterIframeAttribs(props);
63
- const iframeRef = React.useRef(null);
64
- const consoleGroup = createAutoConsoleGroup();
65
- const onBeforeClose = () => {
66
- consoleGroup.event('close');
67
- consoleGroup.warn(`Close event ignored, to remove the iframe update your React component.`);
68
- return false;
69
- };
70
-
71
- // This hook is only run once, as once iframe-resizer is bound, it will
72
- // deal with changes to the element and does not need recalling
73
- React.useEffect(() => {
74
- const iframe = iframeRef.current;
75
- const resizerOptions = {
76
- ...props,
77
- onBeforeClose
78
- };
79
- consoleGroup.label(`react(${iframe.id})`);
80
- consoleGroup.event('setup');
81
- const resizer = connectResizer(resizerOptions)(iframe);
82
- consoleGroup.expand(resizerOptions.logExpand);
83
- if (props.log) consoleGroup.log('Created React component');
84
- return () => {
85
- consoleGroup.endAutoGroup();
86
- resizer?.disconnect();
87
- };
88
- }, []); // eslint-disable-line react-hooks/exhaustive-deps
89
-
90
- React.useImperativeHandle(forwardRef, () => ({
91
- getRef: () => iframeRef,
92
- getElement: () => iframeRef.current,
93
- resize: () => iframeRef.current.iframeResizer.resize(),
94
- moveToAnchor: anchor => iframeRef.current.iframeResizer.moveToAnchor(anchor),
95
- sendMessage: (message, targetOrigin) => {
96
- iframeRef.current.iframeResizer.sendMessage(message, targetOrigin);
97
- }
98
- }));
99
-
100
- // eslint-disable-next-line jsx-a11y/iframe-has-title
101
- return /*#__PURE__*/React.createElement("iframe", _extends({}, filteredProps, {
102
- ref: iframeRef
103
- }));
104
- }
105
-
106
- module.exports = IframeResizer;
1
+ "use strict";const l=require("@iframe-resizer/core"),d=require("auto-console-group"),i=require("react"),g=o=>o?.__esModule?o.default:o,m=({license:o,bodyBackground:s,bodyMargin:c,bodyPadding:e,checkOrigin:r,direction:a,inPageLinks:n,log:t,offset:u,offsetHeight:z,offsetWidth:v,scrolling:h,tolerance:A,warningTimeout:M,waitForLoad:b,onAfterClose:y,onReady:C,onMessage:E,onResized:I,...f})=>f,R=g(d);function p({forwardRef:o,...s}){const c=m(s),e=i.useRef(null),r=R(),a=()=>(r.event("close"),r.warn("Close event ignored, to remove the iframe update your React component."),!1);return i.useEffect(()=>{const n=e.current,t={...s,onBeforeClose:a};r.label(`react(${n.id})`),r.event("setup");const u=l(t)(n);return r.expand(t.logExpand),s.log&&r.log("Created React component"),()=>{r.endAutoGroup(),u?.disconnect()}},[]),i.useImperativeHandle(o,()=>({getRef:()=>e,getElement:()=>e.current,resize:()=>e.current.iframeResizer.resize(),moveToAnchor:n=>e.current.iframeResizer.moveToAnchor(n),sendMessage:(n,t)=>{e.current.iframeResizer.sendMessage(n,t)}})),i.createElement("iframe",{...c,ref:e})}module.exports=p;
2
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../../packages/common/utils.ts","../../packages/react/filter-iframe-attribs.ts","../../packages/react/index.tsx"],"sourcesContent":["import { OBJECT, STRING } from './consts'\n\nexport const isElement = (node: Node): boolean => node.nodeType === Node.ELEMENT_NODE\nexport const isNumber = (value: unknown): value is number =>\n typeof value === 'number' && !Number.isNaN(value)\nexport const isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === OBJECT && value !== null\nexport const isString = (value: unknown): value is string => typeof value === STRING\n\nexport const isSafari: boolean = /^((?!chrome|android).)*safari/i.test(\n navigator.userAgent,\n)\n\nexport function isIframe(element: unknown): element is HTMLIFrameElement {\n if (!isObject(element)) return false\n\n try {\n return (element as unknown as HTMLElement).tagName === 'IFRAME' || element instanceof HTMLIFrameElement\n } catch (error) {\n return false\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...args: any[]) => any\n\nexport const isolateUserCode = (func: AnyFunction, ...val: unknown[]): ReturnType<typeof setTimeout> =>\n setTimeout(() => func(...val), 0)\n\nexport const once = <T extends AnyFunction>(fn: T): T => {\n let done = false\n\n return function (this: unknown, ...args: unknown[]) {\n return done\n ? undefined\n : ((done = true), fn.apply(this, args))\n } as unknown as T\n}\n\nconst hasOwnFallback = (o: object, k: PropertyKey): boolean =>\n Object.prototype.hasOwnProperty.call(o, k)\n\nexport const hasOwn = (o: object, k: PropertyKey): boolean =>\n Object.hasOwn ? Object.hasOwn(o, k) : hasOwnFallback(o, k)\n\nexport const isDarkModeEnabled = (): boolean =>\n window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches\n\nexport const id = <T>(x: T): T => x\n\nconst ROUNDING = 1000\n\nexport const round = (value: number): number => Math.round(value * ROUNDING) / ROUNDING\n\nexport const capitalizeFirstLetter = (string: string): string =>\n string.charAt(0).toUpperCase() + string.slice(1)\n\nexport const isDef = (value: unknown): boolean => `${value}` !== '' && value !== undefined\n\nexport const invoke = <T>(fn: () => T): T => fn()\n\nexport const lower = (str: string): string => str.toLowerCase()\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getElementName(el: any): string {\n switch (true) {\n case !isDef(el):\n return ''\n\n case isDef(el.id):\n return `${el.nodeName}#${el.id}`\n\n case isDef(el.name):\n return `${el.nodeName} (${el.name}`\n\n case isDef(el.className):\n return `${el.nodeName}.${el.className}`\n\n default:\n return el.nodeName\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const esModuleInterop = <T = any>(mod: any): T =>\n // eslint-disable-next-line no-underscore-dangle\n mod?.__esModule ? mod.default : mod\n\nexport const typeAssert = (value: unknown, type: string, error: string): void => {\n // eslint-disable-next-line valid-typeof\n if (typeof value !== type) {\n throw new TypeError(`${error} is not a ${capitalizeFirstLetter(type)}`)\n }\n}\n","export default ({\n license,\n bodyBackground,\n bodyMargin,\n bodyPadding,\n checkOrigin,\n direction,\n inPageLinks,\n log,\n offset,\n offsetHeight,\n offsetWidth,\n scrolling,\n tolerance,\n warningTimeout,\n waitForLoad,\n onAfterClose,\n onReady,\n onMessage,\n onResized,\n ...iframeProps\n}: Record<string, unknown>) => iframeProps\n","import connectResizer from '@iframe-resizer/core'\nimport type {\n IFrameObject,\n IFrameComponent,\n IFrameMessageData,\n IFrameMouseData,\n IFrameResizedData,\n IFrameScrollData,\n} from '@iframe-resizer/core'\nimport acg from 'auto-console-group'\nimport React, { type ReactElement, type RefObject, useEffect, useImperativeHandle, useRef } from 'react'\n\nimport { esModuleInterop } from '../common/utils'\nimport filterIframeAttribs from './filter-iframe-attribs'\n\nexport type { IFrameObject, IFrameComponent }\n\nexport type IFrameForwardRef = Omit<IFrameObject, 'close' | 'disconnect'> & {\n getElement: () => IFrameComponent\n getRef: () => RefObject<HTMLIFrameElement | null>\n}\n\ntype IframeProps = React.DetailedHTMLProps<\n React.IframeHTMLAttributes<HTMLIFrameElement>,\n HTMLIFrameElement\n>\n\nexport type ResizerOptions = {\n bodyBackground?: string | null\n bodyMargin?: string | number | null\n bodyPadding?: string | number | null\n checkOrigin?: boolean | string[]\n direction?: 'vertical' | 'horizontal' | 'none' | 'both'\n forwardRef?: any\n inPageLinks?: boolean\n license: string\n log?: boolean | 'expanded' | 'collapsed'\n logExpand?: boolean\n offsetSize?: number\n scrolling?: boolean | 'omit'\n tolerance?: number\n waitForLoad?: boolean\n warningTimeout?: number\n}\n\nexport type ResizerEvents = {\n onCLosed?: (iframeId: string) => void // Remove in v6\n onAfterClose?: (iframeId: string) => void\n onMessage?: (ev: IFrameMessageData) => void\n onMouseEnter?: (ev: IFrameMouseData) => void\n onMouseLeave?: (ev: IFrameMouseData) => void\n onReady?: (iframe: IFrameComponent) => void\n onResized?: (ev: IFrameResizedData) => void\n onScroll?: (ev: IFrameScrollData) => boolean\n}\n\nexport type IframeResizerProps = Omit<IframeProps, 'scrolling'> &\n ResizerOptions &\n ResizerEvents\n\n// Deal with UMD not converting default exports to named exports\nconst createAutoConsoleGroup = esModuleInterop(acg)\n\n// TODO: Add support for React.forwardRef() in next major version (Breaking change)\nfunction IframeResizer({ forwardRef, ...props }: IframeResizerProps): ReactElement {\n const filteredProps = filterIframeAttribs(props)\n const iframeRef = useRef<IFrameComponent>(null)\n const consoleGroup = createAutoConsoleGroup()\n\n const onBeforeClose = () => {\n consoleGroup.event('close')\n consoleGroup.warn(\n `Close event ignored, to remove the iframe update your React component.`,\n )\n\n return false\n }\n\n // This hook is only run once, as once iframe-resizer is bound, it will\n // deal with changes to the element and does not need recalling\n useEffect(() => {\n const iframe = iframeRef.current\n const resizerOptions = { ...props, onBeforeClose }\n\n consoleGroup.label(`react(${iframe.id})`)\n consoleGroup.event('setup')\n\n const resizer = connectResizer(resizerOptions)(iframe)\n\n consoleGroup.expand(resizerOptions.logExpand)\n if (props.log) consoleGroup.log('Created React component')\n\n return () => {\n consoleGroup.endAutoGroup()\n resizer?.disconnect()\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n useImperativeHandle(forwardRef, () => ({\n getRef: () => iframeRef,\n getElement: () => iframeRef.current,\n resize: () => iframeRef.current.iframeResizer.resize(),\n moveToAnchor: (anchor: string) =>\n iframeRef.current.iframeResizer.moveToAnchor(anchor),\n sendMessage: (message: string, targetOrigin?: string) => {\n iframeRef.current.iframeResizer.sendMessage(message, targetOrigin)\n },\n }))\n\n // eslint-disable-next-line jsx-a11y/iframe-has-title\n return <iframe {...filteredProps} ref={iframeRef} />\n}\n\nexport default IframeResizer\n"],"names":["esModuleInterop","mod","filterIframeAttribs","license","bodyBackground","bodyMargin","bodyPadding","checkOrigin","direction","inPageLinks","log","offset","offsetHeight","offsetWidth","scrolling","tolerance","warningTimeout","waitForLoad","onAfterClose","onReady","onMessage","onResized","iframeProps","createAutoConsoleGroup","acg","IframeResizer","forwardRef","props","filteredProps","iframeRef","useRef","consoleGroup","onBeforeClose","useEffect","iframe","resizerOptions","resizer","connectResizer","useImperativeHandle","anchor","message","targetOrigin","React"],"mappings":"wGAoFaA,EAA4BC,GAEvCA,GAAK,WAAaA,EAAI,QAAUA,ECtFlCC,EAAe,CAAC,CACd,QAAAC,EACA,eAAAC,EACA,WAAAC,EACA,YAAAC,EACA,YAAAC,EACA,UAAAC,EACA,YAAAC,EACA,IAAAC,EACA,OAAAC,EACA,aAAAC,EACA,YAAAC,EACA,UAAAC,EACA,UAAAC,EACA,eAAAC,EACA,YAAAC,EACA,aAAAC,EACA,QAAAC,EACA,UAAAC,EACA,UAAAC,EACA,GAAGC,CACL,IAA+BA,ECwCzBC,EAAyBvB,EAAgBwB,CAAG,EAGlD,SAASC,EAAc,CAAE,WAAAC,EAAY,GAAGC,GAA2C,CACjF,MAAMC,EAAgB1B,EAAoByB,CAAK,EACzCE,EAAYC,EAAAA,OAAwB,IAAI,EACxCC,EAAeR,EAAA,EAEfS,EAAgB,KACpBD,EAAa,MAAM,OAAO,EAC1BA,EAAa,KACX,wEAAA,EAGK,IAKTE,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAASL,EAAU,QACnBM,EAAiB,CAAE,GAAGR,EAAO,cAAAK,CAAA,EAEnCD,EAAa,MAAM,SAASG,EAAO,EAAE,GAAG,EACxCH,EAAa,MAAM,OAAO,EAE1B,MAAMK,EAAUC,EAAeF,CAAc,EAAED,CAAM,EAErD,OAAAH,EAAa,OAAOI,EAAe,SAAS,EACxCR,EAAM,KAAKI,EAAa,IAAI,yBAAyB,EAElD,IAAM,CACXA,EAAa,aAAA,EACbK,GAAS,WAAA,CACX,CACF,EAAG,CAAA,CAAE,EAELE,EAAAA,oBAAoBZ,EAAY,KAAO,CACrC,OAAQ,IAAMG,EACd,WAAY,IAAMA,EAAU,QAC5B,OAAQ,IAAMA,EAAU,QAAQ,cAAc,OAAA,EAC9C,aAAeU,GACbV,EAAU,QAAQ,cAAc,aAAaU,CAAM,EACrD,YAAa,CAACC,EAAiBC,IAA0B,CACvDZ,EAAU,QAAQ,cAAc,YAAYW,EAASC,CAAY,CACnE,CAAA,EACA,EAGKC,EAAA,cAAC,SAAA,CAAQ,GAAGd,EAAe,IAAKC,EAAW,CACpD"}
package/index.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ import { IFrameObject, IFrameComponent, IFrameMessageData, IFrameMouseData, IFrameResizedData, IFrameScrollData } from '@iframe-resizer/core';
2
+ import { default as React, ReactElement, RefObject } from 'react';
3
+ export type { IFrameObject, IFrameComponent };
4
+ export type IFrameForwardRef = Omit<IFrameObject, 'close' | 'disconnect'> & {
5
+ getElement: () => IFrameComponent;
6
+ getRef: () => RefObject<HTMLIFrameElement | null>;
7
+ };
8
+ type IframeProps = React.DetailedHTMLProps<React.IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>;
9
+ export type ResizerOptions = {
10
+ bodyBackground?: string | null;
11
+ bodyMargin?: string | number | null;
12
+ bodyPadding?: string | number | null;
13
+ checkOrigin?: boolean | string[];
14
+ direction?: 'vertical' | 'horizontal' | 'none' | 'both';
15
+ forwardRef?: any;
16
+ inPageLinks?: boolean;
17
+ license: string;
18
+ log?: boolean | 'expanded' | 'collapsed';
19
+ logExpand?: boolean;
20
+ offsetSize?: number;
21
+ scrolling?: boolean | 'omit';
22
+ tolerance?: number;
23
+ waitForLoad?: boolean;
24
+ warningTimeout?: number;
25
+ };
26
+ export type ResizerEvents = {
27
+ onCLosed?: (iframeId: string) => void;
28
+ onAfterClose?: (iframeId: string) => void;
29
+ onMessage?: (ev: IFrameMessageData) => void;
30
+ onMouseEnter?: (ev: IFrameMouseData) => void;
31
+ onMouseLeave?: (ev: IFrameMouseData) => void;
32
+ onReady?: (iframe: IFrameComponent) => void;
33
+ onResized?: (ev: IFrameResizedData) => void;
34
+ onScroll?: (ev: IFrameScrollData) => boolean;
35
+ };
36
+ export type IframeResizerProps = Omit<IframeProps, 'scrolling'> & ResizerOptions & ResizerEvents;
37
+ declare function IframeResizer({ forwardRef, ...props }: IframeResizerProps): ReactElement;
38
+ export default IframeResizer;
package/index.esm.js CHANGED
@@ -1,104 +1,53 @@
1
- /*!
2
- * @preserve
3
- *
4
- * @module iframe-resizer/react 5.5.9 (esm) - 2026-02-06
5
- *
6
- * @license GPL-3.0 for non-commercial use only.
7
- * For commercial use, you must purchase a license from
8
- * https://iframe-resizer.com/pricing
9
- *
10
- * @description Keep same and cross domain iFrames sized to their content
11
- *
12
- * @author David J. Bradshaw <info@iframe-resizer.com>
13
- *
14
- * @see {@link https://iframe-resizer.com}
15
- *
16
- * @copyright (c) 2013 - 2026, David J. Bradshaw. All rights reserved.
17
- */
18
-
19
-
20
- import _extends from '@babel/runtime/helpers/extends';
21
- import connectResizer from '@iframe-resizer/core';
22
- import acg from 'auto-console-group';
23
- import React, { useRef, useEffect, useImperativeHandle } from 'react';
24
-
25
- const filterIframeAttribs = ({
26
- license,
27
- bodyBackground,
28
- bodyMargin,
29
- bodyPadding,
30
- checkOrigin,
31
- direction,
32
- inPageLinks,
33
- log,
34
- offset,
35
- offsetHeight,
36
- offsetWidth,
37
- scrolling,
38
- tolerance,
39
- warningTimeout,
40
- waitForLoad,
41
- onAfterClose,
42
- onReady,
43
- onMessage,
44
- onResized,
45
- ...iframeProps
46
- }) => iframeProps;
47
-
48
- const esModuleInterop = mod =>
49
- // eslint-disable-next-line no-underscore-dangle
50
- mod?.__esModule ? mod.default : mod;
51
-
52
- // Deal with UMD not converting default exports to named exports
53
- const createAutoConsoleGroup = esModuleInterop(acg);
54
-
55
- // TODO: Add support for React.forwardRef() in next major version (Breaking change)
56
- function IframeResizer({
57
- forwardRef,
58
- ...props
59
- }) {
60
- const filteredProps = filterIframeAttribs(props);
61
- const iframeRef = useRef(null);
62
- const consoleGroup = createAutoConsoleGroup();
63
- const onBeforeClose = () => {
64
- consoleGroup.event('close');
65
- consoleGroup.warn(`Close event ignored, to remove the iframe update your React component.`);
66
- return false;
67
- };
68
-
69
- // This hook is only run once, as once iframe-resizer is bound, it will
70
- // deal with changes to the element and does not need recalling
71
- useEffect(() => {
72
- const iframe = iframeRef.current;
73
- const resizerOptions = {
74
- ...props,
75
- onBeforeClose
1
+ import l from "@iframe-resizer/core";
2
+ import u from "auto-console-group";
3
+ import d, { useRef as m, useEffect as g, useImperativeHandle as p } from "react";
4
+ const R = (t) => (
5
+ // eslint-disable-next-line no-underscore-dangle
6
+ t?.__esModule ? t.default : t
7
+ ), z = ({
8
+ license: t,
9
+ bodyBackground: s,
10
+ bodyMargin: i,
11
+ bodyPadding: e,
12
+ checkOrigin: o,
13
+ direction: c,
14
+ inPageLinks: r,
15
+ log: n,
16
+ offset: a,
17
+ offsetHeight: h,
18
+ offsetWidth: A,
19
+ scrolling: M,
20
+ tolerance: b,
21
+ warningTimeout: y,
22
+ waitForLoad: C,
23
+ onAfterClose: E,
24
+ onReady: I,
25
+ onMessage: k,
26
+ onResized: w,
27
+ ...f
28
+ }) => f, v = R(u);
29
+ function T({ forwardRef: t, ...s }) {
30
+ const i = z(s), e = m(null), o = v(), c = () => (o.event("close"), o.warn(
31
+ "Close event ignored, to remove the iframe update your React component."
32
+ ), !1);
33
+ return g(() => {
34
+ const r = e.current, n = { ...s, onBeforeClose: c };
35
+ o.label(`react(${r.id})`), o.event("setup");
36
+ const a = l(n)(r);
37
+ return o.expand(n.logExpand), s.log && o.log("Created React component"), () => {
38
+ o.endAutoGroup(), a?.disconnect();
76
39
  };
77
- consoleGroup.label(`react(${iframe.id})`);
78
- consoleGroup.event('setup');
79
- const resizer = connectResizer(resizerOptions)(iframe);
80
- consoleGroup.expand(resizerOptions.logExpand);
81
- if (props.log) consoleGroup.log('Created React component');
82
- return () => {
83
- consoleGroup.endAutoGroup();
84
- resizer?.disconnect();
85
- };
86
- }, []); // eslint-disable-line react-hooks/exhaustive-deps
87
-
88
- useImperativeHandle(forwardRef, () => ({
89
- getRef: () => iframeRef,
90
- getElement: () => iframeRef.current,
91
- resize: () => iframeRef.current.iframeResizer.resize(),
92
- moveToAnchor: anchor => iframeRef.current.iframeResizer.moveToAnchor(anchor),
93
- sendMessage: (message, targetOrigin) => {
94
- iframeRef.current.iframeResizer.sendMessage(message, targetOrigin);
40
+ }, []), p(t, () => ({
41
+ getRef: () => e,
42
+ getElement: () => e.current,
43
+ resize: () => e.current.iframeResizer.resize(),
44
+ moveToAnchor: (r) => e.current.iframeResizer.moveToAnchor(r),
45
+ sendMessage: (r, n) => {
46
+ e.current.iframeResizer.sendMessage(r, n);
95
47
  }
96
- }));
97
-
98
- // eslint-disable-next-line jsx-a11y/iframe-has-title
99
- return /*#__PURE__*/React.createElement("iframe", _extends({}, filteredProps, {
100
- ref: iframeRef
101
- }));
48
+ })), /* @__PURE__ */ d.createElement("iframe", { ...i, ref: e });
102
49
  }
103
-
104
- export { IframeResizer as default };
50
+ export {
51
+ T as default
52
+ };
53
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../packages/common/utils.ts","../../packages/react/filter-iframe-attribs.ts","../../packages/react/index.tsx"],"sourcesContent":["import { OBJECT, STRING } from './consts'\n\nexport const isElement = (node: Node): boolean => node.nodeType === Node.ELEMENT_NODE\nexport const isNumber = (value: unknown): value is number =>\n typeof value === 'number' && !Number.isNaN(value)\nexport const isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === OBJECT && value !== null\nexport const isString = (value: unknown): value is string => typeof value === STRING\n\nexport const isSafari: boolean = /^((?!chrome|android).)*safari/i.test(\n navigator.userAgent,\n)\n\nexport function isIframe(element: unknown): element is HTMLIFrameElement {\n if (!isObject(element)) return false\n\n try {\n return (element as unknown as HTMLElement).tagName === 'IFRAME' || element instanceof HTMLIFrameElement\n } catch (error) {\n return false\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...args: any[]) => any\n\nexport const isolateUserCode = (func: AnyFunction, ...val: unknown[]): ReturnType<typeof setTimeout> =>\n setTimeout(() => func(...val), 0)\n\nexport const once = <T extends AnyFunction>(fn: T): T => {\n let done = false\n\n return function (this: unknown, ...args: unknown[]) {\n return done\n ? undefined\n : ((done = true), fn.apply(this, args))\n } as unknown as T\n}\n\nconst hasOwnFallback = (o: object, k: PropertyKey): boolean =>\n Object.prototype.hasOwnProperty.call(o, k)\n\nexport const hasOwn = (o: object, k: PropertyKey): boolean =>\n Object.hasOwn ? Object.hasOwn(o, k) : hasOwnFallback(o, k)\n\nexport const isDarkModeEnabled = (): boolean =>\n window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches\n\nexport const id = <T>(x: T): T => x\n\nconst ROUNDING = 1000\n\nexport const round = (value: number): number => Math.round(value * ROUNDING) / ROUNDING\n\nexport const capitalizeFirstLetter = (string: string): string =>\n string.charAt(0).toUpperCase() + string.slice(1)\n\nexport const isDef = (value: unknown): boolean => `${value}` !== '' && value !== undefined\n\nexport const invoke = <T>(fn: () => T): T => fn()\n\nexport const lower = (str: string): string => str.toLowerCase()\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getElementName(el: any): string {\n switch (true) {\n case !isDef(el):\n return ''\n\n case isDef(el.id):\n return `${el.nodeName}#${el.id}`\n\n case isDef(el.name):\n return `${el.nodeName} (${el.name}`\n\n case isDef(el.className):\n return `${el.nodeName}.${el.className}`\n\n default:\n return el.nodeName\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const esModuleInterop = <T = any>(mod: any): T =>\n // eslint-disable-next-line no-underscore-dangle\n mod?.__esModule ? mod.default : mod\n\nexport const typeAssert = (value: unknown, type: string, error: string): void => {\n // eslint-disable-next-line valid-typeof\n if (typeof value !== type) {\n throw new TypeError(`${error} is not a ${capitalizeFirstLetter(type)}`)\n }\n}\n","export default ({\n license,\n bodyBackground,\n bodyMargin,\n bodyPadding,\n checkOrigin,\n direction,\n inPageLinks,\n log,\n offset,\n offsetHeight,\n offsetWidth,\n scrolling,\n tolerance,\n warningTimeout,\n waitForLoad,\n onAfterClose,\n onReady,\n onMessage,\n onResized,\n ...iframeProps\n}: Record<string, unknown>) => iframeProps\n","import connectResizer from '@iframe-resizer/core'\nimport type {\n IFrameObject,\n IFrameComponent,\n IFrameMessageData,\n IFrameMouseData,\n IFrameResizedData,\n IFrameScrollData,\n} from '@iframe-resizer/core'\nimport acg from 'auto-console-group'\nimport React, { type ReactElement, type RefObject, useEffect, useImperativeHandle, useRef } from 'react'\n\nimport { esModuleInterop } from '../common/utils'\nimport filterIframeAttribs from './filter-iframe-attribs'\n\nexport type { IFrameObject, IFrameComponent }\n\nexport type IFrameForwardRef = Omit<IFrameObject, 'close' | 'disconnect'> & {\n getElement: () => IFrameComponent\n getRef: () => RefObject<HTMLIFrameElement | null>\n}\n\ntype IframeProps = React.DetailedHTMLProps<\n React.IframeHTMLAttributes<HTMLIFrameElement>,\n HTMLIFrameElement\n>\n\nexport type ResizerOptions = {\n bodyBackground?: string | null\n bodyMargin?: string | number | null\n bodyPadding?: string | number | null\n checkOrigin?: boolean | string[]\n direction?: 'vertical' | 'horizontal' | 'none' | 'both'\n forwardRef?: any\n inPageLinks?: boolean\n license: string\n log?: boolean | 'expanded' | 'collapsed'\n logExpand?: boolean\n offsetSize?: number\n scrolling?: boolean | 'omit'\n tolerance?: number\n waitForLoad?: boolean\n warningTimeout?: number\n}\n\nexport type ResizerEvents = {\n onCLosed?: (iframeId: string) => void // Remove in v6\n onAfterClose?: (iframeId: string) => void\n onMessage?: (ev: IFrameMessageData) => void\n onMouseEnter?: (ev: IFrameMouseData) => void\n onMouseLeave?: (ev: IFrameMouseData) => void\n onReady?: (iframe: IFrameComponent) => void\n onResized?: (ev: IFrameResizedData) => void\n onScroll?: (ev: IFrameScrollData) => boolean\n}\n\nexport type IframeResizerProps = Omit<IframeProps, 'scrolling'> &\n ResizerOptions &\n ResizerEvents\n\n// Deal with UMD not converting default exports to named exports\nconst createAutoConsoleGroup = esModuleInterop(acg)\n\n// TODO: Add support for React.forwardRef() in next major version (Breaking change)\nfunction IframeResizer({ forwardRef, ...props }: IframeResizerProps): ReactElement {\n const filteredProps = filterIframeAttribs(props)\n const iframeRef = useRef<IFrameComponent>(null)\n const consoleGroup = createAutoConsoleGroup()\n\n const onBeforeClose = () => {\n consoleGroup.event('close')\n consoleGroup.warn(\n `Close event ignored, to remove the iframe update your React component.`,\n )\n\n return false\n }\n\n // This hook is only run once, as once iframe-resizer is bound, it will\n // deal with changes to the element and does not need recalling\n useEffect(() => {\n const iframe = iframeRef.current\n const resizerOptions = { ...props, onBeforeClose }\n\n consoleGroup.label(`react(${iframe.id})`)\n consoleGroup.event('setup')\n\n const resizer = connectResizer(resizerOptions)(iframe)\n\n consoleGroup.expand(resizerOptions.logExpand)\n if (props.log) consoleGroup.log('Created React component')\n\n return () => {\n consoleGroup.endAutoGroup()\n resizer?.disconnect()\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n useImperativeHandle(forwardRef, () => ({\n getRef: () => iframeRef,\n getElement: () => iframeRef.current,\n resize: () => iframeRef.current.iframeResizer.resize(),\n moveToAnchor: (anchor: string) =>\n iframeRef.current.iframeResizer.moveToAnchor(anchor),\n sendMessage: (message: string, targetOrigin?: string) => {\n iframeRef.current.iframeResizer.sendMessage(message, targetOrigin)\n },\n }))\n\n // eslint-disable-next-line jsx-a11y/iframe-has-title\n return <iframe {...filteredProps} ref={iframeRef} />\n}\n\nexport default IframeResizer\n"],"names":["esModuleInterop","mod","filterIframeAttribs","license","bodyBackground","bodyMargin","bodyPadding","checkOrigin","direction","inPageLinks","log","offset","offsetHeight","offsetWidth","scrolling","tolerance","warningTimeout","waitForLoad","onAfterClose","onReady","onMessage","onResized","iframeProps","createAutoConsoleGroup","acg","IframeResizer","forwardRef","props","filteredProps","iframeRef","useRef","consoleGroup","onBeforeClose","useEffect","iframe","resizerOptions","resizer","connectResizer","useImperativeHandle","anchor","message","targetOrigin","React"],"mappings":";;;AAoFO,MAAMA,IAAkB,CAAUC;AAAA;AAAA,EAEvCA,GAAK,aAAaA,EAAI,UAAUA;AAAA,GCtFlCC,IAAe,CAAC;AAAA,EACd,SAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,KAAAC;AAAA,EACA,QAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,MAA+BA,GCwCzBC,IAAyBvB,EAAgBwB,CAAG;AAGlD,SAASC,EAAc,EAAE,YAAAC,GAAY,GAAGC,KAA2C;AACjF,QAAMC,IAAgB1B,EAAoByB,CAAK,GACzCE,IAAYC,EAAwB,IAAI,GACxCC,IAAeR,EAAA,GAEfS,IAAgB,OACpBD,EAAa,MAAM,OAAO,GAC1BA,EAAa;AAAA,IACX;AAAA,EAAA,GAGK;AAKT,SAAAE,EAAU,MAAM;AACd,UAAMC,IAASL,EAAU,SACnBM,IAAiB,EAAE,GAAGR,GAAO,eAAAK,EAAA;AAEnC,IAAAD,EAAa,MAAM,SAASG,EAAO,EAAE,GAAG,GACxCH,EAAa,MAAM,OAAO;AAE1B,UAAMK,IAAUC,EAAeF,CAAc,EAAED,CAAM;AAErD,WAAAH,EAAa,OAAOI,EAAe,SAAS,GACxCR,EAAM,OAAKI,EAAa,IAAI,yBAAyB,GAElD,MAAM;AACX,MAAAA,EAAa,aAAA,GACbK,GAAS,WAAA;AAAA,IACX;AAAA,EACF,GAAG,CAAA,CAAE,GAELE,EAAoBZ,GAAY,OAAO;AAAA,IACrC,QAAQ,MAAMG;AAAA,IACd,YAAY,MAAMA,EAAU;AAAA,IAC5B,QAAQ,MAAMA,EAAU,QAAQ,cAAc,OAAA;AAAA,IAC9C,cAAc,CAACU,MACbV,EAAU,QAAQ,cAAc,aAAaU,CAAM;AAAA,IACrD,aAAa,CAACC,GAAiBC,MAA0B;AACvD,MAAAZ,EAAU,QAAQ,cAAc,YAAYW,GAASC,CAAY;AAAA,IACnE;AAAA,EAAA,EACA,GAGK,gBAAAC,EAAA,cAAC,UAAA,EAAQ,GAAGd,GAAe,KAAKC,GAAW;AACpD;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iframe-resizer/react",
3
- "version": "5.5.9",
3
+ "version": "6.0.0-beta.0",
4
4
  "license": "GPL-3.0",
5
5
  "homepage": "https://iframe-resizer.com",
6
6
  "author": {
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "main": "index.cjs.js",
21
21
  "module": "index.esm.js",
22
- "types": "iframe-resizer.react.d.ts",
22
+ "types": "index.d.ts",
23
23
  "peerDependencies": {
24
24
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
25
25
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
@@ -38,8 +38,8 @@
38
38
  "react"
39
39
  ],
40
40
  "dependencies": {
41
- "@babel/runtime": "^7.28.6",
42
- "@iframe-resizer/core": "5.5.9",
43
- "auto-console-group": "1.3.0"
41
+ "@iframe-resizer/core": "6.0.0-beta.0",
42
+ "auto-console-group": "1.3.0",
43
+ "react": "^19.2.4"
44
44
  }
45
- }
45
+ }
@@ -1,84 +0,0 @@
1
- /**
2
- * @fileoverview Type definitions for @iframe-resizer/react
3
- *
4
- * I'm not a TypeScript dev, so please feel free to submit PRs to improve this file.
5
- */
6
-
7
- declare module '@iframe-resizer/react' {
8
- import * as React from 'react'
9
-
10
- namespace IframeResizer {
11
- type IFrameObject = {
12
- moveToAnchor: (anchor: string) => void
13
- resize: () => void
14
- sendMessage: (message: string, targetOrigin?: string) => void
15
- }
16
-
17
- interface IFrameComponent extends HTMLIFrameElement {
18
- iFrameResizer: IFrameObject
19
- }
20
-
21
- type IFrameForwardRef = Omit<IFrameObject, 'close' | 'disconnect'> & {
22
- getElement: () => IFrameComponent
23
- getRef: () => any
24
- }
25
-
26
- type IframeProps = React.DetailedHTMLProps<
27
- React.IframeHTMLAttributes<HTMLIFrameElement>,
28
- HTMLIFrameElement
29
- >
30
-
31
- type ResizerOptions = {
32
- bodyBackground?: string | null
33
- bodyMargin?: string | number | null
34
- bodyPadding?: string | number | null
35
- checkOrigin?: boolean | string[]
36
- direction?: 'vertical' | 'horizontal' | 'none' | 'both'
37
- forwardRef?: any
38
- inPageLinks?: boolean
39
- license: string
40
- log?: boolean | 'expanded' | 'collapsed'
41
- offsetSize?: number
42
- scrolling?: boolean | 'omit'
43
- tolerance?: number
44
- waitForLoad?: boolean
45
- warningTimeout?: number
46
- }
47
-
48
- type ResizerEvents = {
49
- onCLosed?: (iframeId: string) => void // Remove in v6
50
- onAfterClose?: (iframeId: string) => void
51
- onMessage?: (ev: { iframe: IFrameComponent; message: any }) => void
52
- onMouseEnter?: (ev: {
53
- iframe: IFrameComponent
54
- height: number
55
- width: number
56
- type: string
57
- }) => void
58
- onMouseLeave?: (ev: {
59
- iframe: IFrameComponent
60
- height: number
61
- width: number
62
- type: string
63
- }) => void
64
- onReady?: (iframe: IFrameComponent) => void
65
- onResized?: (ev: {
66
- iframe: IFrameComponent
67
- height: number
68
- width: number
69
- type: string
70
- }) => void
71
- onScroll?: (ev: { x: number; y: number }) => boolean
72
- }
73
-
74
- type IframeResizerProps = Omit<IframeProps, 'scrolling'> &
75
- ResizerOptions &
76
- ResizerEvents
77
- }
78
-
79
- function IframeResizer(
80
- props: IframeResizer.IframeResizerProps,
81
- ): React.ReactElement
82
-
83
- export = IframeResizer
84
- }