UNPKG

@finapi/finapi-js-loader

Version:

finAPI JS Loader

296 lines (284 loc) 16.9 kB
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var Widget = /*#__PURE__*/function () { /** * @param id - unique identifier of the widget used for injecting HTML nodes * @param container - parent HTML element where the widget will be injected * @param target - URL of the environment from which the widget's JS bundle will be fetched. Use this, for example, when testing features that are only released to the sandbox environment. By default, `https://widget-library-finapi-general-live.finapi.io` is used. * @param ownerDocument - parent Document where the widget will be injected. For example, shadow root or document fragment. By default, the default top-level document is used. * @param customBundleFileName - allows modifying the filename of the widget's JS bundle that will be fetched. By default, bundle filenames are determined from the supplied `id`. This property is useful during dev mode when widgets are generated together into one `main.js` file. * @param internalProps - internal properties that will be passed to the widget. */ function Widget(id, container, target, ownerDocument, customBundleFileName, internalProps) { this.ownerDocument = void 0; this.scriptId = void 0; this.container = void 0; this.webComponentId = void 0; this.source = void 0; this.internalProps = void 0; this.webComponentId = "finapi-" + id; this.scriptId = id + "-script"; this.container = container; this.ownerDocument = ownerDocument || document; this.source = this.getSource(id, target, customBundleFileName); this.internalProps = internalProps; } /** * Loads the web component into the container element. * * @param properties - Optional properties to be passed to the web component. * @param callbacks - Optional callbacks to be passed to the web component. */ var _proto = Widget.prototype; _proto.load = function load(properties, callbacks) { var isScriptAppended = this.ownerDocument.querySelector("#" + this.scriptId) != null; if (!isScriptAppended) { this.ownerDocument.body.appendChild(this.createScript()); } this.unload(); var webComponent = this.createWebComponent(properties, callbacks); this.container.appendChild(webComponent); } /** * Removes the web component from the DOM. */; _proto.unload = function unload() { var webComponent = this.ownerDocument.querySelector(this.webComponentId); if (webComponent && webComponent.parentNode) { webComponent.parentNode.removeChild(webComponent); } }; _proto.getSource = function getSource(widgetId, target, customBundleFileName) { var host = target || 'https://widget-library-finapi-general-live.finapi.io'; var widgetBundleFileName = customBundleFileName || "finapi-" + widgetId + ".js"; return host + "/" + widgetBundleFileName; }; _proto.createScript = function createScript() { var script = this.ownerDocument.createElement('script'); script.src = this.source + "?t=" + Date.now(); script.id = this.scriptId; script.async = false; return script; }; _proto.createWebComponent = function createWebComponent(properties, callbacks) { var _properties$scroll; var webComponent = this.ownerDocument.createElement(this.webComponentId); var propertyPort = webComponent.properties || webComponent; if (properties) { Object.keys(properties).forEach(function (key) { propertyPort[key] = properties[key]; }); } var internalProps = this.internalProps; if (internalProps) { Object.keys(internalProps).forEach(function (key) { propertyPort[key] = internalProps[key]; }); } if (properties != null && (_properties$scroll = properties.scroll) != null && _properties$scroll.enabled && window.history.scrollRestoration) { window.history.scrollRestoration = 'manual'; } if (callbacks) { Object.keys(callbacks).forEach(function (event) { webComponent.addEventListener(event, function (e) { var customEvent = e; var callback = callbacks[event]; if (callback) { callback(customEvent.detail); } }); }); } return webComponent; }; return Widget; }(); var CreditCheckAccount = /*#__PURE__*/function (_Widget) { _inheritsLoose(CreditCheckAccount, _Widget); /** * # CreditCheck Konto * Digital account overview. CreditCheck is a zero integration solution that * provides digital account analysis and visibility into the loan application * process. * * @param container - parent HTML element where the widget will be injected * @param target - URL of the environment from which the widget's JS bundle will be fetched. Use this, for example, when testing features that are only released to the sandbox environment. By default, `https://widget-library-finapi-general-live.finapi.io` is used. * @param ownerDocument - parent Document where the widget will be injected. For example, shadow root or document fragment. By default, the default top-level document is used. * @param customBundleFileName - allows modifying the filename of the widget's JS bundle that will be fetched. This property is useful during dev mode when widgets are generated together into one `main.js` file. */ function CreditCheckAccount(container, target, ownerDocument, customBundleFileName) { return _Widget.call(this, 'creditcheck', container, target, ownerDocument, customBundleFileName, { type: 'account' }) || this; } return CreditCheckAccount; }(Widget); var CreditCheckB2B = /*#__PURE__*/function (_Widget) { _inheritsLoose(CreditCheckB2B, _Widget); /** * # CreditCheck credit application * Digital account overview in the loan application. CreditCheck is a zero * integration solution that provides digital account analysis and visibility * into the loan application process. * * @param container - parent HTML element where the widget will be injected * @param target - URL of the environment from which the widget's JS bundle will be fetched. Use this, for example, when testing features that are only released to the sandbox environment. By default, `https://widget-library-finapi-general-live.finapi.io` is used. * @param ownerDocument - parent Document where the widget will be injected. For example, shadow root or document fragment. By default, the default top-level document is used. * @param customBundleFileName - allows modifying the filename of the widget's JS bundle that will be fetched. This property is useful during dev mode when widgets are generated together into one `main.js` file. */ function CreditCheckB2B(container, target, ownerDocument, customBundleFileName) { return _Widget.call(this, 'creditcheck', container, target, ownerDocument, customBundleFileName, { type: 'b2b' }) || this; } return CreditCheckB2B; }(Widget); var CreditCheckLoan = /*#__PURE__*/function (_Widget) { _inheritsLoose(CreditCheckLoan, _Widget); /** * # CreditCheck credit application * Digital account overview in the loan application. CreditCheck is a zero * integration solution that provides digital account analysis and visibility * into the loan application process. * * @param container - parent HTML element where the widget will be injected * @param target - URL of the environment from which the widget's JS bundle will be fetched. Use this, for example, when testing features that are only released to the sandbox environment. By default, `https://widget-library-finapi-general-live.finapi.io` is used. * @param ownerDocument - parent Document where the widget will be injected. For example, shadow root or document fragment. By default, the default top-level document is used. * @param customBundleFileName - allows modifying the filename of the widget's JS bundle that will be fetched. This property is useful during dev mode when widgets are generated together into one `main.js` file. */ function CreditCheckLoan(container, target, ownerDocument, customBundleFileName) { return _Widget.call(this, 'creditcheck', container, target, ownerDocument, customBundleFileName, { type: 'loan' }) || this; } return CreditCheckLoan; }(Widget); var DigitalAccountCheck = /*#__PURE__*/function (_Widget) { _inheritsLoose(DigitalAccountCheck, _Widget); /** * # Digital account check (B2C) * Digital account check is a zero * integration solution that provides digital account analysis and visibility for private (consumers) accounts. * * @param container - parent HTML element where the widget will be injected * @param target - URL of the environment from which the widget's JS bundle will be fetched. Use this, for example, when testing features that are only released to the sandbox environment. By default, `https://widget-library-finapi-general-live.finapi.io` is used. * @param ownerDocument - parent Document where the widget will be injected. For example, shadow root or document fragment. By default, the default top-level document is used. * @param customBundleFileName - allows modifying the filename of the widget's JS bundle that will be fetched. This property is useful during dev mode when widgets are generated together into one `main.js` file. */ function DigitalAccountCheck(container, target, ownerDocument, customBundleFileName) { return _Widget.call(this, 'creditcheck', container, target, ownerDocument, customBundleFileName, { type: 'dac_b2c' }) || this; } return DigitalAccountCheck; }(Widget); var DigitalAccountCheckB2b = /*#__PURE__*/function (_Widget) { _inheritsLoose(DigitalAccountCheckB2b, _Widget); /** * # Digital account check (B2B) * Digital account check is a zero * integration solution that provides digital account analysis and visibility for business accounts. * * @param container - parent HTML element where the widget will be injected * @param target - URL of the environment from which the widget's JS bundle will be fetched. Use this, for example, when testing features that are only released to the sandbox environment. By default, `https://widget-library-finapi-general-live.finapi.io` is used. * @param ownerDocument - parent Document where the widget will be injected. For example, shadow root or document fragment. By default, the default top-level document is used. * @param customBundleFileName - allows modifying the filename of the widget's JS bundle that will be fetched. This property is useful during dev mode when widgets are generated together into one `main.js` file. */ function DigitalAccountCheckB2b(container, target, ownerDocument, customBundleFileName) { return _Widget.call(this, 'creditcheck', container, target, ownerDocument, customBundleFileName, { type: 'dac_b2b' }) || this; } return DigitalAccountCheckB2b; }(Widget); var GiroIdentBasis = /*#__PURE__*/function (_Widget) { _inheritsLoose(GiroIdentBasis, _Widget); /** * # GiroIdent Basis * Checking and verifying the name. In the basic version, the given name is * compared in real time with the first name and surname of the account holder. * * ## styleOverrides * - `.startButton` - enables you to customize the button displayed on the * initial view, which initiates the evaluation process * * @param container - parent HTML element where the widget will be injected * @param target - URL of the environment from which the widget's JS bundle will be fetched. Use this, for example, when testing features that are only released to the sandbox environment. By default, `https://widget-library-finapi-general-live.finapi.io` is used. * @param ownerDocument - parent Document where the widget will be injected. For example, shadow root or document fragment. By default, the default top-level document is used. * @param customBundleFileName - allows modifying the filename of the widget's JS bundle that will be fetched. This property is useful during dev mode when widgets are generated together into one `main.js` file. */ function GiroIdentBasis(container, target, ownerDocument, customBundleFileName) { return _Widget.call(this, 'giroident', container, target, ownerDocument, customBundleFileName, { type: 'basis' }) || this; } return GiroIdentBasis; }(Widget); /** @internal */ var TestingTool = /*#__PURE__*/function (_Widget) { _inheritsLoose(TestingTool, _Widget); /** * # Testing Tool * The Testing Tool widget will allow importing users’ accounts, choosing one * of them, and executing the payment. It will be provided to the testing * company, which will use it for testing accounts from different countries. * * @param container - parent HTML element where the widget will be injected * @param target - URL of the environment from which the widget's JS bundle will be fetched. Use this, for example, when testing features that are only released to the sandbox environment. By default, `https://widget-library-finapi-general-live.finapi.io` is used. * @param ownerDocument - parent Document where the widget will be injected. For example, shadow root or document fragment. By default, the default top-level document is used. * @param customBundleFileName - allows modifying the filename of the widget's JS bundle that will be fetched. This property is useful during dev mode when widgets are generated together into one `main.js` file. */ function TestingTool(container, target, ownerDocument, customBundleFileName) { return _Widget.call(this, 'testingTool', container, target, ownerDocument, customBundleFileName) || this; } return TestingTool; }(Widget); var TransactionViewer = /*#__PURE__*/function (_Widget) { _inheritsLoose(TransactionViewer, _Widget); /** * # Transaction Viewer * The Transaction Viewer will be used to search for imported transactions, * check the assigned labels, correct any incorrect labels, and provide * feedback. * * @param container - parent HTML element where the widget will be injected * @param target - URL of the environment from which the widget's JS bundle will be fetched. Use this, for example, when testing features that are only released to the sandbox environment. By default, `https://widget-library-finapi-general-live.finapi.io` is used. * @param ownerDocument - parent Document where the widget will be injected. For example, shadow root or document fragment. By default, the default top-level document is used. * @param customBundleFileName - allows modifying the filename of the widget's JS bundle that will be fetched. This property is useful during dev mode when widgets are generated together into one `main.js` file. */ function TransactionViewer(container, target, ownerDocument, customBundleFileName) { return _Widget.call(this, 'transactionViewer', container, target, ownerDocument, customBundleFileName) || this; } return TransactionViewer; }(Widget); /** @internal */ var WidgetGallery = /*#__PURE__*/function (_Widget) { _inheritsLoose(WidgetGallery, _Widget); /** * # Widget Gallery * Widget Gallery is a widget in Widget Library which allows customers to * browse, try, and order Widgets offered by finAPI. It will be embedded on * the company’s homepage. * * @param container - parent HTML element where the widget will be injected * @param target - URL of the environment from which the widget's JS bundle will be fetched. Use this, for example, when testing features that are only released to the sandbox environment. By default, `https://widget-library-finapi-general-live.finapi.io` is used. * @param ownerDocument - parent Document where the widget will be injected. For example, shadow root or document fragment. By default, the default top-level document is used. * @param customBundleFileName - allows modifying the filename of the widget's JS bundle that will be fetched. This property is useful during dev mode when widgets are generated together into one `main.js` file. */ function WidgetGallery(container, target, ownerDocument, customBundleFileName) { return _Widget.call(this, 'widgetGallery', container, target, ownerDocument, customBundleFileName) || this; } return WidgetGallery; }(Widget); export { CreditCheckAccount, CreditCheckB2B, CreditCheckLoan, DigitalAccountCheck, DigitalAccountCheckB2b, GiroIdentBasis, TestingTool, TransactionViewer, WidgetGallery }; //# sourceMappingURL=finapi-js-loader.esm.js.map