1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.IFrame = void 0;
|
4 | const jsx_runtime_1 = require("react/jsx-runtime");
|
5 | const react_1 = require("react");
|
6 | const ready_manager_1 = require("./ready-manager");
|
7 | const IFrameRefForwarding = ({ onLoad, onError, ...props }, ref) => {
|
8 | const [handle] = (0, react_1.useState)(() => (0, ready_manager_1.delayRender)());
|
9 | const didLoad = (0, react_1.useCallback)((e) => {
|
10 | (0, ready_manager_1.continueRender)(handle);
|
11 | onLoad === null || onLoad === void 0 ? void 0 : onLoad(e);
|
12 | }, [handle, onLoad]);
|
13 | const didGetError = (0, react_1.useCallback)((e) => {
|
14 | (0, ready_manager_1.continueRender)(handle);
|
15 | if (onError) {
|
16 | onError(e);
|
17 | }
|
18 | else {
|
19 | console.error('Error loading iframe:', e, 'Handle the event using the onError() prop to make this message disappear.');
|
20 | }
|
21 | }, [handle, onError]);
|
22 | return (0, jsx_runtime_1.jsx)("iframe", Object.assign({}, props, { ref: ref, onError: didGetError, onLoad: didLoad }), void 0);
|
23 | };
|
24 | exports.IFrame = (0, react_1.forwardRef)(IFrameRefForwarding);
|
25 |
|
\ | No newline at end of file |