UNPKG

@zohodesk/platform-middleware

Version:

Generalized Contract for the events from Marketplace App, In-App widgets, CRM-Plus and EFC

56 lines (40 loc) 1.27 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** Libraries */ var style = { wh100: { width: '100%', height: '100%' } }; var WidgetFrame = function WidgetFrame(props) { var instance = props.instance; var widgetDetails = instance.__WIDGET__; var url = widgetDetails.url, location = widgetDetails.location; var frameRef = _react2.default.createRef(); (0, _react.useEffect)(function () { var frameInstance = frameRef.current; if (instance && typeof instance.handleLoad === 'function' && frameInstance) { frameInstance.addEventListener('load', instance.handleLoad); } }, []); return _react2.default.createElement('iframe', { id: instance._uniqueID, location: location, src: url, ref: frameRef, style: style.wh100 }); }; exports.default = WidgetFrame; WidgetFrame.propTypes = { instance: _propTypes2.default.object };