UNPKG

formiojs

Version:

Common js library for client side interaction with <form.io>

133 lines (122 loc) • 2.91 MB
/******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./lib/index.js"); /******/ }) /************************************************************************/ /******/ ({ /***/ "./lib/Component.js": /*!**************************!*\ !*** ./lib/Component.js ***! \**************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\n__webpack_require__(/*! core-js/modules/es6.function.name */ \"./node_modules/core-js/modules/es6.function.name.js\");\n\n__webpack_require__(/*! core-js/modules/es6.object.assign */ \"./node_modules/core-js/modules/es6.object.assign.js\");\n\n__webpack_require__(/*! core-js/modules/es6.regexp.replace */ \"./node_modules/core-js/modules/es6.regexp.replace.js\");\n\n__webpack_require__(/*! core-js/modules/es6.regexp.constructor */ \"./node_modules/core-js/modules/es6.regexp.constructor.js\");\n\n__webpack_require__(/*! core-js/modules/es6.regexp.to-string */ \"./node_modules/core-js/modules/es6.regexp.to-string.js\");\n\n__webpack_require__(/*! core-js/modules/web.dom.iterable */ \"./node_modules/core-js/modules/web.dom.iterable.js\");\n\nvar _eventemitter = _interopRequireDefault(__webpack_require__(/*! eventemitter2 */ \"./node_modules/eventemitter2/lib/eventemitter2.js\"));\n\nvar FormioUtils = _interopRequireWildcard(__webpack_require__(/*! ./utils/utils */ \"./lib/utils/utils.js\"));\n\nvar _i18next = _interopRequireDefault(__webpack_require__(/*! i18next */ \"./node_modules/i18next/dist/es/index.js\"));\n\nvar _lodash = _interopRequireDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\n\nvar _moment = _interopRequireDefault(__webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\"));\n\nvar _vanillaTextMask = _interopRequireDefault(__webpack_require__(/*! vanilla-text-mask */ \"./node_modules/vanilla-text-mask/dist/vanillaTextMask.js\"));\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n/**\n * Root component for all elements within the renderer.\n */\nvar Component =\n/*#__PURE__*/\nfunction () {\n function Component(options, id) {\n _classCallCheck(this, Component);\n\n /**\n * The options for this component.\n * @type {{}}\n */\n this.options = _lodash.default.assign({\n language: 'en',\n highlightErrors: true,\n row: '',\n namespace: 'formio'\n }, options || {});\n /**\n * The ID of this component. This value is auto-generated when the component is created, but\n * can also be provided from the component.id value passed into the constructor.\n * @type {string}\n */\n\n this.id = id || FormioUtils.getRandomComponentId();\n /**\n * An array of event handlers so that the destry command can deregister them.\n * @type {Array}\n */\n\n this.eventHandlers = []; // Use the i18next that is passed in, otherwise use the global version.\n\n this.i18next = this.options.i18next || _i18next.default;\n /**\n * An instance of the EventEmitter class to handle the emitting and registration of events.\n *\n * @type {EventEmitter}\n */\n\n this.events = options && options.events ? options.events : new _eventemitter.default({\n wildcard: false,\n maxListeners: 0\n });\n /**\n * All of the input masks associated with this component.\n * @type {Array}\n */\n\n this.inputMasks = [];\n }\n /**\n * Register for a new event within this component.\n *\n * @example\n * let component = new BaseComponent({\n * type: 'textfield',\n * label: 'First Name',\n * key: 'firstName'\n * });\n * component.on('componentChange', (changed) => {\n * console.log('this element is changed.');\n * });\n *\n *\n * @param {string} event - The event you wish to register the handler for.\n * @param {function} cb - The callback handler to handle this event.\n * @param {boolean} internal - If this event is an \"internal\" event and should get removed when destroyed.\n * This parameter is necessary because any external \"on\" bindings should be persistent even through internal\n * redraw events which will call the \"destroy\" methods.\n */\n\n\n _createClass(Component, [{\n key: \"on\",\n value: function on(event, cb, internal) {\n if (!this.events) {\n return;\n }\n\n var type = \"\".concat(this.options.namespace, \".\").concat(event); // Store the component id in the handler so that we can determine which events are for this component.\n\n cb.id = this.id;\n cb.internal = internal; // Register for this event.\n\n return this.events.on(type, cb);\n }\n /**\n * Removes all listeners for a certain event.\n *\n * @param event\n */\n\n }, {\n key: \"off\",\n value: function off(event) {\n var _this = this;\n\n if (!this.events) {\n return;\n }\n\n var type = \"\".concat(this.options.namespace, \".\").concat(event); // Iterate through all the internal events.\n\n _lodash.default.each(this.events.listeners(type), function (listener) {\n // Ensure this event is for this component.\n if (listener && listener.id === _this.id) {\n // Turn off this event handler.\n _this.events.off(type, listener);\n }\n });\n }\n /**\n * Emit a new event.\n *\n * @param {string} event - The event to emit.\n * @param {Object} data - The data to emit with the handler.\n */\n\n }, {\n key: \"emit\",\n value: function emit(event, data) {\n if (this.events) {\n this.events.emit(\"\".concat(this.options.namespace, \".\").concat(event), data);\n }\n }\n /**\n * Wrapper method to add an event listener to an HTML element.\n *\n * @param obj\n * The DOM element to add the event to.\n * @param type\n * The event name to add.\n * @param func\n * The callback function to be executed when the listener is triggered.\n * @param persistent\n * If this listener should persist beyond \"destroy\" commands.\n */\n\n }, {\n key: \"addEventListener\",\n value: function addEventListener(obj, type, func, persistent) {\n if (!persistent) {\n this.eventHandlers.push({\n id: this.id,\n obj: obj,\n type: type,\n func: func\n });\n }\n\n if ('addEventListener' in obj) {\n obj.addEventListener(type, func, false);\n } else if ('attachEvent' in obj) {\n obj.attachEvent(\"on\".concat(type), func);\n }\n }\n /**\n * Remove an event listener from the object.\n *\n * @param obj\n * @param type\n */\n\n }, {\n key: \"removeEventListener\",\n value: function removeEventListener(obj, type) {\n var _this2 = this;\n\n var indexes = [];\n\n _lodash.default.each(this.eventHandlers, function (handler, index) {\n if (handler.id === _this2.id && obj.removeEventListener && handler.type === type) {\n obj.removeEventListener(type, handler.func);\n indexes.push(index);\n }\n });\n\n if (indexes.length) {\n _lodash.default.pullAt(this.eventHandlers, indexes);\n }\n }\n /**\n * Removes all event listeners attached to this component.\n */\n\n }, {\n key: \"destroy\",\n value: function destroy() {\n var _this3 = this;\n\n _lodash.default.each(this.events._events, function (events, type) {\n _lodash.default.each(events, function (listener) {\n if (listener && _this3.id === listener.id && listener.internal) {\n _this3.events.off(type, listener);\n }\n });\n });\n\n _lodash.default.each(this.eventHandlers, function (handler) {\n if (_this3.id === handler.id && handler.type && handler.obj && handler.obj.removeEventListener) {\n handler.obj.removeEventListener(handler.type, handler.func);\n }\n }); // Destroy the input masks.\n\n\n this.inputMasks.forEach(function (mask) {\n return mask.destroy();\n });\n this.inputMasks = [];\n }\n /**\n * Append an HTML DOM element to a container.\n *\n * @param element\n * @param container\n */\n\n }, {\n key: \"appendTo\",\n value: function appendTo(element, container) {\n if (container) {\n container.appendChild(element);\n }\n }\n /**\n * Prepend an HTML DOM element to a container.\n *\n * @param {HTMLElement} element - The DOM element to prepend.\n * @param {HTMLElement} container - The DOM element that is the container of the element getting prepended.\n */\n\n }, {\n key: \"prependTo\",\n value: function prependTo(element, container) {\n if (container) {\n if (container.firstChild) {\n try {\n container.insertBefore(element, container.firstChild);\n } catch (err) {\n console.warn(err);\n container.appendChild(element);\n }\n } else {\n container.appendChild(element);\n }\n }\n }\n /**\n * Removes an HTML DOM element from its bounding container.\n *\n * @param {HTMLElement} element - The element to remove.\n * @param {HTMLElement} container - The DOM element that is the container of the element to remove.\n */\n\n }, {\n key: \"removeChildFrom\",\n value: function removeChildFrom(element, container) {\n if (container && container.contains(element)) {\n try {\n container.removeChild(element);\n } catch (err) {\n console.warn(err);\n }\n }\n }\n /**\n * Alias for document.createElement.\n *\n * @param {string} type - The type of element to create\n * @param {Object} attr - The element attributes to add to the created element.\n * @param {Various} children - Child elements. Can be a DOM Element, string or array of both.\n *\n * @return {HTMLElement} - The created element.\n */\n\n }, {\n key: \"ce\",\n value: function ce(type, attr) {\n var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n // Create the element.\n var element = document.createElement(type); // Add attributes.\n\n if (attr) {\n this.attr(element, attr);\n } // Append the children.\n\n\n this.appendChild(element, children);\n return element;\n }\n /**\n * Append different types of children.\n *\n * @param child\n */\n\n }, {\n key: \"appendChild\",\n value: function appendChild(element, child) {\n var _this4 = this;\n\n if (Array.isArray(child)) {\n child.forEach(function (oneChild) {\n _this4.appendChild(element, oneChild);\n });\n } else if (child instanceof HTMLElement || child instanceof Text) {\n element.appendChild(child);\n } else if (child) {\n element.appendChild(this.text(child.toString()));\n }\n }\n /**\n * Creates a new input mask placeholder.\n * @param {HTMLElement} mask - The input mask.\n * @returns {string} - The placeholder that will exist within the input as they type.\n */\n\n }, {\n key: \"maskPlaceholder\",\n value: function maskPlaceholder(mask) {\n return mask.map(function (char) {\n return char instanceof RegExp ? '_' : char;\n }).join('');\n }\n /**\n * Sets the input mask for an input.\n *\n * @param {HTMLElement} input - The html input to apply the mask to.\n * @param {String} inputMask - The input mask to add to this input.\n * @param {Boolean} placeholder - Set the mask placeholder on the input.\n */\n\n }, {\n key: \"setInputMask\",\n value: function setInputMask(input, inputMask, placeholder) {\n if (input && inputMask) {\n var mask = FormioUtils.getInputMask(inputMask);\n this._inputMask = mask;\n input.mask = (0, _vanillaTextMask.default)({\n inputElement: input,\n mask: mask\n });\n\n if (mask.numeric) {\n input.setAttribute('pattern', '\\\\d*');\n }\n\n if (placeholder) {\n input.setAttribute('placeholder', this.maskPlaceholder(mask));\n }\n\n this.inputMasks.push(input.mask);\n }\n }\n /**\n * Translate a text using the i18n system.\n *\n * @param {string} text - The i18n identifier.\n * @param {Object} params - The i18n parameters to use for translation.\n */\n\n }, {\n key: \"t\",\n value: function t(text, params) {\n params = params || {};\n params.nsSeparator = '::';\n params.keySeparator = '.|.';\n params.pluralSeparator = '._.';\n params.contextSeparator = '._.';\n var translated = this.i18next.t(text, params);\n return translated || text;\n }\n /**\n * Alias to create a text node.\n * @param text\n * @returns {Text}\n */\n\n }, {\n key: \"text\",\n value: function text(_text) {\n return document.createTextNode(this.t(_text));\n }\n /**\n * Adds an object of attributes onto an element.\n * @param {HtmlElement} element - The element to add the attributes to.\n * @param {Object} attr - The attributes to add to the input element.\n */\n\n }, {\n key: \"attr\",\n value: function attr(element, _attr) {\n var _this5 = this;\n\n if (!element) {\n return;\n }\n\n _lodash.default.each(_attr, function (value, key) {\n if (typeof value !== 'undefined') {\n if (key.indexOf('on') === 0) {\n // If this is an event, add a listener.\n _this5.addEventListener(element, key.substr(2).toLowerCase(), value);\n } else {\n // Otherwise it is just an attribute.\n element.setAttribute(key, value);\n }\n }\n });\n }\n /**\n * Determines if an element has a class.\n *\n * Taken from jQuery https://j11y.io/jquery/#v=1.5.0&fn=jQuery.fn.hasClass\n */\n\n }, {\n key: \"hasClass\",\n value: function hasClass(element, className) {\n if (!element) {\n return;\n }\n\n className = \" \".concat(className, \" \");\n return \" \".concat(element.className, \" \").replace(/[\\n\\t\\r]/g, ' ').indexOf(className) > -1;\n }\n /**\n * Adds a class to a DOM element.\n *\n * @param element\n * The element to add a class to.\n * @param className\n * The name of the class to add.\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(element, className) {\n if (!element) {\n return;\n }\n\n var classes = element.getAttribute('class');\n\n if (!classes || classes.indexOf(className) === -1) {\n element.setAttribute('class', \"\".concat(classes, \" \").concat(className));\n }\n }\n /**\n * Remove a class from a DOM element.\n *\n * @param element\n * The DOM element to remove the class from.\n * @param className\n * The name of the class that is to be removed.\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(element, className) {\n if (!element) {\n return;\n }\n\n var cls = element.getAttribute('class');\n\n if (cls) {\n cls = cls.replace(new RegExp(\" \".concat(className), 'g'), '');\n element.setAttribute('class', cls);\n }\n }\n /**\n * Empty's an HTML DOM element.\n *\n * @param {HTMLElement} element - The element you wish to empty.\n */\n\n }, {\n key: \"empty\",\n value: function empty(element) {\n if (element) {\n while (element.firstChild) {\n element.removeChild(element.firstChild);\n }\n }\n }\n /**\n * Gets the classname for either Fontawesome or Bootstrap depending on their settings.\n *\n * @param name\n * @param spinning\n * @return {string}\n */\n\n }, {\n key: \"iconClass\",\n value: function iconClass(name, spinning) {\n if (!this.options.icons || this.options.icons === 'glyphicon') {\n return spinning ? \"glyphicon glyphicon-\".concat(name, \" glyphicon-spin\") : \"glyphicon glyphicon-\".concat(name);\n }\n\n switch (name) {\n case 'save':\n return 'fa fa-download';\n\n case 'zoom-in':\n return 'fa fa-search-plus';\n\n case 'zoom-out':\n return 'fa fa-search-minus';\n\n case 'question-sign':\n return 'fa fa-question-circle';\n\n case 'remove-circle':\n return 'fa fa-times-circle-o';\n\n case 'new-window':\n return 'fa fa-window-restore';\n\n default:\n return spinning ? \"fa fa-\".concat(name, \" fa-spin\") : \"fa fa-\".concat(name);\n }\n }\n /**\n * Returns an HTMLElement icon element.\n *\n * @param {string} name - The name of the icon to retrieve.\n * @returns {HTMLElement} - The icon element.\n */\n\n }, {\n key: \"getIcon\",\n value: function getIcon(name) {\n return this.ce('i', {\n class: this.iconClass(name)\n });\n }\n /**\n * Create an evaluation context for all script executions and interpolations.\n *\n * @param additional\n * @return {*}\n */\n\n }, {\n key: \"evalContext\",\n value: function evalContext(additional) {\n return Object.assign({\n _: _lodash.default,\n utils: FormioUtils,\n util: FormioUtils,\n moment: _moment.default,\n instance: this\n }, additional);\n }\n /**\n * Performs an interpolation using the evaluation context of this component.\n *\n * @param string\n * @param data\n * @return {XML|string|*|void}\n */\n\n }, {\n key: \"interpolate\",\n value: function interpolate(string, data) {\n return FormioUtils.interpolate(string, this.evalContext(data));\n }\n /**\n * Performs an evaluation using the evaluation context of this component.\n *\n * @param func\n * @param args\n * @param ret\n * @param tokenize\n * @return {*}\n */\n\n }, {\n key: \"evaluate\",\n value: function evaluate(func, args, ret, tokenize) {\n return FormioUtils.evaluate(func, this.evalContext(args), ret, tokenize);\n }\n /**\n * Allow for options to hook into the functionality of this renderer.\n * @return {*}\n */\n\n }, {\n key: \"hook\",\n value: function hook() {\n var name = arguments[0];\n\n if (this.options && this.options.hooks && this.options.hooks[name]) {\n return this.options.hooks[name].apply(this, Array.prototype.slice.call(arguments, 1));\n } else {\n // If this is an async hook instead of a sync.\n var fn = typeof arguments[arguments.length - 1] === 'function' ? arguments[arguments.length - 1] : null;\n\n if (fn) {\n return fn(null, arguments[1]);\n } else {\n return arguments[1];\n }\n }\n }\n }]);\n\n return Component;\n}();\n\nexports.default = Component;\n\n//# sourceURL=webpack:///./lib/Component.js?"); /***/ }), /***/ "./lib/Form.js": /*!*********************!*\ !*** ./lib/Form.js ***! \*********************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\n__webpack_require__(/*! core-js/modules/es6.regexp.to-string */ \"./node_modules/core-js/modules/es6.regexp.to-string.js\");\n\nvar _Formio = _interopRequireDefault(__webpack_require__(/*! ./Formio */ \"./lib/Formio.js\"));\n\nvar _Wizard = _interopRequireDefault(__webpack_require__(/*! ./Wizard */ \"./lib/Wizard.js\"));\n\nvar _PDF = _interopRequireDefault(__webpack_require__(/*! ./PDF */ \"./lib/PDF.js\"));\n\nvar _Webform = _interopRequireDefault(__webpack_require__(/*! ./Webform */ \"./lib/Webform.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Form =\n/*#__PURE__*/\nfunction () {\n /**\n * Creates an easy to use interface for embedding webforms, pdfs, and wizards into your application.\n *\n * @param {Object} element - The DOM element you wish to render this form within.\n * @param {Object | string} form - Either a Form JSON schema or the URL of a hosted form via. form.io.\n * @param {Object} options - The options to create a new form instance.\n * @param {boolean} options.readOnly - Set this form to readOnly\n * @param {boolean} options.noAlerts - Set to true to disable the alerts dialog.\n * @param {boolean} options.i18n - The translation file for this rendering. @see https://github.com/formio/formio.js/blob/master/i18n.js\n * @param {boolean} options.template - Provides a way to inject custom logic into the creation of every element rendered within the form.\n *\n * @example\n * import Form from 'formiojs/Form';\n * const form = new Form(document.getElementById('formio'), 'https://examples.form.io/example');\n * form.render();\n */\n function Form(element, form, options) {\n _classCallCheck(this, Form);\n\n this.instance = null;\n this.element = element;\n this.form = form;\n this.options = options;\n }\n\n _createClass(Form, [{\n key: \"create\",\n value: function create() {\n if (this.form.display === 'wizard') {\n return new _Wizard.default(this.element, this.options);\n } else if (this.form.display === 'pdf') {\n return new _PDF.default(this.element, this.options);\n } else {\n return new _Webform.default(this.element, this.options);\n }\n }\n }, {\n key: \"setForm\",\n value: function setForm(formParam) {\n var _this = this;\n\n formParam = formParam || this.form;\n this.element.innerHTML = '';\n\n if (typeof formParam === 'string') {\n return new _Formio.default(formParam).loadForm().then(function (form) {\n _this.form = form;\n\n if (_this.instance) {\n _this.instance.destroy();\n }\n\n _this.instance = _this.create();\n _this.instance.url = formParam;\n _this.instance.nosubmit = false;\n\n _this.instance.loadSubmission();\n\n _this.form = _this.instance.form = form;\n return _this.instance.ready.then(function () {\n return _this.instance;\n });\n });\n } else {\n this.form = formParam;\n\n if (this.instance) {\n this.instance.destroy();\n }\n\n this.instance = this.create();\n this.instance.form = this.form;\n return this.instance.ready.then(function () {\n return _this.instance;\n });\n }\n }\n }, {\n key: \"setDisplay\",\n value: function setDisplay(display) {\n this.form.display = display;\n return this.render();\n }\n }, {\n key: \"render\",\n value: function render(form) {\n return this.setForm(form);\n }\n }], [{\n key: \"embed\",\n value: function embed(_embed) {\n if (!_embed || !_embed.src) {\n return null;\n }\n\n var id = this.id || \"formio-\".concat(Math.random().toString(36).substring(7));\n var className = _embed.class || 'formio-form-wrapper'; // Add the styles to the header.\n\n if (_embed.styles) {\n var link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = _embed.styles;\n document.head.appendChild(link);\n }\n\n document.write(\"<div id=\\\"\".concat(id, \"\\\" class=\\\"\").concat(className, \"\\\"></div>\"));\n var formElement = document.getElementById(id);\n return new Form(formElement, _embed.src).render();\n }\n }]);\n\n return Form;\n}(); // Allow simple embedding.\n\n\nexports.default = Form;\n\n_Formio.default.embedForm = function (embed) {\n return Form.embed(embed);\n};\n/**\n * Creates a new form based on the form parameter.\n *\n * @param element {HMTLElement} - The HTML Element to add this form to.\n * @param form {string|Object} - The src of the form, or a form object.\n * @param options {Object} - The options to create this form.\n *\n * @return {Promise} - When the form is instance is ready.\n */\n\n\n_Formio.default.createForm = function (element, form, options) {\n return new Form(element, form, options).render();\n};\n\n_Formio.default.Form = Form;\n\n//# sourceURL=webpack:///./lib/Form.js?"); /***/ }), /***/ "./lib/FormBuilder.js": /*!****************************!*\ !*** ./lib/FormBuilder.js ***! \****************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\n__webpack_require__(/*! core-js/modules/es7.symbol.async-iterator */ \"./node_modules/core-js/modules/es7.symbol.async-iterator.js\");\n\n__webpack_require__(/*! core-js/modules/es6.symbol */ \"./node_modules/core-js/modules/es6.symbol.js\");\n\nvar _Formio = _interopRequireDefault(__webpack_require__(/*! ./Formio */ \"./lib/Formio.js\"));\n\nvar _WebformBuilder = _interopRequireDefault(__webpack_require__(/*! ./WebformBuilder */ \"./lib/WebformBuilder.js\"));\n\nvar _WizardBuilder = _interopRequireDefault(__webpack_require__(/*! ./WizardBuilder */ \"./lib/WizardBuilder.js\"));\n\nvar _PDFBuilder = _interopRequireDefault(__webpack_require__(/*! ./PDFBuilder */ \"./lib/PDFBuilder.js\"));\n\nvar _Form2 = _interopRequireDefault(__webpack_require__(/*! ./Form */ \"./lib/Form.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nvar FormBuilder =\n/*#__PURE__*/\nfunction (_Form) {\n _inherits(FormBuilder, _Form);\n\n /**\n * Creates an easy to use interface for embedding a form builder into your application..\n *\n * @param {Object} element - The DOM element you wish to render this form within.\n * @param {Object | string} form - Either a Form JSON schema or the URL of a hosted form via. form.io.\n * @param {Object} options - The options to create a new form instance.\n * @param {boolean} options.readOnly - Set this form to readOnly\n * @param {boolean} options.noAlerts - Set to true to disable the alerts dialog.\n * @param {boolean} options.i18n - The translation file for this rendering. @see https://github.com/formio/formio.js/blob/master/i18n.js\n * @param {boolean} options.template - Provides a way to inject custom logic into the creation of every element rendered within the form.\n *\n * @example\n * import Form from 'formiojs/FormBuilder';\n * const builder = new FormBuilder(document.getElementById('formio'), {components:[\n * {\n * type: 'textfield',\n * label: 'First Name',\n * key: 'firstName',\n * input: true\n * }\n * ]});\n * builder.render();\n */\n function FormBuilder(element, form, options) {\n _classCallCheck(this, FormBuilder);\n\n return _possibleConstructorReturn(this, _getPrototypeOf(FormBuilder).call(this, element, form, options));\n }\n\n _createClass(FormBuilder, [{\n key: \"create\",\n value: function create() {\n if (!this.form.components) {\n this.form.components = [];\n }\n\n if (this.form.display === 'wizard') {\n return new _WizardBuilder.default(this.element, this.options);\n } else if (this.form.display === 'pdf') {\n return new _PDFBuilder.default(this.element, this.options);\n } else {\n return new _WebformBuilder.default(this.element, this.options);\n }\n }\n }]);\n\n return FormBuilder;\n}(_Form2.default);\n/**\n * Creates a new form based on the form parameter.\n *\n * @param element {HMTLElement} - The HTML Element to add this form to.\n * @param form {string|Object} - The src of the form, or a form object.\n * @param options {Object} - The options to create this form.\n *\n * @return {Promise} - When the form is instance is ready.\n */\n\n\nexports.default = FormBuilder;\n\n_Formio.default.builder = function (element, form, options) {\n var builder = new FormBuilder(element, form, options);\n return builder.render();\n};\n\n_Formio.default.FormBuilder = FormBuilder;\n\n//# sourceURL=webpack:///./lib/FormBuilder.js?"); /***/ }), /***/ "./lib/Formio.js": /*!***********************!*\ !*** ./lib/Formio.js ***! \***********************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("/* WEBPACK VAR INJECTION */(function(global) {\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\n__webpack_require__(/*! core-js/modules/es6.function.name */ \"./node_modules/core-js/modules/es6.function.name.js\");\n\n__webpack_require__(/*! core-js/modules/es7.symbol.async-iterator */ \"./node_modules/core-js/modules/es7.symbol.async-iterator.js\");\n\n__webpack_require__(/*! core-js/modules/es6.symbol */ \"./node_modules/core-js/modules/es6.symbol.js\");\n\n__webpack_require__(/*! core-js/modules/es6.number.constructor */ \"./node_modules/core-js/modules/es6.number.constructor.js\");\n\n__webpack_require__(/*! core-js/modules/web.dom.iterable */ \"./node_modules/core-js/modules/web.dom.iterable.js\");\n\n__webpack_require__(/*! core-js/modules/es6.array.iterator */ \"./node_modules/core-js/modules/es6.array.iterator.js\");\n\n__webpack_require__(/*! core-js/modules/es6.string.iterator */ \"./node_modules/core-js/modules/es6.string.iterator.js\");\n\n__webpack_require__(/*! core-js/modules/es6.object.assign */ \"./node_modules/core-js/modules/es6.object.assign.js\");\n\n__webpack_require__(/*! core-js/modules/es7.array.includes */ \"./node_modules/core-js/modules/es7.array.includes.js\");\n\n__webpack_require__(/*! core-js/modules/es6.string.includes */ \"./node_modules/core-js/modules/es6.string.includes.js\");\n\n__webpack_require__(/*! core-js/modules/es6.regexp.replace */ \"./node_modules/core-js/modules/es6.regexp.replace.js\");\n\n__webpack_require__(/*! core-js/modules/es6.regexp.constructor */ \"./node_modules/core-js/modules/es6.regexp.constructor.js\");\n\n__webpack_require__(/*! core-js/modules/es6.regexp.split */ \"./node_modules/core-js/modules/es6.regexp.split.js\");\n\n__webpack_require__(/*! core-js/modules/es6.regexp.search */ \"./node_modules/core-js/modules/es6.regexp.search.js\");\n\n__webpack_require__(/*! core-js/modules/es6.regexp.match */ \"./node_modules/core-js/modules/es6.regexp.match.js\");\n\nvar _nativePromiseOnly = _interopRequireDefault(__webpack_require__(/*! native-promise-only */ \"./node_modules/native-promise-only/lib/npo.src.js\"));\n\n__webpack_require__(/*! whatwg-fetch */ \"./node_modules/whatwg-fetch/fetch.js\");\n\nvar _eventemitter = __webpack_require__(/*! eventemitter2 */ \"./node_modules/eventemitter2/lib/eventemitter2.js\");\n\nvar _browserCookies = _interopRequireDefault(__webpack_require__(/*! browser-cookies */ \"./node_modules/browser-cookies/src/browser-cookies.js\"));\n\nvar _shallowCopy = _interopRequireDefault(__webpack_require__(/*! shallow-copy */ \"./node_modules/shallow-copy/index.js\"));\n\nvar providers = _interopRequireWildcard(__webpack_require__(/*! ./providers */ \"./lib/providers/index.js\"));\n\nvar _get2 = _interopRequireDefault(__webpack_require__(/*! lodash/get */ \"./node_modules/lodash/get.js\"));\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar isBoolean = function isBoolean(val) {\n return _typeof(val) === _typeof(true);\n};\n\nvar isNil = function isNil(val) {\n return val === null || val === undefined;\n};\n\nvar isObject = function isObject(val) {\n return val && _typeof(val) === 'object';\n};\n/**\n * The Formio interface class.\n *\n * let formio = new Formio('https://examples.form.io/example');\n */\n\n\nvar Formio =\n/*#__PURE__*/\nfunction () {\n /* eslint-disable max-statements */\n function Formio(path) {\n var _this = this;\n\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, Formio);\n\n // Ensure we have an instance of Formio.\n if (!(this instanceof Formio)) {\n return new Formio(path);\n } // Initialize our variables.\n\n\n this.base = '';\n this.projectsUrl = '';\n this.projectUrl = '';\n this.projectId = '';\n this.formUrl = '';\n this.formsUrl = '';\n this.formId = '';\n this.submissionsUrl = '';\n this.submissionUrl = '';\n this.submissionId = '';\n this.actionsUrl = '';\n this.actionId = '';\n this.actionUrl = '';\n this.vsUrl = '';\n this.vId = '';\n this.vUrl = '';\n this.query = ''; // Store the original path and options.\n\n this.path = path;\n this.options = options;\n\n if (options.hasOwnProperty('base')) {\n this.base = options.base;\n } else if (Formio.baseUrl) {\n this.base = Formio.baseUrl;\n } else {\n this.base = window.location.href.match(/http[s]?:\\/\\/api./)[0];\n }\n\n if (!path) {\n // Allow user to create new projects if this was instantiated without\n // a url\n this.projectUrl = \"\".concat(this.base, \"/project\");\n this.projectsUrl = \"\".concat(this.base, \"/project\");\n this.projectId = false;\n this.query = '';\n return;\n }\n\n if (options.hasOwnProperty('project')) {\n this.projectUrl = options.project;\n }\n\n var project = this.projectUrl || Formio.projectUrl;\n var projectRegEx = /(^|\\/)(project)($|\\/[^/]+)/;\n var isProjectUrl = path.search(projectRegEx) !== -1; // The baseURL is the same as the projectUrl, and does not contain \"/project/MONGO_ID\" in\n // its domain. This is almost certainly against the Open Source server.\n\n if (project && this.base === project && !isProjectUrl) {\n this.noProject = true;\n this.projectUrl = this.base;\n } // Normalize to an absolute path.\n\n\n if (path.indexOf('http') !== 0 && path.indexOf('//') !== 0) {\n path = this.base + path;\n }\n\n var hostparts = this.getUrlParts(path);\n var parts = [];\n var hostName = hostparts[1] + hostparts[2];\n path = hostparts.length > 3 ? hostparts[3] : '';\n var queryparts = path.split('?');\n\n if (queryparts.length > 1) {\n path = queryparts[0];\n this.query = \"?\".concat(queryparts[1]);\n } // Register a specific path.\n\n\n var registerPath = function registerPath(name, base) {\n _this[\"\".concat(name, \"sUrl\")] = \"\".concat(base, \"/\").concat(name);\n var regex = new RegExp(\"/\".concat(name, \"/([^/]+)\"));\n\n if (path.search(regex) !== -1) {\n parts = path.match(regex);\n _this[\"\".concat(name, \"Url\")] = parts ? base + parts[0] : '';\n _this[\"\".concat(name, \"Id\")] = parts.length > 1 ? parts[1] : '';\n base += parts[0];\n }\n\n return base;\n }; // Register an array of items.\n\n\n var registerItems = function registerItems(items, base, staticBase) {\n for (var i in items) {\n if (items.hasOwnProperty(i)) {\n var item = items[i];\n\n if (Array.isArray(item)) {\n registerItems(item, base, true);\n } else {\n var newBase = registerPath(item, base);\n base = staticBase ? base : newBase;\n }\n }\n }\n };\n\n if (!this.projectUrl || this.projectUrl === this.base) {\n this.projectUrl = hostName;\n }\n\n if (!this.noProject) {\n // Determine the projectUrl and projectId\n if (isProjectUrl) {\n // Get project id as project/:projectId.\n registerItems(['project'], hostName);\n path = path.replace(projectRegEx, '');\n } else if (hostName === this.base) {\n // Get project id as first part of path (subdirectory).\n if (hostparts.length > 3 && path.split('/').length > 1) {\n var pathParts = path.split('/');\n pathParts.shift(); // Throw away the first /.\n\n this.projectId = pathParts.shift();\n path = \"/\".concat(pathParts.join('/'));\n this.projectUrl = \"\".concat(hostName, \"/\").concat(this.projectId);\n }\n } else {\n // Get project id from subdomain.\n if (hostparts.length > 2 && (hostparts[2].split('.').length > 2 || hostName.includes('localhost'))) {\n this.projectUrl = hostName;\n this.projectId = hostparts[2].split('.')[0];\n }\n }\n\n this.projectsUrl = this.projectsUrl || \"\".concat(this.base, \"/project\");\n } // Configure Form urls and form ids.\n\n\n if (path.search(/(^|\\/)(form)($|\\/)/) !== -1) {\n registerItems(['form', ['submission', 'action', 'v']], this.projectUrl);\n } else {\n var subRegEx = new RegExp('/(submission|action|v)($|/.*)');\n var subs = path.match(subRegEx);\n this.pathType = subs && subs.length > 1 ? subs[1] : '';\n path = path.replace(subRegEx, '');\n path = path.replace(/\\/$/, '');\n this.formsUrl = \"\".concat(this.projectUrl, \"/form\");\n this.formUrl = path ? this.projectUrl + path : '';\n this.formId = path.replace(/^\\/+|\\/+$/g, '');\n var items = ['submission', 'action', 'v'];\n\n for (var i in items) {\n if (items.hasOwnProperty(i)) {\n var item = items[i];\n this[\"\".concat(item, \"sUrl\")] = \"\".concat(this.projectUrl + path, \"/\").concat(item);\n\n if (this.pathType === item && subs.length > 2 && subs[2]) {\n this[\"\".concat(item, \"Id\")] = subs[2].replace(/^\\/+|\\/+$/g, '');\n this[\"\".concat(item, \"Url\")] = this.projectUrl + path + subs[0];\n }\n }\n }\n } // Set the app url if it is not set.\n\n\n if (!Formio.projectUrlSet) {\n Formio.projectUrl = this.projectUrl;\n }\n }\n /* eslint-enable max-statements */\n\n\n _createClass(Formio, [{\n key: \"delete\",\n value: function _delete(type, opts) {\n var _id = \"\".concat(type, \"Id\");\n\n var _url = \"\".concat(type, \"Url\");\n\n if (!this[_id]) {\n _nativePromiseOnly.default.reject('Nothing to delete');\n }\n\n Formio.cache = {};\n return this.makeRequest(type, this[_url], 'delete', null, opts);\n }\n }, {\n key: \"index\",\n value: function index(type, query, opts) {\n var _url = \"\".concat(type, \"Url\");\n\n query = query || '';\n\n if (query && isObject(query)) {\n query = \"?\".concat(Formio.serialize(query.params));\n }\n\n return this.makeRequest(type, this[_url] + query, 'get', null, opts);\n }\n }, {\n key: \"save\",\n value: function save(type, data, opts) {\n var _id = \"\".concat(type, \"Id\");\n\n var _url = \"\".concat(type, \"Url\");\n\n var method = this[_id] || data._id ? 'put' : 'post';\n var reqUrl = this[_id] ? this[_url] : this[\"\".concat(type, \"sUrl\")];\n\n if (!this[_id] && data._id && method === 'put' && !reqUrl.includes(data._id)) {\n reqUrl += \"/\".concat(data._id);\n }\n\n Formio.cache = {};\n return this.makeRequest(type, reqUrl + this.query, method, data, opts);\n }\n }, {\n key: \"load\",\n value: function load(type, query, opts) {\n var _id = \"\".concat(type, \"Id\");\n\n var _url = \"\".concat(type, \"Url\");\n\n if (query && isObject(query)) {\n query = Formio.serialize(query.params);\n }\n\n if (query) {\n query = this.query ? \"\".concat(this.query, \"&\").concat(query) : \"?\".concat(query);\n } else {\n query = this.query;\n }\n\n if (!this[_id]) {\n return _nativePromiseOnly.default.reject(\"Missing \".concat(_id));\n }\n\n return this.makeRequest(type, this[_url] + query, 'get', null, opts);\n }\n }, {\n key: \"makeRequest\",\n value: function makeRequest() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return Formio.makeRequest.apply(Formio, [this].concat(args));\n }\n }, {\n key: \"loadProject\",\n value: function loadProject(query, opts) {\n return this.load('project', query, opts);\n }\n }, {\n key: \"saveProject\",\n value: function saveProject(data, opts) {\n return this.save('project', data, opts);\n }\n }, {\n key: \"delet