@formio/js 5.0.0-rc.93 → 5.0.0-rc.95
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +96 -85
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.js +96 -85
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +203 -11
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +3 -1
- package/dist/formio.utils.js +77 -66
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/components/editgrid/EditGrid.js +6 -8
- package/lib/cjs/components/editgrid/fixtures/comp20.d.ts +43 -0
- package/lib/cjs/components/editgrid/fixtures/comp20.js +44 -0
- package/lib/cjs/components/editgrid/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/editgrid/fixtures/index.js +3 -1
- package/lib/cjs/components/number/Number.js +7 -1
- package/lib/cjs/components/number/fixtures/index.js +1 -1
- package/lib/cjs/components/number/fixtures/scientificNotation.d.ts +14 -0
- package/lib/cjs/components/number/fixtures/scientificNotation.js +15 -0
- package/lib/cjs/components/select/Select.d.ts +1 -1
- package/lib/cjs/components/select/Select.js +12 -5
- package/lib/mjs/components/editgrid/EditGrid.js +6 -8
- package/lib/mjs/components/editgrid/fixtures/comp20.d.ts +43 -0
- package/lib/mjs/components/editgrid/fixtures/comp20.js +42 -0
- package/lib/mjs/components/editgrid/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/editgrid/fixtures/index.js +2 -1
- package/lib/mjs/components/number/Number.js +7 -1
- package/lib/mjs/components/number/fixtures/index.js +1 -1
- package/lib/mjs/components/number/fixtures/scientificNotation.d.ts +14 -0
- package/lib/mjs/components/number/fixtures/scientificNotation.js +13 -0
- package/lib/mjs/components/select/Select.d.ts +1 -1
- package/lib/mjs/components/select/Select.js +11 -4
- package/package.json +4 -4
package/dist/formio.form.js
CHANGED
@@ -36,7 +36,7 @@ eval("/*! @formio/choices.js v10.2.1 | © 2024 Josh Johnson | https://github.com
|
|
36
36
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
37
37
|
|
38
38
|
"use strict";
|
39
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.FieldError = void 0;\nconst util_1 = __webpack_require__(/*! ../process/validation/util */ \"./node_modules/@formio/core/lib/process/validation/util.js\");\nclass FieldError {\n constructor(errorKeyOrMessage, context, ruleName = errorKeyOrMessage) {\n var _a;\n const { component, hasLabel = true, field = (0, util_1.getComponentErrorField)(component, context), level = 'error' } = context;\n this.ruleName = ruleName;\n if ((_a = context.component.validate) === null || _a === void 0 ? void 0 : _a.customMessage) {\n this.errorKeyOrMessage = context.component.validate.customMessage;\n this.context = Object.assign(Object.assign({}, context), { hasLabel: false, field, level });\n }\n else {\n this.errorKeyOrMessage = errorKeyOrMessage;\n this.context = Object.assign(Object.assign({}, context), { hasLabel, field });\n this.level = level;\n }\n }\n}\nexports.FieldError = FieldError;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/error/FieldError.js?");
|
39
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.FieldError = void 0;\nconst util_1 = __webpack_require__(/*! ../process/validation/util */ \"./node_modules/@formio/core/lib/process/validation/util.js\");\nclass FieldError {\n constructor(errorKeyOrMessage, context, ruleName = errorKeyOrMessage) {\n var _a;\n const { component, hasLabel = true, field = (0, util_1.getComponentErrorField)(component, context), level = 'error', } = context;\n this.ruleName = ruleName;\n if ((_a = context.component.validate) === null || _a === void 0 ? void 0 : _a.customMessage) {\n this.errorKeyOrMessage = context.component.validate.customMessage;\n this.context = Object.assign(Object.assign({}, context), { hasLabel: false, field, level });\n }\n else {\n this.errorKeyOrMessage = errorKeyOrMessage;\n this.context = Object.assign(Object.assign({}, context), { hasLabel, field });\n this.level = level;\n }\n }\n}\nexports.FieldError = FieldError;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/error/FieldError.js?");
|
40
40
|
|
41
41
|
/***/ }),
|
42
42
|
|
@@ -47,7 +47,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
47
47
|
/***/ (function(__unused_webpack_module, exports) {
|
48
48
|
|
49
49
|
"use strict";
|
50
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ProcessorError = void 0;\nclass ProcessorError extends Error {\n constructor(message, context, processor = 'unknown') {\n super(message);\n this.message = `${message}\\nin ${processor} at ${context.path}`;\n const { component, path, data, row } = context;\n this.context = { component, path, data, row };\n }\n}\nexports.ProcessorError = ProcessorError;\n
|
50
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ProcessorError = void 0;\nclass ProcessorError extends Error {\n constructor(message, context, processor = 'unknown') {\n super(message);\n this.message = `${message}\\nin ${processor} at ${context.path}`;\n const { component, path, data, row } = context;\n this.context = { component, path, data, row };\n }\n}\nexports.ProcessorError = ProcessorError;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/error/ProcessorError.js?");
|
51
51
|
|
52
52
|
/***/ }),
|
53
53
|
|
@@ -91,7 +91,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
91
91
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
92
92
|
|
93
93
|
"use strict";
|
94
|
-
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Component = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst Components_1 = __webpack_require__(/*! ../Components */ \"./node_modules/@formio/core/lib/experimental/base/Components.js\");\nconst template_1 = __webpack_require__(/*! ../../template */ \"./node_modules/@formio/core/lib/experimental/template/index.js\");\nconst Evaluator_1 = __webpack_require__(/*! ../../../utils/Evaluator */ \"./node_modules/@formio/core/lib/utils/Evaluator.js\");\nconst dom = __importStar(__webpack_require__(/*! ../../../utils/dom */ \"./node_modules/@formio/core/lib/utils/dom.js\"));\nconst sanitize_1 = __webpack_require__(/*! ../../../utils/sanitize */ \"./node_modules/@formio/core/lib/utils/sanitize.js\");\nconst model_1 = __webpack_require__(/*! ../../model */ \"./node_modules/@formio/core/lib/experimental/model/index.js\");\nfunction Component(props = {}) {\n props = (0, lodash_1.merge)({\n type: 'component',\n template: false,\n schema: {\n persistent: true,\n protected: false,\n }\n }, props);\n props.schema.type = props.type;\n const ModelClass = props.model || model_1.Model;\n return function (BaseClass) {\n return class ExtendedComponent extends ModelClass(props)(BaseClass) {\n constructor() {\n super(...arguments);\n /**\n * Boolean to let us know if this component is attached to the DOM or not.\n */\n this.attached = false;\n /**\n * The DOM element references used for component logic.\n */\n this.refs = {};\n /**\n * The template to render for this component.\n */\n this.template = props.template;\n /**\n * An array of attached listeners.\n */\n this.attachedListeners = [];\n }\n get defaultOptions() {\n return {\n language: 'en',\n namespace: 'formio'\n };\n }\n get defaultTemplate() {\n return (ctx) => `<span>${ctx.t('Unknown Component')}</span>`;\n }\n /**\n * Interpolate a template string.\n * @param template - The template string to interpolate.\n * @param context - The context variables to pass to the interpolation.\n */\n interpolate(template, context) {\n return Evaluator_1.Evaluator.interpolate(template, context);\n }\n /**\n * The rendering context.\n * @param context - The existing contexts from parent classes.\n */\n renderContext(context = {}) {\n if (super.renderContext) {\n return super.renderContext(context);\n }\n return context;\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 evaluate(func, args = {}, ret = '', tokenize = false) {\n return Evaluator_1.Evaluator.evaluate(func, this.evalContext(args), ret, tokenize);\n }\n /**\n * Renders this component as an HTML string.\n */\n render(context = {}) {\n if (super.render) {\n return super.render(context);\n }\n return this.renderTemplate((this.template || this.component.type), this.renderContext(context));\n }\n /**\n * Returns the template references.\n */\n getRefs() {\n if (super.getRefs) {\n return super.getRefs();\n }\n return {};\n }\n /**\n * Loads the elemement references.\n * @param element\n */\n loadRefs(element) {\n const refs = this.getRefs();\n for (const ref in refs) {\n if (refs[ref] === 'single') {\n this.refs[ref] = element.querySelector(`[ref=\"${ref}\"]`);\n }\n else {\n this.refs[ref] = element.querySelectorAll(`[ref=\"${ref}\"]`);\n }\n }\n }\n /**\n * Renders the component and then attaches this component to the HTMLElement.\n * @param element\n */\n attach(element) {\n const _super = Object.create(null, {\n attach: { get: () => super.attach }\n });\n return __awaiter(this, void 0, void 0, function* () {\n if (this.element && !element) {\n element = this.element;\n }\n if (!element) {\n return this;\n }\n const parent = element.parentNode;\n if (!parent) {\n return this;\n }\n const index = Array.prototype.indexOf.call(parent.children, element);\n element.outerHTML = String(this.sanitize(this.render()));\n element = parent.children[index];\n this.element = element;\n this.loadRefs(this.element);\n if (_super.attach) {\n yield _super.attach.call(this, element);\n }\n this.attached = true;\n return this;\n });\n }\n /**\n * Redraw this component.\n * @returns\n */\n redraw() {\n return __awaiter(this, void 0, void 0, function* () {\n if (this.element) {\n this.clear();\n return this.attach();\n }\n });\n }\n /**\n * Sanitize an html string.\n *\n * @param string\n * @returns {*}\n */\n sanitize(dirty) {\n return (0, sanitize_1.sanitize)(dirty, this.options);\n }\n /**\n * Get all available translations.\n */\n get translations() {\n if (this.options.language &&\n this.options.i18n &&\n this.options.i18n[this.options.language]) {\n return this.options.i18n[this.options.language];\n }\n return {};\n }\n /**\n * Tranlation method to translate a string being rendered.\n * @param str\n */\n t(str) {\n if (this.translations[str]) {\n return this.translations[str];\n }\n return str;\n }\n /**\n * The evaluation context for interpolations.\n * @param extend\n */\n evalContext(extend = {}) {\n return Object.assign({\n instance: this,\n component: this.component,\n options: this.options,\n row: this.data,\n data: this.root ? this.root.data : this.data,\n rowIndex: this.rowIndex,\n value: () => this.dataValue,\n t: (str) => this.t(str)\n }, extend);\n }\n /**\n * Render a template with provided context.\n * @param name\n * @param ctx\n */\n renderTemplate(name, ctx = {}) {\n return template_1.Template.render(name, this.evalContext(ctx), 'html', this.defaultTemplate);\n }\n /**\n * Determines if the value of this component is redacted from the user as if it is coming from the server, but is protected.\n *\n * @return {boolean|*}\n */\n isValueRedacted() {\n return (this.component.protected ||\n !this.component.persistent ||\n (this.component.persistent === 'client-only'));\n }\n /**\n * Sets the data value and updates the view representation.\n * @param value\n */\n setValue(value) {\n let changed = false;\n if (super.setValue) {\n changed = super.setValue(value);\n }\n return this.updateValue(value) || changed;\n }\n /**\n * Returns the main HTML Element for this component.\n */\n getElement() {\n return this.element;\n }\n /**\n * Remove all event handlers.\n */\n detach() {\n this.refs = {};\n this.attached = false;\n this.removeAttachedListeners();\n if (super.detach) {\n super.detach();\n }\n }\n /**\n * Clear an element.\n */\n clear() {\n this.detach();\n dom.empty(this.getElement());\n if (super.clear) {\n super.clear();\n }\n }\n /**\n * Appends an element to this component.\n * @param element\n */\n append(element) {\n dom.appendTo(element, this.element);\n }\n /**\n * Prepends an element to this component.\n * @param element\n */\n prepend(element) {\n dom.prependTo(element, this.element);\n }\n /**\n * Removes an element from this component.\n * @param element\n */\n removeChild(element) {\n dom.removeChildFrom(element, this.element);\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 addEventListener(obj, type, func) {\n if (!obj) {\n return;\n }\n if ('addEventListener' in obj) {\n obj.addEventListener(type, func, false);\n }\n else if ('attachEvent' in obj) {\n obj.attachEvent(`on${type}`, func);\n }\n this.attachedListeners.push({ obj, type, func });\n return this;\n }\n /**\n * Remove all the attached listeners.\n */\n removeAttachedListeners() {\n this.attachedListeners.forEach((item) => this.removeEventListener(item.obj, item.type, item.func));\n this.attachedListeners = [];\n }\n /**\n * Remove an event listener from the object.\n *\n * @param obj\n * @param type\n */\n removeEventListener(obj, type, func) {\n if (obj) {\n obj.removeEventListener(type, func);\n }\n return this;\n }\n };\n };\n}\nexports.Component = Component;\n// Add the default component.\nComponents_1.Components.addDecorator(Component, 'component');\nComponents_1.Components.addComponent(Component()(), 'component');\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/base/component/Component.js?");
|
94
|
+
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Component = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst Components_1 = __webpack_require__(/*! ../Components */ \"./node_modules/@formio/core/lib/experimental/base/Components.js\");\nconst template_1 = __webpack_require__(/*! ../../template */ \"./node_modules/@formio/core/lib/experimental/template/index.js\");\nconst Evaluator_1 = __webpack_require__(/*! ../../../utils/Evaluator */ \"./node_modules/@formio/core/lib/utils/Evaluator.js\");\nconst dom = __importStar(__webpack_require__(/*! ../../../utils/dom */ \"./node_modules/@formio/core/lib/utils/dom.js\"));\nconst sanitize_1 = __webpack_require__(/*! ../../../utils/sanitize */ \"./node_modules/@formio/core/lib/utils/sanitize.js\");\nconst model_1 = __webpack_require__(/*! ../../model */ \"./node_modules/@formio/core/lib/experimental/model/index.js\");\nfunction Component(props = {}) {\n props = (0, lodash_1.merge)({\n type: 'component',\n template: false,\n schema: {\n persistent: true,\n protected: false,\n },\n }, props);\n props.schema.type = props.type;\n const ModelClass = props.model || model_1.Model;\n return function (BaseClass) {\n return class ExtendedComponent extends ModelClass(props)(BaseClass) {\n constructor() {\n super(...arguments);\n /**\n * Boolean to let us know if this component is attached to the DOM or not.\n */\n this.attached = false;\n /**\n * The DOM element references used for component logic.\n */\n this.refs = {};\n /**\n * The template to render for this component.\n */\n this.template = props.template;\n /**\n * An array of attached listeners.\n */\n this.attachedListeners = [];\n }\n get defaultOptions() {\n return {\n language: 'en',\n namespace: 'formio',\n };\n }\n get defaultTemplate() {\n return (ctx) => `<span>${ctx.t('Unknown Component')}</span>`;\n }\n /**\n * Interpolate a template string.\n * @param template - The template string to interpolate.\n * @param context - The context variables to pass to the interpolation.\n */\n interpolate(template, context) {\n return Evaluator_1.Evaluator.interpolate(template, context);\n }\n /**\n * The rendering context.\n * @param context - The existing contexts from parent classes.\n */\n renderContext(context = {}) {\n if (super.renderContext) {\n return super.renderContext(context);\n }\n return context;\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 evaluate(func, args = {}, ret = '', tokenize = false) {\n return Evaluator_1.Evaluator.evaluate(func, this.evalContext(args), ret, tokenize);\n }\n /**\n * Renders this component as an HTML string.\n */\n render(context = {}) {\n if (super.render) {\n return super.render(context);\n }\n return this.renderTemplate(this.template || this.component.type, this.renderContext(context));\n }\n /**\n * Returns the template references.\n */\n getRefs() {\n if (super.getRefs) {\n return super.getRefs();\n }\n return {};\n }\n /**\n * Loads the elemement references.\n * @param element\n */\n loadRefs(element) {\n const refs = this.getRefs();\n for (const ref in refs) {\n if (refs[ref] === 'single') {\n this.refs[ref] = element.querySelector(`[ref=\"${ref}\"]`);\n }\n else {\n this.refs[ref] = element.querySelectorAll(`[ref=\"${ref}\"]`);\n }\n }\n }\n /**\n * Renders the component and then attaches this component to the HTMLElement.\n * @param element\n */\n attach(element) {\n const _super = Object.create(null, {\n attach: { get: () => super.attach }\n });\n return __awaiter(this, void 0, void 0, function* () {\n if (this.element && !element) {\n element = this.element;\n }\n if (!element) {\n return this;\n }\n const parent = element.parentNode;\n if (!parent) {\n return this;\n }\n const index = Array.prototype.indexOf.call(parent.children, element);\n element.outerHTML = String(this.sanitize(this.render()));\n element = parent.children[index];\n this.element = element;\n this.loadRefs(this.element);\n if (_super.attach) {\n yield _super.attach.call(this, element);\n }\n this.attached = true;\n return this;\n });\n }\n /**\n * Redraw this component.\n * @returns\n */\n redraw() {\n return __awaiter(this, void 0, void 0, function* () {\n if (this.element) {\n this.clear();\n return this.attach();\n }\n });\n }\n /**\n * Sanitize an html string.\n *\n * @param string\n * @returns {*}\n */\n sanitize(dirty) {\n return (0, sanitize_1.sanitize)(dirty, this.options);\n }\n /**\n * Get all available translations.\n */\n get translations() {\n if (this.options.language &&\n this.options.i18n &&\n this.options.i18n[this.options.language]) {\n return this.options.i18n[this.options.language];\n }\n return {};\n }\n /**\n * Tranlation method to translate a string being rendered.\n * @param str\n */\n t(str) {\n if (this.translations[str]) {\n return this.translations[str];\n }\n return str;\n }\n /**\n * The evaluation context for interpolations.\n * @param extend\n */\n evalContext(extend = {}) {\n return Object.assign({\n instance: this,\n component: this.component,\n options: this.options,\n row: this.data,\n data: this.root ? this.root.data : this.data,\n rowIndex: this.rowIndex,\n value: () => this.dataValue,\n t: (str) => this.t(str),\n }, extend);\n }\n /**\n * Render a template with provided context.\n * @param name\n * @param ctx\n */\n renderTemplate(name, ctx = {}) {\n return template_1.Template.render(name, this.evalContext(ctx), 'html', this.defaultTemplate);\n }\n /**\n * Determines if the value of this component is redacted from the user as if it is coming from the server, but is protected.\n *\n * @return {boolean|*}\n */\n isValueRedacted() {\n return (this.component.protected ||\n !this.component.persistent ||\n this.component.persistent === 'client-only');\n }\n /**\n * Sets the data value and updates the view representation.\n * @param value\n */\n setValue(value) {\n let changed = false;\n if (super.setValue) {\n changed = super.setValue(value);\n }\n return this.updateValue(value) || changed;\n }\n /**\n * Returns the main HTML Element for this component.\n */\n getElement() {\n return this.element;\n }\n /**\n * Remove all event handlers.\n */\n detach() {\n this.refs = {};\n this.attached = false;\n this.removeAttachedListeners();\n if (super.detach) {\n super.detach();\n }\n }\n /**\n * Clear an element.\n */\n clear() {\n this.detach();\n dom.empty(this.getElement());\n if (super.clear) {\n super.clear();\n }\n }\n /**\n * Appends an element to this component.\n * @param element\n */\n append(element) {\n dom.appendTo(element, this.element);\n }\n /**\n * Prepends an element to this component.\n * @param element\n */\n prepend(element) {\n dom.prependTo(element, this.element);\n }\n /**\n * Removes an element from this component.\n * @param element\n */\n removeChild(element) {\n dom.removeChildFrom(element, this.element);\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 addEventListener(obj, type, func) {\n if (!obj) {\n return;\n }\n if ('addEventListener' in obj) {\n obj.addEventListener(type, func, false);\n }\n else if ('attachEvent' in obj) {\n obj.attachEvent(`on${type}`, func);\n }\n this.attachedListeners.push({ obj, type, func });\n return this;\n }\n /**\n * Remove all the attached listeners.\n */\n removeAttachedListeners() {\n this.attachedListeners.forEach((item) => this.removeEventListener(item.obj, item.type, item.func));\n this.attachedListeners = [];\n }\n /**\n * Remove an event listener from the object.\n *\n * @param obj\n * @param type\n */\n removeEventListener(obj, type, func) {\n if (obj) {\n obj.removeEventListener(type, func);\n }\n return this;\n }\n };\n };\n}\nexports.Component = Component;\n// Add the default component.\nComponents_1.Components.addDecorator(Component, 'component');\nComponents_1.Components.addComponent(Component()(), 'component');\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/base/component/Component.js?");
|
95
95
|
|
96
96
|
/***/ }),
|
97
97
|
|
@@ -135,7 +135,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
135
135
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
136
136
|
|
137
137
|
"use strict";
|
138
|
-
eval("\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.DataTableComponent = exports.DataTable = void 0;\nconst base_1 = __webpack_require__(/*! ../base */ \"./node_modules/@formio/core/lib/experimental/base/index.js\");\n/**\n * A base class for a data table.\n */\nclass DataTable {\n constructor(component, options, data) {\n this.component = component;\n this.options = options;\n this.data = data;\n }\n renderClasses() {\n let classes = '';\n if (this.component.bordered) {\n classes += ' table-bordered';\n }\n if (this.component.striped) {\n classes += ' table-striped';\n }\n if (this.component.hover) {\n classes += ' table-hover';\n }\n if (this.component.condensed) {\n classes += ' table-condensed';\n }\n return classes;\n }\n renderContext(extend = {}) {\n return Object.assign({\n classes: this.renderClasses()
|
138
|
+
eval("\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.DataTableComponent = exports.DataTable = void 0;\nconst base_1 = __webpack_require__(/*! ../base */ \"./node_modules/@formio/core/lib/experimental/base/index.js\");\n/**\n * A base class for a data table.\n */\nclass DataTable {\n constructor(component, options, data) {\n this.component = component;\n this.options = options;\n this.data = data;\n }\n renderClasses() {\n let classes = '';\n if (this.component.bordered) {\n classes += ' table-bordered';\n }\n if (this.component.striped) {\n classes += ' table-striped';\n }\n if (this.component.hover) {\n classes += ' table-hover';\n }\n if (this.component.condensed) {\n classes += ' table-condensed';\n }\n return classes;\n }\n renderContext(extend = {}) {\n return Object.assign({\n classes: this.renderClasses(),\n }, extend);\n }\n}\nexports.DataTable = DataTable;\nlet DataTableComponent = class DataTableComponent extends DataTable {\n};\nexports.DataTableComponent = DataTableComponent;\nexports.DataTableComponent = DataTableComponent = __decorate([\n (0, base_1.ArrayComponent)({\n type: 'datatable',\n schema: {\n bordered: true,\n striped: false,\n hover: true,\n condensed: true,\n },\n template: 'datatable',\n })\n], DataTableComponent);\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/components/datatable.js?");
|
139
139
|
|
140
140
|
/***/ }),
|
141
141
|
|
@@ -146,7 +146,7 @@ eval("\nvar __decorate = (this && this.__decorate) || function (decorators, targ
|
|
146
146
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
147
147
|
|
148
148
|
"use strict";
|
149
|
-
eval("\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.DataValueComponent = void 0;\nconst base_1 = __webpack_require__(/*! ../base */ \"./node_modules/@formio/core/lib/experimental/base/index.js\");\nconst html_1 = __webpack_require__(/*! ./html */ \"./node_modules/@formio/core/lib/experimental/components/html.js\");\nlet DataValueComponent = class DataValueComponent extends html_1.HTML {\n};\nexports.DataValueComponent = DataValueComponent;\nexports.DataValueComponent = DataValueComponent = __decorate([\n (0, base_1.Component)({\n type: 'datavalue',\n schema: {\n tag: 'span',\n attrs: [],\n className: ''
|
149
|
+
eval("\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.DataValueComponent = void 0;\nconst base_1 = __webpack_require__(/*! ../base */ \"./node_modules/@formio/core/lib/experimental/base/index.js\");\nconst html_1 = __webpack_require__(/*! ./html */ \"./node_modules/@formio/core/lib/experimental/components/html.js\");\nlet DataValueComponent = class DataValueComponent extends html_1.HTML {\n};\nexports.DataValueComponent = DataValueComponent;\nexports.DataValueComponent = DataValueComponent = __decorate([\n (0, base_1.Component)({\n type: 'datavalue',\n schema: {\n tag: 'span',\n attrs: [],\n className: '',\n },\n template: (ctx) => {\n return `<${ctx.tag} ref=\"val\"${ctx.attrs}>${ctx.value()}</${ctx.tag}>`;\n },\n })\n], DataValueComponent);\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/components/datavalue.js?");
|
150
150
|
|
151
151
|
/***/ }),
|
152
152
|
|
@@ -157,7 +157,7 @@ eval("\nvar __decorate = (this && this.__decorate) || function (decorators, targ
|
|
157
157
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
158
158
|
|
159
159
|
"use strict";
|
160
|
-
eval("\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.HTMLComponent = exports.HTML = exports.HTMLProperties = void 0;\nconst base_1 = __webpack_require__(/*! ../base */ \"./node_modules/@formio/core/lib/experimental/base/index.js\");\nexports.HTMLProperties = {\n type: 'html',\n schema: {\n tag: 'span',\n content: '',\n attrs: [],\n className: ''
|
160
|
+
eval("\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.HTMLComponent = exports.HTML = exports.HTMLProperties = void 0;\nconst base_1 = __webpack_require__(/*! ../base */ \"./node_modules/@formio/core/lib/experimental/base/index.js\");\nexports.HTMLProperties = {\n type: 'html',\n schema: {\n tag: 'span',\n content: '',\n attrs: [],\n className: '',\n },\n template: (ctx) => {\n return `<${ctx.tag} ref=\"${ctx.ref}\"${ctx.attrs}>${ctx.t(ctx.content)}</${ctx.tag}>`;\n },\n};\n/**\n * Base class for HTML based components.\n */\nclass HTML {\n constructor(component, options, data) {\n this.component = component;\n this.options = options;\n this.data = data;\n }\n getAttributes() {\n let hasClass = false;\n let attrs = '';\n for (let i in this.component.attrs) {\n if (this.component.attrs.hasOwnProperty(i)) {\n const attrValue = this.component.attrs[i];\n const isString = Number.isNaN(parseInt(i));\n let attr = isString ? i : attrValue.attr;\n const value = isString ? attrValue : attrValue.value;\n if (attr === 'class' && this.component.className) {\n hasClass = true;\n attr += ` ${this.component.className}`;\n }\n attrs += ` ${attr}=\"${this.interpolate(value, this.evalContext())}\"`;\n }\n }\n if (!hasClass && this.component.className) {\n attrs += ` class=\"${this.interpolate(this.component.className, this.evalContext())}\"`;\n }\n return attrs;\n }\n renderContext(extend = {}) {\n return Object.assign({\n tag: this.component.tag,\n ref: this.component.type,\n content: this.component.content\n ? this.interpolate(this.component.content, this.evalContext())\n : '',\n attrs: this.getAttributes(),\n }, extend);\n }\n}\nexports.HTML = HTML;\nlet HTMLComponent = class HTMLComponent extends HTML {\n};\nexports.HTMLComponent = HTMLComponent;\nexports.HTMLComponent = HTMLComponent = __decorate([\n (0, base_1.Component)(exports.HTMLProperties)\n], HTMLComponent);\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/components/html.js?");
|
161
161
|
|
162
162
|
/***/ }),
|
163
163
|
|
@@ -168,7 +168,7 @@ eval("\nvar __decorate = (this && this.__decorate) || function (decorators, targ
|
|
168
168
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
169
169
|
|
170
170
|
"use strict";
|
171
|
-
eval("\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.HTMLContainerComponent = exports.HTMLContainer = void 0;\nconst base_1 = __webpack_require__(/*! ../base */ \"./node_modules/@formio/core/lib/experimental/base/index.js\");\nconst html_1 = __webpack_require__(/*! ./html */ \"./node_modules/@formio/core/lib/experimental/components/html.js\");\n/**\n * Base HTMLContainer component.\n */\nclass HTMLContainer extends html_1.HTML {\n renderContext(extend = {}) {\n return super.renderContext(Object.assign({\n content: this.renderComponents()
|
171
|
+
eval("\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.HTMLContainerComponent = exports.HTMLContainer = void 0;\nconst base_1 = __webpack_require__(/*! ../base */ \"./node_modules/@formio/core/lib/experimental/base/index.js\");\nconst html_1 = __webpack_require__(/*! ./html */ \"./node_modules/@formio/core/lib/experimental/components/html.js\");\n/**\n * Base HTMLContainer component.\n */\nclass HTMLContainer extends html_1.HTML {\n renderContext(extend = {}) {\n return super.renderContext(Object.assign({\n content: this.renderComponents(),\n }, extend));\n }\n}\nexports.HTMLContainer = HTMLContainer;\nlet HTMLContainerComponent = class HTMLContainerComponent extends HTMLContainer {\n};\nexports.HTMLContainerComponent = HTMLContainerComponent;\nexports.HTMLContainerComponent = HTMLContainerComponent = __decorate([\n (0, base_1.NestedComponent)({\n type: 'htmlcontainer',\n schema: html_1.HTMLProperties.schema,\n template: html_1.HTMLProperties.template,\n })\n], HTMLContainerComponent);\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/components/htmlcontainer.js?");
|
172
172
|
|
173
173
|
/***/ }),
|
174
174
|
|
@@ -179,7 +179,7 @@ eval("\nvar __decorate = (this && this.__decorate) || function (decorators, targ
|
|
179
179
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
180
180
|
|
181
181
|
"use strict";
|
182
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.InputComponent = exports.Input = exports.DataValueComponent = exports.DataTableComponent = exports.DataTable = exports.HTMLContainerComponent = exports.HTMLContainer = exports.HTMLComponent = exports.HTML = void 0;\nconst templates_1 = __importDefault(__webpack_require__(/*! ./templates */ \"./node_modules/@formio/core/lib/experimental/components/templates/index.js\"));\nconst html_1 = __webpack_require__(/*! ./html */ \"./node_modules/@formio/core/lib/experimental/components/html.js\");\nconst htmlcontainer_1 = __webpack_require__(/*! ./htmlcontainer */ \"./node_modules/@formio/core/lib/experimental/components/htmlcontainer.js\");\nconst datatable_1 = __webpack_require__(/*! ./datatable */ \"./node_modules/@formio/core/lib/experimental/components/datatable.js\");\nconst datavalue_1 = __webpack_require__(/*! ./datavalue */ \"./node_modules/@formio/core/lib/experimental/components/datavalue.js\");\nconst input_1 = __webpack_require__(/*! ./input/input */ \"./node_modules/@formio/core/lib/experimental/components/input/input.js\");\nvar html_2 = __webpack_require__(/*! ./html */ \"./node_modules/@formio/core/lib/experimental/components/html.js\");\nObject.defineProperty(exports, \"HTML\", ({ enumerable: true, get: function () { return html_2.HTML; } }));\nObject.defineProperty(exports, \"HTMLComponent\", ({ enumerable: true, get: function () { return html_2.HTMLComponent; } }));\nvar htmlcontainer_2 = __webpack_require__(/*! ./htmlcontainer */ \"./node_modules/@formio/core/lib/experimental/components/htmlcontainer.js\");\nObject.defineProperty(exports, \"HTMLContainer\", ({ enumerable: true, get: function () { return htmlcontainer_2.HTMLContainer; } }));\nObject.defineProperty(exports, \"HTMLContainerComponent\", ({ enumerable: true, get: function () { return htmlcontainer_2.HTMLContainerComponent; } }));\nvar datatable_2 = __webpack_require__(/*! ./datatable */ \"./node_modules/@formio/core/lib/experimental/components/datatable.js\");\nObject.defineProperty(exports, \"DataTable\", ({ enumerable: true, get: function () { return datatable_2.DataTable; } }));\nObject.defineProperty(exports, \"DataTableComponent\", ({ enumerable: true, get: function () { return datatable_2.DataTableComponent; } }));\nvar datavalue_2 = __webpack_require__(/*! ./datavalue */ \"./node_modules/@formio/core/lib/experimental/components/datavalue.js\");\nObject.defineProperty(exports, \"DataValueComponent\", ({ enumerable: true, get: function () { return datavalue_2.DataValueComponent; } }));\nvar input_2 = __webpack_require__(/*! ./input/input */ \"./node_modules/@formio/core/lib/experimental/components/input/input.js\");\nObject.defineProperty(exports, \"Input\", ({ enumerable: true, get: function () { return input_2.Input; } }));\nObject.defineProperty(exports, \"InputComponent\", ({ enumerable: true, get: function () { return input_2.InputComponent; } }));\nexports[\"default\"] = {\n components: {\n html: html_1.HTMLComponent,\n htmlcontainer: htmlcontainer_1.HTMLContainerComponent,\n datatable: datatable_1.DataTableComponent,\n datavalue: datavalue_1.DataValueComponent,\n input: input_1.InputComponent
|
182
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.InputComponent = exports.Input = exports.DataValueComponent = exports.DataTableComponent = exports.DataTable = exports.HTMLContainerComponent = exports.HTMLContainer = exports.HTMLComponent = exports.HTML = void 0;\nconst templates_1 = __importDefault(__webpack_require__(/*! ./templates */ \"./node_modules/@formio/core/lib/experimental/components/templates/index.js\"));\nconst html_1 = __webpack_require__(/*! ./html */ \"./node_modules/@formio/core/lib/experimental/components/html.js\");\nconst htmlcontainer_1 = __webpack_require__(/*! ./htmlcontainer */ \"./node_modules/@formio/core/lib/experimental/components/htmlcontainer.js\");\nconst datatable_1 = __webpack_require__(/*! ./datatable */ \"./node_modules/@formio/core/lib/experimental/components/datatable.js\");\nconst datavalue_1 = __webpack_require__(/*! ./datavalue */ \"./node_modules/@formio/core/lib/experimental/components/datavalue.js\");\nconst input_1 = __webpack_require__(/*! ./input/input */ \"./node_modules/@formio/core/lib/experimental/components/input/input.js\");\nvar html_2 = __webpack_require__(/*! ./html */ \"./node_modules/@formio/core/lib/experimental/components/html.js\");\nObject.defineProperty(exports, \"HTML\", ({ enumerable: true, get: function () { return html_2.HTML; } }));\nObject.defineProperty(exports, \"HTMLComponent\", ({ enumerable: true, get: function () { return html_2.HTMLComponent; } }));\nvar htmlcontainer_2 = __webpack_require__(/*! ./htmlcontainer */ \"./node_modules/@formio/core/lib/experimental/components/htmlcontainer.js\");\nObject.defineProperty(exports, \"HTMLContainer\", ({ enumerable: true, get: function () { return htmlcontainer_2.HTMLContainer; } }));\nObject.defineProperty(exports, \"HTMLContainerComponent\", ({ enumerable: true, get: function () { return htmlcontainer_2.HTMLContainerComponent; } }));\nvar datatable_2 = __webpack_require__(/*! ./datatable */ \"./node_modules/@formio/core/lib/experimental/components/datatable.js\");\nObject.defineProperty(exports, \"DataTable\", ({ enumerable: true, get: function () { return datatable_2.DataTable; } }));\nObject.defineProperty(exports, \"DataTableComponent\", ({ enumerable: true, get: function () { return datatable_2.DataTableComponent; } }));\nvar datavalue_2 = __webpack_require__(/*! ./datavalue */ \"./node_modules/@formio/core/lib/experimental/components/datavalue.js\");\nObject.defineProperty(exports, \"DataValueComponent\", ({ enumerable: true, get: function () { return datavalue_2.DataValueComponent; } }));\nvar input_2 = __webpack_require__(/*! ./input/input */ \"./node_modules/@formio/core/lib/experimental/components/input/input.js\");\nObject.defineProperty(exports, \"Input\", ({ enumerable: true, get: function () { return input_2.Input; } }));\nObject.defineProperty(exports, \"InputComponent\", ({ enumerable: true, get: function () { return input_2.InputComponent; } }));\nexports[\"default\"] = {\n components: {\n html: html_1.HTMLComponent,\n htmlcontainer: htmlcontainer_1.HTMLContainerComponent,\n datatable: datatable_1.DataTableComponent,\n datavalue: datavalue_1.DataValueComponent,\n input: input_1.InputComponent,\n },\n templates: templates_1.default,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/components/index.js?");
|
183
183
|
|
184
184
|
/***/ }),
|
185
185
|
|
@@ -190,7 +190,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
190
190
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
191
191
|
|
192
192
|
"use strict";
|
193
|
-
eval("\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.InputComponent = exports.Input = void 0;\nconst base_1 = __webpack_require__(/*! ../../base */ \"./node_modules/@formio/core/lib/experimental/base/index.js\");\nconst html_1 = __webpack_require__(/*! ../html */ \"./node_modules/@formio/core/lib/experimental/components/html.js\");\n/**\n * Base Input component for extending purposes.\n */\nclass Input extends html_1.HTML {\n getAttributes() {\n const attributes = super.getAttributes();\n const inputName = `${this.component.type}-${this.component.key}
|
193
|
+
eval("\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.InputComponent = exports.Input = void 0;\nconst base_1 = __webpack_require__(/*! ../../base */ \"./node_modules/@formio/core/lib/experimental/base/index.js\");\nconst html_1 = __webpack_require__(/*! ../html */ \"./node_modules/@formio/core/lib/experimental/components/html.js\");\n/**\n * Base Input component for extending purposes.\n */\nclass Input extends html_1.HTML {\n getAttributes() {\n const attributes = super.getAttributes();\n const inputName = `${this.component.type}-${this.component.key}`\n .toLowerCase()\n .replace(/[^a-z0-9\\-]+/g, '_');\n return ` type=\"${this.component.inputType}\" id=\"${inputName}\" name=\"${inputName}\"${attributes}`;\n }\n onInput() {\n this.updateValue(this.element.value);\n }\n attach(element) {\n return __awaiter(this, void 0, void 0, function* () {\n this.addEventListener(this.element, this.component.changeEvent, this.onInput.bind(this));\n return this;\n });\n }\n detach() {\n this.removeEventListener(this.element, this.component.changeEvent, this.onInput.bind(this));\n }\n setValue(value) {\n if (this.element) {\n this.element.value = value;\n }\n }\n}\nexports.Input = Input;\nlet InputComponent = class InputComponent extends Input {\n};\nexports.InputComponent = InputComponent;\nexports.InputComponent = InputComponent = __decorate([\n (0, base_1.Component)({\n type: 'input',\n template: html_1.HTMLProperties.template,\n schema: Object.assign(Object.assign({}, html_1.HTMLProperties.schema), {\n tag: 'input',\n ref: 'input',\n changeEvent: 'input',\n inputType: 'text',\n }),\n })\n], InputComponent);\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/components/input/input.js?");
|
194
194
|
|
195
195
|
/***/ }),
|
196
196
|
|
@@ -244,7 +244,7 @@ eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ?
|
|
244
244
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
245
245
|
|
246
246
|
"use strict";
|
247
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n__webpack_require__(/*! core-js/features/object/from-entries */ \"./node_modules/core-js/features/object/from-entries.js\");\nconst sdk_1 = __webpack_require__(/*! ../sdk */ \"./node_modules/@formio/core/lib/sdk/index.js\");\nconst utils_1 = __webpack_require__(/*! ../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst base_1 = __webpack_require__(/*! ./base */ \"./node_modules/@formio/core/lib/experimental/base/index.js\");\nconst template_1 = __webpack_require__(/*! ./template */ \"./node_modules/@formio/core/lib/experimental/template/index.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst components_1 = __importDefault(__webpack_require__(/*! ./components */ \"./node_modules/@formio/core/lib/experimental/components/index.js\"));\nconst modules_1 = __importDefault(__webpack_require__(/*! ../modules */ \"./node_modules/@formio/core/lib/modules/index.js\"));\nclass FormioCore extends sdk_1.Formio {\n static usePlugin(key, plugin) {\n switch (key) {\n case 'options':\n if (!sdk_1.Formio.options) {\n return;\n }\n sdk_1.Formio.options = (0, lodash_1.merge)(sdk_1.Formio.options, plugin);\n break;\n case 'templates':\n if (!sdk_1.Formio.Templates) {\n return;\n }\n const current = sdk_1.Formio.Templates.framework || 'bootstrap';\n for (const framework of Object.keys(plugin)) {\n sdk_1.Formio.Templates.extendTemplate(framework, plugin[framework]);\n }\n if (plugin[current]) {\n sdk_1.Formio.Templates.current = plugin[current];\n }\n break;\n case 'components':\n if (!sdk_1.Formio.Components) {\n return;\n }\n sdk_1.Formio.Components.setComponents(plugin);\n break;\n case 'framework':\n if (!sdk_1.Formio.Templates) {\n return;\n }\n sdk_1.Formio.Templates.framework = plugin;\n break;\n case 'fetch':\n for (const name of Object.keys(plugin)) {\n sdk_1.Formio.registerPlugin(plugin[name], name);\n }\n break;\n case 'rules':\n if (!sdk_1.Formio.Rules) {\n return;\n }\n sdk_1.Formio.Rules.addRules(plugin);\n break;\n case 'evaluator':\n if (!sdk_1.Formio.Evaluator) {\n return;\n }\n sdk_1.Formio.Evaluator.registerEvaluator(plugin);\n break;\n default:\n console.log('Unknown plugin option', key);\n }\n }\n static useModule(module) {\n // Sanity check.\n if (typeof module !== 'object') {\n return;\n }\n for (const key of Object.keys(module)) {\n FormioCore.usePlugin(key, module[key]);\n }\n }\n /**\n * Allows passing in plugins as multiple arguments or an array of plugins.\n *\n * Formio.plugins(plugin1, plugin2, etc);\n * Formio.plugins([plugin1, plugin2, etc]);\n */\n static use(...mods) {\n mods.forEach((mod) => {\n if (Array.isArray(mod)) {\n mod.forEach(p => FormioCore.useModule(p));\n }\n else {\n FormioCore.useModule(mod);\n }\n });\n }\n}\nFormioCore.Components = base_1.Components;\nFormioCore.render = base_1.render;\nFormioCore.Evaluator = utils_1.Evaluator;\nFormioCore.Utils = utils_1.Utils;\nFormioCore.Templates = template_1.Template;\nexports[\"default\"] = FormioCore;\nFormioCore.use(components_1.default);\nFormioCore.use(modules_1.default);\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/core.js?");
|
247
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n__webpack_require__(/*! core-js/features/object/from-entries */ \"./node_modules/core-js/features/object/from-entries.js\");\nconst sdk_1 = __webpack_require__(/*! ../sdk */ \"./node_modules/@formio/core/lib/sdk/index.js\");\nconst utils_1 = __webpack_require__(/*! ../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst base_1 = __webpack_require__(/*! ./base */ \"./node_modules/@formio/core/lib/experimental/base/index.js\");\nconst template_1 = __webpack_require__(/*! ./template */ \"./node_modules/@formio/core/lib/experimental/template/index.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst components_1 = __importDefault(__webpack_require__(/*! ./components */ \"./node_modules/@formio/core/lib/experimental/components/index.js\"));\nconst modules_1 = __importDefault(__webpack_require__(/*! ../modules */ \"./node_modules/@formio/core/lib/modules/index.js\"));\nclass FormioCore extends sdk_1.Formio {\n static usePlugin(key, plugin) {\n switch (key) {\n case 'options':\n if (!sdk_1.Formio.options) {\n return;\n }\n sdk_1.Formio.options = (0, lodash_1.merge)(sdk_1.Formio.options, plugin);\n break;\n case 'templates':\n if (!sdk_1.Formio.Templates) {\n return;\n }\n const current = sdk_1.Formio.Templates.framework || 'bootstrap';\n for (const framework of Object.keys(plugin)) {\n sdk_1.Formio.Templates.extendTemplate(framework, plugin[framework]);\n }\n if (plugin[current]) {\n sdk_1.Formio.Templates.current = plugin[current];\n }\n break;\n case 'components':\n if (!sdk_1.Formio.Components) {\n return;\n }\n sdk_1.Formio.Components.setComponents(plugin);\n break;\n case 'framework':\n if (!sdk_1.Formio.Templates) {\n return;\n }\n sdk_1.Formio.Templates.framework = plugin;\n break;\n case 'fetch':\n for (const name of Object.keys(plugin)) {\n sdk_1.Formio.registerPlugin(plugin[name], name);\n }\n break;\n case 'rules':\n if (!sdk_1.Formio.Rules) {\n return;\n }\n sdk_1.Formio.Rules.addRules(plugin);\n break;\n case 'evaluator':\n if (!sdk_1.Formio.Evaluator) {\n return;\n }\n sdk_1.Formio.Evaluator.registerEvaluator(plugin);\n break;\n default:\n console.log('Unknown plugin option', key);\n }\n }\n static useModule(module) {\n // Sanity check.\n if (typeof module !== 'object') {\n return;\n }\n for (const key of Object.keys(module)) {\n FormioCore.usePlugin(key, module[key]);\n }\n }\n /**\n * Allows passing in plugins as multiple arguments or an array of plugins.\n *\n * Formio.plugins(plugin1, plugin2, etc);\n * Formio.plugins([plugin1, plugin2, etc]);\n */\n static use(...mods) {\n mods.forEach((mod) => {\n if (Array.isArray(mod)) {\n mod.forEach((p) => FormioCore.useModule(p));\n }\n else {\n FormioCore.useModule(mod);\n }\n });\n }\n}\nFormioCore.Components = base_1.Components;\nFormioCore.render = base_1.render;\nFormioCore.Evaluator = utils_1.Evaluator;\nFormioCore.Utils = utils_1.Utils;\nFormioCore.Templates = template_1.Template;\nexports[\"default\"] = FormioCore;\nFormioCore.use(components_1.default);\nFormioCore.use(modules_1.default);\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/core.js?");
|
248
248
|
|
249
249
|
/***/ }),
|
250
250
|
|
@@ -277,7 +277,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
277
277
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
278
278
|
|
279
279
|
"use strict";
|
280
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Model = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst EventEmitter_1 = __webpack_require__(/*! ./EventEmitter */ \"./node_modules/@formio/core/lib/experimental/model/EventEmitter.js\");\nfunction Model(props = {}) {\n if (!props.schema) {\n props.schema = {};\n }\n if (!props.schema.key) {\n props.schema.key = '';\n }\n return function (BaseClass) {\n return class BaseModel extends (0, EventEmitter_1.EventEmitter)(BaseClass) {\n /**\n * The default JSON schema\n * @param extend\n */\n static schema() {\n return props.schema;\n }\n /**\n * @constructor\n * @param component\n * @param options\n * @param data\n */\n constructor(component = {}, options = {}, data = {}) {\n super(component, options, data);\n this.component = component;\n this.options = options;\n this.data = data;\n /**\n * The root entity.\n */\n this.root = null;\n this.id = `e${Math.random().toString(36).substring(7)}`;\n this.component = (0, lodash_1.merge)({}, this.defaultSchema, this.component);\n this.options = Object.assign(Object.assign({}, this.defaultOptions), this.options);\n if (!this.options.noInit) {\n this.init();\n }\n }\n get defaultOptions() {\n return {};\n }\n get defaultSchema() {\n return BaseModel.schema();\n }\n /**\n * Initializes the entity.\n */\n init() {\n this.hook('init');\n }\n /**\n * Return the errors from validation for this component.\n */\n get errors() {\n return this.validator.errors;\n }\n /**\n * The empty value for this component.\n *\n * @return {null}\n */\n get emptyValue() {\n return null;\n }\n /**\n * Checks to see if this components value is empty.\n *\n * @param value\n * @returns\n */\n isEmpty(value = this.dataValue) {\n const isEmptyArray = (
|
280
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Model = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst EventEmitter_1 = __webpack_require__(/*! ./EventEmitter */ \"./node_modules/@formio/core/lib/experimental/model/EventEmitter.js\");\nfunction Model(props = {}) {\n if (!props.schema) {\n props.schema = {};\n }\n if (!props.schema.key) {\n props.schema.key = '';\n }\n return function (BaseClass) {\n return class BaseModel extends (0, EventEmitter_1.EventEmitter)(BaseClass) {\n /**\n * The default JSON schema\n * @param extend\n */\n static schema() {\n return props.schema;\n }\n /**\n * @constructor\n * @param component\n * @param options\n * @param data\n */\n constructor(component = {}, options = {}, data = {}) {\n super(component, options, data);\n this.component = component;\n this.options = options;\n this.data = data;\n /**\n * The root entity.\n */\n this.root = null;\n this.id = `e${Math.random().toString(36).substring(7)}`;\n this.component = (0, lodash_1.merge)({}, this.defaultSchema, this.component);\n this.options = Object.assign(Object.assign({}, this.defaultOptions), this.options);\n if (!this.options.noInit) {\n this.init();\n }\n }\n get defaultOptions() {\n return {};\n }\n get defaultSchema() {\n return BaseModel.schema();\n }\n /**\n * Initializes the entity.\n */\n init() {\n this.hook('init');\n }\n /**\n * Return the errors from validation for this component.\n */\n get errors() {\n return this.validator.errors;\n }\n /**\n * The empty value for this component.\n *\n * @return {null}\n */\n get emptyValue() {\n return null;\n }\n /**\n * Checks to see if this components value is empty.\n *\n * @param value\n * @returns\n */\n isEmpty(value = this.dataValue) {\n const isEmptyArray = (0, lodash_1.isArray)(value) && value.length === 1 ? (0, lodash_1.isEqual)(value[0], this.emptyValue) : false;\n return (value == null || value.length === 0 || (0, lodash_1.isEqual)(value, this.emptyValue) || isEmptyArray);\n }\n /**\n * Returns the data value for this component.\n */\n get dataValue() {\n return this.component.key ? (0, lodash_1.get)(this.data, this.component.key) : this.data;\n }\n /**\n * Sets the datavalue for this component.\n */\n set dataValue(value) {\n if (this.component.key) {\n (0, lodash_1.set)(this.data, this.component.key, value);\n }\n }\n /**\n * Determine if this component has changed values.\n *\n * @param value - The value to compare against the current value.\n */\n hasChanged(value) {\n return String(value) !== String(this.dataValue);\n }\n /**\n * Updates the data model value\n * @param value The value to update within this component.\n * @return boolean true if the value has changed.\n */\n updateValue(value) {\n const changed = this.hasChanged(value);\n this.dataValue = value;\n if (changed) {\n // Bubble a change event.\n this.bubble('change', value);\n }\n return changed;\n }\n /**\n * Get the model value.\n * @returns\n */\n getValue() {\n return this.dataValue;\n }\n /**\n * Allow for options to hook into the functionality of this entity.\n * @return {*}\n */\n hook(name, ...args) {\n if (this.options && this.options.hooks && this.options.hooks[name]) {\n return this.options.hooks[name].apply(this, args);\n }\n else {\n // If this is an async hook instead of a sync.\n const fn = typeof args[args.length - 1] === 'function' ? args[args.length - 1] : null;\n if (fn) {\n return fn(null, args[1]);\n }\n else {\n return args[1];\n }\n }\n }\n };\n };\n}\nexports.Model = Model;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/model/Model.js?");
|
281
281
|
|
282
282
|
/***/ }),
|
283
283
|
|
@@ -288,7 +288,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
288
288
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
289
289
|
|
290
290
|
"use strict";
|
291
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.NestedArrayModel = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst NestedDataModel_1 = __webpack_require__(/*! ./NestedDataModel */ \"./node_modules/@formio/core/lib/experimental/model/NestedDataModel.js\");\nfunction NestedArrayModel(props = {}) {\n return function (BaseClass) {\n return class BaseNestedArrayModel extends (0, NestedDataModel_1.NestedDataModel)(props)(BaseClass) {\n get defaultValue() {\n return [];\n }\n /**\n * Returns a row of componments at the provided index.\n * @param index The index of the row to return\n */\n row(index) {\n return
|
291
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.NestedArrayModel = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst NestedDataModel_1 = __webpack_require__(/*! ./NestedDataModel */ \"./node_modules/@formio/core/lib/experimental/model/NestedDataModel.js\");\nfunction NestedArrayModel(props = {}) {\n return function (BaseClass) {\n return class BaseNestedArrayModel extends (0, NestedDataModel_1.NestedDataModel)(props)(BaseClass) {\n get defaultValue() {\n return [];\n }\n /**\n * Returns a row of componments at the provided index.\n * @param index The index of the row to return\n */\n row(index) {\n return index < this.rows.length ? this.rows[index] : [];\n }\n /**\n * Removes a row and detatches all components within that row.\n *\n * @param index The index of the row to remove.\n */\n removeRow(index) {\n this.row(index).forEach((comp) => this.removeComponent(comp));\n this.dataValue.splice(index, 1);\n this.rows.splice(index, 1);\n }\n /**\n * Adds a new row of components.\n *\n * @param data The data context to pass to this row of components.\n */\n addRow(data = {}, index = 0) {\n const rowData = data;\n this.dataValue[index] = rowData;\n this.createRowComponents(rowData, index);\n }\n /**\n * Sets the data for a specific row of components.\n * @param rowData The data to set\n * @param index The index of the rows to set the data within.\n */\n setRowData(rowData, index) {\n var _a;\n this.dataValue[index] = rowData;\n (_a = this.row(index)) === null || _a === void 0 ? void 0 : _a.forEach((comp) => (comp.data = rowData));\n }\n /**\n * Determines if the data within a row has changed.\n *\n * @param rowData\n * @param index\n */\n rowChanged(rowData, index) {\n var _a;\n let changed = false;\n (_a = this.row(index)) === null || _a === void 0 ? void 0 : _a.forEach((comp) => {\n const hasChanged = comp.hasChanged((0, lodash_1.get)(rowData, comp.component.key));\n changed = hasChanged || changed;\n if (hasChanged) {\n comp.bubble('change', comp);\n }\n });\n return changed;\n }\n /**\n * Creates all components for each row.\n * @param data\n * @returns\n */\n createComponents(data) {\n this.rows = [];\n let added = [];\n this.eachRowValue(data, (row, index) => {\n added = added.concat(this.createRowComponents(row, index));\n });\n return added;\n }\n /**\n * Creates a new row of components.\n *\n * @param data The data context to pass along to this row of components.\n */\n createRowComponents(data, index = 0) {\n const comps = super.createComponents(data, (comp) => {\n comp.rowIndex = index;\n });\n this.rows[index] = comps;\n return comps;\n }\n getIndexes(value) {\n if (super.getIndexes) {\n return super.getIndexes(value);\n }\n return {\n min: 0,\n max: value.length - 1,\n };\n }\n eachRowValue(value, fn) {\n if (!value || !value.length) {\n return;\n }\n const indexes = this.getIndexes(value);\n for (let i = indexes.min; i <= indexes.max; i++) {\n fn(value[i], i);\n }\n }\n /**\n * The empty value for this component.\n *\n * @return {array}\n */\n get emptyValue() {\n return [];\n }\n /**\n * Returns the dataValue for this component.\n */\n get dataValue() {\n return this.component.key ? (0, lodash_1.get)(this.data, this.component.key) : this.data;\n }\n /**\n * Set the datavalue of an array component.\n *\n * @param value The value to set this component to.\n */\n set dataValue(value) {\n // Only set the value if it is an array.\n if (Array.isArray(value)) {\n // Get the current data value.\n const dataValue = this.dataValue;\n this.eachRowValue(value, (row, index) => {\n if (index >= dataValue.length) {\n this.addRow(row, index);\n }\n this.setRowData(row, index);\n });\n // Remove superfluous rows.\n if (dataValue.length > value.length) {\n for (let i = dataValue.length - 1; i >= value.length; i--) {\n this.removeRow(i);\n }\n }\n }\n }\n /**\n * Determine if this array component has changed.\n *\n * @param value\n */\n hasChanged(value) {\n const dataValue = this.dataValue;\n // If the length changes, then this compnent has changed.\n if (value.length !== dataValue.length) {\n this.emit('changed', this);\n return true;\n }\n let changed = false;\n this.eachRowValue(value, (rowData, index) => {\n changed = this.rowChanged(rowData, index) || changed;\n });\n return changed;\n }\n /**\n * Sets the value of an array component.\n *\n * @param value\n */\n setValue(value) {\n var changed = false;\n this.eachComponentValue(value, (comp, val) => {\n changed = comp.setValue(val) || changed;\n });\n return changed;\n }\n };\n };\n}\nexports.NestedArrayModel = NestedArrayModel;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/model/NestedArrayModel.js?");
|
292
292
|
|
293
293
|
/***/ }),
|
294
294
|
|
@@ -299,7 +299,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
299
299
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
300
300
|
|
301
301
|
"use strict";
|
302
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.NestedDataModel = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst NestedModel_1 = __webpack_require__(/*! ./NestedModel */ \"./node_modules/@formio/core/lib/experimental/model/NestedModel.js\");\nfunction NestedDataModel(props = {}) {\n return function (BaseClass) {\n return class BaseNestedDataModel extends (0, NestedModel_1.NestedModel)(props)(BaseClass) {\n get emptyValue() {\n return {};\n }\n get defaultValue() {\n return {};\n }\n /**\n * Get the component data.\n */\n componentData() {\n if (!this.component.key) {\n return this.data;\n }\n const compData = (0, lodash_1.get)(this.data, this.component.key, this.defaultValue);\n if (!Object.keys(compData).length) {\n (0, lodash_1.set)(this.data, this.component.key, compData);\n }\n return compData;\n }\n get dataValue() {\n return this.component.key ? (0, lodash_1.get)(this.data, this.component.key) : this.data;\n }\n set dataValue(value) {\n this.eachComponentValue(value, (comp, val) => (comp.dataValue = val));\n }\n };\n };\n}\nexports.NestedDataModel = NestedDataModel;\n
|
302
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.NestedDataModel = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst NestedModel_1 = __webpack_require__(/*! ./NestedModel */ \"./node_modules/@formio/core/lib/experimental/model/NestedModel.js\");\nfunction NestedDataModel(props = {}) {\n return function (BaseClass) {\n return class BaseNestedDataModel extends (0, NestedModel_1.NestedModel)(props)(BaseClass) {\n get emptyValue() {\n return {};\n }\n get defaultValue() {\n return {};\n }\n /**\n * Get the component data.\n */\n componentData() {\n if (!this.component.key) {\n return this.data;\n }\n const compData = (0, lodash_1.get)(this.data, this.component.key, this.defaultValue);\n if (!Object.keys(compData).length) {\n (0, lodash_1.set)(this.data, this.component.key, compData);\n }\n return compData;\n }\n get dataValue() {\n return this.component.key ? (0, lodash_1.get)(this.data, this.component.key) : this.data;\n }\n set dataValue(value) {\n this.eachComponentValue(value, (comp, val) => (comp.dataValue = val));\n }\n };\n };\n}\nexports.NestedDataModel = NestedDataModel;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/model/NestedDataModel.js?");
|
303
303
|
|
304
304
|
/***/ }),
|
305
305
|
|
@@ -310,7 +310,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
310
310
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
311
311
|
|
312
312
|
"use strict";
|
313
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.NestedModel = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst Model_1 = __webpack_require__(/*! ./Model */ \"./node_modules/@formio/core/lib/experimental/model/Model.js\");\nfunction NestedModel(props = {}) {\n if (!props.schema) {\n props.schema = {};\n }\n if (!props.schema.components) {\n props.schema.components = [];\n }\n return function (BaseClass) {\n return class BaseNestedModel extends (0, Model_1.Model)(props)(BaseClass) {\n /**\n * Initialize the nested entity by creating the children.\n */\n init() {\n super.init();\n this.components = [];\n this.createComponents(this.componentData());\n }\n /**\n * Get the component data.\n * @returns\n */\n componentData() {\n return this.data;\n }\n /**\n * Creates a new component entity.\n * @param component\n * @param options\n * @param data\n * @returns\n */\n createComponent(component, options, data) {\n if (!props.factory) {\n console.log('Cannot create components. No \"factory\" provided.');\n return null;\n }\n const comp = props.factory.create(component, Object.assign({ noInit: true }, options), data);\n comp.parent = this;\n comp.root = this.root || this;\n comp.init();\n return comp;\n }\n /**\n * Creates the components.\n * @param data\n * @returns\n */\n createComponents(data, eachComp) {\n const added = [];\n (this.component.components || []).forEach((comp) => {\n const newComp = this.createComponent(comp, this.options, data);\n if (newComp) {\n this.components.push(newComp);\n added.push(newComp);\n if (eachComp) {\n eachComp(newComp);\n }\n }\n });\n return added;\n }\n /**\n * Removes a child comopnent.\n * @param component\n */\n removeComponent(component) {\n (this.components || []).forEach((comp, index) => {\n if (comp === component) {\n if (comp.detach) {\n comp.detach();\n }\n this.components.splice(index, 1);\n }\n });\n }\n /**\n * Checks for the validity of this component and all components within this component.\n * @returns\n */\n checkValidity() {\n return __awaiter(this, void 0, void 0, function* () {\n return this.components.reduce((valid, comp) => {\n return valid && comp.checkValidity();\n }, this.checkComponentValidity());\n });\n }\n /**\n * Get the default value for this nested entity.\n */\n get defaultValue() {\n return {};\n }\n /**\n * The empty value for this component.\n *\n * @return {null}\n */\n get emptyValue() {\n return {};\n }\n /**\n * Get the datavalue of this component.\n */\n get dataValue() {\n return this.data;\n }\n /**\n * Perform an iteration over each component within this container component.\n *\n * @param {function} fn - Called for each component\n */\n eachComponent(fn) {\n (0, lodash_1.each)(this.components, (component, index) => {\n if (fn(component, index) === false) {\n return false;\n }\n });\n }\n /**\n * Iterate through each component value.\n *\n * @param value The context data value.\n * @param fn Callback to be called with the component and the value for that component.\n */\n eachComponentValue(value, fn) {\n if (Object.keys(value).length) {\n this.eachComponent((comp) => {\n fn(comp, (0, lodash_1.get)(value, comp.component.key));\n });\n }\n }\n /**\n * Set the data value for this nested entity.\n */\n set dataValue(value) {\n this.eachComponentValue(value, (comp, val) => (comp.dataValue = val));\n }\n /**\n * Sets the value for a data component.\n *\n * @param value\n */\n setValue(value) {\n var changed = false;\n this.eachComponentValue(value, (comp, val) => {\n changed = comp.setValue(val) || changed;\n });\n return changed;\n }\n };\n };\n}\nexports.NestedModel = NestedModel;\n
|
313
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.NestedModel = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst Model_1 = __webpack_require__(/*! ./Model */ \"./node_modules/@formio/core/lib/experimental/model/Model.js\");\nfunction NestedModel(props = {}) {\n if (!props.schema) {\n props.schema = {};\n }\n if (!props.schema.components) {\n props.schema.components = [];\n }\n return function (BaseClass) {\n return class BaseNestedModel extends (0, Model_1.Model)(props)(BaseClass) {\n /**\n * Initialize the nested entity by creating the children.\n */\n init() {\n super.init();\n this.components = [];\n this.createComponents(this.componentData());\n }\n /**\n * Get the component data.\n * @returns\n */\n componentData() {\n return this.data;\n }\n /**\n * Creates a new component entity.\n * @param component\n * @param options\n * @param data\n * @returns\n */\n createComponent(component, options, data) {\n if (!props.factory) {\n console.log('Cannot create components. No \"factory\" provided.');\n return null;\n }\n const comp = props.factory.create(component, Object.assign({ noInit: true }, options), data);\n comp.parent = this;\n comp.root = this.root || this;\n comp.init();\n return comp;\n }\n /**\n * Creates the components.\n * @param data\n * @returns\n */\n createComponents(data, eachComp) {\n const added = [];\n (this.component.components || []).forEach((comp) => {\n const newComp = this.createComponent(comp, this.options, data);\n if (newComp) {\n this.components.push(newComp);\n added.push(newComp);\n if (eachComp) {\n eachComp(newComp);\n }\n }\n });\n return added;\n }\n /**\n * Removes a child comopnent.\n * @param component\n */\n removeComponent(component) {\n (this.components || []).forEach((comp, index) => {\n if (comp === component) {\n if (comp.detach) {\n comp.detach();\n }\n this.components.splice(index, 1);\n }\n });\n }\n /**\n * Checks for the validity of this component and all components within this component.\n * @returns\n */\n checkValidity() {\n return __awaiter(this, void 0, void 0, function* () {\n return this.components.reduce((valid, comp) => {\n return valid && comp.checkValidity();\n }, this.checkComponentValidity());\n });\n }\n /**\n * Get the default value for this nested entity.\n */\n get defaultValue() {\n return {};\n }\n /**\n * The empty value for this component.\n *\n * @return {null}\n */\n get emptyValue() {\n return {};\n }\n /**\n * Get the datavalue of this component.\n */\n get dataValue() {\n return this.data;\n }\n /**\n * Perform an iteration over each component within this container component.\n *\n * @param {function} fn - Called for each component\n */\n eachComponent(fn) {\n (0, lodash_1.each)(this.components, (component, index) => {\n if (fn(component, index) === false) {\n return false;\n }\n });\n }\n /**\n * Iterate through each component value.\n *\n * @param value The context data value.\n * @param fn Callback to be called with the component and the value for that component.\n */\n eachComponentValue(value, fn) {\n if (Object.keys(value).length) {\n this.eachComponent((comp) => {\n fn(comp, (0, lodash_1.get)(value, comp.component.key));\n });\n }\n }\n /**\n * Set the data value for this nested entity.\n */\n set dataValue(value) {\n this.eachComponentValue(value, (comp, val) => (comp.dataValue = val));\n }\n /**\n * Sets the value for a data component.\n *\n * @param value\n */\n setValue(value) {\n var changed = false;\n this.eachComponentValue(value, (comp, val) => {\n changed = comp.setValue(val) || changed;\n });\n return changed;\n }\n };\n };\n}\nexports.NestedModel = NestedModel;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/experimental/model/NestedModel.js?");
|
314
314
|
|
315
315
|
/***/ }),
|
316
316
|
|
@@ -365,7 +365,7 @@ eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ?
|
|
365
365
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
366
366
|
|
367
367
|
"use strict";
|
368
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst jsonlogic_1 = __webpack_require__(/*! ./jsonlogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/index.js\");\nexports[\"default\"] = [
|
368
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst jsonlogic_1 = __webpack_require__(/*! ./jsonlogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/index.js\");\nexports[\"default\"] = [jsonlogic_1.JSONLogicModule];\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/modules/index.js?");
|
369
369
|
|
370
370
|
/***/ }),
|
371
371
|
|
@@ -376,7 +376,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\ncons
|
|
376
376
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
377
377
|
|
378
378
|
"use strict";
|
379
|
-
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.JSONLogicModule = exports.interpolate = exports.evaluate = exports.JSONLogicEvaluator = void 0;\nconst utils_1 = __webpack_require__(/*! ../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst jsonLogic_1 = __webpack_require__(/*! ./jsonLogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/jsonLogic.js\");\nclass JSONLogicEvaluator extends utils_1.BaseEvaluator {\n static evaluate(func, args = {}, ret = '', interpolate = false, context = {}, options = {}) {\n let returnVal = null;\n if (typeof func === 'object') {\n try {\n returnVal = jsonLogic_1.jsonLogic.apply(func, args);\n }\n catch (err) {\n returnVal = null;\n console.warn(`An error occured within JSON Logic`, err);\n }\n }\n else {\n returnVal = utils_1.BaseEvaluator.evaluate(func, args, ret, interpolate, context, options);\n }\n return returnVal;\n }\n}\nexports.JSONLogicEvaluator = JSONLogicEvaluator;\nfunction evaluate(context, evaluation, ret = 'result', evalContextFn, options = {}) {\n const { evalContext, instance } = context;\n const evalContextValue = evalContext ? evalContext(context) : context;\n if (evalContextFn) {\n evalContextFn(evalContextValue);\n }\n if (instance && instance.evaluate) {\n return instance.evaluate(evaluation, evalContextValue, ret, false, options);\n }\n return JSONLogicEvaluator.evaluate(evaluation, evalContextValue, ret, false, context, options);\n}\nexports.evaluate = evaluate;\nfunction interpolate(context, evaluation, evalContextFn) {\n const { evalContext, instance } = context;\n const evalContextValue = evalContext ? evalContext(context) : context;\n if (evalContextFn) {\n evalContextFn(evalContextValue);\n }\n if (instance && instance.evaluate) {\n return instance.interpolate(evaluation, evalContextValue, {\n noeval: true
|
379
|
+
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.JSONLogicModule = exports.interpolate = exports.evaluate = exports.JSONLogicEvaluator = void 0;\nconst utils_1 = __webpack_require__(/*! ../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst jsonLogic_1 = __webpack_require__(/*! ./jsonLogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/jsonLogic.js\");\nclass JSONLogicEvaluator extends utils_1.BaseEvaluator {\n static evaluate(func, args = {}, ret = '', interpolate = false, context = {}, options = {}) {\n let returnVal = null;\n if (typeof func === 'object') {\n try {\n returnVal = jsonLogic_1.jsonLogic.apply(func, args);\n }\n catch (err) {\n returnVal = null;\n console.warn(`An error occured within JSON Logic`, err);\n }\n }\n else {\n returnVal = utils_1.BaseEvaluator.evaluate(func, args, ret, interpolate, context, options);\n }\n return returnVal;\n }\n}\nexports.JSONLogicEvaluator = JSONLogicEvaluator;\nfunction evaluate(context, evaluation, ret = 'result', evalContextFn, options = {}) {\n const { evalContext, instance } = context;\n const evalContextValue = evalContext ? evalContext(context) : context;\n if (evalContextFn) {\n evalContextFn(evalContextValue);\n }\n if (instance && instance.evaluate) {\n return instance.evaluate(evaluation, evalContextValue, ret, false, options);\n }\n return JSONLogicEvaluator.evaluate(evaluation, evalContextValue, ret, false, context, options);\n}\nexports.evaluate = evaluate;\nfunction interpolate(context, evaluation, evalContextFn) {\n const { evalContext, instance } = context;\n const evalContextValue = evalContext ? evalContext(context) : context;\n if (evalContextFn) {\n evalContextFn(evalContextValue);\n }\n if (instance && instance.evaluate) {\n return instance.interpolate(evaluation, evalContextValue, {\n noeval: true,\n });\n }\n return JSONLogicEvaluator.interpolate(evaluation, evalContextValue, {\n noeval: true,\n });\n}\nexports.interpolate = interpolate;\n__exportStar(__webpack_require__(/*! ./jsonLogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/jsonLogic.js\"), exports);\nexports.JSONLogicModule = {\n evaluator: JSONLogicEvaluator,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/modules/jsonlogic/index.js?");
|
380
380
|
|
381
381
|
/***/ }),
|
382
382
|
|
@@ -387,7 +387,7 @@ eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ?
|
|
387
387
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
388
388
|
|
389
389
|
"use strict";
|
390
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.jsonLogic = void 0;\nconst json_logic_js_1 = __importDefault(__webpack_require__(/*! json-logic-js */ \"./node_modules/json-logic-js/logic.js\"));\nexports.jsonLogic = json_logic_js_1.default;\nconst date_1 = __webpack_require__(/*! ../../utils/date */ \"./node_modules/@formio/core/lib/utils/date.js\");\nconst operators_1 = __webpack_require__(/*! ./operators */ \"./node_modules/@formio/core/lib/modules/jsonlogic/operators.js\");\n// Configure JsonLogic\nfor (
|
390
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.jsonLogic = void 0;\nconst json_logic_js_1 = __importDefault(__webpack_require__(/*! json-logic-js */ \"./node_modules/json-logic-js/logic.js\"));\nexports.jsonLogic = json_logic_js_1.default;\nconst date_1 = __webpack_require__(/*! ../../utils/date */ \"./node_modules/@formio/core/lib/utils/date.js\");\nconst operators_1 = __webpack_require__(/*! ./operators */ \"./node_modules/@formio/core/lib/modules/jsonlogic/operators.js\");\n// Configure JsonLogic\nfor (const operator in operators_1._) {\n json_logic_js_1.default.add_operation(`_${operator}`, operators_1._[operator]);\n}\n// Retrieve Any Date\njson_logic_js_1.default.add_operation('getDate', (date) => {\n return (0, date_1.dayjs)(date).toISOString();\n});\n// Set Relative Minimum Date\njson_logic_js_1.default.add_operation('relativeMinDate', (relativeMinDate) => {\n return (0, date_1.dayjs)().subtract(relativeMinDate, 'days').toISOString();\n});\n// Set Relative Maximum Date\njson_logic_js_1.default.add_operation('relativeMaxDate', (relativeMaxDate) => {\n return (0, date_1.dayjs)().add(relativeMaxDate, 'days').toISOString();\n});\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/modules/jsonlogic/jsonLogic.js?");
|
391
391
|
|
392
392
|
/***/ }),
|
393
393
|
|
@@ -398,7 +398,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
398
398
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
399
399
|
|
400
400
|
"use strict";
|
401
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports._ = void 0;\n// Use only immutable useful functions from Lodash.\n// Visit https://lodash.com/docs for more info.\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nexports._ = {\n chunk: lodash_1.chunk,\n compact: lodash_1.compact,\n concat: lodash_1.concat,\n difference: lodash_1.difference,\n drop: lodash_1.drop,\n dropRight: lodash_1.dropRight,\n findIndex: lodash_1.findIndex,\n findLastIndex: lodash_1.findLastIndex,\n first: lodash_1.first,\n flatten: lodash_1.flatten,\n flattenDeep: lodash_1.flattenDeep,\n flattenDepth: lodash_1.flattenDepth,\n fromPairs: lodash_1.fromPairs,\n head: lodash_1.head,\n indexOf: lodash_1.indexOf,\n initial: lodash_1.initial,\n intersection: lodash_1.intersection,\n intersectionBy: lodash_1.intersectionBy,\n intersectionWith: lodash_1.intersectionWith,\n join: lodash_1.join,\n last: lodash_1.last,\n lastIndexOf: lodash_1.lastIndexOf,\n nth: lodash_1.nth,\n slice: lodash_1.slice,\n sortedIndex: lodash_1.sortedIndex,\n sortedIndexBy: lodash_1.sortedIndexBy,\n sortedIndexOf: lodash_1.sortedIndexOf,\n sortedLastIndex: lodash_1.sortedLastIndex,\n sortedLastIndexBy: lodash_1.sortedLastIndexBy,\n sortedLastIndexOf: lodash_1.sortedLastIndexOf,\n sortedUniq: lodash_1.sortedUniq,\n sortedUniqBy: lodash_1.sortedUniqBy,\n tail: lodash_1.tail,\n take: lodash_1.take,\n takeRight: lodash_1.takeRight,\n takeRightWhile: lodash_1.takeRightWhile,\n takeWhile: lodash_1.takeWhile,\n union: lodash_1.union,\n unionBy: lodash_1.unionBy,\n unionWith: lodash_1.unionWith,\n uniq: lodash_1.uniq,\n uniqBy: lodash_1.uniqBy,\n uniqWith: lodash_1.uniqWith,\n unzip: lodash_1.unzip,\n unzipWith: lodash_1.unzipWith,\n without: lodash_1.without,\n xor: lodash_1.xor,\n xorBy: lodash_1.xorBy,\n xorWith: lodash_1.xorWith,\n zip: lodash_1.zip,\n zipObject: lodash_1.zipObject,\n zipObjectDeep: lodash_1.zipObjectDeep,\n zipWith: lodash_1.zipWith,\n countBy: lodash_1.countBy,\n every: lodash_1.every,\n filter: lodash_1.filter,\n find: lodash_1.find,\n findLast: lodash_1.findLast,\n flatMap: lodash_1.flatMap,\n flatMapDeep: lodash_1.flatMapDeep,\n flatMapDepth: lodash_1.flatMapDepth,\n groupBy: lodash_1.groupBy,\n includes: lodash_1.includes,\n invokeMap: lodash_1.invokeMap,\n keyBy: lodash_1.keyBy,\n map: lodash_1.map,\n orderBy: lodash_1.orderBy,\n partition: lodash_1.partition,\n reduce: lodash_1.reduce,\n reduceRight: lodash_1.reduceRight,\n reject: lodash_1.reject,\n sample: lodash_1.sample,\n sampleSize: lodash_1.sampleSize,\n shuffle: lodash_1.shuffle,\n size: lodash_1.size,\n some: lodash_1.some,\n sortBy: lodash_1.sortBy,\n now: lodash_1.now,\n flip: lodash_1.flip,\n negate: lodash_1.negate,\n overArgs: lodash_1.overArgs,\n partial: lodash_1.partial,\n partialRight: lodash_1.partialRight,\n rearg: lodash_1.rearg,\n rest: lodash_1.rest,\n spread: lodash_1.spread,\n castArray: lodash_1.castArray,\n clone: lodash_1.clone,\n cloneDeepWith: lodash_1.cloneDeepWith,\n cloneDeep: lodash_1.cloneDeep,\n conformsTo: lodash_1.conformsTo,\n eq: lodash_1.eq,\n gt: lodash_1.gt,\n gte: lodash_1.gte,\n isArguments: lodash_1.isArguments,\n isArray: lodash_1.isArray,\n isArrayBuffer: lodash_1.isArrayBuffer,\n isArrayLike: lodash_1.isArrayLike,\n isArrayLikeObject: lodash_1.isArrayLikeObject,\n isBoolean: lodash_1.isBoolean,\n isBuffer: lodash_1.isBuffer,\n isDate: lodash_1.isDate,\n isElement: lodash_1.isElement,\n isEmpty: lodash_1.isEmpty,\n isEqual: lodash_1.isEqual,\n isEqualWith: lodash_1.isEqualWith,\n isError: lodash_1.isError,\n isFinite: lodash_1.isFinite,\n isFunction: lodash_1.isFunction,\n isInteger: lodash_1.isInteger,\n isLength: lodash_1.isLength,\n isMap: lodash_1.isMap,\n isMatch: lodash_1.isMatch,\n isMatchWith: lodash_1.isMatchWith,\n isNaN: lodash_1.isNaN,\n isNative: lodash_1.isNative,\n isNil: lodash_1.isNil,\n isNull: lodash_1.isNull,\n isNumber: lodash_1.isNumber,\n isObject: lodash_1.isObject,\n isObjectLike: lodash_1.isObjectLike,\n isPlainObject: lodash_1.isPlainObject,\n isRegExp: lodash_1.isRegExp,\n isSafeInteger: lodash_1.isSafeInteger,\n isSet: lodash_1.isSet,\n isString: lodash_1.isString,\n isSymbol: lodash_1.isSymbol,\n isTypedArray: lodash_1.isTypedArray,\n isUndefined: lodash_1.isUndefined,\n isWeakMap: lodash_1.isWeakMap,\n isWeakSet: lodash_1.isWeakSet,\n lt: lodash_1.lt,\n lte: lodash_1.lte,\n toArray: lodash_1.toArray,\n toFinite: lodash_1.toFinite,\n toInteger: lodash_1.toInteger,\n toLength: lodash_1.toLength,\n toNumber: lodash_1.toNumber,\n toPlainObject: lodash_1.toPlainObject,\n toSafeInteger: lodash_1.toSafeInteger,\n toString: lodash_1.toString,\n add: lodash_1.add,\n ceil: lodash_1.ceil,\n divide: lodash_1.divide,\n floor: lodash_1.floor,\n max: lodash_1.max,\n maxBy: lodash_1.maxBy,\n mean: lodash_1.mean,\n meanBy: lodash_1.meanBy,\n min: lodash_1.min,\n minBy: lodash_1.minBy,\n multiply: lodash_1.multiply,\n round: lodash_1.round,\n subtract: lodash_1.subtract,\n sum: lodash_1.sum,\n sumBy: lodash_1.sumBy,\n clamp: lodash_1.clamp,\n inRange: lodash_1.inRange,\n random: lodash_1.random,\n at: lodash_1.at,\n entries: lodash_1.entries,\n entriesIn: lodash_1.entriesIn,\n findKey: lodash_1.findKey,\n findLastKey: lodash_1.findLastKey,\n functions: lodash_1.functions,\n functionsIn: lodash_1.functionsIn,\n get: lodash_1.get,\n has: lodash_1.has,\n hasIn: lodash_1.hasIn,\n invert: lodash_1.invert,\n invertBy: lodash_1.invertBy,\n invoke: lodash_1.invoke,\n keys: lodash_1.keys,\n keysIn: lodash_1.keysIn,\n mapKeys: lodash_1.mapKeys,\n mapValues: lodash_1.mapValues,\n omit: lodash_1.omit,\n omitBy: lodash_1.omitBy,\n pick: lodash_1.pick,\n pickBy: lodash_1.pickBy,\n result: lodash_1.result,\n toPairs: lodash_1.toPairs,\n toPairsIn: lodash_1.toPairsIn,\n transform: lodash_1.transform,\n values: lodash_1.values,\n valuesIn: lodash_1.valuesIn,\n camelCase: lodash_1.camelCase,\n capitalize: lodash_1.capitalize,\n deburr: lodash_1.deburr,\n endsWith: lodash_1.endsWith,\n escape: lodash_1.escape,\n escapeRegExp: lodash_1.escapeRegExp,\n kebabCase: lodash_1.kebabCase,\n lowerCase: lodash_1.lowerCase,\n lowerFirst: lodash_1.lowerFirst,\n pad: lodash_1.pad,\n padEnd: lodash_1.padEnd,\n padStart: lodash_1.padStart,\n parseInt: lodash_1.parseInt,\n repeat: lodash_1.repeat,\n replace: lodash_1.replace,\n snakeCase: lodash_1.snakeCase,\n split: lodash_1.split,\n startCase: lodash_1.startCase,\n startsWith: lodash_1.startsWith,\n toLower: lodash_1.toLower,\n toUpper: lodash_1.toUpper,\n trim: lodash_1.trim,\n trimEnd: lodash_1.trimEnd,\n trimStart: lodash_1.trimStart,\n truncate: lodash_1.truncate,\n unescape: lodash_1.unescape,\n upperCase: lodash_1.upperCase,\n upperFirst: lodash_1.upperFirst,\n words: lodash_1.words,\n cond: lodash_1.cond,\n conforms: lodash_1.conforms,\n constant: lodash_1.constant,\n defaultTo: lodash_1.defaultTo,\n flow: lodash_1.flow,\n flowRight: lodash_1.flowRight,\n identity: lodash_1.identity,\n iteratee: lodash_1.iteratee,\n matches: lodash_1.matches,\n matchesProperty: lodash_1.matchesProperty,\n method: lodash_1.method,\n methodOf: lodash_1.methodOf,\n nthArg: lodash_1.nthArg,\n over: lodash_1.over,\n overEvery: lodash_1.overEvery,\n overSome: lodash_1.overSome,\n property: lodash_1.property,\n propertyOf: lodash_1.propertyOf,\n range: lodash_1.range,\n rangeRight: lodash_1.rangeRight,\n stubArray: lodash_1.stubArray,\n stubFalse: lodash_1.stubFalse,\n stubObject: lodash_1.stubObject,\n stubString: lodash_1.stubString,\n stubTrue: lodash_1.stubTrue,\n times: lodash_1.times,\n toPath: lodash_1.toPath,\n uniqueId: lodash_1.uniqueId
|
401
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports._ = void 0;\n// Use only immutable useful functions from Lodash.\n// Visit https://lodash.com/docs for more info.\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nexports._ = {\n chunk: lodash_1.chunk,\n compact: lodash_1.compact,\n concat: lodash_1.concat,\n difference: lodash_1.difference,\n drop: lodash_1.drop,\n dropRight: lodash_1.dropRight,\n findIndex: lodash_1.findIndex,\n findLastIndex: lodash_1.findLastIndex,\n first: lodash_1.first,\n flatten: lodash_1.flatten,\n flattenDeep: lodash_1.flattenDeep,\n flattenDepth: lodash_1.flattenDepth,\n fromPairs: lodash_1.fromPairs,\n head: lodash_1.head,\n indexOf: lodash_1.indexOf,\n initial: lodash_1.initial,\n intersection: lodash_1.intersection,\n intersectionBy: lodash_1.intersectionBy,\n intersectionWith: lodash_1.intersectionWith,\n join: lodash_1.join,\n last: lodash_1.last,\n lastIndexOf: lodash_1.lastIndexOf,\n nth: lodash_1.nth,\n slice: lodash_1.slice,\n sortedIndex: lodash_1.sortedIndex,\n sortedIndexBy: lodash_1.sortedIndexBy,\n sortedIndexOf: lodash_1.sortedIndexOf,\n sortedLastIndex: lodash_1.sortedLastIndex,\n sortedLastIndexBy: lodash_1.sortedLastIndexBy,\n sortedLastIndexOf: lodash_1.sortedLastIndexOf,\n sortedUniq: lodash_1.sortedUniq,\n sortedUniqBy: lodash_1.sortedUniqBy,\n tail: lodash_1.tail,\n take: lodash_1.take,\n takeRight: lodash_1.takeRight,\n takeRightWhile: lodash_1.takeRightWhile,\n takeWhile: lodash_1.takeWhile,\n union: lodash_1.union,\n unionBy: lodash_1.unionBy,\n unionWith: lodash_1.unionWith,\n uniq: lodash_1.uniq,\n uniqBy: lodash_1.uniqBy,\n uniqWith: lodash_1.uniqWith,\n unzip: lodash_1.unzip,\n unzipWith: lodash_1.unzipWith,\n without: lodash_1.without,\n xor: lodash_1.xor,\n xorBy: lodash_1.xorBy,\n xorWith: lodash_1.xorWith,\n zip: lodash_1.zip,\n zipObject: lodash_1.zipObject,\n zipObjectDeep: lodash_1.zipObjectDeep,\n zipWith: lodash_1.zipWith,\n countBy: lodash_1.countBy,\n every: lodash_1.every,\n filter: lodash_1.filter,\n find: lodash_1.find,\n findLast: lodash_1.findLast,\n flatMap: lodash_1.flatMap,\n flatMapDeep: lodash_1.flatMapDeep,\n flatMapDepth: lodash_1.flatMapDepth,\n groupBy: lodash_1.groupBy,\n includes: lodash_1.includes,\n invokeMap: lodash_1.invokeMap,\n keyBy: lodash_1.keyBy,\n map: lodash_1.map,\n orderBy: lodash_1.orderBy,\n partition: lodash_1.partition,\n reduce: lodash_1.reduce,\n reduceRight: lodash_1.reduceRight,\n reject: lodash_1.reject,\n sample: lodash_1.sample,\n sampleSize: lodash_1.sampleSize,\n shuffle: lodash_1.shuffle,\n size: lodash_1.size,\n some: lodash_1.some,\n sortBy: lodash_1.sortBy,\n now: lodash_1.now,\n flip: lodash_1.flip,\n negate: lodash_1.negate,\n overArgs: lodash_1.overArgs,\n partial: lodash_1.partial,\n partialRight: lodash_1.partialRight,\n rearg: lodash_1.rearg,\n rest: lodash_1.rest,\n spread: lodash_1.spread,\n castArray: lodash_1.castArray,\n clone: lodash_1.clone,\n cloneDeepWith: lodash_1.cloneDeepWith,\n cloneDeep: lodash_1.cloneDeep,\n conformsTo: lodash_1.conformsTo,\n eq: lodash_1.eq,\n gt: lodash_1.gt,\n gte: lodash_1.gte,\n isArguments: lodash_1.isArguments,\n isArray: lodash_1.isArray,\n isArrayBuffer: lodash_1.isArrayBuffer,\n isArrayLike: lodash_1.isArrayLike,\n isArrayLikeObject: lodash_1.isArrayLikeObject,\n isBoolean: lodash_1.isBoolean,\n isBuffer: lodash_1.isBuffer,\n isDate: lodash_1.isDate,\n isElement: lodash_1.isElement,\n isEmpty: lodash_1.isEmpty,\n isEqual: lodash_1.isEqual,\n isEqualWith: lodash_1.isEqualWith,\n isError: lodash_1.isError,\n isFinite: lodash_1.isFinite,\n isFunction: lodash_1.isFunction,\n isInteger: lodash_1.isInteger,\n isLength: lodash_1.isLength,\n isMap: lodash_1.isMap,\n isMatch: lodash_1.isMatch,\n isMatchWith: lodash_1.isMatchWith,\n isNaN: lodash_1.isNaN,\n isNative: lodash_1.isNative,\n isNil: lodash_1.isNil,\n isNull: lodash_1.isNull,\n isNumber: lodash_1.isNumber,\n isObject: lodash_1.isObject,\n isObjectLike: lodash_1.isObjectLike,\n isPlainObject: lodash_1.isPlainObject,\n isRegExp: lodash_1.isRegExp,\n isSafeInteger: lodash_1.isSafeInteger,\n isSet: lodash_1.isSet,\n isString: lodash_1.isString,\n isSymbol: lodash_1.isSymbol,\n isTypedArray: lodash_1.isTypedArray,\n isUndefined: lodash_1.isUndefined,\n isWeakMap: lodash_1.isWeakMap,\n isWeakSet: lodash_1.isWeakSet,\n lt: lodash_1.lt,\n lte: lodash_1.lte,\n toArray: lodash_1.toArray,\n toFinite: lodash_1.toFinite,\n toInteger: lodash_1.toInteger,\n toLength: lodash_1.toLength,\n toNumber: lodash_1.toNumber,\n toPlainObject: lodash_1.toPlainObject,\n toSafeInteger: lodash_1.toSafeInteger,\n toString: lodash_1.toString,\n add: lodash_1.add,\n ceil: lodash_1.ceil,\n divide: lodash_1.divide,\n floor: lodash_1.floor,\n max: lodash_1.max,\n maxBy: lodash_1.maxBy,\n mean: lodash_1.mean,\n meanBy: lodash_1.meanBy,\n min: lodash_1.min,\n minBy: lodash_1.minBy,\n multiply: lodash_1.multiply,\n round: lodash_1.round,\n subtract: lodash_1.subtract,\n sum: lodash_1.sum,\n sumBy: lodash_1.sumBy,\n clamp: lodash_1.clamp,\n inRange: lodash_1.inRange,\n random: lodash_1.random,\n at: lodash_1.at,\n entries: lodash_1.entries,\n entriesIn: lodash_1.entriesIn,\n findKey: lodash_1.findKey,\n findLastKey: lodash_1.findLastKey,\n functions: lodash_1.functions,\n functionsIn: lodash_1.functionsIn,\n get: lodash_1.get,\n has: lodash_1.has,\n hasIn: lodash_1.hasIn,\n invert: lodash_1.invert,\n invertBy: lodash_1.invertBy,\n invoke: lodash_1.invoke,\n keys: lodash_1.keys,\n keysIn: lodash_1.keysIn,\n mapKeys: lodash_1.mapKeys,\n mapValues: lodash_1.mapValues,\n omit: lodash_1.omit,\n omitBy: lodash_1.omitBy,\n pick: lodash_1.pick,\n pickBy: lodash_1.pickBy,\n result: lodash_1.result,\n toPairs: lodash_1.toPairs,\n toPairsIn: lodash_1.toPairsIn,\n transform: lodash_1.transform,\n values: lodash_1.values,\n valuesIn: lodash_1.valuesIn,\n camelCase: lodash_1.camelCase,\n capitalize: lodash_1.capitalize,\n deburr: lodash_1.deburr,\n endsWith: lodash_1.endsWith,\n escape: lodash_1.escape,\n escapeRegExp: lodash_1.escapeRegExp,\n kebabCase: lodash_1.kebabCase,\n lowerCase: lodash_1.lowerCase,\n lowerFirst: lodash_1.lowerFirst,\n pad: lodash_1.pad,\n padEnd: lodash_1.padEnd,\n padStart: lodash_1.padStart,\n parseInt: lodash_1.parseInt,\n repeat: lodash_1.repeat,\n replace: lodash_1.replace,\n snakeCase: lodash_1.snakeCase,\n split: lodash_1.split,\n startCase: lodash_1.startCase,\n startsWith: lodash_1.startsWith,\n toLower: lodash_1.toLower,\n toUpper: lodash_1.toUpper,\n trim: lodash_1.trim,\n trimEnd: lodash_1.trimEnd,\n trimStart: lodash_1.trimStart,\n truncate: lodash_1.truncate,\n unescape: lodash_1.unescape,\n upperCase: lodash_1.upperCase,\n upperFirst: lodash_1.upperFirst,\n words: lodash_1.words,\n cond: lodash_1.cond,\n conforms: lodash_1.conforms,\n constant: lodash_1.constant,\n defaultTo: lodash_1.defaultTo,\n flow: lodash_1.flow,\n flowRight: lodash_1.flowRight,\n identity: lodash_1.identity,\n iteratee: lodash_1.iteratee,\n matches: lodash_1.matches,\n matchesProperty: lodash_1.matchesProperty,\n method: lodash_1.method,\n methodOf: lodash_1.methodOf,\n nthArg: lodash_1.nthArg,\n over: lodash_1.over,\n overEvery: lodash_1.overEvery,\n overSome: lodash_1.overSome,\n property: lodash_1.property,\n propertyOf: lodash_1.propertyOf,\n range: lodash_1.range,\n rangeRight: lodash_1.rangeRight,\n stubArray: lodash_1.stubArray,\n stubFalse: lodash_1.stubFalse,\n stubObject: lodash_1.stubObject,\n stubString: lodash_1.stubString,\n stubTrue: lodash_1.stubTrue,\n times: lodash_1.times,\n toPath: lodash_1.toPath,\n uniqueId: lodash_1.uniqueId,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/modules/jsonlogic/operators.js?");
|
402
402
|
|
403
403
|
/***/ }),
|
404
404
|
|
@@ -409,7 +409,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
409
409
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
410
410
|
|
411
411
|
"use strict";
|
412
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.calculateProcessInfo = exports.calculateProcess = exports.calculateProcessSync = exports.shouldCalculate = void 0;\nconst jsonlogic_1 = __webpack_require__(/*! ../../modules/jsonlogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/index.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst shouldCalculate = (context) => {\n const { component, config } = context;\n if (!component.calculateValue
|
412
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.calculateProcessInfo = exports.calculateProcess = exports.calculateProcessSync = exports.shouldCalculate = void 0;\nconst jsonlogic_1 = __webpack_require__(/*! ../../modules/jsonlogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/index.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst shouldCalculate = (context) => {\n const { component, config } = context;\n if (!component.calculateValue || ((config === null || config === void 0 ? void 0 : config.server) && !component.calculateServer)) {\n return false;\n }\n return true;\n};\nexports.shouldCalculate = shouldCalculate;\nconst calculateProcessSync = (context) => {\n const { component, data, evalContext, scope, path, value } = context;\n if (!(0, exports.shouldCalculate)(context)) {\n return;\n }\n const evalContextValue = evalContext ? evalContext(context) : context;\n evalContextValue.value = value || null;\n if (!scope.calculated)\n scope.calculated = [];\n const newValue = jsonlogic_1.JSONLogicEvaluator.evaluate(component.calculateValue, evalContextValue, 'value');\n // Only set a new value if it is not \"null\" which would be the case if no calculation occurred.\n if (newValue !== null) {\n scope.calculated.push({\n path,\n value: newValue,\n });\n (0, lodash_1.set)(data, path, newValue);\n }\n return;\n};\nexports.calculateProcessSync = calculateProcessSync;\nconst calculateProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.calculateProcessSync)(context);\n});\nexports.calculateProcess = calculateProcess;\nexports.calculateProcessInfo = {\n name: 'calculate',\n process: exports.calculateProcess,\n processSync: exports.calculateProcessSync,\n shouldProcess: exports.shouldCalculate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/calculation/index.js?");
|
413
413
|
|
414
414
|
/***/ }),
|
415
415
|
|
@@ -420,7 +420,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
420
420
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
421
421
|
|
422
422
|
"use strict";
|
423
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.clearHiddenProcessInfo = exports.clearHiddenProcess = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\n/**\n * This processor function checks components for the `hidden` property and unsets corresponding data\n */\nconst clearHiddenProcess = (context) => {\n var _a, _b;\n const { component, data, path, value, scope } = context;\n // No need to unset the value if it's undefined\n if (value === undefined) {\n return;\n }\n if (!scope.clearHidden) {\n scope.clearHidden = {};\n }\n // Check if there's a conditional set for the component and if it's marked as conditionally hidden\n const isConditionallyHidden = (_a = scope.conditionals) === null || _a === void 0 ? void 0 : _a.find((cond) => {\n return path === cond.path && cond.conditionallyHidden;\n });\n const shouldClearValueWhenHidden = !component.hasOwnProperty('clearOnHide') || component.clearOnHide;\n if (shouldClearValueWhenHidden
|
423
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.clearHiddenProcessInfo = exports.clearHiddenProcess = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\n/**\n * This processor function checks components for the `hidden` property and unsets corresponding data\n */\nconst clearHiddenProcess = (context) => {\n var _a, _b;\n const { component, data, path, value, scope } = context;\n // No need to unset the value if it's undefined\n if (value === undefined) {\n return;\n }\n if (!scope.clearHidden) {\n scope.clearHidden = {};\n }\n // Check if there's a conditional set for the component and if it's marked as conditionally hidden\n const isConditionallyHidden = (_a = scope.conditionals) === null || _a === void 0 ? void 0 : _a.find((cond) => {\n return path === cond.path && cond.conditionallyHidden;\n });\n const shouldClearValueWhenHidden = !component.hasOwnProperty('clearOnHide') || component.clearOnHide;\n if (shouldClearValueWhenHidden &&\n (isConditionallyHidden || component.hidden || ((_b = component.ephermalState) === null || _b === void 0 ? void 0 : _b.conditionallyHidden))) {\n (0, lodash_1.unset)(data, path);\n scope.clearHidden[path] = true;\n }\n};\nexports.clearHiddenProcess = clearHiddenProcess;\nexports.clearHiddenProcessInfo = {\n name: 'clearHidden',\n shouldProcess: () => true,\n processSync: exports.clearHiddenProcess,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/clearHidden.js?");
|
424
424
|
|
425
425
|
/***/ }),
|
426
426
|
|
@@ -431,7 +431,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
431
431
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
432
432
|
|
433
433
|
"use strict";
|
434
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.conditionProcessInfo = exports.simpleConditionProcessInfo = exports.customConditionProcessInfo = exports.conditionProcessSync = exports.conditionProcess = exports.simpleConditionProcessSync = exports.simpleConditionProcess = exports.customConditionProcessSync = exports.customConditionProcess = exports.conditionalProcess = exports.isConditionallyHidden = exports.isSimpleConditionallyHidden = exports.isCustomConditionallyHidden = exports.hasConditions = void 0;\nconst utils_1 = __webpack_require__(/*! ../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst conditions_1 = __webpack_require__(/*! ../../utils/conditions */ \"./node_modules/@formio/core/lib/utils/conditions.js\");\nconst hasCustomConditions = (context) => {\n const { component } = context;\n return !!component.customConditional;\n};\nconst hasSimpleConditions = (context) => {\n const { component } = context;\n const { conditional } = component;\n if ((0, conditions_1.isLegacyConditional)(conditional) ||\n (0, conditions_1.isSimpleConditional)(conditional) ||\n (0, conditions_1.isJSONConditional)(conditional)) {\n return true;\n }\n return false;\n};\nconst hasConditions = (context) => {\n return hasSimpleConditions(context) || hasCustomConditions(context);\n};\nexports.hasConditions = hasConditions;\nconst isCustomConditionallyHidden = (context) => {\n if (!hasCustomConditions(context)) {\n return false;\n }\n const { component } = context;\n const { customConditional } = component;\n let show = null;\n if (customConditional) {\n show = (0, conditions_1.checkCustomConditional)(customConditional, context, 'show');\n }\n if (show === null) {\n return false;\n }\n return !show;\n};\nexports.isCustomConditionallyHidden = isCustomConditionallyHidden;\nconst isSimpleConditionallyHidden = (context) => {\n if (!hasSimpleConditions(context)) {\n return false;\n }\n const { component } = context;\n const { conditional } = component;\n let show = null;\n if ((0, conditions_1.isJSONConditional)(conditional)) {\n show = (0, conditions_1.checkJsonConditional)(conditional, context);\n }\n if ((0, conditions_1.isLegacyConditional)(conditional)) {\n show = (0, conditions_1.checkLegacyConditional)(conditional, context);\n }\n if ((0, conditions_1.isSimpleConditional)(conditional)) {\n show = (0, conditions_1.checkSimpleConditional)(conditional, context);\n }\n if (show === null || show === undefined) {\n return false;\n }\n return !show;\n};\nexports.isSimpleConditionallyHidden = isSimpleConditionallyHidden;\nconst isConditionallyHidden = (context) => {\n return (0, exports.isCustomConditionallyHidden)(context) || (0, exports.isSimpleConditionallyHidden)(context);\n};\nexports.isConditionallyHidden = isConditionallyHidden;\nconst conditionalProcess = (context, isHidden) => {\n const { scope, path } = context;\n if (!(0, exports.hasConditions)(context)) {\n return;\n }\n if (!scope.conditionals) {\n scope.conditionals = [];\n }\n let conditionalComp = scope.conditionals.find((cond) =>
|
434
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.conditionProcessInfo = exports.simpleConditionProcessInfo = exports.customConditionProcessInfo = exports.conditionProcessSync = exports.conditionProcess = exports.simpleConditionProcessSync = exports.simpleConditionProcess = exports.customConditionProcessSync = exports.customConditionProcess = exports.conditionalProcess = exports.isConditionallyHidden = exports.isSimpleConditionallyHidden = exports.isCustomConditionallyHidden = exports.hasConditions = void 0;\nconst utils_1 = __webpack_require__(/*! ../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst conditions_1 = __webpack_require__(/*! ../../utils/conditions */ \"./node_modules/@formio/core/lib/utils/conditions.js\");\nconst hasCustomConditions = (context) => {\n const { component } = context;\n return !!component.customConditional;\n};\nconst hasSimpleConditions = (context) => {\n const { component } = context;\n const { conditional } = component;\n if ((0, conditions_1.isLegacyConditional)(conditional) ||\n (0, conditions_1.isSimpleConditional)(conditional) ||\n (0, conditions_1.isJSONConditional)(conditional)) {\n return true;\n }\n return false;\n};\nconst hasConditions = (context) => {\n return hasSimpleConditions(context) || hasCustomConditions(context);\n};\nexports.hasConditions = hasConditions;\nconst isCustomConditionallyHidden = (context) => {\n if (!hasCustomConditions(context)) {\n return false;\n }\n const { component } = context;\n const { customConditional } = component;\n let show = null;\n if (customConditional) {\n show = (0, conditions_1.checkCustomConditional)(customConditional, context, 'show');\n }\n if (show === null) {\n return false;\n }\n return !show;\n};\nexports.isCustomConditionallyHidden = isCustomConditionallyHidden;\nconst isSimpleConditionallyHidden = (context) => {\n if (!hasSimpleConditions(context)) {\n return false;\n }\n const { component } = context;\n const { conditional } = component;\n let show = null;\n if ((0, conditions_1.isJSONConditional)(conditional)) {\n show = (0, conditions_1.checkJsonConditional)(conditional, context);\n }\n if ((0, conditions_1.isLegacyConditional)(conditional)) {\n show = (0, conditions_1.checkLegacyConditional)(conditional, context);\n }\n if ((0, conditions_1.isSimpleConditional)(conditional)) {\n show = (0, conditions_1.checkSimpleConditional)(conditional, context);\n }\n if (show === null || show === undefined) {\n return false;\n }\n return !show;\n};\nexports.isSimpleConditionallyHidden = isSimpleConditionallyHidden;\nconst isConditionallyHidden = (context) => {\n return (0, exports.isCustomConditionallyHidden)(context) || (0, exports.isSimpleConditionallyHidden)(context);\n};\nexports.isConditionallyHidden = isConditionallyHidden;\nconst conditionalProcess = (context, isHidden) => {\n const { scope, path } = context;\n if (!(0, exports.hasConditions)(context)) {\n return;\n }\n if (!scope.conditionals) {\n scope.conditionals = [];\n }\n let conditionalComp = scope.conditionals.find((cond) => cond.path === path);\n if (!conditionalComp) {\n conditionalComp = { path, conditionallyHidden: false };\n scope.conditionals.push(conditionalComp);\n }\n conditionalComp.conditionallyHidden =\n conditionalComp.conditionallyHidden || isHidden(context) === true;\n if (conditionalComp.conditionallyHidden) {\n (0, utils_1.registerEphermalState)(context.component, 'conditionallyHidden', true);\n }\n};\nexports.conditionalProcess = conditionalProcess;\nconst customConditionProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.customConditionProcessSync)(context);\n});\nexports.customConditionProcess = customConditionProcess;\nconst customConditionProcessSync = (context) => {\n return (0, exports.conditionalProcess)(context, exports.isCustomConditionallyHidden);\n};\nexports.customConditionProcessSync = customConditionProcessSync;\nconst simpleConditionProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.simpleConditionProcessSync)(context);\n});\nexports.simpleConditionProcess = simpleConditionProcess;\nconst simpleConditionProcessSync = (context) => {\n return (0, exports.conditionalProcess)(context, exports.isSimpleConditionallyHidden);\n};\nexports.simpleConditionProcessSync = simpleConditionProcessSync;\nconst conditionProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.conditionProcessSync)(context);\n});\nexports.conditionProcess = conditionProcess;\nconst conditionProcessSync = (context) => {\n return (0, exports.conditionalProcess)(context, exports.isConditionallyHidden);\n};\nexports.conditionProcessSync = conditionProcessSync;\nexports.customConditionProcessInfo = {\n name: 'customConditions',\n process: exports.customConditionProcess,\n processSync: exports.customConditionProcessSync,\n shouldProcess: hasCustomConditions,\n};\nexports.simpleConditionProcessInfo = {\n name: 'simpleConditions',\n process: exports.simpleConditionProcess,\n processSync: exports.simpleConditionProcessSync,\n shouldProcess: hasSimpleConditions,\n};\nexports.conditionProcessInfo = {\n name: 'conditions',\n process: exports.conditionProcess,\n processSync: exports.conditionProcessSync,\n shouldProcess: hasSimpleConditions,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/conditions/index.js?");
|
435
435
|
|
436
436
|
/***/ }),
|
437
437
|
|
@@ -442,7 +442,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
442
442
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
443
443
|
|
444
444
|
"use strict";
|
445
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.defaultValueProcessInfo = exports.serverDefaultValueProcessInfo = exports.customDefaultValueProcessInfo = exports.defaultValueProcessSync = exports.defaultValueProcess = exports.serverDefaultValueProcessSync = exports.serverDefaultValueProcess = exports.customDefaultValueProcessSync = exports.customDefaultValueProcess = exports.hasDefaultValue = exports.hasServerDefaultValue = exports.hasCustomDefaultValue = void 0;\nconst jsonlogic_1 = __webpack_require__(/*! ../../modules/jsonlogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/index.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst formUtil_1 = __webpack_require__(/*! ../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst hasCustomDefaultValue = (context) => {\n const { component } = context;\n if (!component.customDefaultValue) {\n return false;\n }\n return true;\n};\nexports.hasCustomDefaultValue = hasCustomDefaultValue;\nconst hasServerDefaultValue = (context) => {\n const { component } = context;\n if (!component.hasOwnProperty('defaultValue')) {\n return false;\n }\n return true;\n};\nexports.hasServerDefaultValue = hasServerDefaultValue;\nconst hasDefaultValue = (context) => {\n return (0, exports.hasCustomDefaultValue)(context) || (0, exports.hasServerDefaultValue)(context);\n};\nexports.hasDefaultValue = hasDefaultValue;\nconst customDefaultValueProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.customDefaultValueProcessSync)(context);\n});\nexports.customDefaultValueProcess = customDefaultValueProcess;\nconst customDefaultValueProcessSync = (context) => {\n const { component, row, data, scope, evalContext, path } = context;\n if (!(0, exports.hasCustomDefaultValue)(context)) {\n return;\n }\n if (!scope.defaultValues)\n scope.defaultValues = [];\n if ((0, lodash_1.has)(row, (0, formUtil_1.getComponentKey)(component))) {\n return;\n }\n let defaultValue = null;\n if (component.customDefaultValue) {\n const evalContextValue = evalContext ? evalContext(context) : context;\n evalContextValue.value = null;\n defaultValue = jsonlogic_1.JSONLogicEvaluator.evaluate(component.customDefaultValue, evalContextValue, 'value');\n if (component.multiple && !Array.isArray(defaultValue)) {\n defaultValue = defaultValue ? [defaultValue] : [];\n }\n scope.defaultValues.push({\n path,\n value: defaultValue
|
445
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.defaultValueProcessInfo = exports.serverDefaultValueProcessInfo = exports.customDefaultValueProcessInfo = exports.defaultValueProcessSync = exports.defaultValueProcess = exports.serverDefaultValueProcessSync = exports.serverDefaultValueProcess = exports.customDefaultValueProcessSync = exports.customDefaultValueProcess = exports.hasDefaultValue = exports.hasServerDefaultValue = exports.hasCustomDefaultValue = void 0;\nconst jsonlogic_1 = __webpack_require__(/*! ../../modules/jsonlogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/index.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst formUtil_1 = __webpack_require__(/*! ../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst hasCustomDefaultValue = (context) => {\n const { component } = context;\n if (!component.customDefaultValue) {\n return false;\n }\n return true;\n};\nexports.hasCustomDefaultValue = hasCustomDefaultValue;\nconst hasServerDefaultValue = (context) => {\n const { component } = context;\n if (!component.hasOwnProperty('defaultValue')) {\n return false;\n }\n return true;\n};\nexports.hasServerDefaultValue = hasServerDefaultValue;\nconst hasDefaultValue = (context) => {\n return (0, exports.hasCustomDefaultValue)(context) || (0, exports.hasServerDefaultValue)(context);\n};\nexports.hasDefaultValue = hasDefaultValue;\nconst customDefaultValueProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.customDefaultValueProcessSync)(context);\n});\nexports.customDefaultValueProcess = customDefaultValueProcess;\nconst customDefaultValueProcessSync = (context) => {\n const { component, row, data, scope, evalContext, path } = context;\n if (!(0, exports.hasCustomDefaultValue)(context)) {\n return;\n }\n if (!scope.defaultValues)\n scope.defaultValues = [];\n if ((0, lodash_1.has)(row, (0, formUtil_1.getComponentKey)(component))) {\n return;\n }\n let defaultValue = null;\n if (component.customDefaultValue) {\n const evalContextValue = evalContext ? evalContext(context) : context;\n evalContextValue.value = null;\n defaultValue = jsonlogic_1.JSONLogicEvaluator.evaluate(component.customDefaultValue, evalContextValue, 'value');\n if (component.multiple && !Array.isArray(defaultValue)) {\n defaultValue = defaultValue ? [defaultValue] : [];\n }\n scope.defaultValues.push({\n path,\n value: defaultValue,\n });\n }\n if (defaultValue !== null && defaultValue !== undefined) {\n (0, lodash_1.set)(data, path, defaultValue);\n }\n};\nexports.customDefaultValueProcessSync = customDefaultValueProcessSync;\nconst serverDefaultValueProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.serverDefaultValueProcessSync)(context);\n});\nexports.serverDefaultValueProcess = serverDefaultValueProcess;\nconst serverDefaultValueProcessSync = (context) => {\n const { component, row, data, scope, path } = context;\n if (!(0, exports.hasServerDefaultValue)(context)) {\n return;\n }\n if (!scope.defaultValues)\n scope.defaultValues = [];\n if ((0, lodash_1.has)(row, (0, formUtil_1.getComponentKey)(component))) {\n return;\n }\n let defaultValue = null;\n if (component.defaultValue !== undefined && component.defaultValue !== null) {\n defaultValue = component.defaultValue;\n if (component.multiple && !Array.isArray(defaultValue)) {\n defaultValue = defaultValue ? [defaultValue] : [];\n }\n scope.defaultValues.push({\n path,\n value: defaultValue,\n });\n }\n if (defaultValue !== null && defaultValue !== undefined) {\n (0, lodash_1.set)(data, path, defaultValue);\n }\n};\nexports.serverDefaultValueProcessSync = serverDefaultValueProcessSync;\nconst defaultValueProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.defaultValueProcessSync)(context);\n});\nexports.defaultValueProcess = defaultValueProcess;\nconst defaultValueProcessSync = (context) => {\n (0, exports.customDefaultValueProcessSync)(context);\n (0, exports.serverDefaultValueProcessSync)(context);\n};\nexports.defaultValueProcessSync = defaultValueProcessSync;\nexports.customDefaultValueProcessInfo = {\n name: 'customDefaultValue',\n process: exports.customDefaultValueProcess,\n processSync: exports.customDefaultValueProcessSync,\n shouldProcess: exports.hasCustomDefaultValue,\n};\nexports.serverDefaultValueProcessInfo = {\n name: 'serverDefaultValue',\n process: exports.serverDefaultValueProcess,\n processSync: exports.serverDefaultValueProcessSync,\n shouldProcess: exports.hasServerDefaultValue,\n};\nexports.defaultValueProcessInfo = {\n name: 'defaultValue',\n process: exports.defaultValueProcess,\n processSync: exports.defaultValueProcessSync,\n shouldProcess: exports.hasDefaultValue,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/defaultValue/index.js?");
|
446
446
|
|
447
447
|
/***/ }),
|
448
448
|
|
@@ -453,7 +453,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
453
453
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
454
454
|
|
455
455
|
"use strict";
|
456
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.dereferenceProcessInfo = exports.dereferenceProcess = void 0;\nconst error_1 = __webpack_require__(/*! ../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst utils_1 = __webpack_require__(/*! ../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst isDereferenceableDataTableComponent = (component) => {\n var _a, _b, _c;\n return component
|
456
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.dereferenceProcessInfo = exports.dereferenceProcess = void 0;\nconst error_1 = __webpack_require__(/*! ../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst utils_1 = __webpack_require__(/*! ../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst isDereferenceableDataTableComponent = (component) => {\n var _a, _b, _c;\n return (component &&\n component.type === 'datatable' &&\n ((_a = component.fetch) === null || _a === void 0 ? void 0 : _a.enableFetch) === true &&\n ((_b = component.fetch) === null || _b === void 0 ? void 0 : _b.dataSrc) === 'resource' &&\n typeof ((_c = component.fetch) === null || _c === void 0 ? void 0 : _c.resource) === 'string');\n};\n/**\n * This function is used to dereference reference IDs contained in the form.\n * It is currently only compatible with Data Table components.\n * @todo Add support for other components (if applicable) and for submission data dereferencing (e.g. save-as-reference, currently a property action).\n */\nconst dereferenceProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n var _a;\n const { component, config, scope, path } = context;\n if (!scope.dereference) {\n scope.dereference = {};\n }\n if (!isDereferenceableDataTableComponent(component)) {\n return;\n }\n if (!(config === null || config === void 0 ? void 0 : config.database)) {\n throw new error_1.ProcessorError('Cannot dereference resource value without a database config object', context, 'dereference');\n }\n try {\n const components = yield ((_a = config.database) === null || _a === void 0 ? void 0 : _a.dereferenceDataTableComponent(component));\n const vmCompatibleComponents = (0, utils_1.fastCloneDeep)(components);\n scope.dereference[path] = vmCompatibleComponents;\n // Modify the components in place; we have to do this now as opposed to a \"post-processor\" step because\n // eachComponentDataAsync will immediately turn around and introspect these components in the case of Data Table\n component.components = vmCompatibleComponents;\n }\n catch (err) {\n throw new error_1.ProcessorError(err.message || err, context, 'dereference');\n }\n});\nexports.dereferenceProcess = dereferenceProcess;\nexports.dereferenceProcessInfo = {\n name: 'dereference',\n shouldProcess: () => true,\n process: exports.dereferenceProcess,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/dereference/index.js?");
|
457
457
|
|
458
458
|
/***/ }),
|
459
459
|
|
@@ -464,7 +464,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
464
464
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
465
465
|
|
466
466
|
"use strict";
|
467
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.fetchProcessInfo = exports.fetchProcess = exports.shouldFetch = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst utils_1 = __webpack_require__(/*! ../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst formUtil_1 = __webpack_require__(/*! ../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst shouldFetch = (context) => {\n const { component, config } = context;\n if (component.type !== 'datasource' ||\n ((config === null || config === void 0 ? void 0 : config.server) && !(0, lodash_1.get)(component, 'trigger.server', false))) {\n return false;\n }\n return true;\n};\nexports.shouldFetch = shouldFetch;\nconst fetchProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n var _a;\n const { component, row, evalContext, path, scope, config } = context;\n let _fetch = null;\n try {\n _fetch = context.fetch ? context.fetch : fetch;\n }\n catch (
|
467
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.fetchProcessInfo = exports.fetchProcess = exports.shouldFetch = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst utils_1 = __webpack_require__(/*! ../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst formUtil_1 = __webpack_require__(/*! ../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst shouldFetch = (context) => {\n const { component, config } = context;\n if (component.type !== 'datasource' ||\n ((config === null || config === void 0 ? void 0 : config.server) && !(0, lodash_1.get)(component, 'trigger.server', false))) {\n return false;\n }\n return true;\n};\nexports.shouldFetch = shouldFetch;\nconst fetchProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n var _a;\n const { component, row, evalContext, path, scope, config } = context;\n let _fetch = null;\n try {\n _fetch = context.fetch ? context.fetch : fetch;\n }\n catch (ignoreErr) {\n _fetch = null;\n }\n if (!_fetch) {\n console.log('You must provide a fetch interface to the fetch processor.');\n return;\n }\n if (!(0, exports.shouldFetch)(context)) {\n return;\n }\n if (!scope.fetched)\n scope.fetched = {};\n const evalContextValue = evalContext ? evalContext(context) : context;\n const url = utils_1.Evaluator.interpolateString((0, lodash_1.get)(component, 'fetch.url', ''), evalContextValue);\n if (!url) {\n return;\n }\n const request = {\n method: (0, lodash_1.get)(component, 'fetch.method', 'get').toUpperCase(),\n headers: {},\n };\n if ((config === null || config === void 0 ? void 0 : config.headers) &&\n (component === null || component === void 0 ? void 0 : component.fetch) &&\n ((_a = component === null || component === void 0 ? void 0 : component.fetch) === null || _a === void 0 ? void 0 : _a.forwardHeaders)) {\n request.headers = JSON.parse(JSON.stringify(config.headers));\n delete request.headers['host'];\n delete request.headers['content-length'];\n delete request.headers['content-type'];\n delete request.headers['connection'];\n delete request.headers['cache-control'];\n }\n request.headers['Accept'] = '*/*';\n request.headers['user-agent'] = 'Form.io DataSource Component';\n (0, lodash_1.get)(component, 'fetch.headers', []).map((header) => {\n header.value = utils_1.Evaluator.interpolateString(header.value, evalContextValue);\n if (header.value && header.key) {\n request.headers[header.key] = header.value;\n }\n return header;\n });\n if ((0, lodash_1.get)(component, 'fetch.authenticate', false) && (config === null || config === void 0 ? void 0 : config.tokens)) {\n Object.assign(request.headers, config.tokens);\n }\n const body = (0, lodash_1.get)(component, 'fetch.specifyBody', '');\n if (request.method === 'POST') {\n request.body = JSON.stringify(utils_1.Evaluator.evaluate(body, evalContextValue, 'body'));\n }\n try {\n // Perform the fetch.\n const result = yield (yield _fetch(url, request)).json();\n const mapFunction = (0, lodash_1.get)(component, 'fetch.mapFunction');\n // Set the row data of the fetched value.\n const key = (0, formUtil_1.getComponentKey)(component);\n (0, lodash_1.set)(row, key, mapFunction\n ? utils_1.Evaluator.evaluate(mapFunction, Object.assign(Object.assign({}, evalContextValue), { responseData: result }), 'value')\n : result);\n // Make sure the value does not get filtered for now...\n if (!scope.filter)\n scope.filter = {};\n scope.filter[path] = true;\n scope.fetched[path] = true;\n }\n catch (err) {\n console.log(err.message);\n }\n});\nexports.fetchProcess = fetchProcess;\nexports.fetchProcessInfo = {\n name: 'fetch',\n process: exports.fetchProcess,\n shouldProcess: exports.shouldFetch,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/fetch/index.js?");
|
468
468
|
|
469
469
|
/***/ }),
|
470
470
|
|
@@ -475,7 +475,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
475
475
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
476
476
|
|
477
477
|
"use strict";
|
478
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.filterProcessInfo = exports.filterPostProcess = exports.filterProcess = exports.filterProcessSync = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst utils_1 = __webpack_require__(/*! ../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst lodash_2 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst formUtil_1 = __webpack_require__(/*! ../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst filterProcessSync = (context) => {\n const { scope, component } = context;\n
|
478
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.filterProcessInfo = exports.filterPostProcess = exports.filterProcess = exports.filterProcessSync = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst utils_1 = __webpack_require__(/*! ../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst lodash_2 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst formUtil_1 = __webpack_require__(/*! ../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst filterProcessSync = (context) => {\n const { scope, component } = context;\n const { value } = context;\n const absolutePath = (0, formUtil_1.getComponentAbsolutePath)(component);\n if (!scope.filter)\n scope.filter = {};\n if (value !== undefined) {\n const modelType = utils_1.Utils.getModelType(component);\n switch (modelType) {\n case 'dataObject':\n scope.filter[absolutePath] = {\n compModelType: modelType,\n include: true,\n value: { data: {} },\n };\n break;\n case 'nestedArray':\n scope.filter[absolutePath] = {\n compModelType: modelType,\n include: true,\n value: [],\n };\n break;\n case 'nestedDataArray':\n scope.filter[absolutePath] = {\n compModelType: modelType,\n include: true,\n value: Array.isArray(value) ? value.map((v) => (Object.assign(Object.assign({}, v), { data: {} }))) : [],\n };\n break;\n case 'object':\n scope.filter[absolutePath] = {\n compModelType: modelType,\n include: true,\n value: component.type === 'address' ? false : {},\n };\n break;\n default:\n scope.filter[absolutePath] = {\n compModelType: modelType,\n include: true,\n };\n break;\n }\n }\n};\nexports.filterProcessSync = filterProcessSync;\nconst filterProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.filterProcessSync)(context);\n});\nexports.filterProcess = filterProcess;\nconst filterPostProcess = (context) => {\n var _a;\n const { scope, submission } = context;\n const filtered = {};\n for (const path in scope.filter) {\n if (scope.filter[path].include) {\n let value = (0, lodash_2.get)(submission === null || submission === void 0 ? void 0 : submission.data, path);\n if (scope.filter[path].value) {\n if ((0, lodash_2.isObject)(value) && ((_a = scope.filter[path].value) === null || _a === void 0 ? void 0 : _a.data)) {\n value = Object.assign(Object.assign({}, value), scope.filter[path].value);\n }\n else {\n value = scope.filter[path].value;\n }\n }\n (0, lodash_1.set)(filtered, path, value);\n }\n }\n context.data = filtered;\n};\nexports.filterPostProcess = filterPostProcess;\nexports.filterProcessInfo = {\n name: 'filter',\n process: exports.filterProcess,\n processSync: exports.filterProcessSync,\n postProcess: exports.filterPostProcess,\n shouldProcess: () => true,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/filter/index.js?");
|
479
479
|
|
480
480
|
/***/ }),
|
481
481
|
|
@@ -508,7 +508,7 @@ eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ?
|
|
508
508
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
509
509
|
|
510
510
|
"use strict";
|
511
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.logicProcessInfo = exports.logicProcess = exports.logicProcessSync = void 0;\nconst logic_1 = __webpack_require__(/*! ../../utils/logic */ \"./node_modules/@formio/core/lib/utils/logic.js\");\n// This processor ensures that a \"linked\" row context is provided to every component.\nconst logicProcessSync = (context) => {\n return (0, logic_1.applyActions)(context);\n};\nexports.logicProcessSync = logicProcessSync;\nconst logicProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.logicProcessSync)(context);\n});\nexports.logicProcess = logicProcess;\nexports.logicProcessInfo = {\n name: 'logic',\n process: exports.logicProcess,\n processSync: exports.logicProcessSync,\n shouldProcess: logic_1.hasLogic
|
511
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.logicProcessInfo = exports.logicProcess = exports.logicProcessSync = void 0;\nconst logic_1 = __webpack_require__(/*! ../../utils/logic */ \"./node_modules/@formio/core/lib/utils/logic.js\");\n// This processor ensures that a \"linked\" row context is provided to every component.\nconst logicProcessSync = (context) => {\n return (0, logic_1.applyActions)(context);\n};\nexports.logicProcessSync = logicProcessSync;\nconst logicProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.logicProcessSync)(context);\n});\nexports.logicProcess = logicProcess;\nexports.logicProcessInfo = {\n name: 'logic',\n process: exports.logicProcess,\n processSync: exports.logicProcessSync,\n shouldProcess: logic_1.hasLogic,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/logic/index.js?");
|
512
512
|
|
513
513
|
/***/ }),
|
514
514
|
|
@@ -519,7 +519,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
519
519
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
520
520
|
|
521
521
|
"use strict";
|
522
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.normalizeProcessInfo = exports.normalizeProcessSync = exports.normalizeProcess = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst dayjs_1 = __importDefault(__webpack_require__(/*! dayjs */ \"./node_modules/dayjs/dayjs.min.js\"));\nconst customParseFormat_1 = __importDefault(__webpack_require__(/*! dayjs/plugin/customParseFormat */ \"./node_modules/dayjs/plugin/customParseFormat.js\"));\ndayjs_1.default.extend(customParseFormat_1.default);\nconst isAddressComponent = (component) => component.type === \"address\";\nconst isDayComponent = (component) => component.type === \"day\";\nconst isEmailComponent = (component) => component.type === \"email\";\nconst isRadioComponent = (component) => component.type === \"radio\";\nconst isRecaptchaComponent = (component) => component.type === \"recaptcha\";\nconst isSelectComponent = (component) => component.type === \"select\";\nconst isSelectBoxesComponent = (component) => component.type === \"selectboxes\";\nconst isTagsComponent = (component) => component.type === \"tags\";\nconst isTextFieldComponent = (component) => component.type === \"textfield\";\nconst isTimeComponent = (component) => component.type === \"time\";\nconst isNumberComponent = (component) => component.type === \"number\";\nconst normalizeAddressComponentValue = (component, value) => {\n if (!component.multiple && Boolean(component.enableManualMode) && value && !value.mode) {\n return {\n mode: 'autocomplete',\n address: value,\n };\n }\n return value;\n};\nconst getLocaleDateFormatInfo = (locale = 'en') => {\n const formatInfo = {};\n const day = 21;\n const exampleDate = new Date(2017, 11, day);\n const localDateString = exampleDate.toLocaleDateString(locale);\n formatInfo.dayFirst = localDateString.slice(0, 2) === day.toString();\n return formatInfo;\n};\nconst getLocaleDayFirst = (component, form) => {\n var _a;\n if (component.useLocaleSettings) {\n return getLocaleDateFormatInfo((_a = form.options) === null || _a === void 0 ? void 0 : _a.language).dayFirst;\n }\n return component.dayFirst;\n};\nconst normalizeDayComponentValue = (component, form, value) => {\n // TODO: this is a quick and dirty port of the Day component's normalizeValue method, may need some updates\n const valueMask = /^\\d{2}\\/\\d{2}\\/\\d{4}$/;\n const isDayFirst = getLocaleDayFirst(component, form);\n const showDay = !(0, lodash_1.get)(component, 'fields.day.hide', false);\n const showMonth = !(0, lodash_1.get)(component, 'fields.month.hide', false);\n const showYear = !(0, lodash_1.get)(component, 'fields.year.hide', false);\n if (!value || valueMask.test(value)) {\n return value;\n }\n let dateParts = [];\n const valueParts = value.split('/');\n const [DAY, MONTH, YEAR] = component.dayFirst ? [0, 1, 2] : [1, 0, 2];\n const defaultValue = component.defaultValue ? component.defaultValue.split('/') : '';\n let defaultDay = '';\n let defaultMonth = '';\n let defaultYear = '';\n const getDayWithHiddenFields = (parts) => {\n let DAY, MONTH, YEAR;\n [DAY, MONTH, YEAR] = component.dayFirst ? [0, 1, 2] : [1, 0, 2];\n if (!showDay) {\n MONTH = MONTH === 0 ? 0 : MONTH - 1;\n YEAR = YEAR - 1;\n DAY = null;\n }\n if (!showMonth) {\n if (!(0, lodash_1.isNull)(DAY)) {\n DAY = DAY === 0 ? 0 : DAY - 1;\n }\n YEAR = YEAR - 1;\n MONTH = null;\n }\n if (!showYear) {\n YEAR = null;\n }\n return {\n month: (0, lodash_1.isNull)(MONTH) ? '' : parts[MONTH],\n day: (0, lodash_1.isNull)(DAY) ? '' : parts[DAY],\n year: (0, lodash_1.isNull)(YEAR) ? '' : parts[YEAR],\n };\n };\n const getNextPart = (shouldTake, defaultValue) => {\n // Only push the part if it's not an empty string\n const part = shouldTake ? valueParts.shift() : defaultValue;\n if (part !== '') {\n dateParts.push(part);\n }\n };\n if (defaultValue) {\n const hasHiddenFields = defaultValue.length !== 3;\n defaultDay = hasHiddenFields ? getDayWithHiddenFields(defaultValue).day : defaultValue[DAY];\n defaultMonth = hasHiddenFields ? getDayWithHiddenFields(defaultValue).month : defaultValue[MONTH];\n defaultYear = hasHiddenFields ? getDayWithHiddenFields(defaultValue).year : defaultValue[YEAR];\n }\n if (isDayFirst) {\n getNextPart(showDay, defaultDay);\n }\n getNextPart(showMonth, defaultMonth);\n if (!isDayFirst) {\n getNextPart(showDay, defaultDay);\n }\n getNextPart(showYear, defaultYear);\n return dateParts.join('/');\n};\nconst normalizeRadioComponentValue = (value, dataType) => {\n switch (dataType) {\n case 'number':\n return +value;\n case 'string':\n return typeof value === 'object' ? JSON.stringify(value) : String(value);\n case 'boolean':\n return !(!value || value.toString() === 'false');\n }\n const isEquivalent = (0, lodash_1.toString)(value) === Number(value).toString();\n if (!isNaN(parseFloat(value)) && isFinite(value) && isEquivalent) {\n return +value;\n }\n if (value === 'true') {\n return true;\n }\n if (value === 'false') {\n return false;\n }\n return value;\n};\nconst normalizeSingleSelectComponentValue = (component, value) => {\n if ((0, lodash_1.isNil)(value)) {\n return;\n }\n const valueIsObject = (0, lodash_1.isObject)(value);\n //check if value equals to default emptyValue\n if (valueIsObject && Object.keys(value).length === 0) {\n return value;\n }\n const dataType = component.dataType || 'auto';\n const normalize = {\n value,\n number() {\n const numberValue = Number(this.value);\n const isEquivalent = value.toString() === numberValue.toString();\n if (!Number.isNaN(numberValue) && Number.isFinite(numberValue) && value !== '' && isEquivalent) {\n this.value = numberValue;\n }\n return this;\n },\n boolean() {\n if ((0, lodash_1.isString)(this.value) && (this.value.toLowerCase() === 'true' || this.value.toLowerCase() === 'false')) {\n this.value = (this.value.toLowerCase() === 'true');\n }\n return this;\n },\n string() {\n this.value = String(this.value);\n return this;\n },\n object() {\n return this;\n },\n auto() {\n if ((0, lodash_1.isObject)(this.value)) {\n this.value = this.object().value;\n }\n else {\n this.value = this.string().number().boolean().value;\n }\n return this;\n }\n };\n try {\n return normalize[dataType]().value;\n }\n catch (err) {\n console.warn('Failed to normalize value', err);\n return value;\n }\n};\nconst normalizeSelectComponentValue = (component, value) => {\n if (component.multiple && Array.isArray(value)) {\n return value.map((singleValue) => normalizeSingleSelectComponentValue(component, singleValue));\n }\n return normalizeSingleSelectComponentValue(component, value);\n};\nconst normalizeSelectBoxesComponentValue = (value) => {\n if (!value) {\n value = {};\n }\n if (typeof value !== 'object') {\n if (typeof value === 'string') {\n return {\n [value]: true\n };\n }\n else {\n return {};\n }\n }\n if (Array.isArray(value)) {\n return value.reduce((acc, curr) => {\n return Object.assign(Object.assign({}, acc), { [curr]: true });\n }, {});\n }\n return value;\n};\nconst normalizeTagsComponentValue = (component, value) => {\n const delimiter = component.delimeter || ',';\n if ((!component.hasOwnProperty('storeas') || component.storeas === 'string') && Array.isArray(value)) {\n return value.join(delimiter);\n }\n else if (component.storeas === 'array' && typeof value === 'string') {\n return value.split(delimiter).filter(result => result);\n }\n return value;\n};\nconst normalizeMaskValue = (component, defaultValues, value, path) => {\n if (component.inputMasks && component.inputMasks.length > 0) {\n if (!value || typeof value !== 'object') {\n return {\n value: value,\n maskName: component.inputMasks[0].label\n };\n }\n if (!value.value) {\n const defaultValue = defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.find((defaultValue) => defaultValue.path === path);\n value.value = Array.isArray(defaultValue) && defaultValue.length > 0 ? defaultValue[0] : defaultValue;\n }\n }\n return value;\n};\nconst normalizeTextFieldComponentValue = (component, defaultValues, value, path) => {\n // If the component has truncate multiple spaces enabled, then normalize the value to remove extra spaces.\n if (component.truncateMultipleSpaces && typeof value === 'string') {\n value = value.trim().replace(/\\s{2,}/g, ' ');\n }\n if (component.allowMultipleMasks && component.inputMasks && component.inputMasks.length > 0) {\n if (Array.isArray(value)) {\n return value.map((val) => normalizeMaskValue(component, defaultValues, val, path));\n }\n else {\n return normalizeMaskValue(component, defaultValues, value, path);\n }\n }\n return value;\n};\n// Allow submissions of time components in their visual \"format\" property by coercing them to the \"dataFormat\" property\n// i.e. \"HH:mm\" -> \"HH:mm:ss\"\nconst normalizeTimeComponentValue = (component, value) => {\n const defaultDataFormat = 'HH:mm:ss';\n const defaultFormat = 'HH:mm';\n if ((0, dayjs_1.default)(value, component.format || defaultFormat, true).isValid()) {\n return (0, dayjs_1.default)(value, component.format || defaultFormat, true).format(component.dataFormat || defaultDataFormat);\n }\n return value;\n};\nconst normalizeSingleNumberComponentValue = (component, value) => {\n if (!isNaN(parseFloat(value)) && isFinite(value)) {\n return +value;\n }\n return value;\n};\nconst normalizeNumberComponentValue = (component, value) => {\n if (component.multiple && Array.isArray(value)) {\n return value.map((singleValue) => normalizeSingleNumberComponentValue(component, singleValue));\n }\n return normalizeSingleNumberComponentValue(component, value);\n};\nconst normalizeProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.normalizeProcessSync)(context);\n});\nexports.normalizeProcess = normalizeProcess;\nconst normalizeProcessSync = (context) => {\n const { component, form, scope, path, data, value } = context;\n if (!scope.normalize) {\n scope.normalize = {};\n }\n let { defaultValues } = scope;\n scope.normalize[path] = {\n type: component.type,\n normalized: false\n };\n // First check for component-type-specific transformations\n if (isAddressComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeAddressComponentValue(component, value));\n scope.normalize[path].normalized = true;\n }\n else if (isDayComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeDayComponentValue(component, form, value));\n scope.normalize[path].normalized = true;\n }\n else if (isEmailComponent(component)) {\n if (value && typeof value === 'string') {\n (0, lodash_1.set)(data, path, value.toLowerCase());\n scope.normalize[path].normalized = true;\n }\n }\n else if (isRadioComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeRadioComponentValue(value, component.dataType));\n scope.normalize[path].normalized = true;\n }\n else if (isSelectComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeSelectComponentValue(component, value));\n scope.normalize[path].normalized = true;\n }\n else if (isSelectBoxesComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeSelectBoxesComponentValue(value));\n scope.normalize[path].normalized = true;\n }\n else if (isTagsComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeTagsComponentValue(component, value));\n scope.normalize[path].normalized = true;\n }\n else if (isTextFieldComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeTextFieldComponentValue(component, defaultValues, value, path));\n scope.normalize[path].normalized = true;\n }\n else if (isTimeComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeTimeComponentValue(component, value));\n scope.normalize[path].normalized = true;\n }\n else if (isNumberComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeNumberComponentValue(component, value));\n scope.normalize[path].normalized = true;\n }\n // Next perform component-type-agnostic transformations (i.e. super())\n if (component.multiple && !Array.isArray(value)) {\n (0, lodash_1.set)(data, path, value ? [value] : []);\n scope.normalize[path].normalized = true;\n }\n};\nexports.normalizeProcessSync = normalizeProcessSync;\nexports.normalizeProcessInfo = {\n name: 'normalize',\n shouldProcess: () => true,\n process: exports.normalizeProcess,\n processSync: exports.normalizeProcessSync\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/normalize/index.js?");
|
522
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.normalizeProcessInfo = exports.normalizeProcessSync = exports.normalizeProcess = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst dayjs_1 = __importDefault(__webpack_require__(/*! dayjs */ \"./node_modules/dayjs/dayjs.min.js\"));\nconst customParseFormat_1 = __importDefault(__webpack_require__(/*! dayjs/plugin/customParseFormat */ \"./node_modules/dayjs/plugin/customParseFormat.js\"));\ndayjs_1.default.extend(customParseFormat_1.default);\nconst isAddressComponent = (component) => component.type === 'address';\nconst isDayComponent = (component) => component.type === 'day';\nconst isEmailComponent = (component) => component.type === 'email';\nconst isRadioComponent = (component) => component.type === 'radio';\nconst isSelectComponent = (component) => component.type === 'select';\nconst isSelectBoxesComponent = (component) => component.type === 'selectboxes';\nconst isTagsComponent = (component) => component.type === 'tags';\nconst isTextFieldComponent = (component) => component.type === 'textfield';\nconst isTimeComponent = (component) => component.type === 'time';\nconst isNumberComponent = (component) => component.type === 'number';\nconst normalizeAddressComponentValue = (component, value) => {\n if (!component.multiple && Boolean(component.enableManualMode) && value && !value.mode) {\n return {\n mode: 'autocomplete',\n address: value,\n };\n }\n return value;\n};\nconst getLocaleDateFormatInfo = (locale = 'en') => {\n const formatInfo = {};\n const day = 21;\n const exampleDate = new Date(2017, 11, day);\n const localDateString = exampleDate.toLocaleDateString(locale);\n formatInfo.dayFirst = localDateString.slice(0, 2) === day.toString();\n return formatInfo;\n};\nconst getLocaleDayFirst = (component, form) => {\n var _a;\n if (component.useLocaleSettings) {\n return getLocaleDateFormatInfo((_a = form.options) === null || _a === void 0 ? void 0 : _a.language).dayFirst;\n }\n return component.dayFirst;\n};\nconst normalizeDayComponentValue = (component, form, value) => {\n // TODO: this is a quick and dirty port of the Day component's normalizeValue method, may need some updates\n const valueMask = /^\\d{2}\\/\\d{2}\\/\\d{4}$/;\n const isDayFirst = getLocaleDayFirst(component, form);\n const showDay = !(0, lodash_1.get)(component, 'fields.day.hide', false);\n const showMonth = !(0, lodash_1.get)(component, 'fields.month.hide', false);\n const showYear = !(0, lodash_1.get)(component, 'fields.year.hide', false);\n if (!value || valueMask.test(value)) {\n return value;\n }\n const dateParts = [];\n const valueParts = value.split('/');\n const [DAY, MONTH, YEAR] = component.dayFirst ? [0, 1, 2] : [1, 0, 2];\n const defaultValue = component.defaultValue ? component.defaultValue.split('/') : '';\n let defaultDay = '';\n let defaultMonth = '';\n let defaultYear = '';\n const getDayWithHiddenFields = (parts) => {\n let DAY, MONTH, YEAR;\n [DAY, MONTH, YEAR] = component.dayFirst ? [0, 1, 2] : [1, 0, 2];\n if (!showDay) {\n MONTH = MONTH === 0 ? 0 : MONTH - 1;\n YEAR = YEAR - 1;\n DAY = null;\n }\n if (!showMonth) {\n if (!(0, lodash_1.isNull)(DAY)) {\n DAY = DAY === 0 ? 0 : DAY - 1;\n }\n YEAR = YEAR - 1;\n MONTH = null;\n }\n if (!showYear) {\n YEAR = null;\n }\n return {\n month: (0, lodash_1.isNull)(MONTH) ? '' : parts[MONTH],\n day: (0, lodash_1.isNull)(DAY) ? '' : parts[DAY],\n year: (0, lodash_1.isNull)(YEAR) ? '' : parts[YEAR],\n };\n };\n const getNextPart = (shouldTake, defaultValue) => {\n // Only push the part if it's not an empty string\n const part = shouldTake ? valueParts.shift() : defaultValue;\n if (part !== '') {\n dateParts.push(part);\n }\n };\n if (defaultValue) {\n const hasHiddenFields = defaultValue.length !== 3;\n defaultDay = hasHiddenFields ? getDayWithHiddenFields(defaultValue).day : defaultValue[DAY];\n defaultMonth = hasHiddenFields\n ? getDayWithHiddenFields(defaultValue).month\n : defaultValue[MONTH];\n defaultYear = hasHiddenFields ? getDayWithHiddenFields(defaultValue).year : defaultValue[YEAR];\n }\n if (isDayFirst) {\n getNextPart(showDay, defaultDay);\n }\n getNextPart(showMonth, defaultMonth);\n if (!isDayFirst) {\n getNextPart(showDay, defaultDay);\n }\n getNextPart(showYear, defaultYear);\n return dateParts.join('/');\n};\nconst normalizeRadioComponentValue = (value, dataType) => {\n switch (dataType) {\n case 'number':\n return +value;\n case 'string':\n return typeof value === 'object' ? JSON.stringify(value) : String(value);\n case 'boolean':\n return !(!value || value.toString() === 'false');\n }\n const isEquivalent = (0, lodash_1.toString)(value) === Number(value).toString();\n if (!isNaN(parseFloat(value)) && isFinite(value) && isEquivalent) {\n return +value;\n }\n if (value === 'true') {\n return true;\n }\n if (value === 'false') {\n return false;\n }\n return value;\n};\nconst normalizeSingleSelectComponentValue = (component, value) => {\n if ((0, lodash_1.isNil)(value)) {\n return;\n }\n const valueIsObject = (0, lodash_1.isObject)(value);\n //check if value equals to default emptyValue\n if (valueIsObject && Object.keys(value).length === 0) {\n return value;\n }\n const dataType = component.dataType || 'auto';\n const normalize = {\n value,\n number() {\n const numberValue = Number(this.value);\n const isEquivalent = value.toString() === numberValue.toString();\n if (!Number.isNaN(numberValue) &&\n Number.isFinite(numberValue) &&\n value !== '' &&\n isEquivalent) {\n this.value = numberValue;\n }\n return this;\n },\n boolean() {\n if ((0, lodash_1.isString)(this.value) &&\n (this.value.toLowerCase() === 'true' || this.value.toLowerCase() === 'false')) {\n this.value = this.value.toLowerCase() === 'true';\n }\n return this;\n },\n string() {\n this.value = String(this.value);\n return this;\n },\n object() {\n return this;\n },\n auto() {\n if ((0, lodash_1.isObject)(this.value)) {\n this.value = this.object().value;\n }\n else {\n this.value = this.string().number().boolean().value;\n }\n return this;\n },\n };\n try {\n return normalize[dataType]().value;\n }\n catch (err) {\n console.warn('Failed to normalize value', err);\n return value;\n }\n};\nconst normalizeSelectComponentValue = (component, value) => {\n if (component.multiple && Array.isArray(value)) {\n return value.map((singleValue) => normalizeSingleSelectComponentValue(component, singleValue));\n }\n return normalizeSingleSelectComponentValue(component, value);\n};\nconst normalizeSelectBoxesComponentValue = (value) => {\n if (!value) {\n value = {};\n }\n if (typeof value !== 'object') {\n if (typeof value === 'string') {\n return {\n [value]: true,\n };\n }\n else {\n return {};\n }\n }\n if (Array.isArray(value)) {\n return value.reduce((acc, curr) => {\n return Object.assign(Object.assign({}, acc), { [curr]: true });\n }, {});\n }\n return value;\n};\nconst normalizeTagsComponentValue = (component, value) => {\n const delimiter = component.delimeter || ',';\n if ((!component.hasOwnProperty('storeas') || component.storeas === 'string') &&\n Array.isArray(value)) {\n return value.join(delimiter);\n }\n else if (component.storeas === 'array' && typeof value === 'string') {\n return value.split(delimiter).filter((result) => result);\n }\n return value;\n};\nconst normalizeMaskValue = (component, defaultValues, value, path) => {\n if (component.inputMasks && component.inputMasks.length > 0) {\n if (!value || typeof value !== 'object') {\n return {\n value: value,\n maskName: component.inputMasks[0].label,\n };\n }\n if (!value.value) {\n const defaultValue = defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.find((defaultValue) => defaultValue.path === path);\n value.value =\n Array.isArray(defaultValue) && defaultValue.length > 0 ? defaultValue[0] : defaultValue;\n }\n }\n return value;\n};\nconst normalizeTextFieldComponentValue = (component, defaultValues, value, path) => {\n // If the component has truncate multiple spaces enabled, then normalize the value to remove extra spaces.\n if (component.truncateMultipleSpaces && typeof value === 'string') {\n value = value.trim().replace(/\\s{2,}/g, ' ');\n }\n if (component.allowMultipleMasks && component.inputMasks && component.inputMasks.length > 0) {\n if (Array.isArray(value)) {\n return value.map((val) => normalizeMaskValue(component, defaultValues, val, path));\n }\n else {\n return normalizeMaskValue(component, defaultValues, value, path);\n }\n }\n return value;\n};\n// Allow submissions of time components in their visual \"format\" property by coercing them to the \"dataFormat\" property\n// i.e. \"HH:mm\" -> \"HH:mm:ss\"\nconst normalizeTimeComponentValue = (component, value) => {\n const defaultDataFormat = 'HH:mm:ss';\n const defaultFormat = 'HH:mm';\n if ((0, dayjs_1.default)(value, component.format || defaultFormat, true).isValid()) {\n return (0, dayjs_1.default)(value, component.format || defaultFormat, true).format(component.dataFormat || defaultDataFormat);\n }\n return value;\n};\nconst normalizeSingleNumberComponentValue = (component, value) => {\n if (!isNaN(parseFloat(value)) && isFinite(value)) {\n return +value;\n }\n return value;\n};\nconst normalizeNumberComponentValue = (component, value) => {\n if (component.multiple && Array.isArray(value)) {\n return value.map((singleValue) => normalizeSingleNumberComponentValue(component, singleValue));\n }\n return normalizeSingleNumberComponentValue(component, value);\n};\nconst normalizeProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.normalizeProcessSync)(context);\n});\nexports.normalizeProcess = normalizeProcess;\nconst normalizeProcessSync = (context) => {\n const { component, form, scope, path, data, value } = context;\n if (!scope.normalize) {\n scope.normalize = {};\n }\n const { defaultValues } = scope;\n scope.normalize[path] = {\n type: component.type,\n normalized: false,\n };\n // First check for component-type-specific transformations\n if (isAddressComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeAddressComponentValue(component, value));\n scope.normalize[path].normalized = true;\n }\n else if (isDayComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeDayComponentValue(component, form, value));\n scope.normalize[path].normalized = true;\n }\n else if (isEmailComponent(component)) {\n if (value && typeof value === 'string') {\n (0, lodash_1.set)(data, path, value.toLowerCase());\n scope.normalize[path].normalized = true;\n }\n }\n else if (isRadioComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeRadioComponentValue(value, component.dataType));\n scope.normalize[path].normalized = true;\n }\n else if (isSelectComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeSelectComponentValue(component, value));\n scope.normalize[path].normalized = true;\n }\n else if (isSelectBoxesComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeSelectBoxesComponentValue(value));\n scope.normalize[path].normalized = true;\n }\n else if (isTagsComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeTagsComponentValue(component, value));\n scope.normalize[path].normalized = true;\n }\n else if (isTextFieldComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeTextFieldComponentValue(component, defaultValues, value, path));\n scope.normalize[path].normalized = true;\n }\n else if (isTimeComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeTimeComponentValue(component, value));\n scope.normalize[path].normalized = true;\n }\n else if (isNumberComponent(component)) {\n (0, lodash_1.set)(data, path, normalizeNumberComponentValue(component, value));\n scope.normalize[path].normalized = true;\n }\n // Next perform component-type-agnostic transformations (i.e. super())\n if (component.multiple && !Array.isArray(value)) {\n (0, lodash_1.set)(data, path, value ? [value] : []);\n scope.normalize[path].normalized = true;\n }\n};\nexports.normalizeProcessSync = normalizeProcessSync;\nexports.normalizeProcessInfo = {\n name: 'normalize',\n shouldProcess: () => true,\n process: exports.normalizeProcess,\n processSync: exports.normalizeProcessSync,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/normalize/index.js?");
|
523
523
|
|
524
524
|
/***/ }),
|
525
525
|
|
@@ -530,7 +530,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
530
530
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
531
531
|
|
532
532
|
"use strict";
|
533
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.populateProcessInfo = exports.populateProcessSync = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst formUtil_1 = __webpack_require__(/*! ../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\n// This processor ensures that a \"linked\" row context is provided to every component.\nconst populateProcessSync = (context) => {\n const { component, path, scope } = context;\n const { data } = scope;\n const compDataPath = (0, formUtil_1.componentPath)(component, (0, formUtil_1.getContextualRowPath)(component, path));\n const compData = (0, lodash_1.get)(data, compDataPath);\n if (!scope.populated)\n scope.populated = [];\n switch ((0, formUtil_1.getModelType)(component)) {\n case 'nestedArray':\n if (!compData || !compData.length) {\n (0, lodash_1.set)(data, compDataPath, [{}]);\n scope.row = (0, lodash_1.get)(data, compDataPath)[0];\n scope.populated.push({\n path,\n row: (0, lodash_1.get)(data, compDataPath)[0]
|
533
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.populateProcessInfo = exports.populateProcessSync = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst formUtil_1 = __webpack_require__(/*! ../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\n// This processor ensures that a \"linked\" row context is provided to every component.\nconst populateProcessSync = (context) => {\n const { component, path, scope } = context;\n const { data } = scope;\n const compDataPath = (0, formUtil_1.componentPath)(component, (0, formUtil_1.getContextualRowPath)(component, path));\n const compData = (0, lodash_1.get)(data, compDataPath);\n if (!scope.populated)\n scope.populated = [];\n switch ((0, formUtil_1.getModelType)(component)) {\n case 'nestedArray':\n if (!compData || !compData.length) {\n (0, lodash_1.set)(data, compDataPath, [{}]);\n scope.row = (0, lodash_1.get)(data, compDataPath)[0];\n scope.populated.push({\n path,\n row: (0, lodash_1.get)(data, compDataPath)[0],\n });\n }\n break;\n case 'dataObject':\n case 'object':\n if (!compData || typeof compData !== 'object') {\n (0, lodash_1.set)(data, compDataPath, {});\n scope.row = (0, lodash_1.get)(data, compDataPath);\n scope.populated.push({\n path,\n row: (0, lodash_1.get)(data, compDataPath),\n });\n }\n break;\n }\n};\nexports.populateProcessSync = populateProcessSync;\nexports.populateProcessInfo = {\n name: 'populate',\n shouldProcess: () => true,\n processSync: exports.populateProcessSync,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/populate/index.js?");
|
534
534
|
|
535
535
|
/***/ }),
|
536
536
|
|
@@ -541,7 +541,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
541
541
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
542
542
|
|
543
543
|
"use strict";
|
544
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ProcessTargets = exports.ProcessorMap = exports.processSync = exports.process = void 0;\nconst formUtil_1 = __webpack_require__(/*! ../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst processOne_1 = __webpack_require__(/*! ./processOne */ \"./node_modules/@formio/core/lib/process/processOne.js\");\nconst defaultValue_1 = __webpack_require__(/*! ./defaultValue */ \"./node_modules/@formio/core/lib/process/defaultValue/index.js\");\nconst fetch_1 = __webpack_require__(/*! ./fetch */ \"./node_modules/@formio/core/lib/process/fetch/index.js\");\nconst calculation_1 = __webpack_require__(/*! ./calculation */ \"./node_modules/@formio/core/lib/process/calculation/index.js\");\nconst logic_1 = __webpack_require__(/*! ./logic */ \"./node_modules/@formio/core/lib/process/logic/index.js\");\nconst conditions_1 = __webpack_require__(/*! ./conditions */ \"./node_modules/@formio/core/lib/process/conditions/index.js\");\nconst validation_1 = __webpack_require__(/*! ./validation */ \"./node_modules/@formio/core/lib/process/validation/index.js\");\nconst filter_1 = __webpack_require__(/*! ./filter */ \"./node_modules/@formio/core/lib/process/filter/index.js\");\nconst normalize_1 = __webpack_require__(/*! ./normalize */ \"./node_modules/@formio/core/lib/process/normalize/index.js\");\nconst dereference_1 = __webpack_require__(/*! ./dereference */ \"./node_modules/@formio/core/lib/process/dereference/index.js\");\nconst clearHidden_1 = __webpack_require__(/*! ./clearHidden */ \"./node_modules/@formio/core/lib/process/clearHidden.js\");\nconst hideChildren_1 = __webpack_require__(/*! ./hideChildren */ \"./node_modules/@formio/core/lib/process/hideChildren.js\");\nfunction process(context) {\n return __awaiter(this, void 0, void 0, function* () {\n const { instances, components, data, scope, flat, processors } = context;\n yield (0, formUtil_1.eachComponentDataAsync)(components, data, (component, compData, row, path, components, index, parent) => __awaiter(this, void 0, void 0, function* () {\n // Skip processing if row is null or undefined\n if (!row) {\n return;\n }\n yield (0, processOne_1.processOne)(Object.assign(Object.assign({}, context), { data: compData, component,\n components,\n path,\n row,\n index, instance: instances ? instances[path] : undefined, parent }));\n if (flat) {\n return true;\n }\n if (scope.noRecurse) {\n scope.noRecurse = false;\n return true;\n }\n }));\n for (let i = 0; i < (processors === null || processors === void 0 ? void 0 : processors.length); i++) {\n const processor = processors[i];\n if (processor.postProcess) {\n processor.postProcess(context);\n }\n }\n return scope;\n });\n}\nexports.process = process;\nfunction processSync(context) {\n const { instances, components, data, scope, flat, processors } = context;\n (0, formUtil_1.eachComponentData)(components, data, (component, compData, row, path, components, index, parent) => {\n // Skip processing if row is null or undefined\n if (!row) {\n return;\n }\n (0, processOne_1.processOneSync)(Object.assign(Object.assign({}, context), { data: compData, component,\n components,\n path,\n row,\n index, instance: instances ? instances[path] : undefined, parent }));\n if (flat) {\n return true;\n }\n if (scope.noRecurse) {\n scope.noRecurse = false;\n return true;\n }\n });\n for (let i = 0; i < (processors === null || processors === void 0 ? void 0 : processors.length); i++) {\n const processor = processors[i];\n if (processor.postProcess) {\n processor.postProcess(context);\n }\n }\n return scope;\n}\nexports.processSync = processSync;\nexports.ProcessorMap = {\n filter: filter_1.filterProcessInfo,\n defaultValue: defaultValue_1.defaultValueProcessInfo,\n serverDefaultValue: defaultValue_1.serverDefaultValueProcessInfo,\n customDefaultValue: defaultValue_1.customDefaultValueProcessInfo,\n calculate: calculation_1.calculateProcessInfo,\n conditions: conditions_1.conditionProcessInfo,\n customConditions: conditions_1.customConditionProcessInfo,\n simpleConditions: conditions_1.simpleConditionProcessInfo,\n normalize: normalize_1.normalizeProcessInfo,\n dereference: dereference_1.dereferenceProcessInfo,\n clearHidden: clearHidden_1.clearHiddenProcessInfo,\n fetch: fetch_1.fetchProcessInfo,\n logic: logic_1.logicProcessInfo,\n validate: validation_1.validateProcessInfo,\n validateCustom: validation_1.validateCustomProcessInfo,\n validateServer: validation_1.validateServerProcessInfo,\n hideChildren: hideChildren_1.hideChildrenProcessorInfo
|
544
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ProcessTargets = exports.ProcessorMap = exports.processSync = exports.process = void 0;\nconst formUtil_1 = __webpack_require__(/*! ../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst processOne_1 = __webpack_require__(/*! ./processOne */ \"./node_modules/@formio/core/lib/process/processOne.js\");\nconst defaultValue_1 = __webpack_require__(/*! ./defaultValue */ \"./node_modules/@formio/core/lib/process/defaultValue/index.js\");\nconst fetch_1 = __webpack_require__(/*! ./fetch */ \"./node_modules/@formio/core/lib/process/fetch/index.js\");\nconst calculation_1 = __webpack_require__(/*! ./calculation */ \"./node_modules/@formio/core/lib/process/calculation/index.js\");\nconst logic_1 = __webpack_require__(/*! ./logic */ \"./node_modules/@formio/core/lib/process/logic/index.js\");\nconst conditions_1 = __webpack_require__(/*! ./conditions */ \"./node_modules/@formio/core/lib/process/conditions/index.js\");\nconst validation_1 = __webpack_require__(/*! ./validation */ \"./node_modules/@formio/core/lib/process/validation/index.js\");\nconst filter_1 = __webpack_require__(/*! ./filter */ \"./node_modules/@formio/core/lib/process/filter/index.js\");\nconst normalize_1 = __webpack_require__(/*! ./normalize */ \"./node_modules/@formio/core/lib/process/normalize/index.js\");\nconst dereference_1 = __webpack_require__(/*! ./dereference */ \"./node_modules/@formio/core/lib/process/dereference/index.js\");\nconst clearHidden_1 = __webpack_require__(/*! ./clearHidden */ \"./node_modules/@formio/core/lib/process/clearHidden.js\");\nconst hideChildren_1 = __webpack_require__(/*! ./hideChildren */ \"./node_modules/@formio/core/lib/process/hideChildren.js\");\nfunction process(context) {\n return __awaiter(this, void 0, void 0, function* () {\n const { instances, components, data, scope, flat, processors } = context;\n yield (0, formUtil_1.eachComponentDataAsync)(components, data, (component, compData, row, path, components, index, parent) => __awaiter(this, void 0, void 0, function* () {\n // Skip processing if row is null or undefined\n if (!row) {\n return;\n }\n yield (0, processOne_1.processOne)(Object.assign(Object.assign({}, context), { data: compData, component,\n components,\n path,\n row,\n index, instance: instances ? instances[path] : undefined, parent }));\n if (flat) {\n return true;\n }\n if (scope.noRecurse) {\n scope.noRecurse = false;\n return true;\n }\n }));\n for (let i = 0; i < (processors === null || processors === void 0 ? void 0 : processors.length); i++) {\n const processor = processors[i];\n if (processor.postProcess) {\n processor.postProcess(context);\n }\n }\n return scope;\n });\n}\nexports.process = process;\nfunction processSync(context) {\n const { instances, components, data, scope, flat, processors } = context;\n (0, formUtil_1.eachComponentData)(components, data, (component, compData, row, path, components, index, parent) => {\n // Skip processing if row is null or undefined\n if (!row) {\n return;\n }\n (0, processOne_1.processOneSync)(Object.assign(Object.assign({}, context), { data: compData, component,\n components,\n path,\n row,\n index, instance: instances ? instances[path] : undefined, parent }));\n if (flat) {\n return true;\n }\n if (scope.noRecurse) {\n scope.noRecurse = false;\n return true;\n }\n });\n for (let i = 0; i < (processors === null || processors === void 0 ? void 0 : processors.length); i++) {\n const processor = processors[i];\n if (processor.postProcess) {\n processor.postProcess(context);\n }\n }\n return scope;\n}\nexports.processSync = processSync;\nexports.ProcessorMap = {\n filter: filter_1.filterProcessInfo,\n defaultValue: defaultValue_1.defaultValueProcessInfo,\n serverDefaultValue: defaultValue_1.serverDefaultValueProcessInfo,\n customDefaultValue: defaultValue_1.customDefaultValueProcessInfo,\n calculate: calculation_1.calculateProcessInfo,\n conditions: conditions_1.conditionProcessInfo,\n customConditions: conditions_1.customConditionProcessInfo,\n simpleConditions: conditions_1.simpleConditionProcessInfo,\n normalize: normalize_1.normalizeProcessInfo,\n dereference: dereference_1.dereferenceProcessInfo,\n clearHidden: clearHidden_1.clearHiddenProcessInfo,\n fetch: fetch_1.fetchProcessInfo,\n logic: logic_1.logicProcessInfo,\n validate: validation_1.validateProcessInfo,\n validateCustom: validation_1.validateCustomProcessInfo,\n validateServer: validation_1.validateServerProcessInfo,\n hideChildren: hideChildren_1.hideChildrenProcessorInfo,\n};\nexports.ProcessTargets = {\n submission: [\n filter_1.filterProcessInfo,\n defaultValue_1.serverDefaultValueProcessInfo,\n normalize_1.normalizeProcessInfo,\n dereference_1.dereferenceProcessInfo,\n fetch_1.fetchProcessInfo,\n conditions_1.simpleConditionProcessInfo,\n validation_1.validateServerProcessInfo,\n ],\n evaluator: [\n defaultValue_1.customDefaultValueProcessInfo,\n calculation_1.calculateProcessInfo,\n logic_1.logicProcessInfo,\n conditions_1.conditionProcessInfo,\n hideChildren_1.hideChildrenProcessorInfo,\n clearHidden_1.clearHiddenProcessInfo,\n validation_1.validateProcessInfo,\n ],\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/process.js?");
|
545
545
|
|
546
546
|
/***/ }),
|
547
547
|
|
@@ -552,7 +552,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
552
552
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
553
553
|
|
554
554
|
"use strict";
|
555
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.processOneSync = exports.processOne = exports.dataValue = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst types_1 = __webpack_require__(/*! ../types */ \"./node_modules/@formio/core/lib/types/index.js\");\nconst formUtil_1 = __webpack_require__(/*! ../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst utils_1 = __webpack_require__(/*! ../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nfunction dataValue(component, row) {\n const key = (0, formUtil_1.getComponentKey)(component);\n return key ? (0, lodash_1.get)(row, key) : undefined;\n}\nexports.dataValue = dataValue;\nfunction processOne(context) {\n return __awaiter(this, void 0, void 0, function* () {\n const { processors, component } = context;\n // Create a getter for `value` that is always derived from the current data object\n if (typeof context.value === 'undefined') {\n Object.defineProperty(context, 'value', {\n enumerable: true,\n get() {\n return (0, lodash_1.get)(context.data, context.path);\n },\n set(newValue) {\n (0, lodash_1.set)(context.data, context.path, newValue);\n }
|
555
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.processOneSync = exports.processOne = exports.dataValue = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst types_1 = __webpack_require__(/*! ../types */ \"./node_modules/@formio/core/lib/types/index.js\");\nconst formUtil_1 = __webpack_require__(/*! ../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst utils_1 = __webpack_require__(/*! ../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nfunction dataValue(component, row) {\n const key = (0, formUtil_1.getComponentKey)(component);\n return key ? (0, lodash_1.get)(row, key) : undefined;\n}\nexports.dataValue = dataValue;\nfunction processOne(context) {\n return __awaiter(this, void 0, void 0, function* () {\n const { processors, component } = context;\n // Create a getter for `value` that is always derived from the current data object\n if (typeof context.value === 'undefined') {\n Object.defineProperty(context, 'value', {\n enumerable: true,\n get() {\n return (0, lodash_1.get)(context.data, context.path);\n },\n set(newValue) {\n (0, lodash_1.set)(context.data, context.path, newValue);\n },\n });\n }\n // If the component has ephermal state, then we need to reset the ephermal state in case this is e.g. a data grid, in which each row needs to be validated independently\n (0, utils_1.resetEphermalState)(component);\n if (!context.row) {\n return;\n }\n context.processor = types_1.ProcessorType.Custom;\n for (const processor of processors) {\n if (processor === null || processor === void 0 ? void 0 : processor.process) {\n yield processor.process(context);\n }\n }\n });\n}\nexports.processOne = processOne;\nfunction processOneSync(context) {\n const { processors, component } = context;\n // Create a getter for `value` that is always derived from the current data object\n if (typeof context.value === 'undefined') {\n Object.defineProperty(context, 'value', {\n enumerable: true,\n get() {\n return (0, lodash_1.get)(context.data, context.path);\n },\n set(newValue) {\n (0, lodash_1.set)(context.data, context.path, newValue);\n },\n });\n }\n // If the component has ephermal state, then we need to reset the ephermal state in case this is e.g. a data grid, in which each row needs to be validated independently\n (0, utils_1.resetEphermalState)(component);\n if (!context.row) {\n return;\n }\n context.processor = types_1.ProcessorType.Custom;\n for (const processor of processors) {\n if (processor === null || processor === void 0 ? void 0 : processor.processSync) {\n processor.processSync(context);\n }\n }\n}\nexports.processOneSync = processOneSync;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/processOne.js?");
|
556
556
|
|
557
557
|
/***/ }),
|
558
558
|
|
@@ -563,7 +563,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
563
563
|
/***/ (function(__unused_webpack_module, exports) {
|
564
564
|
|
565
565
|
"use strict";
|
566
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.EN_ERRORS = void 0;\nexports.EN_ERRORS = {\n unsavedRowsError: 'Please save all rows before proceeding.',\n invalidRowsError: 'Please correct invalid rows before proceeding.',\n invalidRowError: 'Invalid row. Please correct it or delete.',\n invalidOption: '{{field}} is an invalid value.',\n invalidDay: '{{field}} is not a valid day.',\n required: '{{field}} is required',\n unique: '{{field}} must be unique',\n array: '{{field}} must be an array',\n array_nonempty: '{{field}} must be a non-empty array'
|
566
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.EN_ERRORS = void 0;\nexports.EN_ERRORS = {\n unsavedRowsError: 'Please save all rows before proceeding.',\n invalidRowsError: 'Please correct invalid rows before proceeding.',\n invalidRowError: 'Invalid row. Please correct it or delete.',\n invalidOption: '{{field}} is an invalid value.',\n invalidDay: '{{field}} is not a valid day.',\n required: '{{field}} is required',\n unique: '{{field}} must be unique',\n array: '{{field}} must be an array',\n array_nonempty: '{{field}} must be a non-empty array',\n nonarray: '{{field}} must not be an array',\n select: '{{field}} contains an invalid selection',\n pattern: '{{field}} does not match the pattern {{pattern}}',\n minLength: '{{field}} must have at least {{length}} characters.',\n maxLength: '{{field}} must have no more than {{length}} characters.',\n minWords: '{{field}} must have at least {{length}} words.',\n maxWords: '{{field}} must have no more than {{length}} words.',\n min: '{{field}} cannot be less than {{min}}.',\n max: '{{field}} cannot be greater than {{max}}.',\n maxDate: '{{field}} should not contain date after {{- maxDate}}',\n minDate: '{{field}} should not contain date before {{- minDate}}',\n maxYear: '{{field}} should not contain year greater than {{maxYear}}',\n minSelectedCount: 'You must select at least {{minCount}} items',\n maxSelectedCount: 'You may only select up to {{maxCount}} items',\n minYear: '{{field}} should not contain year less than {{minYear}}',\n invalid_email: '{{field}} must be a valid email.',\n invalid_url: '{{field}} must be a valid url.',\n invalid_regex: '{{field}} does not match the pattern {{regex}}.',\n invalid_date: '{{field}} is not a valid date.',\n invalid_day: '{{field}} is not a valid day.',\n invalidValueProperty: 'Invalid Value Property',\n mask: '{{field}} does not match the mask.',\n valueIsNotAvailable: '{{ field }} is an invalid value.',\n time: '{{field}} is not a valid time.',\n invalidDate: '{{field}} is not a valid date',\n number: '{{field}} is not a valid number.',\n requiredDayField: '{{ field }} is required',\n requiredMonthField: '{{ field }} is required',\n requiredYearField: '{{ field }} is required',\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/i18n/en.js?");
|
567
567
|
|
568
568
|
/***/ }),
|
569
569
|
|
@@ -574,7 +574,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
574
574
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
575
575
|
|
576
576
|
"use strict";
|
577
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.VALIDATION_ERRORS = void 0;\nconst en_1 = __webpack_require__(/*! ./en */ \"./node_modules/@formio/core/lib/process/validation/i18n/en.js\");\nexports.VALIDATION_ERRORS = {\n en: en_1.EN_ERRORS
|
577
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.VALIDATION_ERRORS = void 0;\nconst en_1 = __webpack_require__(/*! ./en */ \"./node_modules/@formio/core/lib/process/validation/i18n/en.js\");\nexports.VALIDATION_ERRORS = {\n en: en_1.EN_ERRORS,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/i18n/index.js?");
|
578
578
|
|
579
579
|
/***/ }),
|
580
580
|
|
@@ -585,7 +585,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
585
585
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
586
586
|
|
587
587
|
"use strict";
|
588
|
-
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateProcessInfo = exports.validateServerProcessInfo = exports.validateCustomProcessInfo = exports.validateAllProcessSync = exports.validateAllProcess = exports.validateServerProcessSync = exports.validateServerProcess = exports.validateCustomProcessSync = exports.validateCustomProcess = exports.validateProcessSync = exports.validateProcess = exports.shouldValidateServer = exports.shouldValidateCustom = exports.shouldValidateAll = exports.shouldSkipValidation = exports.shouldSkipValidationSimple = exports.shouldSkipValidationCustom = exports._shouldSkipValidation = exports.isForcedHidden = exports.isValueHidden = exports.isInputComponent = exports.validationRules = void 0;\nconst rules_1 = __webpack_require__(/*! ./rules */ \"./node_modules/@formio/core/lib/process/validation/rules/index.js\");\nconst find_1 = __importDefault(__webpack_require__(/*! lodash/find */ \"./node_modules/lodash/find.js\"));\nconst get_1 = __importDefault(__webpack_require__(/*! lodash/get */ \"./node_modules/lodash/get.js\"));\nconst pick_1 = __importDefault(__webpack_require__(/*! lodash/pick */ \"./node_modules/lodash/pick.js\"));\nconst formUtil_1 = __webpack_require__(/*! ../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst error_1 = __webpack_require__(/*! ../../utils/error */ \"./node_modules/@formio/core/lib/utils/error.js\");\nconst conditions_1 = __webpack_require__(/*! ../conditions */ \"./node_modules/@formio/core/lib/process/conditions/index.js\");\n// Cleans up validation errors to remove unnessesary parts\n// and make them transferable to ivm.\nconst cleanupValidationError = (error) => (Object.assign(Object.assign({}, error), { context: (0, pick_1.default)(error.context, [\n 'component',\n 'path',\n 'index',\n 'value',\n 'field',\n 'hasLabel',\n 'processor',\n 'setting',\n 'pattern',\n 'length',\n 'min',\n 'max',\n 'maxDate',\n 'minDate',\n 'maxYear',\n 'minYear',\n 'minCount',\n 'maxCount',\n 'regex'\n ]) }));\nfunction validationRules(context, rules, skipValidation) {\n if (skipValidation && skipValidation(context)) {\n return [];\n }\n const validationRules = [];\n return rules.reduce((acc, rule) => {\n if (rule.shouldProcess && rule.shouldProcess(context)) {\n acc.push(rule);\n }\n return acc;\n }, validationRules);\n}\nexports.validationRules = validationRules;\nfunction isInputComponent(context) {\n const { component } = context;\n return !component.hasOwnProperty('input') || component.input;\n}\nexports.isInputComponent = isInputComponent;\nfunction isValueHidden(context) {\n const { component, config } = context;\n if (component.protected) {\n return false;\n }\n if ((component.hasOwnProperty('persistent') && !component.persistent) ||\n (component.persistent === 'client-only')) {\n return true;\n }\n return false;\n}\nexports.isValueHidden = isValueHidden;\nfunction isForcedHidden(context, isConditionallyHidden) {\n const { component } = context;\n if (isConditionallyHidden(context)) {\n return true;\n }\n if (component.hasOwnProperty('hidden')) {\n return !!component.hidden;\n }\n return false;\n}\nexports.isForcedHidden = isForcedHidden;\nconst _shouldSkipValidation = (context, isConditionallyHidden) => {\n var _a;\n const { component, scope, path } = context;\n if ((scope === null || scope === void 0 ? void 0 : scope.conditionals) &&\n ((0, find_1.default)(scope.conditionals, {\n path: (0, formUtil_1.getComponentPath)(component, path),\n conditionallyHidden: true\n }) || ((_a = component.ephermalState) === null || _a === void 0 ? void 0 : _a.conditionallyHidden) === true)) {\n return true;\n }\n const { validateWhenHidden = false } = component || {};\n const rules = [\n // Skip validation if component is readOnly\n // () => this.options.readOnly,\n // Do not check validations if component is not an input component.\n () => !isInputComponent(context),\n // Check to see if we are editing and if so, check component persistence.\n () => isValueHidden(context),\n // Force valid if component is hidden.\n () => isForcedHidden(context, isConditionallyHidden) && !validateWhenHidden,\n ];\n return rules.some(pred => pred());\n ;\n};\nexports._shouldSkipValidation = _shouldSkipValidation;\nconst shouldSkipValidationCustom = (context) => {\n return (0, exports._shouldSkipValidation)(context, conditions_1.isCustomConditionallyHidden);\n};\nexports.shouldSkipValidationCustom = shouldSkipValidationCustom;\nconst shouldSkipValidationSimple = (context) => {\n return (0, exports._shouldSkipValidation)(context, conditions_1.isSimpleConditionallyHidden);\n};\nexports.shouldSkipValidationSimple = shouldSkipValidationSimple;\nconst shouldSkipValidation = (context) => {\n return (0, exports._shouldSkipValidation)(context, conditions_1.isConditionallyHidden);\n};\nexports.shouldSkipValidation = shouldSkipValidation;\nfunction shouldValidateAll(context) {\n return validationRules(context, rules_1.rules, exports.shouldSkipValidation).length > 0;\n}\nexports.shouldValidateAll = shouldValidateAll;\nfunction shouldValidateCustom(context) {\n const { component } = context;\n if (component.customConditional) {\n return true;\n }\n return !(0, exports.shouldSkipValidationCustom)(context);\n}\nexports.shouldValidateCustom = shouldValidateCustom;\nfunction shouldValidateServer(context) {\n const { component } = context;\n if (component.customConditional) {\n return false;\n }\n if ((0, exports.shouldSkipValidationSimple)(context)) {\n return false;\n }\n return shouldValidateAll(context);\n}\nexports.shouldValidateServer = shouldValidateServer;\nfunction handleError(error, context) {\n const { scope, component } = context;\n const absolutePath = (0, formUtil_1.getComponentAbsolutePath)(component);\n if (error) {\n const cleanedError = cleanupValidationError(error);\n cleanedError.context.path = absolutePath;\n if (!(0, find_1.default)(scope.errors, { errorKeyOrMessage: cleanedError.errorKeyOrMessage, context: {\n path: absolutePath\n } })) {\n if (!scope.validated)\n scope.validated = [];\n if (!scope.errors)\n scope.errors = [];\n scope.errors.push(cleanedError);\n scope.validated.push({ path: absolutePath, error: cleanedError });\n }\n }\n}\nconst validateProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n const { component, data, row, path, instance, scope, rules, skipValidation } = context;\n let { value } = context;\n if (!scope.validated)\n scope.validated = [];\n if (!scope.errors)\n scope.errors = [];\n if (!rules || !rules.length) {\n return;\n }\n if (component.multiple && Array.isArray(value) && value.length > 0) {\n const fullValueRules = rules.filter(rule => rule.fullValue);\n const otherRules = rules.filter(rule => !rule.fullValue);\n for (let i = 0; i < value.length; i++) {\n const amendedPath = `${path}[${i}]`;\n let amendedValue = (0, get_1.default)(data, amendedPath);\n if (instance === null || instance === void 0 ? void 0 : instance.shouldSkipValidation(data)) {\n return;\n }\n const rulesToExecute = validationRules(context, otherRules, skipValidation);\n if (!rulesToExecute.length) {\n continue;\n }\n if (component.truncateMultipleSpaces && amendedValue && typeof amendedValue === 'string') {\n amendedValue = amendedValue.trim().replace(/\\s{2,}/g, ' ');\n }\n for (const rule of rulesToExecute) {\n if (rule && rule.process) {\n handleError(yield rule.process(Object.assign(Object.assign({}, context), { value: amendedValue, index: i, path: amendedPath })), context);\n }\n }\n }\n for (const rule of fullValueRules) {\n if (rule && rule.process) {\n handleError(yield rule.process(Object.assign(Object.assign({}, context), { value })), context);\n }\n }\n return;\n }\n if (instance === null || instance === void 0 ? void 0 : instance.shouldSkipValidation(data, row)) {\n return;\n }\n const rulesToExecute = validationRules(context, rules, skipValidation);\n if (!rulesToExecute.length) {\n return;\n }\n if (component.truncateMultipleSpaces && value && typeof value === 'string') {\n value = value.trim().replace(/\\s{2,}/g, ' ');\n }\n for (const rule of rulesToExecute) {\n try {\n if (rule && rule.process) {\n handleError(yield rule.process(Object.assign(Object.assign({}, context), { value })), context);\n }\n }\n catch (err) {\n console.error(\"Validator error:\", (0, error_1.getErrorMessage)(err));\n }\n }\n return;\n});\nexports.validateProcess = validateProcess;\nconst validateProcessSync = (context) => {\n const { component, data, row, path, instance, scope, rules, skipValidation } = context;\n let { value } = context;\n if (!scope.validated)\n scope.validated = [];\n if (!scope.errors)\n scope.errors = [];\n if (!rules || !rules.length) {\n return;\n }\n if (component.multiple && Array.isArray(value) && value.length > 0) {\n const fullValueRules = rules.filter(rule => rule.fullValue);\n const otherRules = rules.filter(rule => !rule.fullValue);\n for (let i = 0; i < value.length; i++) {\n const amendedPath = `${path}[${i}]`;\n let amendedValue = (0, get_1.default)(data, amendedPath);\n if (instance === null || instance === void 0 ? void 0 : instance.shouldSkipValidation(data)) {\n return;\n }\n const rulesToExecute = validationRules(context, otherRules, skipValidation);\n if (!rulesToExecute.length) {\n continue;\n }\n if (component.truncateMultipleSpaces && amendedValue && typeof amendedValue === 'string') {\n amendedValue = amendedValue.trim().replace(/\\s{2,}/g, ' ');\n }\n for (const rule of rulesToExecute) {\n if (rule && rule.processSync) {\n handleError(rule.processSync(Object.assign(Object.assign({}, context), { value: amendedValue, index: i, path: amendedPath })), context);\n }\n }\n }\n for (const rule of fullValueRules) {\n if (rule && rule.processSync) {\n handleError(rule.processSync(Object.assign(Object.assign({}, context), { value })), context);\n }\n }\n return;\n }\n if (instance === null || instance === void 0 ? void 0 : instance.shouldSkipValidation(data, row)) {\n return;\n }\n const rulesToExecute = validationRules(context, rules, skipValidation);\n if (!rulesToExecute.length) {\n return;\n }\n if (component.truncateMultipleSpaces && value && typeof value === 'string') {\n value = value.trim().replace(/\\s{2,}/g, ' ');\n }\n for (const rule of rulesToExecute) {\n try {\n if (rule && rule.processSync) {\n handleError(rule.processSync(Object.assign(Object.assign({}, context), { value })), context);\n }\n }\n catch (err) {\n console.error(\"Validator error:\", (0, error_1.getErrorMessage)(err));\n }\n }\n return;\n};\nexports.validateProcessSync = validateProcessSync;\nconst validateCustomProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n context.rules = context.rules || rules_1.evaluationRules;\n context.skipValidation = exports.shouldSkipValidationCustom;\n return (0, exports.validateProcess)(context);\n});\nexports.validateCustomProcess = validateCustomProcess;\nconst validateCustomProcessSync = (context) => {\n context.rules = context.rules || rules_1.evaluationRules;\n context.skipValidation = exports.shouldSkipValidationCustom;\n return (0, exports.validateProcessSync)(context);\n};\nexports.validateCustomProcessSync = validateCustomProcessSync;\nconst validateServerProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n context.rules = context.rules || rules_1.serverRules;\n context.skipValidation = exports.shouldSkipValidationSimple;\n return (0, exports.validateProcess)(context);\n});\nexports.validateServerProcess = validateServerProcess;\nconst validateServerProcessSync = (context) => {\n context.rules = context.rules || rules_1.serverRules;\n context.skipValidation = exports.shouldSkipValidationSimple;\n return (0, exports.validateProcessSync)(context);\n};\nexports.validateServerProcessSync = validateServerProcessSync;\nconst validateAllProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n context.rules = context.rules || rules_1.rules;\n context.skipValidation = exports.shouldSkipValidation;\n return (0, exports.validateProcess)(context);\n});\nexports.validateAllProcess = validateAllProcess;\nconst validateAllProcessSync = (context) => {\n context.rules = context.rules || rules_1.rules;\n context.skipValidation = exports.shouldSkipValidation;\n return (0, exports.validateProcessSync)(context);\n};\nexports.validateAllProcessSync = validateAllProcessSync;\nexports.validateCustomProcessInfo = {\n name: 'validateCustom',\n process: exports.validateCustomProcess,\n processSync: exports.validateCustomProcessSync,\n shouldProcess: shouldValidateCustom,\n};\nexports.validateServerProcessInfo = {\n name: 'validateServer',\n process: exports.validateServerProcess,\n processSync: exports.validateServerProcessSync,\n shouldProcess: shouldValidateServer,\n};\nexports.validateProcessInfo = {\n name: 'validate',\n process: exports.validateAllProcess,\n processSync: exports.validateAllProcessSync,\n shouldProcess: shouldValidateAll,\n};\n__exportStar(__webpack_require__(/*! ./util */ \"./node_modules/@formio/core/lib/process/validation/util.js\"), exports);\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/index.js?");
|
588
|
+
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateProcessInfo = exports.validateServerProcessInfo = exports.validateCustomProcessInfo = exports.validateAllProcessSync = exports.validateAllProcess = exports.validateServerProcessSync = exports.validateServerProcess = exports.validateCustomProcessSync = exports.validateCustomProcess = exports.validateProcessSync = exports.validateProcess = exports.shouldValidateServer = exports.shouldValidateCustom = exports.shouldValidateAll = exports.shouldSkipValidation = exports.shouldSkipValidationSimple = exports.shouldSkipValidationCustom = exports._shouldSkipValidation = exports.isForcedHidden = exports.isValueHidden = exports.isInputComponent = exports.validationRules = void 0;\nconst rules_1 = __webpack_require__(/*! ./rules */ \"./node_modules/@formio/core/lib/process/validation/rules/index.js\");\nconst find_1 = __importDefault(__webpack_require__(/*! lodash/find */ \"./node_modules/lodash/find.js\"));\nconst get_1 = __importDefault(__webpack_require__(/*! lodash/get */ \"./node_modules/lodash/get.js\"));\nconst pick_1 = __importDefault(__webpack_require__(/*! lodash/pick */ \"./node_modules/lodash/pick.js\"));\nconst formUtil_1 = __webpack_require__(/*! ../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst error_1 = __webpack_require__(/*! ../../utils/error */ \"./node_modules/@formio/core/lib/utils/error.js\");\nconst conditions_1 = __webpack_require__(/*! ../conditions */ \"./node_modules/@formio/core/lib/process/conditions/index.js\");\n// Cleans up validation errors to remove unnessesary parts\n// and make them transferable to ivm.\nconst cleanupValidationError = (error) => (Object.assign(Object.assign({}, error), { context: (0, pick_1.default)(error.context, [\n 'component',\n 'path',\n 'index',\n 'value',\n 'field',\n 'hasLabel',\n 'processor',\n 'setting',\n 'pattern',\n 'length',\n 'min',\n 'max',\n 'maxDate',\n 'minDate',\n 'maxYear',\n 'minYear',\n 'minCount',\n 'maxCount',\n 'regex',\n ]) }));\nfunction validationRules(context, rules, skipValidation) {\n if (skipValidation && skipValidation(context)) {\n return [];\n }\n const validationRules = [];\n return rules.reduce((acc, rule) => {\n if (rule.shouldProcess && rule.shouldProcess(context)) {\n acc.push(rule);\n }\n return acc;\n }, validationRules);\n}\nexports.validationRules = validationRules;\nfunction isInputComponent(context) {\n const { component } = context;\n return !component.hasOwnProperty('input') || component.input;\n}\nexports.isInputComponent = isInputComponent;\nfunction isValueHidden(context) {\n const { component } = context;\n if (component.protected) {\n return false;\n }\n if ((component.hasOwnProperty('persistent') && !component.persistent) ||\n component.persistent === 'client-only') {\n return true;\n }\n return false;\n}\nexports.isValueHidden = isValueHidden;\nfunction isForcedHidden(context, isConditionallyHidden) {\n const { component } = context;\n if (isConditionallyHidden(context)) {\n return true;\n }\n if (component.hasOwnProperty('hidden')) {\n return !!component.hidden;\n }\n return false;\n}\nexports.isForcedHidden = isForcedHidden;\nconst _shouldSkipValidation = (context, isConditionallyHidden) => {\n var _a;\n const { component, scope, path } = context;\n if ((scope === null || scope === void 0 ? void 0 : scope.conditionals) &&\n ((0, find_1.default)(scope.conditionals, {\n path: (0, formUtil_1.getComponentPath)(component, path),\n conditionallyHidden: true,\n }) ||\n ((_a = component.ephermalState) === null || _a === void 0 ? void 0 : _a.conditionallyHidden) === true)) {\n return true;\n }\n const { validateWhenHidden = false } = component || {};\n const rules = [\n // Skip validation if component is readOnly\n // () => this.options.readOnly,\n // Do not check validations if component is not an input component.\n () => !isInputComponent(context),\n // Check to see if we are editing and if so, check component persistence.\n () => isValueHidden(context),\n // Force valid if component is hidden.\n () => isForcedHidden(context, isConditionallyHidden) && !validateWhenHidden,\n ];\n return rules.some((pred) => pred());\n};\nexports._shouldSkipValidation = _shouldSkipValidation;\nconst shouldSkipValidationCustom = (context) => {\n return (0, exports._shouldSkipValidation)(context, conditions_1.isCustomConditionallyHidden);\n};\nexports.shouldSkipValidationCustom = shouldSkipValidationCustom;\nconst shouldSkipValidationSimple = (context) => {\n return (0, exports._shouldSkipValidation)(context, conditions_1.isSimpleConditionallyHidden);\n};\nexports.shouldSkipValidationSimple = shouldSkipValidationSimple;\nconst shouldSkipValidation = (context) => {\n return (0, exports._shouldSkipValidation)(context, conditions_1.isConditionallyHidden);\n};\nexports.shouldSkipValidation = shouldSkipValidation;\nfunction shouldValidateAll(context) {\n return validationRules(context, rules_1.rules, exports.shouldSkipValidation).length > 0;\n}\nexports.shouldValidateAll = shouldValidateAll;\nfunction shouldValidateCustom(context) {\n const { component } = context;\n if (component.customConditional) {\n return true;\n }\n return !(0, exports.shouldSkipValidationCustom)(context);\n}\nexports.shouldValidateCustom = shouldValidateCustom;\nfunction shouldValidateServer(context) {\n const { component } = context;\n if (component.customConditional) {\n return false;\n }\n if ((0, exports.shouldSkipValidationSimple)(context)) {\n return false;\n }\n return shouldValidateAll(context);\n}\nexports.shouldValidateServer = shouldValidateServer;\nfunction handleError(error, context) {\n const { scope, component } = context;\n const absolutePath = (0, formUtil_1.getComponentAbsolutePath)(component);\n if (error) {\n const cleanedError = cleanupValidationError(error);\n cleanedError.context.path = absolutePath;\n if (!(0, find_1.default)(scope.errors, {\n errorKeyOrMessage: cleanedError.errorKeyOrMessage,\n context: {\n path: absolutePath,\n },\n })) {\n if (!scope.validated)\n scope.validated = [];\n if (!scope.errors)\n scope.errors = [];\n scope.errors.push(cleanedError);\n scope.validated.push({ path: absolutePath, error: cleanedError });\n }\n }\n}\nconst validateProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n const { component, data, row, path, instance, scope, rules, skipValidation } = context;\n let { value } = context;\n if (!scope.validated)\n scope.validated = [];\n if (!scope.errors)\n scope.errors = [];\n if (!rules || !rules.length) {\n return;\n }\n if (component.multiple && Array.isArray(value) && value.length > 0) {\n const fullValueRules = rules.filter((rule) => rule.fullValue);\n const otherRules = rules.filter((rule) => !rule.fullValue);\n for (let i = 0; i < value.length; i++) {\n const amendedPath = `${path}[${i}]`;\n let amendedValue = (0, get_1.default)(data, amendedPath);\n if (instance === null || instance === void 0 ? void 0 : instance.shouldSkipValidation(data)) {\n return;\n }\n const rulesToExecute = validationRules(context, otherRules, skipValidation);\n if (!rulesToExecute.length) {\n continue;\n }\n if (component.truncateMultipleSpaces && amendedValue && typeof amendedValue === 'string') {\n amendedValue = amendedValue.trim().replace(/\\s{2,}/g, ' ');\n }\n for (const rule of rulesToExecute) {\n if (rule && rule.process) {\n handleError(yield rule.process(Object.assign(Object.assign({}, context), { value: amendedValue, index: i, path: amendedPath })), context);\n }\n }\n }\n for (const rule of fullValueRules) {\n if (rule && rule.process) {\n handleError(yield rule.process(Object.assign(Object.assign({}, context), { value })), context);\n }\n }\n return;\n }\n if (instance === null || instance === void 0 ? void 0 : instance.shouldSkipValidation(data, row)) {\n return;\n }\n const rulesToExecute = validationRules(context, rules, skipValidation);\n if (!rulesToExecute.length) {\n return;\n }\n if (component.truncateMultipleSpaces && value && typeof value === 'string') {\n value = value.trim().replace(/\\s{2,}/g, ' ');\n }\n for (const rule of rulesToExecute) {\n try {\n if (rule && rule.process) {\n handleError(yield rule.process(Object.assign(Object.assign({}, context), { value })), context);\n }\n }\n catch (err) {\n console.error('Validator error:', (0, error_1.getErrorMessage)(err));\n }\n }\n return;\n});\nexports.validateProcess = validateProcess;\nconst validateProcessSync = (context) => {\n const { component, data, row, path, instance, scope, rules, skipValidation } = context;\n let { value } = context;\n if (!scope.validated)\n scope.validated = [];\n if (!scope.errors)\n scope.errors = [];\n if (!rules || !rules.length) {\n return;\n }\n if (component.multiple && Array.isArray(value) && value.length > 0) {\n const fullValueRules = rules.filter((rule) => rule.fullValue);\n const otherRules = rules.filter((rule) => !rule.fullValue);\n for (let i = 0; i < value.length; i++) {\n const amendedPath = `${path}[${i}]`;\n let amendedValue = (0, get_1.default)(data, amendedPath);\n if (instance === null || instance === void 0 ? void 0 : instance.shouldSkipValidation(data)) {\n return;\n }\n const rulesToExecute = validationRules(context, otherRules, skipValidation);\n if (!rulesToExecute.length) {\n continue;\n }\n if (component.truncateMultipleSpaces && amendedValue && typeof amendedValue === 'string') {\n amendedValue = amendedValue.trim().replace(/\\s{2,}/g, ' ');\n }\n for (const rule of rulesToExecute) {\n if (rule && rule.processSync) {\n handleError(rule.processSync(Object.assign(Object.assign({}, context), { value: amendedValue, index: i, path: amendedPath })), context);\n }\n }\n }\n for (const rule of fullValueRules) {\n if (rule && rule.processSync) {\n handleError(rule.processSync(Object.assign(Object.assign({}, context), { value })), context);\n }\n }\n return;\n }\n if (instance === null || instance === void 0 ? void 0 : instance.shouldSkipValidation(data, row)) {\n return;\n }\n const rulesToExecute = validationRules(context, rules, skipValidation);\n if (!rulesToExecute.length) {\n return;\n }\n if (component.truncateMultipleSpaces && value && typeof value === 'string') {\n value = value.trim().replace(/\\s{2,}/g, ' ');\n }\n for (const rule of rulesToExecute) {\n try {\n if (rule && rule.processSync) {\n handleError(rule.processSync(Object.assign(Object.assign({}, context), { value })), context);\n }\n }\n catch (err) {\n console.error('Validator error:', (0, error_1.getErrorMessage)(err));\n }\n }\n return;\n};\nexports.validateProcessSync = validateProcessSync;\nconst validateCustomProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n context.rules = context.rules || rules_1.evaluationRules;\n context.skipValidation = exports.shouldSkipValidationCustom;\n return (0, exports.validateProcess)(context);\n});\nexports.validateCustomProcess = validateCustomProcess;\nconst validateCustomProcessSync = (context) => {\n context.rules = context.rules || rules_1.evaluationRules;\n context.skipValidation = exports.shouldSkipValidationCustom;\n return (0, exports.validateProcessSync)(context);\n};\nexports.validateCustomProcessSync = validateCustomProcessSync;\nconst validateServerProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n context.rules = context.rules || rules_1.serverRules;\n context.skipValidation = exports.shouldSkipValidationSimple;\n return (0, exports.validateProcess)(context);\n});\nexports.validateServerProcess = validateServerProcess;\nconst validateServerProcessSync = (context) => {\n context.rules = context.rules || rules_1.serverRules;\n context.skipValidation = exports.shouldSkipValidationSimple;\n return (0, exports.validateProcessSync)(context);\n};\nexports.validateServerProcessSync = validateServerProcessSync;\nconst validateAllProcess = (context) => __awaiter(void 0, void 0, void 0, function* () {\n context.rules = context.rules || rules_1.rules;\n context.skipValidation = exports.shouldSkipValidation;\n return (0, exports.validateProcess)(context);\n});\nexports.validateAllProcess = validateAllProcess;\nconst validateAllProcessSync = (context) => {\n context.rules = context.rules || rules_1.rules;\n context.skipValidation = exports.shouldSkipValidation;\n return (0, exports.validateProcessSync)(context);\n};\nexports.validateAllProcessSync = validateAllProcessSync;\nexports.validateCustomProcessInfo = {\n name: 'validateCustom',\n process: exports.validateCustomProcess,\n processSync: exports.validateCustomProcessSync,\n shouldProcess: shouldValidateCustom,\n};\nexports.validateServerProcessInfo = {\n name: 'validateServer',\n process: exports.validateServerProcess,\n processSync: exports.validateServerProcessSync,\n shouldProcess: shouldValidateServer,\n};\nexports.validateProcessInfo = {\n name: 'validate',\n process: exports.validateAllProcess,\n processSync: exports.validateAllProcessSync,\n shouldProcess: shouldValidateAll,\n};\n__exportStar(__webpack_require__(/*! ./util */ \"./node_modules/@formio/core/lib/process/validation/util.js\"), exports);\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/index.js?");
|
589
589
|
|
590
590
|
/***/ }),
|
591
591
|
|
@@ -596,7 +596,7 @@ eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ?
|
|
596
596
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
597
597
|
|
598
598
|
"use strict";
|
599
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.asynchronousRules = void 0;\nconst validateUrlSelectValue_1 = __webpack_require__(/*! ./validateUrlSelectValue */ \"./node_modules/@formio/core/lib/process/validation/rules/validateUrlSelectValue.js\");\nconst validateAvailableItems_1 = __webpack_require__(/*! ./validateAvailableItems */ \"./node_modules/@formio/core/lib/process/validation/rules/validateAvailableItems.js\");\n// These are the validations that are asynchronouse (e.g. require fetch\nexports.asynchronousRules = [\n validateUrlSelectValue_1.validateUrlSelectValueInfo,\n validateAvailableItems_1.validateAvailableItemsInfo
|
599
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.asynchronousRules = void 0;\nconst validateUrlSelectValue_1 = __webpack_require__(/*! ./validateUrlSelectValue */ \"./node_modules/@formio/core/lib/process/validation/rules/validateUrlSelectValue.js\");\nconst validateAvailableItems_1 = __webpack_require__(/*! ./validateAvailableItems */ \"./node_modules/@formio/core/lib/process/validation/rules/validateAvailableItems.js\");\n// These are the validations that are asynchronouse (e.g. require fetch\nexports.asynchronousRules = [\n validateUrlSelectValue_1.validateUrlSelectValueInfo,\n validateAvailableItems_1.validateAvailableItemsInfo,\n];\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/asynchronousRules.js?");
|
600
600
|
|
601
601
|
/***/ }),
|
602
602
|
|
@@ -607,7 +607,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
607
607
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
608
608
|
|
609
609
|
"use strict";
|
610
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.clientRules = void 0;\nconst validateDate_1 = __webpack_require__(/*! ./validateDate */ \"./node_modules/@formio/core/lib/process/validation/rules/validateDate.js\");\nconst validateDay_1 = __webpack_require__(/*! ./validateDay */ \"./node_modules/@formio/core/lib/process/validation/rules/validateDay.js\");\nconst validateEmail_1 = __webpack_require__(/*! ./validateEmail */ \"./node_modules/@formio/core/lib/process/validation/rules/validateEmail.js\");\nconst validateJson_1 = __webpack_require__(/*! ./validateJson */ \"./node_modules/@formio/core/lib/process/validation/rules/validateJson.js\");\nconst validateMask_1 = __webpack_require__(/*! ./validateMask */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMask.js\");\nconst validateMaximumDay_1 = __webpack_require__(/*! ./validateMaximumDay */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMaximumDay.js\");\nconst validateMaximumLength_1 = __webpack_require__(/*! ./validateMaximumLength */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMaximumLength.js\");\nconst validateMaximumSelectedCount_1 = __webpack_require__(/*! ./validateMaximumSelectedCount */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMaximumSelectedCount.js\");\nconst validateMaximumValue_1 = __webpack_require__(/*! ./validateMaximumValue */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMaximumValue.js\");\nconst validateMaximumWords_1 = __webpack_require__(/*! ./validateMaximumWords */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMaximumWords.js\");\nconst validateMaximumYear_1 = __webpack_require__(/*! ./validateMaximumYear */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMaximumYear.js\");\nconst validateMinimumDay_1 = __webpack_require__(/*! ./validateMinimumDay */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMinimumDay.js\");\nconst validateMinimumLength_1 = __webpack_require__(/*! ./validateMinimumLength */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMinimumLength.js\");\nconst validateMinimumSelectedCount_1 = __webpack_require__(/*! ./validateMinimumSelectedCount */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMinimumSelectedCount.js\");\nconst validateMinimumValue_1 = __webpack_require__(/*! ./validateMinimumValue */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMinimumValue.js\");\nconst validateMinimumWords_1 = __webpack_require__(/*! ./validateMinimumWords */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMinimumWords.js\");\nconst validateMinimumYear_1 = __webpack_require__(/*! ./validateMinimumYear */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMinimumYear.js\");\nconst validateMultiple_1 = __webpack_require__(/*! ./validateMultiple */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMultiple.js\");\nconst validateRegexPattern_1 = __webpack_require__(/*! ./validateRegexPattern */ \"./node_modules/@formio/core/lib/process/validation/rules/validateRegexPattern.js\");\nconst validateRequired_1 = __webpack_require__(/*! ./validateRequired */ \"./node_modules/@formio/core/lib/process/validation/rules/validateRequired.js\");\nconst validateRequiredDay_1 = __webpack_require__(/*! ./validateRequiredDay */ \"./node_modules/@formio/core/lib/process/validation/rules/validateRequiredDay.js\");\nconst validateTime_1 = __webpack_require__(/*! ./validateTime */ \"./node_modules/@formio/core/lib/process/validation/rules/validateTime.js\");\nconst validateUrl_1 = __webpack_require__(/*! ./validateUrl */ \"./node_modules/@formio/core/lib/process/validation/rules/validateUrl.js\");\nconst validateValueProperty_1 = __webpack_require__(/*! ./validateValueProperty */ \"./node_modules/@formio/core/lib/process/validation/rules/validateValueProperty.js\");\nconst validateNumber_1 = __webpack_require__(/*! ./validateNumber */ \"./node_modules/@formio/core/lib/process/validation/rules/validateNumber.js\");\n// These are the validations that are performed in the client.\nexports.clientRules = [\n validateDate_1.validateDateInfo,\n validateDay_1.validateDayInfo,\n validateEmail_1.validateEmailInfo,\n validateJson_1.validateJsonInfo,\n validateMask_1.validateMaskInfo,\n validateMaximumDay_1.validateMaximumDayInfo,\n validateMaximumLength_1.validateMaximumLengthInfo,\n validateMaximumSelectedCount_1.validateMaximumSelectedCountInfo,\n validateMaximumValue_1.validateMaximumValueInfo,\n validateMaximumWords_1.validateMaximumWordsInfo,\n validateMaximumYear_1.validateMaximumYearInfo,\n validateMinimumDay_1.validateMinimumDayInfo,\n validateMinimumLength_1.validateMinimumLengthInfo,\n validateMinimumSelectedCount_1.validateMinimumSelectedCountInfo,\n validateMinimumValue_1.validateMinimumValueInfo,\n validateMinimumWords_1.validateMinimumWordsInfo,\n validateMinimumYear_1.validateMinimumYearInfo,\n validateMultiple_1.validateMultipleInfo,\n validateRegexPattern_1.validateRegexPatternInfo,\n validateRequired_1.validateRequiredInfo,\n validateRequiredDay_1.validateRequiredDayInfo,\n validateTime_1.validateTimeInfo,\n validateUrl_1.validateUrlInfo,\n validateValueProperty_1.validateValuePropertyInfo,\n validateNumber_1.validateNumberInfo
|
610
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.clientRules = void 0;\nconst validateDate_1 = __webpack_require__(/*! ./validateDate */ \"./node_modules/@formio/core/lib/process/validation/rules/validateDate.js\");\nconst validateDay_1 = __webpack_require__(/*! ./validateDay */ \"./node_modules/@formio/core/lib/process/validation/rules/validateDay.js\");\nconst validateEmail_1 = __webpack_require__(/*! ./validateEmail */ \"./node_modules/@formio/core/lib/process/validation/rules/validateEmail.js\");\nconst validateJson_1 = __webpack_require__(/*! ./validateJson */ \"./node_modules/@formio/core/lib/process/validation/rules/validateJson.js\");\nconst validateMask_1 = __webpack_require__(/*! ./validateMask */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMask.js\");\nconst validateMaximumDay_1 = __webpack_require__(/*! ./validateMaximumDay */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMaximumDay.js\");\nconst validateMaximumLength_1 = __webpack_require__(/*! ./validateMaximumLength */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMaximumLength.js\");\nconst validateMaximumSelectedCount_1 = __webpack_require__(/*! ./validateMaximumSelectedCount */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMaximumSelectedCount.js\");\nconst validateMaximumValue_1 = __webpack_require__(/*! ./validateMaximumValue */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMaximumValue.js\");\nconst validateMaximumWords_1 = __webpack_require__(/*! ./validateMaximumWords */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMaximumWords.js\");\nconst validateMaximumYear_1 = __webpack_require__(/*! ./validateMaximumYear */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMaximumYear.js\");\nconst validateMinimumDay_1 = __webpack_require__(/*! ./validateMinimumDay */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMinimumDay.js\");\nconst validateMinimumLength_1 = __webpack_require__(/*! ./validateMinimumLength */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMinimumLength.js\");\nconst validateMinimumSelectedCount_1 = __webpack_require__(/*! ./validateMinimumSelectedCount */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMinimumSelectedCount.js\");\nconst validateMinimumValue_1 = __webpack_require__(/*! ./validateMinimumValue */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMinimumValue.js\");\nconst validateMinimumWords_1 = __webpack_require__(/*! ./validateMinimumWords */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMinimumWords.js\");\nconst validateMinimumYear_1 = __webpack_require__(/*! ./validateMinimumYear */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMinimumYear.js\");\nconst validateMultiple_1 = __webpack_require__(/*! ./validateMultiple */ \"./node_modules/@formio/core/lib/process/validation/rules/validateMultiple.js\");\nconst validateRegexPattern_1 = __webpack_require__(/*! ./validateRegexPattern */ \"./node_modules/@formio/core/lib/process/validation/rules/validateRegexPattern.js\");\nconst validateRequired_1 = __webpack_require__(/*! ./validateRequired */ \"./node_modules/@formio/core/lib/process/validation/rules/validateRequired.js\");\nconst validateRequiredDay_1 = __webpack_require__(/*! ./validateRequiredDay */ \"./node_modules/@formio/core/lib/process/validation/rules/validateRequiredDay.js\");\nconst validateTime_1 = __webpack_require__(/*! ./validateTime */ \"./node_modules/@formio/core/lib/process/validation/rules/validateTime.js\");\nconst validateUrl_1 = __webpack_require__(/*! ./validateUrl */ \"./node_modules/@formio/core/lib/process/validation/rules/validateUrl.js\");\nconst validateValueProperty_1 = __webpack_require__(/*! ./validateValueProperty */ \"./node_modules/@formio/core/lib/process/validation/rules/validateValueProperty.js\");\nconst validateNumber_1 = __webpack_require__(/*! ./validateNumber */ \"./node_modules/@formio/core/lib/process/validation/rules/validateNumber.js\");\n// These are the validations that are performed in the client.\nexports.clientRules = [\n validateDate_1.validateDateInfo,\n validateDay_1.validateDayInfo,\n validateEmail_1.validateEmailInfo,\n validateJson_1.validateJsonInfo,\n validateMask_1.validateMaskInfo,\n validateMaximumDay_1.validateMaximumDayInfo,\n validateMaximumLength_1.validateMaximumLengthInfo,\n validateMaximumSelectedCount_1.validateMaximumSelectedCountInfo,\n validateMaximumValue_1.validateMaximumValueInfo,\n validateMaximumWords_1.validateMaximumWordsInfo,\n validateMaximumYear_1.validateMaximumYearInfo,\n validateMinimumDay_1.validateMinimumDayInfo,\n validateMinimumLength_1.validateMinimumLengthInfo,\n validateMinimumSelectedCount_1.validateMinimumSelectedCountInfo,\n validateMinimumValue_1.validateMinimumValueInfo,\n validateMinimumWords_1.validateMinimumWordsInfo,\n validateMinimumYear_1.validateMinimumYearInfo,\n validateMultiple_1.validateMultipleInfo,\n validateRegexPattern_1.validateRegexPatternInfo,\n validateRequired_1.validateRequiredInfo,\n validateRequiredDay_1.validateRequiredDayInfo,\n validateTime_1.validateTimeInfo,\n validateUrl_1.validateUrlInfo,\n validateValueProperty_1.validateValuePropertyInfo,\n validateNumber_1.validateNumberInfo,\n];\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/clientRules.js?");
|
611
611
|
|
612
612
|
/***/ }),
|
613
613
|
|
@@ -618,7 +618,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
618
618
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
619
619
|
|
620
620
|
"use strict";
|
621
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.databaseRules = void 0;\nconst validateUnique_1 = __webpack_require__(/*! ./validateUnique */ \"./node_modules/@formio/core/lib/process/validation/rules/validateUnique.js\");\nconst validateResourceSelectValue_1 = __webpack_require__(/*! ./validateResourceSelectValue */ \"./node_modules/@formio/core/lib/process/validation/rules/validateResourceSelectValue.js\");\n// These are the validations that require a database connection.\nexports.databaseRules = [\n validateUnique_1.validateUniqueInfo,\n validateResourceSelectValue_1.validateResourceSelectValueInfo
|
621
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.databaseRules = void 0;\nconst validateUnique_1 = __webpack_require__(/*! ./validateUnique */ \"./node_modules/@formio/core/lib/process/validation/rules/validateUnique.js\");\nconst validateResourceSelectValue_1 = __webpack_require__(/*! ./validateResourceSelectValue */ \"./node_modules/@formio/core/lib/process/validation/rules/validateResourceSelectValue.js\");\n// These are the validations that require a database connection.\nexports.databaseRules = [\n validateUnique_1.validateUniqueInfo,\n validateResourceSelectValue_1.validateResourceSelectValueInfo,\n];\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/databaseRules.js?");
|
622
622
|
|
623
623
|
/***/ }),
|
624
624
|
|
@@ -629,7 +629,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
629
629
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
630
630
|
|
631
631
|
"use strict";
|
632
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.evaluationRules = void 0;\nconst validateCustom_1 = __webpack_require__(/*! ./validateCustom */ \"./node_modules/@formio/core/lib/process/validation/rules/validateCustom.js\");\nconst validateAvailableItems_1 = __webpack_require__(/*! ./validateAvailableItems */ \"./node_modules/@formio/core/lib/process/validation/rules/validateAvailableItems.js\");\nexports.evaluationRules = [\n validateCustom_1.validateCustomInfo,\n validateAvailableItems_1.validateAvailableItemsInfo
|
632
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.evaluationRules = void 0;\nconst validateCustom_1 = __webpack_require__(/*! ./validateCustom */ \"./node_modules/@formio/core/lib/process/validation/rules/validateCustom.js\");\nconst validateAvailableItems_1 = __webpack_require__(/*! ./validateAvailableItems */ \"./node_modules/@formio/core/lib/process/validation/rules/validateAvailableItems.js\");\nexports.evaluationRules = [\n validateCustom_1.validateCustomInfo,\n validateAvailableItems_1.validateAvailableItemsInfo,\n];\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/evaluationRules.js?");
|
633
633
|
|
634
634
|
/***/ }),
|
635
635
|
|
@@ -651,7 +651,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
651
651
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
652
652
|
|
653
653
|
"use strict";
|
654
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateAvailableItemsInfo = exports.validateAvailableItemsSync = exports.shouldValidate = exports.validateAvailableItems = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst utils_1 = __webpack_require__(/*! ../../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst util_1 = __webpack_require__(/*! ../util */ \"./node_modules/@formio/core/lib/process/validation/util.js\");\nconst error_2 = __webpack_require__(/*! ../../../utils/error */ \"./node_modules/@formio/core/lib/utils/error.js\");\nfunction isValidatableRadioComponent(component) {\n var _a;\n return (component &&\n component.type === 'radio' &&\n !!((_a = component.validate) === null || _a === void 0 ? void 0 : _a.onlyAvailableItems));\n}\nfunction isValidateableSelectComponent(component) {\n var _a;\n return (component &&\n !!((_a = component.validate) === null || _a === void 0 ? void 0 : _a.onlyAvailableItems) &&\n component.type === 'select' &&\n component.dataSrc !== 'resource');\n}\nfunction isValidateableSelectBoxesComponent(component) {\n var _a;\n return (component &&\n !!((_a = component.validate) === null || _a === void 0 ? void 0 : _a.onlyAvailableItems) &&\n component.type === 'selectboxes' &&\n component.dataSrc === 'url');\n}\nfunction mapDynamicValues(component, values) {\n return values.map((value) => {\n if (component.valueProperty) {\n return value[component.valueProperty];\n }\n return value;\n });\n}\nfunction mapStaticValues(values) {\n return values.map((obj) => obj.value);\n}\nconst getAvailableDynamicValues = (component, context) => __awaiter(void 0, void 0, void 0, function* () {\n let _fetch = null;\n try {\n _fetch = context.fetch ? context.fetch : fetch;\n }\n catch (err) {\n _fetch = null;\n }\n try {\n if (!_fetch) {\n console.log('You must provide a fetch interface to the fetch processor.');\n return null;\n }\n const response = yield _fetch(component.data.url, { method: 'GET' });\n const data = yield response.json();\n return data ? mapDynamicValues(component, data) : null;\n }\n catch (err) {\n console.error((0, error_2.getErrorMessage)(err));\n return null;\n }\n});\nfunction getAvailableSelectValues(component, context) {\n return __awaiter(this, void 0, void 0, function* () {\n if ((0, lodash_1.isUndefined)(component.dataSrc) && component.data.hasOwnProperty('values')) {\n component.dataSrc = 'values';\n }\n ;\n switch (component.dataSrc) {\n case 'values':\n if (Array.isArray(component.data.values)) {\n return mapStaticValues(component.data.values);\n }\n throw new error_1.ProcessorError(`Failed to validate available values in static values select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n case 'json': {\n if (typeof component.data.json === 'string') {\n try {\n return mapDynamicValues(component, JSON.parse(component.data.json));\n }\n catch (err) {\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': ${err}`, context, 'validate:validateAvailableItems');\n }\n }\n else if (Array.isArray(component.data.json)) {\n // TODO: need to retype this\n return mapDynamicValues(component, component.data.json);\n }\n else {\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n }\n }\n case 'custom':\n const customItems = utils_1.Evaluator.evaluate(component.data.custom, {\n values: [],\n }, 'values');\n if ((0, util_1.isPromise)(customItems)) {\n const resolvedCustomItems = yield customItems;\n if (Array.isArray(resolvedCustomItems)) {\n return resolvedCustomItems;\n }\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n }\n if (Array.isArray(customItems)) {\n return customItems;\n }\n else {\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n }\n case 'url':\n return yield getAvailableDynamicValues(component, context);\n default:\n throw new error_1.ProcessorError(`Failed to validate available values in select component '${component.key}': data source ${component.dataSrc} is not valid}`, context, 'validate:validateAvailableItems');\n }\n });\n}\nfunction getAvailableSelectValuesSync(component, context) {\n var _a;\n if ((0, lodash_1.isUndefined)(component.dataSrc) && component.data.hasOwnProperty('values')) {\n component.dataSrc = 'values';\n }\n ;\n switch (component.dataSrc) {\n case 'values':\n if (Array.isArray((_a = component.data) === null || _a === void 0 ? void 0 : _a.values)) {\n return mapStaticValues(component.data.values);\n }\n throw new error_1.ProcessorError(`Failed to validate available values in static values select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n case 'json': {\n if (typeof component.data.json === 'string') {\n try {\n return mapDynamicValues(component, JSON.parse(component.data.json));\n }\n catch (err) {\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': ${err}`, context, 'validate:validateAvailableItems');\n }\n }\n else if (Array.isArray(component.data.json)) {\n // TODO: need to retype this\n return mapDynamicValues(component, component.data.json);\n }\n else {\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n }\n }\n case 'custom':\n const customItems = utils_1.Evaluator.evaluate(component.data.custom, {\n values: [],\n }, 'values');\n if (Array.isArray(customItems)) {\n return customItems;\n }\n else {\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n }\n case 'url':\n return null;\n default:\n throw new error_1.ProcessorError(`Failed to validate available values in select component '${component.key}': data source ${component.dataSrc} is not valid}`, context, 'validate:validateAvailableItems');\n }\n}\nfunction compareComplexValues(valueA, valueB, context) {\n if (!(0, util_1.isObject)(valueA) || !(0, util_1.isObject)(valueB)) {\n return false;\n }\n try {\n // TODO: we need to have normalized values here at this moment, otherwise\n // this won't work\n return JSON.stringify(valueA) === JSON.stringify(valueB);\n }\n catch (err) {\n throw new error_1.ProcessorError(`Error while comparing available values: ${err}`, context, 'validate:validateAvailableItems');\n }\n}\nconst validateAvailableItems = (context) => __awaiter(void 0, void 0, void 0, function* () {\n const { component, value } = context;\n const error = new error_1.FieldError('invalidOption', context, 'onlyAvailableItems');\n try {\n if (isValidatableRadioComponent(component)) {\n if (value == null || (0, lodash_1.isEmpty)(value)) {\n return null;\n }\n const values = component.dataSrc === 'url' ? yield getAvailableDynamicValues(component, context) : component.values;\n if (values) {\n if ((0, util_1.isObject)(value)) {\n return values.find((optionValue) => compareComplexValues(optionValue, value, context)) !==\n undefined\n ? null\n : error;\n }\n return values.find((optionValue) => optionValue === value) !== undefined ? null : error;\n }\n return null;\n }\n else if (isValidateableSelectComponent(component)) {\n if (value == null || (0, lodash_1.isEmpty)(value)) {\n return null;\n }\n const values = yield getAvailableSelectValues(component, context);\n if (values) {\n if ((0, util_1.isObject)(value)) {\n return values.find((optionValue) => compareComplexValues(optionValue, value, context)) !==\n undefined\n ? null\n : error;\n }\n return values.find((optionValue) => optionValue === value) !== undefined ? null : error;\n }\n }\n else if (isValidateableSelectBoxesComponent(component)) {\n if (value == null || (0, lodash_1.isEmpty)(value)) {\n return null;\n }\n const values = yield getAvailableDynamicValues(component, context);\n if (values) {\n if ((0, util_1.isObject)(value)) {\n return values.find((optionValue) => compareComplexValues(optionValue, value, context)) !==\n undefined\n ? null\n : error;\n }\n return values.find((optionValue) => optionValue === value) !== undefined ? null : error;\n }\n }\n }\n catch (err) {\n throw new error_1.ProcessorError(err.message || err, context, 'validate:validateAvailableItems');\n }\n return null;\n});\nexports.validateAvailableItems = validateAvailableItems;\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (value == null || (0, lodash_1.isEmpty)(value)) {\n return false;\n }\n if (isValidatableRadioComponent(component)) {\n return true;\n }\n if (isValidateableSelectComponent(component)) {\n return true;\n }\n if (isValidateableSelectBoxesComponent(component)) {\n return true;\n }\n return false;\n};\nexports.shouldValidate = shouldValidate;\nconst validateAvailableItemsSync = (context) => {\n const { component, value } = context;\n const error = new error_1.FieldError('invalidOption', context, 'onlyAvailableItems');\n try {\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n if (isValidatableRadioComponent(component) && component.dataSrc !== 'url') {\n const values = component.values;\n if (values) {\n return values.findIndex(({ value: optionValue }) => optionValue === value) !== -1\n ? null\n : error;\n }\n return null;\n }\n else if (isValidateableSelectComponent(component)) {\n const values = getAvailableSelectValuesSync(component, context);\n if (values) {\n if ((0, util_1.isObject)(value)) {\n return values.find((optionValue) => compareComplexValues(optionValue, value, context)) !==\n undefined\n ? null\n : error;\n }\n return values.find((optionValue) => optionValue === value) !== undefined ? null : error;\n }\n }\n }\n catch (err) {\n throw new error_1.ProcessorError(err.message || err, context, 'validate:validateAvailableItems');\n }\n return null;\n};\nexports.validateAvailableItemsSync = validateAvailableItemsSync;\nexports.validateAvailableItemsInfo = {\n name: 'validateAvailableItems',\n process: exports.validateAvailableItems,\n processSync: exports.validateAvailableItemsSync,\n shouldProcess: exports.shouldValidate\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateAvailableItems.js?");
|
654
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateAvailableItemsInfo = exports.validateAvailableItemsSync = exports.shouldValidate = exports.validateAvailableItems = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst utils_1 = __webpack_require__(/*! ../../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst util_1 = __webpack_require__(/*! ../util */ \"./node_modules/@formio/core/lib/process/validation/util.js\");\nconst error_2 = __webpack_require__(/*! ../../../utils/error */ \"./node_modules/@formio/core/lib/utils/error.js\");\nfunction isValidatableRadioComponent(component) {\n var _a;\n return component && component.type === 'radio' && !!((_a = component.validate) === null || _a === void 0 ? void 0 : _a.onlyAvailableItems);\n}\nfunction isValidateableSelectComponent(component) {\n var _a;\n return (component &&\n !!((_a = component.validate) === null || _a === void 0 ? void 0 : _a.onlyAvailableItems) &&\n component.type === 'select' &&\n component.dataSrc !== 'resource');\n}\nfunction isValidateableSelectBoxesComponent(component) {\n var _a;\n return (component &&\n !!((_a = component.validate) === null || _a === void 0 ? void 0 : _a.onlyAvailableItems) &&\n component.type === 'selectboxes' &&\n component.dataSrc === 'url');\n}\nfunction mapDynamicValues(component, values) {\n return values.map((value) => {\n if (component.valueProperty) {\n return value[component.valueProperty];\n }\n return value;\n });\n}\nfunction mapStaticValues(values) {\n return values.map((obj) => obj.value);\n}\nconst getAvailableDynamicValues = (component, context) => __awaiter(void 0, void 0, void 0, function* () {\n let _fetch = null;\n try {\n _fetch = context.fetch ? context.fetch : fetch;\n }\n catch (ignoreErr) {\n _fetch = null;\n }\n try {\n if (!_fetch) {\n console.log('You must provide a fetch interface to the fetch processor.');\n return null;\n }\n const response = yield _fetch(component.data.url, { method: 'GET' });\n const data = yield response.json();\n return data ? mapDynamicValues(component, data) : null;\n }\n catch (err) {\n console.error((0, error_2.getErrorMessage)(err));\n return null;\n }\n});\nfunction getAvailableSelectValues(component, context) {\n return __awaiter(this, void 0, void 0, function* () {\n if ((0, lodash_1.isUndefined)(component.dataSrc) && component.data.hasOwnProperty('values')) {\n component.dataSrc = 'values';\n }\n switch (component.dataSrc) {\n case 'values':\n if (Array.isArray(component.data.values)) {\n return mapStaticValues(component.data.values);\n }\n throw new error_1.ProcessorError(`Failed to validate available values in static values select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n case 'json': {\n if (typeof component.data.json === 'string') {\n try {\n return mapDynamicValues(component, JSON.parse(component.data.json));\n }\n catch (err) {\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': ${err}`, context, 'validate:validateAvailableItems');\n }\n }\n else if (Array.isArray(component.data.json)) {\n // TODO: need to retype this\n return mapDynamicValues(component, component.data.json);\n }\n else {\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n }\n }\n case 'custom': {\n const customItems = utils_1.Evaluator.evaluate(component.data.custom, {\n values: [],\n }, 'values');\n if ((0, util_1.isPromise)(customItems)) {\n const resolvedCustomItems = yield customItems;\n if (Array.isArray(resolvedCustomItems)) {\n return resolvedCustomItems;\n }\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n }\n if (Array.isArray(customItems)) {\n return customItems;\n }\n else {\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n }\n }\n case 'url':\n return yield getAvailableDynamicValues(component, context);\n default:\n throw new error_1.ProcessorError(`Failed to validate available values in select component '${component.key}': data source ${component.dataSrc} is not valid}`, context, 'validate:validateAvailableItems');\n }\n });\n}\nfunction getAvailableSelectValuesSync(component, context) {\n var _a;\n if ((0, lodash_1.isUndefined)(component.dataSrc) && component.data.hasOwnProperty('values')) {\n component.dataSrc = 'values';\n }\n switch (component.dataSrc) {\n case 'values':\n if (Array.isArray((_a = component.data) === null || _a === void 0 ? void 0 : _a.values)) {\n return mapStaticValues(component.data.values);\n }\n throw new error_1.ProcessorError(`Failed to validate available values in static values select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n case 'json': {\n if (typeof component.data.json === 'string') {\n try {\n return mapDynamicValues(component, JSON.parse(component.data.json));\n }\n catch (err) {\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': ${err}`, context, 'validate:validateAvailableItems');\n }\n }\n else if (Array.isArray(component.data.json)) {\n // TODO: need to retype this\n return mapDynamicValues(component, component.data.json);\n }\n else {\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n }\n }\n case 'custom': {\n const customItems = utils_1.Evaluator.evaluate(component.data.custom, {\n values: [],\n }, 'values');\n if (Array.isArray(customItems)) {\n return customItems;\n }\n else {\n throw new error_1.ProcessorError(`Failed to validate available values in JSON select component '${component.key}': the values are not an array`, context, 'validate:validateAvailableItems');\n }\n }\n case 'url':\n return null;\n default:\n throw new error_1.ProcessorError(`Failed to validate available values in select component '${component.key}': data source ${component.dataSrc} is not valid}`, context, 'validate:validateAvailableItems');\n }\n}\nfunction compareComplexValues(valueA, valueB, context) {\n if (!(0, util_1.isObject)(valueA) || !(0, util_1.isObject)(valueB)) {\n return false;\n }\n try {\n // TODO: we need to have normalized values here at this moment, otherwise\n // this won't work\n return JSON.stringify(valueA) === JSON.stringify(valueB);\n }\n catch (err) {\n throw new error_1.ProcessorError(`Error while comparing available values: ${err}`, context, 'validate:validateAvailableItems');\n }\n}\nconst validateAvailableItems = (context) => __awaiter(void 0, void 0, void 0, function* () {\n const { component, value } = context;\n const error = new error_1.FieldError('invalidOption', context, 'onlyAvailableItems');\n try {\n if (isValidatableRadioComponent(component)) {\n if (value == null || (0, lodash_1.isEmpty)(value)) {\n return null;\n }\n const values = component.dataSrc === 'url'\n ? yield getAvailableDynamicValues(component, context)\n : component.values;\n if (values) {\n if ((0, util_1.isObject)(value)) {\n return values.find((optionValue) => compareComplexValues(optionValue, value, context)) !==\n undefined\n ? null\n : error;\n }\n return values.find((optionValue) => optionValue.value === value || optionValue === value) !== undefined\n ? null\n : error;\n }\n return null;\n }\n else if (isValidateableSelectComponent(component)) {\n if (value == null || (0, lodash_1.isEmpty)(value)) {\n return null;\n }\n const values = yield getAvailableSelectValues(component, context);\n if (values) {\n if ((0, util_1.isObject)(value)) {\n return values.find((optionValue) => compareComplexValues(optionValue, value, context)) !==\n undefined\n ? null\n : error;\n }\n return values.find((optionValue) => optionValue === value) !== undefined ? null : error;\n }\n }\n else if (isValidateableSelectBoxesComponent(component)) {\n if (value == null || (0, lodash_1.isEmpty)(value)) {\n return null;\n }\n const values = yield getAvailableDynamicValues(component, context);\n if (values) {\n if ((0, util_1.isObject)(value)) {\n return values.find((optionValue) => compareComplexValues(optionValue, value, context)) !==\n undefined\n ? null\n : error;\n }\n return values.find((optionValue) => optionValue === value) !== undefined ? null : error;\n }\n }\n }\n catch (err) {\n throw new error_1.ProcessorError(err.message || err, context, 'validate:validateAvailableItems');\n }\n return null;\n});\nexports.validateAvailableItems = validateAvailableItems;\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (value == null || (0, lodash_1.isEmpty)(value)) {\n return false;\n }\n if (isValidatableRadioComponent(component)) {\n return true;\n }\n if (isValidateableSelectComponent(component)) {\n return true;\n }\n if (isValidateableSelectBoxesComponent(component)) {\n return true;\n }\n return false;\n};\nexports.shouldValidate = shouldValidate;\nconst validateAvailableItemsSync = (context) => {\n const { component, value } = context;\n const error = new error_1.FieldError('invalidOption', context, 'onlyAvailableItems');\n try {\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n if (isValidatableRadioComponent(component) && component.dataSrc !== 'url') {\n const values = component.values;\n if (values) {\n return values.findIndex(({ value: optionValue }) => optionValue === value) !== -1\n ? null\n : error;\n }\n return null;\n }\n else if (isValidateableSelectComponent(component)) {\n const values = getAvailableSelectValuesSync(component, context);\n if (values) {\n if ((0, util_1.isObject)(value)) {\n return values.find((optionValue) => compareComplexValues(optionValue, value, context)) !==\n undefined\n ? null\n : error;\n }\n return values.find((optionValue) => optionValue === value) !== undefined ? null : error;\n }\n }\n }\n catch (err) {\n throw new error_1.ProcessorError(err.message || err, context, 'validate:validateAvailableItems');\n }\n return null;\n};\nexports.validateAvailableItemsSync = validateAvailableItemsSync;\nexports.validateAvailableItemsInfo = {\n name: 'validateAvailableItems',\n process: exports.validateAvailableItems,\n processSync: exports.validateAvailableItemsSync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateAvailableItems.js?");
|
655
655
|
|
656
656
|
/***/ }),
|
657
657
|
|
@@ -662,7 +662,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
662
662
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
663
663
|
|
664
664
|
"use strict";
|
665
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateCustomInfo = exports.validateCustomSync = exports.shouldValidate = exports.validateCustom = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst utils_1 = __webpack_require__(/*! ../../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst validateCustom = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateCustomSync)(context);\n});\nexports.validateCustom = validateCustom;\nconst shouldValidate = (context) => {\n var _a;\n const { component } = context;\n const customValidation = (_a = component.validate) === null || _a === void 0 ? void 0 : _a.custom;\n if (!customValidation) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateCustomSync = (context) => {\n var _a;\n const { component, data, row, value, index, instance, evalContext } = context;\n const customValidation = (_a = component.validate) === null || _a === void 0 ? void 0 : _a.custom;\n try {\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n const evalContextValue = Object.assign(Object.assign({}, ((instance === null || instance === void 0 ? void 0 : instance.evalContext)
|
665
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateCustomInfo = exports.validateCustomSync = exports.shouldValidate = exports.validateCustom = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst utils_1 = __webpack_require__(/*! ../../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst validateCustom = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateCustomSync)(context);\n});\nexports.validateCustom = validateCustom;\nconst shouldValidate = (context) => {\n var _a;\n const { component } = context;\n const customValidation = (_a = component.validate) === null || _a === void 0 ? void 0 : _a.custom;\n if (!customValidation) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateCustomSync = (context) => {\n var _a;\n const { component, data, row, value, index, instance, evalContext } = context;\n const customValidation = (_a = component.validate) === null || _a === void 0 ? void 0 : _a.custom;\n try {\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n const evalContextValue = Object.assign(Object.assign({}, ((instance === null || instance === void 0 ? void 0 : instance.evalContext)\n ? instance.evalContext()\n : evalContext\n ? evalContext(context)\n : context)), { component,\n data,\n row, rowIndex: index, instance, valid: true, input: value });\n const isValid = utils_1.Evaluator.evaluate(customValidation, evalContextValue, 'valid', true, {}, {});\n if (isValid === null || isValid === true) {\n return null;\n }\n return new error_1.FieldError(typeof isValid === 'string' ? isValid : 'custom', Object.assign(Object.assign({}, context), { hasLabel: false, setting: customValidation }), 'custom');\n }\n catch (err) {\n throw new error_1.ProcessorError(err.message || err, context, 'validate:validateCustom');\n }\n};\nexports.validateCustomSync = validateCustomSync;\nexports.validateCustomInfo = {\n name: 'validateCustom',\n process: exports.validateCustom,\n processSync: exports.validateCustomSync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateCustom.js?");
|
666
666
|
|
667
667
|
/***/ }),
|
668
668
|
|
@@ -673,7 +673,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
673
673
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
674
674
|
|
675
675
|
"use strict";
|
676
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateDateInfo = exports.validateDateSync = exports.validateDate = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isValidatableDateTimeComponent = (obj) => {\n return !!obj && !!obj.type && obj.type === 'datetime';\n};\nconst isValidatable = (component) => {\n return isValidatableDateTimeComponent(component);\n};\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (!value || !isValidatable(component)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateDate = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateDateSync)(context);\n});\nexports.validateDate = validateDate;\nconst validateDateSync = (context) => {\n const error = new error_1.FieldError('invalidDate', context, 'date');\n const {
|
676
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateDateInfo = exports.validateDateSync = exports.validateDate = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isValidatableDateTimeComponent = (obj) => {\n return !!obj && !!obj.type && obj.type === 'datetime';\n};\nconst isValidatable = (component) => {\n return isValidatableDateTimeComponent(component);\n};\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (!value || !isValidatable(component)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateDate = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateDateSync)(context);\n});\nexports.validateDate = validateDate;\nconst validateDateSync = (context) => {\n const error = new error_1.FieldError('invalidDate', context, 'date');\n const { value } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n // TODO: is this right?\n if (typeof value === 'string') {\n if (value.toLowerCase() === 'invalid date') {\n return error;\n }\n if (new Date(value).toString() === 'Invalid Date') {\n return error;\n }\n return null;\n }\n else if (value instanceof Date) {\n return value.toString() !== 'Invalid Date' ? null : error;\n }\n return error;\n};\nexports.validateDateSync = validateDateSync;\nexports.validateDateInfo = {\n name: 'validateDate',\n process: exports.validateDate,\n processSync: exports.validateDateSync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateDate.js?");
|
677
677
|
|
678
678
|
/***/ }),
|
679
679
|
|
@@ -684,7 +684,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
684
684
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
685
685
|
|
686
686
|
"use strict";
|
687
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateDayInfo = exports.validateDaySync = exports.validateDay = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isLeapYear = (year) => {\n // Year is leap if it is evenly divisible by 400 or evenly divisible by 4 and not evenly divisible by 100.\n return !(year % 400) || (!!(year % 100) && !(year % 4));\n};\nconst getDaysInMonthCount = (month, year) => {\n switch (month) {\n case 1: // January\n case 3: // March\n case 5: // May\n case 7: // July\n case 8: // August\n case 10: // October\n case 12: // December\n return 31;\n case 4: // April\n case 6: // June\n case 9: // September\n case 11: // November\n return 30;\n case 2: // February\n return isLeapYear(year) ? 29 : 28;\n default:\n return 31;\n }\n};\nconst isDayComponent = (component) => {\n return component && component.type === 'day';\n};\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (!value) {\n return false;\n }\n if (!isDayComponent(component)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateDay = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateDaySync)(context);\n});\nexports.validateDay = validateDay;\nconst validateDaySync = (context) => {\n const { component, value } = context;\n if (!(0, exports.shouldValidate)(context) || !isDayComponent(component)) {\n return null;\n }\n const error = new error_1.FieldError('invalidDay', context, 'day');\n if (typeof value !== 'string') {\n return error;\n }\n let [DAY, MONTH, YEAR] = component.dayFirst ? [0, 1, 2] : [1, 0, 2];\n const values = value.split('/').map((x) => parseInt(x, 10));\n let day = values[DAY];\n let month = values[MONTH];\n let year = values[YEAR];\n if (values.length !== 3) {\n if (component.fields.day.hide) {\n MONTH = MONTH === 0 ? 0 : MONTH - 1;\n YEAR = YEAR - 1;\n day = 0;\n month = values[MONTH];\n year = values[YEAR];\n }\n
|
687
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateDayInfo = exports.validateDaySync = exports.validateDay = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isLeapYear = (year) => {\n // Year is leap if it is evenly divisible by 400 or evenly divisible by 4 and not evenly divisible by 100.\n return !(year % 400) || (!!(year % 100) && !(year % 4));\n};\nconst getDaysInMonthCount = (month, year) => {\n switch (month) {\n case 1: // January\n case 3: // March\n case 5: // May\n case 7: // July\n case 8: // August\n case 10: // October\n case 12: // December\n return 31;\n case 4: // April\n case 6: // June\n case 9: // September\n case 11: // November\n return 30;\n case 2: // February\n return isLeapYear(year) ? 29 : 28;\n default:\n return 31;\n }\n};\nconst isDayComponent = (component) => {\n return component && component.type === 'day';\n};\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (!value) {\n return false;\n }\n if (!isDayComponent(component)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateDay = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateDaySync)(context);\n});\nexports.validateDay = validateDay;\nconst validateDaySync = (context) => {\n const { component, value } = context;\n if (!(0, exports.shouldValidate)(context) || !isDayComponent(component)) {\n return null;\n }\n const error = new error_1.FieldError('invalidDay', context, 'day');\n if (typeof value !== 'string') {\n return error;\n }\n let [DAY, MONTH, YEAR] = component.dayFirst ? [0, 1, 2] : [1, 0, 2];\n const values = value.split('/').map((x) => parseInt(x, 10));\n let day = values[DAY];\n let month = values[MONTH];\n let year = values[YEAR];\n if (values.length !== 3) {\n if (component.fields.day.hide) {\n MONTH = MONTH === 0 ? 0 : MONTH - 1;\n YEAR = YEAR - 1;\n day = 0;\n month = values[MONTH];\n year = values[YEAR];\n }\n if (component.fields.month.hide) {\n DAY = DAY === 0 ? 0 : DAY - 1;\n YEAR = YEAR - 1;\n day = component.fields.day.hide && day === 0 ? 0 : values[DAY];\n month = 0;\n year = values[YEAR];\n }\n if (component.fields.year.hide) {\n day = component.fields.day.hide && day === 0 ? 0 : values[DAY];\n month = component.fields.month.hide && month === 0 ? 0 : values[MONTH];\n year = 0;\n }\n }\n const maxDay = getDaysInMonthCount(month, year);\n if (isNaN(day) || day < 0 || day > maxDay) {\n return error;\n }\n if (isNaN(month) || month < 0 || month > 12) {\n return error;\n }\n if (isNaN(year) || year < 0 || year > 9999) {\n return error;\n }\n return null;\n};\nexports.validateDaySync = validateDaySync;\nexports.validateDayInfo = {\n name: 'validateDay',\n process: exports.validateDay,\n processSync: exports.validateDaySync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateDay.js?");
|
688
688
|
|
689
689
|
/***/ }),
|
690
690
|
|
@@ -695,7 +695,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
695
695
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
696
696
|
|
697
697
|
"use strict";
|
698
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateEmailInfo = exports.validateEmailSync = exports.validateEmail = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isValidatableEmailComponent = (component) => {\n return component && component.type === 'email';\n};\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (!value) {\n return false;\n }\n if (!isValidatableEmailComponent(component)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateEmail = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateEmailSync)(context);\n});\nexports.validateEmail = validateEmail;\nconst validateEmailSync = (context) => {\n const error = new error_1.FieldError('invalid_email', context, 'email');\n const { value } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n // From http://stackoverflow.com/questions/46155/validate-email-address-in-javascript\n const emailRegex = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n // Allow emails to be valid if the component is pristine and no value is provided.\n if (typeof value === 'string' && !emailRegex.test(value)) {\n return error;\n }\n return null;\n};\nexports.validateEmailSync = validateEmailSync;\nexports.validateEmailInfo = {\n name: 'validateEmail',\n process: exports.validateEmail,\n processSync: exports.validateEmailSync,\n shouldProcess: exports.shouldValidate
|
698
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateEmailInfo = exports.validateEmailSync = exports.validateEmail = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isValidatableEmailComponent = (component) => {\n return component && component.type === 'email';\n};\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (!value) {\n return false;\n }\n if (!isValidatableEmailComponent(component)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateEmail = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateEmailSync)(context);\n});\nexports.validateEmail = validateEmail;\nconst validateEmailSync = (context) => {\n const error = new error_1.FieldError('invalid_email', context, 'email');\n const { value } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n // From http://stackoverflow.com/questions/46155/validate-email-address-in-javascript\n const emailRegex = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n // Allow emails to be valid if the component is pristine and no value is provided.\n if (typeof value === 'string' && !emailRegex.test(value)) {\n return error;\n }\n return null;\n};\nexports.validateEmailSync = validateEmailSync;\nexports.validateEmailInfo = {\n name: 'validateEmail',\n process: exports.validateEmail,\n processSync: exports.validateEmailSync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateEmail.js?");
|
699
699
|
|
700
700
|
/***/ }),
|
701
701
|
|
@@ -706,7 +706,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
706
706
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
707
707
|
|
708
708
|
"use strict";
|
709
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateJsonInfo = exports.validateJsonSync = exports.validateJson = exports.shouldValidate = void 0;\nconst jsonlogic_1 = __webpack_require__(/*! ../../../modules/jsonlogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/index.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst shouldValidate = (context) => {\n var _a;\n const { component } = context;\n if (!((_a = component.validate) === null || _a === void 0 ? void 0 : _a.json) || !(0, lodash_1.isObject)(component.validate.json)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateJson = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateJsonSync)(context);\n});\nexports.validateJson = validateJson;\nconst validateJsonSync = (context) => {\n var _a;\n const { component,
|
709
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateJsonInfo = exports.validateJsonSync = exports.validateJson = exports.shouldValidate = void 0;\nconst jsonlogic_1 = __webpack_require__(/*! ../../../modules/jsonlogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/index.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst shouldValidate = (context) => {\n var _a;\n const { component } = context;\n if (!((_a = component.validate) === null || _a === void 0 ? void 0 : _a.json) || !(0, lodash_1.isObject)(component.validate.json)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateJson = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateJsonSync)(context);\n});\nexports.validateJson = validateJson;\nconst validateJsonSync = (context) => {\n var _a;\n const { component, value, evalContext } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n const func = (_a = component === null || component === void 0 ? void 0 : component.validate) === null || _a === void 0 ? void 0 : _a.json;\n const evalContextValue = evalContext ? evalContext(context) : context;\n evalContextValue.value = value || null;\n const valid = jsonlogic_1.JSONLogicEvaluator.evaluate(func, Object.assign(Object.assign({}, evalContextValue), { input: value }), 'valid');\n if (valid === null) {\n return null;\n }\n return valid === true\n ? null\n : new error_1.FieldError(valid || 'jsonLogic', Object.assign(Object.assign({}, context), { setting: func }), 'json');\n};\nexports.validateJsonSync = validateJsonSync;\nexports.validateJsonInfo = {\n name: 'validateJson',\n process: exports.validateJson,\n processSync: exports.validateJsonSync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateJson.js?");
|
710
710
|
|
711
711
|
/***/ }),
|
712
712
|
|
@@ -717,7 +717,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
717
717
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
718
718
|
|
719
719
|
"use strict";
|
720
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateMaskInfo = exports.validateMaskSync = exports.validateMask = exports.shouldValidate = exports.matchInputMask = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst inputmask_1 = __importDefault(__webpack_require__(/*! inputmask */ \"./node_modules/@formio/core/node_modules/inputmask/dist/inputmask.js\"));\nconst isMaskType = (obj) => {\n return ((obj === null || obj === void 0 ? void 0 : obj.maskName) &&\n typeof (obj === null || obj === void 0 ? void 0 : obj.maskName) === 'string' &&\n (obj === null || obj === void 0 ? void 0 : obj.value) &&\n typeof (obj === null || obj === void 0 ? void 0 : obj.value) === 'string');\n};\nconst isValidatableComponent = (component) => {\n // For some reason we skip mask validation for time components\n return ((component
|
720
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateMaskInfo = exports.validateMaskSync = exports.validateMask = exports.shouldValidate = exports.matchInputMask = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst inputmask_1 = __importDefault(__webpack_require__(/*! inputmask */ \"./node_modules/@formio/core/node_modules/inputmask/dist/inputmask.js\"));\nconst isMaskType = (obj) => {\n return ((obj === null || obj === void 0 ? void 0 : obj.maskName) &&\n typeof (obj === null || obj === void 0 ? void 0 : obj.maskName) === 'string' &&\n (obj === null || obj === void 0 ? void 0 : obj.value) &&\n typeof (obj === null || obj === void 0 ? void 0 : obj.value) === 'string');\n};\nconst isValidatableComponent = (component) => {\n // For some reason we skip mask validation for time components\n return ((component &&\n component.type &&\n component.type !== 'time' &&\n component &&\n component.hasOwnProperty('inputMask') &&\n !!component.inputMask) ||\n (component && component.hasOwnProperty('inputMasks') && !(0, lodash_1.isEmpty)(component.inputMasks)));\n};\nfunction getMaskByLabel(component, maskName) {\n var _a;\n if (maskName) {\n const inputMask = (_a = component.inputMasks) === null || _a === void 0 ? void 0 : _a.find((inputMask) => {\n return inputMask.label === maskName;\n });\n return inputMask ? inputMask.mask : undefined;\n }\n return;\n}\nfunction getInputMask(mask, placeholderChar) {\n if (mask instanceof Array) {\n return mask;\n }\n const maskArray = [];\n for (let i = 0; i < mask.length; i++) {\n switch (mask[i]) {\n case '9':\n maskArray.push(/\\d/);\n break;\n case 'A':\n maskArray.push(/[a-zA-Z]/);\n break;\n case 'a':\n maskArray.push(/[a-z]/);\n break;\n case '*':\n maskArray.push(/[a-zA-Z0-9]/);\n break;\n // If char which is used inside mask placeholder was used in the mask, replace it with space to prevent errors\n case placeholderChar:\n maskArray.push(' ');\n break;\n default:\n maskArray.push(mask[i]);\n break;\n }\n }\n return maskArray;\n}\nfunction matchInputMask(value, inputMask) {\n if (!inputMask) {\n return true;\n }\n // If value is longer than mask, it isn't valid.\n if (value.length > inputMask.length) {\n return false;\n }\n for (let i = 0; i < inputMask.length; i++) {\n const char = value[i];\n const charPart = inputMask[i];\n if (charPart instanceof RegExp) {\n if (!charPart.test(char)) {\n return false;\n }\n continue;\n }\n else if (charPart !== char) {\n return false;\n }\n }\n return true;\n}\nexports.matchInputMask = matchInputMask;\nconst shouldValidate = (context) => {\n var _a;\n const { component, value } = context;\n if (!isValidatableComponent(component) || !value) {\n return false;\n }\n if (value == null) {\n return false;\n }\n if (component.allowMultipleMasks && ((_a = component.inputMasks) === null || _a === void 0 ? void 0 : _a.length)) {\n const mask = value && isMaskType(value) ? value : undefined;\n const formioInputMask = getMaskByLabel(component, mask === null || mask === void 0 ? void 0 : mask.maskName);\n if (formioInputMask && !getInputMask(formioInputMask)) {\n return false;\n }\n }\n else if (!getInputMask(component.inputMask || '')) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateMask = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateMaskSync)(context);\n});\nexports.validateMask = validateMask;\n// TODO: this function has side effects\nconst validateMaskSync = (context) => {\n var _a;\n const { component, value } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n let inputMask;\n let maskValue;\n if (component.allowMultipleMasks && ((_a = component.inputMasks) === null || _a === void 0 ? void 0 : _a.length)) {\n const mask = value && isMaskType(value) ? value : undefined;\n const formioInputMask = getMaskByLabel(component, mask === null || mask === void 0 ? void 0 : mask.maskName);\n if (formioInputMask) {\n inputMask = formioInputMask;\n }\n maskValue = mask === null || mask === void 0 ? void 0 : mask.value;\n }\n else {\n inputMask = component.inputMask || '';\n }\n if (!inputMask) {\n return null;\n }\n if (value && inputMask && typeof value === 'string' && component.type === 'textfield') {\n return inputmask_1.default.isValid(value, { mask: inputMask.toString() })\n ? null\n : new error_1.FieldError('mask', context);\n }\n const inputMaskArr = getInputMask(inputMask);\n if (value != null && inputMaskArr) {\n const error = new error_1.FieldError('mask', context);\n return matchInputMask(maskValue || value, inputMaskArr) ? null : error;\n }\n return null;\n};\nexports.validateMaskSync = validateMaskSync;\nexports.validateMaskInfo = {\n name: 'validateMask',\n process: exports.validateMask,\n processSync: exports.validateMaskSync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateMask.js?");
|
721
721
|
|
722
722
|
/***/ }),
|
723
723
|
|
@@ -739,7 +739,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
739
739
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
740
740
|
|
741
741
|
"use strict";
|
742
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateMaximumLengthInfo = exports.validateMaximumLengthSync = exports.validateMaximumLength = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isValidatableTextFieldComponent = (component) => {\n var _a;\n return component && ((_a = component.validate) === null || _a === void 0 ? void 0 : _a.hasOwnProperty('maxLength'));\n};\nconst getValidationSetting = (component) => {\n var _a;\n let maxLength = (_a = component.validate) === null || _a === void 0 ? void 0 : _a.maxLength;\n maxLength =
|
742
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateMaximumLengthInfo = exports.validateMaximumLengthSync = exports.validateMaximumLength = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isValidatableTextFieldComponent = (component) => {\n var _a;\n return component && ((_a = component.validate) === null || _a === void 0 ? void 0 : _a.hasOwnProperty('maxLength'));\n};\nconst getValidationSetting = (component) => {\n var _a;\n let maxLength = (_a = component.validate) === null || _a === void 0 ? void 0 : _a.maxLength;\n maxLength = typeof maxLength === 'string' ? parseInt(maxLength, 10) : maxLength;\n return maxLength;\n};\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (!isValidatableTextFieldComponent(component)) {\n return false;\n }\n if (!value) {\n return false;\n }\n if (typeof value !== 'string') {\n return false;\n }\n const setting = getValidationSetting(component);\n if (setting === undefined) {\n return false;\n }\n if (!setting || Number.isNaN(setting)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateMaximumLength = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateMaximumLengthSync)(context);\n});\nexports.validateMaximumLength = validateMaximumLength;\nconst validateMaximumLengthSync = (context) => {\n const { component, value } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n const maxLength = getValidationSetting(component);\n if (maxLength === undefined || Number.isNaN(maxLength)) {\n return null;\n }\n if (!value || typeof value !== 'string') {\n return null;\n }\n if (value.length > maxLength) {\n const error = new error_1.FieldError('maxLength', Object.assign(Object.assign({}, context), { length: String(maxLength), setting: String(maxLength) }));\n return error;\n }\n return null;\n};\nexports.validateMaximumLengthSync = validateMaximumLengthSync;\nexports.validateMaximumLengthInfo = {\n name: 'validateMaximumLength',\n process: exports.validateMaximumLength,\n processSync: exports.validateMaximumLengthSync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateMaximumLength.js?");
|
743
743
|
|
744
744
|
/***/ }),
|
745
745
|
|
@@ -860,7 +860,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
860
860
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
861
861
|
|
862
862
|
"use strict";
|
863
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateMultipleInfo = exports.validateMultipleSync = exports.validateMultiple = exports.shouldValidate = exports.emptyValueIsArray = exports.isEligible = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst formUtil_1 = __webpack_require__(/*! ../../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst isEligible = (component) => {\n // TODO: would be nice if this was type safe\n switch (component.type) {\n case 'hidden':\n case 'address':\n if (!component.multiple) {\n return false;\n }\n return true;\n case 'textarea':\n if (!component.as ||\n component.as !== 'json' ||\n (component.as === 'json' && !component.multiple)) {\n return false;\n }\n return true;\n // TODO: For backwards compatibility, skip multiple validation for select components until we can investigate\n // how this validation might break existing forms\n case 'select':\n return false;\n default:\n return true;\n }\n};\nexports.isEligible = isEligible;\nconst isTagsComponent = (component) => {\n return (component === null || component === void 0 ? void 0 : component.type) === 'tags';\n};\nconst emptyValueIsArray = (component) => {\n // TODO: How do we infer the data model of the compoennt given only its JSON? For now, we have to hardcode component types\n switch (component.type) {\n case 'datagrid':\n case 'editgrid':\n case 'tagpad':\n case 'sketchpad':\n case 'datatable':\n case 'dynamicWizard':\n case 'file':\n return true;\n case 'select':\n case 'textfield':\n return !!component.multiple;\n case 'tags':\n return component.storeas !== 'string';\n default:\n return true;\n }\n};\nexports.emptyValueIsArray = emptyValueIsArray;\nconst shouldValidate = (context) => {\n const { component } = context;\n if (!(0, exports.isEligible)(component)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateMultiple = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateMultipleSync)(context);\n});\nexports.validateMultiple = validateMultiple;\nconst validateMultipleSync = (context) => {\n var _a;\n const { component, value } = context;\n // Skip multiple validation if the component tells us to\n if (!(0, exports.isEligible)(component)) {\n return null;\n }\n const shouldBeMultipleArray = !!component.multiple;\n const isRequired = !!((_a = component.validate) === null || _a === void 0 ? void 0 : _a.required);\n const compModelType = (0, formUtil_1.getModelType)(component);\n const underlyingValueShouldBeArray = ['nestedArray', 'nestedDataArray'].indexOf(compModelType) !== -1
|
863
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateMultipleInfo = exports.validateMultipleSync = exports.validateMultiple = exports.shouldValidate = exports.emptyValueIsArray = exports.isEligible = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst formUtil_1 = __webpack_require__(/*! ../../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst isEligible = (component) => {\n // TODO: would be nice if this was type safe\n switch (component.type) {\n case 'hidden':\n case 'address':\n if (!component.multiple) {\n return false;\n }\n return true;\n case 'textarea':\n if (!component.as ||\n component.as !== 'json' ||\n (component.as === 'json' && !component.multiple)) {\n return false;\n }\n return true;\n // TODO: For backwards compatibility, skip multiple validation for select components until we can investigate\n // how this validation might break existing forms\n case 'select':\n return false;\n default:\n return true;\n }\n};\nexports.isEligible = isEligible;\nconst isTagsComponent = (component) => {\n return (component === null || component === void 0 ? void 0 : component.type) === 'tags';\n};\nconst emptyValueIsArray = (component) => {\n // TODO: How do we infer the data model of the compoennt given only its JSON? For now, we have to hardcode component types\n switch (component.type) {\n case 'datagrid':\n case 'editgrid':\n case 'tagpad':\n case 'sketchpad':\n case 'datatable':\n case 'dynamicWizard':\n case 'file':\n return true;\n case 'select':\n case 'textfield':\n return !!component.multiple;\n case 'tags':\n return component.storeas !== 'string';\n default:\n return true;\n }\n};\nexports.emptyValueIsArray = emptyValueIsArray;\nconst shouldValidate = (context) => {\n const { component } = context;\n if (!(0, exports.isEligible)(component)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateMultiple = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateMultipleSync)(context);\n});\nexports.validateMultiple = validateMultiple;\nconst validateMultipleSync = (context) => {\n var _a;\n const { component, value } = context;\n // Skip multiple validation if the component tells us to\n if (!(0, exports.isEligible)(component)) {\n return null;\n }\n const shouldBeMultipleArray = !!component.multiple;\n const isRequired = !!((_a = component.validate) === null || _a === void 0 ? void 0 : _a.required);\n const compModelType = (0, formUtil_1.getModelType)(component);\n const underlyingValueShouldBeArray = ['nestedArray', 'nestedDataArray'].indexOf(compModelType) !== -1 ||\n (isTagsComponent(component) && component.storeas === 'array');\n const valueIsArray = Array.isArray(value);\n if (shouldBeMultipleArray) {\n if (valueIsArray && underlyingValueShouldBeArray) {\n if (value.length === 0) {\n return isRequired ? new error_1.FieldError('array_nonempty', Object.assign(Object.assign({}, context), { setting: true })) : null;\n }\n // TODO: We need to be permissive here for file components, which have an array model type but don't have an underlying array value\n // (in other words, a file component's data object will always be a single array regardless of whether or not multiple is set)\n // In the future, we could consider checking the underlying value's type to determine if it should be an array\n // return Array.isArray(value[0]) ? null : new FieldError('array', { ...context, setting: true });\n return null;\n }\n else if (valueIsArray && !underlyingValueShouldBeArray) {\n if (value.length === 0) {\n return isRequired ? new error_1.FieldError('array_nonempty', Object.assign(Object.assign({}, context), { setting: true })) : null;\n }\n return Array.isArray(value[0]) && compModelType !== 'any'\n ? new error_1.FieldError('nonarray', Object.assign(Object.assign({}, context), { setting: true }))\n : null;\n }\n else {\n const error = new error_1.FieldError('array', Object.assign(Object.assign({}, context), { setting: true }));\n // Null/undefined is ok if this value isn't required; anything else should fail\n return (0, lodash_1.isNil)(value) ? (isRequired ? error : null) : error;\n }\n }\n else {\n const canBeArray = (0, exports.emptyValueIsArray)(component) || underlyingValueShouldBeArray;\n if (!canBeArray && valueIsArray) {\n return new error_1.FieldError('nonarray', Object.assign(Object.assign({}, context), { setting: false }));\n }\n return null;\n }\n};\nexports.validateMultipleSync = validateMultipleSync;\nexports.validateMultipleInfo = {\n name: 'validateMultiple',\n process: exports.validateMultiple,\n fullValue: true,\n processSync: exports.validateMultipleSync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateMultiple.js?");
|
864
864
|
|
865
865
|
/***/ }),
|
866
866
|
|
@@ -893,7 +893,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
893
893
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
894
894
|
|
895
895
|
"use strict";
|
896
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateRequiredInfo = exports.validateRequiredSync = exports.validateRequired = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst util_1 = __webpack_require__(/*! ../util */ \"./node_modules/@formio/core/lib/process/validation/util.js\");\nconst formUtil_1 = __webpack_require__(/*! ../../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst isAddressComponent = (component) => {\n return component.type === 'address';\n};\nconst isDayComponent = (component) => {\n return component.type === 'day';\n};\nconst isAddressComponentDataObject = (value) => {\n return value !== null
|
896
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateRequiredInfo = exports.validateRequiredSync = exports.validateRequired = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst util_1 = __webpack_require__(/*! ../util */ \"./node_modules/@formio/core/lib/process/validation/util.js\");\nconst formUtil_1 = __webpack_require__(/*! ../../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst isAddressComponent = (component) => {\n return component.type === 'address';\n};\nconst isDayComponent = (component) => {\n return component.type === 'day';\n};\nconst isAddressComponentDataObject = (value) => {\n return (value !== null &&\n typeof value === 'object' &&\n value.mode &&\n value.address &&\n typeof value.address === 'object');\n};\n// Checkboxes and selectboxes consider false to be falsy, whereas other components with\n// settable values (e.g. radio, select, datamap, container, etc.) consider it truthy\nconst isComponentThatCannotHaveFalseValue = (component) => {\n return component.type === 'checkbox' || component.type === 'selectboxes';\n};\nconst valueIsPresent = (value, considerFalseTruthy, isNestedDatatype) => {\n // Evaluate for 3 out of 6 falsy values (\"\", null, undefined), don't check for 0\n // and only check for false under certain conditions\n if (value === null ||\n value === undefined ||\n value === '' ||\n (!considerFalseTruthy && value === false)) {\n return false;\n }\n // Evaluate for empty object\n else if ((0, util_1.isEmptyObject)(value)) {\n return false;\n }\n // Evaluate for empty array\n else if (Array.isArray(value) && value.length === 0) {\n return false;\n }\n // Recursively evaluate\n else if (typeof value === 'object' && !isNestedDatatype) {\n return Object.values(value).some((val) => valueIsPresent(val, considerFalseTruthy, isNestedDatatype));\n }\n // If value is an array, check it's children have value\n else if (Array.isArray(value) && value.length) {\n return (0, util_1.doesArrayDataHaveValue)(value);\n }\n return true;\n};\nconst shouldValidate = (context) => {\n var _a, _b;\n const { component } = context;\n if (((_a = component.validate) === null || _a === void 0 ? void 0 : _a.required) &&\n !(component.hidden || ((_b = component.ephermalState) === null || _b === void 0 ? void 0 : _b.conditionallyHidden))) {\n return true;\n }\n return false;\n};\nexports.shouldValidate = shouldValidate;\nconst validateRequired = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateRequiredSync)(context);\n});\nexports.validateRequired = validateRequired;\nconst validateRequiredSync = (context) => {\n const error = new error_1.FieldError('required', Object.assign(Object.assign({}, context), { setting: true }));\n const { component, value } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n if (isAddressComponent(component) && isAddressComponentDataObject(value)) {\n return (0, util_1.isEmptyObject)(value.address)\n ? error\n : Object.values(value.address).every((val) => !!val)\n ? null\n : error;\n }\n else if (isDayComponent(component) && value === '00/00/0000') {\n return error;\n }\n else if (isComponentThatCannotHaveFalseValue(component)) {\n return !valueIsPresent(value, false, (0, formUtil_1.isComponentNestedDataType)(component)) ? error : null;\n }\n return !valueIsPresent(value, true, (0, formUtil_1.isComponentNestedDataType)(component)) ? error : null;\n};\nexports.validateRequiredSync = validateRequiredSync;\nexports.validateRequiredInfo = {\n name: 'validateRequired',\n process: exports.validateRequired,\n processSync: exports.validateRequiredSync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateRequired.js?");
|
897
897
|
|
898
898
|
/***/ }),
|
899
899
|
|
@@ -904,7 +904,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
904
904
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
905
905
|
|
906
906
|
"use strict";
|
907
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateRequiredDayInfo = exports.validateRequiredDaySync = exports.validateRequiredDay = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isValidatableDayComponent = (component) => {\n var _a, _b, _c, _d, _e, _f;\n return (component &&\n component.type === 'day' &&\n (((_b = (_a = component.fields) === null || _a === void 0 ? void 0 : _a.day) === null || _b === void 0 ? void 0 : _b.required)
|
907
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateRequiredDayInfo = exports.validateRequiredDaySync = exports.validateRequiredDay = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isValidatableDayComponent = (component) => {\n var _a, _b, _c, _d, _e, _f;\n return (component &&\n component.type === 'day' &&\n (((_b = (_a = component.fields) === null || _a === void 0 ? void 0 : _a.day) === null || _b === void 0 ? void 0 : _b.required) ||\n ((_d = (_c = component.fields) === null || _c === void 0 ? void 0 : _c.month) === null || _d === void 0 ? void 0 : _d.required) ||\n ((_f = (_e = component.fields) === null || _e === void 0 ? void 0 : _e.year) === null || _f === void 0 ? void 0 : _f.required)));\n};\nconst shouldValidate = (context) => {\n const { component } = context;\n return isValidatableDayComponent(component);\n};\nexports.shouldValidate = shouldValidate;\nconst validateRequiredDay = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateRequiredDaySync)(context);\n});\nexports.validateRequiredDay = validateRequiredDay;\nconst validateRequiredDaySync = (context) => {\n var _a, _b, _c, _d, _e, _f;\n const { component, value } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n if (!isValidatableDayComponent(component)) {\n return null;\n }\n if (!value) {\n return new error_1.FieldError('requiredDayEmpty', context, 'day');\n }\n if (typeof value !== 'string') {\n throw new error_1.ProcessorError(`Cannot validate required day field of ${value} because it is not a string`, context, 'validate:validateRequiredDay');\n }\n const [DAY, MONTH, YEAR] = component.dayFirst ? [0, 1, 2] : [1, 0, 2];\n const values = value.split('/').map((x) => parseInt(x, 10)), day = values[DAY], month = values[MONTH], year = values[YEAR];\n if (!day && ((_b = (_a = component.fields) === null || _a === void 0 ? void 0 : _a.day) === null || _b === void 0 ? void 0 : _b.required)) {\n return new error_1.FieldError('requiredDayField', context, 'day');\n }\n if (!month && ((_d = (_c = component.fields) === null || _c === void 0 ? void 0 : _c.month) === null || _d === void 0 ? void 0 : _d.required)) {\n return new error_1.FieldError('requiredMonthField', context, 'day');\n }\n if (!year && ((_f = (_e = component.fields) === null || _e === void 0 ? void 0 : _e.year) === null || _f === void 0 ? void 0 : _f.required)) {\n return new error_1.FieldError('requiredYearField', context, 'day');\n }\n return null;\n};\nexports.validateRequiredDaySync = validateRequiredDaySync;\nexports.validateRequiredDayInfo = {\n name: 'validateRequiredDay',\n process: exports.validateRequiredDay,\n processSync: exports.validateRequiredDaySync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateRequiredDay.js?");
|
908
908
|
|
909
909
|
/***/ }),
|
910
910
|
|
@@ -915,7 +915,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
915
915
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
916
916
|
|
917
917
|
"use strict";
|
918
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateResourceSelectValueInfo = exports.validateResourceSelectValue = exports.shouldValidate = exports.generateUrl = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst util_1 = __webpack_require__(/*! ../util */ \"./node_modules/@formio/core/lib/process/validation/util.js\");\nconst isValidatableSelectComponent = (component) => {\n var _a;\n return (component &&\n component.type === 'select' &&\n (0, util_1.toBoolean)(component.dataSrc === 'resource') &&\n (0, util_1.toBoolean)((_a = component.validate) === null || _a === void 0 ? void 0 : _a.select));\n};\nconst generateUrl = (baseUrl, component, value) => {\n const url = baseUrl;\n const query = url.searchParams;\n if (component.searchField) {\n let searchValue = value;\n if (component.valueProperty) {\n searchValue = value[component.valueProperty];\n }\n else {\n searchValue = value;\n }\n query.set(component.searchField, typeof searchValue === 'string' ? searchValue : JSON.stringify(searchValue));\n }\n if (component.selectFields) {\n query.set('select', component.selectFields);\n }\n if (component.sort) {\n query.set('sort', component.sort);\n }\n if (component.filter) {\n const filterQueryStrings = new URLSearchParams(component.filter);\n filterQueryStrings.forEach((value, key) => query.set(key, value));\n }\n return url;\n};\nexports.generateUrl = generateUrl;\nconst shouldValidate = (context) => {\n var _a;\n const { component, value,
|
918
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateResourceSelectValueInfo = exports.validateResourceSelectValue = exports.shouldValidate = exports.generateUrl = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst util_1 = __webpack_require__(/*! ../util */ \"./node_modules/@formio/core/lib/process/validation/util.js\");\nconst isValidatableSelectComponent = (component) => {\n var _a;\n return (component &&\n component.type === 'select' &&\n (0, util_1.toBoolean)(component.dataSrc === 'resource') &&\n (0, util_1.toBoolean)((_a = component.validate) === null || _a === void 0 ? void 0 : _a.select));\n};\nconst generateUrl = (baseUrl, component, value) => {\n const url = baseUrl;\n const query = url.searchParams;\n if (component.searchField) {\n let searchValue = value;\n if (component.valueProperty) {\n searchValue = value[component.valueProperty];\n }\n else {\n searchValue = value;\n }\n query.set(component.searchField, typeof searchValue === 'string' ? searchValue : JSON.stringify(searchValue));\n }\n if (component.selectFields) {\n query.set('select', component.selectFields);\n }\n if (component.sort) {\n query.set('sort', component.sort);\n }\n if (component.filter) {\n const filterQueryStrings = new URLSearchParams(component.filter);\n filterQueryStrings.forEach((value, key) => query.set(key, value));\n }\n return url;\n};\nexports.generateUrl = generateUrl;\nconst shouldValidate = (context) => {\n var _a;\n const { component, value, config } = context;\n // Only run this validation if server-side\n if (!(config === null || config === void 0 ? void 0 : config.server)) {\n return false;\n }\n if (!isValidatableSelectComponent(component)) {\n return false;\n }\n if (!value ||\n (0, util_1.isEmptyObject)(value) ||\n (Array.isArray(value) && value.length === 0)) {\n return false;\n }\n // If given an invalid configuration, do not validate the remote value\n if (component.dataSrc !== 'resource' || !((_a = component.data) === null || _a === void 0 ? void 0 : _a.resource)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateResourceSelectValue = (context) => __awaiter(void 0, void 0, void 0, function* () {\n var _a;\n const { value, config } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n if (!config || !config.database) {\n throw new error_1.ProcessorError(\"Can't validate for resource value without a database config object\", context, 'validate:validateResourceSelectValue');\n }\n try {\n const resourceSelectValueResult = yield ((_a = config.database) === null || _a === void 0 ? void 0 : _a.validateResourceSelectValue(context, value));\n return resourceSelectValueResult === true ? null : new error_1.FieldError('select', context);\n }\n catch (err) {\n throw new error_1.ProcessorError(err.message || err, context, 'validate:validateResourceSelectValue');\n }\n});\nexports.validateResourceSelectValue = validateResourceSelectValue;\nexports.validateResourceSelectValueInfo = {\n name: 'validateResourceSelectValue',\n process: exports.validateResourceSelectValue,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateResourceSelectValue.js?");
|
919
919
|
|
920
920
|
/***/ }),
|
921
921
|
|
@@ -926,7 +926,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
926
926
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
927
927
|
|
928
928
|
"use strict";
|
929
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateTimeInfo = exports.validateTime = exports.validateTimeSync = exports.shouldValidate = void 0;\nconst formUtil_1 = __webpack_require__(/*! ../../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst date_1 = __webpack_require__(/*! ../../../utils/date */ \"./node_modules/@formio/core/lib/utils/date.js\");\nconst customParseFormat_1 = __importDefault(__webpack_require__(/*! dayjs/plugin/customParseFormat */ \"./node_modules/dayjs/plugin/customParseFormat.js\"));\ndate_1.dayjs.extend(customParseFormat_1.default);\nconst isValidatableTimeComponent = (comp) => {\n return comp && comp.type === 'time';\n};\nconst shouldValidate = (context) => {\n const { component
|
929
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateTimeInfo = exports.validateTime = exports.validateTimeSync = exports.shouldValidate = void 0;\nconst formUtil_1 = __webpack_require__(/*! ../../../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst date_1 = __webpack_require__(/*! ../../../utils/date */ \"./node_modules/@formio/core/lib/utils/date.js\");\nconst customParseFormat_1 = __importDefault(__webpack_require__(/*! dayjs/plugin/customParseFormat */ \"./node_modules/dayjs/plugin/customParseFormat.js\"));\ndate_1.dayjs.extend(customParseFormat_1.default);\nconst isValidatableTimeComponent = (comp) => {\n return comp && comp.type === 'time';\n};\nconst shouldValidate = (context) => {\n const { component } = context;\n if (!isValidatableTimeComponent(component)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateTimeSync = (context) => {\n const { component, data, path, value } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n try {\n if (!value || (0, formUtil_1.isComponentDataEmpty)(component, data, path))\n return null;\n const format = component.dataFormat || 'HH:mm:ss';\n const isValid = (0, date_1.dayjs)(String(value), format, true).isValid();\n return isValid ? null : new error_1.FieldError('time', context);\n }\n catch (ignoreErr) {\n throw new error_1.ProcessorError(`Could not validate time component ${component.key} with value ${value}`, context, 'validate:validateTime');\n }\n};\nexports.validateTimeSync = validateTimeSync;\nconst validateTime = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateTimeSync)(context);\n});\nexports.validateTime = validateTime;\nexports.validateTimeInfo = {\n name: 'validateTime',\n process: exports.validateTime,\n processSync: exports.validateTimeSync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateTime.js?");
|
930
930
|
|
931
931
|
/***/ }),
|
932
932
|
|
@@ -937,7 +937,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
937
937
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
938
938
|
|
939
939
|
"use strict";
|
940
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateUniqueInfo = exports.validateUnique = exports.shouldValidate = void 0;\nconst FieldError_1 = __webpack_require__(/*! ../../../error/FieldError */ \"./node_modules/@formio/core/lib/error/FieldError.js\");\nconst util_1 = __webpack_require__(/*! ../util */ \"./node_modules/@formio/core/lib/process/validation/util.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (!component.unique) {\n return false;\n }\n if (!value || (0, util_1.isEmptyObject)(value)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateUnique = (context) => __awaiter(void 0, void 0, void 0, function* () {\n var _a;\n const { value, config, component } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n if (!config || !config.database) {\n throw new error_1.ProcessorError(\"Can't test for unique value without a database config object\", context, 'validate:validateUnique');\n }\n try {\n const isUnique = yield ((_a = config.database) === null || _a === void 0 ? void 0 : _a.isUnique(context, value));\n if (typeof isUnique === 'string') {\n return new FieldError_1.FieldError('unique', Object.assign(Object.assign({}, context), { component: Object.assign(Object.assign({}, component), { conflictId: isUnique }) }));\n }\n return
|
940
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateUniqueInfo = exports.validateUnique = exports.shouldValidate = void 0;\nconst FieldError_1 = __webpack_require__(/*! ../../../error/FieldError */ \"./node_modules/@formio/core/lib/error/FieldError.js\");\nconst util_1 = __webpack_require__(/*! ../util */ \"./node_modules/@formio/core/lib/process/validation/util.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (!component.unique) {\n return false;\n }\n if (!value || (0, util_1.isEmptyObject)(value)) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateUnique = (context) => __awaiter(void 0, void 0, void 0, function* () {\n var _a;\n const { value, config, component } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n if (!config || !config.database) {\n throw new error_1.ProcessorError(\"Can't test for unique value without a database config object\", context, 'validate:validateUnique');\n }\n try {\n const isUnique = yield ((_a = config.database) === null || _a === void 0 ? void 0 : _a.isUnique(context, value));\n if (typeof isUnique === 'string') {\n return new FieldError_1.FieldError('unique', Object.assign(Object.assign({}, context), { component: Object.assign(Object.assign({}, component), { conflictId: isUnique }) }));\n }\n return isUnique === true ? null : new FieldError_1.FieldError('unique', context);\n }\n catch (err) {\n throw new error_1.ProcessorError(err.message || err, context, 'validate:validateUnique');\n }\n});\nexports.validateUnique = validateUnique;\nexports.validateUniqueInfo = {\n name: 'validateUnique',\n fullValue: true,\n process: exports.validateUnique,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateUnique.js?");
|
941
941
|
|
942
942
|
/***/ }),
|
943
943
|
|
@@ -948,7 +948,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
948
948
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
949
949
|
|
950
950
|
"use strict";
|
951
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateUrlInfo = exports.validateUrl = exports.validateUrlSync = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isUrlComponent = (component) => {\n return component && component.type === 'url';\n};\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (!isUrlComponent(component)) {\n return false;\n }\n if (!value) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateUrlSync = (context) => {\n const { value } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n const error = new error_1.FieldError('invalid_url', context, 'url');\n if (typeof value !== 'string') {\n return error;\n }\n // From https://stackoverflow.com/questions/8667070/javascript-regular-expression-to-validate-url\n const re = /^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))(?::\\d{2,5})?(?:[/?#]\\S*)?$/i;\n // From http://stackoverflow.com/questions/46155/validate-email-address-in-javascript\n const emailRe = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n // Allow urls to be valid if the component is pristine and no value is provided.\n return
|
951
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateUrlInfo = exports.validateUrl = exports.validateUrlSync = exports.shouldValidate = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isUrlComponent = (component) => {\n return component && component.type === 'url';\n};\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (!isUrlComponent(component)) {\n return false;\n }\n if (!value) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateUrlSync = (context) => {\n const { value } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n const error = new error_1.FieldError('invalid_url', context, 'url');\n if (typeof value !== 'string') {\n return error;\n }\n // From https://stackoverflow.com/questions/8667070/javascript-regular-expression-to-validate-url\n const re = /^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))(?::\\d{2,5})?(?:[/?#]\\S*)?$/i;\n // From http://stackoverflow.com/questions/46155/validate-email-address-in-javascript\n const emailRe = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n // Allow urls to be valid if the component is pristine and no value is provided.\n return re.test(value) && !emailRe.test(value) ? null : error;\n};\nexports.validateUrlSync = validateUrlSync;\nconst validateUrl = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateUrlSync)(context);\n});\nexports.validateUrl = validateUrl;\nexports.validateUrlInfo = {\n name: 'validateUrl',\n process: exports.validateUrl,\n processSync: exports.validateUrlSync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateUrl.js?");
|
952
952
|
|
953
953
|
/***/ }),
|
954
954
|
|
@@ -959,7 +959,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
959
959
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
960
960
|
|
961
961
|
"use strict";
|
962
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateUrlSelectValueInfo = exports.validateUrlSelectValue = exports.shouldValidate = exports.generateUrl = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst utils_1 = __webpack_require__(/*! ../../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst util_1 = __webpack_require__(/*! ../util */ \"./node_modules/@formio/core/lib/process/validation/util.js\");\nconst error_2 = __webpack_require__(/*! ../../../utils/error */ \"./node_modules/@formio/core/lib/utils/error.js\");\nconst isValidatableSelectComponent = (component) => {\n var _a;\n return (component &&\n component.type === 'select' &&\n (0, util_1.toBoolean)(component.dataSrc === 'url') &&\n (0, util_1.toBoolean)((_a = component.validate) === null || _a === void 0 ? void 0 : _a.select));\n};\nconst generateUrl = (baseUrl, component, value) => {\n const url = baseUrl;\n const query = url.searchParams;\n if (component.searchField) {\n let searchValue = value;\n if (component.valueProperty) {\n searchValue = value[component.valueProperty];\n }\n else {\n searchValue = value;\n }\n query.set(component.searchField, typeof searchValue === 'string' ? searchValue : JSON.stringify(searchValue));\n }\n if (component.selectFields) {\n query.set('select', component.selectFields);\n }\n if (component.sort) {\n query.set('sort', component.sort);\n }\n if (component.filter) {\n const filterQueryStrings = new URLSearchParams(component.filter);\n filterQueryStrings.forEach((value, key) => query.set(key, value));\n }\n return url;\n};\nexports.generateUrl = generateUrl;\nconst shouldValidate = (context) => {\n var _a;\n const { component, value,
|
962
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateUrlSelectValueInfo = exports.validateUrlSelectValue = exports.shouldValidate = exports.generateUrl = void 0;\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst utils_1 = __webpack_require__(/*! ../../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst util_1 = __webpack_require__(/*! ../util */ \"./node_modules/@formio/core/lib/process/validation/util.js\");\nconst error_2 = __webpack_require__(/*! ../../../utils/error */ \"./node_modules/@formio/core/lib/utils/error.js\");\nconst isValidatableSelectComponent = (component) => {\n var _a;\n return (component &&\n component.type === 'select' &&\n (0, util_1.toBoolean)(component.dataSrc === 'url') &&\n (0, util_1.toBoolean)((_a = component.validate) === null || _a === void 0 ? void 0 : _a.select));\n};\nconst generateUrl = (baseUrl, component, value) => {\n const url = baseUrl;\n const query = url.searchParams;\n if (component.searchField) {\n let searchValue = value;\n if (component.valueProperty) {\n searchValue = value[component.valueProperty];\n }\n else {\n searchValue = value;\n }\n query.set(component.searchField, typeof searchValue === 'string' ? searchValue : JSON.stringify(searchValue));\n }\n if (component.selectFields) {\n query.set('select', component.selectFields);\n }\n if (component.sort) {\n query.set('sort', component.sort);\n }\n if (component.filter) {\n const filterQueryStrings = new URLSearchParams(component.filter);\n filterQueryStrings.forEach((value, key) => query.set(key, value));\n }\n return url;\n};\nexports.generateUrl = generateUrl;\nconst shouldValidate = (context) => {\n var _a;\n const { component, value, config } = context;\n // Only run this validation if server-side\n if (!(config === null || config === void 0 ? void 0 : config.server)) {\n return false;\n }\n if (!isValidatableSelectComponent(component)) {\n return false;\n }\n if (!value ||\n (0, util_1.isEmptyObject)(value) ||\n (Array.isArray(value) && value.length === 0)) {\n return false;\n }\n // If given an invalid configuration, do not validate the remote value\n if (component.dataSrc !== 'url' || !((_a = component.data) === null || _a === void 0 ? void 0 : _a.url) || !component.searchField) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateUrlSelectValue = (context) => __awaiter(void 0, void 0, void 0, function* () {\n const { component, value, data, config } = context;\n let _fetch = null;\n try {\n _fetch = context.fetch ? context.fetch : fetch;\n }\n catch (ignoreErr) {\n _fetch = null;\n }\n try {\n if (!_fetch) {\n console.log('You must provide a fetch interface to the fetch processor.');\n return null;\n }\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n const baseUrl = new URL(utils_1.Evaluator\n ? utils_1.Evaluator.interpolate(component.data.url, data, {})\n : component.data.url);\n const url = (0, exports.generateUrl)(baseUrl, component, value);\n const headers = component.data.headers\n ? component.data.headers.reduce((acc, header) => (Object.assign(Object.assign({}, acc), { [header.key]: header.value })), {})\n : {};\n // Set form.io authentication\n if (component.authenticate && config && config.tokens) {\n Object.assign(headers, config.tokens);\n }\n try {\n const response = yield _fetch(url.toString(), { method: 'GET', headers });\n // TODO: should we always expect JSON here?\n if (response.ok) {\n const data = yield response.json();\n const error = new error_1.FieldError('select', context);\n if (Array.isArray(data)) {\n return data && data.length ? null : error;\n }\n return data ? ((0, util_1.isEmptyObject)(data) ? error : null) : error;\n }\n const data = yield response.text();\n throw new error_1.ProcessorError(`Component with path ${component.key} returned an error while validating remote value: ${data}`, context, 'validate:validateRemoteSelectValue');\n }\n catch (err) {\n throw new error_1.ProcessorError(`Component with path ${component.key} returned an error while validating remote value: ${err}`, context, 'validate:validateRemoteSelectValue');\n }\n }\n catch (err) {\n console.error((0, error_2.getErrorMessage)(err));\n return null;\n }\n});\nexports.validateUrlSelectValue = validateUrlSelectValue;\nexports.validateUrlSelectValueInfo = {\n name: 'validateUrlSelectValue',\n process: exports.validateUrlSelectValue,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateUrlSelectValue.js?");
|
963
963
|
|
964
964
|
/***/ }),
|
965
965
|
|
@@ -970,7 +970,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
970
970
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
971
971
|
|
972
972
|
"use strict";
|
973
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateValuePropertyInfo = exports.validateValuePropertySync = exports.validateValueProperty = exports.shouldValidate = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isValidatableListComponent = (comp) => {\n return (comp &&\n comp.type &&\n (comp.type ===
|
973
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.validateValuePropertyInfo = exports.validateValuePropertySync = exports.validateValueProperty = exports.shouldValidate = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst error_1 = __webpack_require__(/*! ../../../error */ \"./node_modules/@formio/core/lib/error/index.js\");\nconst isValidatableListComponent = (comp) => {\n return (comp &&\n comp.type &&\n (comp.type === 'radio' || comp.type === 'selectboxes' || comp.type === 'select'));\n};\nconst shouldValidate = (context) => {\n const { component, value } = context;\n if (!isValidatableListComponent(component)) {\n return false;\n }\n if (component.dataSrc !== 'url') {\n return false;\n }\n if (!value || (typeof value === 'object' && (0, lodash_1.isEmpty)(value))) {\n return false;\n }\n const valueProperty = component.valueProperty;\n if (!valueProperty) {\n return false;\n }\n return true;\n};\nexports.shouldValidate = shouldValidate;\nconst validateValueProperty = (context) => __awaiter(void 0, void 0, void 0, function* () {\n return (0, exports.validateValuePropertySync)(context);\n});\nexports.validateValueProperty = validateValueProperty;\nconst validateValuePropertySync = (context) => {\n const { component, value } = context;\n if (!(0, exports.shouldValidate)(context)) {\n return null;\n }\n const error = new error_1.FieldError('invalidValueProperty', context);\n // TODO: at some point in the radio component's change pipeline, object values are coerced into strings; testing for\n // '[object Object]' is an ugly way to determine whether or not the ValueProperty is invalid, but it'll have to do\n // for now\n if (component.inputType === 'radio' &&\n ((0, lodash_1.isUndefined)(value) || (0, lodash_1.isObject)(value) || value === '[object Object]')) {\n return error;\n }\n // TODO: a cousin to the above issue, but sometimes ValueProperty will resolve to a boolean value so the keys in\n // e.g. SelectBoxes components will strings coerced from booleans; again, not pretty, but good enough for now\n else if (component.inputType !== 'radio') {\n if (Object.entries(value).some(([key, value]) => value && (key === '[object Object]' || key === 'true' || key === 'false'))) {\n return error;\n }\n }\n return null;\n};\nexports.validateValuePropertySync = validateValuePropertySync;\nexports.validateValuePropertyInfo = {\n name: 'validateValueProperty',\n process: exports.validateValueProperty,\n processSync: exports.validateValuePropertySync,\n shouldProcess: exports.shouldValidate,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/rules/validateValueProperty.js?");
|
974
974
|
|
975
975
|
/***/ }),
|
976
976
|
|
@@ -981,7 +981,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
981
981
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
982
982
|
|
983
983
|
"use strict";
|
984
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.doesArrayDataHaveValue = exports.hasValue = exports.interpolateErrors = exports.isObject = exports.isPromise = exports.toBoolean = exports.getComponentErrorField = exports.isEmptyObject = exports.isComponentProtected = exports.isComponentPersistent = void 0;\nconst utils_1 = __webpack_require__(/*! ../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst i18n_1 = __webpack_require__(/*! ./i18n */ \"./node_modules/@formio/core/lib/process/validation/i18n/index.js\");\nconst isEmpty_1 = __importDefault(__webpack_require__(/*! lodash/isEmpty */ \"./node_modules/lodash/isEmpty.js\"));\nconst isObject_1 = __importDefault(__webpack_require__(/*! lodash/isObject */ \"./node_modules/lodash/isObject.js\"));\nconst isPlainObject_1 = __importDefault(__webpack_require__(/*! lodash/isPlainObject */ \"./node_modules/lodash/isPlainObject.js\"));\nfunction isComponentPersistent(component) {\n return component.persistent ? component.persistent : true;\n}\nexports.isComponentPersistent = isComponentPersistent;\nfunction isComponentProtected(component) {\n return component.protected ? component.protected : false;\n}\nexports.isComponentProtected = isComponentProtected;\nfunction isEmptyObject(obj) {\n return !!obj && Object.keys(obj).length === 0 && obj.constructor === Object;\n}\nexports.isEmptyObject = isEmptyObject;\nfunction getComponentErrorField(component, context) {\n const toInterpolate = component.errorLabel || component.label || component.placeholder || component.key;\n return utils_1.Evaluator.interpolate(toInterpolate, context);\n}\nexports.getComponentErrorField = getComponentErrorField;\nfunction toBoolean(value) {\n switch (typeof value) {\n case 'string':\n if (value === 'true' || value === '1') {\n return true;\n }\n else if (value === 'false' || value === '0') {\n return false;\n }\n else {\n throw `Cannot coerce string ${value} to boolean}`;\n }\n case 'boolean':\n return value;\n default:\n return !!value;\n }\n}\nexports.toBoolean = toBoolean;\nfunction isPromise(value) {\n return (value &&\n value.then &&\n typeof value.then === 'function' &&\n Object.prototype.toString.call(value) === '[object Promise]');\n}\nexports.isPromise = isPromise;\nfunction isObject(obj) {\n return
|
984
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.doesArrayDataHaveValue = exports.hasValue = exports.interpolateErrors = exports.isObject = exports.isPromise = exports.toBoolean = exports.getComponentErrorField = exports.isEmptyObject = exports.isComponentProtected = exports.isComponentPersistent = void 0;\nconst utils_1 = __webpack_require__(/*! ../../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\nconst i18n_1 = __webpack_require__(/*! ./i18n */ \"./node_modules/@formio/core/lib/process/validation/i18n/index.js\");\nconst isEmpty_1 = __importDefault(__webpack_require__(/*! lodash/isEmpty */ \"./node_modules/lodash/isEmpty.js\"));\nconst isObject_1 = __importDefault(__webpack_require__(/*! lodash/isObject */ \"./node_modules/lodash/isObject.js\"));\nconst isPlainObject_1 = __importDefault(__webpack_require__(/*! lodash/isPlainObject */ \"./node_modules/lodash/isPlainObject.js\"));\nfunction isComponentPersistent(component) {\n return component.persistent ? component.persistent : true;\n}\nexports.isComponentPersistent = isComponentPersistent;\nfunction isComponentProtected(component) {\n return component.protected ? component.protected : false;\n}\nexports.isComponentProtected = isComponentProtected;\nfunction isEmptyObject(obj) {\n return !!obj && Object.keys(obj).length === 0 && obj.constructor === Object;\n}\nexports.isEmptyObject = isEmptyObject;\nfunction getComponentErrorField(component, context) {\n const toInterpolate = component.errorLabel || component.label || component.placeholder || component.key;\n return utils_1.Evaluator.interpolate(toInterpolate, context);\n}\nexports.getComponentErrorField = getComponentErrorField;\nfunction toBoolean(value) {\n switch (typeof value) {\n case 'string':\n if (value === 'true' || value === '1') {\n return true;\n }\n else if (value === 'false' || value === '0') {\n return false;\n }\n else {\n throw `Cannot coerce string ${value} to boolean}`;\n }\n case 'boolean':\n return value;\n default:\n return !!value;\n }\n}\nexports.toBoolean = toBoolean;\nfunction isPromise(value) {\n return (value &&\n value.then &&\n typeof value.then === 'function' &&\n Object.prototype.toString.call(value) === '[object Promise]');\n}\nexports.isPromise = isPromise;\nfunction isObject(obj) {\n return obj != null && (typeof obj === 'object' || typeof obj === 'function');\n}\nexports.isObject = isObject;\nconst getCustomErrorMessage = ({ errorKeyOrMessage, context }) => { var _a, _b; return ((_b = (_a = context.component) === null || _a === void 0 ? void 0 : _a.errors) === null || _b === void 0 ? void 0 : _b[errorKeyOrMessage]) || ''; };\n/**\n * Interpolates @formio/core errors so that they are compatible with the renderer\n * @param {FieldError[]} errors\n * @param firstPass\n * @returns {[]}\n */\nconst interpolateErrors = (errors, lang = 'en') => {\n return errors.map((error) => {\n const { errorKeyOrMessage, context } = error;\n const i18n = i18n_1.VALIDATION_ERRORS[lang] || {};\n const toInterpolate = getCustomErrorMessage(error) || i18n[errorKeyOrMessage] || errorKeyOrMessage;\n const paths = [];\n context.path.split('.').forEach((part) => {\n const match = part.match(/\\[([0-9]+)\\]$/);\n if (match) {\n paths.push(part.substring(0, match.index));\n paths.push(parseInt(match[1]));\n }\n else {\n paths.push(part);\n }\n });\n return {\n message: (0, utils_1.unescapeHTML)(utils_1.Evaluator.interpolateString(toInterpolate, context)),\n level: error.level,\n path: paths,\n context: {\n validator: error.ruleName,\n hasLabel: context.hasLabel,\n key: context.component.key,\n label: context.component.label || context.component.placeholder || context.component.key,\n path: context.path,\n value: context.value,\n setting: context.setting,\n index: context.index || 0,\n },\n };\n });\n};\nexports.interpolateErrors = interpolateErrors;\nconst hasValue = (value) => {\n if ((0, isObject_1.default)(value)) {\n return !(0, isEmpty_1.default)(value);\n }\n return (typeof value === 'number' && !Number.isNaN(value)) || !!value;\n};\nexports.hasValue = hasValue;\nconst doesArrayDataHaveValue = (dataValue = []) => {\n if (!Array.isArray(dataValue)) {\n return !!dataValue;\n }\n if (!dataValue.length) {\n return false;\n }\n const isArrayDataComponent = dataValue.every(isPlainObject_1.default);\n if (isArrayDataComponent) {\n return dataValue.some((value) => Object.values(value).some(exports.hasValue));\n }\n return dataValue.some(exports.hasValue);\n};\nexports.doesArrayDataHaveValue = doesArrayDataHaveValue;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/process/validation/util.js?");
|
985
985
|
|
986
986
|
/***/ }),
|
987
987
|
|
@@ -992,7 +992,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
992
992
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
993
993
|
|
994
994
|
"use strict";
|
995
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\n/**\n * The Form.io Plugins allow external systems to \"hook\" into the default behaviors of the JavaScript SDK.\n */\nclass Plugins {\n /**\n * Returns the plugin identity.\n *\n * @param value\n */\n static identity(value) {\n return value;\n }\n /**\n * De-registers a plugin.\n * @param plugin The plugin you wish to deregister.\n */\n static deregisterPlugin(plugin) {\n const beforeLength = Plugins.plugins.length;\n Plugins.plugins = Plugins.plugins.filter((p) => {\n if (p !== plugin && p.__name !== plugin) {\n return true;\n }\n (p.deregister || lodash_1.noop).call(plugin, Plugins.Formio);\n return false;\n });\n return beforeLength !== Plugins.plugins.length;\n }\n /**\n * Registers a new plugin.\n *\n * @param plugin The Plugin object.\n * @param name The name of the plugin you wish to register.\n */\n static registerPlugin(plugin, name) {\n Plugins.plugins.push(plugin);\n Plugins.plugins.sort((a, b) => (b.priority || 0) - (a.priority || 0));\n plugin.__name = name;\n (plugin.init || lodash_1.noop).call(plugin, Plugins.Formio);\n }\n /**\n * Returns a plugin provided the name of the plugin.\n * @param name The name of the plugin you would like to get.\n */\n static getPlugin(name) {\n for (const plugin of Plugins.plugins) {\n if (plugin.__name === name) {\n return plugin;\n }\n }\n return null;\n }\n /**\n * Wait for a plugin function to complete.\n * @param pluginFn - A function within the plugin.\n * @param args\n */\n static pluginWait(pluginFn, ...args) {\n return Promise.all(Plugins.plugins.map((plugin) => (plugin[pluginFn] || lodash_1.noop).call(plugin, ...args)));\n }\n /**\n * Gets a value from a Plugin\n * @param pluginFn\n * @param args\n */\n static pluginGet(pluginFn, ...args) {\n const callPlugin = (index) => {\n const plugin = Plugins.plugins[index];\n if (!plugin) {\n return Promise.resolve(null);\n }\n return Promise.resolve((plugin[pluginFn] || lodash_1.noop).call(plugin, ...args))
|
995
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\n/**\n * The Form.io Plugins allow external systems to \"hook\" into the default behaviors of the JavaScript SDK.\n */\nclass Plugins {\n /**\n * Returns the plugin identity.\n *\n * @param value\n */\n static identity(value) {\n return value;\n }\n /**\n * De-registers a plugin.\n * @param plugin The plugin you wish to deregister.\n */\n static deregisterPlugin(plugin) {\n const beforeLength = Plugins.plugins.length;\n Plugins.plugins = Plugins.plugins.filter((p) => {\n if (p !== plugin && p.__name !== plugin) {\n return true;\n }\n (p.deregister || lodash_1.noop).call(plugin, Plugins.Formio);\n return false;\n });\n return beforeLength !== Plugins.plugins.length;\n }\n /**\n * Registers a new plugin.\n *\n * @param plugin The Plugin object.\n * @param name The name of the plugin you wish to register.\n */\n static registerPlugin(plugin, name) {\n Plugins.plugins.push(plugin);\n Plugins.plugins.sort((a, b) => (b.priority || 0) - (a.priority || 0));\n plugin.__name = name;\n (plugin.init || lodash_1.noop).call(plugin, Plugins.Formio);\n }\n /**\n * Returns a plugin provided the name of the plugin.\n * @param name The name of the plugin you would like to get.\n */\n static getPlugin(name) {\n for (const plugin of Plugins.plugins) {\n if (plugin.__name === name) {\n return plugin;\n }\n }\n return null;\n }\n /**\n * Wait for a plugin function to complete.\n * @param pluginFn - A function within the plugin.\n * @param args\n */\n static pluginWait(pluginFn, ...args) {\n return Promise.all(Plugins.plugins.map((plugin) => (plugin[pluginFn] || lodash_1.noop).call(plugin, ...args)));\n }\n /**\n * Gets a value from a Plugin\n * @param pluginFn\n * @param args\n */\n static pluginGet(pluginFn, ...args) {\n const callPlugin = (index) => {\n const plugin = Plugins.plugins[index];\n if (!plugin) {\n return Promise.resolve(null);\n }\n return Promise.resolve((plugin[pluginFn] || lodash_1.noop).call(plugin, ...args)).then((result) => {\n if (!(0, lodash_1.isNil)(result)) {\n return result;\n }\n return callPlugin(index + 1);\n });\n };\n return callPlugin(0);\n }\n /**\n * Allows a Plugin to alter the behavior of the JavaScript library.\n *\n * @param pluginFn\n * @param value\n * @param args\n */\n static pluginAlter(pluginFn, value, ...args) {\n return Plugins.plugins.reduce((value, plugin) => (plugin[pluginFn] || Plugins.identity)(value, ...args), value);\n }\n}\n/**\n * An array of Form.io Plugins.\n */\nPlugins.plugins = [];\nexports[\"default\"] = Plugins;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/sdk/Plugins.js?");
|
996
996
|
|
997
997
|
/***/ }),
|
998
998
|
|
@@ -1084,6 +1084,17 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n\n\n
|
|
1084
1084
|
|
1085
1085
|
/***/ }),
|
1086
1086
|
|
1087
|
+
/***/ "./node_modules/@formio/core/lib/types/ResourceToDomOptions.js":
|
1088
|
+
/*!*********************************************************************!*\
|
1089
|
+
!*** ./node_modules/@formio/core/lib/types/ResourceToDomOptions.js ***!
|
1090
|
+
\*********************************************************************/
|
1091
|
+
/***/ (function(__unused_webpack_module, exports) {
|
1092
|
+
|
1093
|
+
"use strict";
|
1094
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/types/ResourceToDomOptions.js?");
|
1095
|
+
|
1096
|
+
/***/ }),
|
1097
|
+
|
1087
1098
|
/***/ "./node_modules/@formio/core/lib/types/Role.js":
|
1088
1099
|
/*!*****************************************************!*\
|
1089
1100
|
!*** ./node_modules/@formio/core/lib/types/Role.js ***!
|
@@ -1135,7 +1146,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n\n\n
|
|
1135
1146
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1136
1147
|
|
1137
1148
|
"use strict";
|
1138
|
-
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n__exportStar(__webpack_require__(/*! ./project/Project */ \"./node_modules/@formio/core/lib/types/project/Project.js\"), exports);\n__exportStar(__webpack_require__(/*! ./Form */ \"./node_modules/@formio/core/lib/types/Form.js\"), exports);\n__exportStar(__webpack_require__(/*! ./Submission */ \"./node_modules/@formio/core/lib/types/Submission.js\"), exports);\n__exportStar(__webpack_require__(/*! ./Role */ \"./node_modules/@formio/core/lib/types/Role.js\"), exports);\n__exportStar(__webpack_require__(/*! ./Action */ \"./node_modules/@formio/core/lib/types/Action.js\"), exports);\n__exportStar(__webpack_require__(/*! ./Access */ \"./node_modules/@formio/core/lib/types/Access.js\"), exports);\n__exportStar(__webpack_require__(/*! ./RuleFn */ \"./node_modules/@formio/core/lib/types/RuleFn.js\"), exports);\n__exportStar(__webpack_require__(/*! ./Component */ \"./node_modules/@formio/core/lib/types/Component.js\"), exports);\n__exportStar(__webpack_require__(/*! ./process */ \"./node_modules/@formio/core/lib/types/process/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./DataObject */ \"./node_modules/@formio/core/lib/types/DataObject.js\"), exports);\n__exportStar(__webpack_require__(/*! ./formUtil */ \"./node_modules/@formio/core/lib/types/formUtil.js\"), exports);\n__exportStar(__webpack_require__(/*! ./PassedComponentInstance */ \"./node_modules/@formio/core/lib/types/PassedComponentInstance.js\"), exports);\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/types/index.js?");
|
1149
|
+
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n__exportStar(__webpack_require__(/*! ./project/Project */ \"./node_modules/@formio/core/lib/types/project/Project.js\"), exports);\n__exportStar(__webpack_require__(/*! ./Form */ \"./node_modules/@formio/core/lib/types/Form.js\"), exports);\n__exportStar(__webpack_require__(/*! ./Submission */ \"./node_modules/@formio/core/lib/types/Submission.js\"), exports);\n__exportStar(__webpack_require__(/*! ./Role */ \"./node_modules/@formio/core/lib/types/Role.js\"), exports);\n__exportStar(__webpack_require__(/*! ./Action */ \"./node_modules/@formio/core/lib/types/Action.js\"), exports);\n__exportStar(__webpack_require__(/*! ./Access */ \"./node_modules/@formio/core/lib/types/Access.js\"), exports);\n__exportStar(__webpack_require__(/*! ./RuleFn */ \"./node_modules/@formio/core/lib/types/RuleFn.js\"), exports);\n__exportStar(__webpack_require__(/*! ./Component */ \"./node_modules/@formio/core/lib/types/Component.js\"), exports);\n__exportStar(__webpack_require__(/*! ./process */ \"./node_modules/@formio/core/lib/types/process/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./DataObject */ \"./node_modules/@formio/core/lib/types/DataObject.js\"), exports);\n__exportStar(__webpack_require__(/*! ./formUtil */ \"./node_modules/@formio/core/lib/types/formUtil.js\"), exports);\n__exportStar(__webpack_require__(/*! ./PassedComponentInstance */ \"./node_modules/@formio/core/lib/types/PassedComponentInstance.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ResourceToDomOptions */ \"./node_modules/@formio/core/lib/types/ResourceToDomOptions.js\"), exports);\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/types/index.js?");
|
1139
1150
|
|
1140
1151
|
/***/ }),
|
1141
1152
|
|
@@ -1410,7 +1421,7 @@ eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ?
|
|
1410
1421
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1411
1422
|
|
1412
1423
|
"use strict";
|
1413
|
-
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.processes = void 0;\nconst processes_1 = __webpack_require__(/*! ../../process */ \"./node_modules/@formio/core/lib/process/index.js\");\n__exportStar(__webpack_require__(/*! ./ProcessType */ \"./node_modules/@formio/core/lib/types/process/ProcessType.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorType */ \"./node_modules/@formio/core/lib/types/process/ProcessorType.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorContext */ \"./node_modules/@formio/core/lib/types/process/ProcessorContext.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorFn */ \"./node_modules/@formio/core/lib/types/process/ProcessorFn.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessContext */ \"./node_modules/@formio/core/lib/types/process/ProcessContext.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorContext */ \"./node_modules/@formio/core/lib/types/process/ProcessorContext.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorScope */ \"./node_modules/@formio/core/lib/types/process/ProcessorScope.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorsScope */ \"./node_modules/@formio/core/lib/types/process/ProcessorsScope.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessConfig */ \"./node_modules/@formio/core/lib/types/process/ProcessConfig.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorInfo */ \"./node_modules/@formio/core/lib/types/process/ProcessorInfo.js\"), exports);\n__exportStar(__webpack_require__(/*! ./validation */ \"./node_modules/@formio/core/lib/types/process/validation/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./calculation */ \"./node_modules/@formio/core/lib/types/process/calculation/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./conditions */ \"./node_modules/@formio/core/lib/types/process/conditions/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./defaultValue */ \"./node_modules/@formio/core/lib/types/process/defaultValue/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./fetch */ \"./node_modules/@formio/core/lib/types/process/fetch/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./filter */ \"./node_modules/@formio/core/lib/types/process/filter/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./populate */ \"./node_modules/@formio/core/lib/types/process/populate/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./logic */ \"./node_modules/@formio/core/lib/types/process/logic/index.js\"), exports);\nexports.processes = {\n calculation: processes_1.calculateProcessInfo,\n conditions: processes_1.conditionProcessInfo,\n defaultValue: processes_1.defaultValueProcessInfo,\n fetch: processes_1.fetchProcessInfo,\n filter: processes_1.filterProcessInfo,\n logic: processes_1.logicProcessInfo,\n populate: processes_1.populateProcessInfo,\n validation: processes_1.validateProcessInfo
|
1424
|
+
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.processes = void 0;\nconst processes_1 = __webpack_require__(/*! ../../process */ \"./node_modules/@formio/core/lib/process/index.js\");\n__exportStar(__webpack_require__(/*! ./ProcessType */ \"./node_modules/@formio/core/lib/types/process/ProcessType.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorType */ \"./node_modules/@formio/core/lib/types/process/ProcessorType.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorContext */ \"./node_modules/@formio/core/lib/types/process/ProcessorContext.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorFn */ \"./node_modules/@formio/core/lib/types/process/ProcessorFn.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessContext */ \"./node_modules/@formio/core/lib/types/process/ProcessContext.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorContext */ \"./node_modules/@formio/core/lib/types/process/ProcessorContext.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorScope */ \"./node_modules/@formio/core/lib/types/process/ProcessorScope.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorsScope */ \"./node_modules/@formio/core/lib/types/process/ProcessorsScope.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessConfig */ \"./node_modules/@formio/core/lib/types/process/ProcessConfig.js\"), exports);\n__exportStar(__webpack_require__(/*! ./ProcessorInfo */ \"./node_modules/@formio/core/lib/types/process/ProcessorInfo.js\"), exports);\n__exportStar(__webpack_require__(/*! ./validation */ \"./node_modules/@formio/core/lib/types/process/validation/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./calculation */ \"./node_modules/@formio/core/lib/types/process/calculation/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./conditions */ \"./node_modules/@formio/core/lib/types/process/conditions/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./defaultValue */ \"./node_modules/@formio/core/lib/types/process/defaultValue/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./fetch */ \"./node_modules/@formio/core/lib/types/process/fetch/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./filter */ \"./node_modules/@formio/core/lib/types/process/filter/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./populate */ \"./node_modules/@formio/core/lib/types/process/populate/index.js\"), exports);\n__exportStar(__webpack_require__(/*! ./logic */ \"./node_modules/@formio/core/lib/types/process/logic/index.js\"), exports);\nexports.processes = {\n calculation: processes_1.calculateProcessInfo,\n conditions: processes_1.conditionProcessInfo,\n defaultValue: processes_1.defaultValueProcessInfo,\n fetch: processes_1.fetchProcessInfo,\n filter: processes_1.filterProcessInfo,\n logic: processes_1.logicProcessInfo,\n populate: processes_1.populateProcessInfo,\n validation: processes_1.validateProcessInfo,\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/types/process/index.js?");
|
1414
1425
|
|
1415
1426
|
/***/ }),
|
1416
1427
|
|
@@ -1564,7 +1575,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
1564
1575
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1565
1576
|
|
1566
1577
|
"use strict";
|
1567
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Evaluator = exports.BaseEvaluator = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\n// BaseEvaluator is for extending.\nclass BaseEvaluator {\n static evaluator(func, ...params) {\n if (Evaluator.noeval) {\n console.warn('No evaluations allowed for this renderer.');\n return lodash_1.noop;\n }\n if (typeof func === 'function') {\n return func;\n }\n if (typeof params[0] === 'object') {\n params = (0, lodash_1.keys)(params[0]);\n }\n return new Function(...params, func);\n }\n
|
1578
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Evaluator = exports.BaseEvaluator = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\n// BaseEvaluator is for extending.\nclass BaseEvaluator {\n static evaluator(func, ...params) {\n if (Evaluator.noeval) {\n console.warn('No evaluations allowed for this renderer.');\n return lodash_1.noop;\n }\n if (typeof func === 'function') {\n return func;\n }\n if (typeof params[0] === 'object') {\n params = (0, lodash_1.keys)(params[0]);\n }\n return new Function(...params, func);\n }\n static interpolateString(rawTemplate, data, options = {}) {\n if (!rawTemplate) {\n return '';\n }\n if (typeof rawTemplate !== 'string') {\n return rawTemplate.toString();\n }\n return rawTemplate.replace(/({{\\s*(.*?)\\s*}})/g, (match, $1, $2) => {\n // If this is a function call and we allow evals.\n if ($2.indexOf('(') !== -1 && !(Evaluator.noeval || options.noeval)) {\n return $2.replace(/([^(]+)\\(([^)]+)\\s*\\);?/, (evalMatch, funcName, args) => {\n funcName = (0, lodash_1.trim)(funcName);\n const func = (0, lodash_1.get)(data, funcName);\n if (func) {\n if (args) {\n args = args.split(',').map((arg) => {\n arg = (0, lodash_1.trim)(arg);\n if (arg.indexOf('\"') === 0 || arg.indexOf(\"'\") === 0) {\n return arg.substring(1, arg.length - 1);\n }\n return (0, lodash_1.get)(data, arg);\n });\n }\n return Evaluator.evaluate(func, args, '', false, data, options);\n }\n return '';\n });\n }\n else {\n let dataPath = $2;\n if ($2.indexOf('?') !== -1) {\n dataPath = $2.replace(/\\?\\./g, '.');\n }\n // Allow for conditional values.\n const parts = dataPath.split('||').map((item) => item.trim());\n let value = '';\n let path = '';\n for (let i = 0; i < parts.length; i++) {\n path = parts[i];\n value = (0, lodash_1.get)(data, path);\n if (value) {\n break;\n }\n }\n if (options.data) {\n (0, lodash_1.set)(options.data, path, value);\n }\n return value;\n }\n });\n }\n static interpolate(rawTemplate, data, options = {}) {\n if (typeof rawTemplate === 'function' && !(Evaluator.noeval || options.noeval)) {\n try {\n return rawTemplate(data);\n }\n catch (err) {\n console.warn('Error interpolating template', err, data);\n return err.message;\n }\n }\n return Evaluator.interpolateString(String(rawTemplate), data, options);\n }\n /**\n * Evaluate a method.\n *\n * @param func\n * @param args\n * @return {*}\n */\n static evaluate(func, args = {}, ret = '', interpolate = false, context = {}, options = {}) {\n let returnVal = null;\n options = (0, lodash_1.isObject)(options) ? options : { noeval: options };\n const component = args.component ? args.component : { key: 'unknown' };\n if (!args.form && args.instance) {\n args.form = (0, lodash_1.get)(args.instance, 'root._form', {});\n }\n const componentKey = component.key;\n if (typeof func === 'string') {\n if (ret) {\n func = `var ${ret};${func};return ${ret}`;\n }\n if (interpolate) {\n func = BaseEvaluator.interpolate(func, args, options);\n }\n try {\n if (Evaluator.noeval || options.noeval) {\n func = lodash_1.noop;\n }\n else {\n func = Evaluator.evaluator(func, args, context);\n }\n args = (0, lodash_1.values)(args);\n }\n catch (err) {\n console.warn(`An error occured within the custom function for ${componentKey}`, err);\n returnVal = null;\n func = false;\n }\n }\n if (typeof func === 'function') {\n try {\n returnVal = Evaluator.execute(func, args, context, options);\n }\n catch (err) {\n returnVal = null;\n console.warn(`An error occured within custom function for ${componentKey}`, err);\n }\n }\n else if (func) {\n console.warn(`Unknown function type for ${componentKey}`);\n }\n return returnVal;\n }\n /**\n * Execute a function.\n *\n * @param func\n * @param args\n * @returns\n */\n static execute(func, args, context = {}, options = {}) {\n options = (0, lodash_1.isObject)(options) ? options : { noeval: options };\n if (Evaluator.noeval || options.noeval) {\n console.warn('No evaluations allowed for this renderer.');\n return;\n }\n return Array.isArray(args) ? func.apply(context, args) : func.call(context, args);\n }\n}\nexports.BaseEvaluator = BaseEvaluator;\nBaseEvaluator.templateSettings = {\n interpolate: /{{([\\s\\S]+?)}}/g,\n evaluate: /\\{%([\\s\\S]+?)%\\}/g,\n escape: /\\{\\{\\{([\\s\\S]+?)\\}\\}\\}/g,\n};\nBaseEvaluator.noeval = false;\n// The extendable evaluator\nclass Evaluator extends BaseEvaluator {\n /**\n * Allow external modules the ability to extend the Evaluator.\n * @param evaluator\n */\n static registerEvaluator(evaluator) {\n Object.keys(evaluator).forEach((key) => {\n Evaluator[key] = evaluator[key];\n });\n }\n}\nexports.Evaluator = Evaluator;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/Evaluator.js?");
|
1568
1579
|
|
1569
1580
|
/***/ }),
|
1570
1581
|
|
@@ -1575,7 +1586,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
1575
1586
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1576
1587
|
|
1577
1588
|
"use strict";
|
1578
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.checkSimpleConditional = exports.checkJsonConditional = exports.checkLegacyConditional = exports.checkCustomConditional = exports.conditionallyHidden = exports.isSimpleConditional = exports.isLegacyConditional = exports.isJSONConditional = void 0;\nconst jsonlogic_1 = __webpack_require__(/*! ../modules/jsonlogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/index.js\");\nconst formUtil_1 = __webpack_require__(/*! ./formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst operators_1 = __importDefault(__webpack_require__(/*! ./operators */ \"./node_modules/@formio/core/lib/utils/operators/index.js\"));\nconst isJSONConditional = (conditional) => {\n return conditional && conditional.json && (0, lodash_1.isObject)(conditional.json);\n};\nexports.isJSONConditional = isJSONConditional;\nconst isLegacyConditional = (conditional) => {\n return conditional && conditional.when;\n};\nexports.isLegacyConditional = isLegacyConditional;\nconst isSimpleConditional = (conditional) => {\n return conditional && conditional.conjunction && conditional.conditions;\n};\nexports.isSimpleConditional = isSimpleConditional;\nfunction conditionallyHidden(context) {\n const { scope, path } = context;\n if (scope.conditionals && path) {\n const hidden = (0, lodash_1.find)(scope.conditionals, (conditional) => {\n return conditional.path === path;\n });\n return hidden === null || hidden === void 0 ? void 0 : hidden.conditionallyHidden;\n }\n return false;\n}\nexports.conditionallyHidden = conditionallyHidden;\n/**\n * Check custom javascript conditional.\n *\n * @param component\n * @param custom\n * @param row\n * @param data\n * @returns {*}\n */\nfunction checkCustomConditional(condition, context, variable = 'show') {\n const { evalContext } = context;\n if (!condition) {\n return null;\n }\n const value = (0, jsonlogic_1.evaluate)(context, condition, variable, evalContext);\n if (value === null) {\n return null;\n }\n return value;\n}\nexports.checkCustomConditional = checkCustomConditional;\n/**\n * Checks the legacy conditionals.\n *\n * @param conditional\n * @param context\n * @param checkDefault\n * @returns\n */\nfunction checkLegacyConditional(conditional, context) {\n const { row, data, component } = context;\n if (!conditional || !(0, exports.isLegacyConditional)(conditional) || !conditional.when) {\n return null;\n }\n const value = (0, formUtil_1.getComponentActualValue)(component, conditional.when, data, row);\n const eq = String(conditional.eq);\n const show = String(conditional.show);\n if ((0, lodash_1.isObject)(value) && (0, lodash_1.has)(value, eq)) {\n return String(value[eq]) === show;\n }\n if (Array.isArray(value) && value.map(String).includes(eq)) {\n return show === 'true';\n }\n return (String(value) === eq) === (show === 'true');\n}\nexports.checkLegacyConditional = checkLegacyConditional;\n/**\n * Checks the JSON Conditionals.\n * @param conditional\n * @param context\n * @returns\n */\nfunction checkJsonConditional(conditional, context) {\n const { evalContext } = context;\n if (!conditional || !(0, exports.isJSONConditional)(conditional)) {\n return null;\n }\n const evalContextValue = evalContext ? evalContext(context) : context;\n return jsonlogic_1.JSONLogicEvaluator.evaluate(conditional.json, evalContextValue);\n}\nexports.checkJsonConditional = checkJsonConditional;\n/**\n * Checks if condition can potentially have a value path instead of component path.\n * @param condition\n * @returns {boolean}\n */\nfunction isConditionPotentiallyBasedOnValuePath(condition = {}) {\n let comparedValue;\n try {\n comparedValue = JSON.parse(condition.value);\n }\n catch (
|
1589
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.checkSimpleConditional = exports.checkJsonConditional = exports.checkLegacyConditional = exports.checkCustomConditional = exports.conditionallyHidden = exports.isSimpleConditional = exports.isLegacyConditional = exports.isJSONConditional = void 0;\nconst jsonlogic_1 = __webpack_require__(/*! ../modules/jsonlogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/index.js\");\nconst formUtil_1 = __webpack_require__(/*! ./formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst operators_1 = __importDefault(__webpack_require__(/*! ./operators */ \"./node_modules/@formio/core/lib/utils/operators/index.js\"));\nconst isJSONConditional = (conditional) => {\n return conditional && conditional.json && (0, lodash_1.isObject)(conditional.json);\n};\nexports.isJSONConditional = isJSONConditional;\nconst isLegacyConditional = (conditional) => {\n return conditional && conditional.when;\n};\nexports.isLegacyConditional = isLegacyConditional;\nconst isSimpleConditional = (conditional) => {\n return conditional && conditional.conjunction && conditional.conditions;\n};\nexports.isSimpleConditional = isSimpleConditional;\nfunction conditionallyHidden(context) {\n const { scope, path } = context;\n if (scope.conditionals && path) {\n const hidden = (0, lodash_1.find)(scope.conditionals, (conditional) => {\n return conditional.path === path;\n });\n return hidden === null || hidden === void 0 ? void 0 : hidden.conditionallyHidden;\n }\n return false;\n}\nexports.conditionallyHidden = conditionallyHidden;\n/**\n * Check custom javascript conditional.\n *\n * @param component\n * @param custom\n * @param row\n * @param data\n * @returns {*}\n */\nfunction checkCustomConditional(condition, context, variable = 'show') {\n const { evalContext } = context;\n if (!condition) {\n return null;\n }\n const value = (0, jsonlogic_1.evaluate)(context, condition, variable, evalContext);\n if (value === null) {\n return null;\n }\n return value;\n}\nexports.checkCustomConditional = checkCustomConditional;\n/**\n * Checks the legacy conditionals.\n *\n * @param conditional\n * @param context\n * @param checkDefault\n * @returns\n */\nfunction checkLegacyConditional(conditional, context) {\n const { row, data, component } = context;\n if (!conditional || !(0, exports.isLegacyConditional)(conditional) || !conditional.when) {\n return null;\n }\n const value = (0, formUtil_1.getComponentActualValue)(component, conditional.when, data, row);\n const eq = String(conditional.eq);\n const show = String(conditional.show);\n if ((0, lodash_1.isObject)(value) && (0, lodash_1.has)(value, eq)) {\n return String(value[eq]) === show;\n }\n if (Array.isArray(value) && value.map(String).includes(eq)) {\n return show === 'true';\n }\n return (String(value) === eq) === (show === 'true');\n}\nexports.checkLegacyConditional = checkLegacyConditional;\n/**\n * Checks the JSON Conditionals.\n * @param conditional\n * @param context\n * @returns\n */\nfunction checkJsonConditional(conditional, context) {\n const { evalContext } = context;\n if (!conditional || !(0, exports.isJSONConditional)(conditional)) {\n return null;\n }\n const evalContextValue = evalContext ? evalContext(context) : context;\n return jsonlogic_1.JSONLogicEvaluator.evaluate(conditional.json, evalContextValue);\n}\nexports.checkJsonConditional = checkJsonConditional;\n/**\n * Checks if condition can potentially have a value path instead of component path.\n * @param condition\n * @returns {boolean}\n */\nfunction isConditionPotentiallyBasedOnValuePath(condition = {}) {\n let comparedValue;\n try {\n comparedValue = JSON.parse(condition.value);\n }\n catch (ignoreError) {\n comparedValue = condition.value;\n }\n return ((0, lodash_1.isBoolean)(comparedValue) &&\n (condition.component || '').split('.').length > 1 &&\n condition.operator === 'isEqual');\n}\n/**\n * Checks the simple conditionals.\n * @param conditional\n * @param context\n * @returns\n */\nfunction checkSimpleConditional(conditional, context) {\n const { component, data, row, instance, form } = context;\n if (!conditional || !(0, exports.isSimpleConditional)(conditional)) {\n return null;\n }\n const { conditions = [], conjunction = 'all', show = true } = conditional;\n if (!conditions.length) {\n return null;\n }\n const conditionsResult = (0, lodash_1.filter)((0, lodash_1.map)(conditions, (cond) => {\n let { value: comparedValue, component: conditionComponentPath } = cond;\n const { operator } = cond;\n if (!conditionComponentPath) {\n // Ignore conditions if there is no component path.\n return null;\n }\n const formComponents = (form === null || form === void 0 ? void 0 : form.components) || [];\n let conditionComponent = (0, formUtil_1.getComponent)(formComponents, conditionComponentPath, true);\n // If condition componenet is not found, check if conditionComponentPath is value path.\n // Need to handle condtions like:\n // {\n // \"component\": \"selectBoxes.a\",\n // \"operator\": \"isEqual\",\n // \"value\": \"true\"\n // }\n if (!conditionComponent &&\n isConditionPotentiallyBasedOnValuePath(cond) &&\n formComponents.length) {\n const flattenedComponents = (0, formUtil_1.flattenComponents)(formComponents, true);\n const pathParts = (0, lodash_1.split)(conditionComponentPath, '.');\n const valuePathParts = [];\n while (!conditionComponent && pathParts.length) {\n conditionComponent = flattenedComponents[`${pathParts.join('.')}`];\n if (!conditionComponent) {\n valuePathParts.unshift(pathParts.pop());\n }\n }\n if (conditionComponent &&\n conditionComponent.type === 'selectboxes' &&\n valuePathParts.length) {\n console.warn('Condition based on selectboxes has wrong format. Resave the form in the form builder to fix it.');\n conditionComponentPath = pathParts.join('.');\n comparedValue = valuePathParts.join('.');\n }\n }\n const value = conditionComponent\n ? (0, formUtil_1.getComponentActualValue)(conditionComponent, conditionComponentPath, data, row)\n : null;\n const ConditionOperator = operators_1.default[operator];\n return ConditionOperator\n ? new ConditionOperator().getResult({\n value,\n comparedValue,\n instance,\n component,\n conditionComponent,\n conditionComponentPath,\n data,\n })\n : true;\n }), (res) => res !== null);\n let result = false;\n switch (conjunction) {\n case 'any':\n result = (0, lodash_1.some)(conditionsResult, (res) => !!res);\n break;\n default:\n result = (0, lodash_1.every)(conditionsResult, (res) => !!res);\n }\n return show ? result : !result;\n}\nexports.checkSimpleConditional = checkSimpleConditional;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/conditions.js?");
|
1579
1590
|
|
1580
1591
|
/***/ }),
|
1581
1592
|
|
@@ -1586,7 +1597,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1586
1597
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1587
1598
|
|
1588
1599
|
"use strict";
|
1589
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.dayjs = exports.isPartialDay = exports.getDateValidationFormat = exports.getDateSetting = exports.formatDate = exports.momentDate = exports.convertFormatToMoment = exports.currentTimezone = void 0;\nconst dayjs_1 = __importDefault(__webpack_require__(/*! dayjs */ \"./node_modules/dayjs/dayjs.min.js\"));\nexports.dayjs = dayjs_1.default;\nconst timezone_1 = __importDefault(__webpack_require__(/*! dayjs/plugin/timezone */ \"./node_modules/dayjs/plugin/timezone.js\"));\nconst utc_1 = __importDefault(__webpack_require__(/*! dayjs/plugin/utc */ \"./node_modules/dayjs/plugin/utc.js\"));\nconst customParseFormat_1 = __importDefault(__webpack_require__(/*! dayjs/plugin/customParseFormat */ \"./node_modules/dayjs/plugin/customParseFormat.js\"));\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst Evaluator_1 = __webpack_require__(/*! ./Evaluator */ \"./node_modules/@formio/core/lib/utils/Evaluator.js\");\ndayjs_1.default.extend(utc_1.default);\ndayjs_1.default.extend(timezone_1.default);\ndayjs_1.default.extend(customParseFormat_1.default);\n/**\n * Get the current timezone string.\n *\n * @return {string}\n */\nfunction currentTimezone() {\n return dayjs_1.default.tz.guess();\n}\nexports.currentTimezone = currentTimezone;\n/**\n * Convert the format from the angular-datepicker module to moment format.\n * @param format\n * @return {string}\n */\nfunction convertFormatToMoment(format) {\n return format\n // Year conversion.\n .replace(/y/g, 'Y')\n // Day in month.\n .replace(/d/g, 'D')\n // Day in week.\n .replace(/E/g, 'd')\n // AM/PM marker\n .replace(/a/g, 'A')\n // Unix Timestamp\n .replace(/U/g, 'X');\n}\nexports.convertFormatToMoment = convertFormatToMoment;\n/**\n * Get the moment date object for translating dates with timezones.\n *\n * @param value\n * @param format\n * @param timezone\n * @return {*}\n */\nfunction momentDate(value, format, timezone) {\n const momentDate = (0, dayjs_1.default)(value);\n if (timezone === 'UTC') {\n return dayjs_1.default.utc();\n }\n if (timezone !== currentTimezone() || (format && format.match(/\\s(z$|z\\s)/))) {\n return momentDate.tz(timezone);\n }\n return momentDate;\n}\nexports.momentDate = momentDate;\n/**\n * Format a date provided a value, format, and timezone object.\n *\n * @param value\n * @param format\n * @param timezone\n * @return {string}\n */\nfunction formatDate(value, format, timezone) {\n const momentDate = (0, dayjs_1.default)(value);\n if (timezone === 'UTC') {\n return `${dayjs_1.default.utc().format(convertFormatToMoment(format))} UTC`;\n }\n if (timezone) {\n return momentDate.tz(timezone).format(`${convertFormatToMoment(format)} z`);\n }\n return momentDate.format(convertFormatToMoment(format));\n}\nexports.formatDate = formatDate;\n/**\n * Return a translated date setting.\n *\n * @param date\n * @return {(null|Date)}\n */\nfunction getDateSetting(date) {\n if ((0, lodash_1.isNil)(date) || (0, lodash_1.isNaN)(date) || date === '') {\n return null;\n }\n if (date instanceof Date) {\n return date;\n }\n else if (typeof date.toDate === 'function') {\n return date.isValid() ? date.toDate() : null;\n }\n let dateSetting =
|
1600
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.dayjs = exports.isPartialDay = exports.getDateValidationFormat = exports.getDateSetting = exports.formatDate = exports.momentDate = exports.convertFormatToMoment = exports.currentTimezone = void 0;\nconst dayjs_1 = __importDefault(__webpack_require__(/*! dayjs */ \"./node_modules/dayjs/dayjs.min.js\"));\nexports.dayjs = dayjs_1.default;\nconst timezone_1 = __importDefault(__webpack_require__(/*! dayjs/plugin/timezone */ \"./node_modules/dayjs/plugin/timezone.js\"));\nconst utc_1 = __importDefault(__webpack_require__(/*! dayjs/plugin/utc */ \"./node_modules/dayjs/plugin/utc.js\"));\nconst customParseFormat_1 = __importDefault(__webpack_require__(/*! dayjs/plugin/customParseFormat */ \"./node_modules/dayjs/plugin/customParseFormat.js\"));\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst Evaluator_1 = __webpack_require__(/*! ./Evaluator */ \"./node_modules/@formio/core/lib/utils/Evaluator.js\");\ndayjs_1.default.extend(utc_1.default);\ndayjs_1.default.extend(timezone_1.default);\ndayjs_1.default.extend(customParseFormat_1.default);\n/**\n * Get the current timezone string.\n *\n * @return {string}\n */\nfunction currentTimezone() {\n return dayjs_1.default.tz.guess();\n}\nexports.currentTimezone = currentTimezone;\n/**\n * Convert the format from the angular-datepicker module to moment format.\n * @param format\n * @return {string}\n */\nfunction convertFormatToMoment(format) {\n return (format\n // Year conversion.\n .replace(/y/g, 'Y')\n // Day in month.\n .replace(/d/g, 'D')\n // Day in week.\n .replace(/E/g, 'd')\n // AM/PM marker\n .replace(/a/g, 'A')\n // Unix Timestamp\n .replace(/U/g, 'X'));\n}\nexports.convertFormatToMoment = convertFormatToMoment;\n/**\n * Get the moment date object for translating dates with timezones.\n *\n * @param value\n * @param format\n * @param timezone\n * @return {*}\n */\nfunction momentDate(value, format, timezone) {\n const momentDate = (0, dayjs_1.default)(value);\n if (timezone === 'UTC') {\n return dayjs_1.default.utc();\n }\n if (timezone !== currentTimezone() || (format && format.match(/\\s(z$|z\\s)/))) {\n return momentDate.tz(timezone);\n }\n return momentDate;\n}\nexports.momentDate = momentDate;\n/**\n * Format a date provided a value, format, and timezone object.\n *\n * @param value\n * @param format\n * @param timezone\n * @return {string}\n */\nfunction formatDate(value, format, timezone) {\n const momentDate = (0, dayjs_1.default)(value);\n if (timezone === 'UTC') {\n return `${dayjs_1.default.utc().format(convertFormatToMoment(format))} UTC`;\n }\n if (timezone) {\n return momentDate.tz(timezone).format(`${convertFormatToMoment(format)} z`);\n }\n return momentDate.format(convertFormatToMoment(format));\n}\nexports.formatDate = formatDate;\n/**\n * Return a translated date setting.\n *\n * @param date\n * @return {(null|Date)}\n */\nfunction getDateSetting(date) {\n if ((0, lodash_1.isNil)(date) || (0, lodash_1.isNaN)(date) || date === '') {\n return null;\n }\n if (date instanceof Date) {\n return date;\n }\n else if (typeof date.toDate === 'function') {\n return date.isValid() ? date.toDate() : null;\n }\n let dateSetting = typeof date !== 'string' || date.indexOf('moment(') === -1 ? (0, dayjs_1.default)(date) : null;\n if (dateSetting && dateSetting.isValid()) {\n return dateSetting.toDate();\n }\n dateSetting = null;\n try {\n const value = Evaluator_1.Evaluator.evaluator(`return ${date};`, 'moment')(dayjs_1.default);\n if (typeof value === 'string') {\n dateSetting = (0, dayjs_1.default)(value);\n }\n else if (typeof value.toDate === 'function') {\n dateSetting = (0, dayjs_1.default)(value.toDate().toUTCString());\n }\n else if (value instanceof Date) {\n dateSetting = (0, dayjs_1.default)(value);\n }\n }\n catch (ignoreError) {\n return null;\n }\n if (!dateSetting) {\n return null;\n }\n // Ensure this is a date.\n if (!dateSetting.isValid()) {\n return null;\n }\n return dateSetting.toDate();\n}\nexports.getDateSetting = getDateSetting;\nconst getDateValidationFormat = (component) => {\n return component.dayFirst ? 'DD-MM-YYYY' : 'MM-DD-YYYY';\n};\nexports.getDateValidationFormat = getDateValidationFormat;\nconst isPartialDay = (component, value) => {\n if (!value) {\n return true;\n }\n const [DAY, MONTH, YEAR] = component.dayFirst ? [0, 1, 2] : [1, 0, 2];\n const values = value.split('/');\n return values[DAY] === '00' || values[MONTH] === '00' || values[YEAR] === '0000';\n};\nexports.isPartialDay = isPartialDay;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/date.js?");
|
1590
1601
|
|
1591
1602
|
/***/ }),
|
1592
1603
|
|
@@ -1630,7 +1641,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
1630
1641
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1631
1642
|
|
1632
1643
|
"use strict";
|
1633
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.eachComponent = void 0;\nconst index_1 = __webpack_require__(/*! ./index */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\n/**\n * Iterate through each component within a form.\n *\n * @param {Object} components\n * The components to iterate.\n * @param {Function} fn\n * The iteration function to invoke for each component.\n * @param {Boolean} includeAll\n * Whether or not to include layout components.\n * @param {String} path\n * The current data path of the element. Example: data.user.firstName\n * @param {Object} parent\n * The parent object.\n */\nfunction eachComponent(components, fn, includeAll, path =
|
1644
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.eachComponent = void 0;\nconst index_1 = __webpack_require__(/*! ./index */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\n/**\n * Iterate through each component within a form.\n *\n * @param {Object} components\n * The components to iterate.\n * @param {Function} fn\n * The iteration function to invoke for each component.\n * @param {Boolean} includeAll\n * Whether or not to include layout components.\n * @param {String} path\n * The current data path of the element. Example: data.user.firstName\n * @param {Object} parent\n * The parent object.\n */\nfunction eachComponent(components, fn, includeAll, path = '', parent) {\n if (!components)\n return;\n components.forEach((component) => {\n if (!component) {\n return;\n }\n const info = (0, index_1.componentInfo)(component);\n let noRecurse = false;\n // Keep track of parent references.\n if (parent) {\n // Ensure we don't create infinite JSON structures.\n Object.defineProperty(component, 'parent', {\n enumerable: false,\n writable: true,\n value: JSON.parse(JSON.stringify(parent)),\n });\n Object.defineProperty(component.parent, 'parent', {\n enumerable: false,\n writable: true,\n value: parent.parent,\n });\n Object.defineProperty(component.parent, 'path', {\n enumerable: false,\n writable: true,\n value: parent.path,\n });\n delete component.parent.components;\n delete component.parent.componentMap;\n delete component.parent.columns;\n delete component.parent.rows;\n }\n Object.defineProperty(component, 'path', {\n enumerable: false,\n writable: true,\n value: (0, index_1.componentPath)(component, path),\n });\n if (includeAll || component.tree || !info.layout) {\n noRecurse = !!fn(component, component.path, components, parent);\n }\n if (!noRecurse) {\n if (info.hasColumns) {\n component.columns.forEach((column) => eachComponent(column.components, fn, includeAll, path, parent ? component : null));\n }\n else if (info.hasRows) {\n component.rows.forEach((row) => {\n if (Array.isArray(row)) {\n row.forEach((column) => eachComponent(column.components, fn, includeAll, path, parent ? component : null));\n }\n });\n }\n else if (info.hasComps) {\n eachComponent(component.components, fn, includeAll, (0, index_1.componentFormPath)(component, path, component.path), parent ? component : null);\n }\n }\n });\n}\nexports.eachComponent = eachComponent;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/formUtil/eachComponent.js?");
|
1634
1645
|
|
1635
1646
|
/***/ }),
|
1636
1647
|
|
@@ -1641,7 +1652,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
1641
1652
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1642
1653
|
|
1643
1654
|
"use strict";
|
1644
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.eachComponentAsync = void 0;\nconst index_1 = __webpack_require__(/*! ./index */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\n// Async each component.\nfunction eachComponentAsync(components_1, fn_1) {\n return __awaiter(this, arguments, void 0, function* (components, fn, includeAll = false, path =
|
1655
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.eachComponentAsync = void 0;\nconst index_1 = __webpack_require__(/*! ./index */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\n// Async each component.\nfunction eachComponentAsync(components_1, fn_1) {\n return __awaiter(this, arguments, void 0, function* (components, fn, includeAll = false, path = '', parent) {\n var _a, _b;\n if (!components)\n return;\n for (let i = 0; i < components.length; i++) {\n if (!components[i]) {\n continue;\n }\n const component = components[i];\n const info = (0, index_1.componentInfo)(component);\n // Keep track of parent references.\n if (parent) {\n // Ensure we don't create infinite JSON structures.\n Object.defineProperty(component, 'parent', {\n enumerable: false,\n writable: true,\n value: JSON.parse(JSON.stringify(parent)),\n });\n Object.defineProperty(component.parent, 'parent', {\n enumerable: false,\n writable: true,\n value: parent.parent,\n });\n Object.defineProperty(component.parent, 'path', {\n enumerable: false,\n writable: true,\n value: parent.path,\n });\n delete component.parent.components;\n delete component.parent.componentMap;\n delete component.parent.columns;\n delete component.parent.rows;\n }\n Object.defineProperty(component, 'path', {\n enumerable: false,\n writable: true,\n value: (0, index_1.componentPath)(component, path),\n });\n if (includeAll || component.tree || !info.layout) {\n if (yield fn(component, component.path, components, parent)) {\n continue;\n }\n }\n if (info.hasColumns) {\n for (let j = 0; j < component.columns.length; j++) {\n yield eachComponentAsync((_a = component.columns[j]) === null || _a === void 0 ? void 0 : _a.components, fn, includeAll, path, parent ? component : null);\n }\n }\n else if (info.hasRows) {\n for (let j = 0; j < component.rows.length; j++) {\n const row = component.rows[j];\n if (Array.isArray(row)) {\n for (let k = 0; k < row.length; k++) {\n yield eachComponentAsync((_b = row[k]) === null || _b === void 0 ? void 0 : _b.components, fn, includeAll, path, parent ? component : null);\n }\n }\n }\n }\n else if (info.hasComps) {\n yield eachComponentAsync(component.components, fn, includeAll, (0, index_1.componentFormPath)(component, path, component.path), parent ? component : null);\n }\n }\n });\n}\nexports.eachComponentAsync = eachComponentAsync;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/formUtil/eachComponentAsync.js?");
|
1645
1656
|
|
1646
1657
|
/***/ }),
|
1647
1658
|
|
@@ -1652,7 +1663,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
1652
1663
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1653
1664
|
|
1654
1665
|
"use strict";
|
1655
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.eachComponentData = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst index_1 = __webpack_require__(/*! ./index */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst eachComponent_1 = __webpack_require__(/*! ./eachComponent */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponent.js\");\nconst eachComponentData = (components, data, fn, path =
|
1666
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.eachComponentData = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst index_1 = __webpack_require__(/*! ./index */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst eachComponent_1 = __webpack_require__(/*! ./eachComponent */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponent.js\");\nconst eachComponentData = (components, data, fn, path = '', index, parent, includeAll = false) => {\n if (!components || !data) {\n return;\n }\n return (0, eachComponent_1.eachComponent)(components, (component, compPath, componentComponents, compParent) => {\n const row = (0, index_1.getContextualRowData)(component, compPath, data);\n if (fn(component, data, row, compPath, componentComponents, index, compParent) === true) {\n return true;\n }\n if ((0, index_1.isComponentNestedDataType)(component)) {\n const value = (0, lodash_1.get)(data, compPath, data);\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const nestedComponentPath = (0, index_1.getModelType)(component) === 'nestedDataArray'\n ? `${compPath}[${i}].data`\n : `${compPath}[${i}]`;\n (0, exports.eachComponentData)(component.components, data, fn, nestedComponentPath, i, component, includeAll);\n }\n return true;\n }\n else if ((0, lodash_1.isEmpty)(row) && !includeAll) {\n // Tree components may submit empty objects; since we've already evaluated the parent tree/layout component, we won't worry about constituent elements\n return true;\n }\n if ((0, index_1.getModelType)(component) === 'dataObject') {\n // No need to bother processing all the children data if there is no data for this form or the reference value has not been loaded.\n const nestedFormValue = (0, lodash_1.get)(data, component.path);\n const noReferenceAttached = (nestedFormValue === null || nestedFormValue === void 0 ? void 0 : nestedFormValue._id) && (0, lodash_1.isEmpty)(nestedFormValue.data) && !(0, lodash_1.has)(nestedFormValue, 'form');\n const shouldProcessNestedFormData = (nestedFormValue === null || nestedFormValue === void 0 ? void 0 : nestedFormValue._id)\n ? !noReferenceAttached\n : (0, lodash_1.has)(data, component.path);\n if (shouldProcessNestedFormData) {\n // For nested forms, we need to reset the \"data\" and \"path\" objects for all of the children components, and then re-establish the data when it is done.\n const childPath = (0, index_1.componentDataPath)(component, path, compPath);\n const childData = (0, lodash_1.get)(data, childPath, {});\n (0, exports.eachComponentData)(component.components, childData, fn, '', index, component, includeAll);\n (0, lodash_1.set)(data, childPath, childData);\n }\n }\n else {\n (0, exports.eachComponentData)(component.components, data, fn, (0, index_1.componentDataPath)(component, path, compPath), index, component, includeAll);\n }\n return true;\n }\n else if ((0, index_1.getModelType)(component) === 'none') {\n const info = (0, index_1.componentInfo)(component);\n if (info.hasColumns) {\n const columnsComponent = component;\n columnsComponent.columns.forEach((column) => (0, exports.eachComponentData)(column.components, data, fn, (0, index_1.componentFormPath)(columnsComponent, path, columnsComponent.path), index, component));\n }\n else if (info.hasRows) {\n const rowsComponent = component;\n rowsComponent.rows.forEach((row) => {\n if (Array.isArray(row)) {\n row.forEach((row) => (0, exports.eachComponentData)(row.components, data, fn, (0, index_1.componentFormPath)(rowsComponent, path, rowsComponent.path), index, component));\n }\n });\n }\n else if (info.hasComps) {\n const componentWithChildren = component;\n (0, exports.eachComponentData)(componentWithChildren.components, data, fn, (0, index_1.componentFormPath)(componentWithChildren, path, componentWithChildren.path), index, component);\n }\n return true;\n }\n return false;\n }, true, path, parent);\n};\nexports.eachComponentData = eachComponentData;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/formUtil/eachComponentData.js?");
|
1656
1667
|
|
1657
1668
|
/***/ }),
|
1658
1669
|
|
@@ -1663,7 +1674,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
1663
1674
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1664
1675
|
|
1665
1676
|
"use strict";
|
1666
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.eachComponentDataAsync = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst index_1 = __webpack_require__(/*! ./index */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst eachComponentAsync_1 = __webpack_require__(/*! ./eachComponentAsync */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentAsync.js\");\n// Async each component data.\nconst eachComponentDataAsync = (components_1, data_1, fn_1, ...args_1) => __awaiter(void 0, [components_1, data_1, fn_1, ...args_1], void 0, function* (components, data, fn, path =
|
1677
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.eachComponentDataAsync = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst index_1 = __webpack_require__(/*! ./index */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst eachComponentAsync_1 = __webpack_require__(/*! ./eachComponentAsync */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentAsync.js\");\n// Async each component data.\nconst eachComponentDataAsync = (components_1, data_1, fn_1, ...args_1) => __awaiter(void 0, [components_1, data_1, fn_1, ...args_1], void 0, function* (components, data, fn, path = '', index, parent, includeAll = false) {\n if (!components || !data) {\n return;\n }\n return yield (0, eachComponentAsync_1.eachComponentAsync)(components, (component, compPath, componentComponents, compParent) => __awaiter(void 0, void 0, void 0, function* () {\n const row = (0, index_1.getContextualRowData)(component, compPath, data);\n if ((yield fn(component, data, row, compPath, componentComponents, index, compParent)) === true) {\n return true;\n }\n if ((0, index_1.isComponentNestedDataType)(component)) {\n const value = (0, lodash_1.get)(data, compPath, data);\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const nestedComponentPath = (0, index_1.getModelType)(component) === 'nestedDataArray'\n ? `${compPath}[${i}].data`\n : `${compPath}[${i}]`;\n yield (0, exports.eachComponentDataAsync)(component.components, data, fn, nestedComponentPath, i, component, includeAll);\n }\n return true;\n }\n else if ((0, lodash_1.isEmpty)(row) && !includeAll) {\n // Tree components may submit empty objects; since we've already evaluated the parent tree/layout component, we won't worry about constituent elements\n return true;\n }\n if ((0, index_1.getModelType)(component) === 'dataObject') {\n // No need to bother processing all the children data if there is no data for this form or the reference value has not been loaded.\n const nestedFormValue = (0, lodash_1.get)(data, component.path);\n const noReferenceAttached = (nestedFormValue === null || nestedFormValue === void 0 ? void 0 : nestedFormValue._id) && (0, lodash_1.isEmpty)(nestedFormValue.data) && !(0, lodash_1.has)(nestedFormValue, 'form');\n const shouldProcessNestedFormData = (nestedFormValue === null || nestedFormValue === void 0 ? void 0 : nestedFormValue._id)\n ? !noReferenceAttached\n : (0, lodash_1.has)(data, component.path);\n if (shouldProcessNestedFormData) {\n // For nested forms, we need to reset the \"data\" and \"path\" objects for all of the children components, and then re-establish the data when it is done.\n const childPath = (0, index_1.componentDataPath)(component, path, compPath);\n const childData = (0, lodash_1.get)(data, childPath, null);\n yield (0, exports.eachComponentDataAsync)(component.components, childData, fn, '', index, component, includeAll);\n (0, lodash_1.set)(data, childPath, childData);\n }\n }\n else {\n yield (0, exports.eachComponentDataAsync)(component.components, data, fn, (0, index_1.componentDataPath)(component, path, compPath), index, component, includeAll);\n }\n return true;\n }\n else if ((0, index_1.getModelType)(component) === 'none') {\n const info = (0, index_1.componentInfo)(component);\n if (info.hasColumns) {\n const columnsComponent = component;\n for (const column of columnsComponent.columns) {\n yield (0, exports.eachComponentDataAsync)(column.components, data, fn, path, index, component);\n }\n }\n else if (info.hasRows) {\n const rowsComponent = component;\n for (const rowArray of rowsComponent.rows) {\n if (Array.isArray(rowArray)) {\n for (const row of rowArray) {\n yield (0, exports.eachComponentDataAsync)(row.components, data, fn, path, index, component);\n }\n }\n }\n }\n else if (info.hasComps) {\n const componentWithChildren = component;\n yield (0, exports.eachComponentDataAsync)(componentWithChildren.components, data, fn, (0, index_1.componentFormPath)(componentWithChildren, path, componentWithChildren.path), index, component);\n }\n return true;\n }\n return false;\n }), true, path, parent);\n});\nexports.eachComponentDataAsync = eachComponentDataAsync;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/formUtil/eachComponentDataAsync.js?");
|
1667
1678
|
|
1668
1679
|
/***/ }),
|
1669
1680
|
|
@@ -1674,7 +1685,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
1674
1685
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1675
1686
|
|
1676
1687
|
"use strict";
|
1677
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.eachComponentDataAsync = exports.eachComponentAsync = exports.eachComponentData = exports.eachComponent = exports.compareSelectResourceWithObjectTypeValues = exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.isComponentDataEmpty = exports.getEmptyValue = exports.findComponent = exports.applyFormChanges = exports.generateFormChange = exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.removeComponent = exports.findComponents = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.isLayoutComponent = exports.getComponentActualValue = exports.getComponentData = exports.componentInfo = exports.getContextualRowData = exports.getContextualRowPath = exports.getComponentKey = exports.componentFormPath = exports.componentDataPath = exports.componentPath = exports.isComponentNestedDataType = exports.getComponentPath = exports.getComponentAbsolutePath = exports.getModelType = exports.MODEL_TYPES_OF_KNOWN_COMPONENTS = exports.uniqueName = exports.guid = exports.flattenComponents = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst fast_json_patch_1 = __webpack_require__(/*! fast-json-patch */ \"./node_modules/fast-json-patch/index.mjs\");\nconst Evaluator_1 = __webpack_require__(/*! ../Evaluator */ \"./node_modules/@formio/core/lib/utils/Evaluator.js\");\nconst eachComponent_1 = __webpack_require__(/*! ./eachComponent */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponent.js\");\nObject.defineProperty(exports, \"eachComponent\", ({ enumerable: true, get: function () { return eachComponent_1.eachComponent; } }));\nconst eachComponentData_1 = __webpack_require__(/*! ./eachComponentData */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentData.js\");\nObject.defineProperty(exports, \"eachComponentData\", ({ enumerable: true, get: function () { return eachComponentData_1.eachComponentData; } }));\nconst eachComponentAsync_1 = __webpack_require__(/*! ./eachComponentAsync */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentAsync.js\");\nObject.defineProperty(exports, \"eachComponentAsync\", ({ enumerable: true, get: function () { return eachComponentAsync_1.eachComponentAsync; } }));\nconst eachComponentDataAsync_1 = __webpack_require__(/*! ./eachComponentDataAsync */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentDataAsync.js\");\nObject.defineProperty(exports, \"eachComponentDataAsync\", ({ enumerable: true, get: function () { return eachComponentDataAsync_1.eachComponentDataAsync; } }));\n/**\n * Flatten the form components for data manipulation.\n *\n * @param {Object} components\n * The components to iterate.\n * @param {Boolean} includeAll\n * Whether or not to include layout components.\n *\n * @returns {Object}\n * The flattened components map.\n */\nfunction flattenComponents(components, includeAll = false) {\n const flattened = {};\n (0, eachComponent_1.eachComponent)(components, (component, path) => {\n flattened[path] = component;\n }, includeAll);\n return flattened;\n}\nexports.flattenComponents = flattenComponents;\nfunction guid() {\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === \"x\" ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\nexports.guid = guid;\n/**\n * Make a filename guaranteed to be unique.\n * @param name\n * @param template\n * @param evalContext\n * @returns {string}\n */\nfunction uniqueName(name, template, evalContext) {\n template = template || \"{{fileName}}-{{guid}}\";\n //include guid in template anyway, to prevent overwriting issue if filename matches existing file\n if (!template.includes(\"{{guid}}\")) {\n template = `${template}-{{guid}}`;\n }\n const parts = name.split(\".\");\n let fileName = parts.slice(0, parts.length - 1).join(\".\");\n const extension = parts.length > 1 ? `.${(0, lodash_1.last)(parts)}` : \"\";\n //allow only 100 characters from original name to avoid issues with filename length restrictions\n fileName = fileName.substr(0, 100);\n evalContext = Object.assign(evalContext || {}, {\n fileName,\n guid: guid(),\n });\n //only letters, numbers, dots, dashes, underscores and spaces are allowed. Anything else will be replaced with dash\n const uniqueName = `${Evaluator_1.Evaluator.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\\-_ ]/g, \"-\");\n return uniqueName;\n}\nexports.uniqueName = uniqueName;\n/**\n * Defines model types for known components.\n * For now, these will be the only model types supported by the @formio/core library.\n *\n * nestedArray: for components that store their data as an array and have nested components.\n * nestedDataArray: for components that store their data as an array and have nested components, but keeps the value of nested components inside 'data' property.\n * array: for components that store their data as an array.\n * dataObject: for components that store their data in a nested { data: {} } object.\n * object: for components that store their data in an object.\n * map: for components that store their data in a map.\n * content: for components that do not store data.\n * string: for components that store their data as a string.\n * number: for components that store their data as a number.\n * boolean: for components that store their data as a boolean.\n * none: for components that do not store data and should not be included in the submission.\n * any: for components that can store any type of data.\n *\n */\nexports.MODEL_TYPES_OF_KNOWN_COMPONENTS = {\n nestedArray: [\n 'datagrid',\n 'editgrid',\n 'datatable',\n 'dynamicWizard',\n ],\n nestedDataArray: [\n 'tagpad',\n ],\n dataObject: [\n 'form'\n ],\n object: [\n 'container',\n 'address',\n ],\n map: [\n 'datamap',\n ],\n content: [\n 'htmlelement',\n 'content'\n ],\n string: [\n 'textfield',\n 'password',\n 'email',\n 'url',\n 'phoneNumber',\n 'day',\n 'datetime',\n 'time',\n 'signature',\n ],\n number: [\n 'number',\n 'currency'\n ],\n boolean: [\n 'checkbox',\n 'radio',\n ],\n none: [\n 'table',\n 'well',\n 'columns',\n 'fieldset',\n 'panel',\n 'tabs'\n ],\n any: [\n 'survey',\n 'captcha',\n 'textarea',\n 'selectboxes',\n 'tags',\n 'select',\n 'hidden',\n 'button',\n 'datasource',\n 'sketchpad',\n 'reviewpage',\n 'file',\n ],\n};\nfunction getModelType(component) {\n // If the component JSON asserts a model type, use that.\n if (component.modelType) {\n return component.modelType;\n }\n // Otherwise, check for known component types.\n for (const type of Object.keys(exports.MODEL_TYPES_OF_KNOWN_COMPONENTS)) {\n if (exports.MODEL_TYPES_OF_KNOWN_COMPONENTS[type].includes(component.type)) {\n return type;\n }\n }\n // Otherwise check for components that assert no value.\n if ((component.input === false)) {\n return 'none';\n }\n // Otherwise default to any.\n return 'any';\n}\nexports.getModelType = getModelType;\nfunction getComponentAbsolutePath(component) {\n let paths = [component.path];\n while (component.parent) {\n component = component.parent;\n // We only need to do this for nested forms because they reset the data contexts for the children.\n if (getModelType(component) === 'dataObject') {\n paths[paths.length - 1] = `data.${paths[paths.length - 1]}`;\n paths.push(component.path);\n }\n }\n return paths.reverse().join('.');\n}\nexports.getComponentAbsolutePath = getComponentAbsolutePath;\nfunction getComponentPath(component, path) {\n const key = getComponentKey(component);\n if (!key) {\n return path;\n }\n if (!path) {\n return key;\n }\n if (path.match(new RegExp(`${key}$`))) {\n return path;\n }\n return (getModelType(component) === 'none') ? `${path}.${key}` : path;\n}\nexports.getComponentPath = getComponentPath;\nfunction isComponentNestedDataType(component) {\n return component.tree || getModelType(component) === 'nestedArray' ||\n getModelType(component) === 'nestedDataArray' ||\n getModelType(component) === 'dataObject' ||\n getModelType(component) === 'object' ||\n getModelType(component) === 'map';\n}\nexports.isComponentNestedDataType = isComponentNestedDataType;\nfunction componentPath(component, parentPath) {\n parentPath = component.parentPath || parentPath;\n const key = getComponentKey(component);\n if (!key) {\n // If the component does not have a key, then just always return the parent path.\n return parentPath || '';\n }\n return parentPath ? `${parentPath}.${key}` : key;\n}\nexports.componentPath = componentPath;\nconst componentDataPath = (component, parentPath, path) => {\n parentPath = component.parentPath || parentPath;\n path = path || componentPath(component, parentPath);\n // See if we are a nested component.\n if (component.components && Array.isArray(component.components)) {\n if (getModelType(component) === 'dataObject') {\n return `${path}.data`;\n }\n if (getModelType(component) === 'nestedArray') {\n return `${path}[0]`;\n }\n if (getModelType(component) === 'nestedDataArray') {\n return `${path}[0].data`;\n }\n if (isComponentNestedDataType(component)) {\n return path;\n }\n return parentPath;\n }\n return path;\n};\nexports.componentDataPath = componentDataPath;\nconst componentFormPath = (component, parentPath, path) => {\n parentPath = component.parentPath || parentPath;\n path = path || componentPath(component, parentPath);\n if (getModelType(component) === 'dataObject') {\n return `${path}.data`;\n }\n if (isComponentNestedDataType(component)) {\n return path;\n }\n return parentPath;\n};\nexports.componentFormPath = componentFormPath;\nfunction getComponentKey(component) {\n if (component.type === 'checkbox' &&\n component.inputType === 'radio' &&\n component.name) {\n return component.name;\n }\n return component.key;\n}\nexports.getComponentKey = getComponentKey;\nfunction getContextualRowPath(component, path) {\n return path.replace(new RegExp(`\\.?${getComponentKey(component)}$`), '');\n}\nexports.getContextualRowPath = getContextualRowPath;\nfunction getContextualRowData(component, path, data) {\n const rowPath = getContextualRowPath(component, path);\n return rowPath ? (0, lodash_1.get)(data, rowPath, null) : data;\n}\nexports.getContextualRowData = getContextualRowData;\nfunction componentInfo(component) {\n const hasColumns = component.columns && Array.isArray(component.columns);\n const hasRows = component.rows && Array.isArray(component.rows);\n const hasComps = component.components && Array.isArray(component.components);\n const isContent = getModelType(component) === 'content';\n const isLayout = getModelType(component) === 'none';\n const isInput = !component.hasOwnProperty('input') || !!component.input;\n return {\n hasColumns,\n hasRows,\n hasComps,\n layout: hasColumns || hasRows || (hasComps && !isInput) || isLayout || isContent,\n iterable: hasColumns || hasRows || hasComps || isContent,\n };\n}\nexports.componentInfo = componentInfo;\n// Provided components, data, and a key, this will return the components data.\nfunction getComponentData(components, data, path) {\n const compData = { component: null, data: null };\n (0, eachComponentData_1.eachComponentData)(components, data, (component, data, row, compPath) => {\n if (compPath === path) {\n compData.component = component;\n compData.data = row;\n return true;\n }\n });\n return compData;\n}\nexports.getComponentData = getComponentData;\nfunction getComponentActualValue(component, compPath, data, row) {\n var _a;\n // The compPath here will NOT contain the indexes for DataGrids and EditGrids.\n //\n // a[0].b[2].c[3].d\n //\n // Because of this, we will need to determine our parent component path (not data path),\n // and find the \"row\" based comp path.\n //\n // a[0].b[2].c[3].d => a.b.c.d\n //\n let parentInputComponent = null;\n let parent = component;\n let rowPath = '';\n while (((_a = parent === null || parent === void 0 ? void 0 : parent.parent) === null || _a === void 0 ? void 0 : _a.path) && !parentInputComponent) {\n parent = parent.parent;\n if (parent.input) {\n parentInputComponent = parent;\n }\n }\n if (parentInputComponent) {\n const parentCompPath = parentInputComponent.path.replace(/\\[[0-9]+\\]/g, '');\n rowPath = compPath.replace(parentCompPath, '');\n rowPath = (0, lodash_1.trim)(rowPath, '. ');\n }\n let value = null;\n if (data) {\n value = (0, lodash_1.get)(data, compPath);\n }\n if (rowPath && row && (0, lodash_1.isNil)(value)) {\n value = (0, lodash_1.get)(row, rowPath);\n }\n if ((0, lodash_1.isNil)(value) || ((0, lodash_1.isObject)(value) && (0, lodash_1.isEmpty)(value))) {\n value = '';\n }\n return value;\n}\nexports.getComponentActualValue = getComponentActualValue;\n/**\n * Determine if a component is a layout component or not.\n *\n * @param {Object} component\n * The component to check.\n *\n * @returns {Boolean}\n * Whether or not the component is a layout component.\n */\nfunction isLayoutComponent(component) {\n return Boolean((component.columns && Array.isArray(component.columns)) ||\n (component.rows && Array.isArray(component.rows)) ||\n (component.components && Array.isArray(component.components)));\n}\nexports.isLayoutComponent = isLayoutComponent;\n/**\n * Matches if a component matches the query.\n *\n * @param component\n * @param query\n * @return {boolean}\n */\nfunction matchComponent(component, query) {\n if ((0, lodash_1.isString)(query)) {\n return (component.key === query) || (component.path === query);\n }\n else {\n let matches = false;\n (0, lodash_1.forOwn)(query, (value, key) => {\n matches = ((0, lodash_1.get)(component, key) === value);\n if (!matches) {\n return false;\n }\n });\n return matches;\n }\n}\nexports.matchComponent = matchComponent;\n/**\n * Get a component by its key\n *\n * @param {Object} components - The components to iterate.\n * @param {String|Object} key - The key of the component to get, or a query of the component to search.\n * @param {boolean} includeAll - Whether or not to include layout components.\n * @returns {Component} - The component that matches the given key, or undefined if not found.\n */\nfunction getComponent(components, key, includeAll = false) {\n let result;\n (0, eachComponent_1.eachComponent)(components, (component, path) => {\n if ((path === key) || (component.path === key) || (component.input && (component.key === key))) {\n result = component;\n return true;\n }\n }, includeAll);\n return result;\n}\nexports.getComponent = getComponent;\n/**\n * Finds a component provided a query of properties of that component.\n *\n * @param components\n * @param query\n * @return {*}\n */\nfunction searchComponents(components, query) {\n const results = [];\n (0, eachComponent_1.eachComponent)(components, (component) => {\n if (matchComponent(component, query)) {\n results.push(component);\n }\n }, true);\n return results;\n}\nexports.searchComponents = searchComponents;\n/**\n * Deprecated version of findComponents. Renamed to searchComponents.\n * @param {import('@formio/core').Component[]} components - The components to find components within.\n * @param {object} query - The query to use when searching for the components.\n * @returns {import('@formio/core').Component[]} - The result of the component that is found.\n */\nfunction findComponents(components, query) {\n console.warn('formio.js/utils findComponents is deprecated. Use searchComponents instead.');\n return searchComponents(components, query);\n}\nexports.findComponents = findComponents;\n/**\n * Remove a component by path.\n *\n * @param components\n * @param path\n */\nfunction removeComponent(components, path) {\n // Using _.unset() leave a null value. Use Array splice instead.\n // @ts-ignore\n var index = path.pop();\n if (path.length !== 0) {\n components = (0, lodash_1.get)(components, path);\n }\n components.splice(index, 1);\n}\nexports.removeComponent = removeComponent;\n/**\n * Returns if this component has a conditional statement.\n *\n * @param component - The component JSON schema.\n *\n * @returns {boolean} - TRUE - This component has a conditional, FALSE - No conditional provided.\n */\nfunction hasCondition(component) {\n return Boolean((component.customConditional) ||\n (component.conditional && (component.conditional.when ||\n component.conditional.json ||\n (component.conditional.conjunction && (0, lodash_1.isBoolean)(component.conditional.show) && !(0, lodash_1.isEmpty)(component.conditional.conditions)))));\n}\nexports.hasCondition = hasCondition;\n/**\n * Extension of standard #parseFloat(value) function, that also clears input string.\n *\n * @param {any} value\n * The value to parse.\n *\n * @returns {Number}\n * Parsed value.\n */\nfunction parseFloatExt(value) {\n return parseFloat((0, lodash_1.isString)(value)\n ? value.replace(/[^\\de.+-]/gi, '')\n : value);\n}\nexports.parseFloatExt = parseFloatExt;\n/**\n * Formats provided value in way how Currency component uses it.\n *\n * @param {any} value\n * The value to format.\n *\n * @returns {String}\n * Value formatted for Currency component.\n */\nfunction formatAsCurrency(value) {\n const parsedValue = parseFloatExt(value);\n if (isNaN(parsedValue)) {\n return '';\n }\n const parts = (0, lodash_1.round)(parsedValue, 2)\n .toString()\n .split('.');\n parts[0] = (0, lodash_1.chunk)(Array.from(parts[0]).reverse(), 3)\n .reverse()\n .map((part) => part\n .reverse()\n .join(''))\n .join(',');\n parts[1] = (0, lodash_1.pad)(parts[1], 2, '0');\n return parts.join('.');\n}\nexports.formatAsCurrency = formatAsCurrency;\n/**\n * Escapes RegEx characters in provided String value.\n *\n * @param {String} value\n * String for escaping RegEx characters.\n * @returns {string}\n * String with escaped RegEx characters.\n */\nfunction escapeRegExCharacters(value) {\n return value.replace(/[-[\\]/{}()*+?.\\\\^$|]/g, '\\\\$&');\n}\nexports.escapeRegExCharacters = escapeRegExCharacters;\n/**\n * Get the value for a component key, in the given submission.\n *\n * @param {Object} submission\n * A submission object to search.\n * @param {String} key\n * A for components API key to search for.\n */\nfunction getValue(submission, key) {\n const search = (data) => {\n if ((0, lodash_1.isPlainObject)(data)) {\n if ((0, lodash_1.has)(data, key)) {\n return (0, lodash_1.get)(data, key);\n }\n let value = null;\n (0, lodash_1.forOwn)(data, (prop) => {\n const result = search(prop);\n if (!(0, lodash_1.isNil)(result)) {\n value = result;\n return false;\n }\n });\n return value;\n }\n else {\n return null;\n }\n };\n return search(submission.data);\n}\nexports.getValue = getValue;\n/**\n * Iterate over all components in a form and get string values for translation.\n * @param form\n */\nfunction getStrings(form) {\n const properties = ['label', 'title', 'legend', 'tooltip', 'description', 'placeholder', 'prefix', 'suffix', 'errorLabel', 'content', 'html'];\n const strings = [];\n (0, eachComponent_1.eachComponent)(form.components, (component) => {\n properties.forEach(property => {\n if (component.hasOwnProperty(property) && component[property]) {\n strings.push({\n key: component.key,\n type: component.type,\n property,\n string: component[property]\n });\n }\n });\n if ((!component.dataSrc || component.dataSrc === 'values') && component.hasOwnProperty('values') && Array.isArray(component.values) && component.values.length) {\n component.values.forEach((value, index) => {\n strings.push({\n key: component.key,\n property: `value[${index}].label`,\n string: component.values[index].label\n });\n });\n }\n // Hard coded values from Day component\n if (component.type === 'day') {\n [\n 'day',\n 'month',\n 'year',\n 'Day',\n 'Month',\n 'Year',\n 'january',\n 'february',\n 'march',\n 'april',\n 'may',\n 'june',\n 'july',\n 'august',\n 'september',\n 'october',\n 'november',\n 'december'\n ].forEach(string => {\n strings.push({\n key: component.key,\n property: 'day',\n string,\n });\n });\n if (component.fields.day.placeholder) {\n strings.push({\n key: component.key,\n property: 'fields.day.placeholder',\n string: component.fields.day.placeholder,\n });\n }\n if (component.fields.month.placeholder) {\n strings.push({\n key: component.key,\n property: 'fields.month.placeholder',\n string: component.fields.month.placeholder,\n });\n }\n if (component.fields.year.placeholder) {\n strings.push({\n key: component.key,\n property: 'fields.year.placeholder',\n string: component.fields.year.placeholder,\n });\n }\n }\n if (component.type === 'editgrid') {\n const string = component.addAnother || 'Add Another';\n if (component.addAnother) {\n strings.push({\n key: component.key,\n property: 'addAnother',\n string,\n });\n }\n }\n if (component.type === 'select') {\n [\n 'loading...',\n 'Type to search'\n ].forEach(string => {\n strings.push({\n key: component.key,\n property: 'select',\n string,\n });\n });\n }\n }, true);\n return strings;\n}\nexports.getStrings = getStrings;\n// ?????????????????????????\n// questionable section\nfunction generateFormChange(type, data) {\n let change;\n switch (type) {\n case 'add':\n change = {\n op: 'add',\n key: data.component.key,\n container: data.parent.key, // Parent component\n path: data.path, // Path to container within parent component.\n index: data.index, // Index of component in parent container.\n component: data.component\n };\n break;\n case 'edit':\n change = {\n op: 'edit',\n key: data.originalComponent.key,\n patches: (0, fast_json_patch_1.compare)(data.originalComponent, data.component)\n };\n // Don't save if nothing changed.\n if (!change.patches.length) {\n change = null;\n }\n break;\n case 'remove':\n change = {\n op: 'remove',\n key: data.component.key,\n };\n break;\n }\n return change;\n}\nexports.generateFormChange = generateFormChange;\nfunction applyFormChanges(form, changes) {\n const failed = [];\n changes.forEach(function (change) {\n var found = false;\n switch (change.op) {\n case 'add':\n var newComponent = change.component;\n // Find the container to set the component in.\n findComponent(form.components, change.container, null, function (parent) {\n if (!change.container) {\n parent = form;\n }\n // A move will first run an add so remove any existing components with matching key before inserting.\n findComponent(form.components, change.key, null, function (component, path) {\n // If found, use the existing component. (If someone else edited it, the changes would be here)\n newComponent = component;\n removeComponent(form.components, path);\n });\n found = true;\n var container = (0, lodash_1.get)(parent, change.path);\n container.splice(change.index, 0, newComponent);\n });\n break;\n case 'remove':\n findComponent(form.components, change.key, null, function (component, path) {\n found = true;\n const oldComponent = (0, lodash_1.get)(form.components, path);\n if (oldComponent.key !== component.key) {\n path.pop();\n }\n removeComponent(form.components, path);\n });\n break;\n case 'edit':\n findComponent(form.components, change.key, null, function (component, path) {\n found = true;\n try {\n const oldComponent = (0, lodash_1.get)(form.components, path);\n const newComponent = (0, fast_json_patch_1.applyPatch)(component, change.patches).newDocument;\n if (oldComponent.key !== newComponent.key) {\n path.pop();\n }\n (0, lodash_1.set)(form.components, path, newComponent);\n }\n catch (err) {\n failed.push(change);\n }\n });\n break;\n case 'move':\n break;\n }\n if (!found) {\n failed.push(change);\n }\n });\n return {\n form,\n failed\n };\n}\nexports.applyFormChanges = applyFormChanges;\n/**\n* This function will find a component in a form and return the component AND THE PATH to the component in the form.\n* Path to the component is stored as an array of nested components and their indexes.The Path is being filled recursively\n* when you iterating through the nested structure.\n* If the component is not found the callback won't be called and function won't return anything.\n*\n* @param components\n* @param key\n* @param fn\n* @param path\n* @returns {*}\n*/\nfunction findComponent(components, key, path, fn) {\n if (!components)\n return;\n path = path || [];\n if (!key) {\n return fn(components);\n }\n components.forEach(function (component, index) {\n var newPath = path.slice();\n // Add an index of the component it iterates through in nested structure\n newPath.push(index);\n if (!component)\n return;\n if (component.hasOwnProperty('columns') && Array.isArray(component.columns)) {\n newPath.push('columns');\n component.columns.forEach(function (column, index) {\n var colPath = newPath.slice();\n colPath.push(index);\n colPath.push('components');\n findComponent(column.components, key, colPath, fn);\n });\n }\n if (component.hasOwnProperty('rows') && Array.isArray(component.rows)) {\n newPath.push('rows');\n component.rows.forEach(function (row, index) {\n var rowPath = newPath.slice();\n rowPath.push(index);\n row.forEach(function (column, index) {\n var colPath = rowPath.slice();\n colPath.push(index);\n colPath.push('components');\n findComponent(column.components, key, colPath, fn);\n });\n });\n }\n if (component.hasOwnProperty('components') && Array.isArray(component.components)) {\n newPath.push('components');\n findComponent(component.components, key, newPath, fn);\n }\n if (component.key === key) {\n //Final callback if the component is found\n fn(component, newPath, components);\n }\n });\n}\nexports.findComponent = findComponent;\nconst isCheckboxComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'checkbox';\nconst isDataGridComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'datagrid';\nconst isEditGridComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'editgrid';\nconst isAddressComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'address';\nconst isDataTableComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'datatable';\nconst hasChildComponents = (component) => (component === null || component === void 0 ? void 0 : component.components) != null;\nconst isDateTimeComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'datetime';\nconst isSelectBoxesComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'selectboxes';\nconst isTextAreaComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'textarea';\nconst isTextFieldComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'textfield';\nfunction getEmptyValue(component) {\n switch (component.type) {\n case 'textarea':\n case 'textfield':\n case 'time':\n case 'datetime':\n case 'day':\n return '';\n case 'datagrid':\n case 'editgrid':\n return [];\n default:\n return null;\n }\n}\nexports.getEmptyValue = getEmptyValue;\nconst replaceBlanks = (value) => {\n const nbsp = '<p> </p>';\n const br = '<p><br></p>';\n const brNbsp = '<p><br> </p>';\n const regExp = new RegExp(`^${nbsp}|${nbsp}$|^${br}|${br}$|^${brNbsp}|${brNbsp}$`, 'g');\n return typeof value === 'string' ? value.replace(regExp, '').trim() : value;\n};\nfunction trimBlanks(value) {\n if (!value) {\n return value;\n }\n if (Array.isArray(value)) {\n value = value.map((val) => replaceBlanks(val));\n }\n else {\n value = replaceBlanks(value);\n }\n return value;\n}\nfunction isValueEmpty(component, value) {\n const compValueIsEmptyArray = ((0, lodash_1.isArray)(value) && value.length === 1) ? (0, lodash_1.isEqual)(value[0], getEmptyValue(component)) : false;\n return value == null || value === '' || ((0, lodash_1.isArray)(value) && value.length === 0) || compValueIsEmptyArray;\n}\nfunction isComponentDataEmpty(component, data, path, valueCond) {\n var _a;\n const value = (0, lodash_1.isNil)(valueCond) ? (0, lodash_1.get)(data, path) : valueCond;\n const addressIgnoreProperties = ['mode', 'address'];\n if (isCheckboxComponent(component)) {\n return isValueEmpty(component, value) || value === false;\n }\n else if (isAddressComponent(component)) {\n if (Object.keys(value).length === 0) {\n return true;\n }\n return !Object.values((0, lodash_1.omit)(value, addressIgnoreProperties)).some(Boolean);\n }\n else if (isDataGridComponent(component) || isEditGridComponent(component) || isDataTableComponent(component) || hasChildComponents(component)) {\n if ((_a = component.components) === null || _a === void 0 ? void 0 : _a.length) {\n let childrenEmpty = true;\n // wrap component in an array to let eachComponentData handle introspection to child components (e.g. this will be different\n // for data grids versus nested forms, etc.)\n (0, eachComponentData_1.eachComponentData)([component], data, (thisComponent, data, row, path, components, index) => {\n if (component.key === thisComponent.key)\n return;\n if (!isComponentDataEmpty(thisComponent, data, path)) {\n childrenEmpty = false;\n }\n });\n return isValueEmpty(component, value) || childrenEmpty;\n }\n return isValueEmpty(component, value);\n }\n else if (isDateTimeComponent(component)) {\n return isValueEmpty(component, value) || value.toString() === 'Invalid date';\n }\n else if (isSelectBoxesComponent(component)) {\n let selectBoxEmpty = true;\n for (const key in value) {\n if (value[key]) {\n selectBoxEmpty = false;\n break;\n }\n }\n return isValueEmpty(component, value) || selectBoxEmpty;\n }\n else if (isTextAreaComponent(component)) {\n const isPlain = !component.wysiwyg && !component.editor;\n return isPlain ? typeof value === 'string' ? isValueEmpty(component, value.trim()) : isValueEmpty(component, value) : isValueEmpty(component, trimBlanks(value));\n }\n else if (isTextFieldComponent(component)) {\n if (component.allowMultipleMasks && !!component.inputMasks && !!component.inputMasks.length) {\n return isValueEmpty(component, value) || (component.multiple ? value.length === 0 : (!value.maskName || !value.value));\n }\n return isValueEmpty(component, value === null || value === void 0 ? void 0 : value.toString().trim());\n }\n return isValueEmpty(component, value);\n}\nexports.isComponentDataEmpty = isComponentDataEmpty;\n/**\n * Returns the template keys inside the template code.\n * @param {string} template - The template to get the keys from.\n * @returns {Array<string>} - The keys inside the template.\n */\nfunction getItemTemplateKeys(template) {\n const templateKeys = [];\n if (!template) {\n return templateKeys;\n }\n const keys = template.match(/({{\\s*(.*?)\\s*}})/g);\n if (keys) {\n keys.forEach((key) => {\n const propKey = key.match(/{{\\s*item\\.(.*?)\\s*}}/);\n if (propKey && propKey.length > 1) {\n templateKeys.push(propKey[1]);\n }\n });\n }\n return templateKeys;\n}\nexports.getItemTemplateKeys = getItemTemplateKeys;\n/**\n * Returns if the component is a select resource with an object for its value.\n * @param {Component} comp - The component to check.\n * @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.\n */\nfunction isSelectResourceWithObjectValue(comp = {}) {\n const { reference, dataSrc, valueProperty } = comp;\n return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));\n}\nexports.isSelectResourceWithObjectValue = isSelectResourceWithObjectValue;\n/**\n * Compares real select resource value with expected value in condition.\n * @param {any} value - current value of selectcomponent.\n * @param {any} comparedValue - expocted value of select component.\n * @param {SelectComponent} conditionComponent - select component on which the condtion is based.\n * @returns {boolean} - TRUE if the select component current value is equal to the expected value; FALSE otherwise.\n */\nfunction compareSelectResourceWithObjectTypeValues(value, comparedValue, conditionComponent) {\n if (!value || !(0, lodash_1.isPlainObject)(value)) {\n return false;\n }\n const { template, valueProperty } = conditionComponent;\n if (valueProperty === 'data') {\n value = { data: value };\n comparedValue = { data: comparedValue };\n }\n return (0, lodash_1.every)(getItemTemplateKeys(template) || [], (k) => (0, lodash_1.isEqual)((0, lodash_1.get)(value, k), (0, lodash_1.get)(comparedValue, k)));\n}\nexports.compareSelectResourceWithObjectTypeValues = compareSelectResourceWithObjectTypeValues;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/formUtil/index.js?");
|
1688
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.eachComponentDataAsync = exports.eachComponentAsync = exports.eachComponentData = exports.eachComponent = exports.compareSelectResourceWithObjectTypeValues = exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.isComponentDataEmpty = exports.getEmptyValue = exports.findComponent = exports.applyFormChanges = exports.generateFormChange = exports.getStrings = exports.getValue = exports.escapeRegExCharacters = exports.formatAsCurrency = exports.parseFloatExt = exports.hasCondition = exports.removeComponent = exports.findComponents = exports.searchComponents = exports.getComponent = exports.matchComponent = exports.isLayoutComponent = exports.getComponentActualValue = exports.getComponentData = exports.componentInfo = exports.getContextualRowData = exports.getContextualRowPath = exports.getComponentKey = exports.componentFormPath = exports.componentDataPath = exports.componentPath = exports.isComponentNestedDataType = exports.getComponentPath = exports.getComponentAbsolutePath = exports.getModelType = exports.MODEL_TYPES_OF_KNOWN_COMPONENTS = exports.uniqueName = exports.guid = exports.flattenComponents = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst fast_json_patch_1 = __webpack_require__(/*! fast-json-patch */ \"./node_modules/fast-json-patch/index.mjs\");\nconst Evaluator_1 = __webpack_require__(/*! ../Evaluator */ \"./node_modules/@formio/core/lib/utils/Evaluator.js\");\nconst eachComponent_1 = __webpack_require__(/*! ./eachComponent */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponent.js\");\nObject.defineProperty(exports, \"eachComponent\", ({ enumerable: true, get: function () { return eachComponent_1.eachComponent; } }));\nconst eachComponentData_1 = __webpack_require__(/*! ./eachComponentData */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentData.js\");\nObject.defineProperty(exports, \"eachComponentData\", ({ enumerable: true, get: function () { return eachComponentData_1.eachComponentData; } }));\nconst eachComponentAsync_1 = __webpack_require__(/*! ./eachComponentAsync */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentAsync.js\");\nObject.defineProperty(exports, \"eachComponentAsync\", ({ enumerable: true, get: function () { return eachComponentAsync_1.eachComponentAsync; } }));\nconst eachComponentDataAsync_1 = __webpack_require__(/*! ./eachComponentDataAsync */ \"./node_modules/@formio/core/lib/utils/formUtil/eachComponentDataAsync.js\");\nObject.defineProperty(exports, \"eachComponentDataAsync\", ({ enumerable: true, get: function () { return eachComponentDataAsync_1.eachComponentDataAsync; } }));\n/**\n * Flatten the form components for data manipulation.\n *\n * @param {Object} components\n * The components to iterate.\n * @param {Boolean} includeAll\n * Whether or not to include layout components.\n *\n * @returns {Object}\n * The flattened components map.\n */\nfunction flattenComponents(components, includeAll = false) {\n const flattened = {};\n (0, eachComponent_1.eachComponent)(components, (component, path) => {\n flattened[path] = component;\n }, includeAll);\n return flattened;\n}\nexports.flattenComponents = flattenComponents;\nfunction guid() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\nexports.guid = guid;\n/**\n * Make a filename guaranteed to be unique.\n * @param name\n * @param template\n * @param evalContext\n * @returns {string}\n */\nfunction uniqueName(name, template, evalContext) {\n template = template || '{{fileName}}-{{guid}}';\n //include guid in template anyway, to prevent overwriting issue if filename matches existing file\n if (!template.includes('{{guid}}')) {\n template = `${template}-{{guid}}`;\n }\n const parts = name.split('.');\n let fileName = parts.slice(0, parts.length - 1).join('.');\n const extension = parts.length > 1 ? `.${(0, lodash_1.last)(parts)}` : '';\n //allow only 100 characters from original name to avoid issues with filename length restrictions\n fileName = fileName.substr(0, 100);\n evalContext = Object.assign(evalContext || {}, {\n fileName,\n guid: guid(),\n });\n //only letters, numbers, dots, dashes, underscores and spaces are allowed. Anything else will be replaced with dash\n const uniqueName = `${Evaluator_1.Evaluator.interpolate(template, evalContext)}${extension}`.replace(/[^0-9a-zA-Z.\\-_ ]/g, '-');\n return uniqueName;\n}\nexports.uniqueName = uniqueName;\n/**\n * Defines model types for known components.\n * For now, these will be the only model types supported by the @formio/core library.\n *\n * nestedArray: for components that store their data as an array and have nested components.\n * nestedDataArray: for components that store their data as an array and have nested components, but keeps the value of nested components inside 'data' property.\n * array: for components that store their data as an array.\n * dataObject: for components that store their data in a nested { data: {} } object.\n * object: for components that store their data in an object.\n * map: for components that store their data in a map.\n * content: for components that do not store data.\n * string: for components that store their data as a string.\n * number: for components that store their data as a number.\n * boolean: for components that store their data as a boolean.\n * none: for components that do not store data and should not be included in the submission.\n * any: for components that can store any type of data.\n *\n */\nexports.MODEL_TYPES_OF_KNOWN_COMPONENTS = {\n nestedArray: ['datagrid', 'editgrid', 'datatable', 'dynamicWizard'],\n nestedDataArray: ['tagpad'],\n dataObject: ['form'],\n object: ['container', 'address'],\n map: ['datamap'],\n content: ['htmlelement', 'content'],\n string: [\n 'textfield',\n 'password',\n 'email',\n 'url',\n 'phoneNumber',\n 'day',\n 'datetime',\n 'time',\n 'signature',\n ],\n number: ['number', 'currency'],\n boolean: ['checkbox', 'radio'],\n none: ['table', 'well', 'columns', 'fieldset', 'panel', 'tabs'],\n any: [\n 'survey',\n 'captcha',\n 'textarea',\n 'selectboxes',\n 'tags',\n 'select',\n 'hidden',\n 'button',\n 'datasource',\n 'sketchpad',\n 'reviewpage',\n 'file',\n ],\n};\nfunction getModelType(component) {\n // If the component JSON asserts a model type, use that.\n if (component.modelType) {\n return component.modelType;\n }\n // Otherwise, check for known component types.\n for (const type of Object.keys(exports.MODEL_TYPES_OF_KNOWN_COMPONENTS)) {\n if (exports.MODEL_TYPES_OF_KNOWN_COMPONENTS[type].includes(component.type)) {\n return type;\n }\n }\n // Otherwise check for components that assert no value.\n if (component.input === false) {\n return 'none';\n }\n // Otherwise default to any.\n return 'any';\n}\nexports.getModelType = getModelType;\nfunction getComponentAbsolutePath(component) {\n const paths = [component.path];\n while (component.parent) {\n component = component.parent;\n // We only need to do this for nested forms because they reset the data contexts for the children.\n if (getModelType(component) === 'dataObject') {\n paths[paths.length - 1] = `data.${paths[paths.length - 1]}`;\n paths.push(component.path);\n }\n }\n return paths.reverse().join('.');\n}\nexports.getComponentAbsolutePath = getComponentAbsolutePath;\nfunction getComponentPath(component, path) {\n const key = getComponentKey(component);\n if (!key) {\n return path;\n }\n if (!path) {\n return key;\n }\n if (path.match(new RegExp(`${key}$`))) {\n return path;\n }\n return getModelType(component) === 'none' ? `${path}.${key}` : path;\n}\nexports.getComponentPath = getComponentPath;\nfunction isComponentNestedDataType(component) {\n return (component.tree ||\n getModelType(component) === 'nestedArray' ||\n getModelType(component) === 'nestedDataArray' ||\n getModelType(component) === 'dataObject' ||\n getModelType(component) === 'object' ||\n getModelType(component) === 'map');\n}\nexports.isComponentNestedDataType = isComponentNestedDataType;\nfunction componentPath(component, parentPath) {\n parentPath = component.parentPath || parentPath;\n const key = getComponentKey(component);\n if (!key) {\n // If the component does not have a key, then just always return the parent path.\n return parentPath || '';\n }\n return parentPath ? `${parentPath}.${key}` : key;\n}\nexports.componentPath = componentPath;\nconst componentDataPath = (component, parentPath, path) => {\n parentPath = component.parentPath || parentPath;\n path = path || componentPath(component, parentPath);\n // See if we are a nested component.\n if (component.components && Array.isArray(component.components)) {\n if (getModelType(component) === 'dataObject') {\n return `${path}.data`;\n }\n if (getModelType(component) === 'nestedArray') {\n return `${path}[0]`;\n }\n if (getModelType(component) === 'nestedDataArray') {\n return `${path}[0].data`;\n }\n if (isComponentNestedDataType(component)) {\n return path;\n }\n return parentPath;\n }\n return path;\n};\nexports.componentDataPath = componentDataPath;\nconst componentFormPath = (component, parentPath, path) => {\n parentPath = component.parentPath || parentPath;\n path = path || componentPath(component, parentPath);\n if (getModelType(component) === 'dataObject') {\n return `${path}.data`;\n }\n if (isComponentNestedDataType(component)) {\n return path;\n }\n return parentPath;\n};\nexports.componentFormPath = componentFormPath;\nfunction getComponentKey(component) {\n if (component.type === 'checkbox' &&\n component.inputType === 'radio' &&\n component.name) {\n return component.name;\n }\n return component.key;\n}\nexports.getComponentKey = getComponentKey;\nfunction getContextualRowPath(component, path) {\n return path.replace(new RegExp(`.?${getComponentKey(component)}$`), '');\n}\nexports.getContextualRowPath = getContextualRowPath;\nfunction getContextualRowData(component, path, data) {\n const rowPath = getContextualRowPath(component, path);\n return rowPath ? (0, lodash_1.get)(data, rowPath, null) : data;\n}\nexports.getContextualRowData = getContextualRowData;\nfunction componentInfo(component) {\n const hasColumns = component.columns && Array.isArray(component.columns);\n const hasRows = component.rows && Array.isArray(component.rows);\n const hasComps = component.components && Array.isArray(component.components);\n const isContent = getModelType(component) === 'content';\n const isLayout = getModelType(component) === 'none';\n const isInput = !component.hasOwnProperty('input') || !!component.input;\n return {\n hasColumns,\n hasRows,\n hasComps,\n layout: hasColumns || hasRows || (hasComps && !isInput) || isLayout || isContent,\n iterable: hasColumns || hasRows || hasComps || isContent,\n };\n}\nexports.componentInfo = componentInfo;\n// Provided components, data, and a key, this will return the components data.\nfunction getComponentData(components, data, path) {\n const compData = { component: null, data: null };\n (0, eachComponentData_1.eachComponentData)(components, data, (component, data, row, compPath) => {\n if (compPath === path) {\n compData.component = component;\n compData.data = row;\n return true;\n }\n });\n return compData;\n}\nexports.getComponentData = getComponentData;\nfunction getComponentActualValue(component, compPath, data, row) {\n var _a;\n // The compPath here will NOT contain the indexes for DataGrids and EditGrids.\n //\n // a[0].b[2].c[3].d\n //\n // Because of this, we will need to determine our parent component path (not data path),\n // and find the \"row\" based comp path.\n //\n // a[0].b[2].c[3].d => a.b.c.d\n //\n let parentInputComponent = null;\n let parent = component;\n let rowPath = '';\n while (((_a = parent === null || parent === void 0 ? void 0 : parent.parent) === null || _a === void 0 ? void 0 : _a.path) && !parentInputComponent) {\n parent = parent.parent;\n if (parent.input) {\n parentInputComponent = parent;\n }\n }\n if (parentInputComponent) {\n const parentCompPath = parentInputComponent.path.replace(/\\[[0-9]+\\]/g, '');\n rowPath = compPath.replace(parentCompPath, '');\n rowPath = (0, lodash_1.trim)(rowPath, '. ');\n }\n let value = null;\n if (data) {\n value = (0, lodash_1.get)(data, compPath);\n }\n if (rowPath && row && (0, lodash_1.isNil)(value)) {\n value = (0, lodash_1.get)(row, rowPath);\n }\n if ((0, lodash_1.isNil)(value) || ((0, lodash_1.isObject)(value) && (0, lodash_1.isEmpty)(value))) {\n value = '';\n }\n return value;\n}\nexports.getComponentActualValue = getComponentActualValue;\n/**\n * Determine if a component is a layout component or not.\n *\n * @param {Object} component\n * The component to check.\n *\n * @returns {Boolean}\n * Whether or not the component is a layout component.\n */\nfunction isLayoutComponent(component) {\n return Boolean((component.columns &&\n Array.isArray(component.columns)) ||\n (component.rows && Array.isArray(component.rows)) ||\n (component.components &&\n Array.isArray(component.components)));\n}\nexports.isLayoutComponent = isLayoutComponent;\n/**\n * Matches if a component matches the query.\n *\n * @param component\n * @param query\n * @return {boolean}\n */\nfunction matchComponent(component, query) {\n if ((0, lodash_1.isString)(query)) {\n return component.key === query || component.path === query;\n }\n else {\n let matches = false;\n (0, lodash_1.forOwn)(query, (value, key) => {\n matches = (0, lodash_1.get)(component, key) === value;\n if (!matches) {\n return false;\n }\n });\n return matches;\n }\n}\nexports.matchComponent = matchComponent;\n/**\n * Get a component by its key\n *\n * @param {Object} components - The components to iterate.\n * @param {String|Object} key - The key of the component to get, or a query of the component to search.\n * @param {boolean} includeAll - Whether or not to include layout components.\n * @returns {Component} - The component that matches the given key, or undefined if not found.\n */\nfunction getComponent(components, key, includeAll = false) {\n let result;\n (0, eachComponent_1.eachComponent)(components, (component, path) => {\n if (path === key || component.path === key || (component.input && component.key === key)) {\n result = component;\n return true;\n }\n }, includeAll);\n return result;\n}\nexports.getComponent = getComponent;\n/**\n * Finds a component provided a query of properties of that component.\n *\n * @param components\n * @param query\n * @return {*}\n */\nfunction searchComponents(components, query) {\n const results = [];\n (0, eachComponent_1.eachComponent)(components, (component) => {\n if (matchComponent(component, query)) {\n results.push(component);\n }\n }, true);\n return results;\n}\nexports.searchComponents = searchComponents;\n/**\n * Deprecated version of findComponents. Renamed to searchComponents.\n * @param {import('@formio/core').Component[]} components - The components to find components within.\n * @param {object} query - The query to use when searching for the components.\n * @returns {import('@formio/core').Component[]} - The result of the component that is found.\n */\nfunction findComponents(components, query) {\n console.warn('formio.js/utils findComponents is deprecated. Use searchComponents instead.');\n return searchComponents(components, query);\n}\nexports.findComponents = findComponents;\n/**\n * Remove a component by path.\n *\n * @param components\n * @param path\n */\nfunction removeComponent(components, path) {\n // Using _.unset() leave a null value. Use Array splice instead.\n // @ts-expect-error - no clue why we did this, isn't it a string?\n const index = path.pop();\n if (path.length !== 0) {\n components = (0, lodash_1.get)(components, path);\n }\n components.splice(index, 1);\n}\nexports.removeComponent = removeComponent;\n/**\n * Returns if this component has a conditional statement.\n *\n * @param component - The component JSON schema.\n *\n * @returns {boolean} - TRUE - This component has a conditional, FALSE - No conditional provided.\n */\nfunction hasCondition(component) {\n return Boolean(component.customConditional ||\n (component.conditional &&\n (component.conditional.when ||\n component.conditional.json ||\n (component.conditional.conjunction &&\n (0, lodash_1.isBoolean)(component.conditional.show) &&\n !(0, lodash_1.isEmpty)(component.conditional.conditions)))));\n}\nexports.hasCondition = hasCondition;\n/**\n * Extension of standard #parseFloat(value) function, that also clears input string.\n *\n * @param {any} value\n * The value to parse.\n *\n * @returns {Number}\n * Parsed value.\n */\nfunction parseFloatExt(value) {\n return parseFloat((0, lodash_1.isString)(value) ? value.replace(/[^\\de.+-]/gi, '') : value);\n}\nexports.parseFloatExt = parseFloatExt;\n/**\n * Formats provided value in way how Currency component uses it.\n *\n * @param {any} value\n * The value to format.\n *\n * @returns {String}\n * Value formatted for Currency component.\n */\nfunction formatAsCurrency(value) {\n const parsedValue = parseFloatExt(value);\n if (isNaN(parsedValue)) {\n return '';\n }\n const parts = (0, lodash_1.round)(parsedValue, 2).toString().split('.');\n parts[0] = (0, lodash_1.chunk)(Array.from(parts[0]).reverse(), 3)\n .reverse()\n .map((part) => part.reverse().join(''))\n .join(',');\n parts[1] = (0, lodash_1.pad)(parts[1], 2, '0');\n return parts.join('.');\n}\nexports.formatAsCurrency = formatAsCurrency;\n/**\n * Escapes RegEx characters in provided String value.\n *\n * @param {String} value\n * String for escaping RegEx characters.\n * @returns {string}\n * String with escaped RegEx characters.\n */\nfunction escapeRegExCharacters(value) {\n return value.replace(/[-[\\]/{}()*+?.\\\\^$|]/g, '\\\\$&');\n}\nexports.escapeRegExCharacters = escapeRegExCharacters;\n/**\n * Get the value for a component key, in the given submission.\n *\n * @param {Object} submission\n * A submission object to search.\n * @param {String} key\n * A for components API key to search for.\n */\nfunction getValue(submission, key) {\n const search = (data) => {\n if ((0, lodash_1.isPlainObject)(data)) {\n if ((0, lodash_1.has)(data, key)) {\n return (0, lodash_1.get)(data, key);\n }\n let value = null;\n (0, lodash_1.forOwn)(data, (prop) => {\n const result = search(prop);\n if (!(0, lodash_1.isNil)(result)) {\n value = result;\n return false;\n }\n });\n return value;\n }\n else {\n return null;\n }\n };\n return search(submission.data);\n}\nexports.getValue = getValue;\n/**\n * Iterate over all components in a form and get string values for translation.\n * @param form\n */\nfunction getStrings(form) {\n const properties = [\n 'label',\n 'title',\n 'legend',\n 'tooltip',\n 'description',\n 'placeholder',\n 'prefix',\n 'suffix',\n 'errorLabel',\n 'content',\n 'html',\n ];\n const strings = [];\n (0, eachComponent_1.eachComponent)(form.components, (component) => {\n properties.forEach((property) => {\n if (component.hasOwnProperty(property) && component[property]) {\n strings.push({\n key: component.key,\n type: component.type,\n property,\n string: component[property],\n });\n }\n });\n if ((!component.dataSrc || component.dataSrc === 'values') &&\n component.hasOwnProperty('values') &&\n Array.isArray(component.values) &&\n component.values.length) {\n component.values.forEach((value, index) => {\n strings.push({\n key: component.key,\n property: `value[${index}].label`,\n string: component.values[index].label,\n });\n });\n }\n // Hard coded values from Day component\n if (component.type === 'day') {\n [\n 'day',\n 'month',\n 'year',\n 'Day',\n 'Month',\n 'Year',\n 'january',\n 'february',\n 'march',\n 'april',\n 'may',\n 'june',\n 'july',\n 'august',\n 'september',\n 'october',\n 'november',\n 'december',\n ].forEach((string) => {\n strings.push({\n key: component.key,\n property: 'day',\n string,\n });\n });\n if (component.fields.day.placeholder) {\n strings.push({\n key: component.key,\n property: 'fields.day.placeholder',\n string: component.fields.day.placeholder,\n });\n }\n if (component.fields.month.placeholder) {\n strings.push({\n key: component.key,\n property: 'fields.month.placeholder',\n string: component.fields.month.placeholder,\n });\n }\n if (component.fields.year.placeholder) {\n strings.push({\n key: component.key,\n property: 'fields.year.placeholder',\n string: component.fields.year.placeholder,\n });\n }\n }\n if (component.type === 'editgrid') {\n const string = component.addAnother || 'Add Another';\n if (component.addAnother) {\n strings.push({\n key: component.key,\n property: 'addAnother',\n string,\n });\n }\n }\n if (component.type === 'select') {\n ['loading...', 'Type to search'].forEach((string) => {\n strings.push({\n key: component.key,\n property: 'select',\n string,\n });\n });\n }\n }, true);\n return strings;\n}\nexports.getStrings = getStrings;\n// ?????????????????????????\n// questionable section\nfunction generateFormChange(type, data) {\n let change;\n switch (type) {\n case 'add':\n change = {\n op: 'add',\n key: data.component.key,\n container: data.parent.key, // Parent component\n path: data.path, // Path to container within parent component.\n index: data.index, // Index of component in parent container.\n component: data.component,\n };\n break;\n case 'edit':\n change = {\n op: 'edit',\n key: data.originalComponent.key,\n patches: (0, fast_json_patch_1.compare)(data.originalComponent, data.component),\n };\n // Don't save if nothing changed.\n if (!change.patches.length) {\n change = null;\n }\n break;\n case 'remove':\n change = {\n op: 'remove',\n key: data.component.key,\n };\n break;\n }\n return change;\n}\nexports.generateFormChange = generateFormChange;\nfunction applyFormChanges(form, changes) {\n const failed = [];\n changes.forEach(function (change) {\n let found = false;\n switch (change.op) {\n case 'add': {\n let newComponent = change.component;\n // Find the container to set the component in.\n findComponent(form.components, change.container, null, function (parent) {\n if (!change.container) {\n parent = form;\n }\n // A move will first run an add so remove any existing components with matching key before inserting.\n findComponent(form.components, change.key, null, function (component, path) {\n // If found, use the existing component. (If someone else edited it, the changes would be here)\n newComponent = component;\n removeComponent(form.components, path);\n });\n found = true;\n const container = (0, lodash_1.get)(parent, change.path);\n container.splice(change.index, 0, newComponent);\n });\n break;\n }\n case 'remove':\n findComponent(form.components, change.key, null, function (component, path) {\n found = true;\n const oldComponent = (0, lodash_1.get)(form.components, path);\n if (oldComponent.key !== component.key) {\n path.pop();\n }\n removeComponent(form.components, path);\n });\n break;\n case 'edit':\n findComponent(form.components, change.key, null, function (component, path) {\n found = true;\n try {\n const oldComponent = (0, lodash_1.get)(form.components, path);\n const newComponent = (0, fast_json_patch_1.applyPatch)(component, change.patches).newDocument;\n if (oldComponent.key !== newComponent.key) {\n path.pop();\n }\n (0, lodash_1.set)(form.components, path, newComponent);\n }\n catch (ignoreError) {\n failed.push(change);\n }\n });\n break;\n case 'move':\n break;\n }\n if (!found) {\n failed.push(change);\n }\n });\n return {\n form,\n failed,\n };\n}\nexports.applyFormChanges = applyFormChanges;\n/**\n * This function will find a component in a form and return the component AND THE PATH to the component in the form.\n * Path to the component is stored as an array of nested components and their indexes.The Path is being filled recursively\n * when you iterating through the nested structure.\n * If the component is not found the callback won't be called and function won't return anything.\n *\n * @param components\n * @param key\n * @param fn\n * @param path\n * @returns {*}\n */\nfunction findComponent(components, key, path, fn) {\n if (!components)\n return;\n path = path || [];\n if (!key) {\n return fn(components);\n }\n components.forEach(function (component, index) {\n const newPath = path.slice();\n // Add an index of the component it iterates through in nested structure\n newPath.push(index);\n if (!component)\n return;\n if (component.hasOwnProperty('columns') && Array.isArray(component.columns)) {\n newPath.push('columns');\n component.columns.forEach(function (column, index) {\n const colPath = newPath.slice();\n colPath.push(index);\n colPath.push('components');\n findComponent(column.components, key, colPath, fn);\n });\n }\n if (component.hasOwnProperty('rows') && Array.isArray(component.rows)) {\n newPath.push('rows');\n component.rows.forEach(function (row, index) {\n const rowPath = newPath.slice();\n rowPath.push(index);\n row.forEach(function (column, index) {\n const colPath = rowPath.slice();\n colPath.push(index);\n colPath.push('components');\n findComponent(column.components, key, colPath, fn);\n });\n });\n }\n if (component.hasOwnProperty('components') && Array.isArray(component.components)) {\n newPath.push('components');\n findComponent(component.components, key, newPath, fn);\n }\n if (component.key === key) {\n //Final callback if the component is found\n fn(component, newPath, components);\n }\n });\n}\nexports.findComponent = findComponent;\nconst isCheckboxComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'checkbox';\nconst isDataGridComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'datagrid';\nconst isEditGridComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'editgrid';\nconst isAddressComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'address';\nconst isDataTableComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'datatable';\nconst hasChildComponents = (component) => (component === null || component === void 0 ? void 0 : component.components) != null;\nconst isDateTimeComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'datetime';\nconst isSelectBoxesComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'selectboxes';\nconst isTextAreaComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'textarea';\nconst isTextFieldComponent = (component) => (component === null || component === void 0 ? void 0 : component.type) === 'textfield';\nfunction getEmptyValue(component) {\n switch (component.type) {\n case 'textarea':\n case 'textfield':\n case 'time':\n case 'datetime':\n case 'day':\n return '';\n case 'datagrid':\n case 'editgrid':\n return [];\n default:\n return null;\n }\n}\nexports.getEmptyValue = getEmptyValue;\nconst replaceBlanks = (value) => {\n const nbsp = '<p> </p>';\n const br = '<p><br></p>';\n const brNbsp = '<p><br> </p>';\n const regExp = new RegExp(`^${nbsp}|${nbsp}$|^${br}|${br}$|^${brNbsp}|${brNbsp}$`, 'g');\n return typeof value === 'string' ? value.replace(regExp, '').trim() : value;\n};\nfunction trimBlanks(value) {\n if (!value) {\n return value;\n }\n if (Array.isArray(value)) {\n value = value.map((val) => replaceBlanks(val));\n }\n else {\n value = replaceBlanks(value);\n }\n return value;\n}\nfunction isValueEmpty(component, value) {\n const compValueIsEmptyArray = (0, lodash_1.isArray)(value) && value.length === 1 ? (0, lodash_1.isEqual)(value[0], getEmptyValue(component)) : false;\n return (value == null || value === '' || ((0, lodash_1.isArray)(value) && value.length === 0) || compValueIsEmptyArray);\n}\nfunction isComponentDataEmpty(component, data, path, valueCond) {\n var _a;\n const value = (0, lodash_1.isNil)(valueCond) ? (0, lodash_1.get)(data, path) : valueCond;\n const addressIgnoreProperties = ['mode', 'address'];\n if (isCheckboxComponent(component)) {\n return isValueEmpty(component, value) || value === false;\n }\n else if (isAddressComponent(component)) {\n if (Object.keys(value).length === 0) {\n return true;\n }\n return !Object.values((0, lodash_1.omit)(value, addressIgnoreProperties)).some(Boolean);\n }\n else if (isDataGridComponent(component) ||\n isEditGridComponent(component) ||\n isDataTableComponent(component) ||\n hasChildComponents(component)) {\n if ((_a = component.components) === null || _a === void 0 ? void 0 : _a.length) {\n let childrenEmpty = true;\n // wrap component in an array to let eachComponentData handle introspection to child components (e.g. this will be different\n // for data grids versus nested forms, etc.)\n (0, eachComponentData_1.eachComponentData)([component], data, (thisComponent, data, row, path) => {\n if (component.key === thisComponent.key)\n return;\n if (!isComponentDataEmpty(thisComponent, data, path)) {\n childrenEmpty = false;\n }\n });\n return isValueEmpty(component, value) || childrenEmpty;\n }\n return isValueEmpty(component, value);\n }\n else if (isDateTimeComponent(component)) {\n return isValueEmpty(component, value) || value.toString() === 'Invalid date';\n }\n else if (isSelectBoxesComponent(component)) {\n let selectBoxEmpty = true;\n for (const key in value) {\n if (value[key]) {\n selectBoxEmpty = false;\n break;\n }\n }\n return isValueEmpty(component, value) || selectBoxEmpty;\n }\n else if (isTextAreaComponent(component)) {\n const isPlain = !component.wysiwyg && !component.editor;\n return isPlain\n ? typeof value === 'string'\n ? isValueEmpty(component, value.trim())\n : isValueEmpty(component, value)\n : isValueEmpty(component, trimBlanks(value));\n }\n else if (isTextFieldComponent(component)) {\n if (component.allowMultipleMasks && !!component.inputMasks && !!component.inputMasks.length) {\n return (isValueEmpty(component, value) ||\n (component.multiple ? value.length === 0 : !value.maskName || !value.value));\n }\n return isValueEmpty(component, value === null || value === void 0 ? void 0 : value.toString().trim());\n }\n return isValueEmpty(component, value);\n}\nexports.isComponentDataEmpty = isComponentDataEmpty;\n/**\n * Returns the template keys inside the template code.\n * @param {string} template - The template to get the keys from.\n * @returns {Array<string>} - The keys inside the template.\n */\nfunction getItemTemplateKeys(template) {\n const templateKeys = [];\n if (!template) {\n return templateKeys;\n }\n const keys = template.match(/({{\\s*(.*?)\\s*}})/g);\n if (keys) {\n keys.forEach((key) => {\n const propKey = key.match(/{{\\s*item\\.(.*?)\\s*}}/);\n if (propKey && propKey.length > 1) {\n templateKeys.push(propKey[1]);\n }\n });\n }\n return templateKeys;\n}\nexports.getItemTemplateKeys = getItemTemplateKeys;\n/**\n * Returns if the component is a select resource with an object for its value.\n * @param {Component} comp - The component to check.\n * @returns {boolean} - TRUE if the component is a select resource with an object for its value; FALSE otherwise.\n */\nfunction isSelectResourceWithObjectValue(comp = {}) {\n const { reference, dataSrc, valueProperty } = comp;\n return reference || (dataSrc === 'resource' && (!valueProperty || valueProperty === 'data'));\n}\nexports.isSelectResourceWithObjectValue = isSelectResourceWithObjectValue;\n/**\n * Compares real select resource value with expected value in condition.\n * @param {any} value - current value of selectcomponent.\n * @param {any} comparedValue - expocted value of select component.\n * @param {SelectComponent} conditionComponent - select component on which the condtion is based.\n * @returns {boolean} - TRUE if the select component current value is equal to the expected value; FALSE otherwise.\n */\nfunction compareSelectResourceWithObjectTypeValues(value, comparedValue, conditionComponent) {\n if (!value || !(0, lodash_1.isPlainObject)(value)) {\n return false;\n }\n const { template, valueProperty } = conditionComponent;\n if (valueProperty === 'data') {\n value = { data: value };\n comparedValue = { data: comparedValue };\n }\n return (0, lodash_1.every)(getItemTemplateKeys(template) || [], (k) => (0, lodash_1.isEqual)((0, lodash_1.get)(value, k), (0, lodash_1.get)(comparedValue, k)));\n}\nexports.compareSelectResourceWithObjectTypeValues = compareSelectResourceWithObjectTypeValues;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/formUtil/index.js?");
|
1678
1689
|
|
1679
1690
|
/***/ }),
|
1680
1691
|
|
@@ -1696,7 +1707,7 @@ eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ?
|
|
1696
1707
|
/***/ (function(__unused_webpack_module, exports) {
|
1697
1708
|
|
1698
1709
|
"use strict";
|
1699
|
-
eval("\n// copied from https://github.com/auth0/jwt-decode\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.jwtDecode = void 0;\nfunction b64DecodeUnicode(str) {\n return decodeURIComponent(atob(str).replace(/(.)/g, function (m, p) {\n let code = p.charCodeAt(0).toString(16).toUpperCase();\n if (code.length < 2) {\n code = '0' + code;\n }\n return '%' + code;\n }));\n}\nfunction b64UrlDecode(str) {\n let output = str.replace(/-/g, '+').replace(/_/g, '/');\n switch (output.length % 4) {\n case 0:\n break;\n case 2:\n output += '==';\n break;\n case 3:\n output += '=';\n break;\n default:\n throw new Error('base64 string is not of the correct length');\n }\n try {\n return b64DecodeUnicode(output);\n }\n catch (
|
1710
|
+
eval("\n// copied from https://github.com/auth0/jwt-decode\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.jwtDecode = void 0;\nfunction b64DecodeUnicode(str) {\n return decodeURIComponent(atob(str).replace(/(.)/g, function (m, p) {\n let code = p.charCodeAt(0).toString(16).toUpperCase();\n if (code.length < 2) {\n code = '0' + code;\n }\n return '%' + code;\n }));\n}\nfunction b64UrlDecode(str) {\n let output = str.replace(/-/g, '+').replace(/_/g, '/');\n switch (output.length % 4) {\n case 0:\n break;\n case 2:\n output += '==';\n break;\n case 3:\n output += '=';\n break;\n default:\n throw new Error('base64 string is not of the correct length');\n }\n try {\n return b64DecodeUnicode(output);\n }\n catch (ignoreError) {\n return atob(output);\n }\n}\nfunction jwtDecode(token, options = {}) {\n if (typeof token !== 'string') {\n throw new Error('Invalid token specified: must be a string');\n }\n const pos = options.header === true ? 0 : 1;\n const part = token.split('.')[pos];\n if (typeof part !== 'string') {\n throw new Error('Invalid token specified: missing part #' + (pos + 1));\n }\n let decoded;\n try {\n decoded = b64UrlDecode(part);\n }\n catch (e) {\n throw new Error('Invalid token specified: invalid base64 for part #' + (pos + 1) + ' (' + e.message + ')');\n }\n try {\n return JSON.parse(decoded);\n }\n catch (e) {\n throw new Error('Invalid token specified: invalid json for part #' + (pos + 1) + ' (' + e.message + ')');\n }\n}\nexports.jwtDecode = jwtDecode;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/jwtDecode.js?");
|
1700
1711
|
|
1701
1712
|
/***/ }),
|
1702
1713
|
|
@@ -1707,7 +1718,7 @@ eval("\n// copied from https://github.com/auth0/jwt-decode\nObject.definePropert
|
|
1707
1718
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1708
1719
|
|
1709
1720
|
"use strict";
|
1710
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.applyActions = exports.setCustomAction = exports.setMergeComponentSchema = exports.setValueProperty = exports.setActionProperty = exports.setActionStringProperty = exports.setActionBooleanProperty = exports.checkTrigger = exports.hasLogic = void 0;\nconst conditions_1 = __webpack_require__(/*! ./conditions */ \"./node_modules/@formio/core/lib/utils/conditions.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst jsonlogic_1 = __webpack_require__(/*! ../modules/jsonlogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/index.js\");\nconst utils_1 = __webpack_require__(/*! ./utils */ \"./node_modules/@formio/core/lib/utils/utils.js\");\nconst hasLogic = (context) => {\n const { component } = context;\n const { logic } = component;\n if (!logic || !logic.length) {\n return false;\n }\n return true;\n};\nexports.hasLogic = hasLogic;\nconst checkTrigger = (context, trigger) => {\n let shouldTrigger = false;\n switch (trigger.type) {\n case 'simple':\n if ((0, conditions_1.isLegacyConditional)(trigger.simple)) {\n shouldTrigger = (0, conditions_1.checkLegacyConditional)(trigger.simple, context);\n }\n else {\n shouldTrigger = (0, conditions_1.checkSimpleConditional)(trigger.simple, context);\n }\n break;\n case 'javascript':\n shouldTrigger = (0, conditions_1.checkCustomConditional)(trigger.javascript, context, 'result');\n break;\n case 'json':\n shouldTrigger = (0, conditions_1.checkJsonConditional)(trigger, context);\n break;\n default:\n shouldTrigger = false;\n break;\n }\n if (shouldTrigger === null) {\n return false;\n }\n return shouldTrigger;\n};\nexports.checkTrigger = checkTrigger;\nfunction setActionBooleanProperty(context, action) {\n var _a, _b;\n const { component, scope, path } = context;\n const property = action.property.value;\n const currentValue = (0, lodash_1.get)(component, property, false).toString();\n const newValue = action.state.toString();\n if (currentValue !== newValue) {\n (0, lodash_1.set)(component, property, newValue === 'true');\n // If this is \"logic\" forcing a component to set hidden property, then we will set the \"conditionallyHidden\"\n // flag which will trigger the clearOnHide functionality.\n if (property === 'hidden'
|
1721
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.applyActions = exports.setCustomAction = exports.setMergeComponentSchema = exports.setValueProperty = exports.setActionProperty = exports.setActionStringProperty = exports.setActionBooleanProperty = exports.checkTrigger = exports.hasLogic = void 0;\nconst conditions_1 = __webpack_require__(/*! ./conditions */ \"./node_modules/@formio/core/lib/utils/conditions.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst jsonlogic_1 = __webpack_require__(/*! ../modules/jsonlogic */ \"./node_modules/@formio/core/lib/modules/jsonlogic/index.js\");\nconst utils_1 = __webpack_require__(/*! ./utils */ \"./node_modules/@formio/core/lib/utils/utils.js\");\nconst hasLogic = (context) => {\n const { component } = context;\n const { logic } = component;\n if (!logic || !logic.length) {\n return false;\n }\n return true;\n};\nexports.hasLogic = hasLogic;\nconst checkTrigger = (context, trigger) => {\n let shouldTrigger = false;\n switch (trigger.type) {\n case 'simple':\n if ((0, conditions_1.isLegacyConditional)(trigger.simple)) {\n shouldTrigger = (0, conditions_1.checkLegacyConditional)(trigger.simple, context);\n }\n else {\n shouldTrigger = (0, conditions_1.checkSimpleConditional)(trigger.simple, context);\n }\n break;\n case 'javascript':\n shouldTrigger = (0, conditions_1.checkCustomConditional)(trigger.javascript, context, 'result');\n break;\n case 'json':\n shouldTrigger = (0, conditions_1.checkJsonConditional)(trigger, context);\n break;\n default:\n shouldTrigger = false;\n break;\n }\n if (shouldTrigger === null) {\n return false;\n }\n return shouldTrigger;\n};\nexports.checkTrigger = checkTrigger;\nfunction setActionBooleanProperty(context, action) {\n var _a, _b;\n const { component, scope, path } = context;\n const property = action.property.value;\n const currentValue = (0, lodash_1.get)(component, property, false).toString();\n const newValue = action.state.toString();\n if (currentValue !== newValue) {\n (0, lodash_1.set)(component, property, newValue === 'true');\n // If this is \"logic\" forcing a component to set hidden property, then we will set the \"conditionallyHidden\"\n // flag which will trigger the clearOnHide functionality.\n if (property === 'hidden' && path) {\n if (!scope.conditionals) {\n scope.conditionals = [];\n }\n const conditionallyHidden = (_a = scope.conditionals) === null || _a === void 0 ? void 0 : _a.find((cond) => {\n return cond.path === path;\n });\n if (conditionallyHidden) {\n conditionallyHidden.conditionallyHidden = !!component.hidden;\n (0, utils_1.registerEphermalState)(component, 'conditionallyHidden', !!component.hidden);\n }\n else {\n (_b = scope.conditionals) === null || _b === void 0 ? void 0 : _b.push({\n path,\n conditionallyHidden: !!component.hidden,\n });\n }\n }\n return true;\n }\n return false;\n}\nexports.setActionBooleanProperty = setActionBooleanProperty;\nfunction setActionStringProperty(context, action) {\n const { component } = context;\n const property = action.property.value;\n const textValue = action.property.component\n ? action[action.property.component]\n : action.text;\n const currentValue = (0, lodash_1.get)(component, property, '');\n const newValue = (0, jsonlogic_1.interpolate)(Object.assign(Object.assign({}, context), { value: '' }), textValue, (evalContext) => {\n evalContext.value = currentValue;\n });\n if (newValue !== currentValue) {\n (0, lodash_1.set)(component, property, newValue);\n return true;\n }\n return false;\n}\nexports.setActionStringProperty = setActionStringProperty;\nfunction setActionProperty(context, action) {\n switch (action.property.type) {\n case 'boolean':\n return setActionBooleanProperty(context, action);\n case 'string':\n return setActionStringProperty(context, action);\n }\n return false;\n}\nexports.setActionProperty = setActionProperty;\nfunction setValueProperty(context, action) {\n const { component, data, path } = context;\n const oldValue = (0, lodash_1.get)(data, path);\n const newValue = (0, jsonlogic_1.evaluate)(context, action.value, 'value', (evalContext) => {\n evalContext.value = (0, lodash_1.clone)(oldValue);\n });\n if (!(0, lodash_1.isEqual)(oldValue, newValue) &&\n !(component.clearOnHide && (0, conditions_1.conditionallyHidden)(context))) {\n (0, lodash_1.set)(data, path, newValue);\n return true;\n }\n return false;\n}\nexports.setValueProperty = setValueProperty;\nfunction setMergeComponentSchema(context, action) {\n const { component, data, path } = context;\n const oldValue = (0, lodash_1.get)(data, path);\n const schema = (0, jsonlogic_1.evaluate)(Object.assign(Object.assign({}, context), { value: {} }), action.schemaDefinition, 'schema', (evalContext) => {\n evalContext.value = (0, lodash_1.clone)(oldValue);\n });\n const merged = (0, lodash_1.assign)({}, component, schema);\n if (!(0, lodash_1.isEqual)(component, merged)) {\n (0, lodash_1.assign)(component, schema);\n return true;\n }\n return false;\n}\nexports.setMergeComponentSchema = setMergeComponentSchema;\nfunction setCustomAction(context, action) {\n return setValueProperty(context, { type: 'value', value: action.customAction });\n}\nexports.setCustomAction = setCustomAction;\nconst applyActions = (context) => {\n const { component } = context;\n const { logic } = component;\n if (!logic || !logic.length) {\n return false;\n }\n return logic.reduce((changed, logicItem) => {\n const { actions, trigger } = logicItem;\n if (!trigger || !actions || !actions.length || !(0, exports.checkTrigger)(context, trigger)) {\n return changed;\n }\n return actions.reduce((changed, action) => {\n switch (action.type) {\n case 'property':\n if (setActionProperty(context, action)) {\n return true;\n }\n return changed;\n case 'value':\n return setValueProperty(context, action) || changed;\n case 'mergeComponentSchema':\n if (setMergeComponentSchema(context, action)) {\n return true;\n }\n return changed;\n case 'customAction':\n return setCustomAction(context, action) || changed;\n default:\n return changed;\n }\n }, changed);\n }, false);\n};\nexports.applyActions = applyActions;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/logic.js?");
|
1711
1722
|
|
1712
1723
|
/***/ }),
|
1713
1724
|
|
@@ -1718,7 +1729,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
1718
1729
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1719
1730
|
|
1720
1731
|
"use strict";
|
1721
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.matchInputMask = exports.getInputMask = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\n/**\n * Returns an input mask that is compatible with the input mask library.\n * @param {string} mask - The Form.io input mask.\n * @param {string} placeholderChar - Char which is used as a placeholder.\n * @returns {Array} - The input mask for the mask library.\n */\nfunction getInputMask(mask, placeholderChar) {\n if (mask instanceof Array) {\n return mask;\n }\n const maskArray = [];\n maskArray.numeric = true;\n for (let i = 0; i < mask.length; i++) {\n switch (mask[i]) {\n case '9':\n maskArray.push(/\\d/);\n break;\n case 'A':\n maskArray.numeric = false;\n maskArray.push(/[a-zA-Z]/);\n break;\n case 'a':\n maskArray.numeric = false;\n maskArray.push(/[a-z]/);\n break;\n case '*':\n maskArray.numeric = false;\n maskArray.push(/[a-zA-Z0-9]/);\n break;\n // If char which is used inside mask placeholder was used in the mask, replace it with space to prevent errors\n case placeholderChar:\n maskArray.numeric = false;\n maskArray.push(' ');\n break;\n default:\n maskArray.numeric = false;\n maskArray.push(mask[i]);\n break;\n }\n }\n return maskArray;\n}\nexports.getInputMask = getInputMask;\nfunction matchInputMask(value, inputMask) {\n if (!inputMask) {\n return true;\n }\n // If value is longer than mask, it isn't valid.\n if (value.length > inputMask.length) {\n return false;\n }\n for (let i = 0; i < inputMask.length; i++) {\n const char = value[i];\n const charPart = inputMask[i];\n if (!((0, lodash_1.isRegExp)(charPart) && charPart.test(char) || charPart === char)) {\n return false;\n }\n }\n return true;\n}\nexports.matchInputMask = matchInputMask;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/mask.js?");
|
1732
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.matchInputMask = exports.getInputMask = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\n/**\n * Returns an input mask that is compatible with the input mask library.\n * @param {string} mask - The Form.io input mask.\n * @param {string} placeholderChar - Char which is used as a placeholder.\n * @returns {Array} - The input mask for the mask library.\n */\nfunction getInputMask(mask, placeholderChar) {\n if (mask instanceof Array) {\n return mask;\n }\n const maskArray = [];\n maskArray.numeric = true;\n for (let i = 0; i < mask.length; i++) {\n switch (mask[i]) {\n case '9':\n maskArray.push(/\\d/);\n break;\n case 'A':\n maskArray.numeric = false;\n maskArray.push(/[a-zA-Z]/);\n break;\n case 'a':\n maskArray.numeric = false;\n maskArray.push(/[a-z]/);\n break;\n case '*':\n maskArray.numeric = false;\n maskArray.push(/[a-zA-Z0-9]/);\n break;\n // If char which is used inside mask placeholder was used in the mask, replace it with space to prevent errors\n case placeholderChar:\n maskArray.numeric = false;\n maskArray.push(' ');\n break;\n default:\n maskArray.numeric = false;\n maskArray.push(mask[i]);\n break;\n }\n }\n return maskArray;\n}\nexports.getInputMask = getInputMask;\nfunction matchInputMask(value, inputMask) {\n if (!inputMask) {\n return true;\n }\n // If value is longer than mask, it isn't valid.\n if (value.length > inputMask.length) {\n return false;\n }\n for (let i = 0; i < inputMask.length; i++) {\n const char = value[i];\n const charPart = inputMask[i];\n if (!(((0, lodash_1.isRegExp)(charPart) && charPart.test(char)) || charPart === char)) {\n return false;\n }\n }\n return true;\n}\nexports.matchInputMask = matchInputMask;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/mask.js?");
|
1722
1733
|
|
1723
1734
|
/***/ }),
|
1724
1735
|
|
@@ -1729,7 +1740,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
1729
1740
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1730
1741
|
|
1731
1742
|
"use strict";
|
1732
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\
|
1743
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nclass ConditionOperator {\n static get operatorKey() {\n return '';\n }\n static get displayedName() {\n return '';\n }\n static get requireValue() {\n return true;\n }\n execute() {\n return true;\n }\n getResult(options = {}) {\n const { value } = options;\n if ((0, lodash_1.isArray)(value)) {\n return (0, lodash_1.some)(value, (valueItem) => this.execute(Object.assign(Object.assign({}, options), { value: valueItem })));\n }\n return this.execute(options);\n }\n}\nexports[\"default\"] = ConditionOperator;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/operators/ConditionOperator.js?");
|
1733
1744
|
|
1734
1745
|
/***/ }),
|
1735
1746
|
|
@@ -1740,7 +1751,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\ncons
|
|
1740
1751
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1741
1752
|
|
1742
1753
|
"use strict";
|
1743
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst ConditionOperator_1 = __importDefault(__webpack_require__(/*! ./ConditionOperator */ \"./node_modules/@formio/core/lib/utils/operators/ConditionOperator.js\"));\nconst moment_1 = __importDefault(__webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\"));\nconst date_1 = __webpack_require__(/*! ../../utils/date */ \"./node_modules/@formio/core/lib/utils/date.js\");\nclass DateGeaterThan extends ConditionOperator_1.default {\n static get operatorKey() {\n return 'dateGreaterThan';\n }\n static get displayedName() {\n return 'Greater Than';\n }\n getFormattedDates({ value, comparedValue, conditionTriggerComponent }) {\n const validationFormat = conditionTriggerComponent && conditionTriggerComponent.component.type === 'day'
|
1754
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst ConditionOperator_1 = __importDefault(__webpack_require__(/*! ./ConditionOperator */ \"./node_modules/@formio/core/lib/utils/operators/ConditionOperator.js\"));\nconst moment_1 = __importDefault(__webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\"));\nconst date_1 = __webpack_require__(/*! ../../utils/date */ \"./node_modules/@formio/core/lib/utils/date.js\");\nclass DateGeaterThan extends ConditionOperator_1.default {\n static get operatorKey() {\n return 'dateGreaterThan';\n }\n static get displayedName() {\n return 'Greater Than';\n }\n getFormattedDates({ value, comparedValue, conditionTriggerComponent }) {\n const validationFormat = conditionTriggerComponent && conditionTriggerComponent.component.type === 'day'\n ? (0, date_1.getDateValidationFormat)(conditionTriggerComponent.component)\n : null;\n const date = validationFormat ? (0, moment_1.default)(value, validationFormat) : (0, moment_1.default)(value);\n const comparedDate = validationFormat\n ? (0, moment_1.default)(comparedValue, validationFormat)\n : (0, moment_1.default)(comparedValue);\n return { date, comparedDate };\n }\n execute(options, functionName = 'isAfter') {\n const { value, instance, conditionComponentPath } = options;\n if (!value) {\n return false;\n }\n let conditionTriggerComponent = null;\n if (instance && instance.root) {\n conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);\n }\n if (conditionTriggerComponent &&\n conditionTriggerComponent.component.type === 'day' &&\n (0, date_1.isPartialDay)(conditionTriggerComponent.component, value)) {\n return false;\n }\n const { date, comparedDate } = this.getFormattedDates(Object.assign(Object.assign({}, options), { conditionTriggerComponent }));\n return date[functionName](comparedDate);\n }\n}\nexports[\"default\"] = DateGeaterThan;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/operators/DateGreaterThan.js?");
|
1744
1755
|
|
1745
1756
|
/***/ }),
|
1746
1757
|
|
@@ -1850,7 +1861,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1850
1861
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1851
1862
|
|
1852
1863
|
"use strict";
|
1853
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst formUtil_1 = __webpack_require__(/*! ../formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst ConditionOperator_1 = __importDefault(__webpack_require__(/*! ./ConditionOperator */ \"./node_modules/@formio/core/lib/utils/operators/ConditionOperator.js\"));\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nclass IsEqualTo extends ConditionOperator_1.default {\n static get operatorKey() {\n return 'isEqual';\n }\n static get displayedName() {\n return 'Is Equal To';\n }\n execute({ value, comparedValue, conditionComponent }) {\n // special check for select boxes\n if ((conditionComponent === null || conditionComponent === void 0 ? void 0 : conditionComponent.type) === 'selectboxes') {\n return (0, lodash_1.get)(value, comparedValue, false);\n }\n if (value
|
1864
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst formUtil_1 = __webpack_require__(/*! ../formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst ConditionOperator_1 = __importDefault(__webpack_require__(/*! ./ConditionOperator */ \"./node_modules/@formio/core/lib/utils/operators/ConditionOperator.js\"));\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nclass IsEqualTo extends ConditionOperator_1.default {\n static get operatorKey() {\n return 'isEqual';\n }\n static get displayedName() {\n return 'Is Equal To';\n }\n execute({ value, comparedValue, conditionComponent }) {\n // special check for select boxes\n if ((conditionComponent === null || conditionComponent === void 0 ? void 0 : conditionComponent.type) === 'selectboxes') {\n return (0, lodash_1.get)(value, comparedValue, false);\n }\n if (value &&\n comparedValue &&\n typeof value !== typeof comparedValue &&\n (0, lodash_1.isString)(comparedValue)) {\n try {\n comparedValue = JSON.parse(comparedValue);\n }\n catch (ignoreError) {\n // do nothing\n }\n }\n if (conditionComponent &&\n (0, formUtil_1.isSelectResourceWithObjectValue)(conditionComponent) &&\n conditionComponent.template) {\n return (0, formUtil_1.compareSelectResourceWithObjectTypeValues)(value, comparedValue, conditionComponent);\n }\n return (0, lodash_1.isEqual)(value, comparedValue);\n }\n}\nexports[\"default\"] = IsEqualTo;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/operators/IsEqualTo.js?");
|
1854
1865
|
|
1855
1866
|
/***/ }),
|
1856
1867
|
|
@@ -1938,7 +1949,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1938
1949
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1939
1950
|
|
1940
1951
|
"use strict";
|
1941
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst IsNotEqualTo_1 = __importDefault(__webpack_require__(/*! ./IsNotEqualTo */ \"./node_modules/@formio/core/lib/utils/operators/IsNotEqualTo.js\"));\nconst IsEmptyValue_1 = __importDefault(__webpack_require__(/*! ./IsEmptyValue */ \"./node_modules/@formio/core/lib/utils/operators/IsEmptyValue.js\"));\nconst IsNotEmptyValue_1 = __importDefault(__webpack_require__(/*! ./IsNotEmptyValue */ \"./node_modules/@formio/core/lib/utils/operators/IsNotEmptyValue.js\"));\nconst LessThan_1 = __importDefault(__webpack_require__(/*! ./LessThan */ \"./node_modules/@formio/core/lib/utils/operators/LessThan.js\"));\nconst GreaterThan_1 = __importDefault(__webpack_require__(/*! ./GreaterThan */ \"./node_modules/@formio/core/lib/utils/operators/GreaterThan.js\"));\nconst IsEqualTo_1 = __importDefault(__webpack_require__(/*! ./IsEqualTo */ \"./node_modules/@formio/core/lib/utils/operators/IsEqualTo.js\"));\nconst DateGreaterThan_1 = __importDefault(__webpack_require__(/*! ./DateGreaterThan */ \"./node_modules/@formio/core/lib/utils/operators/DateGreaterThan.js\"));\nconst DateLessThan_1 = __importDefault(__webpack_require__(/*! ./DateLessThan */ \"./node_modules/@formio/core/lib/utils/operators/DateLessThan.js\"));\nconst Includes_1 = __importDefault(__webpack_require__(/*! ./Includes */ \"./node_modules/@formio/core/lib/utils/operators/Includes.js\"));\nconst StartsWith_1 = __importDefault(__webpack_require__(/*! ./StartsWith */ \"./node_modules/@formio/core/lib/utils/operators/StartsWith.js\"));\nconst NotIncludes_1 = __importDefault(__webpack_require__(/*! ./NotIncludes */ \"./node_modules/@formio/core/lib/utils/operators/NotIncludes.js\"));\nconst EndsWith_1 = __importDefault(__webpack_require__(/*! ./EndsWith */ \"./node_modules/@formio/core/lib/utils/operators/EndsWith.js\"));\nconst DateGreaterThanOrEqual_1 = __importDefault(__webpack_require__(/*! ./DateGreaterThanOrEqual */ \"./node_modules/@formio/core/lib/utils/operators/DateGreaterThanOrEqual.js\"));\nconst DateLessThanOrEqual_1 = __importDefault(__webpack_require__(/*! ./DateLessThanOrEqual */ \"./node_modules/@formio/core/lib/utils/operators/DateLessThanOrEqual.js\"));\nconst LessThanOrEqual_1 = __importDefault(__webpack_require__(/*! ./LessThanOrEqual */ \"./node_modules/@formio/core/lib/utils/operators/LessThanOrEqual.js\"));\nconst GreaterThanOrEqual_1 = __importDefault(__webpack_require__(/*! ./GreaterThanOrEqual */ \"./node_modules/@formio/core/lib/utils/operators/GreaterThanOrEqual.js\"));\nconst IsDateEqual_1 = __importDefault(__webpack_require__(/*! ./IsDateEqual */ \"./node_modules/@formio/core/lib/utils/operators/IsDateEqual.js\"));\nconst IsNotDateEqual_1 = __importDefault(__webpack_require__(/*! ./IsNotDateEqual */ \"./node_modules/@formio/core/lib/utils/operators/IsNotDateEqual.js\"));\nconst ConditionOperators = {\n [`${IsNotEqualTo_1.default.operatorKey}`]: IsNotEqualTo_1.default,\n [`${IsEqualTo_1.default.operatorKey}`]: IsEqualTo_1.default,\n [`${IsEmptyValue_1.default.operatorKey}`]: IsEmptyValue_1.default,\n [`${IsNotEmptyValue_1.default.operatorKey}`]: IsNotEmptyValue_1.default,\n [`${LessThan_1.default.operatorKey}`]: LessThan_1.default,\n [`${GreaterThan_1.default.operatorKey}`]: GreaterThan_1.default,\n [`${DateGreaterThan_1.default.operatorKey}`]: DateGreaterThan_1.default,\n [`${DateLessThan_1.default.operatorKey}`]: DateLessThan_1.default,\n [`${Includes_1.default.operatorKey}`]: Includes_1.default,\n [`${StartsWith_1.default.operatorKey}`]: StartsWith_1.default,\n [`${EndsWith_1.default.operatorKey}`]: EndsWith_1.default,\n [`${NotIncludes_1.default.operatorKey}`]: NotIncludes_1.default,\n [`${DateGreaterThanOrEqual_1.default.operatorKey}`]: DateGreaterThanOrEqual_1.default,\n [`${DateLessThanOrEqual_1.default.operatorKey}`]: DateLessThanOrEqual_1.default,\n [`${LessThanOrEqual_1.default.operatorKey}`]: LessThanOrEqual_1.default,\n [`${GreaterThanOrEqual_1.default.operatorKey}`]: GreaterThanOrEqual_1.default,\n [`${IsDateEqual_1.default.operatorKey}`]: IsDateEqual_1.default,\n [`${IsNotDateEqual_1.default.operatorKey}`]: IsNotDateEqual_1.default
|
1952
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst IsNotEqualTo_1 = __importDefault(__webpack_require__(/*! ./IsNotEqualTo */ \"./node_modules/@formio/core/lib/utils/operators/IsNotEqualTo.js\"));\nconst IsEmptyValue_1 = __importDefault(__webpack_require__(/*! ./IsEmptyValue */ \"./node_modules/@formio/core/lib/utils/operators/IsEmptyValue.js\"));\nconst IsNotEmptyValue_1 = __importDefault(__webpack_require__(/*! ./IsNotEmptyValue */ \"./node_modules/@formio/core/lib/utils/operators/IsNotEmptyValue.js\"));\nconst LessThan_1 = __importDefault(__webpack_require__(/*! ./LessThan */ \"./node_modules/@formio/core/lib/utils/operators/LessThan.js\"));\nconst GreaterThan_1 = __importDefault(__webpack_require__(/*! ./GreaterThan */ \"./node_modules/@formio/core/lib/utils/operators/GreaterThan.js\"));\nconst IsEqualTo_1 = __importDefault(__webpack_require__(/*! ./IsEqualTo */ \"./node_modules/@formio/core/lib/utils/operators/IsEqualTo.js\"));\nconst DateGreaterThan_1 = __importDefault(__webpack_require__(/*! ./DateGreaterThan */ \"./node_modules/@formio/core/lib/utils/operators/DateGreaterThan.js\"));\nconst DateLessThan_1 = __importDefault(__webpack_require__(/*! ./DateLessThan */ \"./node_modules/@formio/core/lib/utils/operators/DateLessThan.js\"));\nconst Includes_1 = __importDefault(__webpack_require__(/*! ./Includes */ \"./node_modules/@formio/core/lib/utils/operators/Includes.js\"));\nconst StartsWith_1 = __importDefault(__webpack_require__(/*! ./StartsWith */ \"./node_modules/@formio/core/lib/utils/operators/StartsWith.js\"));\nconst NotIncludes_1 = __importDefault(__webpack_require__(/*! ./NotIncludes */ \"./node_modules/@formio/core/lib/utils/operators/NotIncludes.js\"));\nconst EndsWith_1 = __importDefault(__webpack_require__(/*! ./EndsWith */ \"./node_modules/@formio/core/lib/utils/operators/EndsWith.js\"));\nconst DateGreaterThanOrEqual_1 = __importDefault(__webpack_require__(/*! ./DateGreaterThanOrEqual */ \"./node_modules/@formio/core/lib/utils/operators/DateGreaterThanOrEqual.js\"));\nconst DateLessThanOrEqual_1 = __importDefault(__webpack_require__(/*! ./DateLessThanOrEqual */ \"./node_modules/@formio/core/lib/utils/operators/DateLessThanOrEqual.js\"));\nconst LessThanOrEqual_1 = __importDefault(__webpack_require__(/*! ./LessThanOrEqual */ \"./node_modules/@formio/core/lib/utils/operators/LessThanOrEqual.js\"));\nconst GreaterThanOrEqual_1 = __importDefault(__webpack_require__(/*! ./GreaterThanOrEqual */ \"./node_modules/@formio/core/lib/utils/operators/GreaterThanOrEqual.js\"));\nconst IsDateEqual_1 = __importDefault(__webpack_require__(/*! ./IsDateEqual */ \"./node_modules/@formio/core/lib/utils/operators/IsDateEqual.js\"));\nconst IsNotDateEqual_1 = __importDefault(__webpack_require__(/*! ./IsNotDateEqual */ \"./node_modules/@formio/core/lib/utils/operators/IsNotDateEqual.js\"));\nconst ConditionOperators = {\n [`${IsNotEqualTo_1.default.operatorKey}`]: IsNotEqualTo_1.default,\n [`${IsEqualTo_1.default.operatorKey}`]: IsEqualTo_1.default,\n [`${IsEmptyValue_1.default.operatorKey}`]: IsEmptyValue_1.default,\n [`${IsNotEmptyValue_1.default.operatorKey}`]: IsNotEmptyValue_1.default,\n [`${LessThan_1.default.operatorKey}`]: LessThan_1.default,\n [`${GreaterThan_1.default.operatorKey}`]: GreaterThan_1.default,\n [`${DateGreaterThan_1.default.operatorKey}`]: DateGreaterThan_1.default,\n [`${DateLessThan_1.default.operatorKey}`]: DateLessThan_1.default,\n [`${Includes_1.default.operatorKey}`]: Includes_1.default,\n [`${StartsWith_1.default.operatorKey}`]: StartsWith_1.default,\n [`${EndsWith_1.default.operatorKey}`]: EndsWith_1.default,\n [`${NotIncludes_1.default.operatorKey}`]: NotIncludes_1.default,\n [`${DateGreaterThanOrEqual_1.default.operatorKey}`]: DateGreaterThanOrEqual_1.default,\n [`${DateLessThanOrEqual_1.default.operatorKey}`]: DateLessThanOrEqual_1.default,\n [`${LessThanOrEqual_1.default.operatorKey}`]: LessThanOrEqual_1.default,\n [`${GreaterThanOrEqual_1.default.operatorKey}`]: GreaterThanOrEqual_1.default,\n [`${IsDateEqual_1.default.operatorKey}`]: IsDateEqual_1.default,\n [`${IsNotDateEqual_1.default.operatorKey}`]: IsNotDateEqual_1.default,\n};\nexports[\"default\"] = ConditionOperators;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/operators/index.js?");
|
1942
1953
|
|
1943
1954
|
/***/ }),
|
1944
1955
|
|
@@ -1949,7 +1960,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1949
1960
|
/***/ (function(__unused_webpack_module, exports) {
|
1950
1961
|
|
1951
1962
|
"use strict";
|
1952
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.override = void 0;\n/**\n * Simple class to allow for overriding base classes.\n * @param classObj\n * @param extenders\n */\nfunction override(classObj, extenders) {\n for (
|
1963
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.override = void 0;\n/**\n * Simple class to allow for overriding base classes.\n * @param classObj\n * @param extenders\n */\nfunction override(classObj, extenders) {\n for (const key in extenders) {\n if (extenders.hasOwnProperty(key)) {\n const extender = extenders[key];\n if (typeof extender === 'function') {\n classObj.prototype[key] = extender;\n }\n else {\n const prop = Object.getOwnPropertyDescriptor(classObj.prototype, key);\n for (const attr in extender) {\n if (extender.hasOwnProperty(attr)) {\n prop[attr] = extender[attr](prop[attr]);\n }\n }\n Object.defineProperty(classObj.prototype, key, prop);\n }\n }\n }\n}\nexports.override = override;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/override.js?");
|
1953
1964
|
|
1954
1965
|
/***/ }),
|
1955
1966
|
|
@@ -1960,7 +1971,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
1960
1971
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1961
1972
|
|
1962
1973
|
"use strict";
|
1963
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.sanitize = void 0;\nconst dompurify_1 = __importDefault(__webpack_require__(/*! dompurify */ \"./node_modules/dompurify/dist/purify.js\"));\nlet DOMPurify = null;\nconst getDOMPurify = () => {\n if (DOMPurify) {\n return DOMPurify;\n }\n if (window) {\n DOMPurify = (0, dompurify_1.default)(window);\n return DOMPurify;\n }\n return null;\n};\n/**\n * Sanitize an html string.\n *\n * @param string\n * @returns {*}\n */\nfunction sanitize(string, options) {\n const dompurify = getDOMPurify();\n if (!dompurify) {\n console.log('DOMPurify unable to sanitize the contents.');\n return string;\n }\n // Dompurify configuration\n const sanitizeOptions = {\n ADD_ATTR: ['ref', 'target', 'within'],\n USE_PROFILES: { html: true }
|
1974
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.sanitize = void 0;\nconst dompurify_1 = __importDefault(__webpack_require__(/*! dompurify */ \"./node_modules/dompurify/dist/purify.js\"));\nlet DOMPurify = null;\nconst getDOMPurify = () => {\n if (DOMPurify) {\n return DOMPurify;\n }\n if (window) {\n DOMPurify = (0, dompurify_1.default)(window);\n return DOMPurify;\n }\n return null;\n};\n/**\n * Sanitize an html string.\n *\n * @param string\n * @returns {*}\n */\nfunction sanitize(string, options) {\n const dompurify = getDOMPurify();\n if (!dompurify) {\n console.log('DOMPurify unable to sanitize the contents.');\n return string;\n }\n // Dompurify configuration\n const sanitizeOptions = {\n ADD_ATTR: ['ref', 'target', 'within'],\n USE_PROFILES: { html: true },\n };\n // Add attrs\n if (options.sanitizeConfig &&\n Array.isArray(options.sanitizeConfig.addAttr) &&\n options.sanitizeConfig.addAttr.length > 0) {\n options.sanitizeConfig.addAttr.forEach((attr) => {\n sanitizeOptions.ADD_ATTR.push(attr);\n });\n }\n // Add tags\n if (options.sanitizeConfig &&\n Array.isArray(options.sanitizeConfig.addTags) &&\n options.sanitizeConfig.addTags.length > 0) {\n sanitizeOptions.ADD_TAGS = options.sanitizeConfig.addTags;\n }\n // Allow tags\n if (options.sanitizeConfig &&\n Array.isArray(options.sanitizeConfig.allowedTags) &&\n options.sanitizeConfig.allowedTags.length > 0) {\n sanitizeOptions.ALLOWED_TAGS = options.sanitizeConfig.allowedTags;\n }\n // Allow attributes\n if (options.sanitizeConfig &&\n Array.isArray(options.sanitizeConfig.allowedAttrs) &&\n options.sanitizeConfig.allowedAttrs.length > 0) {\n sanitizeOptions.ALLOWED_ATTR = options.sanitizeConfig.allowedAttrs;\n }\n // Allowd URI Regex\n if (options.sanitizeConfig && options.sanitizeConfig.allowedUriRegex) {\n sanitizeOptions.ALLOWED_URI_REGEXP = options.sanitizeConfig.allowedUriRegex;\n }\n // Allow to extend the existing array of elements that are safe for URI-like values\n if (options.sanitizeConfig &&\n Array.isArray(options.sanitizeConfig.addUriSafeAttr) &&\n options.sanitizeConfig.addUriSafeAttr.length > 0) {\n sanitizeOptions.ADD_URI_SAFE_ATTR = options.sanitizeConfig.addUriSafeAttr;\n }\n return dompurify.sanitize(string, sanitizeOptions);\n}\nexports.sanitize = sanitize;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/sanitize.js?");
|
1964
1975
|
|
1965
1976
|
/***/ }),
|
1966
1977
|
|
@@ -1971,7 +1982,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1971
1982
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1972
1983
|
|
1973
1984
|
"use strict";
|
1974
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.unwind = exports.rewind = exports.mergeArray = exports.mergeObject = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst fastCloneDeep_1 = __webpack_require__(/*! ./fastCloneDeep */ \"./node_modules/@formio/core/lib/utils/fastCloneDeep.js\");\nconst formUtil_1 = __webpack_require__(/*! ./formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nfunction mergeObject(src, dst) {\n (0, lodash_1.each)(src, function (value, key) {\n if (!Array.isArray(value)) {\n dst[key] = value;\n }\n else {\n if (!dst[key]) {\n dst[key] = [];\n }\n mergeArray(value, dst[key]);\n }\n });\n}\nexports.mergeObject = mergeObject;\nfunction mergeArray(src, dst) {\n src.forEach(function (value) {\n
|
1985
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.unwind = exports.rewind = exports.mergeArray = exports.mergeObject = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst fastCloneDeep_1 = __webpack_require__(/*! ./fastCloneDeep */ \"./node_modules/@formio/core/lib/utils/fastCloneDeep.js\");\nconst formUtil_1 = __webpack_require__(/*! ./formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nfunction mergeObject(src, dst) {\n (0, lodash_1.each)(src, function (value, key) {\n if (!Array.isArray(value)) {\n dst[key] = value;\n }\n else {\n if (!dst[key]) {\n dst[key] = [];\n }\n mergeArray(value, dst[key]);\n }\n });\n}\nexports.mergeObject = mergeObject;\nfunction mergeArray(src, dst) {\n src.forEach(function (value) {\n const query = {};\n (0, lodash_1.each)(value, function (subValue, key) {\n if (!Array.isArray(subValue)) {\n query[key] = subValue;\n }\n });\n const dstValue = (0, lodash_1.find)(dst, query);\n if (dstValue) {\n mergeObject(value, dstValue);\n }\n else {\n dst.push(value);\n }\n });\n}\nexports.mergeArray = mergeArray;\nfunction rewind(submissions) {\n const submission = { data: {} };\n if (submissions && submissions.length) {\n submissions.forEach((sub) => mergeObject(sub.data, submission.data));\n }\n return submission;\n}\nexports.rewind = rewind;\nfunction unwind(form, submission) {\n const dataPaths = {};\n const locked = {};\n const submissions = [(0, fastCloneDeep_1.fastCloneDeep)(submission)];\n // Set the data value for a data path.\n const setDataValue = function (dataPath, values, parent, offset, current) {\n offset = offset || 0;\n current = current || 0;\n // Make sure we don't overwrite any locked values.\n while ((0, lodash_1.has)(locked, '[' + current + '].' + parent)) {\n if (current + 1 >= submissions.length) {\n submissions.push((0, fastCloneDeep_1.fastCloneDeep)(submissions[current]));\n }\n current++;\n }\n // Ensure that all parents have been copied over to this path.\n /* eslint-disable no-useless-escape */\n const parentPath = parent.replace(/\\.[^\\.]+$/, '');\n if (!(0, lodash_1.has)(submissions[current].data, parentPath) &&\n submissions[current - 1] &&\n (0, lodash_1.has)(submissions[current - 1].data, parentPath)) {\n (0, lodash_1.set)(submissions[current].data, parentPath, (0, fastCloneDeep_1.fastCloneDeep)((0, lodash_1.get)(submissions[current - 1].data, parentPath)));\n }\n /* eslint-enable no-useless-escape */\n const pathValue = [];\n (0, lodash_1.set)(submissions[current].data, parent, pathValue);\n (0, lodash_1.set)(locked, '[' + current + '].' + parent, true);\n for (let i = offset; i < values.length; i++) {\n if (i - offset <= dataPath.max) {\n pathValue.push(values[i]);\n if (dataPath.paths && Object.keys(dataPath.paths).length) {\n addData(dataPath.paths, values[i], parent + '[' + (i - offset) + ']', current);\n }\n }\n else {\n setDataValue(dataPath, values, parent, i, current);\n break;\n }\n }\n };\n // Add data to a series of data paths.\n const addData = function (dataPaths, data, parent, current) {\n for (const path in dataPaths) {\n const dataPath = dataPaths[path];\n if (data[path] && Array.isArray(data[path])) {\n setDataValue(dataPath, data[path], parent ? parent + '.' + path : path, 0, current);\n }\n }\n };\n const addDataPaths = function (dataPath, paths, index, parentDataPath) {\n index = index || 0;\n const path = paths[index];\n /* eslint-disable no-useless-escape */\n const matches = path.match(/([^\\[]+)\\[?([0-9]+)?\\]?/);\n /* eslint-enable no-useless-escape */\n if (matches && matches.length === 3) {\n const dataParam = matches[1];\n const dataIndex = parseInt(matches[2], 10) || 0;\n if (dataPath[dataParam]) {\n if (dataIndex > dataPath[dataParam].max) {\n dataPath[dataParam].max = dataIndex;\n }\n }\n else {\n dataPath[dataParam] = {\n max: dataIndex,\n param: dataParam,\n parent: parentDataPath || null,\n paths: {},\n };\n }\n if (index + 1 < paths.length) {\n addDataPaths(dataPath[dataParam].paths, paths, index + 1, dataPath[dataParam]);\n }\n }\n };\n // Iterate through all components.\n (0, formUtil_1.eachComponent)(form.components, function (component, path) {\n var _a;\n if (component.type === 'form' && ((_a = component.components) === null || _a === void 0 ? void 0 : _a.length)) {\n (0, formUtil_1.eachComponent)(component.components, (comp) => {\n comp.isInsideNestedForm = true;\n });\n }\n if (!component.overlay || (!component.overlay.width && !component.overlay.height)) {\n return;\n }\n const hasDataPath = component.properties && component.properties.dataPath;\n let key = component.key;\n if (hasDataPath) {\n path = component.properties.dataPath;\n key = component.properties.dataPath;\n }\n const paths = (0, lodash_1.filter)(path.replace(new RegExp('.?' + component.key + '$'), '').split('.'));\n if (!hasDataPath && paths.length && !component.isInsideNestedForm) {\n key = paths.join('.') + '.' + component.key;\n }\n if (component.multiple) {\n paths.push(component.key);\n }\n component.key = key;\n if (paths && paths.length) {\n addDataPaths(dataPaths, paths);\n }\n }, true);\n addData(dataPaths, submission.data);\n return submissions;\n}\nexports.unwind = unwind;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/unwind.js?");
|
1975
1986
|
|
1976
1987
|
/***/ }),
|
1977
1988
|
|
@@ -1982,7 +1993,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
1982
1993
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
1983
1994
|
|
1984
1995
|
"use strict";
|
1985
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.resetEphermalState = exports.registerEphermalState = exports.unescapeHTML = exports.boolValue = exports.escapeRegExCharacters = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\n/**\n * Escapes RegEx characters in provided String value.\n *\n * @param {String} value\n * String for escaping RegEx characters.\n * @returns {string}\n * String with escaped RegEx characters.\n */\nfunction escapeRegExCharacters(value) {\n return value.replace(/[-[\\]/{}()*+?.\\\\^$|]/g, '\\\\$&');\n}\nexports.escapeRegExCharacters = escapeRegExCharacters;\n/**\n * Determines the boolean value of a setting.\n *\n * @param value\n * @return {boolean}\n */\nfunction boolValue(value) {\n if ((0, lodash_1.isBoolean)(value)) {\n return value;\n }\n else if ((0, lodash_1.isString)(value)) {\n return
|
1996
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.resetEphermalState = exports.attachResourceToDom = exports.registerEphermalState = exports.unescapeHTML = exports.boolValue = exports.escapeRegExCharacters = void 0;\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\n/**\n * Escapes RegEx characters in provided String value.\n *\n * @param {String} value\n * String for escaping RegEx characters.\n * @returns {string}\n * String with escaped RegEx characters.\n */\nfunction escapeRegExCharacters(value) {\n return value.replace(/[-[\\]/{}()*+?.\\\\^$|]/g, '\\\\$&');\n}\nexports.escapeRegExCharacters = escapeRegExCharacters;\n/**\n * Determines the boolean value of a setting.\n *\n * @param value\n * @return {boolean}\n */\nfunction boolValue(value) {\n if ((0, lodash_1.isBoolean)(value)) {\n return value;\n }\n else if ((0, lodash_1.isString)(value)) {\n return value.toLowerCase() === 'true';\n }\n else {\n return !!value;\n }\n}\nexports.boolValue = boolValue;\n/**\n * Unescape HTML characters like <, >, & and etc.\n * @param str\n * @returns {string}\n */\nfunction unescapeHTML(str) {\n if (typeof window === 'undefined' || !('DOMParser' in window)) {\n return str;\n }\n const doc = new window.DOMParser().parseFromString(str, 'text/html');\n return doc.documentElement.textContent;\n}\nexports.unescapeHTML = unescapeHTML;\nfunction registerEphermalState(component, name, value) {\n if (!component.ephermalState) {\n Object.defineProperty(component, 'ephermalState', {\n enumerable: false,\n configurable: true,\n writable: true,\n value: {},\n });\n }\n Object.defineProperty(component.ephermalState, name, {\n enumerable: false,\n writable: false,\n configurable: true,\n value,\n });\n}\nexports.registerEphermalState = registerEphermalState;\nfunction attachResourceToDom(options) {\n const { name, formio, onload, rootElement } = options;\n let { src } = options;\n src = Array.isArray(src) ? src : [src];\n src.forEach((lib) => {\n let attrs = {};\n let elementType = '';\n if (typeof lib === 'string') {\n lib = {\n type: 'script',\n src: lib,\n };\n }\n switch (lib.type) {\n case 'script':\n elementType = 'script';\n attrs = {\n src: lib.src,\n type: 'text/javascript',\n defer: true,\n async: true,\n referrerpolicy: 'origin',\n };\n break;\n case 'styles':\n elementType = 'link';\n attrs = {\n href: lib.src,\n rel: 'stylesheet',\n };\n break;\n }\n // Add the script to the top of the page.\n const element = document.createElement(elementType);\n if (element.setAttribute) {\n for (const attr in attrs) {\n element.setAttribute(attr, attrs[attr]);\n }\n }\n if (onload) {\n element.addEventListener('load', () => {\n formio.libraries[name].loaded = true;\n onload(formio.libraries[name].ready);\n });\n }\n if (rootElement) {\n rootElement.insertAdjacentElement('afterend', element);\n return;\n }\n const { head } = document;\n if (head) {\n head.appendChild(element);\n }\n });\n}\nexports.attachResourceToDom = attachResourceToDom;\nfunction resetEphermalState(component) {\n if (component.ephermalState) {\n delete component.ephermalState;\n }\n}\nexports.resetEphermalState = resetEphermalState;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/utils/utils.js?");
|
1986
1997
|
|
1987
1998
|
/***/ }),
|
1988
1999
|
|
@@ -2002,7 +2013,7 @@ eval("/*!\n * dist/inputmask\n * https://github.com/RobinHerbots/Inputmask\n * C
|
|
2002
2013
|
\**********************************************************************/
|
2003
2014
|
/***/ (function(module) {
|
2004
2015
|
|
2005
|
-
eval("!function(e,t){ true?module.exports=t():0}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=\"\",t(0)}([function(e,t,n){\"use strict\";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,\"__esModule\",{value:!0});var i=n(1);Object.defineProperty(t,\"createAutoCorrectedDatePipe\",{enumerable:!0,get:function(){return r(i).default}});var o=n(2);Object.defineProperty(t,\"createNumberMask\",{enumerable:!0,get:function(){return r(o).default}});var u=n(3);Object.defineProperty(t,\"emailMask\",{enumerable:!0,get:function(){return r(u).default}})},function(e,t){\"use strict\";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"mm dd yyyy\",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minYear,o=void 0===n?1:n,u=t.maxYear,a=void 0===u?9999:u,c=e.split(/[^dmyHMS]+/).sort(function(e,t){return i.indexOf(e)-i.indexOf(t)});return function(t){var n=[],i={dd:31,mm:12,yy:99,yyyy:a,HH:23,MM:59,SS:59},u={dd:1,mm:1,yy:0,yyyy:o,HH:0,MM:0,SS:0},l=t.split(\"\");c.forEach(function(t){var r=e.indexOf(t),o=parseInt(i[t].toString().substr(0,1),10);parseInt(l[r],10)>o&&(l[r+1]=l[r],l[r]=0,n.push(r))});var s=0,
|
2016
|
+
eval("!function(e,t){ true?module.exports=t():0}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=\"\",t(0)}([function(e,t,n){\"use strict\";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,\"__esModule\",{value:!0});var i=n(1);Object.defineProperty(t,\"createAutoCorrectedDatePipe\",{enumerable:!0,get:function(){return r(i).default}});var o=n(2);Object.defineProperty(t,\"createNumberMask\",{enumerable:!0,get:function(){return r(o).default}});var u=n(3);Object.defineProperty(t,\"emailMask\",{enumerable:!0,get:function(){return r(u).default}})},function(e,t){\"use strict\";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:\"mm dd yyyy\",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minYear,o=void 0===n?1:n,u=t.maxYear,a=void 0===u?9999:u,c=e.split(/[^dmyHMS]+/).sort(function(e,t){return i.indexOf(e)-i.indexOf(t)});return function(t){var n=[],i={dd:31,mm:12,yy:99,yyyy:a,HH:23,MM:59,SS:59},u={dd:1,mm:1,yy:0,yyyy:o,HH:0,MM:0,SS:0},l=t.split(\"\");c.forEach(function(t){var r=e.indexOf(t),o=parseInt(i[t].toString().substr(0,1),10);parseInt(l[r],10)>o&&(l[r+1]=l[r],l[r]=0,n.push(r))});var s=0,f=c.some(function(n){var c=e.indexOf(n),l=n.length,f=t.substr(c,l).replace(/\\D/g,\"\"),d=parseInt(f,10);\"mm\"===n&&(s=d||0);var p=\"dd\"===n?r[s]:i[n];if(\"yyyy\"===n&&(1!==o||9999!==a)){var y=parseInt(i[n].toString().substring(0,f.length),10),v=parseInt(u[n].toString().substring(0,f.length),10);return d<v||d>y}return d>p||f.length===l&&d<u[n]});return!f&&{value:l.join(\"\"),indexesOfPipedChars:n}}}Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=n;var r=[31,31,29,31,30,31,30,31,31,30,31,30,31],i=[\"yyyy\",\"yy\",\"mm\",\"dd\",\"HH\",\"MM\",\"SS\"]},function(e,t){\"use strict\";function n(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function r(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l,r=t.length;if(t===l||t[0]===m[0]&&1===r)return m.split(l).concat([h]).concat(x.split(l));if(t===A&&w)return m.split(l).concat([\"0\",A,h]).concat(x.split(l));var c=t[0]===d&&D;c&&(t=t.toString().substr(1));var s=t.lastIndexOf(A),f=s!==-1,b=void 0,O=void 0,M=void 0;if(t.slice(q*-1)===x&&(t=t.slice(0,q*-1)),f&&(w||H)?(b=t.slice(t.slice(0,Y)===m?Y:0,s),O=t.slice(s+1,r),O=i(O.replace(y,l))):b=t.slice(0,Y)===m?t.slice(Y):t,L&&(\"undefined\"==typeof L?\"undefined\":a(L))===v){var j=\".\"===_?\"[.]\":\"\"+_,P=(b.match(new RegExp(j,\"g\"))||[]).length;b=b.slice(0,L+P*B)}if(b=b.replace(y,l),R||(b=b.replace(/^0+(0$|[^0])/,\"$1\")),b=S?o(b,_):b,M=i(b),(f&&w||H===!0)&&(t[s-1]!==A&&M.push(g),M.push(A,g),O&&((\"undefined\"==typeof I?\"undefined\":a(I))===v&&(O=O.slice(0,I)),M=M.concat(O)),H===!0&&t[s-1]===A&&M.push(h)),Y>0&&(M=m.split(l).concat(M)),c&&(M.length===Y&&M.push(h),M=[p].concat(M)),x.length>0&&(M=M.concat(x.split(l))),V&&/[eE]/.test(t)){var E=t.split(/[eE]/),C=u(E,2),k=C[0],N=C[1],$=k.match(/^[-+]?[0-9]*\\.?[0-9]+/),T=N&&N.match(/^[-+]?[0-9]+$/);if($&&(!N||T)){var Z=e($[0]),z=T?i(T[0]):[];return[].concat(n(Z),[\"e\"],n(z))}}return M}var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.prefix,m=void 0===r?c:r,b=t.suffix,x=void 0===b?l:b,O=t.includeThousandsSeparator,S=void 0===O||O,M=t.thousandsSeparatorSymbol,_=void 0===M?s:M,j=t.allowDecimal,w=void 0!==j&&j,P=t.decimalSymbol,A=void 0===P?f:P,E=t.decimalLimit,I=void 0===E?2:E,C=t.requireDecimal,H=void 0!==C&&C,k=t.allowNegative,D=void 0!==k&&k,N=t.allowLeadingZeroes,R=void 0!==N&&N,$=t.integerLimit,L=void 0===$?null:$,T=t.allowScientificNotation,V=void 0!==T&&T,Y=m&&m.length||0,q=x&&x.length||0,B=_&&_.length||0;return e.instanceOf=\"createNumberMask\",e}function i(e){return e.split(l).map(function(e){return h.test(e)?h:e})}function o(e,t){return e.replace(/\\B(?=(\\d{3})+(?!\\d))/g,t)}Object.defineProperty(t,\"__esModule\",{value:!0});var u=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError(\"Invalid attempt to destructure non-iterable instance\")}}(),a=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e};t.default=r;var c=\"$\",l=\"\",s=\",\",f=\".\",d=\"-\",p=/-/,y=/\\D+/g,v=\"number\",h=/\\d/,g=\"[]\"},function(e,t,n){\"use strict\";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){e=e.replace(O,y);var n=t.placeholderChar,r=t.currentCaretPosition,i=e.indexOf(v),s=e.lastIndexOf(p),f=s<i?-1:s,d=o(e,i+1,v),h=o(e,f-1,p),g=u(e,i,n),m=a(e,i,f,n),b=c(e,f,n,r);g=l(g),m=l(m),b=l(b,!0);var x=g.concat(d).concat(m).concat(h).concat(b);return x}function o(e,t,n){var r=[];return e[t]===n?r.push(n):r.push(h,n),r.push(h),r}function u(e,t){return t===-1?e:e.slice(0,t)}function a(e,t,n,r){var i=y;return t!==-1&&(i=n===-1?e.slice(t+1,e.length):e.slice(t+1,n)),i=i.replace(new RegExp(\"[\\\\s\"+r+\"]\",m),y),i===v?d:i.length<1?g:i[i.length-1]===p?i.slice(0,i.length-1):i}function c(e,t,n,r){var i=y;return t!==-1&&(i=e.slice(t+1,e.length)),i=i.replace(new RegExp(\"[\\\\s\"+n+\".]\",m),y),0===i.length?e[t-1]===p&&r!==e.length?d:y:i}function l(e,t){return e.split(y).map(function(e){return e===g?e:t?x:b})}Object.defineProperty(t,\"__esModule\",{value:!0});var s=n(4),f=r(s),d=\"*\",p=\".\",y=\"\",v=\"@\",h=\"[]\",g=\" \",m=\"g\",b=/[^\\s]/,x=/[^.\\s]/,O=/\\s/g;t.default={mask:i,pipe:f.default}},function(e,t){\"use strict\";function n(e,t){var n=t.currentCaretPosition,o=t.rawValue,d=t.previousConformedValue,p=t.placeholderChar,y=e;y=r(y);var v=y.indexOf(a),h=null===o.match(new RegExp(\"[^@\\\\s.\"+p+\"]\"));if(h)return u;if(y.indexOf(l)!==-1||v!==-1&&n!==v+1||o.indexOf(i)===-1&&d!==u&&o.indexOf(c)!==-1)return!1;var g=y.indexOf(i),m=y.slice(g+1,y.length);return(m.match(f)||s).length>1&&y.substr(-1)===c&&n!==o.length&&(y=y.slice(0,y.length-1)),y}function r(e){var t=0;return e.replace(o,function(){return t++,1===t?i:u})}Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=n;var i=\"@\",o=/@/g,u=\"\",a=\"@.\",c=\".\",l=\"..\",s=[],f=/\\./g}])});\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/text-mask-addons/dist/textMaskAddons.js?");
|
2006
2017
|
|
2007
2018
|
/***/ }),
|
2008
2019
|
|
@@ -4586,7 +4597,7 @@ eval("\n\nfunction hash(str) {\n var hash = 5381,\n i = str.length;\n\n
|
|
4586
4597
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
4587
4598
|
|
4588
4599
|
"use strict";
|
4589
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Formio = exports.FormioPathType = void 0;\nconst fetch_ponyfill_1 = __importDefault(__webpack_require__(/*! fetch-ponyfill */ \"./node_modules/fetch-ponyfill/build/fetch-browser.js\"));\nconst fastCloneDeep_1 = __webpack_require__(/*! ../utils/fastCloneDeep */ \"./node_modules/@formio/core/lib/utils/fastCloneDeep.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst formUtil_1 = __webpack_require__(/*! ../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst jwtDecode_1 = __webpack_require__(/*! ../utils/jwtDecode */ \"./node_modules/@formio/core/lib/utils/jwtDecode.js\");\nconst eventemitter3_1 = __importDefault(__webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.js\"));\nconst browser_cookies_1 = __importDefault(__webpack_require__(/*! browser-cookies */ \"./node_modules/browser-cookies/src/browser-cookies.js\"));\nconst { fetch, Headers } = (0, fetch_ponyfill_1.default)();\nconst Plugins_1 = __importDefault(__webpack_require__(/*! ./Plugins */ \"./node_modules/@formio/core/lib/sdk/Plugins.js\"));\n/**\n * The different path types for a project.\n */\nvar FormioPathType;\n(function (FormioPathType) {\n FormioPathType[\"Subdirectories\"] = \"Subdirectories\";\n FormioPathType[\"Subdomains\"] = \"Subdomains\";\n})(FormioPathType || (exports.FormioPathType = FormioPathType = {}));\n/**\n * The Formio interface class. This is a minimalistic API library that allows you to work with the Form.io API's within JavaScript.\n *\n * ## Usage\n * Creating an instance of Formio is simple, and takes only a path (URL String). The path can be different, depending on the desired output.\n * The Formio instance can also access higher level operations, depending on how granular of a path you start with.\n *\n * ```ts\n * var formio = new Formio(<endpoint>, [options]);\n * ```\n *\n * Where **endpoint** is any valid API endpoint within Form.io. These URL's can provide a number of different methods depending on the granularity of the endpoint. This allows you to use the same interface but have access to different methods depending on how granular the endpoint url is.\n * **options** is defined within the {link Formio.constructor} documentation.\n *\n * Here is an example of how this library can be used to load a form JSON from the Form.io API's\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.loadForm().then((form) => {\n * console.log(form);\n * });\n * ```\n */\nclass Formio {\n /* eslint-disable max-statements */\n /**\n * @constructor\n * @param {string} path - A project, form, and submission API Url.\n * @param {FormioOptions} options - Available options to configure the Javascript API.\n */\n constructor(path, options = {}) {\n this.path = path;\n this.options = options;\n /**\n * The base API url of the Form.io Platform. Example: https://api.form.io\n */\n this.base = '';\n /**\n * The Projects Endpoint derived from the provided source.\n *\n * @example https://api.form.io/project\n */\n this.projectsUrl = '';\n /**\n * A specific project endpoint derived from the provided source.\n *\n * @example https://examples.form.io\n */\n this.projectUrl = '';\n /**\n * The Project ID found within the provided source.\n */\n this.projectId = '';\n /**\n * A specific Role URL provided the source.\n *\n * @example https://examples.form.io/role/2342343234234234\n */\n this.roleUrl = '';\n /**\n * The roles endpoint derived from the provided source.\n *\n * @example https://examples.form.io/role\n */\n this.rolesUrl = '';\n /**\n * The roleID derieved from the provided source.\n */\n this.roleId = '';\n /**\n * A specific form url derived from the provided source.\n *\n * @example https://examples.form.io/example\n */\n this.formUrl = '';\n /**\n * The forms url derived from the provided source.\n *\n * @example https://example.form.io/form\n */\n this.formsUrl = '';\n /**\n * The Form ID derived from the provided source.\n */\n this.formId = '';\n /**\n * The submissions URL derived from the provided source.\n *\n * @example https://examples.form.io/example/submission\n */\n this.submissionsUrl = '';\n /**\n * A specific submissions URL derived from a provided source.\n *\n * @example https://examples.form.io/example/submission/223423423423\n */\n this.submissionUrl = '';\n /**\n * The submission ID provided a submission url.\n */\n this.submissionId = '';\n /**\n * The actions url provided a form url as the source.\n *\n * @example https://examples.form.io/example/action\n */\n this.actionsUrl = '';\n /**\n * The Action ID derived from a provided Action url.\n */\n this.actionId = '';\n /**\n * A specific action api endoint.\n */\n this.actionUrl = '';\n this.vsUrl = '';\n this.vId = '';\n this.vUrl = '';\n /**\n * The query string derived from the provided src url.\n */\n this.query = '';\n /**\n * If this is a non-project url, such is the case for Open Source API.\n */\n this.noProject = false;\n // Ensure we have an instance of Formio.\n if (!(this instanceof Formio)) {\n return new Formio(path);\n }\n if (options.useSessionToken) {\n Formio.useSessionToken(options);\n }\n if (options.hasOwnProperty('base') && options.base) {\n this.base = options.base;\n }\n else if (Formio.baseUrl) {\n this.base = Formio.baseUrl;\n }\n else if (window && window.location) {\n const match = window.location.href.match(/http[s]?:\\/\\/api./);\n this.base = match ? match[0] : window.location.origin;\n }\n if (!path) {\n // Allow user to create new projects if this was instantiated without\n // a url\n this.projectUrl = Formio.projectUrl || `${this.base}/project`;\n this.projectsUrl = `${this.base}/project`;\n this.projectId = '';\n this.query = '';\n return;\n }\n if (options.hasOwnProperty('project') && options.project) {\n this.projectUrl = options.project;\n }\n const project = this.projectUrl || Formio.projectUrl;\n const projectRegEx = /(^|\\/)(project)($|\\/[^/]+)/;\n const isProjectUrl = (path.search(projectRegEx) !== -1);\n // 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 if (project && this.base === project && !isProjectUrl) {\n this.noProject = true;\n this.projectUrl = this.base;\n }\n // Normalize to an absolute path.\n if ((path.indexOf('http') !== 0) && (path.indexOf('//') !== 0)) {\n path = this.base + path;\n }\n const hostparts = this.getUrlParts(path);\n let hostName = '';\n let parts = [];\n if (hostparts) {\n hostName = hostparts[1] + hostparts[2];\n path = hostparts.length > 3 ? hostparts[3] : '';\n const queryparts = path.split('?');\n if (queryparts.length > 1) {\n path = queryparts[0];\n this.query = `?${queryparts[1]}`;\n }\n }\n // Register a specific path.\n const registerPath = (name, base) => {\n this[`${name}sUrl`] = `${base}/${name}`;\n const regex = new RegExp(`/${name}/([^/]+)`);\n if (path && path.search(regex) !== -1) {\n parts = path.match(regex);\n this[`${name}Url`] = parts ? (base + parts[0]) : '';\n this[`${name}Id`] = (parts.length > 1) ? parts[1] : '';\n base += parts[0];\n }\n return base;\n };\n // Register an array of items.\n const registerItems = (items, base, staticBase) => {\n for (const i in items) {\n if (items.hasOwnProperty(i)) {\n const item = items[i];\n if (Array.isArray(item)) {\n registerItems(item, base, true);\n }\n else {\n const newBase = registerPath(item, base);\n base = staticBase ? base : newBase;\n }\n }\n }\n };\n if (!this.projectUrl || (this.projectUrl === this.base)) {\n // If a project uses Subdirectories path type, we need to specify a projectUrl\n if (!this.projectUrl && !isProjectUrl && Formio.pathType === 'Subdirectories') {\n const regex = `^${hostName.replace(/\\//g, '\\\\/')}.[^/]+`;\n const match = project.match(new RegExp(regex));\n this.projectUrl = match ? match[0] : hostName;\n }\n else {\n this.projectUrl = hostName;\n }\n }\n // Check if we have a specified path type.\n let isNotSubdomainType = false;\n if (Formio.pathType) {\n isNotSubdomainType = Formio.pathType !== 'Subdomains';\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 }\n else if (hostName === this.base) {\n // Get project id as first part of path (subdirectory).\n if (hostparts && hostparts.length > 3 && path.split('/').length > 1) {\n const isFile = path.match(/.json/);\n const pathParts = path.split('/');\n if (isFile) {\n this.projectUrl = hostName;\n }\n else {\n pathParts.shift(); // Throw away the first /.\n const projectId = pathParts.shift();\n if (projectId) {\n this.projectId = projectId;\n path = `/${pathParts.join('/')}`;\n this.projectUrl = `${hostName}/${this.projectId}`;\n }\n }\n }\n }\n else {\n // Get project id from subdomain.\n if (hostparts && hostparts.length > 2 && (hostparts[2].split('.').length > 2 || hostName.includes('localhost')) && !isNotSubdomainType) {\n this.projectUrl = hostName;\n this.projectId = hostparts[2].split('.')[0];\n }\n }\n this.projectsUrl = this.projectsUrl || `${this.base}/project`;\n }\n // Configure Role urls and role ids.\n registerItems(['role'], this.projectUrl);\n // Configure Form urls and form ids.\n if (/(^|\\/)(form)($|\\/)/.test(path)) {\n registerItems(['form', ['submission', 'action', 'v']], this.projectUrl);\n }\n else {\n const subRegEx = new RegExp('/(submission|action|v)($|/.*)');\n const subs = path.match(subRegEx);\n if ((subs && (subs.length > 1))) {\n this.pathType = subs[1];\n }\n path = path.replace(subRegEx, '');\n path = path.replace(/\\/$/, '');\n this.formsUrl = `${this.projectUrl}/form`;\n this.formUrl = path ? this.projectUrl + path : '';\n this.formId = path.replace(/^\\/+|\\/+$/g, '');\n const items = ['submission', 'action', 'v'];\n for (const i in items) {\n if (items.hasOwnProperty(i)) {\n const item = items[i];\n this[`${item}sUrl`] = `${this.projectUrl + path}/${item}`;\n if ((this.pathType === item) && subs && (subs.length > 2) && subs[2]) {\n this[`${item}Id`] = subs[2].replace(/^\\/+|\\/+$/g, '');\n this[`${item}Url`] = this.projectUrl + path + subs[0];\n }\n }\n }\n }\n // Set the app url if it is not set.\n if (!Formio.projectUrlSet) {\n Formio.projectUrl = this.projectUrl;\n }\n }\n /* eslint-enable max-statements */\n /**\n * Deletes a remote resource of any provided type.\n *\n * @param {string} type - The type of resource to delete. \"submission\", \"form\", etc.\n * @param {object} options - The options passed to {@link Formio.request}\n * @return {Promise<Response>}\n */\n delete(type, opts) {\n const _id = `${type}Id`;\n const _url = `${type}Url`;\n if (!this[_id]) {\n return Promise.reject('Nothing to delete');\n }\n Formio.cache = {};\n return this.makeRequest(type, this[_url], 'delete', null, opts);\n }\n /**\n * Returns the index (array of records) for any provided type.\n *\n * @param {string} type - The type of resource to fetch the index of. \"submission\", \"form\", etc.\n * @param {object} query - A query object to pass to the request.\n * @param {object} query.params - A map (key-value pairs) of URL query parameters to add to the url.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n index(type, query, opts) {\n const _url = `${type}Url`;\n query = query || '';\n if (query && (0, lodash_1.isObject)(query)) {\n query = `?${Formio.serialize(query.params)}`;\n }\n return this.makeRequest(type, this[_url] + query, 'get', null, opts);\n }\n /**\n * Save a document record using \"upsert\". If the document does not exist, it will be created, if the _id is provided,\n * it will be updated.\n *\n * @param {string} type - The type of resource to fetch the index of. \"submission\", \"form\", etc.\n * @param {object} data - The resource data object.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<object>}\n */\n save(type, data, opts) {\n const _id = `${type}Id`;\n const _url = `${type}Url`;\n const method = (this[_id] || data._id) ? 'put' : 'post';\n let reqUrl = this[_id] ? this[_url] : this[`${type}sUrl`];\n if (!this[_id] && data._id && (method === 'put') && !reqUrl.includes(data._id)) {\n reqUrl += `/${data._id}`;\n }\n Formio.cache = {};\n return this.makeRequest(type, reqUrl + this.query, method, data, opts);\n }\n /**\n * @summary Load (GET) a document record.\n *\n * @param {string} type - The type of resource to fetch the index of. \"submission\", \"form\", etc.\n * @param {object} query - A query object to pass to the request.\n * @param {object} query.params - A map (key-value pairs) of URL query parameters to add to the url.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<object>}\n */\n load(type, query, opts) {\n const _id = `${type}Id`;\n const _url = `${type}Url`;\n if (query && (0, lodash_1.isObject)(query)) {\n query = Formio.serialize(query.params);\n }\n if (query) {\n query = this.query ? (`${this.query}&${query}`) : (`?${query}`);\n }\n else {\n query = this.query;\n }\n if (!this[_id]) {\n return Promise.reject(`Missing ${_id}`);\n }\n let url = this[_url] + query;\n if (type === 'form' && !isNaN(parseInt(this.vId))) {\n url += url.indexOf('?') === -1 ? '?' : '&';\n url += `formRevision=${this.vId}`;\n }\n return this.makeRequest(type, url, 'get', null, opts);\n }\n /**\n * @summary Call {@link Formio.makeRequest} for this Formio instance.\n *\n * @param {string} type - The request resource type. \"submission\", \"form\", etc.\n * @param {string} url - The URL to request.\n * @param {string} method - The request method. GET, PUT, POST, DELETE, or PATCH\n * @param {object} data - The data to pass to the request (for PUT, POST, and PATCH methods)\n * @param {object} options - An object of options to pass to the request method.\n * @param {boolean} options.ignoreCache - To ignore internal caching of the request.\n * @param {object} options.headers - An object of headers to pass along to the request.\n * @param {boolean} options.noToken - If set to true, this will not include the Form.io x-jwt-token along with the request.\n * @param {string} options.namespace - The Form.io namespace to prepend to all LocalStorage variables such as formioToken.\n * @param {boolean} options.getHeaders - Set this if you wish to include the response headers with the return of this method.\n * @return {Promise<Response>}\n */\n makeRequest(type, url, method, data, opts) {\n return Formio.makeRequest(this, type, url, method, data, opts);\n }\n /**\n * @summary Loads a project.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.loadProject().then((project) => {\n * console.log(project);\n * });\n * ```\n *\n * @param {object} query - Query parameters to pass to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n loadProject(query, opts) {\n return this.load('project', query, opts);\n }\n /**\n * Saves or Updates a project.\n *\n * ### Create a new project\n * ```ts\n * const formio = new Formio();\n * formio.saveProject({\n * title: 'My Project',\n * path: 'myproject',\n * name: 'myproject'\n * });\n * ```\n *\n * ### Update an existing project\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.loadProject().then((project) => {\n * project.title = 'Title changed';\n * formio.saveProject(project).then(() => {\n * console.log('Done saving project!');\n * });\n * });\n * ```\n *\n * @param {object} data - The project JSON to create or update.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n saveProject(data, opts) {\n return this.save('project', data, opts);\n }\n /**\n * Deletes a project\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.deleteProject();\n * ```\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n deleteProject(opts) {\n return this.delete('project', opts);\n }\n /**\n * Loads a list of all projects.\n *\n * ```ts\n * Formio.loadProjects().then((projects) => {\n * console.log(projects);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {*}\n */\n static loadProjects(query, opts) {\n query = query || '';\n if ((0, lodash_1.isObject)(query)) {\n query = `?${Formio.serialize(query.params)}`;\n }\n return Formio.makeStaticRequest(`${Formio.baseUrl}/project${query}`, 'GET', null, opts);\n }\n /**\n * Loads a role within a project.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/role/234234234234');\n * formio.loadRole().then((role) => {\n * console.log(role);\n * });\n * ```\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n loadRole(opts) {\n return this.load('role', null, opts);\n }\n /**\n * Create a new or Update an existing role within a project.\n *\n * ### Create new Role example\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.saveRole({\n * title: 'Employee',\n * description: 'A person who belongs to a company.'\n * }).then((role) => {\n * console.log(role);\n * });\n * ```\n *\n * ### Update existing role example\n * ```ts\n * const formio = new Formio('https://examples.form.io/role/234234234234234');\n * formio.loadRole().then((role) => {\n * role.title = 'Manager';\n * formio.saveRole(role).then(() => {\n * console.log('DONE');\n * });\n * });\n * ```\n *\n * @param {object} role - The Role JSON to create or update.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n saveRole(data, opts) {\n return this.save('role', data, opts);\n }\n /**\n * Deletes a role within a project.\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n deleteRole(opts) {\n return this.delete('role', opts);\n }\n /**\n * Load all roles within a project.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.loadRoles().then((roles) => {\n * console.log(roles);\n * });\n * ```\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n loadRoles(opts) {\n return this.index('roles', null, opts);\n }\n /**\n * Loads a form.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.loadForm().then((form) => {\n * console.log(form);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<object>}\n */\n loadForm(query, opts) {\n return this.load('form', query, opts)\n .then((currentForm) => {\n // Check to see if there isn't a number in vId.\n if (!currentForm.revisions || isNaN(parseInt(this.vId))) {\n return currentForm;\n }\n // If a submission already exists but form is marked to load current version of form.\n if (currentForm.revisions === 'current' && this.submissionId) {\n return currentForm;\n }\n // eslint-disable-next-line eqeqeq\n if (currentForm._vid == this.vId || currentForm.revisionId === this.vId) {\n return currentForm;\n }\n // If they specified a revision form, load the revised form components.\n if (query && (0, lodash_1.isObject)(query)) {\n query = Formio.serialize(query.params);\n }\n if (query) {\n query = this.query ? (`${this.query}&${query}`) : (`?${query}`);\n }\n else {\n query = this.query;\n }\n return this.makeRequest('form', this.vUrl + query, 'get', null, opts)\n .then((revisionForm) => {\n currentForm._vid = revisionForm._vid;\n currentForm.components = revisionForm.components;\n currentForm.settings = revisionForm.settings;\n currentForm.revisionId = revisionForm.revisionId;\n // Using object.assign so we don't cross polinate multiple form loads.\n return Object.assign({}, currentForm);\n })\n // If we couldn't load the revision, just return the original form.\n .catch(() => Object.assign({}, currentForm));\n });\n }\n /**\n * Create or Update a specific form.\n *\n * ### Create form example\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.saveForm({\n * title: 'Employee',\n * type: 'resource',\n * path: 'employee',\n * name: 'employee',\n * components: [\n * {\n * type: 'textfield',\n * key: 'firstName',\n * label: 'First Name'\n * },\n * {\n * type: 'textfield',\n * key: 'lastName',\n * label: 'Last Name'\n * }\n * ]\n * });\n * ```\n *\n * ### Update a form example\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.loadForm().then((form) => {\n * form.title = 'Changed Title';\n * formio.saveForm(form).then(() => {\n * console.log('DONE!!!');\n * });\n * });\n * ```\n *\n * @param {object} data - The Form JSON to create or update.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n saveForm(data, opts) {\n return this.save('form', data, opts);\n }\n /**\n * Deletes a form.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.deleteForm().then(() => {\n * console.log('Deleted!');\n * });\n * ```\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n deleteForm(opts) {\n return this.delete('form', opts);\n }\n /**\n * Loads all forms within a project.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.loadForms().then((forms) => {\n * console.log(forms);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n loadForms(query, opts) {\n return this.index('forms', query, opts);\n }\n /**\n * Loads a specific submissionn.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/submission/23423423423423423');\n * formio.loadSubmission().then((submission) => {\n * console.log(submission);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<object>}\n */\n loadSubmission(query, opts) {\n return this.load('submission', query, opts)\n .then((submission) => {\n this.vId = submission._frid || submission._fvid;\n this.vUrl = `${this.formUrl}/v/${this.vId}`;\n return submission;\n });\n }\n /**\n * Creates a new or Updates an existing submission.\n *\n * ### Create a new submission\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.saveSubmission({\n * data: {\n * firstName: 'Joe',\n * lastName: 'Smith'\n * }\n * }).then((submission) => {\n * // This will now be the complete submission object saved on the server.\n * console.log(submission);\n * });\n * ```\n *\n * ### Update an existing submission\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/submission/23423423423423423');\n * formio.loadSubmission().then((submission) => {\n * submission.data.lastName = 'Thompson';\n * formio.saveSubmission(submission).then(() => {\n * console.log('DONE');\n * });\n * });\n * ```\n *\n * @param {object} data - The submission JSON object.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n saveSubmission(data, opts) {\n if (!isNaN(parseInt(this.vId)) && !data._fvid) {\n data._fvid = this.vId;\n }\n return this.save('submission', data, opts);\n }\n /**\n * Deletes a submission.\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n deleteSubmission(opts) {\n return this.delete('submission', opts);\n }\n /**\n * Loads all submissions within a form.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.loadSubmissions({\n * params: {\n * limit: 25,\n * 'data.lastName__regex': 'smith'\n * }\n * }).then((submissions) => {\n * // Should print out 25 submissions where the last name contains \"smith\".\n * console.log(submissions);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n loadSubmissions(query, opts) {\n return this.index('submissions', query, opts);\n }\n /**\n * Loads a form action.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/action/234234234234');\n * formio.loadAction().then((action) => {\n * console.log(action);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n loadAction(query, opts) {\n return this.load('action', query, opts);\n }\n /**\n * Create a new or update an existing action.\n *\n * ### Create a new action for a form.\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.saveAction({\n * data: {\n * name: 'webhook',\n * title: 'Webhook Action',\n * method: ['create', 'update', 'delete'],\n * handler: ['after'],\n * condition: {},\n * settings: {\n * url: 'https://example.com',\n * headers: [{}],\n * block: false,\n * forwardHeaders: false\n * }\n * }\n * }).then((action) => {\n * console.log(action);\n * });\n * ```\n *\n * ### Update an action\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/action/234234234234');\n * formio.loadAction().then((action) => {\n * action.title = 'Updated title';\n * formio.saveAction(action).then(() => {\n * console.log('Done!');\n * });\n * });\n * ```\n *\n * @param {object} data - The action JSON\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n saveAction(data, opts) {\n return this.save('action', data, opts);\n }\n /**\n * Delete an action\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/action/234234234234');\n * formio.deleteAction().then(() => {\n * console.log('Action was deleted.');\n * });\n * ```\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n deleteAction(opts) {\n return this.delete('action', opts);\n }\n /**\n * Loads all actions within a form.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.loadActions().then((actions) => {\n * console.log(actions);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n loadActions(query, opts) {\n return this.index('actions', query, opts);\n }\n /**\n * Returns a list of available actions\n *\n * @return {Promise<Response>}\n */\n availableActions() {\n return this.makeRequest('availableActions', `${this.formUrl}/actions`);\n }\n /**\n * Returns the action information for a specific action, such as \"save\".\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/actions/save');\n * formio.actionInfo().then((info) => {\n * console.log(info);\n * });\n * ```\n *\n * @param {string} name - The name of the action you would like to get information for. i.e. \"save\", \"webhook\", etc.\n * @return {Promise<Response>}\n */\n actionInfo(name) {\n return this.makeRequest('actionInfo', `${this.formUrl}/actions/${name}`);\n }\n /**\n * Determine if a string ID is a valid MongoID.\n *\n * @param {string} id - The id that should be tested if it is avalid id.\n * @return {boolean} - true if it is a valid MongoId, false otherwise.\n */\n isObjectId(id) {\n const checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');\n return checkForHexRegExp.test(id);\n }\n /**\n * Get the project ID of project.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.getProjectId().then((projectId) => {\n * console.log(projectId);\n * };\n * ```\n *\n * @return {Promise<string>}\n */\n getProjectId() {\n if (!this.projectId) {\n return Promise.resolve('');\n }\n if (this.isObjectId(this.projectId)) {\n return Promise.resolve(this.projectId);\n }\n else {\n return this.loadProject().then((project) => {\n return project._id;\n });\n }\n }\n /**\n * Get the ID of a form.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.getFormId().then((formId) => {\n * console.log(formId);\n * });\n * ```\n *\n * @return {Promise<string>}\n */\n getFormId() {\n if (!this.formId) {\n return Promise.resolve('');\n }\n if (this.isObjectId(this.formId)) {\n return Promise.resolve(this.formId);\n }\n else {\n return this.loadForm().then((form) => {\n return form._id;\n });\n }\n }\n /**\n * Instance method for {@link Formio.currentUser}\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<object>}\n */\n currentUser(options) {\n return Formio.currentUser(this, options);\n }\n /**\n * Instance method for {@link Formio.accessInfo}\n *\n * @return {Promise<Response>}\n */\n accessInfo() {\n return Formio.accessInfo(this);\n }\n /**\n * Sets OAuth Logout URL.\n *\n * @param {string} uri - Logout URL.\n * @param {string} options.namespace - The localStorage namespace to use when retrieving tokens from storage.\n * @return {string}\n */\n oauthLogoutURI(uri, options) {\n return Formio.oauthLogoutURI(uri, Object.assign({ formio: this }, this.options, options));\n }\n /**\n * Returns the JWT token for this instance.\n *\n * @param {object} options - The following options are provided.\n * @param {string} options.namespace - The localStorage namespace to use when retrieving tokens from storage.\n * @return {string} - The JWT token for this user.\n */\n getToken(options) {\n return Formio.getToken(Object.assign({ formio: this }, this.options, options));\n }\n /**\n * Sets the JWT token for this instance.\n *\n * @param {string} token - The JWT token to set.\n * @param {object} options - The following options are provided.\n * @param {string} options.namespace - The localStorage namespace to use when retrieving tokens from storage.\n * @return {string} - The JWT token that was set.\n */\n setToken(token, options) {\n return Formio.setToken(token, Object.assign({ formio: this }, this.options, options));\n }\n /**\n * Returns a temporary authentication token for single purpose token generation.\n *\n * @param {number|string} expire - The amount of seconds to wait before this temp token expires.\n * @param {string} allowed - The allowed path string inn the format GET:/path\n * @param {object} options - The options passed to {@link Formio#getToken}\n */\n getTempToken(expire, allowed, options) {\n const token = Formio.getToken(options);\n if (!token) {\n return Promise.reject('You must be authenticated to generate a temporary auth token.');\n }\n const authUrl = Formio.authUrl || this.projectUrl;\n return this.makeRequest('tempToken', `${authUrl}/token`, 'GET', null, {\n ignoreCache: true,\n header: new Headers({\n 'x-expire': expire,\n 'x-allow': allowed\n })\n });\n }\n /**\n * Get a PDF download url for a submission, which will generate a new PDF of the submission. This method will first\n * fetch a temporary download token, and then append this to the download url for this form.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/submission/324234234234234');\n * formio.getDownloadUrl().then((url) => {\n * console.log(url);\n * });\n * ```\n *\n * @param {object} [form] - The form JSON to fetch a download url for.\n * @return {Promise<string>} - The download url.\n */\n getDownloadUrl(form) {\n if (!this.submissionId) {\n return Promise.resolve('');\n }\n if (!form) {\n // Make sure to load the form first.\n return this.loadForm().then((_form) => {\n if (!_form) {\n return '';\n }\n return this.getDownloadUrl(_form);\n });\n }\n let apiUrl = `/project/${form.project}`;\n apiUrl += `/form/${form._id}`;\n apiUrl += `/submission/${this.submissionId}`;\n const postfix = form.submissionRevisions && form.settings.changeLog ? '/download/changelog' : '/download';\n apiUrl += postfix;\n let download = this.base + apiUrl;\n return new Promise((resolve, reject) => {\n this.getTempToken(3600, `GET:${apiUrl}`).then((tempToken) => {\n download += `?token=${tempToken.key}`;\n resolve(download);\n }, () => {\n resolve(download);\n }).catch(reject);\n });\n }\n /**\n * Returns the user permissions to a form and submission.\n *\n * @param user - The user or current user if undefined. For anonymous, use \"null\"\n * @param form - The form or current form if undefined. For no form check, use \"null\"\n * @param submission - The submisison or \"index\" if undefined.\n *\n * @return {{create: boolean, read: boolean, edit: boolean, delete: boolean}}\n */\n userPermissions(user, form, submission) {\n return Promise.all([\n (form !== undefined) ? Promise.resolve(form) : this.loadForm(),\n (user !== undefined) ? Promise.resolve(user) : this.currentUser(),\n (submission !== undefined || !this.submissionId) ? Promise.resolve(submission) : this.loadSubmission(),\n this.accessInfo()\n ]).then((results) => {\n const form = results.shift();\n const user = results.shift() || { _id: false, roles: [] };\n const submission = results.shift();\n const access = results.shift();\n const permMap = {\n create: 'create',\n read: 'read',\n update: 'edit',\n delete: 'delete'\n };\n const perms = {\n user: user,\n form: form,\n access: access,\n create: false,\n read: false,\n edit: false,\n delete: false\n };\n for (const roleName in access.roles) {\n if (access.roles.hasOwnProperty(roleName)) {\n const role = access.roles[roleName];\n if (role.default && (user._id === false)) {\n // User is anonymous. Add the anonymous role.\n user.roles.push(role._id);\n }\n else if (role.admin && user.roles.indexOf(role._id) !== -1) {\n perms.create = true;\n perms.read = true;\n perms.delete = true;\n perms.edit = true;\n return perms;\n }\n }\n }\n if (form && form.submissionAccess) {\n for (let i = 0; i < form.submissionAccess.length; i++) {\n const permission = form.submissionAccess[i];\n const [perm, scope] = permission.type.split('_');\n if (['create', 'read', 'update', 'delete'].includes(perm)) {\n if ((0, lodash_1.intersection)(permission.roles, user.roles).length) {\n perms[permMap[perm]] = (scope === 'all') || (!submission || (user._id === submission.owner));\n }\n }\n }\n }\n // check for Group Permissions\n if (submission) {\n // we would anyway need to loop through components for create permission, so we'll do that for all of them\n (0, formUtil_1.eachComponent)(form.components, (component, path) => {\n if (component && component.defaultPermission) {\n const value = (0, lodash_1.get)(submission.data, path);\n // make it work for single-select Group and multi-select Group\n const groups = Array.isArray(value) ? value : [value];\n groups.forEach(group => {\n if (group && group._id && // group id is present\n user.roles.indexOf(group._id) > -1 // user has group id in his roles\n ) {\n if (component.defaultPermission === 'read') {\n perms[permMap.read] = true;\n }\n if (component.defaultPermission === 'create') {\n perms[permMap.create] = true;\n perms[permMap.read] = true;\n }\n if (component.defaultPermission === 'write') {\n perms[permMap.create] = true;\n perms[permMap.read] = true;\n perms[permMap.update] = true;\n }\n if (component.defaultPermission === 'admin') {\n perms[permMap.create] = true;\n perms[permMap.read] = true;\n perms[permMap.update] = true;\n perms[permMap.delete] = true;\n }\n }\n });\n }\n });\n }\n return perms;\n });\n }\n /**\n * `Determine if the current user can submit a form.\n * @return {*}\n */\n canSubmit() {\n return this.userPermissions().then((perms) => {\n // If there is user and they cannot create, then check anonymous user permissions.\n if (!perms.create && Formio.getUser()) {\n return this.userPermissions(null).then((anonPerms) => {\n if (anonPerms.create) {\n Formio.setUser(null);\n return true;\n }\n return false;\n });\n }\n return perms.create;\n });\n }\n getUrlParts(url) {\n return Formio.getUrlParts(url, this);\n }\n static getUrlParts(url, formio) {\n const base = (formio && formio.base) ? formio.base : Formio.baseUrl;\n let regex = '^(http[s]?:\\\\/\\\\/)';\n if (base && url.indexOf(base) === 0) {\n regex += `(${base.replace(/^http[s]?:\\/\\//, '')})`;\n }\n else {\n regex += '([^/]+)';\n }\n regex += '($|\\\\/.*)';\n return url.match(new RegExp(regex));\n }\n static serialize(obj, _interpolate) {\n const str = [];\n const interpolate = (item) => {\n return _interpolate ? _interpolate(item) : item;\n };\n for (const p in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, p)) {\n str.push(`${encodeURIComponent(p)}=${encodeURIComponent(interpolate(obj[p]))}`);\n }\n }\n return str.join('&');\n }\n static getRequestArgs(formio, type, url, method, data, opts) {\n method = (method || 'GET').toUpperCase();\n if (!opts || !(0, lodash_1.isObject)(opts)) {\n opts = {};\n }\n const requestArgs = {\n url,\n method,\n data: data || null,\n opts\n };\n if (type) {\n requestArgs.type = type;\n }\n if (formio) {\n requestArgs.formio = formio;\n }\n return requestArgs;\n }\n static makeStaticRequest(url, method, data, opts) {\n const requestArgs = Formio.getRequestArgs(null, '', url, method, data, opts);\n const request = Plugins_1.default.pluginWait('preRequest', requestArgs)\n .then(() => Plugins_1.default.pluginGet('staticRequest', requestArgs)\n .then((result) => {\n if ((0, lodash_1.isNil)(result)) {\n return Formio.request(requestArgs.url, requestArgs.method, requestArgs.data, requestArgs.opts.header, requestArgs.opts);\n }\n return result;\n }));\n return Plugins_1.default.pluginAlter('wrapStaticRequestPromise', request, requestArgs);\n }\n /**\n * Make an API request and wrap that request with the Form.io Request plugin system. This is very similar to the\n * {Formio.request} method with a difference being that it will pass the request through the Form.io request plugin.\n *\n * @param {Formio} formio - An instance of the Formio class.\n * @param {string} type - The request resource type. \"submission\", \"form\", etc.\n * @param {string} url - The URL to request.\n * @param {string} method - The request method. GET, PUT, POST, DELETE, or PATCH\n * @param {object} data - The data to pass to the request (for PUT, POST, and PATCH methods)\n * @param {object} options - An object of options to pass to the request method.\n * @param {boolean} options.ignoreCache - To ignore internal caching of the request.\n * @param {object} options.headers - An object of headers to pass along to the request.\n * @param {boolean} options.noToken - If set to true, this will not include the Form.io x-jwt-token along with the request.\n * @param {string} options.namespace - The Form.io namespace to prepend to all LocalStorage variables such as formioToken.\n * @param {boolean} options.getHeaders - Set this if you wish to include the response headers with the return of this method.\n * @return {Promise<Response>}\n */\n static makeRequest(formio, type, url, method, data, opts) {\n if (!formio) {\n return Formio.makeStaticRequest(url, method, data, opts);\n }\n const requestArgs = Formio.getRequestArgs(formio, type, url, method, data, opts);\n requestArgs.opts = requestArgs.opts || {};\n requestArgs.opts.formio = formio;\n //for Formio requests default Accept and Content-type headers\n if (!requestArgs.opts.headers) {\n requestArgs.opts.headers = {};\n }\n requestArgs.opts.headers = (0, lodash_1.defaults)(requestArgs.opts.headers, {\n 'Accept': 'application/json',\n 'Content-type': 'application/json'\n });\n const request = Plugins_1.default.pluginWait('preRequest', requestArgs)\n .then(() => Plugins_1.default.pluginGet('request', requestArgs)\n .then((result) => {\n if ((0, lodash_1.isNil)(result)) {\n return Formio.request(requestArgs.url, requestArgs.method, requestArgs.data, requestArgs.opts.header, requestArgs.opts);\n }\n return result;\n }));\n return Plugins_1.default.pluginAlter('wrapRequestPromise', request, requestArgs);\n }\n /**\n * Execute an API request to any external system. This is a wrapper around the Web fetch method.\n *\n * ```ts\n * Formio.request('https://examples.form.io').then((form) => {\n * console.log(form);\n * });\n * ```\n *\n * @param {string} url - The URL to request.\n * @param {string} method - The request method. GET, PUT, POST, DELETE, or PATCH\n * @param {object} data - The data to pass to the request (for PUT, POST, and PATCH methods)\n * @param {Headers} header - An object of headers to pass to the request.\n * @param {object} options - An object of options to pass to the request method.\n * @param {boolean} options.ignoreCache - To ignore internal caching of the request.\n * @param {object} options.headers - An object of headers to pass along to the request.\n * @param {boolean} options.noToken - If set to true, this will not include the Form.io x-jwt-token along with the request.\n * @param {string} options.namespace - The Form.io namespace to prepend to all LocalStorage variables such as formioToken.\n * @param {boolean} options.getHeaders - Set this if you wish to include the response headers with the return of this method.\n * @return {Promise<Response>|*}\n */\n static request(url, method, data, header, opts) {\n if (!url) {\n return Promise.reject('No url provided');\n }\n method = (method || 'GET').toUpperCase();\n // For reverse compatibility, if they provided the ignoreCache parameter,\n // then change it back to the options format where that is a parameter.\n if ((0, lodash_1.isBoolean)(opts)) {\n opts = { ignoreCache: opts };\n }\n if (!opts || !(0, lodash_1.isObject)(opts)) {\n opts = {};\n }\n // Generate a cachekey.\n const cacheKey = btoa(encodeURI(url));\n // Get the cached promise to save multiple loads.\n if (!opts.ignoreCache && method === 'GET' && Formio.cache.hasOwnProperty(cacheKey)) {\n return Promise.resolve(Formio.cloneResponse(Formio.cache[cacheKey]));\n }\n if (url[0] === '/') {\n url = Formio.baseUrl + url;\n }\n // Set up and fetch request\n const headers = header || new Headers(opts.headers || {\n 'Accept': 'application/json',\n 'Content-type': 'application/json'\n });\n const token = Formio.getToken(opts);\n if (token && !opts.noToken) {\n headers.set('x-jwt-token', token);\n }\n // The fetch-ponyfill can't handle a proper Headers class anymore. Change it back to an object.\n const headerObj = {};\n headers.forEach(function (value, name) {\n headerObj[name] = value;\n });\n let options = {\n method: method,\n headers: headerObj,\n mode: 'cors'\n };\n if (data) {\n options.body = JSON.stringify(data);\n }\n // Allow plugins to alter the options.\n options = Plugins_1.default.pluginAlter('requestOptions', options, url);\n if (options.namespace || Formio.namespace) {\n opts.namespace = options.namespace || Formio.namespace;\n }\n const requestToken = options.headers['x-jwt-token'];\n const result = Plugins_1.default.pluginAlter('wrapFetchRequestPromise', Formio.fetch(url, options), { url, method, data, opts }).then((response) => {\n // Allow plugins to respond.\n response = Plugins_1.default.pluginAlter('requestResponse', response, Formio, data);\n if (!response.ok) {\n if (response.status === 440) {\n Formio.setToken(null, opts);\n Formio.events.emit('formio.sessionExpired', response.body || response);\n }\n else if (response.status === 401) {\n Formio.events.emit('formio.unauthorized', response.body || response);\n }\n else if (response.status === 416) {\n Formio.events.emit('formio.rangeIsNotSatisfiable', response.body || response);\n }\n else if (response.status === 504) {\n return Promise.reject(new Error('Network request failed'));\n }\n // Parse and return the error as a rejected promise to reject this promise\n return (response.headers.get('content-type').includes('application/json')\n ? response.json()\n : response.text())\n .then((error) => {\n return Promise.reject(error);\n });\n }\n // Handle fetch results\n const respToken = response.headers.get('x-jwt-token');\n // In some strange cases, the fetch library will return an x-jwt-token without sending\n // one to the server. This has even been debugged on the server to verify that no token\n // was introduced with the request, but the response contains a token. This is an Invalid\n // case where we do not send an x-jwt-token and get one in return for any GET request.\n let tokenIntroduced = false;\n if ((method === 'GET') &&\n !requestToken &&\n respToken &&\n !opts.external &&\n !url.includes('token=') &&\n !url.includes('x-jwt-token=')) {\n console.warn('Token was introduced in request.');\n tokenIntroduced = true;\n }\n if (response.status >= 200 &&\n response.status < 300 &&\n respToken &&\n respToken !== '' &&\n !tokenIntroduced) {\n Formio.setToken(respToken, Object.assign(Object.assign({}, opts), { fromCurrent: (opts.fromCurrent || !!requestToken) }));\n }\n // 204 is no content. Don't try to .json() it.\n if (response.status === 204) {\n return {};\n }\n const getResult = response.headers.get('content-type').includes('application/json')\n ? response.json()\n : response.text();\n return getResult.then((result) => {\n // Add some content-range metadata to the result here\n let range = response.headers.get('content-range');\n if (range && (0, lodash_1.isObject)(result)) {\n range = range.split('/');\n if (range[0] !== '*') {\n const skipLimit = range[0].split('-');\n result.skip = Number(skipLimit[0]);\n result.limit = skipLimit[1] - skipLimit[0] + 1;\n }\n result.serverCount = range[1] === '*' ? range[1] : Number(range[1]);\n }\n if (!opts.getHeaders) {\n return result;\n }\n const headers = {};\n response.headers.forEach((item, key) => {\n headers[key] = item;\n });\n // Return the result with the headers.\n return {\n result,\n headers,\n };\n });\n })\n .then((result) => {\n if (opts.getHeaders) {\n return result;\n }\n // Cache the response.\n if (method === 'GET') {\n Formio.cache[cacheKey] = result;\n }\n return Formio.cloneResponse(result);\n })\n .catch((err) => {\n if (err === 'Bad Token' && opts.noToken !== false) {\n Formio.setToken(null, opts);\n Formio.events.emit('formio.badToken', err);\n }\n if (err.message) {\n err = new Error(`Could not connect to API server (${err.message}): ${url}`);\n err.networkError = true;\n }\n if (method === 'GET') {\n delete Formio.cache[cacheKey];\n }\n return Promise.reject(err);\n });\n return result;\n }\n // Needed to maintain reverse compatability...\n static get token() {\n return Formio.tokens.formioToken || '';\n }\n // Needed to maintain reverse compatability...\n static set token(token) {\n Formio.tokens.formioToken = token || '';\n }\n static useSessionToken(options) {\n if (typeof localStorage === 'undefined') {\n return;\n }\n let namespace = options;\n if (typeof options === 'object') {\n options = options.namespace;\n }\n const tokenName = `${namespace || Formio.namespace || 'formio'}Token`;\n const token = localStorage.getItem(tokenName);\n if (token) {\n localStorage.removeItem(tokenName);\n sessionStorage.setItem(tokenName, token);\n }\n const userName = `${namespace || Formio.namespace || 'formio'}User`;\n const user = localStorage.getItem(userName);\n if (user) {\n localStorage.removeItem(userName);\n sessionStorage.setItem(userName, user);\n }\n localStorage.setItem('useSessionToken', 'true');\n }\n /**\n * Sets the JWT in storage to be used within an application.\n *\n * @param {string} token - The JWT token to set.\n * @param {object} options - Options as follows\n * @param {string} options.namespace - The namespace to save the token within. i.e. \"formio\"\n * @param {Formio} options.formio - The Formio instance.\n * @return {Promise<object>|void}\n */\n static setToken(token = '', opts = {}) {\n token = token || '';\n opts = (typeof opts === 'string') ? { namespace: opts } : opts || {};\n const tokenName = `${opts.namespace || Formio.namespace || 'formio'}Token`;\n if (!Formio.tokens) {\n Formio.tokens = {};\n }\n const storage = localStorage.getItem('useSessionToken') ? sessionStorage : localStorage;\n if (!token) {\n if (!opts.fromUser) {\n opts.fromToken = true;\n Formio.setUser(null, opts);\n }\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n storage.removeItem(tokenName);\n }\n catch (err) {\n browser_cookies_1.default.erase(tokenName, { path: '/' });\n }\n Formio.tokens[tokenName] = token;\n return Promise.resolve(null);\n }\n if (Formio.tokens[tokenName] !== token) {\n Formio.tokens[tokenName] = token;\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n storage.setItem(tokenName, token);\n }\n catch (err) {\n browser_cookies_1.default.set(tokenName, token, { path: '/' });\n }\n }\n // Return or updates the current user\n return Formio.currentUser(opts.formio, opts);\n }\n /**\n * Returns the token set within the application for the user.\n *\n * @param {object} options - The options as follows.\n * @param {string} options.namespace - The namespace of the token you wish to fetch.\n * @param {boolean} options.decode - If you would like the token returned as decoded JSON.\n * @return {*}\n */\n static getToken(options) {\n options = (typeof options === 'string') ? { namespace: options } : options || {};\n const tokenName = `${options.namespace || Formio.namespace || 'formio'}Token`;\n const decodedTokenName = options.decode ? `${tokenName}Decoded` : tokenName;\n if (!Formio.tokens) {\n Formio.tokens = {};\n }\n if (Formio.tokens[decodedTokenName]) {\n return Formio.tokens[decodedTokenName];\n }\n try {\n const token = localStorage.getItem('useSessionToken')\n ? sessionStorage.getItem(tokenName)\n : localStorage.getItem(tokenName);\n Formio.tokens[tokenName] = token || '';\n if (options.decode) {\n Formio.tokens[decodedTokenName] = Formio.tokens[tokenName] ? (0, jwtDecode_1.jwtDecode)(Formio.tokens[tokenName]) : {};\n return Formio.tokens[decodedTokenName];\n }\n return Formio.tokens[tokenName];\n }\n catch (e) {\n Formio.tokens[tokenName] = browser_cookies_1.default.get(tokenName);\n return '';\n }\n }\n /**\n * Sets the current user within the application cache.\n *\n * @param {object} user - JSON object of the user you wish to set.\n * @param {object} options - Options as follows\n * @param {string} options.namespace - The namespace of the tokens\n */\n static setUser(user, opts = {}) {\n const userName = `${opts.namespace || Formio.namespace || 'formio'}User`;\n const storage = localStorage.getItem('useSessionToken') ? sessionStorage : localStorage;\n if (!user) {\n if (!opts.fromToken) {\n opts.fromUser = true;\n Formio.setToken(null, opts);\n }\n // Emit an event on the cleared user.\n Formio.events.emit('formio.user', null);\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n return storage.removeItem(userName);\n }\n catch (err) {\n return browser_cookies_1.default.erase(userName, { path: '/' });\n }\n }\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n storage.setItem(userName, JSON.stringify(user));\n }\n catch (err) {\n browser_cookies_1.default.set(userName, JSON.stringify(user), { path: '/' });\n }\n // Emit an event on the authenticated user.\n Formio.events.emit('formio.user', user);\n }\n /**\n * Returns the user JSON.\n *\n * @param {object} options - Options as follows\n * @param {string} namespace - The namespace of the tokens stored within this application.\n * @return {object} - The user object.\n */\n static getUser(options) {\n options = options || {};\n const userName = `${options.namespace || Formio.namespace || 'formio'}User`;\n try {\n return JSON.parse((localStorage.getItem('useSessionToken')\n ? sessionStorage\n : localStorage).getItem(userName) || '');\n }\n catch (e) {\n return JSON.parse(browser_cookies_1.default.get(userName));\n }\n }\n /**\n * Sets the BaseURL for the application.\n *\n * @description Every application developed using the JavaScript SDK must set both the {@link Formio.setBaseUrl} and\n * {@link Formio.setProjectUrl} methods. These two functions ensure that every URL passed into the constructor of this\n * class can determine the \"project\" context for which the application is running.\n *\n * Any Open Source server applications will set both the {@link Formio.setBaseUrl} and {@link Formio.setProjectUrl}\n * values will be the same value.\n *\n * ```ts\n * Formio.setBaseUrl('https://yourwebsite.com/forms');\n * Formio.setProjectUrl('https://yourwebsite.com/forms/project');\n *\n * // Now the Formio constructor will know what is the \"project\" and what is the form alias name. Without setBaseUrl\n * // and setProjectUrl, this would throw an error.\n *\n * const formio = new Formio('https://yourwebsite.com/forms/project/user');\n * formio.loadForm().then((form) => {\n * console.log(form);\n * });\n * ```\n *\n * @param {string} url - The URL of the Base API url.\n */\n static setBaseUrl(url) {\n Formio.baseUrl = url;\n if (!Formio.projectUrlSet) {\n Formio.projectUrl = url;\n }\n }\n /**\n * Returns the current base url described at {@link Formio.setBaseUrl}\n *\n * @return {string} - The base url of the application.\n */\n static getBaseUrl() {\n return Formio.baseUrl;\n }\n static setApiUrl(url) {\n return Formio.setBaseUrl(url);\n }\n static getApiUrl() {\n return Formio.getBaseUrl();\n }\n static setAppUrl(url) {\n console.warn('Formio.setAppUrl() is deprecated. Use Formio.setProjectUrl instead.');\n Formio.projectUrl = url;\n Formio.projectUrlSet = true;\n }\n /**\n * Sets the Project Url for the application. This is an important method that needs to be set for all applications. It\n * is documented @ {@link Formio.setBaseUrl}.\n *\n * @param {string} url - The project api url.\n */\n static setProjectUrl(url) {\n Formio.projectUrl = url;\n Formio.projectUrlSet = true;\n }\n /**\n * The Auth URL can be set to customize the authentication requests made from an application. By default, this is\n * just the same value as {@link Formio.projectUrl}\n *\n * @param {string} url - The authentication url\n */\n static setAuthUrl(url) {\n Formio.authUrl = url;\n }\n static getAppUrl() {\n console.warn('Formio.getAppUrl() is deprecated. Use Formio.getProjectUrl instead.');\n return Formio.projectUrl;\n }\n /**\n * Returns the Project url described at {@link Formio.setProjectUrl}\n *\n * @return {string|string} - The Project Url.\n */\n static getProjectUrl() {\n return Formio.projectUrl;\n }\n /**\n * Clears the runtime internal API cache.\n *\n * @description By default, the Formio class will cache all API requests in memory so that any subsequent requests\n * using GET method will return the cached results as long as the API URl is the same as what was cached previously.\n * This cache can be cleared using this method as follows.\n *\n * ```ts\n * Formio.clearCache();\n * ```\n *\n * Or, if you just wish to clear a single request, then the {@link Formio.request#options.ignoreCache} option can be\n * provided when making an API request as follows.\n *\n * ```ts\n * Formio.loadForm({}, {\n * ignoreCache: true\n * }).then((form) => {\n * console.log(form);\n * });\n * ```\n *\n * Both of the following will ensure that a new request is made to the API server and that the results will not be\n * from the cached result.\n */\n static clearCache() {\n Formio.cache = {};\n }\n /**\n * Return the access information about a Project, such as the Role ID's for that project, and if the server is\n * configured to do so, the Form and Resource access configurations that the authenticated user has access to.\n *\n * @description This is useful for an application to determine the UI for a specific user to identify which forms they have\n * access to submit or read.\n *\n * @param {Formio} formio - The Formio instance.\n * @return {Promise<Response>}\n */\n static accessInfo(formio) {\n const projectUrl = formio ? formio.projectUrl : Formio.projectUrl;\n return Formio.makeRequest(formio, 'accessInfo', `${projectUrl}/access`);\n }\n /**\n * Returns an array of roles for the project, which includes the ID's and names of those roles.\n *\n * @param {Formio} formio - The Formio instance.\n * @return {Promise<Response>}\n */\n static projectRoles(formio) {\n const projectUrl = formio ? formio.projectUrl : Formio.projectUrl;\n return Formio.makeRequest(formio, 'projectRoles', `${projectUrl}/role`);\n }\n /**\n * Return the currentUser object. This will fetch the user from the server and respond with the Submission JSON\n * of that user object.\n *\n * @param {Formio} formio - The Formio instance\n * @param {object} options - The options passed to {@link Formio.getUser}\n * @return {Promise<R>|*}\n */\n static currentUser(formio, options = {}) {\n let authUrl = Formio.authUrl;\n if (!authUrl) {\n authUrl = formio ? formio.projectUrl : (Formio.projectUrl || Formio.baseUrl);\n }\n authUrl += '/current';\n if (!options.ignoreCache || options.fromCurrent) {\n const user = Formio.getUser(options);\n if (user) {\n return Plugins_1.default.pluginAlter('wrapStaticRequestPromise', Promise.resolve(user), {\n url: authUrl,\n method: 'GET',\n options\n });\n }\n }\n const token = Formio.getToken(options);\n if ((!options || !options.external) && !token) {\n return Plugins_1.default.pluginAlter('wrapStaticRequestPromise', Promise.resolve(null), {\n url: authUrl,\n method: 'GET',\n options\n });\n }\n options.fromCurrent = true;\n return Formio.makeRequest(formio, 'currentUser', authUrl, 'GET', null, options)\n .then((response) => {\n Formio.setUser(response, options);\n return response;\n });\n }\n /**\n * Performs a logout of the Form.io application. This will reset all cache, as well as make a request to the logout\n * endpoint of the Form.io api platform.\n *\n * @param {Formio} formio - A Formio instance.\n * @param {object} options - Options passed to both {@link Formio.setToken} as well as {@link Formio.setUser}\n * @return {Promise<Response>}\n */\n static logout(formio, options = {}) {\n options.formio = formio;\n const projectUrl = Formio.authUrl ? Formio.authUrl : (formio ? formio.projectUrl : Formio.baseUrl);\n const logout = () => {\n Formio.setToken(null, options);\n Formio.setUser(null, options);\n Formio.clearCache();\n localStorage.removeItem('useSessionToken');\n };\n return Formio.makeRequest(formio, 'logout', `${projectUrl}/logout`)\n .then(function (result) {\n logout();\n if (result.shouldRedirect && result.url) {\n window.location.href = result.url;\n }\n return result;\n })\n .catch(function (err) {\n logout();\n throw err;\n });\n }\n /**\n * Returns the query passed to a page in JSON object format.\n *\n * @description For example, lets say you visit your application using\n * the url as follows.\n *\n * ```\n * https://yourapplication.com/?token=23423423423&username=Joe\n * ```\n *\n * The following code will provide your application with the following.\n *\n * ```ts\n * const query Formio.pageQuery();\n * console.log(query.token); // Will print 23423423423\n * console.log(query.username); // Will print Joe\n * ```\n *\n * @return {{}} - A JSON object representation of the query that was passed to the URL of an application.\n */\n static pageQuery() {\n const pageQuery = {};\n pageQuery.paths = [];\n const hashes = location.hash.substr(1).replace(/\\?/g, '&').split('&');\n let parts = [];\n location.search.substr(1).split('&').forEach(function (item) {\n parts = item.split('=');\n if (parts.length > 1) {\n pageQuery[parts[0]] = parts[1] && decodeURIComponent(parts[1]);\n }\n });\n hashes.forEach(function (item) {\n parts = item.split('=');\n if (parts.length > 1) {\n pageQuery[parts[0]] = parts[1] && decodeURIComponent(parts[1]);\n }\n else if (item.indexOf('/') === 0) {\n pageQuery.paths = item.substr(1).split('/');\n }\n });\n return pageQuery;\n }\n /**\n * Much like {@link Formio.currentUser}, but instead automatically injects the Bearer tokens into the headers to\n * perform a Token swap of the OAuth token which will then return the JWT token for that user.\n *\n * @param {Formio} formio - The Formio instance\n * @param {string} token - An OAuth Bearer token to use for a token swap between the OAuth provider and Form.io\n * @return {Promise<R>|*}\n */\n static oAuthCurrentUser(formio, token) {\n return Formio.currentUser(formio, {\n external: true,\n headers: {\n Authorization: `Bearer ${token}`\n }\n });\n }\n static oauthLogoutURI(uri, options) {\n options = (typeof options === 'string') ? { namespace: options } : options || {};\n const logoutURIName = `${options.namespace || Formio.namespace || 'formio'}LogoutAuthUrl`;\n Formio.tokens[logoutURIName];\n localStorage.setItem(logoutURIName, uri);\n return Formio.tokens[logoutURIName];\n }\n /**\n * Perform a SAML initialization.\n *\n * @description Typically, you would use the {@link Formio.ssoInit} method to perform this function\n * since this method is an alias for the following.\n *\n * ```ts\n * Formio.samlInit();\n * Formio.ssoInit('saml'); // This is the exact same thing as calling Formio.samlInit\n * ```\n *\n * This method will return false if the process is just starting. The code below is a typical block of code that is\n * used to automatically trigger the SAML authentication process within your application using a Button component.\n *\n * ```ts\n * if (Formio.pageQuery().saml) {\n * const sso = Formio.samlInit();\n * if (sso) {\n * sso.then((user) => {\n * // The SSO user is now loaded!\n * console.log(user);\n * });\n * }\n * }\n * ```\n *\n * You can then place the following code withiin the \"Custom\" action of a Button component on your form.\n *\n * ```ts\n * Formio.samlInit();\n * ```\n *\n * Now when you click on this button, it will start the handshake process with SAML, and once it returns, will pass\n * a \"saml\" query parameter back to your application which will execute the code to load the current user from SAML.\n *\n * @param {object} options - Options to pass to the SAML initialization process.\n * @param {string} options.relay - The URL that will be used as the authentication \"relay\" that occurs during a SAML handshake process.\n * @return {boolean|Promise<Object>|void}\n */\n static samlInit(options = {}) {\n const query = Formio.pageQuery();\n if (query.saml) {\n Formio.setUser(null);\n const retVal = Formio.setToken(query.saml);\n let uri = window.location.toString();\n uri = uri.substring(0, uri.indexOf('?'));\n if (window.location.hash) {\n uri += window.location.hash;\n }\n window.history.replaceState({}, document.title, uri);\n return retVal;\n }\n // Set the relay if not provided.\n if (!options.relay) {\n options.relay = window.location.href;\n }\n // go to the saml sso endpoint for this project.\n const authUrl = Formio.authUrl || Formio.projectUrl;\n window.location.href = `${authUrl}/saml/sso?relay=${encodeURI(options.relay)}`;\n return false;\n }\n /**\n * Perform an Okta Authentication process using the {@link https://developer.okta.com/code/javascript/okta_auth_sdk|Okta SDK}.\n *\n * @description This method does require that you first include the Okta JavaScript SDK within your application as follows.\n *\n * First you need to include the Okta Authentication script.\n *\n * ```html\n * <script src=\"https://ok1static.oktacdn.com/assets/js/sdk/okta-auth-js/2.0.1/okta-auth-js.min.js\" type=\"text/javascript\"></script>\n * ```\n *\n * Then you can call this method as follows.\n *\n * ```ts\n * Formio.oktaInit();\n * ```\n *\n * @param {object} options - Options that are passed directly to the {@link https://github.com/okta/okta-auth-js#configuration-reference|Okta SDK constructor}\n * @param {constructor} options.OktaAuth - If the OktaAuth constructor is not provided global to the application, it can be provided to this method using this property.\n * @param {Formio} options.formio - The Formio instance.\n * @param {Array<string>} options.scopes - Scopes that are passed to the {@link https://github.com/okta/okta-auth-js#tokengetwithredirectoptions|getWithRedirect} method from the Okta SDK.\n * @return {Promise<Object>}\n */\n static oktaInit(options = {}) {\n if (typeof OktaAuth !== undefined) {\n options.OktaAuth = OktaAuth;\n }\n if (typeof options.OktaAuth === undefined) {\n const errorMessage = 'Cannot find OktaAuth. Please include the Okta JavaScript SDK within your application. See https://developer.okta.com/code/javascript/okta_auth_sdk for an example.';\n console.warn(errorMessage);\n return Promise.reject(errorMessage);\n }\n return new Promise((resolve, reject) => {\n const Okta = options.OktaAuth;\n delete options.OktaAuth;\n const authClient = new Okta(options);\n authClient.tokenManager.get('accessToken')\n .then((accessToken) => {\n if (accessToken) {\n resolve(Formio.oAuthCurrentUser(options.formio, accessToken.accessToken));\n }\n else if (location.hash) {\n authClient.token.parseFromUrl()\n .then((token) => {\n authClient.tokenManager.add('accessToken', token);\n resolve(Formio.oAuthCurrentUser(options.formio, token.accessToken));\n })\n .catch((err) => {\n console.warn(err);\n reject(err);\n });\n }\n else {\n authClient.token.getWithRedirect({\n responseType: 'token',\n scopes: options.scopes\n });\n resolve(false);\n }\n })\n .catch((error) => {\n reject(error);\n });\n });\n }\n /**\n * A common static method to trigger any SSO processes. This method is really just an alias for other static methods.\n *\n * @param {('saml'|'okta')} type - The type of SSO to trigger. 'saml' is an alias for {@link Formio.samlInit}, and 'okta' is an alias for {@link Formio.oktaInit}.\n * @param {object} options - Options to pass to the specific sso methods\n * @return {*|Promise<Object>|boolean|void}\n */\n static ssoInit(type, options = {}) {\n switch (type) {\n case 'saml':\n return Formio.samlInit(options);\n case 'okta':\n return Formio.oktaInit(options);\n default:\n console.warn('Unknown SSO type');\n return Promise.reject('Unknown SSO type');\n }\n }\n /**\n * Lazy load a remote library dependency.\n *\n * @description This is useful for components that wish to lazy load a required library\n * by adding that library to the <scripts> section of the HTML webpage, and then provide a promise that will resolve\n * when the library becomes available for use.\n *\n * @example Load Google Maps API.\n * ```ts\n * Formio.requireLibrary('googleMaps', 'google.maps.Map', 'https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap', true).then(() => {\n * // Once the promise resolves, the following can now be used within your application.\n * const map = new google.maps.Map(document.getElementById(\"map\"), {...});\n * });\n * ```\n *\n * @param {string} name - The internal name to give to the library you are loading. This is useful for caching the library for later use.\n * @param {string} property - The name of the global property that will be added to the global namespace once the library has been loaded. This is used to check to see if the property exists before resolving the promise that the library is ready for use.\n * @param {string} src - The URL of the library to lazy load.\n * @param {boolean} polling - Determines if polling should be used to determine if they library is ready to use. If set to false, then it will rely on a global callback called ${name}Callback where \"name\" is the first property passed to this method. When this is called, that will indicate when the library is ready. In most cases, you will want to pass true to this parameter to initiate a polling method to check for the library availability in the global context.\n * @return {Promise<object>} - A promise that will resolve when the plugin is ready to be used.\n */\n static requireLibrary(name, property, src, polling = false, onload) {\n if (!Formio.libraries.hasOwnProperty(name)) {\n Formio.libraries[name] = {};\n Formio.libraries[name].ready = new Promise((resolve, reject) => {\n Formio.libraries[name].resolve = resolve;\n Formio.libraries[name].reject = reject;\n });\n const callbackName = `${name}Callback`;\n if (!polling && !window[callbackName]) {\n window[callbackName] = () => Formio.libraries[name].resolve();\n }\n // See if the plugin already exists.\n const plugin = (0, lodash_1.get)(window, property);\n if (plugin) {\n Formio.libraries[name].resolve(plugin);\n }\n else {\n src = Array.isArray(src) ? src : [src];\n src.forEach((lib) => {\n let attrs = {};\n let elementType = '';\n if (typeof lib === 'string') {\n lib = {\n type: 'script',\n src: lib,\n };\n }\n switch (lib.type) {\n case 'script':\n elementType = 'script';\n attrs = {\n src: lib.src,\n type: 'text/javascript',\n defer: true,\n async: true,\n referrerpolicy: 'origin',\n };\n break;\n case 'styles':\n elementType = 'link';\n attrs = {\n href: lib.src,\n rel: 'stylesheet',\n };\n break;\n }\n // Add the script to the top of the page.\n const element = document.createElement(elementType);\n if (element.setAttribute) {\n for (const attr in attrs) {\n element.setAttribute(attr, attrs[attr]);\n }\n }\n if (onload) {\n element.addEventListener('load', () => {\n Formio.libraries[name].loaded = true;\n onload(Formio.libraries[name].ready);\n });\n }\n const { head } = document;\n if (head) {\n head.appendChild(element);\n }\n });\n // if no callback is provided, then check periodically for the script.\n if (polling) {\n const interval = setInterval(() => {\n const plugin = (0, lodash_1.get)(window, property);\n if (plugin) {\n clearInterval(interval);\n Formio.libraries[name].resolve(plugin);\n }\n }, 200);\n }\n }\n }\n const lib = Formio.libraries[name];\n return onload && lib.loaded ? onload(lib.ready) : lib.ready;\n }\n /**\n * Determines if a lazy loaded library is ready to be used.\n *\n * @description Example: Let's assume that the example provided at {@link Formio.requireLibrary} was used elsewhere in your application.\n * You could now use the following within a separate place that will also resolve once the library is ready to be used.\n *\n * ```js\n * Formio.libraryReady('googleMaps').then(() => {\n * // Once the promise resolves, the following can now be used within your application.\n * const map = new google.maps.Map(document.getElementById(\"map\"), {...});\n * });\n * ```\n *\n * @param {string} name - The name of the library to check.\n * @return {Promise<object>} - A promise that will resolve when the library is ready to be used.\n */\n static libraryReady(name) {\n if (Formio.libraries.hasOwnProperty(name) &&\n Formio.libraries[name].ready) {\n return Formio.libraries[name].ready;\n }\n return Promise.reject(`${name} library was not required.`);\n }\n /**\n * Clones the response from the API so that it cannot be mutated.\n *\n * @param response\n */\n static cloneResponse(response) {\n const copy = (0, fastCloneDeep_1.fastCloneDeep)(response);\n if (Array.isArray(response)) {\n copy.skip = response.skip;\n copy.limit = response.limit;\n copy.serverCount = response.serverCount;\n }\n return copy;\n }\n /**\n * Sets the project path type.\n *\n * @param type\n */\n static setPathType(type) {\n if (typeof type === 'string') {\n Formio.pathType = type;\n }\n }\n /**\n * Gets the project path type.\n */\n static getPathType() {\n return Formio.pathType;\n }\n}\nexports.Formio = Formio;\n/**\n * The base API url of the Form.io Platform. Example: https://api.form.io\n */\nFormio.baseUrl = 'https://api.form.io';\n/**\n * The project API url of the Form.io Project. Example: https://examples.form.io\n */\nFormio.projectUrl = '';\n/**\n * The project url to use for Authentication.\n */\nFormio.authUrl = '';\n/**\n * Set to true if the project url has been established with ```Formio.setProjectUrl()```\n */\nFormio.projectUrlSet = false;\n/**\n * The Form.io API Cache. This ensures that requests to the same API endpoint are cached.\n */\nFormio.cache = {};\n/**\n * The namespace used to save the Form.io Token's and variables within an application.\n */\nFormio.namespace = '';\n/**\n * Handles events fired within this SDK library.\n */\nFormio.events = new eventemitter3_1.default();\n/**\n * Stores all of the libraries lazy loaded with ```Formio.requireLibrary``` method.\n */\nFormio.libraries = {};\n/**\n * A direct interface to the Form.io fetch polyfill.\n */\nFormio.fetch = fetch;\n/**\n * A direct interface to the Form.io fetch Headers polyfill.\n */\nFormio.Headers = Headers;\n/**\n * All of the auth tokens for this session.\n */\nFormio.tokens = {};\n/**\n * The version of this library.\n */\nFormio.version = '---VERSION---';\n/**\n * The global options for the Formio library.\n */\nFormio.options = {};\n// Add Plugin methods.\nFormio.plugins = Plugins_1.default.plugins;\nFormio.deregisterPlugin = Plugins_1.default.deregisterPlugin;\nFormio.registerPlugin = Plugins_1.default.registerPlugin;\nFormio.getPlugin = Plugins_1.default.getPlugin;\nFormio.pluginWait = Plugins_1.default.pluginWait;\nFormio.pluginGet = Plugins_1.default.pluginGet;\nFormio.pluginAlter = Plugins_1.default.pluginAlter;\n// Adds Formio to the Plugins Interface.\nPlugins_1.default.Formio = Formio;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/sdk/Formio.js?");
|
4600
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Formio = exports.FormioPathType = void 0;\nconst fetch_ponyfill_1 = __importDefault(__webpack_require__(/*! fetch-ponyfill */ \"./node_modules/fetch-ponyfill/build/fetch-browser.js\"));\nconst fastCloneDeep_1 = __webpack_require__(/*! ../utils/fastCloneDeep */ \"./node_modules/@formio/core/lib/utils/fastCloneDeep.js\");\nconst lodash_1 = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\nconst formUtil_1 = __webpack_require__(/*! ../utils/formUtil */ \"./node_modules/@formio/core/lib/utils/formUtil/index.js\");\nconst jwtDecode_1 = __webpack_require__(/*! ../utils/jwtDecode */ \"./node_modules/@formio/core/lib/utils/jwtDecode.js\");\nconst eventemitter3_1 = __importDefault(__webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.js\"));\nconst browser_cookies_1 = __importDefault(__webpack_require__(/*! browser-cookies */ \"./node_modules/browser-cookies/src/browser-cookies.js\"));\nconst { fetch, Headers } = (0, fetch_ponyfill_1.default)();\nconst Plugins_1 = __importDefault(__webpack_require__(/*! ./Plugins */ \"./node_modules/@formio/core/lib/sdk/Plugins.js\"));\nconst utils_1 = __webpack_require__(/*! ../utils */ \"./node_modules/@formio/core/lib/utils/index.js\");\n/**\n * The different path types for a project.\n */\nvar FormioPathType;\n(function (FormioPathType) {\n FormioPathType[\"Subdirectories\"] = \"Subdirectories\";\n FormioPathType[\"Subdomains\"] = \"Subdomains\";\n})(FormioPathType || (exports.FormioPathType = FormioPathType = {}));\n/**\n * The Formio interface class. This is a minimalistic API library that allows you to work with the Form.io API's within JavaScript.\n *\n * ## Usage\n * Creating an instance of Formio is simple, and takes only a path (URL String). The path can be different, depending on the desired output.\n * The Formio instance can also access higher level operations, depending on how granular of a path you start with.\n *\n * ```ts\n * var formio = new Formio(<endpoint>, [options]);\n * ```\n *\n * Where **endpoint** is any valid API endpoint within Form.io. These URL's can provide a number of different methods depending on the granularity of the endpoint. This allows you to use the same interface but have access to different methods depending on how granular the endpoint url is.\n * **options** is defined within the {link Formio.constructor} documentation.\n *\n * Here is an example of how this library can be used to load a form JSON from the Form.io API's\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.loadForm().then((form) => {\n * console.log(form);\n * });\n * ```\n */\nclass Formio {\n /**\n * @constructor\n * @param {string} path - A project, form, and submission API Url.\n * @param {FormioOptions} options - Available options to configure the Javascript API.\n */\n constructor(path, options = {}) {\n this.path = path;\n this.options = options;\n /**\n * The base API url of the Form.io Platform. Example: https://api.form.io\n */\n this.base = '';\n /**\n * The Projects Endpoint derived from the provided source.\n *\n * @example https://api.form.io/project\n */\n this.projectsUrl = '';\n /**\n * A specific project endpoint derived from the provided source.\n *\n * @example https://examples.form.io\n */\n this.projectUrl = '';\n /**\n * The Project ID found within the provided source.\n */\n this.projectId = '';\n /**\n * A specific Role URL provided the source.\n *\n * @example https://examples.form.io/role/2342343234234234\n */\n this.roleUrl = '';\n /**\n * The roles endpoint derived from the provided source.\n *\n * @example https://examples.form.io/role\n */\n this.rolesUrl = '';\n /**\n * The roleID derieved from the provided source.\n */\n this.roleId = '';\n /**\n * A specific form url derived from the provided source.\n *\n * @example https://examples.form.io/example\n */\n this.formUrl = '';\n /**\n * The forms url derived from the provided source.\n *\n * @example https://example.form.io/form\n */\n this.formsUrl = '';\n /**\n * The Form ID derived from the provided source.\n */\n this.formId = '';\n /**\n * The submissions URL derived from the provided source.\n *\n * @example https://examples.form.io/example/submission\n */\n this.submissionsUrl = '';\n /**\n * A specific submissions URL derived from a provided source.\n *\n * @example https://examples.form.io/example/submission/223423423423\n */\n this.submissionUrl = '';\n /**\n * The submission ID provided a submission url.\n */\n this.submissionId = '';\n /**\n * The actions url provided a form url as the source.\n *\n * @example https://examples.form.io/example/action\n */\n this.actionsUrl = '';\n /**\n * The Action ID derived from a provided Action url.\n */\n this.actionId = '';\n /**\n * A specific action api endoint.\n */\n this.actionUrl = '';\n this.vsUrl = '';\n this.vId = '';\n this.vUrl = '';\n /**\n * The query string derived from the provided src url.\n */\n this.query = '';\n /**\n * If this is a non-project url, such is the case for Open Source API.\n */\n this.noProject = false;\n // Ensure we have an instance of Formio.\n if (!(this instanceof Formio)) {\n return new Formio(path);\n }\n if (options.useSessionToken) {\n Formio.useSessionToken(options);\n }\n if (options.hasOwnProperty('base') && options.base) {\n this.base = options.base;\n }\n else if (Formio.baseUrl) {\n this.base = Formio.baseUrl;\n }\n else if (window && window.location) {\n const match = window.location.href.match(/http[s]?:\\/\\/api./);\n this.base = match ? match[0] : window.location.origin;\n }\n if (!path) {\n // Allow user to create new projects if this was instantiated without\n // a url\n this.projectUrl = Formio.projectUrl || `${this.base}/project`;\n this.projectsUrl = `${this.base}/project`;\n this.projectId = '';\n this.query = '';\n return;\n }\n if (options.hasOwnProperty('project') && options.project) {\n this.projectUrl = options.project;\n }\n const project = this.projectUrl || Formio.projectUrl;\n const projectRegEx = /(^|\\/)(project)($|\\/[^/]+)/;\n const isProjectUrl = path.search(projectRegEx) !== -1;\n // 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 if (project && this.base === project && !isProjectUrl) {\n this.noProject = true;\n this.projectUrl = this.base;\n }\n // Normalize to an absolute path.\n if (path.indexOf('http') !== 0 && path.indexOf('//') !== 0) {\n path = this.base + path;\n }\n const hostparts = this.getUrlParts(path);\n let hostName = '';\n let parts = [];\n if (hostparts) {\n hostName = hostparts[1] + hostparts[2];\n path = hostparts.length > 3 ? hostparts[3] : '';\n const queryparts = path.split('?');\n if (queryparts.length > 1) {\n path = queryparts[0];\n this.query = `?${queryparts[1]}`;\n }\n }\n // Register a specific path.\n const registerPath = (name, base) => {\n this[`${name}sUrl`] = `${base}/${name}`;\n const regex = new RegExp(`/${name}/([^/]+)`);\n if (path && path.search(regex) !== -1) {\n parts = path.match(regex);\n this[`${name}Url`] = parts ? base + parts[0] : '';\n this[`${name}Id`] = parts.length > 1 ? parts[1] : '';\n base += parts[0];\n }\n return base;\n };\n // Register an array of items.\n const registerItems = (items, base, staticBase) => {\n for (const i in items) {\n if (items.hasOwnProperty(i)) {\n const item = items[i];\n if (Array.isArray(item)) {\n registerItems(item, base, true);\n }\n else {\n const newBase = registerPath(item, base);\n base = staticBase ? base : newBase;\n }\n }\n }\n };\n if (!this.projectUrl || this.projectUrl === this.base) {\n // If a project uses Subdirectories path type, we need to specify a projectUrl\n if (!this.projectUrl && !isProjectUrl && Formio.pathType === 'Subdirectories') {\n const regex = `^${hostName.replace(/\\//g, '\\\\/')}.[^/]+`;\n const match = project.match(new RegExp(regex));\n this.projectUrl = match ? match[0] : hostName;\n }\n else {\n this.projectUrl = hostName;\n }\n }\n // Check if we have a specified path type.\n let isNotSubdomainType = false;\n if (Formio.pathType) {\n isNotSubdomainType = Formio.pathType !== 'Subdomains';\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 }\n else if (hostName === this.base) {\n // Get project id as first part of path (subdirectory).\n if (hostparts && hostparts.length > 3 && path.split('/').length > 1) {\n const isFile = path.match(/.json/);\n const pathParts = path.split('/');\n if (isFile) {\n this.projectUrl = hostName;\n }\n else {\n pathParts.shift(); // Throw away the first /.\n const projectId = pathParts.shift();\n if (projectId) {\n this.projectId = projectId;\n path = `/${pathParts.join('/')}`;\n this.projectUrl = `${hostName}/${this.projectId}`;\n }\n }\n }\n }\n else {\n // Get project id from subdomain.\n if (hostparts &&\n hostparts.length > 2 &&\n (hostparts[2].split('.').length > 2 || hostName.includes('localhost')) &&\n !isNotSubdomainType) {\n this.projectUrl = hostName;\n this.projectId = hostparts[2].split('.')[0];\n }\n }\n this.projectsUrl = this.projectsUrl || `${this.base}/project`;\n }\n // Configure Role urls and role ids.\n registerItems(['role'], this.projectUrl);\n // Configure Form urls and form ids.\n if (/(^|\\/)(form)($|\\/)/.test(path)) {\n registerItems(['form', ['submission', 'action', 'v']], this.projectUrl);\n }\n else {\n const subRegEx = new RegExp('/(submission|action|v)($|/.*)');\n const subs = path.match(subRegEx);\n if (subs && subs.length > 1) {\n this.pathType = subs[1];\n }\n path = path.replace(subRegEx, '');\n path = path.replace(/\\/$/, '');\n this.formsUrl = `${this.projectUrl}/form`;\n this.formUrl = path ? this.projectUrl + path : '';\n this.formId = path.replace(/^\\/+|\\/+$/g, '');\n const items = ['submission', 'action', 'v'];\n for (const i in items) {\n if (items.hasOwnProperty(i)) {\n const item = items[i];\n this[`${item}sUrl`] = `${this.projectUrl + path}/${item}`;\n if (this.pathType === item && subs && subs.length > 2 && subs[2]) {\n this[`${item}Id`] = subs[2].replace(/^\\/+|\\/+$/g, '');\n this[`${item}Url`] = this.projectUrl + path + subs[0];\n }\n }\n }\n }\n // Set the app url if it is not set.\n if (!Formio.projectUrlSet) {\n Formio.projectUrl = this.projectUrl;\n }\n }\n /**\n * Deletes a remote resource of any provided type.\n *\n * @param {string} type - The type of resource to delete. \"submission\", \"form\", etc.\n * @param {object} options - The options passed to {@link Formio.request}\n * @return {Promise<Response>}\n */\n delete(type, opts) {\n const _id = `${type}Id`;\n const _url = `${type}Url`;\n if (!this[_id]) {\n return Promise.reject('Nothing to delete');\n }\n Formio.cache = {};\n return this.makeRequest(type, this[_url], 'delete', null, opts);\n }\n /**\n * Returns the index (array of records) for any provided type.\n *\n * @param {string} type - The type of resource to fetch the index of. \"submission\", \"form\", etc.\n * @param {object} query - A query object to pass to the request.\n * @param {object} query.params - A map (key-value pairs) of URL query parameters to add to the url.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n index(type, query, opts) {\n const _url = `${type}Url`;\n query = query || '';\n if (query && (0, lodash_1.isObject)(query)) {\n query = `?${Formio.serialize(query.params)}`;\n }\n return this.makeRequest(type, this[_url] + query, 'get', null, opts);\n }\n /**\n * Save a document record using \"upsert\". If the document does not exist, it will be created, if the _id is provided,\n * it will be updated.\n *\n * @param {string} type - The type of resource to fetch the index of. \"submission\", \"form\", etc.\n * @param {object} data - The resource data object.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<object>}\n */\n save(type, data, opts) {\n const _id = `${type}Id`;\n const _url = `${type}Url`;\n const method = this[_id] || data._id ? 'put' : 'post';\n let reqUrl = this[_id] ? this[_url] : this[`${type}sUrl`];\n if (!this[_id] && data._id && method === 'put' && !reqUrl.includes(data._id)) {\n reqUrl += `/${data._id}`;\n }\n Formio.cache = {};\n return this.makeRequest(type, reqUrl + this.query, method, data, opts);\n }\n /**\n * @summary Load (GET) a document record.\n *\n * @param {string} type - The type of resource to fetch the index of. \"submission\", \"form\", etc.\n * @param {object} query - A query object to pass to the request.\n * @param {object} query.params - A map (key-value pairs) of URL query parameters to add to the url.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<object>}\n */\n load(type, query, opts) {\n const _id = `${type}Id`;\n const _url = `${type}Url`;\n if (query && (0, lodash_1.isObject)(query)) {\n query = Formio.serialize(query.params);\n }\n if (query) {\n query = this.query ? `${this.query}&${query}` : `?${query}`;\n }\n else {\n query = this.query;\n }\n if (!this[_id]) {\n return Promise.reject(`Missing ${_id}`);\n }\n let url = this[_url] + query;\n if (type === 'form' && !isNaN(parseInt(this.vId))) {\n url += url.indexOf('?') === -1 ? '?' : '&';\n url += `formRevision=${this.vId}`;\n }\n return this.makeRequest(type, url, 'get', null, opts);\n }\n /**\n * @summary Call {@link Formio.makeRequest} for this Formio instance.\n *\n * @param {string} type - The request resource type. \"submission\", \"form\", etc.\n * @param {string} url - The URL to request.\n * @param {string} method - The request method. GET, PUT, POST, DELETE, or PATCH\n * @param {object} data - The data to pass to the request (for PUT, POST, and PATCH methods)\n * @param {object} options - An object of options to pass to the request method.\n * @param {boolean} options.ignoreCache - To ignore internal caching of the request.\n * @param {object} options.headers - An object of headers to pass along to the request.\n * @param {boolean} options.noToken - If set to true, this will not include the Form.io x-jwt-token along with the request.\n * @param {string} options.namespace - The Form.io namespace to prepend to all LocalStorage variables such as formioToken.\n * @param {boolean} options.getHeaders - Set this if you wish to include the response headers with the return of this method.\n * @return {Promise<Response>}\n */\n makeRequest(type, url, method, data, opts) {\n return Formio.makeRequest(this, type, url, method, data, opts);\n }\n /**\n * @summary Loads a project.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.loadProject().then((project) => {\n * console.log(project);\n * });\n * ```\n *\n * @param {object} query - Query parameters to pass to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n loadProject(query, opts) {\n return this.load('project', query, opts);\n }\n /**\n * Saves or Updates a project.\n *\n * ### Create a new project\n * ```ts\n * const formio = new Formio();\n * formio.saveProject({\n * title: 'My Project',\n * path: 'myproject',\n * name: 'myproject'\n * });\n * ```\n *\n * ### Update an existing project\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.loadProject().then((project) => {\n * project.title = 'Title changed';\n * formio.saveProject(project).then(() => {\n * console.log('Done saving project!');\n * });\n * });\n * ```\n *\n * @param {object} data - The project JSON to create or update.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n saveProject(data, opts) {\n return this.save('project', data, opts);\n }\n /**\n * Deletes a project\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.deleteProject();\n * ```\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n deleteProject(opts) {\n return this.delete('project', opts);\n }\n /**\n * Loads a list of all projects.\n *\n * ```ts\n * Formio.loadProjects().then((projects) => {\n * console.log(projects);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {*}\n */\n static loadProjects(query, opts) {\n query = query || '';\n if ((0, lodash_1.isObject)(query)) {\n query = `?${Formio.serialize(query.params)}`;\n }\n return Formio.makeStaticRequest(`${Formio.baseUrl}/project${query}`, 'GET', null, opts);\n }\n /**\n * Loads a role within a project.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/role/234234234234');\n * formio.loadRole().then((role) => {\n * console.log(role);\n * });\n * ```\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n loadRole(opts) {\n return this.load('role', null, opts);\n }\n /**\n * Create a new or Update an existing role within a project.\n *\n * ### Create new Role example\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.saveRole({\n * title: 'Employee',\n * description: 'A person who belongs to a company.'\n * }).then((role) => {\n * console.log(role);\n * });\n * ```\n *\n * ### Update existing role example\n * ```ts\n * const formio = new Formio('https://examples.form.io/role/234234234234234');\n * formio.loadRole().then((role) => {\n * role.title = 'Manager';\n * formio.saveRole(role).then(() => {\n * console.log('DONE');\n * });\n * });\n * ```\n *\n * @param {object} role - The Role JSON to create or update.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n saveRole(data, opts) {\n return this.save('role', data, opts);\n }\n /**\n * Deletes a role within a project.\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n deleteRole(opts) {\n return this.delete('role', opts);\n }\n /**\n * Load all roles within a project.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.loadRoles().then((roles) => {\n * console.log(roles);\n * });\n * ```\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n loadRoles(opts) {\n return this.index('roles', null, opts);\n }\n /**\n * Loads a form.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.loadForm().then((form) => {\n * console.log(form);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<object>}\n */\n loadForm(query, opts) {\n return this.load('form', query, opts).then((currentForm) => {\n // Check to see if there isn't a number in vId.\n if (!currentForm.revisions || isNaN(parseInt(this.vId))) {\n return currentForm;\n }\n // If a submission already exists but form is marked to load current version of form.\n if (currentForm.revisions === 'current' && this.submissionId) {\n return currentForm;\n }\n if (currentForm._vid == this.vId || currentForm.revisionId === this.vId) {\n return currentForm;\n }\n // If they specified a revision form, load the revised form components.\n if (query && (0, lodash_1.isObject)(query)) {\n query = Formio.serialize(query.params);\n }\n if (query) {\n query = this.query ? `${this.query}&${query}` : `?${query}`;\n }\n else {\n query = this.query;\n }\n return (this.makeRequest('form', this.vUrl + query, 'get', null, opts)\n .then((revisionForm) => {\n currentForm._vid = revisionForm._vid;\n currentForm.components = revisionForm.components;\n currentForm.settings = revisionForm.settings;\n currentForm.revisionId = revisionForm.revisionId;\n // Using object.assign so we don't cross polinate multiple form loads.\n return Object.assign({}, currentForm);\n })\n // If we couldn't load the revision, just return the original form.\n .catch(() => Object.assign({}, currentForm)));\n });\n }\n /**\n * Create or Update a specific form.\n *\n * ### Create form example\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.saveForm({\n * title: 'Employee',\n * type: 'resource',\n * path: 'employee',\n * name: 'employee',\n * components: [\n * {\n * type: 'textfield',\n * key: 'firstName',\n * label: 'First Name'\n * },\n * {\n * type: 'textfield',\n * key: 'lastName',\n * label: 'Last Name'\n * }\n * ]\n * });\n * ```\n *\n * ### Update a form example\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.loadForm().then((form) => {\n * form.title = 'Changed Title';\n * formio.saveForm(form).then(() => {\n * console.log('DONE!!!');\n * });\n * });\n * ```\n *\n * @param {object} data - The Form JSON to create or update.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n saveForm(data, opts) {\n return this.save('form', data, opts);\n }\n /**\n * Deletes a form.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.deleteForm().then(() => {\n * console.log('Deleted!');\n * });\n * ```\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n deleteForm(opts) {\n return this.delete('form', opts);\n }\n /**\n * Loads all forms within a project.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.loadForms().then((forms) => {\n * console.log(forms);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n loadForms(query, opts) {\n return this.index('forms', query, opts);\n }\n /**\n * Loads a specific submissionn.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/submission/23423423423423423');\n * formio.loadSubmission().then((submission) => {\n * console.log(submission);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<object>}\n */\n loadSubmission(query, opts) {\n return this.load('submission', query, opts).then((submission) => {\n this.vId = submission._frid || submission._fvid;\n this.vUrl = `${this.formUrl}/v/${this.vId}`;\n return submission;\n });\n }\n /**\n * Creates a new or Updates an existing submission.\n *\n * ### Create a new submission\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.saveSubmission({\n * data: {\n * firstName: 'Joe',\n * lastName: 'Smith'\n * }\n * }).then((submission) => {\n * // This will now be the complete submission object saved on the server.\n * console.log(submission);\n * });\n * ```\n *\n * ### Update an existing submission\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/submission/23423423423423423');\n * formio.loadSubmission().then((submission) => {\n * submission.data.lastName = 'Thompson';\n * formio.saveSubmission(submission).then(() => {\n * console.log('DONE');\n * });\n * });\n * ```\n *\n * @param {object} data - The submission JSON object.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n saveSubmission(data, opts) {\n if (!isNaN(parseInt(this.vId)) && !data._fvid) {\n data._fvid = this.vId;\n }\n return this.save('submission', data, opts);\n }\n /**\n * Deletes a submission.\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n deleteSubmission(opts) {\n return this.delete('submission', opts);\n }\n /**\n * Loads all submissions within a form.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.loadSubmissions({\n * params: {\n * limit: 25,\n * 'data.lastName__regex': 'smith'\n * }\n * }).then((submissions) => {\n * // Should print out 25 submissions where the last name contains \"smith\".\n * console.log(submissions);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n loadSubmissions(query, opts) {\n return this.index('submissions', query, opts);\n }\n /**\n * Loads a form action.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/action/234234234234');\n * formio.loadAction().then((action) => {\n * console.log(action);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n loadAction(query, opts) {\n return this.load('action', query, opts);\n }\n /**\n * Create a new or update an existing action.\n *\n * ### Create a new action for a form.\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.saveAction({\n * data: {\n * name: 'webhook',\n * title: 'Webhook Action',\n * method: ['create', 'update', 'delete'],\n * handler: ['after'],\n * condition: {},\n * settings: {\n * url: 'https://example.com',\n * headers: [{}],\n * block: false,\n * forwardHeaders: false\n * }\n * }\n * }).then((action) => {\n * console.log(action);\n * });\n * ```\n *\n * ### Update an action\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/action/234234234234');\n * formio.loadAction().then((action) => {\n * action.title = 'Updated title';\n * formio.saveAction(action).then(() => {\n * console.log('Done!');\n * });\n * });\n * ```\n *\n * @param {object} data - The action JSON\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Object>}\n */\n saveAction(data, opts) {\n return this.save('action', data, opts);\n }\n /**\n * Delete an action\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/action/234234234234');\n * formio.deleteAction().then(() => {\n * console.log('Action was deleted.');\n * });\n * ```\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n deleteAction(opts) {\n return this.delete('action', opts);\n }\n /**\n * Loads all actions within a form.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.loadActions().then((actions) => {\n * console.log(actions);\n * });\n * ```\n *\n * @param {object} query - Query parameters similar to {@link Formio#load}.\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<Response>}\n */\n loadActions(query, opts) {\n return this.index('actions', query, opts);\n }\n /**\n * Returns a list of available actions\n *\n * @return {Promise<Response>}\n */\n availableActions() {\n return this.makeRequest('availableActions', `${this.formUrl}/actions`);\n }\n /**\n * Returns the action information for a specific action, such as \"save\".\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/actions/save');\n * formio.actionInfo().then((info) => {\n * console.log(info);\n * });\n * ```\n *\n * @param {string} name - The name of the action you would like to get information for. i.e. \"save\", \"webhook\", etc.\n * @return {Promise<Response>}\n */\n actionInfo(name) {\n return this.makeRequest('actionInfo', `${this.formUrl}/actions/${name}`);\n }\n /**\n * Determine if a string ID is a valid MongoID.\n *\n * @param {string} id - The id that should be tested if it is avalid id.\n * @return {boolean} - true if it is a valid MongoId, false otherwise.\n */\n isObjectId(id) {\n const checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');\n return checkForHexRegExp.test(id);\n }\n /**\n * Get the project ID of project.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io');\n * formio.getProjectId().then((projectId) => {\n * console.log(projectId);\n * };\n * ```\n *\n * @return {Promise<string>}\n */\n getProjectId() {\n if (!this.projectId) {\n return Promise.resolve('');\n }\n if (this.isObjectId(this.projectId)) {\n return Promise.resolve(this.projectId);\n }\n else {\n return this.loadProject().then((project) => {\n return project._id;\n });\n }\n }\n /**\n * Get the ID of a form.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example');\n * formio.getFormId().then((formId) => {\n * console.log(formId);\n * });\n * ```\n *\n * @return {Promise<string>}\n */\n getFormId() {\n if (!this.formId) {\n return Promise.resolve('');\n }\n if (this.isObjectId(this.formId)) {\n return Promise.resolve(this.formId);\n }\n else {\n return this.loadForm().then((form) => {\n return form._id;\n });\n }\n }\n /**\n * Instance method for {@link Formio.currentUser}\n *\n * @param {object} options - Options to pass to {@link Formio.request}\n * @return {Promise<object>}\n */\n currentUser(options) {\n return Formio.currentUser(this, options);\n }\n /**\n * Instance method for {@link Formio.accessInfo}\n *\n * @return {Promise<Response>}\n */\n accessInfo() {\n return Formio.accessInfo(this);\n }\n /**\n * Sets OAuth Logout URL.\n *\n * @param {string} uri - Logout URL.\n * @param {string} options.namespace - The localStorage namespace to use when retrieving tokens from storage.\n * @return {string}\n */\n oauthLogoutURI(uri, options) {\n return Formio.oauthLogoutURI(uri, Object.assign({ formio: this }, this.options, options));\n }\n /**\n * Returns the JWT token for this instance.\n *\n * @param {object} options - The following options are provided.\n * @param {string} options.namespace - The localStorage namespace to use when retrieving tokens from storage.\n * @return {string} - The JWT token for this user.\n */\n getToken(options) {\n return Formio.getToken(Object.assign({ formio: this }, this.options, options));\n }\n /**\n * Sets the JWT token for this instance.\n *\n * @param {string} token - The JWT token to set.\n * @param {object} options - The following options are provided.\n * @param {string} options.namespace - The localStorage namespace to use when retrieving tokens from storage.\n * @return {string} - The JWT token that was set.\n */\n setToken(token, options) {\n return Formio.setToken(token, Object.assign({ formio: this }, this.options, options));\n }\n /**\n * Returns a temporary authentication token for single purpose token generation.\n *\n * @param {number|string} expire - The amount of seconds to wait before this temp token expires.\n * @param {string} allowed - The allowed path string inn the format GET:/path\n * @param {object} options - The options passed to {@link Formio#getToken}\n */\n getTempToken(expire, allowed, options) {\n const token = Formio.getToken(options);\n if (!token) {\n return Promise.reject('You must be authenticated to generate a temporary auth token.');\n }\n const authUrl = Formio.authUrl || this.projectUrl;\n return this.makeRequest('tempToken', `${authUrl}/token`, 'GET', null, {\n ignoreCache: true,\n header: new Headers({\n 'x-expire': expire,\n 'x-allow': allowed,\n }),\n });\n }\n /**\n * Get a PDF download url for a submission, which will generate a new PDF of the submission. This method will first\n * fetch a temporary download token, and then append this to the download url for this form.\n *\n * ```ts\n * const formio = new Formio('https://examples.form.io/example/submission/324234234234234');\n * formio.getDownloadUrl().then((url) => {\n * console.log(url);\n * });\n * ```\n *\n * @param {object} [form] - The form JSON to fetch a download url for.\n * @return {Promise<string>} - The download url.\n */\n getDownloadUrl(form) {\n if (!this.submissionId) {\n return Promise.resolve('');\n }\n if (!form) {\n // Make sure to load the form first.\n return this.loadForm().then((_form) => {\n if (!_form) {\n return '';\n }\n return this.getDownloadUrl(_form);\n });\n }\n let apiUrl = `/project/${form.project}`;\n apiUrl += `/form/${form._id}`;\n apiUrl += `/submission/${this.submissionId}`;\n const postfix = form.submissionRevisions && form.settings.changeLog ? '/download/changelog' : '/download';\n apiUrl += postfix;\n let download = this.base + apiUrl;\n return new Promise((resolve, reject) => {\n this.getTempToken(3600, `GET:${apiUrl}`)\n .then((tempToken) => {\n download += `?token=${tempToken.key}`;\n resolve(download);\n }, () => {\n resolve(download);\n })\n .catch(reject);\n });\n }\n /**\n * Returns the user permissions to a form and submission.\n *\n * @param user - The user or current user if undefined. For anonymous, use \"null\"\n * @param form - The form or current form if undefined. For no form check, use \"null\"\n * @param submission - The submisison or \"index\" if undefined.\n *\n * @return {{create: boolean, read: boolean, edit: boolean, delete: boolean}}\n */\n userPermissions(user, form, submission) {\n return Promise.all([\n form !== undefined ? Promise.resolve(form) : this.loadForm(),\n user !== undefined ? Promise.resolve(user) : this.currentUser(),\n submission !== undefined || !this.submissionId\n ? Promise.resolve(submission)\n : this.loadSubmission(),\n this.accessInfo(),\n ]).then((results) => {\n const form = results.shift();\n const user = results.shift() || { _id: false, roles: [] };\n const submission = results.shift();\n const access = results.shift();\n const permMap = {\n create: 'create',\n read: 'read',\n update: 'edit',\n delete: 'delete',\n };\n const perms = {\n user: user,\n form: form,\n access: access,\n create: false,\n read: false,\n edit: false,\n delete: false,\n };\n for (const roleName in access.roles) {\n if (access.roles.hasOwnProperty(roleName)) {\n const role = access.roles[roleName];\n if (role.default && user._id === false) {\n // User is anonymous. Add the anonymous role.\n user.roles.push(role._id);\n }\n else if (role.admin && user.roles.indexOf(role._id) !== -1) {\n perms.create = true;\n perms.read = true;\n perms.delete = true;\n perms.edit = true;\n return perms;\n }\n }\n }\n if (form && form.submissionAccess) {\n for (let i = 0; i < form.submissionAccess.length; i++) {\n const permission = form.submissionAccess[i];\n const [perm, scope] = permission.type.split('_');\n if (['create', 'read', 'update', 'delete'].includes(perm)) {\n if ((0, lodash_1.intersection)(permission.roles, user.roles).length) {\n perms[permMap[perm]] =\n scope === 'all' || !submission || user._id === submission.owner;\n }\n }\n }\n }\n // check for Group Permissions\n if (submission) {\n // we would anyway need to loop through components for create permission, so we'll do that for all of them\n (0, formUtil_1.eachComponent)(form.components, (component, path) => {\n if (component && component.defaultPermission) {\n const value = (0, lodash_1.get)(submission.data, path);\n // make it work for single-select Group and multi-select Group\n const groups = Array.isArray(value) ? value : [value];\n groups.forEach((group) => {\n if (group &&\n group._id && // group id is present\n user.roles.indexOf(group._id) > -1 // user has group id in his roles\n ) {\n if (component.defaultPermission === 'read') {\n perms[permMap.read] = true;\n }\n if (component.defaultPermission === 'create') {\n perms[permMap.create] = true;\n perms[permMap.read] = true;\n }\n if (component.defaultPermission === 'write') {\n perms[permMap.create] = true;\n perms[permMap.read] = true;\n perms[permMap.update] = true;\n }\n if (component.defaultPermission === 'admin') {\n perms[permMap.create] = true;\n perms[permMap.read] = true;\n perms[permMap.update] = true;\n perms[permMap.delete] = true;\n }\n }\n });\n }\n });\n }\n return perms;\n });\n }\n /**\n * `Determine if the current user can submit a form.\n * @return {*}\n */\n canSubmit() {\n return this.userPermissions().then((perms) => {\n // If there is user and they cannot create, then check anonymous user permissions.\n if (!perms.create && Formio.getUser()) {\n return this.userPermissions(null).then((anonPerms) => {\n if (anonPerms.create) {\n Formio.setUser(null);\n return true;\n }\n return false;\n });\n }\n return perms.create;\n });\n }\n getUrlParts(url) {\n return Formio.getUrlParts(url, this);\n }\n static getUrlParts(url, formio) {\n const base = formio && formio.base ? formio.base : Formio.baseUrl;\n let regex = '^(http[s]?:\\\\/\\\\/)';\n if (base && url.indexOf(base) === 0) {\n regex += `(${base.replace(/^http[s]?:\\/\\//, '')})`;\n }\n else {\n regex += '([^/]+)';\n }\n regex += '($|\\\\/.*)';\n return url.match(new RegExp(regex));\n }\n static serialize(obj, _interpolate) {\n const str = [];\n const interpolate = (item) => {\n return _interpolate ? _interpolate(item) : item;\n };\n for (const p in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, p)) {\n str.push(`${encodeURIComponent(p)}=${encodeURIComponent(interpolate(obj[p]))}`);\n }\n }\n return str.join('&');\n }\n static getRequestArgs(formio, type, url, method, data, opts) {\n method = (method || 'GET').toUpperCase();\n if (!opts || !(0, lodash_1.isObject)(opts)) {\n opts = {};\n }\n const requestArgs = {\n url,\n method,\n data: data || null,\n opts,\n };\n if (type) {\n requestArgs.type = type;\n }\n if (formio) {\n requestArgs.formio = formio;\n }\n return requestArgs;\n }\n static makeStaticRequest(url, method, data, opts) {\n const requestArgs = Formio.getRequestArgs(null, '', url, method, data, opts);\n const request = Plugins_1.default.pluginWait('preRequest', requestArgs).then(() => Plugins_1.default.pluginGet('staticRequest', requestArgs).then((result) => {\n if ((0, lodash_1.isNil)(result)) {\n return Formio.request(requestArgs.url, requestArgs.method, requestArgs.data, requestArgs.opts.header, requestArgs.opts);\n }\n return result;\n }));\n return Plugins_1.default.pluginAlter('wrapStaticRequestPromise', request, requestArgs);\n }\n /**\n * Make an API request and wrap that request with the Form.io Request plugin system. This is very similar to the\n * {Formio.request} method with a difference being that it will pass the request through the Form.io request plugin.\n *\n * @param {Formio} formio - An instance of the Formio class.\n * @param {string} type - The request resource type. \"submission\", \"form\", etc.\n * @param {string} url - The URL to request.\n * @param {string} method - The request method. GET, PUT, POST, DELETE, or PATCH\n * @param {object} data - The data to pass to the request (for PUT, POST, and PATCH methods)\n * @param {object} options - An object of options to pass to the request method.\n * @param {boolean} options.ignoreCache - To ignore internal caching of the request.\n * @param {object} options.headers - An object of headers to pass along to the request.\n * @param {boolean} options.noToken - If set to true, this will not include the Form.io x-jwt-token along with the request.\n * @param {string} options.namespace - The Form.io namespace to prepend to all LocalStorage variables such as formioToken.\n * @param {boolean} options.getHeaders - Set this if you wish to include the response headers with the return of this method.\n * @return {Promise<Response>}\n */\n static makeRequest(formio, type, url, method, data, opts) {\n if (!formio) {\n return Formio.makeStaticRequest(url, method, data, opts);\n }\n const requestArgs = Formio.getRequestArgs(formio, type, url, method, data, opts);\n requestArgs.opts = requestArgs.opts || {};\n requestArgs.opts.formio = formio;\n //for Formio requests default Accept and Content-type headers\n if (!requestArgs.opts.headers) {\n requestArgs.opts.headers = {};\n }\n requestArgs.opts.headers = (0, lodash_1.defaults)(requestArgs.opts.headers, {\n Accept: 'application/json',\n 'Content-type': 'application/json',\n });\n const request = Plugins_1.default.pluginWait('preRequest', requestArgs).then(() => Plugins_1.default.pluginGet('request', requestArgs).then((result) => {\n if ((0, lodash_1.isNil)(result)) {\n return Formio.request(requestArgs.url, requestArgs.method, requestArgs.data, requestArgs.opts.header, requestArgs.opts);\n }\n return result;\n }));\n return Plugins_1.default.pluginAlter('wrapRequestPromise', request, requestArgs);\n }\n /**\n * Execute an API request to any external system. This is a wrapper around the Web fetch method.\n *\n * ```ts\n * Formio.request('https://examples.form.io').then((form) => {\n * console.log(form);\n * });\n * ```\n *\n * @param {string} url - The URL to request.\n * @param {string} method - The request method. GET, PUT, POST, DELETE, or PATCH\n * @param {object} data - The data to pass to the request (for PUT, POST, and PATCH methods)\n * @param {Headers} header - An object of headers to pass to the request.\n * @param {object} options - An object of options to pass to the request method.\n * @param {boolean} options.ignoreCache - To ignore internal caching of the request.\n * @param {object} options.headers - An object of headers to pass along to the request.\n * @param {boolean} options.noToken - If set to true, this will not include the Form.io x-jwt-token along with the request.\n * @param {string} options.namespace - The Form.io namespace to prepend to all LocalStorage variables such as formioToken.\n * @param {boolean} options.getHeaders - Set this if you wish to include the response headers with the return of this method.\n * @return {Promise<Response>|*}\n */\n static request(url, method, data, header, opts) {\n if (!url) {\n return Promise.reject('No url provided');\n }\n method = (method || 'GET').toUpperCase();\n // For reverse compatibility, if they provided the ignoreCache parameter,\n // then change it back to the options format where that is a parameter.\n if ((0, lodash_1.isBoolean)(opts)) {\n opts = { ignoreCache: opts };\n }\n if (!opts || !(0, lodash_1.isObject)(opts)) {\n opts = {};\n }\n // Generate a cachekey.\n const cacheKey = btoa(encodeURI(url));\n // Get the cached promise to save multiple loads.\n if (!opts.ignoreCache && method === 'GET' && Formio.cache.hasOwnProperty(cacheKey)) {\n return Promise.resolve(Formio.cloneResponse(Formio.cache[cacheKey]));\n }\n if (url[0] === '/') {\n url = Formio.baseUrl + url;\n }\n // Set up and fetch request\n const headers = header ||\n new Headers(opts.headers || {\n Accept: 'application/json',\n 'Content-type': 'application/json',\n });\n const token = Formio.getToken(opts);\n if (token && !opts.noToken) {\n headers.set('x-jwt-token', token);\n }\n // The fetch-ponyfill can't handle a proper Headers class anymore. Change it back to an object.\n const headerObj = {};\n headers.forEach(function (value, name) {\n headerObj[name] = value;\n });\n let options = {\n method: method,\n headers: headerObj,\n mode: 'cors',\n };\n if (data) {\n options.body = JSON.stringify(data);\n }\n // Allow plugins to alter the options.\n options = Plugins_1.default.pluginAlter('requestOptions', options, url);\n if (options.namespace || Formio.namespace) {\n opts.namespace = options.namespace || Formio.namespace;\n }\n const requestToken = options.headers['x-jwt-token'];\n const result = Plugins_1.default.pluginAlter('wrapFetchRequestPromise', Formio.fetch(url, options), {\n url,\n method,\n data,\n opts,\n })\n .then((response) => {\n // Allow plugins to respond.\n response = Plugins_1.default.pluginAlter('requestResponse', response, Formio, data);\n if (!response.ok) {\n if (response.status === 440) {\n Formio.setToken(null, opts);\n Formio.events.emit('formio.sessionExpired', response.body || response);\n }\n else if (response.status === 401) {\n Formio.events.emit('formio.unauthorized', response.body || response);\n }\n else if (response.status === 416) {\n Formio.events.emit('formio.rangeIsNotSatisfiable', response.body || response);\n }\n else if (response.status === 504) {\n return Promise.reject(new Error('Network request failed'));\n }\n // Parse and return the error as a rejected promise to reject this promise\n return (response.headers.get('content-type').includes('application/json')\n ? response.json()\n : response.text()).then((error) => {\n return Promise.reject(error);\n });\n }\n // Handle fetch results\n const respToken = response.headers.get('x-jwt-token');\n // In some strange cases, the fetch library will return an x-jwt-token without sending\n // one to the server. This has even been debugged on the server to verify that no token\n // was introduced with the request, but the response contains a token. This is an Invalid\n // case where we do not send an x-jwt-token and get one in return for any GET request.\n let tokenIntroduced = false;\n if (method === 'GET' &&\n !requestToken &&\n respToken &&\n !opts.external &&\n !url.includes('token=') &&\n !url.includes('x-jwt-token=')) {\n console.warn('Token was introduced in request.');\n tokenIntroduced = true;\n }\n if (response.status >= 200 &&\n response.status < 300 &&\n respToken &&\n respToken !== '' &&\n !tokenIntroduced) {\n Formio.setToken(respToken, Object.assign(Object.assign({}, opts), { fromCurrent: opts.fromCurrent || !!requestToken }));\n }\n // 204 is no content. Don't try to .json() it.\n if (response.status === 204) {\n return {};\n }\n const getResult = response.headers.get('content-type').includes('application/json')\n ? response.json()\n : response.text();\n return getResult.then((result) => {\n // Add some content-range metadata to the result here\n let range = response.headers.get('content-range');\n if (range && (0, lodash_1.isObject)(result)) {\n range = range.split('/');\n if (range[0] !== '*') {\n const skipLimit = range[0].split('-');\n result.skip = Number(skipLimit[0]);\n result.limit = skipLimit[1] - skipLimit[0] + 1;\n }\n result.serverCount = range[1] === '*' ? range[1] : Number(range[1]);\n }\n if (!opts.getHeaders) {\n return result;\n }\n const headers = {};\n response.headers.forEach((item, key) => {\n headers[key] = item;\n });\n // Return the result with the headers.\n return {\n result,\n headers,\n };\n });\n })\n .then((result) => {\n if (opts.getHeaders) {\n return result;\n }\n // Cache the response.\n if (method === 'GET') {\n Formio.cache[cacheKey] = result;\n }\n return Formio.cloneResponse(result);\n })\n .catch((err) => {\n if (err === 'Bad Token' && opts.noToken !== false) {\n Formio.setToken(null, opts);\n Formio.events.emit('formio.badToken', err);\n }\n if (err.message) {\n err = new Error(`Could not connect to API server (${err.message}): ${url}`);\n err.networkError = true;\n }\n if (method === 'GET') {\n delete Formio.cache[cacheKey];\n }\n return Promise.reject(err);\n });\n return result;\n }\n // Needed to maintain reverse compatability...\n static get token() {\n return Formio.tokens.formioToken || '';\n }\n // Needed to maintain reverse compatability...\n static set token(token) {\n Formio.tokens.formioToken = token || '';\n }\n static useSessionToken(options) {\n if (typeof localStorage === 'undefined') {\n return;\n }\n const namespace = options;\n if (typeof options === 'object') {\n options = options.namespace;\n }\n const tokenName = `${namespace || Formio.namespace || 'formio'}Token`;\n const token = localStorage.getItem(tokenName);\n if (token) {\n localStorage.removeItem(tokenName);\n sessionStorage.setItem(tokenName, token);\n }\n const userName = `${namespace || Formio.namespace || 'formio'}User`;\n const user = localStorage.getItem(userName);\n if (user) {\n localStorage.removeItem(userName);\n sessionStorage.setItem(userName, user);\n }\n localStorage.setItem('useSessionToken', 'true');\n }\n /**\n * Sets the JWT in storage to be used within an application.\n *\n * @param {string} token - The JWT token to set.\n * @param {object} options - Options as follows\n * @param {string} options.namespace - The namespace to save the token within. i.e. \"formio\"\n * @param {Formio} options.formio - The Formio instance.\n * @return {Promise<object>|void}\n */\n static setToken(token = '', opts = {}) {\n token = token || '';\n opts = typeof opts === 'string' ? { namespace: opts } : opts || {};\n const tokenName = `${opts.namespace || Formio.namespace || 'formio'}Token`;\n if (!Formio.tokens) {\n Formio.tokens = {};\n }\n const storage = localStorage.getItem('useSessionToken') ? sessionStorage : localStorage;\n if (!token) {\n if (!opts.fromUser) {\n opts.fromToken = true;\n Formio.setUser(null, opts);\n }\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n storage.removeItem(tokenName);\n }\n catch (ignoreErr) {\n browser_cookies_1.default.erase(tokenName, { path: '/' });\n }\n Formio.tokens[tokenName] = token;\n return Promise.resolve(null);\n }\n if (Formio.tokens[tokenName] !== token) {\n Formio.tokens[tokenName] = token;\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n storage.setItem(tokenName, token);\n }\n catch (ignoreErr) {\n browser_cookies_1.default.set(tokenName, token, { path: '/' });\n }\n }\n // Return or updates the current user\n return Formio.currentUser(opts.formio, opts);\n }\n /**\n * Returns the token set within the application for the user.\n *\n * @param {object} options - The options as follows.\n * @param {string} options.namespace - The namespace of the token you wish to fetch.\n * @param {boolean} options.decode - If you would like the token returned as decoded JSON.\n * @return {*}\n */\n static getToken(options) {\n options = typeof options === 'string' ? { namespace: options } : options || {};\n const tokenName = `${options.namespace || Formio.namespace || 'formio'}Token`;\n const decodedTokenName = options.decode ? `${tokenName}Decoded` : tokenName;\n if (!Formio.tokens) {\n Formio.tokens = {};\n }\n if (Formio.tokens[decodedTokenName]) {\n return Formio.tokens[decodedTokenName];\n }\n try {\n const token = localStorage.getItem('useSessionToken')\n ? sessionStorage.getItem(tokenName)\n : localStorage.getItem(tokenName);\n Formio.tokens[tokenName] = token || '';\n if (options.decode) {\n Formio.tokens[decodedTokenName] = Formio.tokens[tokenName]\n ? (0, jwtDecode_1.jwtDecode)(Formio.tokens[tokenName])\n : {};\n return Formio.tokens[decodedTokenName];\n }\n return Formio.tokens[tokenName];\n }\n catch (ignoreError) {\n Formio.tokens[tokenName] = browser_cookies_1.default.get(tokenName);\n return '';\n }\n }\n /**\n * Sets the current user within the application cache.\n *\n * @param {object} user - JSON object of the user you wish to set.\n * @param {object} options - Options as follows\n * @param {string} options.namespace - The namespace of the tokens\n */\n static setUser(user, opts = {}) {\n const userName = `${opts.namespace || Formio.namespace || 'formio'}User`;\n const storage = localStorage.getItem('useSessionToken') ? sessionStorage : localStorage;\n if (!user) {\n if (!opts.fromToken) {\n opts.fromUser = true;\n Formio.setToken(null, opts);\n }\n // Emit an event on the cleared user.\n Formio.events.emit('formio.user', null);\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n return storage.removeItem(userName);\n }\n catch (ignoreError) {\n return browser_cookies_1.default.erase(userName, { path: '/' });\n }\n }\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n storage.setItem(userName, JSON.stringify(user));\n }\n catch (ignoreError) {\n browser_cookies_1.default.set(userName, JSON.stringify(user), { path: '/' });\n }\n // Emit an event on the authenticated user.\n Formio.events.emit('formio.user', user);\n }\n /**\n * Returns the user JSON.\n *\n * @param {object} options - Options as follows\n * @param {string} namespace - The namespace of the tokens stored within this application.\n * @return {object} - The user object.\n */\n static getUser(options) {\n options = options || {};\n const userName = `${options.namespace || Formio.namespace || 'formio'}User`;\n try {\n return JSON.parse((localStorage.getItem('useSessionToken') ? sessionStorage : localStorage).getItem(userName) || '');\n }\n catch (ignoreError) {\n return JSON.parse(browser_cookies_1.default.get(userName));\n }\n }\n /**\n * Sets the BaseURL for the application.\n *\n * @description Every application developed using the JavaScript SDK must set both the {@link Formio.setBaseUrl} and\n * {@link Formio.setProjectUrl} methods. These two functions ensure that every URL passed into the constructor of this\n * class can determine the \"project\" context for which the application is running.\n *\n * Any Open Source server applications will set both the {@link Formio.setBaseUrl} and {@link Formio.setProjectUrl}\n * values will be the same value.\n *\n * ```ts\n * Formio.setBaseUrl('https://yourwebsite.com/forms');\n * Formio.setProjectUrl('https://yourwebsite.com/forms/project');\n *\n * // Now the Formio constructor will know what is the \"project\" and what is the form alias name. Without setBaseUrl\n * // and setProjectUrl, this would throw an error.\n *\n * const formio = new Formio('https://yourwebsite.com/forms/project/user');\n * formio.loadForm().then((form) => {\n * console.log(form);\n * });\n * ```\n *\n * @param {string} url - The URL of the Base API url.\n */\n static setBaseUrl(url) {\n Formio.baseUrl = url;\n if (!Formio.projectUrlSet) {\n Formio.projectUrl = url;\n }\n }\n /**\n * Returns the current base url described at {@link Formio.setBaseUrl}\n *\n * @return {string} - The base url of the application.\n */\n static getBaseUrl() {\n return Formio.baseUrl;\n }\n static setApiUrl(url) {\n return Formio.setBaseUrl(url);\n }\n static getApiUrl() {\n return Formio.getBaseUrl();\n }\n static setAppUrl(url) {\n console.warn('Formio.setAppUrl() is deprecated. Use Formio.setProjectUrl instead.');\n Formio.projectUrl = url;\n Formio.projectUrlSet = true;\n }\n /**\n * Sets the Project Url for the application. This is an important method that needs to be set for all applications. It\n * is documented @ {@link Formio.setBaseUrl}.\n *\n * @param {string} url - The project api url.\n */\n static setProjectUrl(url) {\n Formio.projectUrl = url;\n Formio.projectUrlSet = true;\n }\n /**\n * The Auth URL can be set to customize the authentication requests made from an application. By default, this is\n * just the same value as {@link Formio.projectUrl}\n *\n * @param {string} url - The authentication url\n */\n static setAuthUrl(url) {\n Formio.authUrl = url;\n }\n static getAppUrl() {\n console.warn('Formio.getAppUrl() is deprecated. Use Formio.getProjectUrl instead.');\n return Formio.projectUrl;\n }\n /**\n * Returns the Project url described at {@link Formio.setProjectUrl}\n *\n * @return {string|string} - The Project Url.\n */\n static getProjectUrl() {\n return Formio.projectUrl;\n }\n /**\n * Clears the runtime internal API cache.\n *\n * @description By default, the Formio class will cache all API requests in memory so that any subsequent requests\n * using GET method will return the cached results as long as the API URl is the same as what was cached previously.\n * This cache can be cleared using this method as follows.\n *\n * ```ts\n * Formio.clearCache();\n * ```\n *\n * Or, if you just wish to clear a single request, then the {@link Formio.request#options.ignoreCache} option can be\n * provided when making an API request as follows.\n *\n * ```ts\n * Formio.loadForm({}, {\n * ignoreCache: true\n * }).then((form) => {\n * console.log(form);\n * });\n * ```\n *\n * Both of the following will ensure that a new request is made to the API server and that the results will not be\n * from the cached result.\n */\n static clearCache() {\n Formio.cache = {};\n }\n /**\n * Return the access information about a Project, such as the Role ID's for that project, and if the server is\n * configured to do so, the Form and Resource access configurations that the authenticated user has access to.\n *\n * @description This is useful for an application to determine the UI for a specific user to identify which forms they have\n * access to submit or read.\n *\n * @param {Formio} formio - The Formio instance.\n * @return {Promise<Response>}\n */\n static accessInfo(formio) {\n const projectUrl = formio ? formio.projectUrl : Formio.projectUrl;\n return Formio.makeRequest(formio, 'accessInfo', `${projectUrl}/access`);\n }\n /**\n * Returns an array of roles for the project, which includes the ID's and names of those roles.\n *\n * @param {Formio} formio - The Formio instance.\n * @return {Promise<Response>}\n */\n static projectRoles(formio) {\n const projectUrl = formio ? formio.projectUrl : Formio.projectUrl;\n return Formio.makeRequest(formio, 'projectRoles', `${projectUrl}/role`);\n }\n /**\n * Return the currentUser object. This will fetch the user from the server and respond with the Submission JSON\n * of that user object.\n *\n * @param {Formio} formio - The Formio instance\n * @param {object} options - The options passed to {@link Formio.getUser}\n * @return {Promise<R>|*}\n */\n static currentUser(formio, options = {}) {\n let authUrl = Formio.authUrl;\n if (!authUrl) {\n authUrl = formio ? formio.projectUrl : Formio.projectUrl || Formio.baseUrl;\n }\n authUrl += '/current';\n if (!options.ignoreCache || options.fromCurrent) {\n const user = Formio.getUser(options);\n if (user) {\n return Plugins_1.default.pluginAlter('wrapStaticRequestPromise', Promise.resolve(user), {\n url: authUrl,\n method: 'GET',\n options,\n });\n }\n }\n const token = Formio.getToken(options);\n if ((!options || !options.external) && !token) {\n return Plugins_1.default.pluginAlter('wrapStaticRequestPromise', Promise.resolve(null), {\n url: authUrl,\n method: 'GET',\n options,\n });\n }\n options.fromCurrent = true;\n return Formio.makeRequest(formio, 'currentUser', authUrl, 'GET', null, options).then((response) => {\n Formio.setUser(response, options);\n return response;\n });\n }\n /**\n * Performs a logout of the Form.io application. This will reset all cache, as well as make a request to the logout\n * endpoint of the Form.io api platform.\n *\n * @param {Formio} formio - A Formio instance.\n * @param {object} options - Options passed to both {@link Formio.setToken} as well as {@link Formio.setUser}\n * @return {Promise<Response>}\n */\n static logout(formio, options = {}) {\n options.formio = formio;\n const projectUrl = Formio.authUrl\n ? Formio.authUrl\n : formio\n ? formio.projectUrl\n : Formio.baseUrl;\n const logout = () => {\n Formio.setToken(null, options);\n Formio.setUser(null, options);\n Formio.clearCache();\n localStorage.removeItem('useSessionToken');\n };\n return Formio.makeRequest(formio, 'logout', `${projectUrl}/logout`)\n .then(function (result) {\n logout();\n if (result.shouldRedirect && result.url) {\n window.location.href = result.url;\n }\n return result;\n })\n .catch(function (err) {\n logout();\n throw err;\n });\n }\n /**\n * Returns the query passed to a page in JSON object format.\n *\n * @description For example, lets say you visit your application using\n * the url as follows.\n *\n * ```\n * https://yourapplication.com/?token=23423423423&username=Joe\n * ```\n *\n * The following code will provide your application with the following.\n *\n * ```ts\n * const query Formio.pageQuery();\n * console.log(query.token); // Will print 23423423423\n * console.log(query.username); // Will print Joe\n * ```\n *\n * @return {{}} - A JSON object representation of the query that was passed to the URL of an application.\n */\n static pageQuery() {\n const pageQuery = {};\n pageQuery.paths = [];\n const hashes = location.hash.substr(1).replace(/\\?/g, '&').split('&');\n let parts = [];\n location.search\n .substr(1)\n .split('&')\n .forEach(function (item) {\n parts = item.split('=');\n if (parts.length > 1) {\n pageQuery[parts[0]] = parts[1] && decodeURIComponent(parts[1]);\n }\n });\n hashes.forEach(function (item) {\n parts = item.split('=');\n if (parts.length > 1) {\n pageQuery[parts[0]] = parts[1] && decodeURIComponent(parts[1]);\n }\n else if (item.indexOf('/') === 0) {\n pageQuery.paths = item.substr(1).split('/');\n }\n });\n return pageQuery;\n }\n /**\n * Much like {@link Formio.currentUser}, but instead automatically injects the Bearer tokens into the headers to\n * perform a Token swap of the OAuth token which will then return the JWT token for that user.\n *\n * @param {Formio} formio - The Formio instance\n * @param {string} token - An OAuth Bearer token to use for a token swap between the OAuth provider and Form.io\n * @return {Promise<R>|*}\n */\n static oAuthCurrentUser(formio, token) {\n return Formio.currentUser(formio, {\n external: true,\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n }\n static oauthLogoutURI(uri, options) {\n options = typeof options === 'string' ? { namespace: options } : options || {};\n const logoutURIName = `${options.namespace || Formio.namespace || 'formio'}LogoutAuthUrl`;\n localStorage.setItem(logoutURIName, uri);\n return Formio.tokens[logoutURIName];\n }\n /**\n * Perform a SAML initialization.\n *\n * @description Typically, you would use the {@link Formio.ssoInit} method to perform this function\n * since this method is an alias for the following.\n *\n * ```ts\n * Formio.samlInit();\n * Formio.ssoInit('saml'); // This is the exact same thing as calling Formio.samlInit\n * ```\n *\n * This method will return false if the process is just starting. The code below is a typical block of code that is\n * used to automatically trigger the SAML authentication process within your application using a Button component.\n *\n * ```ts\n * if (Formio.pageQuery().saml) {\n * const sso = Formio.samlInit();\n * if (sso) {\n * sso.then((user) => {\n * // The SSO user is now loaded!\n * console.log(user);\n * });\n * }\n * }\n * ```\n *\n * You can then place the following code withiin the \"Custom\" action of a Button component on your form.\n *\n * ```ts\n * Formio.samlInit();\n * ```\n *\n * Now when you click on this button, it will start the handshake process with SAML, and once it returns, will pass\n * a \"saml\" query parameter back to your application which will execute the code to load the current user from SAML.\n *\n * @param {object} options - Options to pass to the SAML initialization process.\n * @param {string} options.relay - The URL that will be used as the authentication \"relay\" that occurs during a SAML handshake process.\n * @return {boolean|Promise<Object>|void}\n */\n static samlInit(options = {}) {\n const query = Formio.pageQuery();\n if (query.saml) {\n Formio.setUser(null);\n const retVal = Formio.setToken(query.saml);\n let uri = window.location.toString();\n uri = uri.substring(0, uri.indexOf('?'));\n if (window.location.hash) {\n uri += window.location.hash;\n }\n window.history.replaceState({}, document.title, uri);\n return retVal;\n }\n // Set the relay if not provided.\n if (!options.relay) {\n options.relay = window.location.href;\n }\n // go to the saml sso endpoint for this project.\n const authUrl = Formio.authUrl || Formio.projectUrl;\n window.location.href = `${authUrl}/saml/sso?relay=${encodeURI(options.relay)}`;\n return false;\n }\n /**\n * Perform an Okta Authentication process using the {@link https://developer.okta.com/code/javascript/okta_auth_sdk|Okta SDK}.\n *\n * @description This method does require that you first include the Okta JavaScript SDK within your application as follows.\n *\n * First you need to include the Okta Authentication script.\n *\n * ```html\n * <script src=\"https://ok1static.oktacdn.com/assets/js/sdk/okta-auth-js/2.0.1/okta-auth-js.min.js\" type=\"text/javascript\"></script>\n * ```\n *\n * Then you can call this method as follows.\n *\n * ```ts\n * Formio.oktaInit();\n * ```\n *\n * @param {object} options - Options that are passed directly to the {@link https://github.com/okta/okta-auth-js#configuration-reference|Okta SDK constructor}\n * @param {constructor} options.OktaAuth - If the OktaAuth constructor is not provided global to the application, it can be provided to this method using this property.\n * @param {Formio} options.formio - The Formio instance.\n * @param {Array<string>} options.scopes - Scopes that are passed to the {@link https://github.com/okta/okta-auth-js#tokengetwithredirectoptions|getWithRedirect} method from the Okta SDK.\n * @return {Promise<Object>}\n */\n static oktaInit(options = {}) {\n if (typeof OktaAuth !== 'undefined') {\n options.OktaAuth = OktaAuth;\n }\n if (typeof options.OktaAuth === 'undefined') {\n const errorMessage = 'Cannot find OktaAuth. Please include the Okta JavaScript SDK within your application. See https://developer.okta.com/code/javascript/okta_auth_sdk for an example.';\n console.warn(errorMessage);\n return Promise.reject(errorMessage);\n }\n return new Promise((resolve, reject) => {\n const Okta = options.OktaAuth;\n delete options.OktaAuth;\n const authClient = new Okta(options);\n authClient.tokenManager\n .get('accessToken')\n .then((accessToken) => {\n if (accessToken) {\n resolve(Formio.oAuthCurrentUser(options.formio, accessToken.accessToken));\n }\n else if (location.hash) {\n authClient.token\n .parseFromUrl()\n .then((token) => {\n authClient.tokenManager.add('accessToken', token);\n resolve(Formio.oAuthCurrentUser(options.formio, token.accessToken));\n })\n .catch((err) => {\n console.warn(err);\n reject(err);\n });\n }\n else {\n authClient.token.getWithRedirect({\n responseType: 'token',\n scopes: options.scopes,\n });\n resolve(false);\n }\n })\n .catch((error) => {\n reject(error);\n });\n });\n }\n /**\n * A common static method to trigger any SSO processes. This method is really just an alias for other static methods.\n *\n * @param {('saml'|'okta')} type - The type of SSO to trigger. 'saml' is an alias for {@link Formio.samlInit}, and 'okta' is an alias for {@link Formio.oktaInit}.\n * @param {object} options - Options to pass to the specific sso methods\n * @return {*|Promise<Object>|boolean|void}\n */\n static ssoInit(type, options = {}) {\n switch (type) {\n case 'saml':\n return Formio.samlInit(options);\n case 'okta':\n return Formio.oktaInit(options);\n default:\n console.warn('Unknown SSO type');\n return Promise.reject('Unknown SSO type');\n }\n }\n /**\n * Lazy load a remote library dependency.\n *\n * @description This is useful for components that wish to lazy load a required library\n * by adding that library to the <scripts> section of the HTML webpage, and then provide a promise that will resolve\n * when the library becomes available for use.\n *\n * @example Load Google Maps API.\n * ```ts\n * Formio.requireLibrary('googleMaps', 'google.maps.Map', 'https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap', true).then(() => {\n * // Once the promise resolves, the following can now be used within your application.\n * const map = new google.maps.Map(document.getElementById(\"map\"), {...});\n * });\n * ```\n *\n * @param {string} name - The internal name to give to the library you are loading. This is useful for caching the library for later use.\n * @param {string} property - The name of the global property that will be added to the global namespace once the library has been loaded. This is used to check to see if the property exists before resolving the promise that the library is ready for use.\n * @param {string} src - The URL of the library to lazy load.\n * @param {boolean} polling - Determines if polling should be used to determine if they library is ready to use. If set to false, then it will rely on a global callback called ${name}Callback where \"name\" is the first property passed to this method. When this is called, that will indicate when the library is ready. In most cases, you will want to pass true to this parameter to initiate a polling method to check for the library availability in the global context.\n * @param {HTMLElement} rootElement - The element after which the resource would be attached (useful when requiring resources from ShadowRoot).\n * @return {Promise<object>} - A promise that will resolve when the plugin is ready to be used.\n */\n static requireLibrary(name, property, src, polling = false, onload, rootElement) {\n const resourceToDomOptions = {\n name,\n src,\n formio: Formio,\n onload,\n rootElement,\n };\n let hasResourceBeenAdded = false;\n if (!Formio.libraries.hasOwnProperty(name)) {\n Formio.libraries[name] = {};\n Formio.libraries[name].ready = new Promise((resolve, reject) => {\n Formio.libraries[name].resolve = resolve;\n Formio.libraries[name].reject = reject;\n });\n const callbackName = `${name}Callback`;\n if (!polling && !window[callbackName]) {\n window[callbackName] = () => Formio.libraries[name].resolve();\n }\n // See if the plugin already exists.\n const plugin = (0, lodash_1.get)(window, property);\n if (plugin) {\n Formio.libraries[name].resolve(plugin);\n }\n else {\n (0, utils_1.attachResourceToDom)(resourceToDomOptions);\n hasResourceBeenAdded = true;\n // if no callback is provided, then check periodically for the script.\n if (polling) {\n const interval = setInterval(() => {\n const plugin = (0, lodash_1.get)(window, property);\n if (plugin) {\n clearInterval(interval);\n Formio.libraries[name].resolve(plugin);\n }\n }, 200);\n }\n }\n }\n const lib = Formio.libraries[name];\n if (rootElement && !hasResourceBeenAdded) {\n (0, utils_1.attachResourceToDom)(resourceToDomOptions);\n }\n return onload && lib.loaded ? onload(lib.ready) : lib.ready;\n }\n /**\n * Determines if a lazy loaded library is ready to be used.\n *\n * @description Example: Let's assume that the example provided at {@link Formio.requireLibrary} was used elsewhere in your application.\n * You could now use the following within a separate place that will also resolve once the library is ready to be used.\n *\n * ```js\n * Formio.libraryReady('googleMaps').then(() => {\n * // Once the promise resolves, the following can now be used within your application.\n * const map = new google.maps.Map(document.getElementById(\"map\"), {...});\n * });\n * ```\n *\n * @param {string} name - The name of the library to check.\n * @return {Promise<object>} - A promise that will resolve when the library is ready to be used.\n */\n static libraryReady(name) {\n if (Formio.libraries.hasOwnProperty(name) && Formio.libraries[name].ready) {\n return Formio.libraries[name].ready;\n }\n return Promise.reject(`${name} library was not required.`);\n }\n /**\n * Clones the response from the API so that it cannot be mutated.\n *\n * @param response\n */\n static cloneResponse(response) {\n const copy = (0, fastCloneDeep_1.fastCloneDeep)(response);\n if (Array.isArray(response)) {\n copy.skip = response.skip;\n copy.limit = response.limit;\n copy.serverCount = response.serverCount;\n }\n return copy;\n }\n /**\n * Sets the project path type.\n *\n * @param type\n */\n static setPathType(type) {\n if (typeof type === 'string') {\n Formio.pathType = type;\n }\n }\n /**\n * Gets the project path type.\n */\n static getPathType() {\n return Formio.pathType;\n }\n}\nexports.Formio = Formio;\n/**\n * The base API url of the Form.io Platform. Example: https://api.form.io\n */\nFormio.baseUrl = 'https://api.form.io';\n/**\n * The project API url of the Form.io Project. Example: https://examples.form.io\n */\nFormio.projectUrl = '';\n/**\n * The project url to use for Authentication.\n */\nFormio.authUrl = '';\n/**\n * Set to true if the project url has been established with ```Formio.setProjectUrl()```\n */\nFormio.projectUrlSet = false;\n/**\n * The Form.io API Cache. This ensures that requests to the same API endpoint are cached.\n */\nFormio.cache = {};\n/**\n * The namespace used to save the Form.io Token's and variables within an application.\n */\nFormio.namespace = '';\n/**\n * Handles events fired within this SDK library.\n */\nFormio.events = new eventemitter3_1.default();\n/**\n * Stores all of the libraries lazy loaded with ```Formio.requireLibrary``` method.\n */\nFormio.libraries = {};\n/**\n * A direct interface to the Form.io fetch polyfill.\n */\nFormio.fetch = fetch;\n/**\n * A direct interface to the Form.io fetch Headers polyfill.\n */\nFormio.Headers = Headers;\n/**\n * All of the auth tokens for this session.\n */\nFormio.tokens = {};\n/**\n * The version of this library.\n */\nFormio.version = '---VERSION---';\n/**\n * The global options for the Formio library.\n */\nFormio.options = {};\n// Add Plugin methods.\nFormio.plugins = Plugins_1.default.plugins;\nFormio.deregisterPlugin = Plugins_1.default.deregisterPlugin;\nFormio.registerPlugin = Plugins_1.default.registerPlugin;\nFormio.getPlugin = Plugins_1.default.getPlugin;\nFormio.pluginWait = Plugins_1.default.pluginWait;\nFormio.pluginGet = Plugins_1.default.pluginGet;\nFormio.pluginAlter = Plugins_1.default.pluginAlter;\n// Adds Formio to the Plugins Interface.\nPlugins_1.default.Formio = Formio;\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/core/lib/sdk/Formio.js?");
|
4590
4601
|
|
4591
4602
|
/***/ }),
|
4592
4603
|
|
@@ -5256,7 +5267,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5256
5267
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
5257
5268
|
|
5258
5269
|
"use strict";
|
5259
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst process_1 = __webpack_require__(/*! @formio/core/process */ \"./node_modules/@formio/core/lib/process/index.js\");\nconst components_1 = __webpack_require__(/*! @formio/bootstrap/components */ \"./node_modules/@formio/bootstrap/lib/cjs/templates/components/index.js\");\nconst NestedArrayComponent_1 = __importDefault(__webpack_require__(/*! ../_classes/nestedarray/NestedArrayComponent */ \"./lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js\"));\nconst Component_1 = __importDefault(__webpack_require__(/*! ../_classes/component/Component */ \"./lib/cjs/components/_classes/component/Component.js\"));\nconst Alert_1 = __importDefault(__webpack_require__(/*! ../alert/Alert */ \"./lib/cjs/components/alert/Alert.js\"));\nconst utils_1 = __webpack_require__(/*! ../../utils/utils */ \"./lib/cjs/utils/utils.js\");\nconst EditRowState = {\n New: 'new',\n Editing: 'editing',\n Saving: 'saving',\n Saved: 'saved',\n Viewing: 'viewing',\n Removed: 'removed',\n Draft: 'draft',\n};\nclass EditGridComponent extends NestedArrayComponent_1.default {\n static schema(...extend) {\n return NestedArrayComponent_1.default.schema({\n type: 'editgrid',\n label: 'Edit Grid',\n key: 'editGrid',\n clearOnHide: true,\n input: true,\n tree: true,\n removeRow: 'Cancel',\n defaultOpen: false,\n openWhenEmpty: false,\n modal: false,\n components: [],\n inlineEdit: false,\n templates: {\n header: EditGridComponent.defaultHeaderTemplate,\n row: EditGridComponent.defaultRowTemplate,\n tableHeader: EditGridComponent.defaultTableHeaderTemplate,\n tableRow: EditGridComponent.defaultTableRowTemplate,\n footer: '',\n },\n }, ...extend);\n }\n static get builderInfo() {\n return {\n title: 'Edit Grid',\n icon: 'tasks',\n group: 'data',\n documentation: '/userguide/form-building/data-components#edit-grid',\n showPreview: false,\n weight: 30,\n schema: EditGridComponent.schema(),\n };\n }\n static get defaultHeaderTemplate() {\n return `<div class=\"row\">\n {% util.eachComponent(components, function(component) { %}\n {% if (displayValue(component)) { %}\n <div class=\"col-sm-2\">{{ t(component.label) }}</div>\n {% } %}\n {% }) %}\n </div>`;\n }\n static get defaultTableHeaderTemplate() {\n return `\n <tr>\n {% util.eachComponent(components, function(component) { %}\n {% if (!component.hasOwnProperty('tableView') || component.tableView) { %}\n <td class=\"editgrid-table-column\">{{ component.label }}</td>\n {% } %}\n {% }) %}\n {% if (!instance.options.readOnly && !instance.disabled) { %}\n <td class=\"editgrid-table-column\">Actions</td>\n {% } %}\n </tr>\n `;\n }\n static get defaultRowTemplate() {\n return `<div class=\"row\">\n {% util.eachComponent(components, function(component) { %}\n {% if (displayValue(component)) { %}\n <div class=\"col-sm-2\">\n {{ isVisibleInRow(component) ? getView(component, row[component.key]) : ''}}\n </div>\n {% } %}\n {% }) %}\n {% if (!instance.options.readOnly && !instance.disabled) { %}\n <div class=\"col-sm-2\">\n <div class=\"btn-group pull-right\">\n <button class=\"btn btn-default btn-light btn-sm editRow\"><i class=\"{{ iconClass('edit') }}\"></i></button>\n {% if (!instance.hasRemoveButtons || instance.hasRemoveButtons()) { %}\n <button class=\"btn btn-danger btn-sm removeRow\"><i class=\"{{ iconClass('trash') }}\"></i></button>\n {% } %}\n </div>\n </div>\n {% } %}\n </div>`;\n }\n static get defaultTableRowTemplate() {\n return `\n {% util.eachComponent(components, function(component) { %}\n {% if (!component.hasOwnProperty('tableView') || component.tableView) { %}\n <td class=\"editgrid-table-column\">\n {{ getView(component, row[component.key]) }}\n </td>\n {% } %}\n {% }) %}\n {% if (!instance.options.readOnly && !instance.disabled) { %}\n <td class=\"editgrid-table-column\">\n <div class=\"btn-group\">\n <button class=\"btn btn-default btn-light btn-sm editRow\" aria-label=\"{{ t('Edit row') }}\"><i class=\"{{ iconClass('edit') }}\"></i></button>\n {% if (!instance.hasRemoveButtons || instance.hasRemoveButtons()) { %}\n <button class=\"btn btn-danger btn-sm removeRow\" aria-label=\"{{ t('Remove row') }}\"><i class=\"{{ iconClass('trash') }}\"></i></button>\n {% } %}\n </div>\n </td>\n {% } %}\n `;\n }\n get defaultDialogTemplate() {\n return `\n <h3 ${this._referenceAttributeName}=\"dialogHeader\">${this.t('Do you want to clear data?')}</h3>\n <div style=\"display:flex; justify-content: flex-end;\">\n <button ${this._referenceAttributeName}=\"dialogCancelButton\" class=\"btn btn-secondary\" aria-label=\"${this.t('Cancel')}\">${this.t('Cancel')}</button>\n <button ${this._referenceAttributeName}=\"dialogYesButton\" class=\"btn btn-danger\" aria-label=\"${this.t('Yes, delete it')}\">${this.t('Yes, delete it')}</button>\n </div>\n `;\n }\n get defaultRowTemplate() {\n return this.displayAsTable\n ? EditGridComponent.defaultTableRowTemplate\n : EditGridComponent.defaultRowTemplate;\n }\n get defaultHeaderTemplate() {\n return this.displayAsTable\n ? EditGridComponent.defaultTableHeaderTemplate\n : EditGridComponent.defaultHeaderTemplate;\n }\n get rowTemplate() {\n let rowTemplate;\n if (utils_1.Evaluator.noeval) {\n rowTemplate = this.displayAsTable ?\n components_1.editgrid.tableRow\n : components_1.editgrid.row;\n }\n else {\n rowTemplate = this.displayAsTable ?\n lodash_1.default.get(this.component, 'templates.tableRow', this.defaultRowTemplate)\n : lodash_1.default.get(this.component, 'templates.row', this.defaultRowTemplate);\n }\n return rowTemplate;\n }\n get headerTemplate() {\n let headerTemplate;\n if (utils_1.Evaluator.noeval) {\n headerTemplate = this.displayAsTable ?\n components_1.editgrid.tableHeader\n : components_1.editgrid.header;\n }\n else {\n headerTemplate = this.displayAsTable ?\n lodash_1.default.get(this.component, 'templates.tableHeader', this.defaultHeaderTemplate)\n : lodash_1.default.get(this.component, 'templates.header', this.defaultHeaderTemplate);\n }\n return headerTemplate;\n }\n /**\n * @returns {boolean} - Returns true if the component has nested components which don't trigger changes on the root level\n */\n get hasScopedChildren() {\n return !this.inlineEditMode;\n }\n get defaultSchema() {\n return EditGridComponent.schema();\n }\n get emptyValue() {\n return [];\n }\n get editgridKey() {\n return `editgrid-${this.key}`;\n }\n get rowRef() {\n return `${this.editgridKey}-row`;\n }\n get rowElements() {\n return this.refs[this.rowRef];\n }\n get rowRefs() {\n return this.refs[`editgrid-${this.component.key}-row`];\n }\n get addRowRef() {\n return `${this.editgridKey}-addRow`;\n }\n get addRowElements() {\n return this.refs[this.addRowRef];\n }\n get saveRowRef() {\n return `${this.editgridKey}-saveRow`;\n }\n get saveRowElements() {\n return this.refs[this.saveRowRef];\n }\n get cancelRowRef() {\n return `${this.editgridKey}-cancelRow`;\n }\n get cancelRowElements() {\n return this.refs[this.cancelRowRef];\n }\n get inlineEditMode() {\n return this.component.inlineEdit;\n }\n get saveEditMode() {\n return !this.inlineEditMode;\n }\n get minLength() {\n return this.builderMode ? 0 : lodash_1.default.get(this.component, 'validate.minLength', 0);\n }\n get data() {\n return this._data;\n }\n get dataValue() {\n return super.dataValue || [];\n }\n set dataValue(value) {\n super.dataValue = value;\n }\n get displayAsTable() {\n return this.component.displayAsTable;\n }\n set data(value) {\n this._data = value;\n const data = this.dataValue;\n (this.editRows || []).forEach((row, index) => {\n if (!data[index] && row.state !== EditRowState.New) {\n data[index] = {};\n }\n const rowData = data[index] || {};\n row.data = rowData;\n row.components.forEach((component) => {\n component.data = rowData;\n });\n });\n }\n get iteratableRows() {\n return this.editRows;\n }\n get defaultValue() {\n const value = super.defaultValue;\n const defaultValue = Array.isArray(value) ? value : [];\n lodash_1.default.times(this.minLength - defaultValue.length, () => defaultValue.push({}));\n return defaultValue;\n }\n constructor(...args) {\n super(...args);\n this.type = 'editgrid';\n }\n hasRemoveButtons() {\n return !this.component.disableAddingRemovingRows &&\n !this.options.readOnly &&\n !this.disabled &&\n this.fullMode &&\n (this.dataValue.length > lodash_1.default.get(this.component, 'validate.minLength', 0));\n }\n init() {\n if (this.builderMode) {\n this.editRows = [];\n return super.init();\n }\n this.components = this.components || [];\n const dataValue = this.dataValue;\n const openWhenEmpty = !dataValue.length && this.component.openWhenEmpty;\n if (openWhenEmpty) {\n const dataObj = {};\n this.editRows = [];\n this.createRow(dataObj, 0);\n }\n else {\n this.editRows = dataValue.map((row, rowIndex) => ({\n components: this.lazyLoad ? [] : this.createRowComponents(row, rowIndex),\n data: row,\n state: EditRowState.Saved,\n backup: null,\n error: null,\n rowIndex,\n }));\n }\n this.prevHasAddButton = this.hasAddButton();\n this.checkData();\n this.setVariableTypeComponents();\n if (this.variableTypeComponentsIndexes.length) {\n lodash_1.default.each(this.editRows || [], (editRow, rowIndex) => this.checkRowVariableTypeComponents(editRow, rowIndex));\n }\n }\n checkRowVariableTypeComponents(editRow, rowIndex) {\n const rowComponents = editRow.components;\n if (lodash_1.default.some(this.variableTypeComponentsIndexes, (compIndex) => {\n const variableTypeComp = rowComponents[compIndex];\n return variableTypeComp.type !== variableTypeComp.component.type;\n })) {\n editRow.components = this.createRowComponents(editRow.data, rowIndex, true);\n }\n }\n setVariableTypeComponents() {\n //set components which type is changing within a row (e.g.,by mergeComponentSchema action)\n this.variableTypeComponentsIndexes = [];\n lodash_1.default.each(this.component.components, (comp, index) => {\n if (comp.typeChangeEnabled) {\n this.variableTypeComponentsIndexes.push(index);\n }\n });\n }\n isOpen(editRow) {\n return [EditRowState.New, EditRowState.Editing, EditRowState.Viewing].includes(editRow.state);\n }\n isComponentVisibleInSomeRow(component) {\n const rows = this.editRows;\n const savedStates = [EditRowState.Saved, EditRowState.Editing, EditRowState.Draft];\n const savedRows = rows.filter(row => lodash_1.default.includes(savedStates, row.state));\n this.visibleInHeader = this.visibleInHeader || [];\n const changeVisibleInHeader = (component, isVisible) => {\n if (!isVisible) {\n lodash_1.default.remove(this.visibleInHeader, (key) => key === component.key);\n }\n if (isVisible && !lodash_1.default.includes(this.visibleInHeader, component.key)) {\n this.visibleInHeader.push(component.key);\n }\n };\n if (lodash_1.default.isEmpty(rows)) {\n const rowComponents = this.createRowComponents({}, 0);\n let checkComponent;\n (0, utils_1.eachComponent)(rowComponents, (comp) => {\n if (comp.component.key === component.key) {\n checkComponent = comp;\n }\n comp.checkConditions();\n });\n const isVisible = checkComponent ? checkComponent.visible : true;\n [...this.components].forEach((comp) => this.removeComponent(comp, this.components));\n changeVisibleInHeader(component, isVisible);\n return isVisible;\n }\n const isOpenRowWhenEmpty = lodash_1.default.get(this.component, 'openWhenEmpty') && rows.length === 1 && rows[0].state === EditRowState.New;\n if (!lodash_1.default.isEmpty(rows) && lodash_1.default.isEmpty(savedRows) && !isOpenRowWhenEmpty) {\n return lodash_1.default.includes(this.visibleInHeader, component.key);\n }\n return lodash_1.default.some(isOpenRowWhenEmpty ? rows : savedRows, (row, index) => {\n const editingRow = row.state === EditRowState.Editing;\n let isVisible;\n if (!editingRow) {\n const flattenedComponents = this.flattenComponents(index);\n const instance = flattenedComponents[component.key];\n isVisible = instance ? instance.visible : true;\n changeVisibleInHeader(component, isVisible);\n }\n else {\n isVisible = lodash_1.default.includes(this.visibleInHeader, component.key);\n }\n return isVisible;\n });\n }\n render(children) {\n if (this.builderMode) {\n return super.render();\n }\n const dataValue = this.dataValue;\n const headerTemplate = this.headerTemplate;\n const t = this.t.bind(this);\n const templateName = this.displayAsTable ? 'editgridTable' : 'editgrid';\n return super.render(children || this.renderTemplate(templateName, {\n ref: {\n row: this.rowRef,\n addRow: this.addRowRef,\n saveRow: this.saveRowRef,\n cancelRow: this.cancelRowRef,\n },\n header: this.renderString(headerTemplate, {\n displayValue: (component) => this.displayComponentValue(component, true),\n components: this.component.components,\n value: dataValue,\n t\n }),\n footer: this.renderString(lodash_1.default.get(this.component, 'templates.footer'), {\n components: this.component.components,\n value: dataValue,\n t\n }),\n rows: this.editRows.map(this.renderRow.bind(this)),\n openRows: this.editRows.map((row) => this.isOpen(row)),\n errors: this.editRows.map((row) => row.error),\n hasAddButton: this.hasAddButton(),\n hasRemoveButtons: this.hasRemoveButtons(),\n }));\n }\n renderComponents(components) {\n components = components || this.getComponents();\n const children = components.map(component => component.render());\n const templateName = this.displayAsTable && this.prevHasAddButton ? 'tableComponents' : 'components';\n return this.renderTemplate(templateName, {\n children,\n components,\n });\n }\n attach(element) {\n if (this.builderMode) {\n return super.attach(element);\n }\n this.loadRefs(element, {\n [this.addRowRef]: 'multiple',\n [this.saveRowRef]: 'multiple',\n [this.cancelRowRef]: 'multiple',\n [this.rowRef]: 'multiple',\n });\n this.addRowElements.forEach((addButton) => {\n this.addEventListener(addButton, 'click', () => this.addRow());\n });\n let openRowCount = 0;\n this.rowElements.forEach((row, rowIndex) => {\n const editRow = this.editRows[rowIndex];\n if (editRow === null || editRow === void 0 ? void 0 : editRow.isRowSelected) {\n row.classList.add('selected');\n }\n if (this.isOpen(editRow)) {\n this.attachComponents(row, editRow.components);\n this.addEventListener(this.saveRowElements[openRowCount], 'click', () => this.saveRow(rowIndex, true));\n this.addEventListener(this.cancelRowElements[openRowCount], 'click', () => this.cancelRow(rowIndex));\n openRowCount++;\n }\n else {\n // Attach edit and remove button events.\n [\n {\n className: 'removeRow',\n event: 'click',\n action: () => this.removeRow(rowIndex, true),\n },\n {\n className: 'editRow',\n event: 'click',\n action: () => {\n this.editRow(rowIndex).then(() => {\n var _a;\n if (this.component.rowDrafts) {\n const errors = this.validateRow(editRow, false);\n const shouldShowRowErrorsAlert = this.component.modal && errors.length && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted);\n if (shouldShowRowErrorsAlert) {\n this.alert.showErrors(errors, false);\n editRow.alerts = true;\n }\n }\n });\n },\n },\n {\n className: 'row',\n event: 'click',\n action: () => {\n row.classList.toggle('selected');\n let eventName = 'editGridSelectRow';\n if (Array.from(row.classList).includes('selected')) {\n editRow.isRowSelected = true;\n }\n else {\n delete editRow.isRowSelected;\n eventName = 'editGridUnSelectRow';\n }\n this.emit(eventName, {\n component: this.component,\n data: this.dataValue[rowIndex]\n });\n },\n }\n ].forEach(({ className, event, action, }) => {\n const elements = row.getElementsByClassName(className);\n Array.prototype.forEach.call(elements, (element) => {\n if (this.options.pdf && lodash_1.default.intersection(element.classList, ['editRow', 'removeRow']).length) {\n element.style.display = 'none';\n }\n else {\n this.addEventListener(element, event, action);\n }\n });\n });\n }\n });\n // Add open class to the element if any edit grid row is open\n if (openRowCount) {\n this.addClass(this.refs.component, `formio-component-${this.component.type}-row-open`);\n }\n else {\n this.removeClass(this.refs.component, `formio-component-${this.component.type}-row-open`);\n }\n return super.attach(element);\n }\n flattenRowDataValue(dataValue) {\n const flattened = {};\n Object.keys(dataValue).forEach((key) => {\n if (lodash_1.default.isObject(dataValue[key]) && !lodash_1.default.isNil(dataValue[key])) {\n Object.assign(flattened, this.flattenRowDataValue(dataValue[key]));\n }\n else {\n flattened[key] = dataValue[key];\n }\n });\n return flattened;\n }\n isComponentVisibleInRow(component, flattenedComponents) {\n const instance = flattenedComponents[component.key];\n return instance ? instance.visible : true;\n }\n displayComponentValue(component, header) {\n return !!((!component.hasOwnProperty('tableView') || component.tableView)\n && header ? this.isComponentVisibleInSomeRow(component) : lodash_1.default.includes(this.visibleInHeader, component.key));\n }\n renderRow(row, rowIndex) {\n const dataValue = this.dataValue;\n if (this.isOpen(row)) {\n return this.renderComponents(row.components);\n }\n else {\n const flattenedComponents = this.flattenComponents(rowIndex);\n const rowTemplate = this.rowTemplate;\n return this.renderString(rowTemplate, {\n row: dataValue[rowIndex] || {},\n data: this.data,\n rowIndex,\n components: this.component.components,\n flattenedComponents,\n displayValue: (component) => this.displayComponentValue(component),\n isVisibleInRow: (component) => this.isComponentVisibleInRow(component, flattenedComponents),\n getView: (component, data) => {\n var _a, _b;\n const instance = flattenedComponents[component.key];\n const view = instance ? instance.getView(data || instance.dataValue) : '';\n // If there is an html tag in view, don't allow it to be injected in template\n const htmlTagRegExp = new RegExp('<(.*?)>');\n return typeof view === 'string' && view.length && !((_a = instance.component) === null || _a === void 0 ? void 0 : _a.template) && htmlTagRegExp.test(view) && ((_b = instance.component) === null || _b === void 0 ? void 0 : _b.inputFormat) !== 'html'\n ? `<input type=\"text\" value=\"${view.replace(/\"/g, '"')}\" readonly/>`\n : view;\n },\n state: this.editRows[rowIndex].state,\n t: this.t.bind(this)\n });\n }\n }\n eachComponent(fn, rowIndex) {\n lodash_1.default.each(this.getComponents(rowIndex), (component, index) => {\n if (fn(component, index) === false) {\n return false;\n }\n });\n }\n restoreComponentsContext() {\n this.getComponents().forEach((component) => {\n var _a;\n const rowData = this.dataValue[component.rowIndex];\n const editRowData = (_a = this.editRows[component.rowIndex]) === null || _a === void 0 ? void 0 : _a.data;\n component.data = rowData || editRowData;\n });\n }\n flattenComponents(rowIndex) {\n const result = {};\n this.everyComponent((component) => {\n result[component.component.flattenAs || component.key] = component;\n }, rowIndex);\n return result;\n }\n getComponents(rowIndex) {\n var _a;\n // Ensure editrows is set.\n this.editRows = this.editRows || [];\n return this.builderMode\n ? super.getComponents()\n : lodash_1.default.isNumber(rowIndex)\n ? (((_a = this.editRows[rowIndex]) === null || _a === void 0 ? void 0 : _a.components) || [])\n : this.editRows.reduce((result, row) => result.concat(row.components || []), []);\n }\n destroy(all = false) {\n this.calculatedValue = undefined;\n super.destroy(all);\n }\n destroyComponents(all = false, rowIndex = 0) {\n if (this.builderMode) {\n return super.destroyComponents(all);\n }\n const components = this.getComponents(rowIndex).slice();\n components.forEach((comp) => this.removeComponent(comp, this.components, all));\n }\n createRow(dataObj, rowIndex) {\n const editRow = {\n components: this.createRowComponents(dataObj, rowIndex),\n data: dataObj,\n state: EditRowState.New,\n backup: null,\n error: null,\n rowIndex,\n };\n this.editRows.push(editRow);\n if (this.inlineEditMode) {\n this.dataValue.push(dataObj);\n }\n return editRow;\n }\n addRow() {\n if (this.options.readOnly) {\n return;\n }\n const dataObj = {};\n const rowIndex = this.editRows.length;\n const editRow = this.createRow(dataObj, rowIndex);\n if (editRow.state === EditRowState.New) {\n this.emptyRow = (0, utils_1.fastCloneDeep)(editRow.data);\n }\n if (this.inlineEditMode) {\n this.triggerChange();\n }\n this.emit('editGridAddRow', {\n component: this.component,\n row: editRow,\n });\n this.processRow('checkData', null, {}, editRow.data, editRow.components);\n if (this.component.modal) {\n this.addRowModal(rowIndex);\n }\n else {\n this.redraw();\n }\n return editRow;\n }\n addRowModal(rowIndex) {\n const modalContent = this.ce('div');\n const editRow = this.editRows[rowIndex];\n editRow.willBeSaved = false;\n const { components } = editRow;\n modalContent.innerHTML = this.renderComponents(components);\n const dialog = this.component.modal ? this.createModal(modalContent, {}, () => this.showDialog(rowIndex)) : undefined;\n dialog.classList.add(`editgrid-row-modal-${this.id}`);\n editRow.dialog = dialog;\n if (this.alert) {\n this.alert.clear();\n this.alert = null;\n }\n this.alert = new Alert_1.default(dialog.refs.dialogContents, this);\n this.addEventListener(dialog, 'close', () => {\n if (!editRow.willBeSaved) {\n if (this.editRows[rowIndex] && this.editRows[rowIndex].state !== EditRowState.New) {\n this.editRows[rowIndex].components.forEach((comp) => {\n comp.setPristine(true);\n });\n }\n this.cancelRow(rowIndex);\n }\n if (this.alert) {\n this.alert.clear();\n this.alert = null;\n }\n // Remove references to dialog elements to prevent possible in some cases memory leaks\n delete editRow.confirmationDialog;\n delete editRow.dialog;\n });\n dialog.refs.dialogContents.appendChild(this.ce('button', {\n class: 'btn btn-primary',\n onClick: () => {\n // After an attempt to save, all the components inside the row should become not pristine\n if (!this.component.rowDrafts) {\n editRow.components.forEach((comp) => comp.setPristine(false));\n }\n const errors = this.validateRow(editRow, true);\n if (!errors.length || this.component.rowDrafts) {\n editRow.willBeSaved = true;\n dialog.close();\n this.saveRow(rowIndex, true);\n }\n else {\n this.alert.showErrors(errors, false);\n editRow.alerts = true;\n }\n },\n }, this.component.saveRow || 'Save'));\n return this.attachComponents(modalContent, components);\n }\n showDialog(rowIndex) {\n const editRow = this.editRows[rowIndex];\n if (editRow.state === EditRowState.New ? lodash_1.default.isEqual(this.emptyRow, editRow.data) : lodash_1.default.isEqual(editRow.backup, editRow.data)) {\n return Promise.resolve();\n }\n const wrapper = this.ce('div', { ref: 'confirmationDialog' });\n const dialogContent = this.component.dialogTemplate || this.defaultDialogTemplate;\n wrapper.innerHTML = dialogContent;\n wrapper.refs = {};\n this.loadRefs.call(wrapper, wrapper, {\n dialogHeader: 'single',\n dialogCancelButton: 'single',\n dialogYesButton: 'single',\n });\n const dialog = this.createModal(wrapper);\n dialog.classList.add(`editgrid-row-modal-confirmation-${this.id}`);\n const close = (event) => {\n event.preventDefault();\n dialog.close();\n };\n let dialogResult;\n const promise = new Promise((resolve, reject) => {\n dialogResult = { resolve, reject };\n });\n this.addEventListener(wrapper.refs.dialogYesButton, 'click', (event) => {\n close(event);\n dialogResult.resolve();\n });\n this.addEventListener(wrapper.refs.dialogCancelButton, 'click', (event) => {\n close(event);\n dialogResult.reject();\n });\n editRow.confirmationDialog = dialog;\n return promise;\n }\n editRow(rowIndex) {\n const editRow = this.editRows[rowIndex];\n const isAlreadyEditing = editRow.state === EditRowState.Editing || editRow.state === EditRowState.New;\n if (!editRow || isAlreadyEditing) {\n return Promise.resolve();\n }\n editRow.prevState = editRow.state;\n editRow.state = this.options.readOnly ? EditRowState.Viewing : EditRowState.Editing;\n if (this.lazyLoad && (editRow.components.length === 0)) {\n editRow.components = this.createRowComponents(editRow.data, rowIndex);\n }\n const dataSnapshot = (0, utils_1.fastCloneDeep)(editRow.data);\n if (this.inlineEditMode) {\n editRow.backup = dataSnapshot;\n }\n else {\n editRow.backup = (0, utils_1.fastCloneDeep)(editRow.data);\n editRow.data = dataSnapshot;\n this.restoreRowContext(editRow);\n }\n if (this.component.modal) {\n return this.addRowModal(rowIndex);\n }\n return this.redraw();\n }\n clearErrors(rowIndex) {\n const editRow = this.editRows[rowIndex];\n if (editRow && Array.isArray(editRow.components)) {\n editRow.components.forEach((comp) => {\n comp.setPristine(true);\n comp.setCustomValidity('');\n });\n }\n }\n cancelRow(rowIndex) {\n if (this.options.readOnly) {\n return;\n }\n const editRow = this.editRows[rowIndex];\n switch (editRow.state) {\n case EditRowState.New: {\n editRow.state = EditRowState.Removed;\n this.clearErrors(rowIndex);\n this.destroyComponents(false, rowIndex);\n if (this.inlineEditMode) {\n this.splice(rowIndex);\n }\n this.editRows.splice(rowIndex, 1);\n this.openWhenEmpty();\n break;\n }\n case EditRowState.Editing: {\n editRow.state = editRow.prevState;\n if (this.inlineEditMode) {\n this.dataValue[rowIndex] = editRow.backup;\n }\n editRow.data = editRow.backup;\n editRow.backup = null;\n this.restoreRowContext(editRow);\n this.clearErrors(rowIndex);\n break;\n }\n }\n this.emit('editGridCancelRow', {\n instance: this,\n component: this.component,\n editRow,\n });\n this.checkValidity(null, true);\n this.redraw();\n if (this.component.rowDrafts) {\n this.checkValidity(this.data, false);\n }\n }\n saveRow(rowIndex, modified) {\n var _a, _b;\n const editRow = this.editRows[rowIndex];\n if (this.options.readOnly) {\n return;\n }\n // After an attempt to save, all the components inside the row should become not pristine\n if (!this.component.rowDrafts) {\n editRow.components.forEach((comp) => comp.setPristine(false));\n }\n // Mark the row with a 'Saving' state to trigger validation for future row changes\n if (editRow.state === EditRowState.New) {\n editRow.state = EditRowState.Saving;\n }\n const errors = this.validateRow(editRow, true);\n if (!this.component.rowDrafts) {\n if (errors.length) {\n return false;\n }\n }\n if (this.saveEditMode) {\n const dataValue = this.dataValue;\n if ((_b = (_a = this.root) === null || _a === void 0 ? void 0 : _a.focusedComponent) === null || _b === void 0 ? void 0 : _b.component.typeChangeEnabled) {\n this.root.focusedComponent = null;\n }\n switch (editRow.state) {\n case EditRowState.Saving: {\n const newIndex = dataValue.length;\n dataValue.push(editRow.data);\n editRow.components.forEach(component => component.rowIndex = newIndex);\n if (rowIndex !== newIndex) {\n this.editRows.splice(rowIndex, 1);\n this.editRows.splice(newIndex, 0, editRow);\n }\n break;\n }\n case EditRowState.Editing: {\n dataValue[rowIndex] = editRow.data;\n break;\n }\n }\n }\n editRow.state = this.component.rowDrafts && errors.length ? EditRowState.Draft : EditRowState.Saved;\n editRow.backup = null;\n this.updateValue();\n this.emit('editGridSaveRow', {\n component: this.component,\n row: editRow.data,\n instance: this\n });\n this.triggerChange({ modified, noPristineChangeOnModified: modified && this.component.rowDrafts, isolateRow: true });\n if (this.component.rowDrafts) {\n editRow.components.forEach(comp => comp.setPristine(this.pristine));\n }\n this.checkValidity(null, true);\n this.redraw();\n if (editRow.alerts) {\n editRow.alerts = false;\n }\n return true;\n }\n beforeFocus(component) {\n if ('beforeFocus' in this.parent) {\n this.parent.beforeFocus(this);\n }\n const relativePath = this.getRelativePath(component.path);\n const arrayPath = (0, utils_1.getArrayFromComponentPath)(relativePath);\n const rowIndex = arrayPath[0];\n let rowToEditIndex = arrayPath[0];\n this.editRows.forEach((row, indexInArray) => {\n if (row.rowIndex === rowIndex) {\n rowToEditIndex = indexInArray;\n }\n });\n if (lodash_1.default.isNumber(rowToEditIndex)) {\n this.editRow(rowToEditIndex);\n }\n }\n updateComponentsRowIndex(components, rowIndex) {\n components.forEach((component, colIndex) => {\n component.rowIndex = rowIndex;\n component.row = `${rowIndex}-${colIndex}`;\n });\n }\n updateRowsComponents(rowIndex) {\n this.editRows.slice(rowIndex).forEach((row, index) => {\n this.updateComponentsRowIndex(row.components, rowIndex + index);\n });\n }\n baseRemoveRow(rowIndex) {\n const editRow = this.editRows[rowIndex];\n editRow.state = EditRowState.Removed;\n this.destroyComponents(false, rowIndex);\n return editRow;\n }\n removeRow(rowIndex, modified) {\n if (this.options.readOnly) {\n return;\n }\n this.clearErrors(rowIndex);\n this.baseRemoveRow(rowIndex);\n this.removeSubmissionMetadataRow(rowIndex);\n this.splice(rowIndex);\n this.emit('editGridDeleteRow', {\n index: rowIndex\n });\n this.editRows.splice(rowIndex, 1);\n this.openWhenEmpty();\n this.updateRowsComponents(rowIndex);\n this.updateValue();\n this.triggerChange({ modified, noPristineChangeOnModified: modified && this.component.rowDrafts, isolateRow: true });\n this.checkValidity(null, true);\n this.checkData();\n this.redraw();\n }\n createRowComponents(row, rowIndex, recreatePartially) {\n // Iterate through existing components and destroy the ones with the same rowIndex.\n if (this.components) {\n for (let i = 0; i < this.components.length; i++) {\n if (this.components[i].rowIndex === rowIndex) {\n this.components[i].destroy();\n this.components.splice(i, 1);\n }\n }\n }\n const currentRowComponents = lodash_1.default.get(this.editRows, `[${rowIndex}].components`, null);\n return this.component.components.map((col, colIndex) => {\n var _a;\n if (recreatePartially && currentRowComponents && this.variableTypeComponentsIndexes.length) {\n const currentComp = currentRowComponents[colIndex];\n const shouldRecreate = lodash_1.default.includes(this.variableTypeComponentsIndexes, colIndex) && (currentComp === null || currentComp === void 0 ? void 0 : currentComp.type) !== ((_a = currentComp === null || currentComp === void 0 ? void 0 : currentComp.component) === null || _a === void 0 ? void 0 : _a.type);\n if (!shouldRecreate) {\n return currentComp;\n }\n col = currentComp.component;\n }\n const column = lodash_1.default.clone(col);\n const options = lodash_1.default.clone(this.options);\n options.name += `[${rowIndex}]`;\n options.row = `${rowIndex}-${colIndex}`;\n options.onChange = (flags = {}, changed, modified) => {\n var _a, _b;\n if (((_a = changed.instance.root) === null || _a === void 0 ? void 0 : _a.id) && (((_b = this.root) === null || _b === void 0 ? void 0 : _b.id) !== changed.instance.root.id)) {\n changed.instance.root.triggerChange(flags, changed, modified);\n }\n else if (!this.component.modal) {\n this.triggerRootChange(flags, changed, modified);\n }\n if (this.inlineEditMode) {\n return;\n }\n const editRow = this.editRows[rowIndex];\n if (editRow) {\n this.processRow('checkData', null, Object.assign(Object.assign({}, flags), { changed }), editRow.data, editRow.components);\n this.validateRow(editRow, false);\n }\n if (this.variableTypeComponentsIndexes.length) {\n this.checkRowVariableTypeComponents(editRow, rowIndex);\n this.redraw();\n }\n };\n const comp = this.createComponent(lodash_1.default.assign({}, column, { row: options.row }), options, row, null, recreatePartially && currentRowComponents ? currentRowComponents[colIndex] : null);\n comp.rowIndex = rowIndex;\n comp.inEditGrid = true;\n return comp;\n });\n }\n hasOpenRows() {\n return this.editRows.some(row => this.isOpen(row));\n }\n getAttachedData(data = null) {\n const ourData = (0, utils_1.fastCloneDeep)(data || this._data || this.rootValue);\n lodash_1.default.set(ourData, this.key, this.editRows.map((row) => row.data));\n return ourData;\n }\n shouldValidateDraft(editRow) {\n var _a, _b;\n // Draft rows should be validated only when there was an attempt to submit a form\n return (editRow.state === EditRowState.Draft &&\n !this.pristine &&\n !((_a = this.root) === null || _a === void 0 ? void 0 : _a.pristine) &&\n !this.hasOpenRows()) ||\n ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submitted);\n }\n shouldValidateRow(editRow, dirty, fromSubmission) {\n return this.shouldValidateDraft(editRow) ||\n editRow.state === EditRowState.Saving ||\n editRow.state === EditRowState.Editing ||\n editRow.alerts ||\n fromSubmission ||\n dirty;\n }\n validateRow(editRow, dirty, forceSilentCheck, fromSubmission) {\n var _a;\n editRow.errors = [];\n if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {\n const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;\n const rootValue = (0, utils_1.fastCloneDeep)(this.rootValue);\n const editGridValue = lodash_1.default.get(rootValue, this.path, []);\n editGridValue[editRow.rowIndex] = editRow.data;\n lodash_1.default.set(rootValue, this.path, editGridValue);\n const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });\n editRow.errors = (0, process_1.processSync)({\n components: (0, utils_1.fastCloneDeep)(this.component.components).map((component) => {\n component.parentPath = `${this.path}[${editRow.rowIndex}]`;\n return component;\n }),\n data: rootValue,\n row: editRow.data,\n process: 'validateRow',\n instances: this.componentsMap,\n scope: { errors: [] },\n processors: [\n {\n process: validationProcessorProcess,\n processSync: validationProcessorProcess\n }\n ]\n }).errors;\n }\n // TODO: this is essentially running its own custom validation and should be moved into a validation rule\n if (this.component.validate && this.component.validate.row) {\n const valid = this.evaluate(this.component.validate.row, {\n valid: (editRow.length === 0),\n row: editRow.data\n }, 'valid', true);\n if (valid.toString() !== 'true') {\n editRow.errors.push({\n type: 'error',\n rowError: true,\n message: valid.toString()\n });\n }\n if (valid === null) {\n editRow.errors.push({\n type: 'error',\n message: `Invalid row validation for ${this.key}`\n });\n }\n }\n if (!this.component.rowDrafts || ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted)) {\n this.showRowErrorAlerts(editRow, editRow.errors);\n }\n return editRow.errors;\n }\n showRowErrorAlerts(editRow, errors) {\n if (editRow.alerts) {\n if (this.alert) {\n if (errors.length) {\n this.alert.showErrors(errors, false);\n editRow.alerts = true;\n }\n else {\n this.alert.clear();\n this.alert = null;\n }\n }\n }\n }\n /**\n * @returns {boolean} - Return that this component processes its own validation.\n */\n get processOwnValidation() {\n return true;\n }\n checkComponentValidity(data, dirty, row, options = {}, errors = []) {\n var _a, _b;\n const { silentCheck, fromSubmission } = options;\n const superValid = super.checkComponentValidity(data, dirty, row, options, errors);\n // If super tells us that component invalid and there is no need to update alerts, just return false\n if (!superValid && (!this.alert && !this.hasOpenRows())) {\n return false;\n }\n let rowsEditing = false;\n const allRowErrors = [];\n this.editRows.forEach((editRow, index) => {\n // Trigger all errors on the row.\n const rowErrors = this.validateRow(editRow, dirty, silentCheck, fromSubmission);\n errors.push(...rowErrors);\n allRowErrors.push(...rowErrors);\n if (this.rowRefs) {\n const rowContainer = this.rowRefs[index];\n if (rowContainer) {\n const errorContainer = rowContainer.querySelector('.editgrid-row-error');\n if (rowErrors.length && errorContainer && (!this.component.rowDrafts || this.shouldValidateDraft(editRow))) {\n const rowError = rowErrors.find(error => error.rowError);\n this.addClass(errorContainer, 'help-block');\n errorContainer.textContent = this.t(rowError ? rowError.message : this.errorMessage('invalidRowError'));\n }\n else if (errorContainer) {\n errorContainer.textContent = '';\n this.removeClass(errorContainer, 'help-block');\n }\n }\n }\n // If this is a dirty check, and any rows are still editing, we need to throw validation error.\n rowsEditing |= (dirty && this.isOpen(editRow));\n });\n if (allRowErrors.length) {\n if (!silentCheck && (dirty || this.dirty) && (!this.component.rowDrafts || ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted))) {\n this.setCustomValidity(this.t(this.errorMessage('invalidRowsError')), dirty);\n this.removeClass(this.element, 'has-error');\n }\n return false;\n }\n else if (rowsEditing && this.saveEditMode && !this.component.openWhenEmpty) {\n this._errors = this.setCustomValidity(this.t(this.errorMessage('unsavedRowsError')), dirty);\n errors.push(...this._errors);\n return false;\n }\n const message = this.invalid || this.invalidMessage(data, dirty, false, row);\n if (allRowErrors.length && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submitted) && !message) {\n this._errors = this.setCustomValidity(message, dirty);\n errors.push(...this._errors);\n this.root.showErrors([message]);\n }\n else {\n this._errors = this.setCustomValidity(message, dirty);\n errors.push(...this._errors);\n }\n return superValid;\n }\n setRowInvalid(ref, index) {\n const editRow = this.editRows[index];\n const errorContainer = ref.querySelector('.editgrid-row-error');\n if (errorContainer && (!this.component.rowDrafts || this.shouldValidateDraft(editRow))) {\n this.addClass(errorContainer, 'help-block');\n errorContainer.textContent = this.t(this.errorMessage('invalidRowError'));\n }\n else if (errorContainer) {\n errorContainer.textContent = '';\n }\n }\n changeState(changed, flags) {\n if (this.visible && (changed || (flags.resetValue && this.component.modalEdit))) {\n this.rebuild();\n }\n else {\n this.redraw();\n }\n }\n setValue(value, flags = {}) {\n if (!value) {\n value = this.defaultValue;\n }\n if (!Array.isArray(value)) {\n if (typeof value === 'object') {\n value = [value];\n }\n else {\n return false;\n }\n }\n const changed = this.hasChanged(value, this.dataValue);\n if (this.parent && !this.options.server) {\n this.parent.checkComponentConditions();\n }\n this.dataValue = value;\n // Refresh editRow data when data changes.\n this.dataValue.forEach((row, rowIndex) => {\n const editRow = this.editRows[rowIndex];\n if (editRow) {\n editRow.data = row;\n this.restoreRowContext(editRow, flags);\n editRow.state = EditRowState.Saved;\n editRow.backup = null;\n editRow.errors = [];\n }\n else {\n this.editRows[rowIndex] = {\n components: this.lazyLoad ? [] : this.createRowComponents(row, rowIndex),\n data: row,\n state: EditRowState.Saved,\n backup: null,\n errors: [],\n };\n }\n });\n let { length: dataLength } = this.dataValue;\n // If the last row is a new row, then do not remove it.\n if (this.editRows[dataLength] && (this.editRows[dataLength].state === EditRowState.New)) {\n dataLength = (dataLength + 1);\n }\n this.editRows.slice(dataLength).forEach((editRow, index) => this.baseRemoveRow(dataLength + index));\n this.editRows = this.editRows.slice(0, dataLength);\n this.openWhenEmpty();\n this.updateOnChange(flags, changed);\n // do not call checkData with server option, it is called when change is triggered in updateOnChange\n if (!this.options.server) {\n this.checkData();\n }\n this.changeState(changed, flags);\n return changed;\n }\n openWhenEmpty() {\n const shouldBeOpened = !this.dataValue.length && this.component.openWhenEmpty;\n const hasNoRows = !this.editRows.length;\n if (hasNoRows && shouldBeOpened && !this.builderMode) {\n const dataObj = {};\n this.createRow(dataObj, 0);\n }\n }\n restoreRowContext(editRow, flags = {}) {\n editRow.components.forEach((component) => {\n component.data = editRow.data;\n this.setNestedValue(component, editRow.data, flags);\n });\n }\n emptyRows() {\n this.editRows.forEach((editRow, index) => this.destroyComponents(false, index));\n this.editRows = [];\n }\n resetValue() {\n super.resetValue();\n this.emptyRows();\n }\n}\nexports[\"default\"] = EditGridComponent;\nEditGridComponent.prototype.hasChanged = Component_1.default.prototype.hasChanged;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/editgrid/EditGrid.js?");
|
5270
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst process_1 = __webpack_require__(/*! @formio/core/process */ \"./node_modules/@formio/core/lib/process/index.js\");\nconst components_1 = __webpack_require__(/*! @formio/bootstrap/components */ \"./node_modules/@formio/bootstrap/lib/cjs/templates/components/index.js\");\nconst NestedArrayComponent_1 = __importDefault(__webpack_require__(/*! ../_classes/nestedarray/NestedArrayComponent */ \"./lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js\"));\nconst Component_1 = __importDefault(__webpack_require__(/*! ../_classes/component/Component */ \"./lib/cjs/components/_classes/component/Component.js\"));\nconst Alert_1 = __importDefault(__webpack_require__(/*! ../alert/Alert */ \"./lib/cjs/components/alert/Alert.js\"));\nconst utils_1 = __webpack_require__(/*! ../../utils/utils */ \"./lib/cjs/utils/utils.js\");\nconst EditRowState = {\n New: 'new',\n Editing: 'editing',\n Saved: 'saved',\n Viewing: 'viewing',\n Removed: 'removed',\n Draft: 'draft',\n};\nclass EditGridComponent extends NestedArrayComponent_1.default {\n static schema(...extend) {\n return NestedArrayComponent_1.default.schema({\n type: 'editgrid',\n label: 'Edit Grid',\n key: 'editGrid',\n clearOnHide: true,\n input: true,\n tree: true,\n removeRow: 'Cancel',\n defaultOpen: false,\n openWhenEmpty: false,\n modal: false,\n components: [],\n inlineEdit: false,\n templates: {\n header: EditGridComponent.defaultHeaderTemplate,\n row: EditGridComponent.defaultRowTemplate,\n tableHeader: EditGridComponent.defaultTableHeaderTemplate,\n tableRow: EditGridComponent.defaultTableRowTemplate,\n footer: '',\n },\n }, ...extend);\n }\n static get builderInfo() {\n return {\n title: 'Edit Grid',\n icon: 'tasks',\n group: 'data',\n documentation: '/userguide/form-building/data-components#edit-grid',\n showPreview: false,\n weight: 30,\n schema: EditGridComponent.schema(),\n };\n }\n static get defaultHeaderTemplate() {\n return `<div class=\"row\">\n {% util.eachComponent(components, function(component) { %}\n {% if (displayValue(component)) { %}\n <div class=\"col-sm-2\">{{ t(component.label) }}</div>\n {% } %}\n {% }) %}\n </div>`;\n }\n static get defaultTableHeaderTemplate() {\n return `\n <tr>\n {% util.eachComponent(components, function(component) { %}\n {% if (!component.hasOwnProperty('tableView') || component.tableView) { %}\n <td class=\"editgrid-table-column\">{{ component.label }}</td>\n {% } %}\n {% }) %}\n {% if (!instance.options.readOnly && !instance.disabled) { %}\n <td class=\"editgrid-table-column\">Actions</td>\n {% } %}\n </tr>\n `;\n }\n static get defaultRowTemplate() {\n return `<div class=\"row\">\n {% util.eachComponent(components, function(component) { %}\n {% if (displayValue(component)) { %}\n <div class=\"col-sm-2\">\n {{ isVisibleInRow(component) ? getView(component, row[component.key]) : ''}}\n </div>\n {% } %}\n {% }) %}\n {% if (!instance.options.readOnly && !instance.disabled) { %}\n <div class=\"col-sm-2\">\n <div class=\"btn-group pull-right\">\n <button class=\"btn btn-default btn-light btn-sm editRow\"><i class=\"{{ iconClass('edit') }}\"></i></button>\n {% if (!instance.hasRemoveButtons || instance.hasRemoveButtons()) { %}\n <button class=\"btn btn-danger btn-sm removeRow\"><i class=\"{{ iconClass('trash') }}\"></i></button>\n {% } %}\n </div>\n </div>\n {% } %}\n </div>`;\n }\n static get defaultTableRowTemplate() {\n return `\n {% util.eachComponent(components, function(component) { %}\n {% if (!component.hasOwnProperty('tableView') || component.tableView) { %}\n <td class=\"editgrid-table-column\">\n {{ getView(component, row[component.key]) }}\n </td>\n {% } %}\n {% }) %}\n {% if (!instance.options.readOnly && !instance.disabled) { %}\n <td class=\"editgrid-table-column\">\n <div class=\"btn-group\">\n <button class=\"btn btn-default btn-light btn-sm editRow\" aria-label=\"{{ t('Edit row') }}\"><i class=\"{{ iconClass('edit') }}\"></i></button>\n {% if (!instance.hasRemoveButtons || instance.hasRemoveButtons()) { %}\n <button class=\"btn btn-danger btn-sm removeRow\" aria-label=\"{{ t('Remove row') }}\"><i class=\"{{ iconClass('trash') }}\"></i></button>\n {% } %}\n </div>\n </td>\n {% } %}\n `;\n }\n get defaultDialogTemplate() {\n return `\n <h3 ${this._referenceAttributeName}=\"dialogHeader\">${this.t('Do you want to clear data?')}</h3>\n <div style=\"display:flex; justify-content: flex-end;\">\n <button ${this._referenceAttributeName}=\"dialogCancelButton\" class=\"btn btn-secondary\" aria-label=\"${this.t('Cancel')}\">${this.t('Cancel')}</button>\n <button ${this._referenceAttributeName}=\"dialogYesButton\" class=\"btn btn-danger\" aria-label=\"${this.t('Yes, delete it')}\">${this.t('Yes, delete it')}</button>\n </div>\n `;\n }\n get defaultRowTemplate() {\n return this.displayAsTable\n ? EditGridComponent.defaultTableRowTemplate\n : EditGridComponent.defaultRowTemplate;\n }\n get defaultHeaderTemplate() {\n return this.displayAsTable\n ? EditGridComponent.defaultTableHeaderTemplate\n : EditGridComponent.defaultHeaderTemplate;\n }\n get rowTemplate() {\n let rowTemplate;\n if (utils_1.Evaluator.noeval) {\n rowTemplate = this.displayAsTable ?\n components_1.editgrid.tableRow\n : components_1.editgrid.row;\n }\n else {\n rowTemplate = this.displayAsTable ?\n lodash_1.default.get(this.component, 'templates.tableRow', this.defaultRowTemplate)\n : lodash_1.default.get(this.component, 'templates.row', this.defaultRowTemplate);\n }\n return rowTemplate;\n }\n get headerTemplate() {\n let headerTemplate;\n if (utils_1.Evaluator.noeval) {\n headerTemplate = this.displayAsTable ?\n components_1.editgrid.tableHeader\n : components_1.editgrid.header;\n }\n else {\n headerTemplate = this.displayAsTable ?\n lodash_1.default.get(this.component, 'templates.tableHeader', this.defaultHeaderTemplate)\n : lodash_1.default.get(this.component, 'templates.header', this.defaultHeaderTemplate);\n }\n return headerTemplate;\n }\n /**\n * @returns {boolean} - Returns true if the component has nested components which don't trigger changes on the root level\n */\n get hasScopedChildren() {\n return !this.inlineEditMode;\n }\n get defaultSchema() {\n return EditGridComponent.schema();\n }\n get emptyValue() {\n return [];\n }\n get editgridKey() {\n return `editgrid-${this.key}`;\n }\n get rowRef() {\n return `${this.editgridKey}-row`;\n }\n get rowElements() {\n return this.refs[this.rowRef];\n }\n get rowRefs() {\n return this.refs[`editgrid-${this.component.key}-row`];\n }\n get addRowRef() {\n return `${this.editgridKey}-addRow`;\n }\n get addRowElements() {\n return this.refs[this.addRowRef];\n }\n get saveRowRef() {\n return `${this.editgridKey}-saveRow`;\n }\n get saveRowElements() {\n return this.refs[this.saveRowRef];\n }\n get cancelRowRef() {\n return `${this.editgridKey}-cancelRow`;\n }\n get cancelRowElements() {\n return this.refs[this.cancelRowRef];\n }\n get inlineEditMode() {\n return this.component.inlineEdit;\n }\n get saveEditMode() {\n return !this.inlineEditMode;\n }\n get minLength() {\n return this.builderMode ? 0 : lodash_1.default.get(this.component, 'validate.minLength', 0);\n }\n get data() {\n return this._data;\n }\n get dataValue() {\n return super.dataValue || [];\n }\n set dataValue(value) {\n super.dataValue = value;\n }\n get displayAsTable() {\n return this.component.displayAsTable;\n }\n set data(value) {\n this._data = value;\n const data = this.dataValue;\n (this.editRows || []).forEach((row, index) => {\n if (!data[index] && row.state !== EditRowState.New) {\n data[index] = {};\n }\n const rowData = data[index] || {};\n row.data = rowData;\n row.components.forEach((component) => {\n component.data = rowData;\n });\n });\n }\n get iteratableRows() {\n return this.editRows;\n }\n get defaultValue() {\n const value = super.defaultValue;\n const defaultValue = Array.isArray(value) ? value : [];\n lodash_1.default.times(this.minLength - defaultValue.length, () => defaultValue.push({}));\n return defaultValue;\n }\n constructor(...args) {\n super(...args);\n this.type = 'editgrid';\n }\n hasRemoveButtons() {\n return !this.component.disableAddingRemovingRows &&\n !this.options.readOnly &&\n !this.disabled &&\n this.fullMode &&\n (this.dataValue.length > lodash_1.default.get(this.component, 'validate.minLength', 0));\n }\n init() {\n if (this.builderMode) {\n this.editRows = [];\n return super.init();\n }\n this.components = this.components || [];\n const dataValue = this.dataValue;\n const openWhenEmpty = !dataValue.length && this.component.openWhenEmpty;\n if (openWhenEmpty) {\n const dataObj = {};\n this.editRows = [];\n this.createRow(dataObj, 0);\n }\n else {\n this.editRows = dataValue.map((row, rowIndex) => ({\n components: this.lazyLoad ? [] : this.createRowComponents(row, rowIndex),\n data: row,\n state: EditRowState.Saved,\n backup: null,\n error: null,\n rowIndex,\n }));\n }\n this.prevHasAddButton = this.hasAddButton();\n this.checkData();\n this.setVariableTypeComponents();\n if (this.variableTypeComponentsIndexes.length) {\n lodash_1.default.each(this.editRows || [], (editRow, rowIndex) => this.checkRowVariableTypeComponents(editRow, rowIndex));\n }\n }\n checkRowVariableTypeComponents(editRow, rowIndex) {\n const rowComponents = editRow.components;\n if (lodash_1.default.some(this.variableTypeComponentsIndexes, (compIndex) => {\n const variableTypeComp = rowComponents[compIndex];\n return variableTypeComp.type !== variableTypeComp.component.type;\n })) {\n editRow.components = this.createRowComponents(editRow.data, rowIndex, true);\n }\n }\n setVariableTypeComponents() {\n //set components which type is changing within a row (e.g.,by mergeComponentSchema action)\n this.variableTypeComponentsIndexes = [];\n lodash_1.default.each(this.component.components, (comp, index) => {\n if (comp.typeChangeEnabled) {\n this.variableTypeComponentsIndexes.push(index);\n }\n });\n }\n isOpen(editRow) {\n return [EditRowState.New, EditRowState.Editing, EditRowState.Viewing].includes(editRow.state);\n }\n isComponentVisibleInSomeRow(component) {\n const rows = this.editRows;\n const savedStates = [EditRowState.Saved, EditRowState.Editing, EditRowState.Draft];\n const savedRows = rows.filter(row => lodash_1.default.includes(savedStates, row.state));\n this.visibleInHeader = this.visibleInHeader || [];\n const changeVisibleInHeader = (component, isVisible) => {\n if (!isVisible) {\n lodash_1.default.remove(this.visibleInHeader, (key) => key === component.key);\n }\n if (isVisible && !lodash_1.default.includes(this.visibleInHeader, component.key)) {\n this.visibleInHeader.push(component.key);\n }\n };\n if (lodash_1.default.isEmpty(rows)) {\n const rowComponents = this.createRowComponents({}, 0);\n let checkComponent;\n (0, utils_1.eachComponent)(rowComponents, (comp) => {\n if (comp.component.key === component.key) {\n checkComponent = comp;\n }\n comp.checkConditions();\n });\n const isVisible = checkComponent ? checkComponent.visible : true;\n [...this.components].forEach((comp) => this.removeComponent(comp, this.components));\n changeVisibleInHeader(component, isVisible);\n return isVisible;\n }\n const isOpenRowWhenEmpty = lodash_1.default.get(this.component, 'openWhenEmpty') && rows.length === 1 && rows[0].state === EditRowState.New;\n if (!lodash_1.default.isEmpty(rows) && lodash_1.default.isEmpty(savedRows) && !isOpenRowWhenEmpty) {\n return lodash_1.default.includes(this.visibleInHeader, component.key);\n }\n return lodash_1.default.some(isOpenRowWhenEmpty ? rows : savedRows, (row, index) => {\n const editingRow = row.state === EditRowState.Editing;\n let isVisible;\n if (!editingRow) {\n const flattenedComponents = this.flattenComponents(index);\n const instance = flattenedComponents[component.key];\n isVisible = instance ? instance.visible : true;\n changeVisibleInHeader(component, isVisible);\n }\n else {\n isVisible = lodash_1.default.includes(this.visibleInHeader, component.key);\n }\n return isVisible;\n });\n }\n render(children) {\n if (this.builderMode) {\n return super.render();\n }\n const dataValue = this.dataValue;\n const headerTemplate = this.headerTemplate;\n const t = this.t.bind(this);\n const templateName = this.displayAsTable ? 'editgridTable' : 'editgrid';\n return super.render(children || this.renderTemplate(templateName, {\n ref: {\n row: this.rowRef,\n addRow: this.addRowRef,\n saveRow: this.saveRowRef,\n cancelRow: this.cancelRowRef,\n },\n header: this.renderString(headerTemplate, {\n displayValue: (component) => this.displayComponentValue(component, true),\n components: this.component.components,\n value: dataValue,\n t\n }),\n footer: this.renderString(lodash_1.default.get(this.component, 'templates.footer'), {\n components: this.component.components,\n value: dataValue,\n t\n }),\n rows: this.editRows.map(this.renderRow.bind(this)),\n openRows: this.editRows.map((row) => this.isOpen(row)),\n errors: this.editRows.map((row) => row.error),\n hasAddButton: this.hasAddButton(),\n hasRemoveButtons: this.hasRemoveButtons(),\n }));\n }\n renderComponents(components) {\n components = components || this.getComponents();\n const children = components.map(component => component.render());\n const templateName = this.displayAsTable && this.prevHasAddButton ? 'tableComponents' : 'components';\n return this.renderTemplate(templateName, {\n children,\n components,\n });\n }\n attach(element) {\n if (this.builderMode) {\n return super.attach(element);\n }\n this.loadRefs(element, {\n [this.addRowRef]: 'multiple',\n [this.saveRowRef]: 'multiple',\n [this.cancelRowRef]: 'multiple',\n [this.rowRef]: 'multiple',\n });\n this.addRowElements.forEach((addButton) => {\n this.addEventListener(addButton, 'click', () => this.addRow());\n });\n let openRowCount = 0;\n this.rowElements.forEach((row, rowIndex) => {\n const editRow = this.editRows[rowIndex];\n if (editRow === null || editRow === void 0 ? void 0 : editRow.isRowSelected) {\n row.classList.add('selected');\n }\n if (this.isOpen(editRow)) {\n this.attachComponents(row, editRow.components);\n this.addEventListener(this.saveRowElements[openRowCount], 'click', () => this.saveRow(rowIndex, true));\n this.addEventListener(this.cancelRowElements[openRowCount], 'click', () => this.cancelRow(rowIndex));\n openRowCount++;\n }\n else {\n // Attach edit and remove button events.\n [\n {\n className: 'removeRow',\n event: 'click',\n action: () => this.removeRow(rowIndex, true),\n },\n {\n className: 'editRow',\n event: 'click',\n action: () => {\n this.editRow(rowIndex).then(() => {\n var _a;\n if (this.component.rowDrafts) {\n const errors = this.validateRow(editRow, false);\n const shouldShowRowErrorsAlert = this.component.modal && errors.length && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted);\n if (shouldShowRowErrorsAlert) {\n this.alert.showErrors(errors, false);\n editRow.alerts = true;\n }\n }\n });\n },\n },\n {\n className: 'row',\n event: 'click',\n action: () => {\n row.classList.toggle('selected');\n let eventName = 'editGridSelectRow';\n if (Array.from(row.classList).includes('selected')) {\n editRow.isRowSelected = true;\n }\n else {\n delete editRow.isRowSelected;\n eventName = 'editGridUnSelectRow';\n }\n this.emit(eventName, {\n component: this.component,\n data: this.dataValue[rowIndex]\n });\n },\n }\n ].forEach(({ className, event, action, }) => {\n const elements = row.getElementsByClassName(className);\n Array.prototype.forEach.call(elements, (element) => {\n if (this.options.pdf && lodash_1.default.intersection(element.classList, ['editRow', 'removeRow']).length) {\n element.style.display = 'none';\n }\n else {\n this.addEventListener(element, event, action);\n }\n });\n });\n }\n });\n // Add open class to the element if any edit grid row is open\n if (openRowCount) {\n this.addClass(this.refs.component, `formio-component-${this.component.type}-row-open`);\n }\n else {\n this.removeClass(this.refs.component, `formio-component-${this.component.type}-row-open`);\n }\n return super.attach(element);\n }\n flattenRowDataValue(dataValue) {\n const flattened = {};\n Object.keys(dataValue).forEach((key) => {\n if (lodash_1.default.isObject(dataValue[key]) && !lodash_1.default.isNil(dataValue[key])) {\n Object.assign(flattened, this.flattenRowDataValue(dataValue[key]));\n }\n else {\n flattened[key] = dataValue[key];\n }\n });\n return flattened;\n }\n isComponentVisibleInRow(component, flattenedComponents) {\n const instance = flattenedComponents[component.key];\n return instance ? instance.visible : true;\n }\n displayComponentValue(component, header) {\n return !!((!component.hasOwnProperty('tableView') || component.tableView)\n && header ? this.isComponentVisibleInSomeRow(component) : lodash_1.default.includes(this.visibleInHeader, component.key));\n }\n renderRow(row, rowIndex) {\n const dataValue = this.dataValue;\n if (this.isOpen(row)) {\n return this.renderComponents(row.components);\n }\n else {\n const flattenedComponents = this.flattenComponents(rowIndex);\n const rowTemplate = this.rowTemplate;\n return this.renderString(rowTemplate, {\n row: dataValue[rowIndex] || {},\n data: this.data,\n rowIndex,\n components: this.component.components,\n flattenedComponents,\n displayValue: (component) => this.displayComponentValue(component),\n isVisibleInRow: (component) => this.isComponentVisibleInRow(component, flattenedComponents),\n getView: (component, data) => {\n var _a, _b;\n const instance = flattenedComponents[component.key];\n const view = instance ? instance.getView(data || instance.dataValue) : '';\n // If there is an html tag in view, don't allow it to be injected in template\n const htmlTagRegExp = new RegExp('<(.*?)>');\n return typeof view === 'string' && view.length && !((_a = instance.component) === null || _a === void 0 ? void 0 : _a.template) && htmlTagRegExp.test(view) && ((_b = instance.component) === null || _b === void 0 ? void 0 : _b.inputFormat) !== 'html'\n ? `<input type=\"text\" value=\"${view.replace(/\"/g, '"')}\" readonly/>`\n : view;\n },\n state: this.editRows[rowIndex].state,\n t: this.t.bind(this)\n });\n }\n }\n eachComponent(fn, rowIndex) {\n lodash_1.default.each(this.getComponents(rowIndex), (component, index) => {\n if (fn(component, index) === false) {\n return false;\n }\n });\n }\n restoreComponentsContext() {\n this.getComponents().forEach((component) => {\n var _a;\n const rowData = this.dataValue[component.rowIndex];\n const editRowData = (_a = this.editRows[component.rowIndex]) === null || _a === void 0 ? void 0 : _a.data;\n component.data = rowData || editRowData;\n });\n }\n flattenComponents(rowIndex) {\n const result = {};\n this.everyComponent((component) => {\n result[component.component.flattenAs || component.key] = component;\n }, rowIndex);\n return result;\n }\n getComponents(rowIndex) {\n var _a;\n // Ensure editrows is set.\n this.editRows = this.editRows || [];\n return this.builderMode\n ? super.getComponents()\n : lodash_1.default.isNumber(rowIndex)\n ? (((_a = this.editRows[rowIndex]) === null || _a === void 0 ? void 0 : _a.components) || [])\n : this.editRows.reduce((result, row) => result.concat(row.components || []), []);\n }\n destroy(all = false) {\n this.calculatedValue = undefined;\n super.destroy(all);\n }\n destroyComponents(all = false, rowIndex = 0) {\n if (this.builderMode) {\n return super.destroyComponents(all);\n }\n const components = this.getComponents(rowIndex).slice();\n components.forEach((comp) => this.removeComponent(comp, this.components, all));\n }\n createRow(dataObj, rowIndex) {\n const editRow = {\n components: this.createRowComponents(dataObj, rowIndex),\n data: dataObj,\n state: EditRowState.New,\n backup: null,\n error: null,\n rowIndex,\n };\n this.editRows.push(editRow);\n if (this.inlineEditMode) {\n this.dataValue.push(dataObj);\n }\n return editRow;\n }\n addRow() {\n if (this.options.readOnly) {\n return;\n }\n const dataObj = {};\n const rowIndex = this.editRows.length;\n const editRow = this.createRow(dataObj, rowIndex);\n if (editRow.state === EditRowState.New) {\n this.emptyRow = (0, utils_1.fastCloneDeep)(editRow.data);\n }\n if (this.inlineEditMode) {\n this.triggerChange();\n }\n this.emit('editGridAddRow', {\n component: this.component,\n row: editRow,\n });\n this.processRow('checkData', null, {}, editRow.data, editRow.components);\n if (this.component.modal) {\n this.addRowModal(rowIndex);\n }\n else {\n this.redraw();\n }\n return editRow;\n }\n addRowModal(rowIndex) {\n const modalContent = this.ce('div');\n const editRow = this.editRows[rowIndex];\n editRow.willBeSaved = false;\n const { components } = editRow;\n modalContent.innerHTML = this.renderComponents(components);\n const dialog = this.component.modal ? this.createModal(modalContent, {}, () => this.showDialog(rowIndex)) : undefined;\n dialog.classList.add(`editgrid-row-modal-${this.id}`);\n editRow.dialog = dialog;\n if (this.alert) {\n this.alert.clear();\n this.alert = null;\n }\n this.alert = new Alert_1.default(dialog.refs.dialogContents, this);\n this.addEventListener(dialog, 'close', () => {\n if (!editRow.willBeSaved) {\n if (this.editRows[rowIndex] && this.editRows[rowIndex].state !== EditRowState.New) {\n this.editRows[rowIndex].components.forEach((comp) => {\n comp.setPristine(true);\n });\n }\n this.cancelRow(rowIndex);\n }\n if (this.alert) {\n this.alert.clear();\n this.alert = null;\n }\n // Remove references to dialog elements to prevent possible in some cases memory leaks\n delete editRow.confirmationDialog;\n delete editRow.dialog;\n });\n dialog.refs.dialogContents.appendChild(this.ce('button', {\n class: 'btn btn-primary',\n onClick: () => {\n // After an attempt to save, all the components inside the row should become not pristine\n if (!this.component.rowDrafts) {\n editRow.components.forEach((comp) => comp.setPristine(false));\n }\n const errors = this.validateRow(editRow, true);\n if (!errors.length || this.component.rowDrafts) {\n editRow.willBeSaved = true;\n dialog.close();\n this.saveRow(rowIndex, true);\n }\n else {\n this.alert.showErrors(errors, false);\n editRow.alerts = true;\n }\n },\n }, this.component.saveRow || 'Save'));\n return this.attachComponents(modalContent, components);\n }\n showDialog(rowIndex) {\n const editRow = this.editRows[rowIndex];\n if (editRow.state === EditRowState.New ? lodash_1.default.isEqual(this.emptyRow, editRow.data) : lodash_1.default.isEqual(editRow.backup, editRow.data)) {\n return Promise.resolve();\n }\n const wrapper = this.ce('div', { ref: 'confirmationDialog' });\n const dialogContent = this.component.dialogTemplate || this.defaultDialogTemplate;\n wrapper.innerHTML = dialogContent;\n wrapper.refs = {};\n this.loadRefs.call(wrapper, wrapper, {\n dialogHeader: 'single',\n dialogCancelButton: 'single',\n dialogYesButton: 'single',\n });\n const dialog = this.createModal(wrapper);\n dialog.classList.add(`editgrid-row-modal-confirmation-${this.id}`);\n const close = (event) => {\n event.preventDefault();\n dialog.close();\n };\n let dialogResult;\n const promise = new Promise((resolve, reject) => {\n dialogResult = { resolve, reject };\n });\n this.addEventListener(wrapper.refs.dialogYesButton, 'click', (event) => {\n close(event);\n dialogResult.resolve();\n });\n this.addEventListener(wrapper.refs.dialogCancelButton, 'click', (event) => {\n close(event);\n dialogResult.reject();\n });\n editRow.confirmationDialog = dialog;\n return promise;\n }\n editRow(rowIndex) {\n const editRow = this.editRows[rowIndex];\n const isAlreadyEditing = editRow.state === EditRowState.Editing || editRow.state === EditRowState.New;\n if (!editRow || isAlreadyEditing) {\n return Promise.resolve();\n }\n editRow.prevState = editRow.state;\n editRow.state = this.options.readOnly ? EditRowState.Viewing : EditRowState.Editing;\n if (this.lazyLoad && (editRow.components.length === 0)) {\n editRow.components = this.createRowComponents(editRow.data, rowIndex);\n }\n const dataSnapshot = (0, utils_1.fastCloneDeep)(editRow.data);\n if (this.inlineEditMode) {\n editRow.backup = dataSnapshot;\n }\n else {\n editRow.backup = (0, utils_1.fastCloneDeep)(editRow.data);\n editRow.data = dataSnapshot;\n this.restoreRowContext(editRow);\n }\n if (this.component.modal) {\n return this.addRowModal(rowIndex);\n }\n return this.redraw();\n }\n clearErrors(rowIndex) {\n const editRow = this.editRows[rowIndex];\n if (editRow && Array.isArray(editRow.components)) {\n editRow.components.forEach((comp) => {\n comp.setPristine(true);\n comp.setCustomValidity('');\n });\n }\n }\n cancelRow(rowIndex) {\n if (this.options.readOnly) {\n return;\n }\n const editRow = this.editRows[rowIndex];\n switch (editRow.state) {\n case EditRowState.New: {\n editRow.state = EditRowState.Removed;\n this.clearErrors(rowIndex);\n this.destroyComponents(false, rowIndex);\n if (this.inlineEditMode) {\n this.splice(rowIndex);\n }\n this.editRows.splice(rowIndex, 1);\n this.openWhenEmpty();\n break;\n }\n case EditRowState.Editing: {\n editRow.state = editRow.prevState;\n if (this.inlineEditMode) {\n this.dataValue[rowIndex] = editRow.backup;\n }\n editRow.data = editRow.backup;\n editRow.backup = null;\n this.restoreRowContext(editRow);\n this.clearErrors(rowIndex);\n break;\n }\n }\n this.emit('editGridCancelRow', {\n instance: this,\n component: this.component,\n editRow,\n });\n this.checkValidity(null, true);\n this.redraw();\n if (this.component.rowDrafts) {\n this.checkValidity(this.data, false);\n }\n }\n saveRow(rowIndex, modified) {\n var _a, _b;\n const editRow = this.editRows[rowIndex];\n if (this.options.readOnly) {\n return;\n }\n // After an attempt to save, all the components inside the row should become not pristine\n if (!this.component.rowDrafts) {\n editRow.components.forEach((comp) => comp.setPristine(false));\n }\n const errors = this.validateRow(editRow, true);\n if (!this.component.rowDrafts) {\n if (errors.length) {\n return false;\n }\n }\n if (this.saveEditMode) {\n const dataValue = this.dataValue;\n if ((_b = (_a = this.root) === null || _a === void 0 ? void 0 : _a.focusedComponent) === null || _b === void 0 ? void 0 : _b.component.typeChangeEnabled) {\n this.root.focusedComponent = null;\n }\n switch (editRow.state) {\n case EditRowState.New: {\n const newIndex = dataValue.length;\n dataValue.push(editRow.data);\n editRow.components.forEach(component => component.rowIndex = newIndex);\n if (rowIndex !== newIndex) {\n this.editRows.splice(rowIndex, 1);\n this.editRows.splice(newIndex, 0, editRow);\n }\n break;\n }\n case EditRowState.Editing: {\n dataValue[rowIndex] = editRow.data;\n break;\n }\n }\n }\n editRow.state = this.component.rowDrafts && errors.length ? EditRowState.Draft : EditRowState.Saved;\n editRow.backup = null;\n this.updateValue();\n this.emit('editGridSaveRow', {\n component: this.component,\n row: editRow.data,\n instance: this\n });\n this.triggerChange({ modified, noPristineChangeOnModified: modified && this.component.rowDrafts, isolateRow: true });\n if (this.component.rowDrafts) {\n editRow.components.forEach(comp => comp.setPristine(this.pristine));\n }\n this.checkValidity(null, true);\n this.redraw();\n if (editRow.alerts) {\n editRow.alerts = false;\n }\n return true;\n }\n beforeFocus(component) {\n if ('beforeFocus' in this.parent) {\n this.parent.beforeFocus(this);\n }\n const relativePath = this.getRelativePath(component.path);\n const arrayPath = (0, utils_1.getArrayFromComponentPath)(relativePath);\n const rowIndex = arrayPath[0];\n let rowToEditIndex = arrayPath[0];\n this.editRows.forEach((row, indexInArray) => {\n if (row.rowIndex === rowIndex) {\n rowToEditIndex = indexInArray;\n }\n });\n if (lodash_1.default.isNumber(rowToEditIndex)) {\n this.editRow(rowToEditIndex);\n }\n }\n updateComponentsRowIndex(components, rowIndex) {\n components.forEach((component, colIndex) => {\n component.rowIndex = rowIndex;\n component.row = `${rowIndex}-${colIndex}`;\n });\n }\n updateRowsComponents(rowIndex) {\n this.editRows.slice(rowIndex).forEach((row, index) => {\n this.updateComponentsRowIndex(row.components, rowIndex + index);\n });\n }\n baseRemoveRow(rowIndex) {\n const editRow = this.editRows[rowIndex];\n editRow.state = EditRowState.Removed;\n this.destroyComponents(false, rowIndex);\n return editRow;\n }\n removeRow(rowIndex, modified) {\n if (this.options.readOnly) {\n return;\n }\n this.clearErrors(rowIndex);\n this.baseRemoveRow(rowIndex);\n this.removeSubmissionMetadataRow(rowIndex);\n this.splice(rowIndex);\n this.emit('editGridDeleteRow', {\n index: rowIndex\n });\n this.editRows.splice(rowIndex, 1);\n this.openWhenEmpty();\n this.updateRowsComponents(rowIndex);\n this.updateValue();\n this.triggerChange({ modified, noPristineChangeOnModified: modified && this.component.rowDrafts, isolateRow: true });\n this.checkValidity(null, true);\n this.checkData();\n this.redraw();\n }\n createRowComponents(row, rowIndex, recreatePartially) {\n // Iterate through existing components and destroy the ones with the same rowIndex.\n if (this.components) {\n for (let i = 0; i < this.components.length; i++) {\n if (this.components[i].rowIndex === rowIndex) {\n this.components[i].destroy();\n this.components.splice(i, 1);\n }\n }\n }\n const currentRowComponents = lodash_1.default.get(this.editRows, `[${rowIndex}].components`, null);\n return this.component.components.map((col, colIndex) => {\n var _a;\n if (recreatePartially && currentRowComponents && this.variableTypeComponentsIndexes.length) {\n const currentComp = currentRowComponents[colIndex];\n const shouldRecreate = lodash_1.default.includes(this.variableTypeComponentsIndexes, colIndex) && (currentComp === null || currentComp === void 0 ? void 0 : currentComp.type) !== ((_a = currentComp === null || currentComp === void 0 ? void 0 : currentComp.component) === null || _a === void 0 ? void 0 : _a.type);\n if (!shouldRecreate) {\n return currentComp;\n }\n col = currentComp.component;\n }\n const column = lodash_1.default.clone(col);\n const options = lodash_1.default.clone(this.options);\n options.name += `[${rowIndex}]`;\n options.row = `${rowIndex}-${colIndex}`;\n options.onChange = (flags = {}, changed, modified) => {\n var _a, _b;\n if (((_a = changed.instance.root) === null || _a === void 0 ? void 0 : _a.id) && (((_b = this.root) === null || _b === void 0 ? void 0 : _b.id) !== changed.instance.root.id)) {\n changed.instance.root.triggerChange(flags, changed, modified);\n }\n else if (!this.component.modal) {\n this.triggerRootChange(flags, changed, modified);\n }\n if (this.inlineEditMode) {\n return;\n }\n const editRow = this.editRows[rowIndex];\n if (editRow) {\n this.processRow('checkData', null, Object.assign(Object.assign({}, flags), { changed }), editRow.data, editRow.components);\n this.validateRow(editRow, false);\n }\n if (this.variableTypeComponentsIndexes.length) {\n this.checkRowVariableTypeComponents(editRow, rowIndex);\n this.redraw();\n }\n };\n const comp = this.createComponent(lodash_1.default.assign({}, column, { row: options.row }), options, row, null, recreatePartially && currentRowComponents ? currentRowComponents[colIndex] : null);\n comp.rowIndex = rowIndex;\n comp.inEditGrid = true;\n return comp;\n });\n }\n hasOpenRows() {\n return this.editRows.some(row => this.isOpen(row));\n }\n getAttachedData(data = null) {\n const ourData = (0, utils_1.fastCloneDeep)(data || this._data || this.rootValue);\n lodash_1.default.set(ourData, this.key, this.editRows.map((row) => row.data));\n return ourData;\n }\n shouldValidateDraft(editRow) {\n var _a, _b;\n // Draft rows should be validated only when there was an attempt to submit a form\n return (editRow.state === EditRowState.Draft &&\n !this.pristine &&\n !((_a = this.root) === null || _a === void 0 ? void 0 : _a.pristine) &&\n !this.hasOpenRows()) ||\n ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submitted);\n }\n shouldValidateRow(editRow, dirty, fromSubmission) {\n return this.shouldValidateDraft(editRow) ||\n editRow.state === EditRowState.New ||\n editRow.state === EditRowState.Editing ||\n editRow.alerts ||\n fromSubmission ||\n dirty;\n }\n validateRow(editRow, dirty, forceSilentCheck, fromSubmission) {\n var _a;\n editRow.errors = [];\n if (this.shouldValidateRow(editRow, dirty, fromSubmission)) {\n const silentCheck = (this.component.rowDrafts && !this.shouldValidateDraft(editRow)) || forceSilentCheck;\n const rootValue = (0, utils_1.fastCloneDeep)(this.rootValue);\n const editGridValue = lodash_1.default.get(rootValue, this.path, []);\n editGridValue[editRow.rowIndex] = editRow.data;\n lodash_1.default.set(rootValue, this.path, editGridValue);\n const validationProcessorProcess = (context) => this.validationProcessor(context, { dirty, silentCheck });\n const errors = (0, process_1.processSync)({\n components: (0, utils_1.fastCloneDeep)(this.component.components).map((component) => {\n component.parentPath = `${this.path}[${editRow.rowIndex}]`;\n return component;\n }),\n data: rootValue,\n row: editRow.data,\n process: 'validateRow',\n instances: this.componentsMap,\n scope: { errors: [] },\n processors: [\n {\n process: validationProcessorProcess,\n processSync: validationProcessorProcess\n }\n ]\n }).errors;\n editRow.errors = (this.component.modal || this.component.rowDrafts)\n ? errors\n : errors.filter((err) => lodash_1.default.find(this.visibleErrors, ['component.id', err.component.id]));\n }\n // TODO: this is essentially running its own custom validation and should be moved into a validation rule\n if (this.component.validate && this.component.validate.row) {\n const valid = this.evaluate(this.component.validate.row, {\n valid: (editRow.length === 0),\n row: editRow.data\n }, 'valid', true);\n if (valid.toString() !== 'true') {\n editRow.errors.push({\n type: 'error',\n rowError: true,\n message: valid.toString()\n });\n }\n if (valid === null) {\n editRow.errors.push({\n type: 'error',\n message: `Invalid row validation for ${this.key}`\n });\n }\n }\n if (!this.component.rowDrafts || ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted)) {\n this.showRowErrorAlerts(editRow, editRow.errors);\n }\n return editRow.errors;\n }\n showRowErrorAlerts(editRow, errors) {\n if (editRow.alerts) {\n if (this.alert) {\n if (errors.length) {\n this.alert.showErrors(errors, false);\n editRow.alerts = true;\n }\n else {\n this.alert.clear();\n this.alert = null;\n }\n }\n }\n }\n /**\n * @returns {boolean} - Return that this component processes its own validation.\n */\n get processOwnValidation() {\n return true;\n }\n checkComponentValidity(data, dirty, row, options = {}, errors = []) {\n var _a, _b;\n const { silentCheck, fromSubmission } = options;\n const superValid = super.checkComponentValidity(data, dirty, row, options, errors);\n // If super tells us that component invalid and there is no need to update alerts, just return false\n if (!superValid && (!this.alert && !this.hasOpenRows())) {\n return false;\n }\n let rowsEditing = false;\n const allRowErrors = [];\n this.editRows.forEach((editRow, index) => {\n // Trigger all errors on the row.\n const rowErrors = this.validateRow(editRow, dirty, silentCheck, fromSubmission);\n errors.push(...rowErrors);\n allRowErrors.push(...rowErrors);\n if (this.rowRefs) {\n const rowContainer = this.rowRefs[index];\n if (rowContainer) {\n const errorContainer = rowContainer.querySelector('.editgrid-row-error');\n if (rowErrors.length && errorContainer && (!this.component.rowDrafts || this.shouldValidateDraft(editRow))) {\n const rowError = rowErrors.find(error => error.rowError);\n this.addClass(errorContainer, 'help-block');\n errorContainer.textContent = this.t(rowError ? rowError.message : this.errorMessage('invalidRowError'));\n }\n else if (errorContainer) {\n errorContainer.textContent = '';\n this.removeClass(errorContainer, 'help-block');\n }\n }\n }\n // If this is a dirty check, and any rows are still editing, we need to throw validation error.\n rowsEditing |= (dirty && this.isOpen(editRow));\n });\n if (allRowErrors.length) {\n if (!silentCheck && (dirty || this.dirty) && (!this.component.rowDrafts || ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submitted))) {\n this.setCustomValidity(this.t(this.errorMessage('invalidRowsError')), dirty);\n this.removeClass(this.element, 'has-error');\n }\n return false;\n }\n else if (rowsEditing && this.saveEditMode && !this.component.openWhenEmpty) {\n this._errors = this.setCustomValidity(this.t(this.errorMessage('unsavedRowsError')), dirty);\n errors.push(...this._errors);\n return false;\n }\n const message = this.invalid || this.invalidMessage(data, dirty, false, row);\n if (allRowErrors.length && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submitted) && !message) {\n this._errors = this.setCustomValidity(message, dirty);\n errors.push(...this._errors);\n this.root.showErrors([message]);\n }\n else {\n this._errors = this.setCustomValidity(message, dirty);\n errors.push(...this._errors);\n }\n return superValid;\n }\n setRowInvalid(ref, index) {\n const editRow = this.editRows[index];\n const errorContainer = ref.querySelector('.editgrid-row-error');\n if (errorContainer && (!this.component.rowDrafts || this.shouldValidateDraft(editRow))) {\n this.addClass(errorContainer, 'help-block');\n errorContainer.textContent = this.t(this.errorMessage('invalidRowError'));\n }\n else if (errorContainer) {\n errorContainer.textContent = '';\n }\n }\n changeState(changed, flags) {\n if (this.visible && (changed || (flags.resetValue && this.component.modalEdit))) {\n this.rebuild();\n }\n else {\n this.redraw();\n }\n }\n setValue(value, flags = {}) {\n if (!value) {\n value = this.defaultValue;\n }\n if (!Array.isArray(value)) {\n if (typeof value === 'object') {\n value = [value];\n }\n else {\n return false;\n }\n }\n const changed = this.hasChanged(value, this.dataValue);\n if (this.parent && !this.options.server) {\n this.parent.checkComponentConditions();\n }\n this.dataValue = value;\n // Refresh editRow data when data changes.\n this.dataValue.forEach((row, rowIndex) => {\n const editRow = this.editRows[rowIndex];\n if (editRow) {\n editRow.data = row;\n this.restoreRowContext(editRow, flags);\n editRow.state = EditRowState.Saved;\n editRow.backup = null;\n editRow.errors = [];\n }\n else {\n this.editRows[rowIndex] = {\n components: this.lazyLoad ? [] : this.createRowComponents(row, rowIndex),\n data: row,\n state: EditRowState.Saved,\n backup: null,\n errors: [],\n };\n }\n });\n let { length: dataLength } = this.dataValue;\n // If the last row is a new row, then do not remove it.\n if (this.editRows[dataLength] && (this.editRows[dataLength].state === EditRowState.New)) {\n dataLength = (dataLength + 1);\n }\n this.editRows.slice(dataLength).forEach((editRow, index) => this.baseRemoveRow(dataLength + index));\n this.editRows = this.editRows.slice(0, dataLength);\n this.openWhenEmpty();\n this.updateOnChange(flags, changed);\n // do not call checkData with server option, it is called when change is triggered in updateOnChange\n if (!this.options.server) {\n this.checkData();\n }\n this.changeState(changed, flags);\n return changed;\n }\n openWhenEmpty() {\n const shouldBeOpened = !this.dataValue.length && this.component.openWhenEmpty;\n const hasNoRows = !this.editRows.length;\n if (hasNoRows && shouldBeOpened && !this.builderMode) {\n const dataObj = {};\n this.createRow(dataObj, 0);\n }\n }\n restoreRowContext(editRow, flags = {}) {\n editRow.components.forEach((component) => {\n component.data = editRow.data;\n this.setNestedValue(component, editRow.data, flags);\n });\n }\n emptyRows() {\n this.editRows.forEach((editRow, index) => this.destroyComponents(false, index));\n this.editRows = [];\n }\n resetValue() {\n super.resetValue();\n this.emptyRows();\n }\n}\nexports[\"default\"] = EditGridComponent;\nEditGridComponent.prototype.hasChanged = Component_1.default.prototype.hasChanged;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/editgrid/EditGrid.js?");
|
5260
5271
|
|
5261
5272
|
/***/ }),
|
5262
5273
|
|
@@ -5344,7 +5355,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5344
5355
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
5345
5356
|
|
5346
5357
|
"use strict";
|
5347
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst text_mask_addons_1 = __webpack_require__(/*! @formio/text-mask-addons */ \"./node_modules/@formio/text-mask-addons/dist/textMaskAddons.js\");\nconst vanilla_text_mask_1 = __webpack_require__(/*! @formio/vanilla-text-mask */ \"./node_modules/@formio/vanilla-text-mask/dist/vanillaTextMask.js\");\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst Input_1 = __importDefault(__webpack_require__(/*! ../_classes/input/Input */ \"./lib/cjs/components/_classes/input/Input.js\"));\nconst utils_1 = __webpack_require__(/*! ../../utils/utils */ \"./lib/cjs/utils/utils.js\");\nclass NumberComponent extends Input_1.default {\n static schema(...extend) {\n return Input_1.default.schema({\n type: 'number',\n label: 'Number',\n key: 'number',\n validate: {\n min: '',\n max: '',\n step: 'any',\n integer: ''\n }\n }, ...extend);\n }\n static get builderInfo() {\n return {\n title: 'Number',\n icon: 'hashtag',\n group: 'basic',\n documentation: '/userguide/form-building/form-components#number',\n weight: 30,\n schema: NumberComponent.schema()\n };\n }\n static get serverConditionSettings() {\n return NumberComponent.conditionOperatorsSettings;\n }\n static get conditionOperatorsSettings() {\n return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: [...super.conditionOperatorsSettings.operators, 'lessThan', 'greaterThan', 'lessThanOrEqual', 'greaterThanOrEqual'], valueComponent(classComp) {\n return Object.assign(Object.assign({}, classComp), { type: 'number' });\n } });\n }\n static savedValueTypes(schema) {\n schema = schema || {};\n return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.number];\n }\n constructor(...args) {\n var _a, _b, _c;\n super(...args);\n const separators = (0, utils_1.getNumberSeparators)(this.options.language || navigator.language);\n this.decimalSeparator = this.options.decimalSeparator = this.component.decimalSymbol || this.options.decimalSeparator\n || ((_a = this.options.properties) === null || _a === void 0 ? void 0 : _a.decimalSeparator)\n || separators.decimalSeparator;\n if (this.component.delimiter) {\n this.delimiter = this.component.thousandsSeparator || ((_b = this.options.properties) === null || _b === void 0 ? void 0 : _b.thousandsSeparator) || this.options.thousandsSeparator || separators.delimiter;\n }\n else {\n if (this.component.thousandsSeparator || ((_c = this.options.properties) === null || _c === void 0 ? void 0 : _c.thousandsSeparator) || this.options.thousandsSeparator) {\n console.warn('In order for thousands separator to work properly, you must set the delimiter to true in the component json');\n }\n this.delimiter = '';\n }\n const requireDecimal = lodash_1.default.get(this.component, 'requireDecimal', false);\n this.decimalLimit = (0, utils_1.getNumberDecimalLimit)(this.component, requireDecimal ? 2 : 20);\n // Currencies to override BrowserLanguage Config. Object key {}\n if (lodash_1.default.has(this.options, `languageOverride.${this.options.language}`)) {\n const override = lodash_1.default.get(this.options, `languageOverride.${this.options.language}`);\n this.decimalSeparator = override.decimalSeparator;\n this.delimiter = override.delimiter;\n }\n this.numberMask = this.createNumberMask();\n }\n /**\n * Creates the number mask for normal numbers.\n * @returns {*} - The number mask.\n */\n createNumberMask() {\n return (0, text_mask_addons_1.createNumberMask)({\n prefix: '',\n suffix: '',\n requireDecimal: lodash_1.default.get(this.component, 'requireDecimal', false),\n thousandsSeparatorSymbol: this.delimiter || '',\n decimalSymbol: lodash_1.default.get(this.component, 'decimalSymbol', this.decimalSeparator),\n decimalLimit: lodash_1.default.get(this.component, 'decimalLimit', this.decimalLimit),\n allowNegative: lodash_1.default.get(this.component, 'allowNegative', true),\n allowDecimal: this.isDecimalAllowed(),\n });\n }\n get defaultSchema() {\n return NumberComponent.schema();\n }\n get defaultValue() {\n let defaultValue = super.defaultValue;\n if (typeof defaultValue === 'string') {\n // Default value may be a string or have custom thousands separators or decimal symbols, so we need to call\n // parseNumber on it\n defaultValue = this.parseNumber(defaultValue);\n }\n if (!defaultValue && this.component.defaultValue === 0) {\n defaultValue = this.component.defaultValue;\n }\n if (!this.component.multiple && lodash_1.default.isArray(defaultValue)) {\n defaultValue = !defaultValue[0] && defaultValue[0] !== 0 ? null : defaultValue[0];\n }\n return defaultValue;\n }\n isDecimalAllowed() {\n return lodash_1.default.get(this.component, 'allowDecimal', !(this.component.validate && this.component.validate.integer));\n }\n /**\n * parses a numeric string by removing the delimiters and replacing the decimal separator back to '.' so that it can\n * be processed by either parseInt or parseFloat\n * @param {string} value the value to be parsed\n * @returns {number} a parsed number\n */\n parseNumber(value) {\n // Remove delimiters and convert decimal separator to dot.\n value = value.split(this.delimiter).join('').replace(this.decimalSeparator, '.');\n if (this.component.validate && this.component.validate.integer) {\n return parseInt(value, 10);\n }\n else {\n return parseFloat(value);\n }\n }\n setInputMask(input) {\n let numberPattern = '[0-9';\n numberPattern += this.decimalSeparator || '';\n numberPattern += this.delimiter || '';\n numberPattern += ']*';\n input.setAttribute('pattern', numberPattern);\n input.mask = (0, vanilla_text_mask_1.maskInput)({\n inputElement: input,\n mask: this.numberMask,\n shadowRoot: this.root ? this.root.shadowRoot : null,\n });\n }\n get inputInfo() {\n const info = super.inputInfo;\n if (this.component.mask) {\n info.attr.type = 'password';\n }\n else {\n info.attr.type = 'text';\n }\n info.attr.inputmode = this.isDecimalAllowed() ? 'decimal' : 'numeric';\n info.changeEvent = 'input';\n return info;\n }\n getValueAt(index) {\n if (!this.refs.input.length || !this.refs.input[index]) {\n return null;\n }\n const val = this.refs.input[index].value;\n return val && val !== '-_' ? this.parseNumber(val) : null;\n }\n setValueAt(index, value, flags = {}) {\n return super.setValueAt(index, this.formatValue(this.parseValue(value)), flags);\n }\n /**\n * Converts a string to a floating point number, formats the number based on the parsed float function\n * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat) and then returns the\n * formatted number back as a string\n * Example Input: \"123.456,22\"\n * Example Output: \"123456,22\"\n * @param {string | number} input the numeric string to parse\n * @returns {string | null} a parsed string\n */\n parseValue(input) {\n if (typeof input === 'string') {\n input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');\n }\n let value = parseFloat(input);\n if (!lodash_1.default.isNaN(value)) {\n value = String(value).replace('.', this.decimalSeparator);\n }\n else {\n value = null;\n }\n return value;\n }\n formatValue(value) {\n if (this.component.requireDecimal && value && !value.includes(this.decimalSeparator)) {\n return `${value}${this.decimalSeparator}${lodash_1.default.repeat('0', this.decimalLimit)}`;\n }\n else if (this.component.requireDecimal && value && value.includes(this.decimalSeparator)) {\n return `${value}${lodash_1.default.repeat('0', this.decimalLimit - value.split(this.decimalSeparator)[1].length)}`;\n }\n return value;\n }\n focus() {\n const input = this.refs.input[0];\n if (input) {\n super.focus.call(this);\n input.setSelectionRange(0, input.value.length);\n }\n }\n getMaskedValue(value) {\n value = value === null ? '0' : value.toString();\n if (value.includes('.') && '.' !== this.decimalSeparator) {\n value = value.replace('.', this.decimalSeparator);\n }\n return (0, vanilla_text_mask_1.conformToMask)(this.formatValue(value), this.numberMask).conformedValue;\n }\n getValueAsString(value, options) {\n if (!value && value !== 0) {\n return '';\n }\n value = this.getWidgetValueAsString(value, options);\n if (Array.isArray(value)) {\n return value.map((val) => this.getMaskedValue(val)).join(', ');\n }\n return this.getMaskedValue(value);\n }\n addFocusBlurEvents(element) {\n super.addFocusBlurEvents(element);\n this.addEventListener(element, 'blur', () => {\n element.value = this.getValueAsString(this.formatValue(this.parseValue(element.value)));\n });\n }\n}\nexports[\"default\"] = NumberComponent;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/number/Number.js?");
|
5358
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst text_mask_addons_1 = __webpack_require__(/*! @formio/text-mask-addons */ \"./node_modules/@formio/text-mask-addons/dist/textMaskAddons.js\");\nconst vanilla_text_mask_1 = __webpack_require__(/*! @formio/vanilla-text-mask */ \"./node_modules/@formio/vanilla-text-mask/dist/vanillaTextMask.js\");\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst Input_1 = __importDefault(__webpack_require__(/*! ../_classes/input/Input */ \"./lib/cjs/components/_classes/input/Input.js\"));\nconst utils_1 = __webpack_require__(/*! ../../utils/utils */ \"./lib/cjs/utils/utils.js\");\nclass NumberComponent extends Input_1.default {\n static schema(...extend) {\n return Input_1.default.schema({\n type: 'number',\n label: 'Number',\n key: 'number',\n validate: {\n min: '',\n max: '',\n step: 'any',\n integer: ''\n }\n }, ...extend);\n }\n static get builderInfo() {\n return {\n title: 'Number',\n icon: 'hashtag',\n group: 'basic',\n documentation: '/userguide/form-building/form-components#number',\n weight: 30,\n schema: NumberComponent.schema()\n };\n }\n static get serverConditionSettings() {\n return NumberComponent.conditionOperatorsSettings;\n }\n static get conditionOperatorsSettings() {\n return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: [...super.conditionOperatorsSettings.operators, 'lessThan', 'greaterThan', 'lessThanOrEqual', 'greaterThanOrEqual'], valueComponent(classComp) {\n return Object.assign(Object.assign({}, classComp), { type: 'number' });\n } });\n }\n static savedValueTypes(schema) {\n schema = schema || {};\n return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.number];\n }\n constructor(...args) {\n var _a, _b, _c;\n super(...args);\n const separators = (0, utils_1.getNumberSeparators)(this.options.language || navigator.language);\n this.decimalSeparator = this.options.decimalSeparator = this.component.decimalSymbol || this.options.decimalSeparator\n || ((_a = this.options.properties) === null || _a === void 0 ? void 0 : _a.decimalSeparator)\n || separators.decimalSeparator;\n if (this.component.delimiter) {\n this.delimiter = this.component.thousandsSeparator || ((_b = this.options.properties) === null || _b === void 0 ? void 0 : _b.thousandsSeparator) || this.options.thousandsSeparator || separators.delimiter;\n }\n else {\n if (this.component.thousandsSeparator || ((_c = this.options.properties) === null || _c === void 0 ? void 0 : _c.thousandsSeparator) || this.options.thousandsSeparator) {\n console.warn('In order for thousands separator to work properly, you must set the delimiter to true in the component json');\n }\n this.delimiter = '';\n }\n const requireDecimal = lodash_1.default.get(this.component, 'requireDecimal', false);\n this.decimalLimit = (0, utils_1.getNumberDecimalLimit)(this.component, requireDecimal ? 2 : 20);\n // Currencies to override BrowserLanguage Config. Object key {}\n if (lodash_1.default.has(this.options, `languageOverride.${this.options.language}`)) {\n const override = lodash_1.default.get(this.options, `languageOverride.${this.options.language}`);\n this.decimalSeparator = override.decimalSeparator;\n this.delimiter = override.delimiter;\n }\n this.numberMask = this.createNumberMask();\n }\n /**\n * Creates the number mask for normal numbers.\n * @returns {*} - The number mask.\n */\n createNumberMask() {\n return (0, text_mask_addons_1.createNumberMask)({\n prefix: '',\n suffix: '',\n requireDecimal: lodash_1.default.get(this.component, 'requireDecimal', false),\n thousandsSeparatorSymbol: this.delimiter || '',\n decimalSymbol: lodash_1.default.get(this.component, 'decimalSymbol', this.decimalSeparator),\n decimalLimit: lodash_1.default.get(this.component, 'decimalLimit', this.decimalLimit),\n allowNegative: lodash_1.default.get(this.component, 'allowNegative', true),\n allowDecimal: this.isDecimalAllowed(),\n });\n }\n get defaultSchema() {\n return NumberComponent.schema();\n }\n get defaultValue() {\n let defaultValue = super.defaultValue;\n if (typeof defaultValue === 'string') {\n // Default value may be a string or have custom thousands separators or decimal symbols, so we need to call\n // parseNumber on it\n defaultValue = this.parseNumber(defaultValue);\n }\n if (!defaultValue && this.component.defaultValue === 0) {\n defaultValue = this.component.defaultValue;\n }\n if (!this.component.multiple && lodash_1.default.isArray(defaultValue)) {\n defaultValue = !defaultValue[0] && defaultValue[0] !== 0 ? null : defaultValue[0];\n }\n return defaultValue;\n }\n isDecimalAllowed() {\n return lodash_1.default.get(this.component, 'allowDecimal', !(this.component.validate && this.component.validate.integer));\n }\n /**\n * parses a numeric string by removing the delimiters and replacing the decimal separator back to '.' so that it can\n * be processed by either parseInt or parseFloat\n * @param {string} value the value to be parsed\n * @returns {number} a parsed number\n */\n parseNumber(value) {\n // Remove delimiters and convert decimal separator to dot.\n value = value.split(this.delimiter).join('').replace(this.decimalSeparator, '.');\n if (this.component.validate && this.component.validate.integer) {\n return parseInt(value, 10);\n }\n else {\n return parseFloat(value);\n }\n }\n setInputMask(input) {\n let numberPattern = '[0-9';\n numberPattern += this.decimalSeparator || '';\n numberPattern += this.delimiter || '';\n numberPattern += ']*';\n input.setAttribute('pattern', numberPattern);\n input.mask = (0, vanilla_text_mask_1.maskInput)({\n inputElement: input,\n mask: this.numberMask,\n shadowRoot: this.root ? this.root.shadowRoot : null,\n });\n }\n get inputInfo() {\n const info = super.inputInfo;\n if (this.component.mask) {\n info.attr.type = 'password';\n }\n else {\n info.attr.type = 'text';\n }\n info.attr.inputmode = this.isDecimalAllowed() ? 'decimal' : 'numeric';\n info.changeEvent = 'input';\n return info;\n }\n getValueAt(index) {\n if (!this.refs.input.length || !this.refs.input[index]) {\n return null;\n }\n const val = this.refs.input[index].value;\n return val && val !== '-_' ? this.parseNumber(val) : null;\n }\n setValueAt(index, value, flags = {}) {\n return super.setValueAt(index, this.formatValue(this.parseValue(value)), flags);\n }\n /**\n * Converts a string to a floating point number, formats the number based on the parsed float function\n * (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat) and then returns the\n * formatted number back as a string\n * Example Input: \"123.456,22\"\n * Example Output: \"123456,22\"\n * @param {string | number} input the numeric string to parse\n * @returns {string | null} a parsed string\n */\n parseValue(input) {\n if (typeof input === 'string') {\n input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');\n }\n let value = parseFloat(input);\n if (!lodash_1.default.isNaN(value)) {\n // Format scientific notation\n if (/e/i.test(String(value))) {\n value = value.toExponential(this.decimalLimit);\n }\n else {\n value = String(value).replace('.', this.decimalSeparator);\n }\n }\n else {\n value = null;\n }\n return value;\n }\n formatValue(value) {\n if (this.component.requireDecimal && value && !value.includes(this.decimalSeparator)) {\n return `${value}${this.decimalSeparator}${lodash_1.default.repeat('0', this.decimalLimit)}`;\n }\n else if (this.component.requireDecimal && value && value.includes(this.decimalSeparator)) {\n return `${value}${lodash_1.default.repeat('0', this.decimalLimit - value.split(this.decimalSeparator)[1].length)}`;\n }\n return value;\n }\n focus() {\n const input = this.refs.input[0];\n if (input) {\n super.focus.call(this);\n input.setSelectionRange(0, input.value.length);\n }\n }\n getMaskedValue(value) {\n value = value === null ? '0' : value.toString();\n if (value.includes('.') && '.' !== this.decimalSeparator) {\n value = value.replace('.', this.decimalSeparator);\n }\n return (0, vanilla_text_mask_1.conformToMask)(this.formatValue(value), this.numberMask).conformedValue;\n }\n getValueAsString(value, options) {\n if (!value && value !== 0) {\n return '';\n }\n value = this.getWidgetValueAsString(value, options);\n if (Array.isArray(value)) {\n return value.map((val) => this.getMaskedValue(val)).join(', ');\n }\n return this.getMaskedValue(value);\n }\n addFocusBlurEvents(element) {\n super.addFocusBlurEvents(element);\n this.addEventListener(element, 'blur', () => {\n element.value = this.getValueAsString(this.formatValue(this.parseValue(element.value)));\n });\n }\n}\nexports[\"default\"] = NumberComponent;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/number/Number.js?");
|
5348
5359
|
|
5349
5360
|
/***/ }),
|
5350
5361
|
|
@@ -5410,7 +5421,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
5410
5421
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
5411
5422
|
|
5412
5423
|
"use strict";
|
5413
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst Formio_1 = __webpack_require__(/*! ../../Formio */ \"./lib/cjs/Formio.js\");\nconst ListComponent_1 = __importDefault(__webpack_require__(/*! ../_classes/list/ListComponent */ \"./lib/cjs/components/_classes/list/ListComponent.js\"));\nconst Input_1 = __importDefault(__webpack_require__(/*! ../_classes/input/Input */ \"./lib/cjs/components/_classes/input/Input.js\"));\nconst Form_1 = __importDefault(__webpack_require__(/*! ../../Form */ \"./lib/cjs/Form.js\"));\nconst utils_1 = __webpack_require__(/*! ../../utils/utils */ \"./lib/cjs/utils/utils.js\");\nconst ChoicesWrapper_1 = __importDefault(__webpack_require__(/*! ../../utils/ChoicesWrapper */ \"./lib/cjs/utils/ChoicesWrapper.js\"));\nclass SelectComponent extends ListComponent_1.default {\n static schema(...extend) {\n return ListComponent_1.default.schema({\n type: 'select',\n label: 'Select',\n key: 'select',\n idPath: 'id',\n data: {\n values: [{ label: '', value: '' }],\n json: '',\n url: '',\n resource: '',\n custom: ''\n },\n clearOnRefresh: false,\n limit: 100,\n valueProperty: '',\n lazyLoad: true,\n filter: '',\n searchEnabled: true,\n searchDebounce: 0.3,\n searchField: '',\n minSearch: 0,\n readOnlyValue: false,\n selectFields: '',\n selectThreshold: 0.3,\n uniqueOptions: false,\n tableView: true,\n fuseOptions: {\n include: 'score',\n threshold: 0.3,\n },\n indexeddb: {\n filter: {}\n },\n customOptions: {},\n useExactSearch: false,\n }, ...extend);\n }\n static get builderInfo() {\n return {\n title: 'Select',\n group: 'basic',\n icon: 'th-list',\n weight: 70,\n documentation: '/userguide/form-building/form-components#select',\n schema: SelectComponent.schema()\n };\n }\n static get serverConditionSettings() {\n return SelectComponent.conditionOperatorsSettings;\n }\n static get conditionOperatorsSettings() {\n const numberType = () => ({ type: 'number' });\n return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { valueComponent(classComp) {\n const valueComp = Object.assign(Object.assign({}, classComp), { type: 'select' });\n if ((0, utils_1.isSelectResourceWithObjectValue)(classComp)) {\n valueComp.reference = false;\n valueComp.onSetItems = `\n var templateKeys = utils.getItemTemplateKeys(component.template) || [];\n items = _.map(items || [], i => {\n var item = {};\n _.each(templateKeys, k => _.set(item, k, _.get(i, k)));\n return item;\n })\n `;\n }\n return valueComp;\n }, dataTypeOperators: {\n number: ['lessThan', 'greaterThan', 'lessThanOrEqual', 'greaterThanOrEqual'],\n }, dataTypeValueComponents: {\n number: {\n lessThan: numberType,\n greaterThan: numberType,\n lessThanOrEqual: numberType,\n greaterThanOrEqual: numberType,\n },\n } });\n }\n static savedValueTypes(schema) {\n const { boolean, string, number, object, array } = utils_1.componentValueTypes;\n const { dataType, reference } = schema;\n const types = (0, utils_1.getComponentSavedTypes)(schema);\n if (types) {\n return types;\n }\n if (reference) {\n return [object];\n }\n if (dataType === 'object') {\n return [object, array];\n }\n if (utils_1.componentValueTypes[dataType]) {\n return [utils_1.componentValueTypes[dataType]];\n }\n return [boolean, string, number, object, array];\n }\n init() {\n super.init();\n this.templateData = {};\n // Trigger an update.\n let updateArgs = [];\n const triggerUpdate = lodash_1.default.debounce((...args) => {\n updateArgs = [];\n return this.updateItems.apply(this, args);\n }, 100);\n this.triggerUpdate = (...args) => {\n // Make sure we always resolve the previous promise before reassign it\n if (typeof this.itemsLoadedResolve === 'function') {\n this.itemsLoadedResolve();\n }\n this.itemsLoaded = new Promise((resolve) => {\n this.itemsLoadedResolve = resolve;\n });\n if (args.length) {\n updateArgs = args;\n }\n return triggerUpdate(...updateArgs);\n };\n // Keep track of the select options.\n this.selectOptions = [];\n if (this.itemsFromUrl) {\n this.isFromSearch = false;\n this.searchServerCount = null;\n this.defaultServerCount = null;\n this.isScrollLoading = false;\n this.searchDownloadedResources = [];\n this.defaultDownloadedResources = [];\n }\n // If this component has been activated.//\n this.activated = false;\n this.itemsLoaded = new Promise((resolve) => {\n this.itemsLoadedResolve = resolve;\n });\n this.shouldPositionDropdown = this.hasDataGridAncestor();\n if (this.isHtmlRenderMode()) {\n this.activate();\n }\n // Get the template keys for this select component.\n this.getTemplateKeys();\n }\n get defaultSchema() {\n return SelectComponent.schema();\n }\n get emptyValue() {\n if (this.component.multiple) {\n return [];\n }\n // if select has JSON data source type, we are defining if empty value would be an object or a string by checking JSON's first item\n if (this.component.dataSrc === 'json' && this.component.data.json) {\n const firstItem = this.component.data.json[0];\n let firstValue;\n if (this.valueProperty) {\n firstValue = lodash_1.default.get(firstItem, this.valueProperty);\n }\n else {\n firstValue = firstItem;\n }\n if (firstValue && typeof firstValue === 'string') {\n return '';\n }\n else {\n return {};\n }\n }\n if (this.valueProperty) {\n return '';\n }\n return {};\n }\n get valueProperty() {\n if (this.component.valueProperty) {\n return this.component.valueProperty;\n }\n // Force values datasource to use values without actually setting it on the component settings.\n if (this.component.dataSrc === 'values') {\n return 'value';\n }\n return '';\n }\n get inputInfo() {\n const info = super.elementInfo();\n info.type = 'select';\n info.changeEvent = 'change';\n return info;\n }\n get isSelectResource() {\n return this.component.dataSrc === 'resource';\n }\n get itemsFromUrl() {\n return this.isSelectResource || this.isSelectURL;\n }\n get isInfiniteScrollProvided() {\n return this.itemsFromUrl;\n }\n get shouldDisabled() {\n return super.shouldDisabled || this.parentDisabled;\n }\n get shouldInitialLoad() {\n if (this.component.widget === 'html5' &&\n this.isEntireObjectDisplay() &&\n this.component.searchField &&\n this.dataValue) {\n return false;\n }\n return super.shouldLoad;\n }\n get selectMetadata() {\n return super.selectData;\n }\n get selectData() {\n return this.selectMetadata || this.component.selectData;\n }\n isEntireObjectDisplay() {\n return this.component.dataSrc === 'resource' && this.valueProperty === 'data';\n }\n selectValueAndLabel(data) {\n const value = this.getOptionValue((this.isEntireObjectDisplay() && !this.itemValue(data)) ? data : this.itemValue(data));\n return {\n value,\n label: this.itemTemplate((this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data)) ? { data: data } : data, value)\n };\n }\n itemTemplate(data, value) {\n if (!lodash_1.default.isNumber(data) && lodash_1.default.isEmpty(data)) {\n return '';\n }\n // If they wish to show the value in read only mode, then just return the itemValue here.\n if (this.options.readOnly && this.component.readOnlyValue) {\n return this.itemValue(data);\n }\n // Perform a fast interpretation if we should not use the template.\n if (data && !this.component.template) {\n const itemLabel = data.label || data;\n const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;\n return this.sanitize(value, this.shouldSanitizeValue);\n }\n // Inside DataTable component won't have dataValue set\n const shouldUseSelectData = (this.component.multiple && lodash_1.default.isArray(this.dataValue)\n ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val)\n : (this.dataValue === this.normalizeSingleValue(value))) || this.inDataTable;\n if (shouldUseSelectData) {\n const selectData = this.selectData;\n if (selectData) {\n const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;\n if (!this.templateData || !this.templateData[templateValue]) {\n this.getOptionTemplate(data, value);\n }\n if (this.component.multiple) {\n if (selectData[templateValue]) {\n data = selectData[templateValue];\n }\n }\n else {\n data = selectData;\n }\n }\n }\n if (typeof data === 'string' || typeof data === 'number') {\n return this.sanitize(this.t(data, { _userInput: true }), this.shouldSanitizeValue);\n }\n if (Array.isArray(data)) {\n return data.map((val) => {\n if (typeof val === 'string' || typeof val === 'number') {\n return this.sanitize(this.t(val, { _userInput: true }), this.shouldSanitizeValue);\n }\n return val;\n });\n }\n if (data.data) {\n // checking additional fields in the template for the selected Entire Object option\n const hasNestedFields = /item\\.data\\.\\w*/g.test(this.component.template);\n data.data = this.isEntireObjectDisplay() && lodash_1.default.isObject(data.data) && !hasNestedFields\n ? JSON.stringify(data.data)\n : data.data;\n }\n return super.itemTemplate(data, value);\n }\n /**\n * Adds an option to the select dropdown.\n * @param {*} value - The value of the new option.\n * @param {string} label - The label of the new option.\n * @param {object} [attrs] - Additional value attributes. Defaults to {}.\n * @param {string} [id] - An id. Defaults to a random string.\n */\n addOption(value, label, attrs = {}, id = (0, utils_1.getRandomComponentId)()) {\n if (lodash_1.default.isNil(label))\n return;\n const idPath = this.component.idPath\n ? this.component.idPath.split('.').reduceRight((obj, key) => ({ [key]: obj }), id)\n : {};\n const option = Object.assign({ value: this.getOptionValue(value), label }, idPath);\n const skipOption = this.component.uniqueOptions\n ? !!this.selectOptions.find((selectOption) => lodash_1.default.isEqual(selectOption.value, option.value))\n : false;\n if (skipOption) {\n return;\n }\n if (value) {\n this.selectOptions.push(option);\n }\n if (this.refs.selectContainer && (this.component.widget === 'html5')) {\n // Replace an empty Object value to an empty String.\n if (option.value && lodash_1.default.isObject(option.value) && lodash_1.default.isEmpty(option.value)) {\n option.value = '';\n }\n // Add element to option so we can reference it later.\n const div = document.createElement('div');\n div.innerHTML = this.sanitize(this.renderTemplate('selectOption', {\n selected: lodash_1.default.isEqual(this.getOptionValue(this.dataValue), option.value),\n option,\n attrs,\n id,\n useId: (this.valueProperty === '' || this.isEntireObjectDisplay()) && lodash_1.default.isObject(value) && id,\n }), this.shouldSanitizeValue).trim();\n option.element = div.firstChild;\n this.refs.selectContainer.appendChild(option.element);\n }\n }\n addValueOptions(items) {\n items = items || [];\n let added = false;\n let data = this.dataValue;\n // preset submission value with value property before request.\n if (this.options.pdf && !items.length && this.component.dataSrc === 'url' && this.valueProperty) {\n data = Array.isArray(data)\n ? data.map(item => lodash_1.default.set({}, this.valueProperty, item))\n : lodash_1.default.set({}, this.valueProperty, data);\n }\n if (!this.selectOptions.length) {\n // Add the currently selected choices if they don't already exist.\n const currentChoices = Array.isArray(data) && this.component.multiple ? data : [data];\n added = this.addCurrentChoices(currentChoices, items);\n if (!added && !this.component.multiple) {\n this.addPlaceholder();\n }\n }\n return added;\n }\n disableInfiniteScroll() {\n if (!this.downloadedResources) {\n return;\n }\n this.downloadedResources.serverCount = this.downloadedResources.length;\n this.serverCount = this.downloadedResources.length;\n }\n /* eslint-disable max-statements */\n setItems(items, fromSearch) {\n var _a, _b;\n this.selectItems = items;\n // If the items is a string, then parse as JSON.\n if (typeof items == 'string') {\n try {\n items = JSON.parse(items);\n }\n catch (err) {\n console.warn(err.message);\n items = [];\n }\n }\n // Allow js processing (needed for form builder)\n if (this.component.onSetItems) {\n const newItems = typeof this.component.onSetItems === 'function'\n ? this.component.onSetItems(this, items)\n : this.evaluate(this.component.onSetItems, { items: items }, 'items');\n if (newItems) {\n items = newItems;\n }\n }\n if (!this.choices && this.refs.selectContainer) {\n this.empty(this.refs.selectContainer);\n }\n // If they provided select values, then we need to get them instead.\n if (this.component.selectValues) {\n items = lodash_1.default.get(items, this.component.selectValues, items) || [];\n }\n let areItemsEqual;\n if (this.itemsFromUrl) {\n areItemsEqual = this.isSelectURL ? lodash_1.default.isEqual(items, this.downloadedResources) : false;\n const areItemsEnded = this.component.limit > items.length;\n const areItemsDownloaded = areItemsEqual\n && this.downloadedResources\n && this.downloadedResources.length === items.length;\n if (areItemsEnded) {\n this.disableInfiniteScroll();\n }\n else if (areItemsDownloaded) {\n this.selectOptions = [];\n }\n else {\n this.serverCount = items.serverCount;\n }\n }\n if (this.isScrollLoading && items) {\n if (!areItemsEqual) {\n this.downloadedResources = this.downloadedResources\n ? this.downloadedResources.concat(items)\n : items;\n }\n this.downloadedResources.serverCount = items.serverCount || this.downloadedResources.serverCount;\n }\n else {\n this.downloadedResources = items || [];\n this.selectOptions = [];\n // If there is new select option with same id as already selected, set the new one\n if (!lodash_1.default.isEmpty(this.dataValue) && this.component.idPath) {\n const selectedOptionId = lodash_1.default.get(this.dataValue, this.component.idPath, null);\n const newOptionWithSameId = !lodash_1.default.isNil(selectedOptionId) && items.find(item => {\n const itemId = lodash_1.default.get(item, this.component.idPath);\n return itemId === selectedOptionId;\n });\n if (newOptionWithSameId) {\n this.setValue(newOptionWithSameId);\n }\n }\n }\n // Add the value options.\n if (!fromSearch) {\n this.addValueOptions(items);\n }\n if (this.component.widget === 'html5' && !this.component.placeholder) {\n this.addOption(null, '');\n }\n // Iterate through each of the items.\n lodash_1.default.each(items, (item, index) => {\n // preventing references of the components inside the form to the parent form when building forms\n if (this.root && this.root.options.editForm && this.root.options.editForm._id && this.root.options.editForm._id === item._id)\n return;\n const itemValueAndLabel = this.selectValueAndLabel(item);\n this.addOption(itemValueAndLabel.value, itemValueAndLabel.label, {}, lodash_1.default.get(item, this.component.idPath, String(index)));\n });\n if (this.choices) {\n this.choices.setChoices(this.selectOptions, 'value', 'label', true);\n }\n else if (this.loading) {\n // Re-attach select input.\n // this.appendTo(this.refs.input[0], this.selectContainer);\n }\n // We are no longer loading.\n this.isScrollLoading = false;\n this.loading = false;\n const searching = fromSearch && ((_b = (_a = this.choices) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.isFocussed);\n if (!searching) {\n // If a value is provided, then select it.\n if (!this.isEmpty() || this.isRemoveButtonPressed) {\n this.setValue(this.dataValue, {\n noUpdateEvent: true\n });\n }\n else if (this.shouldAddDefaultValue && !this.options.readOnly) {\n // If a default value is provided then select it.\n const defaultValue = this.defaultValue;\n if (!this.isEmpty(defaultValue)) {\n this.setValue(defaultValue);\n }\n }\n }\n // Say we are done loading the items.\n this.itemsLoadedResolve();\n }\n getSingleItemValueForHTMLMode(data) {\n var _a;\n const option = (_a = this.selectOptions) === null || _a === void 0 ? void 0 : _a.find(({ value }) => lodash_1.default.isEqual(value, data));\n if (option) {\n return option.label || data;\n }\n return data;\n }\n itemValueForHTMLMode(value) {\n if (!this.isHtmlRenderMode()) {\n return super.itemValueForHTMLMode(value);\n }\n if (Array.isArray(value)) {\n const values = value.map(item => Array.isArray(item)\n ? this.itemValueForHTMLMode(item)\n : this.getSingleItemValueForHTMLMode(item));\n return values.join(', ');\n }\n return this.getSingleItemValueForHTMLMode(value);\n }\n /* eslint-enable max-statements */\n get defaultValue() {\n let defaultValue = super.defaultValue;\n if (!defaultValue && (this.component.defaultValue === false || this.component.defaultValue === 0)) {\n defaultValue = this.component.defaultValue;\n }\n return defaultValue;\n }\n get loadingError() {\n return !this.component.refreshOn && !this.component.refreshOnBlur && this.networkError;\n }\n loadItems(url, search, headers, options, method, body) {\n options = options || {};\n // See if we should load items or not.\n if (!this.shouldLoad || (!this.itemsFromUrl && this.options.readOnly)) {\n this.isScrollLoading = false;\n this.loading = false;\n this.itemsLoadedResolve();\n return;\n }\n // See if they have not met the minimum search requirements.\n const minSearch = parseInt(this.component.minSearch, 10);\n if (this.component.searchField &&\n (minSearch > 0) &&\n (!search || (search.length < minSearch))) {\n // Set empty items.\n return this.setItems([]);\n }\n // Ensure we have a method and remove any body if method is get\n method = method || 'GET';\n if (method.toUpperCase() === 'GET') {\n body = null;\n }\n const limit = this.component.limit || 100;\n const skip = this.isScrollLoading ? this.selectOptions.length : 0;\n const query = this.component.disableLimit ? {} : {\n limit,\n skip,\n };\n // Allow for url interpolation.\n url = this.interpolate(url, {\n formioBase: Formio_1.Formio.getBaseUrl(),\n search,\n limit,\n skip,\n page: Math.abs(Math.floor(skip / limit))\n });\n // Add search capability.\n if (this.component.searchField && search) {\n const searchValue = Array.isArray(search)\n ? search.join(',')\n : typeof search === 'object'\n ? JSON.stringify(search)\n : search;\n query[this.component.searchField] = this.component.searchField.endsWith('__regex')\n ? lodash_1.default.escapeRegExp(searchValue)\n : searchValue;\n }\n // If they wish to return only some fields.\n if (this.component.selectFields) {\n query.select = this.component.selectFields;\n }\n // Add sort capability\n if (this.component.sort) {\n query.sort = this.component.sort;\n }\n if (!lodash_1.default.isEmpty(query)) {\n // Add the query string.\n url += (!url.includes('?') ? '?' : '&') + Formio_1.Formio.serialize(query, (item) => this.interpolate(item));\n }\n // Add filter capability\n if (this.component.filter) {\n url += (!url.includes('?') ? '?' : '&') + this.interpolate(this.component.filter);\n }\n // Set ignoreCache if it is\n options.ignoreCache = this.component.ignoreCache;\n // Make the request.\n options.header = headers;\n this.loading = true;\n Formio_1.Formio.makeRequest(this.options.formio, 'select', url, method, body, options)\n .then((response) => {\n this.loading = false;\n this.setItems(response, !!search);\n })\n .catch((err) => {\n if (this.itemsFromUrl) {\n this.setItems([]);\n this.disableInfiniteScroll();\n }\n this.isScrollLoading = false;\n this.handleLoadingError(err);\n });\n }\n handleLoadingError(err) {\n this.loading = false;\n if (err.networkError) {\n this.networkError = true;\n }\n this.itemsLoadedResolve();\n this.emit('componentError', {\n component: this.component,\n message: err.toString(),\n });\n console.warn(`Unable to load resources for ${this.key}`);\n }\n /**\n * Get the request headers for this select dropdown.\n * @returns {*} - Returns the request headers for this select dropdown.\n */\n get requestHeaders() {\n // Create the headers object.\n const headers = new Formio_1.Formio.Headers();\n // Add custom headers to the url.\n if (this.component.data && this.component.data.headers) {\n try {\n lodash_1.default.each(this.component.data.headers, (header) => {\n if (header.key) {\n headers.set(header.key, this.interpolate(header.value));\n }\n });\n }\n catch (err) {\n console.warn(err.message);\n }\n }\n return headers;\n }\n getCustomItems() {\n const customItems = this.evaluate(this.component.data.custom, {\n values: []\n }, 'values');\n this.asyncValues = (0, utils_1.isPromise)(customItems);\n return customItems;\n }\n asyncCustomValues() {\n if (!lodash_1.default.isBoolean(this.asyncValues)) {\n this.getCustomItems();\n }\n return this.asyncValues;\n }\n updateCustomItems(forceUpdate) {\n if (this.asyncCustomValues()) {\n if (!forceUpdate && !this.active) {\n this.itemsLoadedResolve();\n return;\n }\n this.loading = true;\n this.getCustomItems()\n .then(items => {\n this.loading = false;\n this.setItems(items || []);\n })\n .catch(err => {\n this.handleLoadingError(err);\n });\n }\n else {\n this.setItems(this.getCustomItems() || []);\n }\n }\n isEmpty(value = this.dataValue) {\n return super.isEmpty(value) || value === undefined;\n }\n refresh(value, { instance }) {\n if (this.component.clearOnRefresh && (instance && !instance.pristine)) {\n this.setValue(this.emptyValue);\n }\n this.updateItems(null, true);\n }\n get additionalResourcesAvailable() {\n return lodash_1.default.isNil(this.serverCount) || (this.serverCount > this.downloadedResources.length);\n }\n get serverCount() {\n if (this.isFromSearch) {\n return this.searchServerCount;\n }\n return this.defaultServerCount;\n }\n set serverCount(value) {\n if (this.isFromSearch) {\n this.searchServerCount = value;\n }\n else {\n this.defaultServerCount = value;\n }\n }\n get downloadedResources() {\n if (this.isFromSearch) {\n return this.searchDownloadedResources;\n }\n return this.defaultDownloadedResources;\n }\n set downloadedResources(value) {\n if (this.isFromSearch) {\n this.searchDownloadedResources = value;\n }\n else {\n this.defaultDownloadedResources = value;\n }\n }\n addPlaceholder() {\n if (!this.component.placeholder) {\n return;\n }\n this.addOption('', this.component.placeholder, { placeholder: true });\n }\n /**\n * Activate this select control.\n */\n activate() {\n if (this.loading || !this.active) {\n this.setLoadingItem();\n }\n if (this.active) {\n return;\n }\n this.activated = true;\n this.triggerUpdate();\n }\n setLoadingItem(addToCurrentList = false) {\n if (this.choices) {\n if (addToCurrentList) {\n this.choices.setChoices([{\n value: `${this.id}-loading`,\n label: 'Loading...',\n disabled: true,\n }], 'value', 'label');\n }\n else {\n this.choices.setChoices([{\n value: '',\n label: `<i class=\"${this.iconClass('refresh')}\" style=\"font-size:1.3em;\"></i>`,\n disabled: true,\n }], 'value', 'label', true);\n }\n }\n else if (this.component.dataSrc === 'url' || this.component.dataSrc === 'resource') {\n this.addOption('', this.t('loading...'));\n }\n }\n get active() {\n return !this.component.lazyLoad || this.activated;\n }\n render() {\n const info = this.inputInfo;\n info.attr = info.attr || {};\n info.multiple = this.component.multiple;\n return super.render(this.wrapElement(this.renderTemplate('select', {\n input: info,\n selectOptions: '',\n index: null,\n })));\n }\n wrapElement(element) {\n return this.component.addResource && !this.options.readOnly\n ? (this.renderTemplate('resourceAdd', {\n element\n }))\n : element;\n }\n choicesOptions() {\n const useSearch = this.component.hasOwnProperty('searchEnabled') ? this.component.searchEnabled : true;\n const placeholderValue = this.t(this.component.placeholder, { _userInput: true });\n let customOptions = this.component.customOptions || {};\n if (typeof customOptions == 'string') {\n try {\n customOptions = JSON.parse(customOptions);\n }\n catch (err) {\n console.warn(err.message);\n customOptions = {};\n }\n }\n const commonFuseOptions = {\n maxPatternLength: 1000,\n distance: 1000,\n };\n return Object.assign({ removeItemButton: this.component.disabled ? false : lodash_1.default.get(this.component, 'removeItemButton', true), itemSelectText: '', classNames: {\n containerOuter: 'choices form-group formio-choices',\n containerInner: this.transform('class', 'form-control ui fluid selection dropdown')\n }, addItemText: false, allowHTML: true, placeholder: !!this.component.placeholder, placeholderValue: placeholderValue, noResultsText: this.t('No results found'), noChoicesText: this.t('No choices to choose from'), searchPlaceholderValue: this.t('Type to search'), shouldSort: false, position: (this.component.dropdown || 'auto'), searchEnabled: useSearch, searchChoices: !this.component.searchField, searchFields: lodash_1.default.get(this, 'component.searchFields', ['label']), shadowRoot: this.root ? this.root.shadowRoot : null, fuseOptions: this.component.useExactSearch\n ? Object.assign({ tokenize: true, matchAllTokens: true }, commonFuseOptions) : Object.assign({}, lodash_1.default.get(this, 'component.fuseOptions', {}), Object.assign({ include: 'score', threshold: lodash_1.default.get(this, 'component.selectThreshold', 0.3) }, commonFuseOptions)), valueComparer: lodash_1.default.isEqual, resetScrollPosition: false }, customOptions);\n }\n /* eslint-disable max-statements */\n attach(element) {\n var _a, _b, _c;\n const superAttach = super.attach(element);\n this.loadRefs(element, {\n selectContainer: 'single',\n addResource: 'single',\n autocompleteInput: 'single'\n });\n //enable autocomplete for select\n const autocompleteInput = this.refs.autocompleteInput;\n if (autocompleteInput) {\n this.addEventListener(autocompleteInput, 'change', (event) => {\n this.setValue(event.target.value);\n });\n }\n const input = this.refs.selectContainer;\n if (!input) {\n return;\n }\n this.addEventListener(input, this.inputInfo.changeEvent, () => this.updateValue(null, {\n modified: true\n }));\n this.attachRefreshOnBlur();\n if (this.component.widget === 'html5') {\n this.addFocusBlurEvents(input);\n this.triggerUpdate(null, true);\n if (this.visible) {\n this.setItems(this.selectItems || []);\n }\n this.focusableElement = input;\n if (this.component.dataSrc === 'custom') {\n this.addEventListener(input, 'focus', () => this.updateCustomItems());\n }\n this.addEventListener(input, 'keydown', (event) => {\n const { key } = event;\n if (['Backspace', 'Delete'].includes(key)) {\n this.setValue(this.emptyValue);\n }\n });\n return;\n }\n const tabIndex = input.tabIndex;\n this.addPlaceholder();\n if (this.i18next) {\n input.setAttribute('dir', this.i18next.dir());\n }\n if ((_c = (_b = (_a = this.choices) === null || _a === void 0 ? void 0 : _a.containerOuter) === null || _b === void 0 ? void 0 : _b.element) === null || _c === void 0 ? void 0 : _c.parentNode) {\n this.choices.destroy();\n }\n const choicesOptions = this.choicesOptions();\n if (ChoicesWrapper_1.default) {\n this.choices = new ChoicesWrapper_1.default(input, choicesOptions);\n if (this.selectOptions && this.selectOptions.length) {\n this.choices.setChoices(this.selectOptions, 'value', 'label', true);\n }\n if (this.component.multiple) {\n this.focusableElement = this.choices.input.element;\n }\n else {\n this.focusableElement = this.choices.containerInner.element;\n this.choices.containerOuter.element.setAttribute('tabIndex', '-1');\n this.addEventListener(this.choices.containerOuter.element, 'focus', () => this.focusableElement.focus());\n }\n Input_1.default.prototype.addFocusBlurEvents.call(this, this.focusableElement);\n if (this.itemsFromUrl && !this.component.noRefreshOnScroll) {\n this.scrollList = this.choices.choiceList.element;\n this.addEventListener(this.scrollList, 'scroll', () => this.onScroll());\n }\n if (choicesOptions.removeItemButton) {\n this.addEventListener(input, 'removeItem', () => {\n this.isRemoveButtonPressed = true;\n });\n }\n }\n if (window && this.choices && this.shouldPositionDropdown) {\n this.addEventListener(window.document, 'scroll', () => {\n this.positionDropdown(true);\n }, false, true);\n }\n this.focusableElement.setAttribute('tabIndex', tabIndex);\n // If a search field is provided, then add an event listener to update items on search.\n if (this.component.searchField) {\n // Make sure to clear the search when no value is provided.\n if (this.choices && this.choices.input && this.choices.input.element) {\n this.addEventListener(this.choices.input.element, 'input', (event) => {\n this.isFromSearch = !!event.target.value;\n if (!event.target.value) {\n this.triggerUpdate();\n }\n else {\n this.serverCount = null;\n this.downloadedResources = [];\n }\n });\n }\n this.addEventListener(input, 'choice', () => {\n if (this.component.multiple && this.component.dataSrc === 'resource' && this.isFromSearch) {\n this.triggerUpdate();\n }\n this.isFromSearch = false;\n });\n // avoid spamming the resource/url endpoint when we have server side filtering enabled.\n const debounceTimeout = this.component.searchField && (this.isSelectResource || this.isSelectURL) ?\n (this.component.searchDebounce === 0 ? 0 : this.component.searchDebounce || this.defaultSchema.searchDebounce) * 1000\n : 0;\n const updateComponent = (evt) => {\n this.triggerUpdate(evt.detail.value);\n };\n this.addEventListener(input, 'search', lodash_1.default.debounce((e) => {\n updateComponent(e);\n this.positionDropdown();\n }, debounceTimeout));\n this.addEventListener(input, 'stopSearch', () => this.triggerUpdate());\n this.addEventListener(input, 'hideDropdown', () => {\n if (this.choices && this.choices.input && this.choices.input.element) {\n this.choices.input.element.value = '';\n }\n this.updateItems(null, true);\n });\n }\n this.addEventListener(input, 'showDropdown', () => {\n this.update();\n this.positionDropdown();\n });\n if (this.shouldPositionDropdown) {\n this.addEventListener(input, 'highlightChoice', () => {\n this.positionDropdown();\n });\n }\n if (this.choices && choicesOptions.placeholderValue && this.choices._isSelectOneElement) {\n this.addPlaceholderItem(choicesOptions.placeholderValue);\n this.addEventListener(input, 'removeItem', () => {\n this.addPlaceholderItem(choicesOptions.placeholderValue);\n });\n }\n // Add value options.\n this.addValueOptions();\n this.setChoicesValue(this.dataValue);\n if (this.isSelectResource && this.refs.addResource) {\n this.addEventListener(this.refs.addResource, 'click', (event) => {\n event.preventDefault();\n const formioForm = this.ce('div');\n const dialog = this.createModal(formioForm);\n const projectUrl = lodash_1.default.get(this.root, 'formio.projectUrl', Formio_1.Formio.getProjectUrl());\n const formUrl = `${projectUrl}/form/${this.component.data.resource}`;\n new Form_1.default(formioForm, formUrl, {}).ready\n .then((form) => {\n form.on('submit', (submission) => {\n // If valueProperty is set, replace the submission with the corresponding value\n let value = this.valueProperty ? lodash_1.default.get(submission, this.valueProperty) : submission;\n if (this.component.multiple) {\n value = [...this.dataValue, value];\n }\n this.setValue(value);\n this.triggerUpdate();\n dialog.close();\n });\n });\n });\n }\n // Force the disabled state with getters and setters.\n this.disabled = this.shouldDisabled;\n this.triggerUpdate();\n return superAttach;\n }\n setDropdownPosition() {\n var _a, _b, _c, _d;\n const dropdown = (_b = (_a = this.choices) === null || _a === void 0 ? void 0 : _a.dropdown) === null || _b === void 0 ? void 0 : _b.element;\n const container = (_d = (_c = this.choices) === null || _c === void 0 ? void 0 : _c.containerOuter) === null || _d === void 0 ? void 0 : _d.element;\n if (!dropdown || !container) {\n return;\n }\n const containerPosition = container.getBoundingClientRect();\n const isFlipped = container.classList.contains('is-flipped');\n lodash_1.default.assign(dropdown.style, {\n top: `${isFlipped ? containerPosition.top - dropdown.offsetHeight : containerPosition.top + containerPosition.height}px`,\n left: `${containerPosition.left}px`,\n width: `${containerPosition.width}px`,\n position: 'fixed',\n bottom: 'unset',\n right: 'unset',\n });\n }\n hasDataGridAncestor(comp) {\n comp = comp || this;\n if (comp.inDataGrid || comp.type === 'datagrid') {\n return true;\n }\n else if (comp.parent) {\n return this.hasDataGridAncestor(comp.parent);\n }\n else {\n return false;\n }\n }\n positionDropdown(scroll) {\n var _a;\n if (!this.shouldPositionDropdown || !this.choices || (!((_a = this.choices.dropdown) === null || _a === void 0 ? void 0 : _a.isActive) && scroll)) {\n return;\n }\n this.setDropdownPosition();\n this.itemsLoaded.then(() => {\n this.setDropdownPosition();\n });\n }\n get isLoadingAvailable() {\n return !this.isScrollLoading && this.additionalResourcesAvailable;\n }\n onScroll() {\n if (this.isLoadingAvailable) {\n this.isScrollLoading = true;\n this.setLoadingItem(true);\n this.triggerUpdate(this.choices.input.element.value);\n }\n }\n attachRefreshOnBlur() {\n if (this.component.refreshOnBlur) {\n this.on('blur', (instance) => {\n this.checkRefreshOn([{ instance, value: instance.dataValue }], { fromBlur: true });\n });\n }\n }\n addPlaceholderItem(placeholderValue) {\n const items = this.choices._store.activeItems;\n if (!items.length) {\n this.choices._addItem({\n value: '',\n label: placeholderValue,\n choiceId: 0,\n groupId: -1,\n customProperties: null,\n placeholder: true,\n keyCode: null\n });\n }\n }\n /* eslint-enable max-statements */\n update() {\n if (this.component.dataSrc === 'custom') {\n this.updateCustomItems();\n }\n // Activate the control.\n this.activate();\n }\n set disabled(disabled) {\n super.disabled = disabled;\n if (!this.choices) {\n return;\n }\n if (disabled) {\n this.setDisabled(this.choices.containerInner.element, true);\n this.focusableElement.removeAttribute('tabIndex');\n this.choices.disable();\n }\n else {\n this.setDisabled(this.choices.containerInner.element, false);\n this.focusableElement.setAttribute('tabIndex', this.component.tabindex || 0);\n this.choices.enable();\n }\n }\n get disabled() {\n return super.disabled;\n }\n set visible(value) {\n // If we go from hidden to visible, trigger a refresh.\n if (value && (!this._visible !== !value)) {\n this.triggerUpdate();\n }\n super.visible = value;\n }\n get visible() {\n return super.visible;\n }\n addCurrentChoices(values, items, keyValue) {\n if (!values) {\n return false;\n }\n const notFoundValuesToAdd = [];\n const added = values.reduce((defaultAdded, value) => {\n if (!value || lodash_1.default.isEmpty(value)) {\n return defaultAdded;\n }\n let found = false;\n // Make sure that `items` and `this.selectOptions` points\n // to the same reference. Because `this.selectOptions` is\n // internal property and all items are populated by\n // `this.addOption` method, we assume that items has\n // 'label' and 'value' properties. This assumption allows\n // us to read correct value from the item.\n const isSelectOptions = items === this.selectOptions;\n if (items && items.length) {\n lodash_1.default.each(items, (choice) => {\n if (choice._id && value._id && (choice._id === value._id)) {\n found = true;\n return false;\n }\n const itemValue = keyValue ? choice.value : this.itemValue(choice, isSelectOptions);\n found |= lodash_1.default.isEqual(itemValue, value);\n return found ? false : true;\n });\n }\n // Add the default option if no item is found.\n if (!found) {\n notFoundValuesToAdd.push(this.selectValueAndLabel(value));\n return true;\n }\n return found || defaultAdded;\n }, false);\n if (notFoundValuesToAdd.length) {\n if (this.choices) {\n this.choices.setChoices(notFoundValuesToAdd, 'value', 'label');\n }\n notFoundValuesToAdd.map(notFoundValue => {\n this.addOption(notFoundValue.value, notFoundValue.label);\n });\n }\n return added;\n }\n getValueAsString(data, options) {\n return (this.component.multiple && Array.isArray(data))\n ? data.map((v) => this.asString(v, options)).join(', ')\n : this.asString(data, options);\n }\n getValue() {\n // If the widget isn't active.\n if (this.viewOnly || this.loading\n || (!this.component.lazyLoad && !this.selectOptions.length)\n || !this.element) {\n return this.dataValue;\n }\n let value = this.emptyValue;\n if (this.choices) {\n value = this.choices.getValue(true);\n // Make sure we don't get the placeholder\n if (!this.component.multiple &&\n this.component.placeholder &&\n (value === this.t(this.component.placeholder, { _userInput: true }))) {\n value = this.emptyValue;\n }\n }\n else if (this.refs.selectContainer) {\n value = this.refs.selectContainer.value;\n if (this.valueProperty === '' || this.isEntireObjectDisplay()) {\n if (value === '') {\n return {};\n }\n const option = this.selectOptions[value] ||\n this.selectOptions.find(option => option.id === value);\n if (option && lodash_1.default.isObject(option.value)) {\n value = option.value;\n }\n }\n }\n else {\n value = this.dataValue;\n }\n // Choices will return undefined if nothing is selected. We really want '' to be empty.\n if (value === undefined || value === null) {\n value = '';\n }\n return value;\n }\n redraw() {\n const done = super.redraw();\n this.triggerUpdate();\n return done;\n }\n normalizeSingleValue(value) {\n if (lodash_1.default.isNil(value)) {\n return;\n }\n const valueIsObject = lodash_1.default.isObject(value);\n //check if value equals to default emptyValue\n if (valueIsObject && Object.keys(value).length === 0) {\n return value;\n }\n const dataType = this.component.dataType || 'auto';\n const normalize = {\n value,\n number() {\n const numberValue = Number(this.value);\n const isEquivalent = value.toString() === numberValue.toString();\n if (!Number.isNaN(numberValue) && Number.isFinite(numberValue) && value !== '' && isEquivalent) {\n this.value = numberValue;\n }\n return this;\n },\n boolean() {\n if (lodash_1.default.isString(this.value)\n && (this.value.toLowerCase() === 'true'\n || this.value.toLowerCase() === 'false')) {\n this.value = (this.value.toLowerCase() === 'true');\n }\n return this;\n },\n string() {\n this.value = String(this.value);\n return this;\n },\n object() {\n return this;\n },\n auto() {\n if (lodash_1.default.isObject(this.value)) {\n this.value = this.object().value;\n }\n else {\n this.value = this.string().number().boolean().value;\n }\n return this;\n }\n };\n try {\n return normalize[dataType]().value;\n }\n catch (err) {\n console.warn('Failed to normalize value', err);\n return value;\n }\n }\n /**\n * Normalize values coming into updateValue. For example, depending on the configuration, string value `\"true\"` will be normalized to boolean `true`.\n * @param {*} value - The value to normalize\n * @returns {*} - Returns the normalized value\n */\n normalizeValue(value) {\n if (this.component.multiple && Array.isArray(value)) {\n return value.map((singleValue) => this.normalizeSingleValue(singleValue));\n }\n return super.normalizeValue(this.normalizeSingleValue(value));\n }\n setMetadata(value) {\n var _a;\n if (lodash_1.default.isNil(value)) {\n return;\n }\n const valueIsObject = lodash_1.default.isObject(value);\n //check if value equals to default emptyValue\n if (valueIsObject && Object.keys(value).length === 0) {\n return value;\n }\n // Check to see if we need to save off the template data into our metadata.\n const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;\n const shouldSaveData = !valueIsObject || this.component.reference;\n if (!lodash_1.default.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submission)) {\n const submission = this.root.submission;\n if (!submission.metadata) {\n submission.metadata = {};\n }\n if (!submission.metadata.selectData) {\n submission.metadata.selectData = {};\n }\n let templateData = this.templateData[templateValue];\n if (this.component.multiple) {\n templateData = {};\n const dataValue = this.dataValue;\n if (dataValue && lodash_1.default.isArray(dataValue) && dataValue.length) {\n dataValue.forEach((dataValueItem) => {\n const dataValueItemValue = this.component.reference ? dataValueItem._id.toString() : dataValueItem;\n templateData[dataValueItemValue] = this.templateData[dataValueItemValue];\n });\n }\n templateData[value] = this.templateData[value];\n }\n lodash_1.default.set(submission.metadata.selectData, this.path, templateData);\n }\n }\n updateValue(value, flags) {\n const changed = super.updateValue(value, flags);\n if (changed || !this.selectMetadata) {\n if (this.component.multiple && Array.isArray(this.dataValue)) {\n this.dataValue.forEach(singleValue => this.setMetadata(singleValue));\n }\n else {\n this.setMetadata(this.dataValue);\n }\n }\n return changed;\n }\n undoValueTyping(value) {\n let untypedValue = value;\n if (this.component.multiple && Array.isArray(value)) {\n untypedValue = value.map(v => {\n if (typeof v === 'boolean' || typeof v === 'number') {\n return v.toString();\n }\n return v;\n });\n }\n else {\n if (typeof value === 'boolean' || typeof value === 'number') {\n untypedValue = value.toString();\n }\n }\n return untypedValue;\n }\n setValue(value, flags = {}) {\n const previousValue = this.dataValue;\n const changed = this.updateValue(value, flags);\n if (this.component.widget === 'html5' && (lodash_1.default.isEqual(value, previousValue) || lodash_1.default.isEqual(previousValue, {}) && lodash_1.default.isEqual(flags, {})) && !flags.fromSubmission) {\n return false;\n }\n value = this.dataValue;\n const hasPreviousValue = !this.isEmpty(previousValue);\n const hasValue = !this.isEmpty(value);\n // Undo typing when searching to set the value.\n value = this.undoValueTyping(value);\n if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {\n this.itemsLoaded.then(() => {\n this.redraw();\n });\n return changed;\n }\n // Do not set the value if we are loading... that will happen after it is done.\n if (this.loading) {\n return changed;\n }\n // Determine if we need to perform an initial lazyLoad api call if searchField is provided.\n if (this.isInitApiCallNeeded(hasValue)) {\n this.loading = true;\n this.lazyLoadInit = true;\n const searchProperty = this.component.searchField || this.component.valueProperty;\n this.triggerUpdate(lodash_1.default.get(value.data || value, searchProperty, value), true);\n return changed;\n }\n // Add the value options.\n this.itemsLoaded.then(() => {\n this.addValueOptions();\n this.setChoicesValue(value, hasPreviousValue, flags);\n });\n return changed;\n }\n isInitApiCallNeeded(hasValue) {\n return this.component.lazyLoad &&\n !this.lazyLoadInit &&\n !this.active &&\n !this.selectOptions.length &&\n hasValue &&\n this.shouldInitialLoad &&\n this.visible && (this.component.searchField || this.component.valueProperty);\n }\n setChoicesValue(value, hasPreviousValue, flags = {}) {\n const hasValue = !this.isEmpty(value) || flags.fromSubmission;\n hasPreviousValue = (hasPreviousValue === undefined) ? true : hasPreviousValue;\n if (this.choices) {\n // Now set the value.\n if (hasValue) {\n this.choices.removeActiveItems();\n // Add the currently selected choices if they don't already exist.\n const currentChoices = Array.isArray(value) && this.component.multiple ? value : [value];\n if (!this.addCurrentChoices(currentChoices, this.selectOptions, true)) {\n this.choices.setChoices(this.selectOptions, 'value', 'label', true);\n }\n this.choices.setChoiceByValue(currentChoices);\n }\n else if (hasPreviousValue || flags.resetValue) {\n this.choices.removeActiveItems();\n }\n }\n else {\n if (hasValue) {\n const values = Array.isArray(value) ? value : [value];\n if (!lodash_1.default.isEqual(this.dataValue, this.defaultValue) && this.selectOptions.length < 2\n || (this.selectData && flags.fromSubmission)) {\n const { value, label } = this.selectValueAndLabel(this.dataValue);\n this.addOption(value, label);\n }\n lodash_1.default.each(this.selectOptions, (selectOption) => {\n lodash_1.default.each(values, (val) => {\n if (selectOption.value === '') {\n selectOption.value = {};\n }\n if (lodash_1.default.isEqual(val, selectOption.value) && selectOption.element) {\n selectOption.element.selected = true;\n selectOption.element.setAttribute('selected', 'selected');\n return false;\n }\n });\n });\n }\n else {\n lodash_1.default.each(this.selectOptions, (selectOption) => {\n if (selectOption.element) {\n selectOption.element.selected = false;\n selectOption.element.removeAttribute('selected');\n }\n });\n }\n }\n }\n validateValueAvailability(setting, value) {\n if (!(0, utils_1.boolValue)(setting) || !value) {\n return true;\n }\n const values = this.getOptionsValues();\n if (values) {\n if (lodash_1.default.isObject(value)) {\n const compareComplexValues = (optionValue) => {\n const normalizedOptionValue = this.normalizeSingleValue(optionValue);\n if (!lodash_1.default.isObject(normalizedOptionValue)) {\n return false;\n }\n try {\n return (JSON.stringify(normalizedOptionValue) === JSON.stringify(value));\n }\n catch (err) {\n console.warn.error('Error while comparing items', err);\n return false;\n }\n };\n return values.findIndex((optionValue) => compareComplexValues(optionValue)) !== -1;\n }\n return values.findIndex((optionValue) => this.normalizeSingleValue(optionValue) === value) !== -1;\n }\n return false;\n }\n /**\n * Performs required transformations on the initial value to use in selectOptions\n * @param {*} value - The value to transform.\n * @returns {*} - Returns the options value.\n */\n getOptionValue(value) {\n return lodash_1.default.isObject(value) && this.isEntireObjectDisplay()\n ? this.normalizeSingleValue(value)\n : lodash_1.default.isObject(value) && (this.valueProperty || this.component.key !== 'resource')\n ? value\n : lodash_1.default.isObject(value) && !this.valueProperty\n ? this.interpolate(this.component.template, { item: value }).replace(/<\\/?[^>]+(>|$)/g, '')\n : lodash_1.default.isNull(value)\n ? this.emptyValue\n : String(this.normalizeSingleValue(value));\n }\n /**\n * If component has static values (values, json) or custom values, returns an array of them\n * @returns {Array<*>|undefined} - Returns an array of the static or custom values.\n */\n getOptionsValues() {\n let rawItems = [];\n switch (this.component.dataSrc) {\n case 'values':\n rawItems = this.component.data.values;\n break;\n case 'json':\n rawItems = this.component.data.json;\n break;\n case 'custom':\n rawItems = this.getCustomItems();\n break;\n case 'url':\n rawItems = this.selectItems;\n break;\n }\n if (typeof rawItems === 'string') {\n try {\n rawItems = JSON.parse(rawItems);\n }\n catch (err) {\n console.warn(err.message);\n rawItems = [];\n }\n }\n if (!Array.isArray(rawItems)) {\n return;\n }\n return rawItems.map((item) => this.getOptionValue(this.itemValue(item)));\n }\n /**\n * Deletes the value of the component.\n */\n deleteValue() {\n this.setValue('', {\n noUpdateEvent: true\n });\n this.unset();\n }\n /**\n * Check if a component is eligible for multiple validation\n * @returns {boolean} - Returns FALSE for select components.\n */\n validateMultiple() {\n // Select component will contain one input when flagged as multiple.\n return false;\n }\n /**\n * Output this select dropdown as a string value.\n * @returns {*}\n */\n isBooleanOrNumber(value) {\n return typeof value === 'number' || typeof value === 'boolean';\n }\n getNormalizedValues() {\n if (!this.component || !this.component.data || !this.component.data.values) {\n return;\n }\n return this.component.data.values.map(value => ({ label: value.label, value: String(this.normalizeSingleValue(value.value)) }));\n }\n asString(value, options = {}) {\n var _a;\n value = value !== null && value !== void 0 ? value : this.getValue();\n if (options.modalPreview || this.inDataTable) {\n if (this.inDataTable) {\n value = this.undoValueTyping(value);\n }\n const templateValue = (this.isEntireObjectDisplay() && !lodash_1.default.isObject(value.data)) ? { data: value } : value;\n const template = this.itemTemplate(templateValue, value, options);\n return template;\n }\n //need to convert values to strings to be able to compare values with available options that are strings\n const convertToString = (data, valueProperty) => {\n if (valueProperty) {\n if (Array.isArray(data)) {\n data.forEach((item) => item[valueProperty] = item[valueProperty].toString());\n }\n else if (lodash_1.default.isObject(data)) {\n data[valueProperty] = data[valueProperty].toString();\n }\n return data;\n }\n if (this.isBooleanOrNumber(data)) {\n data = data.toString();\n }\n if (Array.isArray(data) && data.some(item => this.isBooleanOrNumber(item))) {\n data = data.map(item => this.isBooleanOrNumber(item) ? item.toString() : item);\n }\n return data;\n };\n value = convertToString(value);\n if (['values', 'custom'].includes(this.component.dataSrc) && !this.asyncCustomValues()) {\n const { items, valueProperty, } = this.component.dataSrc === 'values'\n ? {\n items: convertToString(this.getNormalizedValues(), 'value'),\n valueProperty: 'value',\n }\n : {\n items: convertToString(this.getCustomItems(), this.valueProperty),\n valueProperty: this.valueProperty,\n };\n const getFromValues = () => {\n const initialValue = lodash_1.default.find(items, [valueProperty, value]);\n const values = this.defaultSchema.data.values || [];\n return lodash_1.default.isEqual(initialValue, values[0]) ? '-' : initialValue;\n };\n value = (this.component.multiple && Array.isArray(value))\n ? lodash_1.default.filter(items, (item) => value.includes(item.value))\n : (valueProperty && items)\n ? (_a = getFromValues()) !== null && _a !== void 0 ? _a : { value, label: value }\n : value;\n }\n if (lodash_1.default.isString(value)) {\n return value;\n }\n const getTemplateValue = (v) => {\n const itemTemplate = this.itemTemplate(v);\n return options.csv && itemTemplate\n ? (0, utils_1.removeHTML)(itemTemplate)\n : itemTemplate;\n };\n if (Array.isArray(value)) {\n const items = [];\n value.forEach(item => items.push(getTemplateValue(item)));\n if (this.component.dataSrc === 'resource' && items.length > 0) {\n return items.join(', ');\n }\n else if (items.length > 0) {\n return items.join('<br />');\n }\n else {\n return '-';\n }\n }\n if (this.isEntireObjectDisplay() && lodash_1.default.isObject(value)) {\n return JSON.stringify(value);\n }\n return !lodash_1.default.isNil(value)\n ? getTemplateValue(value)\n : '-';\n }\n detach() {\n var _a, _b;\n this.off('blur');\n if (this.choices) {\n if ((_b = (_a = this.choices.containerOuter) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.parentNode) {\n this.choices.destroy();\n }\n this.choices = null;\n }\n super.detach();\n }\n focus() {\n super.focus.call(this);\n if (this.focusableElement) {\n this.focusableElement.focus();\n }\n }\n setErrorClasses(elements, dirty, hasError, hasMessages, element = this.element) {\n super.setErrorClasses(elements, dirty, hasError, hasMessages, element);\n if (this.choices) {\n super.setErrorClasses([this.choices.containerInner.element], dirty, hasError, hasMessages, element);\n }\n else {\n super.setErrorClasses([this.refs.selectContainer], dirty, hasError, hasMessages, element);\n }\n }\n}\nexports[\"default\"] = SelectComponent;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/select/Select.js?");
|
5424
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst Formio_1 = __webpack_require__(/*! ../../Formio */ \"./lib/cjs/Formio.js\");\nconst ListComponent_1 = __importDefault(__webpack_require__(/*! ../_classes/list/ListComponent */ \"./lib/cjs/components/_classes/list/ListComponent.js\"));\nconst Input_1 = __importDefault(__webpack_require__(/*! ../_classes/input/Input */ \"./lib/cjs/components/_classes/input/Input.js\"));\nconst Form_1 = __importDefault(__webpack_require__(/*! ../../Form */ \"./lib/cjs/Form.js\"));\nconst utils_1 = __webpack_require__(/*! ../../utils/utils */ \"./lib/cjs/utils/utils.js\");\nconst ChoicesWrapper_1 = __importDefault(__webpack_require__(/*! ../../utils/ChoicesWrapper */ \"./lib/cjs/utils/ChoicesWrapper.js\"));\nclass SelectComponent extends ListComponent_1.default {\n static schema(...extend) {\n return ListComponent_1.default.schema({\n type: 'select',\n label: 'Select',\n key: 'select',\n idPath: 'id',\n data: {\n values: [{ label: '', value: '' }],\n json: '',\n url: '',\n resource: '',\n custom: ''\n },\n clearOnRefresh: false,\n limit: 100,\n valueProperty: '',\n lazyLoad: true,\n filter: '',\n searchEnabled: true,\n searchDebounce: 0.3,\n searchField: '',\n minSearch: 0,\n readOnlyValue: false,\n selectFields: '',\n selectThreshold: 0.3,\n uniqueOptions: false,\n tableView: true,\n fuseOptions: {\n include: 'score',\n threshold: 0.3,\n },\n indexeddb: {\n filter: {}\n },\n customOptions: {},\n useExactSearch: false,\n }, ...extend);\n }\n static get builderInfo() {\n return {\n title: 'Select',\n group: 'basic',\n icon: 'th-list',\n weight: 70,\n documentation: '/userguide/form-building/form-components#select',\n schema: SelectComponent.schema()\n };\n }\n static get serverConditionSettings() {\n return SelectComponent.conditionOperatorsSettings;\n }\n static get conditionOperatorsSettings() {\n const numberType = () => ({ type: 'number' });\n return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { valueComponent(classComp) {\n const valueComp = Object.assign(Object.assign({}, classComp), { type: 'select' });\n if ((0, utils_1.isSelectResourceWithObjectValue)(classComp)) {\n valueComp.reference = false;\n valueComp.onSetItems = `\n var templateKeys = utils.getItemTemplateKeys(component.template) || [];\n items = _.map(items || [], i => {\n var item = {};\n _.each(templateKeys, k => _.set(item, k, _.get(i, k)));\n return item;\n })\n `;\n }\n return valueComp;\n }, dataTypeOperators: {\n number: ['lessThan', 'greaterThan', 'lessThanOrEqual', 'greaterThanOrEqual'],\n }, dataTypeValueComponents: {\n number: {\n lessThan: numberType,\n greaterThan: numberType,\n lessThanOrEqual: numberType,\n greaterThanOrEqual: numberType,\n },\n } });\n }\n static savedValueTypes(schema) {\n const { boolean, string, number, object, array } = utils_1.componentValueTypes;\n const { dataType, reference } = schema;\n const types = (0, utils_1.getComponentSavedTypes)(schema);\n if (types) {\n return types;\n }\n if (reference) {\n return [object];\n }\n if (dataType === 'object') {\n return [object, array];\n }\n if (utils_1.componentValueTypes[dataType]) {\n return [utils_1.componentValueTypes[dataType]];\n }\n return [boolean, string, number, object, array];\n }\n init() {\n super.init();\n this.templateData = {};\n // Trigger an update.\n let updateArgs = [];\n const triggerUpdate = lodash_1.default.debounce((...args) => {\n updateArgs = [];\n return this.updateItems.apply(this, args);\n }, 100);\n this.triggerUpdate = (...args) => {\n // Make sure we always resolve the previous promise before reassign it\n if (typeof this.itemsLoadedResolve === 'function') {\n this.itemsLoadedResolve();\n }\n this.itemsLoaded = new Promise((resolve) => {\n this.itemsLoadedResolve = resolve;\n });\n if (args.length) {\n updateArgs = args;\n }\n return triggerUpdate(...updateArgs);\n };\n // Keep track of the select options.\n this.selectOptions = [];\n if (this.itemsFromUrl) {\n this.isFromSearch = false;\n this.searchServerCount = null;\n this.defaultServerCount = null;\n this.isScrollLoading = false;\n this.searchDownloadedResources = [];\n this.defaultDownloadedResources = [];\n }\n // If this component has been activated.//\n this.activated = false;\n this.itemsLoaded = new Promise((resolve) => {\n this.itemsLoadedResolve = resolve;\n });\n this.shouldPositionDropdown = this.hasDataGridAncestor();\n if (this.isHtmlRenderMode()) {\n this.activate();\n }\n // Get the template keys for this select component.\n this.getTemplateKeys();\n }\n get defaultSchema() {\n return SelectComponent.schema();\n }\n get emptyValue() {\n if (this.component.multiple) {\n return [];\n }\n // if select has JSON data source type, we are defining if empty value would be an object or a string by checking JSON's first item\n if (this.component.dataSrc === 'json' && this.component.data.json) {\n const firstItem = this.component.data.json[0];\n let firstValue;\n if (this.valueProperty) {\n firstValue = lodash_1.default.get(firstItem, this.valueProperty);\n }\n else {\n firstValue = firstItem;\n }\n if (firstValue && typeof firstValue === 'string') {\n return '';\n }\n else {\n return {};\n }\n }\n if (this.valueProperty) {\n return '';\n }\n return {};\n }\n get valueProperty() {\n if (this.component.valueProperty) {\n return this.component.valueProperty;\n }\n // Force values datasource to use values without actually setting it on the component settings.\n if (this.component.dataSrc === 'values') {\n return 'value';\n }\n return '';\n }\n get inputInfo() {\n const info = super.elementInfo();\n info.type = 'select';\n info.changeEvent = 'change';\n return info;\n }\n get isSelectResource() {\n return this.component.dataSrc === 'resource';\n }\n get itemsFromUrl() {\n return this.isSelectResource || this.isSelectURL;\n }\n get isInfiniteScrollProvided() {\n return this.itemsFromUrl;\n }\n get shouldDisabled() {\n return super.shouldDisabled || this.parentDisabled;\n }\n get shouldInitialLoad() {\n if (this.component.widget === 'html5' &&\n this.isEntireObjectDisplay() &&\n this.component.searchField &&\n this.dataValue) {\n return false;\n }\n return super.shouldLoad;\n }\n get selectMetadata() {\n return super.selectData;\n }\n get selectData() {\n return this.selectMetadata || this.component.selectData;\n }\n isEntireObjectDisplay() {\n return this.component.dataSrc === 'resource' && this.valueProperty === 'data';\n }\n selectValueAndLabel(data) {\n const value = this.getOptionValue((this.isEntireObjectDisplay() && !this.itemValue(data)) ? data : this.itemValue(data));\n return {\n value,\n label: this.itemTemplate((this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data)) ? { data: data } : data, value)\n };\n }\n itemTemplate(data, value) {\n if (!lodash_1.default.isNumber(data) && lodash_1.default.isEmpty(data)) {\n return '';\n }\n // If they wish to show the value in read only mode, then just return the itemValue here.\n if (this.options.readOnly && this.component.readOnlyValue) {\n return this.itemValue(data);\n }\n // Perform a fast interpretation if we should not use the template.\n if (data && !this.component.template) {\n const itemLabel = data.label || data;\n const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;\n return this.sanitize(value, this.shouldSanitizeValue);\n }\n // Inside DataTable component won't have dataValue set\n const shouldUseSelectData = (this.component.multiple && lodash_1.default.isArray(this.dataValue)\n ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val)\n : (this.dataValue === this.normalizeSingleValue(value))) || this.inDataTable;\n if (shouldUseSelectData) {\n const selectData = this.selectData;\n if (selectData) {\n const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;\n if (!this.templateData || !this.templateData[templateValue]) {\n this.getOptionTemplate(data, value);\n }\n if (this.component.multiple) {\n if (selectData[templateValue]) {\n data = selectData[templateValue];\n }\n }\n else {\n data = selectData;\n }\n }\n }\n if (typeof data === 'string' || typeof data === 'number') {\n return this.sanitize(this.t(data, { _userInput: true }), this.shouldSanitizeValue);\n }\n if (Array.isArray(data)) {\n return data.map((val) => {\n if (typeof val === 'string' || typeof val === 'number') {\n return this.sanitize(this.t(val, { _userInput: true }), this.shouldSanitizeValue);\n }\n return val;\n });\n }\n if (data.data) {\n // checking additional fields in the template for the selected Entire Object option\n const hasNestedFields = /item\\.data\\.\\w*/g.test(this.component.template);\n data.data = this.isEntireObjectDisplay() && lodash_1.default.isObject(data.data) && !hasNestedFields\n ? JSON.stringify(data.data)\n : data.data;\n }\n return super.itemTemplate(data, value);\n }\n /**\n * Adds an option to the select dropdown.\n * @param {*} value - The value of the new option.\n * @param {string} label - The label of the new option.\n * @param {object} [attrs] - Additional value attributes. Defaults to {}.\n * @param {string} [id] - An id. Defaults to a random string.\n */\n addOption(value, label, attrs = {}, id = (0, utils_1.getRandomComponentId)()) {\n if (lodash_1.default.isNil(label))\n return;\n const idPath = this.component.idPath\n ? this.component.idPath.split('.').reduceRight((obj, key) => ({ [key]: obj }), id)\n : {};\n const option = Object.assign({ value: this.getOptionValue(value), label }, idPath);\n const skipOption = this.component.uniqueOptions\n ? !!this.selectOptions.find((selectOption) => lodash_1.default.isEqual(selectOption.value, option.value))\n : false;\n if (skipOption) {\n return;\n }\n if (value) {\n this.selectOptions.push(option);\n }\n if (this.refs.selectContainer && (this.component.widget === 'html5')) {\n // Replace an empty Object value to an empty String.\n if (option.value && lodash_1.default.isObject(option.value) && lodash_1.default.isEmpty(option.value)) {\n option.value = '';\n }\n // Add element to option so we can reference it later.\n const div = document.createElement('div');\n div.innerHTML = this.sanitize(this.renderTemplate('selectOption', {\n selected: lodash_1.default.isEqual(this.getOptionValue(this.dataValue), option.value),\n option,\n attrs,\n id,\n useId: (this.valueProperty === '' || this.isEntireObjectDisplay()) && lodash_1.default.isObject(value) && id,\n }), this.shouldSanitizeValue).trim();\n option.element = div.firstChild;\n this.refs.selectContainer.appendChild(option.element);\n }\n }\n addValueOptions(items) {\n items = items || [];\n let added = false;\n let data = this.dataValue;\n // preset submission value with value property before request.\n if (this.options.pdf && !items.length && this.component.dataSrc === 'url' && this.valueProperty) {\n data = Array.isArray(data)\n ? data.map(item => lodash_1.default.set({}, this.valueProperty, item))\n : lodash_1.default.set({}, this.valueProperty, data);\n }\n if (!this.selectOptions.length) {\n // Add the currently selected choices if they don't already exist.\n const currentChoices = Array.isArray(data) && this.component.multiple ? data : [data];\n added = this.addCurrentChoices(currentChoices, items);\n if (!added && !this.component.multiple) {\n this.addPlaceholder();\n }\n }\n return added;\n }\n disableInfiniteScroll() {\n if (!this.downloadedResources) {\n return;\n }\n this.downloadedResources.serverCount = this.downloadedResources.length;\n this.serverCount = this.downloadedResources.length;\n }\n /* eslint-disable max-statements */\n setItems(items, fromSearch) {\n var _a, _b;\n this.selectItems = items;\n // If the items is a string, then parse as JSON.\n if (typeof items == 'string') {\n try {\n items = JSON.parse(items);\n }\n catch (err) {\n console.warn(err.message);\n items = [];\n }\n }\n // Allow js processing (needed for form builder)\n if (this.component.onSetItems) {\n const newItems = typeof this.component.onSetItems === 'function'\n ? this.component.onSetItems(this, items)\n : this.evaluate(this.component.onSetItems, { items: items }, 'items');\n if (newItems) {\n items = newItems;\n }\n }\n if (!this.choices && this.refs.selectContainer) {\n this.empty(this.refs.selectContainer);\n }\n // If they provided select values, then we need to get them instead.\n if (this.component.selectValues) {\n items = lodash_1.default.get(items, this.component.selectValues, items) || [];\n }\n let areItemsEqual;\n if (this.itemsFromUrl) {\n areItemsEqual = this.isSelectURL ? lodash_1.default.isEqual(items, this.downloadedResources) : false;\n const areItemsEnded = this.component.limit > items.length;\n const areItemsDownloaded = areItemsEqual\n && this.downloadedResources\n && this.downloadedResources.length === items.length;\n if (areItemsEnded) {\n this.disableInfiniteScroll();\n }\n else if (areItemsDownloaded) {\n this.selectOptions = [];\n }\n else {\n this.serverCount = items.serverCount;\n }\n }\n if (this.isScrollLoading && items) {\n if (!areItemsEqual) {\n this.downloadedResources = this.downloadedResources\n ? this.downloadedResources.concat(items)\n : items;\n }\n this.downloadedResources.serverCount = items.serverCount || this.downloadedResources.serverCount;\n }\n else {\n this.downloadedResources = items || [];\n this.selectOptions = [];\n // If there is new select option with same id as already selected, set the new one\n if (!lodash_1.default.isEmpty(this.dataValue) && this.component.idPath) {\n const selectedOptionId = lodash_1.default.get(this.dataValue, this.component.idPath, null);\n const newOptionWithSameId = !lodash_1.default.isNil(selectedOptionId) && items.find(item => {\n const itemId = lodash_1.default.get(item, this.component.idPath);\n return itemId === selectedOptionId;\n });\n if (newOptionWithSameId) {\n this.setValue(newOptionWithSameId);\n }\n }\n }\n // Add the value options.\n if (!fromSearch) {\n this.addValueOptions(items);\n }\n if (this.component.widget === 'html5' && !this.component.placeholder) {\n this.addOption(null, '');\n }\n // Iterate through each of the items.\n lodash_1.default.each(items, (item, index) => {\n // preventing references of the components inside the form to the parent form when building forms\n if (this.root && this.root.options.editForm && this.root.options.editForm._id && this.root.options.editForm._id === item._id)\n return;\n const itemValueAndLabel = this.selectValueAndLabel(item);\n this.addOption(itemValueAndLabel.value, itemValueAndLabel.label, {}, lodash_1.default.get(item, this.component.idPath, String(index)));\n });\n if (this.choices) {\n this.choices.setChoices(this.selectOptions, 'value', 'label', true);\n }\n else if (this.loading) {\n // Re-attach select input.\n // this.appendTo(this.refs.input[0], this.selectContainer);\n }\n // We are no longer loading.\n this.isScrollLoading = false;\n this.loading = false;\n const searching = fromSearch && ((_b = (_a = this.choices) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.isFocussed);\n if (!searching) {\n // If a value is provided, then select it.\n if (!this.isEmpty() || this.isRemoveButtonPressed) {\n this.setValue(this.dataValue, {\n noUpdateEvent: true\n });\n }\n else if (this.shouldAddDefaultValue && !this.options.readOnly) {\n // If a default value is provided then select it.\n const defaultValue = this.defaultValue;\n if (!this.isEmpty(defaultValue)) {\n this.setValue(defaultValue);\n }\n }\n }\n // Say we are done loading the items.\n this.itemsLoadedResolve();\n }\n getSingleItemValueForHTMLMode(data) {\n var _a;\n const option = (_a = this.selectOptions) === null || _a === void 0 ? void 0 : _a.find(({ value }) => lodash_1.default.isEqual(value, data));\n if (option) {\n return option.label || data;\n }\n return data;\n }\n itemValueForHTMLMode(value) {\n if (!this.isHtmlRenderMode()) {\n return super.itemValueForHTMLMode(value);\n }\n if (Array.isArray(value)) {\n const values = value.map(item => Array.isArray(item)\n ? this.itemValueForHTMLMode(item)\n : this.getSingleItemValueForHTMLMode(item));\n return values.join(', ');\n }\n return this.getSingleItemValueForHTMLMode(value);\n }\n /* eslint-enable max-statements */\n get defaultValue() {\n let defaultValue = super.defaultValue;\n if (!defaultValue && (this.component.defaultValue === false || this.component.defaultValue === 0)) {\n defaultValue = this.component.defaultValue;\n }\n return defaultValue;\n }\n get loadingError() {\n return !this.component.refreshOn && !this.component.refreshOnBlur && this.networkError;\n }\n loadItems(url, search, headers, options, method, body) {\n options = options || {};\n // See if we should load items or not.\n if (!this.shouldLoad || (!this.itemsFromUrl && this.options.readOnly)) {\n this.isScrollLoading = false;\n this.loading = false;\n this.itemsLoadedResolve();\n return;\n }\n // See if they have not met the minimum search requirements.\n const minSearch = parseInt(this.component.minSearch, 10);\n if (this.component.searchField &&\n (minSearch > 0) &&\n (!search || (search.length < minSearch))) {\n // Set empty items.\n return this.setItems([]);\n }\n // Ensure we have a method and remove any body if method is get\n method = method || 'GET';\n if (method.toUpperCase() === 'GET') {\n body = null;\n }\n const limit = this.component.limit || 100;\n const skip = this.isScrollLoading ? this.selectOptions.length : 0;\n const query = this.component.disableLimit ? {} : {\n limit,\n skip,\n };\n // Allow for url interpolation.\n url = this.interpolate(url, {\n formioBase: Formio_1.Formio.getBaseUrl(),\n search,\n limit,\n skip,\n page: Math.abs(Math.floor(skip / limit))\n });\n // Add search capability.\n if (this.component.searchField && search) {\n const searchValue = Array.isArray(search)\n ? search.join(',')\n : typeof search === 'object'\n ? JSON.stringify(search)\n : search;\n query[this.component.searchField] = this.component.searchField.endsWith('__regex')\n ? lodash_1.default.escapeRegExp(searchValue)\n : searchValue;\n }\n // If they wish to return only some fields.\n if (this.component.selectFields) {\n query.select = this.component.selectFields;\n }\n // Add sort capability\n if (this.component.sort) {\n query.sort = this.component.sort;\n }\n if (!lodash_1.default.isEmpty(query)) {\n // Add the query string.\n url += (!url.includes('?') ? '?' : '&') + Formio_1.Formio.serialize(query, (item) => this.interpolate(item));\n }\n // Add filter capability\n if (this.component.filter) {\n url += (!url.includes('?') ? '?' : '&') + this.interpolate(this.component.filter);\n }\n // Set ignoreCache if it is\n options.ignoreCache = this.component.ignoreCache;\n // Make the request.\n options.header = headers;\n this.loading = true;\n Formio_1.Formio.makeRequest(this.options.formio, 'select', url, method, body, options)\n .then((response) => {\n this.loading = false;\n this.setItems(response, !!search);\n })\n .catch((err) => {\n if (this.itemsFromUrl) {\n this.setItems([]);\n this.disableInfiniteScroll();\n }\n this.isScrollLoading = false;\n this.handleLoadingError(err);\n });\n }\n handleLoadingError(err) {\n this.loading = false;\n if (err.networkError) {\n this.networkError = true;\n }\n this.itemsLoadedResolve();\n this.emit('componentError', {\n component: this.component,\n message: err.toString(),\n });\n console.warn(`Unable to load resources for ${this.key}`);\n }\n /**\n * Get the request headers for this select dropdown.\n * @returns {*} - Returns the request headers for this select dropdown.\n */\n get requestHeaders() {\n // Create the headers object.\n const headers = new Formio_1.Formio.Headers();\n // Add custom headers to the url.\n if (this.component.data && this.component.data.headers) {\n try {\n lodash_1.default.each(this.component.data.headers, (header) => {\n if (header.key) {\n headers.set(header.key, this.interpolate(header.value));\n }\n });\n }\n catch (err) {\n console.warn(err.message);\n }\n }\n return headers;\n }\n getCustomItems() {\n const customItems = this.evaluate(this.component.data.custom, {\n values: []\n }, 'values');\n this.asyncValues = (0, utils_1.isPromise)(customItems);\n return customItems;\n }\n asyncCustomValues() {\n if (!lodash_1.default.isBoolean(this.asyncValues)) {\n this.getCustomItems();\n }\n return this.asyncValues;\n }\n updateCustomItems(forceUpdate) {\n if (this.asyncCustomValues()) {\n if (!forceUpdate && !this.active) {\n this.itemsLoadedResolve();\n return;\n }\n this.loading = true;\n this.getCustomItems()\n .then(items => {\n this.loading = false;\n this.setItems(items || []);\n })\n .catch(err => {\n this.handleLoadingError(err);\n });\n }\n else {\n this.setItems(this.getCustomItems() || []);\n }\n }\n isEmpty(value = this.dataValue) {\n return super.isEmpty(value) || value === undefined;\n }\n refresh(value, { instance }) {\n if (this.component.clearOnRefresh && (instance && !instance.pristine)) {\n this.setValue(this.emptyValue);\n }\n this.updateItems(null, true);\n }\n get additionalResourcesAvailable() {\n return lodash_1.default.isNil(this.serverCount) || (this.serverCount > this.downloadedResources.length);\n }\n get serverCount() {\n if (this.isFromSearch) {\n return this.searchServerCount;\n }\n return this.defaultServerCount;\n }\n set serverCount(value) {\n if (this.isFromSearch) {\n this.searchServerCount = value;\n }\n else {\n this.defaultServerCount = value;\n }\n }\n get downloadedResources() {\n if (this.isFromSearch) {\n return this.searchDownloadedResources;\n }\n return this.defaultDownloadedResources;\n }\n set downloadedResources(value) {\n if (this.isFromSearch) {\n this.searchDownloadedResources = value;\n }\n else {\n this.defaultDownloadedResources = value;\n }\n }\n addPlaceholder() {\n if (!this.component.placeholder) {\n return;\n }\n this.addOption('', this.component.placeholder, { placeholder: true });\n }\n /**\n * Activate this select control.\n */\n activate() {\n if (this.loading || !this.active) {\n this.setLoadingItem();\n }\n if (this.active) {\n return;\n }\n this.activated = true;\n this.triggerUpdate();\n }\n setLoadingItem(addToCurrentList = false) {\n if (this.choices) {\n if (addToCurrentList) {\n this.choices.setChoices([{\n value: `${this.id}-loading`,\n label: 'Loading...',\n disabled: true,\n }], 'value', 'label');\n }\n else {\n this.choices.setChoices([{\n value: '',\n label: `<i class=\"${this.iconClass('refresh')}\" style=\"font-size:1.3em;\"></i>`,\n disabled: true,\n }], 'value', 'label', true);\n }\n }\n else if (this.component.dataSrc === 'url' || this.component.dataSrc === 'resource') {\n this.addOption('', this.t('loading...'));\n }\n }\n get active() {\n return !this.component.lazyLoad || this.activated;\n }\n render() {\n const info = this.inputInfo;\n info.attr = info.attr || {};\n info.multiple = this.component.multiple;\n return super.render(this.wrapElement(this.renderTemplate('select', {\n input: info,\n selectOptions: '',\n index: null,\n })));\n }\n wrapElement(element) {\n return this.component.addResource && !this.options.readOnly\n ? (this.renderTemplate('resourceAdd', {\n element\n }))\n : element;\n }\n choicesOptions() {\n const useSearch = this.component.hasOwnProperty('searchEnabled') ? this.component.searchEnabled : true;\n const placeholderValue = this.t(this.component.placeholder, { _userInput: true });\n let customOptions = this.component.customOptions || {};\n if (typeof customOptions == 'string') {\n try {\n customOptions = JSON.parse(customOptions);\n }\n catch (err) {\n console.warn(err.message);\n customOptions = {};\n }\n }\n const commonFuseOptions = {\n maxPatternLength: 1000,\n distance: 1000,\n };\n return Object.assign({ removeItemButton: this.component.disabled ? false : lodash_1.default.get(this.component, 'removeItemButton', true), itemSelectText: '', classNames: {\n containerOuter: 'choices form-group formio-choices',\n containerInner: this.transform('class', 'form-control ui fluid selection dropdown')\n }, addItemText: false, allowHTML: true, placeholder: !!this.component.placeholder, placeholderValue: placeholderValue, noResultsText: this.t('No results found'), noChoicesText: this.t('No choices to choose from'), searchPlaceholderValue: this.t('Type to search'), shouldSort: false, position: (this.component.dropdown || 'auto'), searchEnabled: useSearch, searchChoices: !this.component.searchField, searchFields: lodash_1.default.get(this, 'component.searchFields', ['label']), shadowRoot: this.root ? this.root.shadowRoot : null, fuseOptions: this.component.useExactSearch\n ? Object.assign({ tokenize: true, matchAllTokens: true }, commonFuseOptions) : Object.assign({}, lodash_1.default.get(this, 'component.fuseOptions', {}), Object.assign({ include: 'score', threshold: lodash_1.default.get(this, 'component.selectThreshold', 0.3) }, commonFuseOptions)), valueComparer: lodash_1.default.isEqual, resetScrollPosition: false }, customOptions);\n }\n /* eslint-disable max-statements */\n attach(element) {\n var _a, _b, _c;\n const superAttach = super.attach(element);\n this.loadRefs(element, {\n selectContainer: 'single',\n addResource: 'single',\n autocompleteInput: 'single'\n });\n //enable autocomplete for select\n const autocompleteInput = this.refs.autocompleteInput;\n if (autocompleteInput) {\n this.addEventListener(autocompleteInput, 'change', (event) => {\n this.setValue(event.target.value);\n });\n }\n const input = this.refs.selectContainer;\n if (!input) {\n return;\n }\n this.addEventListener(input, this.inputInfo.changeEvent, () => this.updateValue(null, {\n modified: true\n }));\n this.attachRefreshOnBlur();\n if (this.component.widget === 'html5') {\n this.addFocusBlurEvents(input);\n this.triggerUpdate(null, true);\n if (this.visible) {\n this.setItems(this.selectItems || []);\n }\n this.focusableElement = input;\n if (this.component.dataSrc === 'custom') {\n this.addEventListener(input, 'focus', () => this.updateCustomItems());\n }\n this.addEventListener(input, 'keydown', (event) => {\n const { key } = event;\n if (['Backspace', 'Delete'].includes(key)) {\n this.setValue(this.emptyValue);\n }\n });\n return;\n }\n const tabIndex = input.tabIndex;\n this.addPlaceholder();\n if (this.i18next) {\n input.setAttribute('dir', this.i18next.dir());\n }\n if ((_c = (_b = (_a = this.choices) === null || _a === void 0 ? void 0 : _a.containerOuter) === null || _b === void 0 ? void 0 : _b.element) === null || _c === void 0 ? void 0 : _c.parentNode) {\n this.choices.destroy();\n }\n const choicesOptions = this.choicesOptions();\n if (ChoicesWrapper_1.default) {\n this.choices = new ChoicesWrapper_1.default(input, choicesOptions);\n if (this.selectOptions && this.selectOptions.length) {\n this.choices.setChoices(this.selectOptions, 'value', 'label', true);\n }\n if (this.component.multiple) {\n this.focusableElement = this.choices.input.element;\n }\n else {\n this.focusableElement = this.choices.containerInner.element;\n this.choices.containerOuter.element.setAttribute('tabIndex', '-1');\n this.addEventListener(this.choices.containerOuter.element, 'focus', () => this.focusableElement.focus());\n }\n Input_1.default.prototype.addFocusBlurEvents.call(this, this.focusableElement);\n if (this.itemsFromUrl && !this.component.noRefreshOnScroll) {\n this.scrollList = this.choices.choiceList.element;\n this.addEventListener(this.scrollList, 'scroll', () => this.onScroll());\n }\n if (choicesOptions.removeItemButton) {\n this.addEventListener(input, 'removeItem', () => {\n this.isRemoveButtonPressed = true;\n });\n }\n }\n if (window && this.choices && this.shouldPositionDropdown) {\n this.addEventListener(window.document, 'scroll', () => {\n this.positionDropdown(true);\n }, false, true);\n }\n this.focusableElement.setAttribute('tabIndex', tabIndex);\n // If a search field is provided, then add an event listener to update items on search.\n if (this.component.searchField) {\n // Make sure to clear the search when no value is provided.\n if (this.choices && this.choices.input && this.choices.input.element) {\n this.addEventListener(this.choices.input.element, 'input', (event) => {\n this.isFromSearch = !!event.target.value;\n if (!event.target.value) {\n this.triggerUpdate();\n }\n else {\n this.serverCount = null;\n this.downloadedResources = [];\n }\n });\n }\n this.addEventListener(input, 'choice', () => {\n if (this.component.multiple && this.component.dataSrc === 'resource' && this.isFromSearch) {\n this.triggerUpdate();\n }\n this.isFromSearch = false;\n });\n // avoid spamming the resource/url endpoint when we have server side filtering enabled.\n const debounceTimeout = this.component.searchField && (this.isSelectResource || this.isSelectURL) ?\n (this.component.searchDebounce === 0 ? 0 : this.component.searchDebounce || this.defaultSchema.searchDebounce) * 1000\n : 0;\n const updateComponent = (evt) => {\n this.triggerUpdate(evt.detail.value);\n };\n this.addEventListener(input, 'search', lodash_1.default.debounce((e) => {\n updateComponent(e);\n this.positionDropdown();\n }, debounceTimeout));\n this.addEventListener(input, 'stopSearch', () => this.triggerUpdate());\n this.addEventListener(input, 'hideDropdown', () => {\n if (this.choices && this.choices.input && this.choices.input.element) {\n this.choices.input.element.value = '';\n }\n this.updateItems(null, true);\n });\n }\n this.addEventListener(input, 'showDropdown', () => {\n this.update();\n this.positionDropdown();\n });\n if (this.shouldPositionDropdown) {\n this.addEventListener(input, 'highlightChoice', () => {\n this.positionDropdown();\n });\n }\n if (this.choices && choicesOptions.placeholderValue && this.choices._isSelectOneElement) {\n this.addPlaceholderItem(choicesOptions.placeholderValue);\n this.addEventListener(input, 'removeItem', () => {\n this.addPlaceholderItem(choicesOptions.placeholderValue);\n });\n }\n // Add value options.\n this.addValueOptions();\n this.setChoicesValue(this.dataValue);\n if (this.isSelectResource && this.refs.addResource) {\n this.addEventListener(this.refs.addResource, 'click', (event) => {\n event.preventDefault();\n const formioForm = this.ce('div');\n const dialog = this.createModal(formioForm);\n const projectUrl = lodash_1.default.get(this.root, 'formio.projectUrl', Formio_1.Formio.getProjectUrl());\n const formUrl = `${projectUrl}/form/${this.component.data.resource}`;\n new Form_1.default(formioForm, formUrl, {}).ready\n .then((form) => {\n form.on('submit', (submission) => {\n // If valueProperty is set, replace the submission with the corresponding value\n let value = this.valueProperty ? lodash_1.default.get(submission, this.valueProperty) : submission;\n if (this.component.multiple) {\n value = [...this.dataValue, value];\n }\n this.setValue(value);\n this.triggerUpdate();\n dialog.close();\n });\n });\n });\n }\n // Force the disabled state with getters and setters.\n this.disabled = this.shouldDisabled;\n this.triggerUpdate();\n return superAttach;\n }\n setDropdownPosition() {\n var _a, _b, _c, _d;\n const dropdown = (_b = (_a = this.choices) === null || _a === void 0 ? void 0 : _a.dropdown) === null || _b === void 0 ? void 0 : _b.element;\n const container = (_d = (_c = this.choices) === null || _c === void 0 ? void 0 : _c.containerOuter) === null || _d === void 0 ? void 0 : _d.element;\n if (!dropdown || !container) {\n return;\n }\n const containerPosition = container.getBoundingClientRect();\n const isFlipped = container.classList.contains('is-flipped');\n lodash_1.default.assign(dropdown.style, {\n top: `${isFlipped ? containerPosition.top - dropdown.offsetHeight : containerPosition.top + containerPosition.height}px`,\n left: `${containerPosition.left}px`,\n width: `${containerPosition.width}px`,\n position: 'fixed',\n bottom: 'unset',\n right: 'unset',\n });\n }\n hasDataGridAncestor(comp) {\n comp = comp || this;\n if (comp.inDataGrid || comp.type === 'datagrid') {\n return true;\n }\n else if (comp.parent) {\n return this.hasDataGridAncestor(comp.parent);\n }\n else {\n return false;\n }\n }\n positionDropdown(scroll) {\n var _a;\n if (!this.shouldPositionDropdown || !this.choices || (!((_a = this.choices.dropdown) === null || _a === void 0 ? void 0 : _a.isActive) && scroll)) {\n return;\n }\n this.setDropdownPosition();\n this.itemsLoaded.then(() => {\n this.setDropdownPosition();\n });\n }\n get isLoadingAvailable() {\n return !this.isScrollLoading && this.additionalResourcesAvailable;\n }\n onScroll() {\n if (this.isLoadingAvailable) {\n this.isScrollLoading = true;\n this.setLoadingItem(true);\n this.triggerUpdate(this.choices.input.element.value);\n }\n }\n attachRefreshOnBlur() {\n if (this.component.refreshOnBlur) {\n this.on('blur', (instance) => {\n this.checkRefreshOn([{ instance, value: instance.dataValue }], { fromBlur: true });\n });\n }\n }\n addPlaceholderItem(placeholderValue) {\n const items = this.choices._store.activeItems;\n if (!items.length) {\n this.choices._addItem({\n value: '',\n label: placeholderValue,\n choiceId: 0,\n groupId: -1,\n customProperties: null,\n placeholder: true,\n keyCode: null\n });\n }\n }\n /* eslint-enable max-statements */\n update() {\n if (this.component.dataSrc === 'custom') {\n this.updateCustomItems();\n }\n // Activate the control.\n this.activate();\n }\n set disabled(disabled) {\n super.disabled = disabled;\n if (!this.choices) {\n return;\n }\n if (disabled) {\n this.setDisabled(this.choices.containerInner.element, true);\n this.focusableElement.removeAttribute('tabIndex');\n this.choices.disable();\n }\n else {\n this.setDisabled(this.choices.containerInner.element, false);\n this.focusableElement.setAttribute('tabIndex', this.component.tabindex || 0);\n this.choices.enable();\n }\n }\n get disabled() {\n return super.disabled;\n }\n set visible(value) {\n // If we go from hidden to visible, trigger a refresh.\n if (value && (!this._visible !== !value)) {\n this.triggerUpdate();\n }\n super.visible = value;\n }\n get visible() {\n return super.visible;\n }\n addCurrentChoices(values, items, keyValue) {\n if (!values) {\n return false;\n }\n const notFoundValuesToAdd = [];\n const added = values.reduce((defaultAdded, value) => {\n if (!value || lodash_1.default.isEmpty(value)) {\n return defaultAdded;\n }\n let found = false;\n // Make sure that `items` and `this.selectOptions` points\n // to the same reference. Because `this.selectOptions` is\n // internal property and all items are populated by\n // `this.addOption` method, we assume that items has\n // 'label' and 'value' properties. This assumption allows\n // us to read correct value from the item.\n const isSelectOptions = items === this.selectOptions;\n if (items && items.length) {\n lodash_1.default.each(items, (choice) => {\n if (choice._id && value._id && (choice._id === value._id)) {\n found = true;\n return false;\n }\n const itemValue = keyValue ? choice.value : this.itemValue(choice, isSelectOptions);\n found |= lodash_1.default.isEqual(itemValue, value);\n return found ? false : true;\n });\n }\n // Add the default option if no item is found.\n if (!found) {\n notFoundValuesToAdd.push(this.selectValueAndLabel(value));\n return true;\n }\n return found || defaultAdded;\n }, false);\n if (notFoundValuesToAdd.length) {\n if (this.choices) {\n this.choices.setChoices(notFoundValuesToAdd, 'value', 'label');\n }\n notFoundValuesToAdd.map(notFoundValue => {\n this.addOption(notFoundValue.value, notFoundValue.label);\n });\n }\n return added;\n }\n getValueAsString(data, options) {\n return (this.component.multiple && Array.isArray(data))\n ? data.map((v) => this.asString(v, options)).join(', ')\n : this.asString(data, options);\n }\n getValue() {\n // If the widget isn't active.\n if (this.viewOnly || this.loading\n || (!this.component.lazyLoad && !this.selectOptions.length)\n || !this.element) {\n return this.dataValue;\n }\n let value = this.emptyValue;\n if (this.choices) {\n value = this.choices.getValue(true);\n // Make sure we don't get the placeholder\n if (!this.component.multiple &&\n this.component.placeholder &&\n (value === this.t(this.component.placeholder, { _userInput: true }))) {\n value = this.emptyValue;\n }\n }\n else if (this.refs.selectContainer) {\n value = this.refs.selectContainer.value;\n if (this.valueProperty === '' || this.isEntireObjectDisplay()) {\n if (value === '') {\n return {};\n }\n const option = this.selectOptions[value] ||\n this.selectOptions.find(option => option.id === value);\n if (option && lodash_1.default.isObject(option.value)) {\n value = option.value;\n }\n }\n }\n else {\n value = this.dataValue;\n }\n // Choices will return undefined if nothing is selected. We really want '' to be empty.\n if (value === undefined || value === null) {\n value = '';\n }\n return value;\n }\n redraw() {\n const done = super.redraw();\n this.triggerUpdate();\n return done;\n }\n normalizeSingleValue(value) {\n if (lodash_1.default.isNil(value)) {\n return;\n }\n const valueIsObject = lodash_1.default.isObject(value);\n //check if value equals to default emptyValue\n if (valueIsObject && Object.keys(value).length === 0) {\n return value;\n }\n const dataType = this.component.dataType || 'auto';\n const normalize = {\n value,\n number() {\n const numberValue = Number(this.value);\n const isEquivalent = value.toString() === numberValue.toString();\n if (!Number.isNaN(numberValue) && Number.isFinite(numberValue) && value !== '' && isEquivalent) {\n this.value = numberValue;\n }\n return this;\n },\n boolean() {\n if (lodash_1.default.isString(this.value)\n && (this.value.toLowerCase() === 'true'\n || this.value.toLowerCase() === 'false')) {\n this.value = (this.value.toLowerCase() === 'true');\n }\n return this;\n },\n string() {\n this.value = String(this.value);\n return this;\n },\n object() {\n return this;\n },\n auto() {\n if (lodash_1.default.isObject(this.value)) {\n this.value = this.object().value;\n }\n else {\n this.value = this.string().number().boolean().value;\n }\n return this;\n }\n };\n try {\n return normalize[dataType]().value;\n }\n catch (err) {\n console.warn('Failed to normalize value', err);\n return value;\n }\n }\n /**\n * Normalize values coming into updateValue. For example, depending on the configuration, string value `\"true\"` will be normalized to boolean `true`.\n * @param {*} value - The value to normalize\n * @returns {*} - Returns the normalized value\n */\n normalizeValue(value) {\n if (this.component.multiple && Array.isArray(value)) {\n return value.map((singleValue) => this.normalizeSingleValue(singleValue));\n }\n return super.normalizeValue(this.normalizeSingleValue(value));\n }\n setMetadata(value, flags = {}) {\n var _a, _b;\n if (lodash_1.default.isNil(value)) {\n return;\n }\n const valueIsObject = lodash_1.default.isObject(value);\n //check if value equals to default emptyValue\n if (valueIsObject && Object.keys(value).length === 0) {\n return value;\n }\n // Check to see if we need to save off the template data into our metadata.\n const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;\n const shouldSaveData = !valueIsObject || this.component.reference;\n if (!lodash_1.default.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submission)) {\n const submission = this.root.submission;\n if (!submission.metadata) {\n submission.metadata = {};\n }\n if (!submission.metadata.selectData) {\n submission.metadata.selectData = {};\n }\n let templateData = this.templateData[templateValue];\n if (this.component.multiple) {\n templateData = {};\n const dataValue = this.dataValue;\n if (dataValue && lodash_1.default.isArray(dataValue) && dataValue.length) {\n dataValue.forEach((dataValueItem) => {\n const dataValueItemValue = this.component.reference ? dataValueItem._id.toString() : dataValueItem;\n templateData[dataValueItemValue] = this.templateData[dataValueItemValue];\n });\n }\n templateData[value] = this.templateData[value];\n }\n lodash_1.default.set(submission.metadata.selectData, this.path, templateData);\n }\n if (flags.resetValue && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission)) {\n const submission = this.root.submission;\n if (!submission.metadata) {\n submission.metadata = {};\n }\n submission.metadata.selectData = {};\n }\n }\n updateValue(value, flags) {\n const changed = super.updateValue(value, flags);\n if (changed || !this.selectMetadata || flags.resetValue) {\n if (this.component.multiple && Array.isArray(this.dataValue)) {\n this.dataValue.forEach(singleValue => this.setMetadata(singleValue, flags));\n }\n else {\n this.setMetadata(this.dataValue, flags);\n }\n }\n return changed;\n }\n undoValueTyping(value) {\n let untypedValue = value;\n if (this.component.multiple && Array.isArray(value)) {\n untypedValue = value.map(v => {\n if (typeof v === 'boolean' || typeof v === 'number') {\n return v.toString();\n }\n return v;\n });\n }\n else {\n if (typeof value === 'boolean' || typeof value === 'number') {\n untypedValue = value.toString();\n }\n }\n return untypedValue;\n }\n setValue(value, flags = {}) {\n const previousValue = this.dataValue;\n const changed = this.updateValue(value, flags);\n if (this.component.widget === 'html5' && (lodash_1.default.isEqual(value, previousValue) || lodash_1.default.isEqual(previousValue, {}) && lodash_1.default.isEqual(flags, {})) && !flags.fromSubmission) {\n return false;\n }\n value = this.dataValue;\n const hasPreviousValue = !this.isEmpty(previousValue);\n const hasValue = !this.isEmpty(value);\n // Undo typing when searching to set the value.\n value = this.undoValueTyping(value);\n if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {\n this.itemsLoaded.then(() => {\n this.redraw();\n });\n return changed;\n }\n // Do not set the value if we are loading... that will happen after it is done.\n if (this.loading) {\n return changed;\n }\n // Determine if we need to perform an initial lazyLoad api call if searchField is provided.\n if (this.isInitApiCallNeeded(hasValue)) {\n this.loading = true;\n this.lazyLoadInit = true;\n const searchProperty = this.component.searchField || this.component.valueProperty;\n this.triggerUpdate(lodash_1.default.get(value.data || value, searchProperty, value), true);\n return changed;\n }\n // Add the value options.\n this.itemsLoaded.then(() => {\n this.addValueOptions();\n this.setChoicesValue(value, hasPreviousValue, flags);\n });\n return changed;\n }\n isInitApiCallNeeded(hasValue) {\n return this.component.lazyLoad &&\n !this.lazyLoadInit &&\n !this.active &&\n !this.selectOptions.length &&\n hasValue &&\n this.shouldInitialLoad &&\n this.visible && (this.component.searchField || this.component.valueProperty);\n }\n setChoicesValue(value, hasPreviousValue, flags = {}) {\n const hasValue = !this.isEmpty(value) || flags.fromSubmission;\n hasPreviousValue = (hasPreviousValue === undefined) ? true : hasPreviousValue;\n if (this.choices) {\n // Now set the value.\n if (hasValue) {\n this.choices.removeActiveItems();\n // Add the currently selected choices if they don't already exist.\n const currentChoices = Array.isArray(value) && this.component.multiple ? value : [value];\n if (!this.addCurrentChoices(currentChoices, this.selectOptions, true)) {\n this.choices.setChoices(this.selectOptions, 'value', 'label', true);\n }\n this.choices.setChoiceByValue(currentChoices);\n }\n else if (hasPreviousValue || flags.resetValue) {\n this.choices.removeActiveItems();\n }\n }\n else {\n if (hasValue) {\n const values = Array.isArray(value) ? value : [value];\n if (!lodash_1.default.isEqual(this.dataValue, this.defaultValue) && this.selectOptions.length < 2\n || (this.selectData && flags.fromSubmission)) {\n const { value, label } = this.selectValueAndLabel(this.dataValue);\n this.addOption(value, label);\n }\n lodash_1.default.each(this.selectOptions, (selectOption) => {\n lodash_1.default.each(values, (val) => {\n if (selectOption.value === '') {\n selectOption.value = {};\n }\n if (lodash_1.default.isEqual(val, selectOption.value) && selectOption.element) {\n selectOption.element.selected = true;\n selectOption.element.setAttribute('selected', 'selected');\n return false;\n }\n });\n });\n }\n else {\n lodash_1.default.each(this.selectOptions, (selectOption) => {\n if (selectOption.element) {\n selectOption.element.selected = false;\n selectOption.element.removeAttribute('selected');\n }\n });\n }\n }\n }\n validateValueAvailability(setting, value) {\n if (!(0, utils_1.boolValue)(setting) || !value) {\n return true;\n }\n const values = this.getOptionsValues();\n if (values) {\n if (lodash_1.default.isObject(value)) {\n const compareComplexValues = (optionValue) => {\n const normalizedOptionValue = this.normalizeSingleValue(optionValue);\n if (!lodash_1.default.isObject(normalizedOptionValue)) {\n return false;\n }\n try {\n return (JSON.stringify(normalizedOptionValue) === JSON.stringify(value));\n }\n catch (err) {\n console.warn.error('Error while comparing items', err);\n return false;\n }\n };\n return values.findIndex((optionValue) => compareComplexValues(optionValue)) !== -1;\n }\n return values.findIndex((optionValue) => this.normalizeSingleValue(optionValue) === value) !== -1;\n }\n return false;\n }\n /**\n * Performs required transformations on the initial value to use in selectOptions\n * @param {*} value - The value to transform.\n * @returns {*} - Returns the options value.\n */\n getOptionValue(value) {\n return lodash_1.default.isObject(value) && this.isEntireObjectDisplay()\n ? this.normalizeSingleValue(value)\n : lodash_1.default.isObject(value) && (this.valueProperty || this.component.key !== 'resource')\n ? value\n : lodash_1.default.isObject(value) && !this.valueProperty\n ? this.interpolate(this.component.template, { item: value }).replace(/<\\/?[^>]+(>|$)/g, '')\n : lodash_1.default.isNull(value)\n ? this.emptyValue\n : String(this.normalizeSingleValue(value));\n }\n /**\n * If component has static values (values, json) or custom values, returns an array of them\n * @returns {Array<*>|undefined} - Returns an array of the static or custom values.\n */\n getOptionsValues() {\n let rawItems = [];\n switch (this.component.dataSrc) {\n case 'values':\n rawItems = this.component.data.values;\n break;\n case 'json':\n rawItems = this.component.data.json;\n break;\n case 'custom':\n rawItems = this.getCustomItems();\n break;\n case 'url':\n rawItems = this.selectItems;\n break;\n }\n if (typeof rawItems === 'string') {\n try {\n rawItems = JSON.parse(rawItems);\n }\n catch (err) {\n console.warn(err.message);\n rawItems = [];\n }\n }\n if (!Array.isArray(rawItems)) {\n return;\n }\n return rawItems.map((item) => this.getOptionValue(this.itemValue(item)));\n }\n /**\n * Deletes the value of the component.\n */\n deleteValue() {\n this.setValue('', {\n noUpdateEvent: true\n });\n this.unset();\n }\n /**\n * Check if a component is eligible for multiple validation\n * @returns {boolean} - Returns FALSE for select components.\n */\n validateMultiple() {\n // Select component will contain one input when flagged as multiple.\n return false;\n }\n /**\n * Output this select dropdown as a string value.\n * @returns {*}\n */\n isBooleanOrNumber(value) {\n return typeof value === 'number' || typeof value === 'boolean';\n }\n getNormalizedValues() {\n if (!this.component || !this.component.data || !this.component.data.values) {\n return;\n }\n return this.component.data.values.map(value => ({ label: value.label, value: String(this.normalizeSingleValue(value.value)) }));\n }\n asString(value, options = {}) {\n var _a;\n value = value !== null && value !== void 0 ? value : this.getValue();\n if (options.modalPreview || this.inDataTable) {\n if (this.inDataTable) {\n value = this.undoValueTyping(value);\n }\n const templateValue = (this.isEntireObjectDisplay() && !lodash_1.default.isObject(value.data)) ? { data: value } : value;\n const template = this.itemTemplate(templateValue, value, options);\n return template;\n }\n //need to convert values to strings to be able to compare values with available options that are strings\n const convertToString = (data, valueProperty) => {\n if (valueProperty) {\n if (Array.isArray(data)) {\n data.forEach((item) => item[valueProperty] = item[valueProperty].toString());\n }\n else if (lodash_1.default.isObject(data)) {\n data[valueProperty] = data[valueProperty].toString();\n }\n return data;\n }\n if (this.isBooleanOrNumber(data)) {\n data = data.toString();\n }\n if (Array.isArray(data) && data.some(item => this.isBooleanOrNumber(item))) {\n data = data.map(item => this.isBooleanOrNumber(item) ? item.toString() : item);\n }\n return data;\n };\n value = convertToString(value);\n if (['values', 'custom'].includes(this.component.dataSrc) && !this.asyncCustomValues()) {\n const { items, valueProperty, } = this.component.dataSrc === 'values'\n ? {\n items: convertToString(this.getNormalizedValues(), 'value'),\n valueProperty: 'value',\n }\n : {\n items: convertToString(this.getCustomItems(), this.valueProperty),\n valueProperty: this.valueProperty,\n };\n const getFromValues = () => {\n const initialValue = lodash_1.default.find(items, [valueProperty, value]);\n const values = this.defaultSchema.data.values || [];\n return lodash_1.default.isEqual(initialValue, values[0]) ? '-' : initialValue;\n };\n value = (this.component.multiple && Array.isArray(value))\n ? lodash_1.default.filter(items, (item) => value.includes(item.value))\n : (valueProperty && items)\n ? (_a = getFromValues()) !== null && _a !== void 0 ? _a : { value, label: value }\n : value;\n }\n if (lodash_1.default.isString(value)) {\n return value;\n }\n const getTemplateValue = (v) => {\n const itemTemplate = this.itemTemplate(v);\n return options.csv && itemTemplate\n ? (0, utils_1.removeHTML)(itemTemplate)\n : itemTemplate;\n };\n if (Array.isArray(value)) {\n const items = [];\n value.forEach(item => items.push(getTemplateValue(item)));\n if (this.component.dataSrc === 'resource' && items.length > 0) {\n return items.join(', ');\n }\n else if (items.length > 0) {\n return items.join('<br />');\n }\n else {\n return '-';\n }\n }\n if (this.isEntireObjectDisplay() && lodash_1.default.isObject(value)) {\n return JSON.stringify(value);\n }\n return !lodash_1.default.isNil(value)\n ? getTemplateValue(value)\n : '-';\n }\n detach() {\n var _a, _b;\n this.off('blur');\n if (this.choices) {\n if ((_b = (_a = this.choices.containerOuter) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.parentNode) {\n this.choices.destroy();\n }\n this.choices = null;\n }\n super.detach();\n }\n focus() {\n super.focus.call(this);\n if (this.focusableElement) {\n this.focusableElement.focus();\n }\n }\n setErrorClasses(elements, dirty, hasError, hasMessages, element = this.element) {\n super.setErrorClasses(elements, dirty, hasError, hasMessages, element);\n if (this.choices) {\n super.setErrorClasses([this.choices.containerInner.element], dirty, hasError, hasMessages, element);\n }\n else {\n super.setErrorClasses([this.refs.selectContainer], dirty, hasError, hasMessages, element);\n }\n }\n}\nexports[\"default\"] = SelectComponent;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/select/Select.js?");
|
5414
5425
|
|
5415
5426
|
/***/ }),
|
5416
5427
|
|
@@ -6893,7 +6904,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\ncons
|
|
6893
6904
|
/***/ (function(__unused_webpack_module, exports) {
|
6894
6905
|
|
6895
6906
|
"use strict";
|
6896
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports[\"default\"] = (iconset, name, spinning) => {\n let biName = name;\n switch (name) {\n case 'cog':\n biName = 'gear';\n break;\n case 'copy':\n biName = 'back';\n break;\n case 'bars':\n biName = 'list';\n break;\n case 'remove':\n biName = 'trash';\n break;\n case 'font':\n biName = 'type';\n break;\n case 'hashtag':\n biName = 'hash';\n break;\n case 'th-list':\n biName = 'menu-button-wide';\n break;\n case 'dot-circle-o':\n biName = 'ui-radios';\n break;\n case 'plus-square-o':\n biName = 'plus-square';\n break;\n case 'minus-square-o':\n biName = 'dash-square';\n break;\n case 'plus-square':\n biName = 'ui-checks';\n break;\n case 'phone-square':\n biName = 'phone';\n break;\n case 'home':\n biName = 'house';\n break;\n case 'clock-o':\n biName = 'clock';\n break;\n case 'usd':\n biName = 'currency-dollar';\n break;\n case 'html5':\n biName = 'file-richtext';\n break;\n case 'pencil-square-o':\n biName = 'pencil-square';\n break;\n case 'columns':\n biName = 'layout-three-columns';\n break;\n case 'list-alt':\n biName = 'window';\n break;\n case 'th-large':\n biName = 'grid-fill';\n break;\n case 'folder-o':\n biName = 'folder';\n break;\n case 'square-o':\n biName = 'square';\n break;\n case 'user-secret':\n biName = 'person-fill-slash';\n break;\n case 'folder-open':\n biName = 'folder2-open';\n break;\n case 'th':\n biName = 'grid-3x3-gap-fill';\n break;\n case 'tasks':\n biName = 'view-stacked';\n break;\n case 'indent':\n biName = 'text-indent-left';\n break;\n case 'refresh':\n biName = 'arrow-repeat';\n break;\n case 'files-o':\n biName = 'files';\n break;\n case 'wpforms':\n biName = 'window-stack';\n break;\n case 'cube':\n biName = 'box';\n break;\n case 'cubes':\n biName = 'boxes';\n break;\n case 'check-square-o':\n biName = 'check-square';\n break;\n case 'plus':\n biName = 'plus-lg';\n break;\n case 'question-sign':\n name = 'question-circle';\n biName = 'question-circle';\n break;\n case 'remove-circle':\n biName = 'x-circle';\n break;\n case 'new-window':\n name = 'window-restore';\n biName = 'window-plus';\n break;\n case 'move':\n name = 'arrows';\n biName = 'arrows-move';\n break;\n case 'edit':\n biName = 'pencil';\n break;\n case 'time':\n biName = 'clock';\n break;\n case 'video':\n biName = 'camera-video';\n break;\n case 'microphone':\n biName = 'mic';\n break;\n case 'folder-open':\n biName = 'folder2-open';\n break;\n case 'check-circle':\n biName = 'check-circle-fill';\n break;\n case 'times-circle':\n biName = 'x-circle-fill';\n break;\n }\n return spinning ? 'spinner-border spinner-border-sm' : `fa fa-${name} bi bi-${biName}`;\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/bootstrap/lib/cjs/templates/bootstrap5/iconClass.js?");
|
6907
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports[\"default\"] = (iconset, name, spinning) => {\n let biName = name;\n switch (name) {\n case 'cog':\n biName = 'gear';\n break;\n case 'copy':\n biName = 'back';\n break;\n case 'bars':\n biName = 'list';\n break;\n case 'remove':\n biName = 'trash';\n break;\n case 'font':\n biName = 'type';\n break;\n case 'hashtag':\n biName = 'hash';\n break;\n case 'th-list':\n biName = 'menu-button-wide';\n break;\n case 'dot-circle-o':\n biName = 'ui-radios';\n break;\n case 'plus-square-o':\n biName = 'plus-square';\n break;\n case 'minus-square-o':\n biName = 'dash-square';\n break;\n case 'plus-square':\n biName = 'ui-checks';\n break;\n case 'phone-square':\n biName = 'phone';\n break;\n case 'home':\n biName = 'house';\n break;\n case 'clock-o':\n biName = 'clock';\n break;\n case 'usd':\n biName = 'currency-dollar';\n break;\n case 'html5':\n biName = 'file-richtext';\n break;\n case 'pencil-square-o':\n biName = 'pencil-square';\n break;\n case 'columns':\n biName = 'layout-three-columns';\n break;\n case 'list-alt':\n biName = 'window';\n break;\n case 'th-large':\n biName = 'grid-fill';\n break;\n case 'folder-o':\n biName = 'folder';\n break;\n case 'square-o':\n biName = 'square';\n break;\n case 'user-secret':\n biName = 'person-fill-slash';\n break;\n case 'folder-open':\n biName = 'folder2-open';\n break;\n case 'th':\n biName = 'grid-3x3-gap-fill';\n break;\n case 'tasks':\n biName = 'view-stacked';\n break;\n case 'indent':\n biName = 'text-indent-left';\n break;\n case 'refresh':\n biName = 'arrow-repeat';\n break;\n case 'files-o':\n biName = 'files';\n break;\n case 'wpforms':\n biName = 'window-stack';\n break;\n case 'cube':\n biName = 'box';\n break;\n case 'cubes':\n biName = 'boxes';\n break;\n case 'check-square-o':\n biName = 'check-square';\n break;\n case 'plus':\n biName = 'plus-lg';\n break;\n case 'question-sign':\n name = 'question-circle';\n biName = 'question-circle';\n break;\n case 'remove-circle':\n biName = 'x-circle';\n break;\n case 'new-window':\n name = 'window-restore';\n biName = 'window-plus';\n break;\n case 'move':\n name = 'arrows';\n biName = 'arrows-move';\n break;\n case 'edit':\n biName = 'pencil';\n break;\n case 'time':\n biName = 'clock';\n break;\n case 'video':\n biName = 'camera-video';\n break;\n case 'microphone':\n biName = 'mic';\n break;\n case 'folder-open':\n biName = 'folder2-open';\n break;\n case 'check-circle':\n biName = 'check-circle-fill';\n break;\n case 'times-circle':\n biName = 'x-circle-fill';\n break;\n case 'pencil':\n biName = 'pencil-fill';\n break;\n case 'minus':\n biName = 'dash';\n break;\n case 'circle':\n biName = 'circle-fill';\n break;\n case 'search-plus':\n biName = 'zoom-in';\n break;\n case 'search-minus':\n biName = 'zoom-out';\n break;\n case 'hand-paper-o':\n biName = 'hand-index';\n break;\n case 'undo':\n biName = 'arrow-counterclockwise';\n break;\n case 'repeat':\n biName = 'arrow-clockwise';\n break;\n }\n return spinning ? 'spinner-border spinner-border-sm' : `fa fa-${name} bi bi-${biName}`;\n};\n\n\n//# sourceURL=webpack://Formio/./node_modules/@formio/bootstrap/lib/cjs/templates/bootstrap5/iconClass.js?");
|
6897
6908
|
|
6898
6909
|
/***/ }),
|
6899
6910
|
|
@@ -8904,7 +8915,7 @@ eval("\nvar parent = __webpack_require__(/*! ../../es/object/from-entries */ \".
|
|
8904
8915
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
8905
8916
|
|
8906
8917
|
"use strict";
|
8907
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a;\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.FormBuilder = exports.Form = exports.Formio = void 0;\nconst CDN_js_1 = __importDefault(__webpack_require__(/*! ./CDN.js */ \"./lib/cjs/CDN.js\"));\nclass Formio {\n static setLicense(license, norecurse = false) {\n _a.license = license;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setLicense(license);\n }\n }\n static setBaseUrl(url, norecurse = false) {\n _a.baseUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setBaseUrl(url);\n }\n }\n static setApiUrl(url, norecurse = false) {\n _a.baseUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setApiUrl(url);\n }\n }\n static setProjectUrl(url, norecurse = false) {\n _a.projectUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setProjectUrl(url);\n }\n }\n static setAppUrl(url, norecurse = false) {\n _a.projectUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setAppUrl(url);\n }\n }\n static setPathType(type, norecurse = false) {\n _a.pathType = type;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setPathType(type);\n }\n }\n static debug(...args) {\n if (_a.config.debug) {\n console.log(...args);\n }\n }\n static clearCache() {\n if (_a.FormioClass) {\n _a.FormioClass.clearCache();\n }\n }\n static global(prop, flag = '') {\n const globalValue = window[prop];\n if (flag && globalValue && !globalValue[flag]) {\n return null;\n }\n _a.debug(`Getting global ${prop}`, globalValue);\n return globalValue;\n }\n static use(module) {\n if (_a.FormioClass && _a.FormioClass.isRenderer) {\n _a.FormioClass.use(module);\n }\n else {\n _a.modules.push(module);\n }\n }\n static createElement(type, attrs, children) {\n const element = document.createElement(type);\n if (!attrs) {\n return element;\n }\n Object.keys(attrs).forEach(key => {\n element.setAttribute(key, attrs[key]);\n });\n (children || []).forEach(child => {\n element.appendChild(_a.createElement(child.tag, child.attrs, child.children));\n });\n return element;\n }\n static addScript(wrapper, src, name, flag = '') {\n return __awaiter(this, void 0, void 0, function* () {\n if (!src) {\n return Promise.resolve();\n }\n if (typeof src !== 'string' && src.length) {\n return Promise.all(src.map(ref => _a.addScript(wrapper, ref)));\n }\n if (name && _a.global(name, flag)) {\n _a.debug(`${name} already loaded.`);\n return Promise.resolve(_a.global(name));\n }\n _a.debug('Adding Script', src);\n try {\n wrapper.appendChild(_a.createElement('script', {\n src\n }));\n }\n catch (err) {\n _a.debug(err);\n return Promise.resolve();\n }\n if (!name) {\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n _a.debug(`Waiting to load ${name}`);\n const wait = setInterval(() => {\n if (_a.global(name, flag)) {\n clearInterval(wait);\n _a.debug(`${name} loaded.`);\n resolve(_a.global(name));\n }\n }, 100);\n });\n });\n }\n static addStyles(wrapper, href) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!href) {\n return;\n }\n if (typeof href !== 'string' && href.length) {\n href.forEach(ref => _a.addStyles(wrapper, ref));\n return;\n }\n _a.debug('Adding Styles', href);\n wrapper.appendChild(_a.createElement('link', {\n rel: 'stylesheet',\n href\n }));\n });\n }\n static submitDone(instance, submission) {\n return __awaiter(this, void 0, void 0, function* () {\n _a.debug('Submision Complete', submission);\n if (_a.config.submitDone) {\n _a.config.submitDone(submission, instance);\n }\n const successMessage = (_a.config.success || '').toString();\n if (successMessage && successMessage.toLowerCase() !== 'false' && instance.element) {\n instance.element.innerHTML = `<div class=\"alert-success\" role=\"alert\">${successMessage}</div>`;\n }\n let returnUrl = _a.config.redirect;\n // Allow form based configuration for return url.\n if (!returnUrl &&\n (instance._form &&\n instance._form.settings &&\n (instance._form.settings.returnUrl ||\n instance._form.settings.redirect))) {\n _a.debug('Return url found in form configuration');\n returnUrl = instance._form.settings.returnUrl || instance._form.settings.redirect;\n }\n if (returnUrl) {\n const formSrc = instance.formio ? instance.formio.formUrl : '';\n const hasQuery = !!returnUrl.match(/\\?/);\n const isOrigin = returnUrl.indexOf(location.origin) === 0;\n returnUrl += hasQuery ? '&' : '?';\n returnUrl += `sub=${submission._id}`;\n if (!isOrigin && formSrc) {\n returnUrl += `&form=${encodeURIComponent(formSrc)}`;\n }\n _a.debug('Return URL', returnUrl);\n window.location.href = returnUrl;\n if (isOrigin) {\n window.location.reload();\n }\n }\n });\n }\n // Return the full script if the builder is being used.\n static formioScript(script, builder) {\n builder = builder || _a.config.includeBuilder;\n if (_a.fullAdded || builder) {\n _a.fullAdded = true;\n return script.replace('formio.form', 'formio.full');\n }\n return script;\n }\n static addLibrary(libWrapper, lib, name) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!lib) {\n return;\n }\n if (lib.dependencies) {\n for (let i = 0; i < lib.dependencies.length; i++) {\n const libName = lib.dependencies[i];\n yield _a.addLibrary(libWrapper, _a.config.libs[libName], libName);\n }\n }\n if (lib.css) {\n yield _a.addStyles((lib.global ? document.body : libWrapper), lib.css);\n }\n if (lib.js) {\n const module = yield _a.addScript((lib.global ? document.body : libWrapper), lib.js, lib.use ? name : false);\n if (lib.use) {\n _a.debug(`Using ${name}`);\n const options = lib.options || {};\n if (!options.license && _a.license) {\n options.license = _a.license;\n }\n _a.use((typeof lib.use === 'function' ? lib.use(module) : module), options);\n }\n }\n if (lib.globalStyle) {\n const style = _a.createElement('style');\n style.type = 'text/css';\n style.innerHTML = lib.globalStyle;\n document.body.appendChild(style);\n }\n });\n }\n static addLoader(wrapper) {\n return __awaiter(this, void 0, void 0, function* () {\n wrapper.appendChild(_a.createElement('div', {\n 'class': 'formio-loader'\n }, [{\n tag: 'div',\n attrs: {\n class: 'loader-wrapper'\n },\n children: [{\n tag: 'div',\n attrs: {\n class: 'loader text-center'\n }\n }]\n }]));\n });\n }\n // eslint-disable-next-line max-statements\n static init(element, options = {}, builder = false) {\n return __awaiter(this, void 0, void 0, function* () {\n _a.cdn = new CDN_js_1.default(_a.config.cdn, _a.config.cdnUrls || {});\n _a.config.libs = _a.config.libs || {\n uswds: {\n dependencies: ['fontawesome'],\n js: `${_a.cdn.uswds}/uswds.min.js`,\n css: `${_a.cdn.uswds}/uswds.min.css`,\n use: true\n },\n fontawesome: {\n // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need\n // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.\n css: `https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css`,\n globalStyle: `@font-face {\n font-family: 'FontAwesome';\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');\n font-weight: normal;\n font-style: normal;\n }`\n },\n bootstrap4: {\n dependencies: ['fontawesome'],\n css: `${_a.cdn.bootstrap4}/css/bootstrap.min.css`\n },\n bootstrap: {\n dependencies: ['bootstrap-icons'],\n css: `${_a.cdn.bootstrap}/css/bootstrap.min.css`\n },\n 'bootstrap-icons': {\n // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need\n // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.\n css: 'https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css',\n globalStyle: `@font-face {\n font-display: block;\n font-family: \"bootstrap-icons\";\n src: url(\"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6\") format(\"woff2\"),\n url(\"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6\") format(\"woff\");\n }`\n }\n };\n // Add all bootswatch templates.\n ['cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'litera', 'lumen', 'lux', 'materia', 'minty', 'pulse', 'sandstone', 'simplex', 'sketchy', 'slate', 'solar', 'spacelab', 'superhero', 'united', 'yeti'].forEach((template) => {\n _a.config.libs[template] = {\n dependencies: ['bootstrap-icons'],\n css: `${_a.cdn.bootswatch}/dist/${template}/bootstrap.min.css`\n };\n });\n const id = _a.config.id || `formio-${Math.random().toString(36).substring(7)}`;\n // Create a new wrapper and add the element inside of a new wrapper.\n let wrapper = _a.createElement('div', {\n 'id': `${id}-wrapper`\n });\n element.parentNode.insertBefore(wrapper, element);\n // If we include the libraries, then we will attempt to run this in shadow dom.\n const useShadowDom = _a.config.includeLibs && !_a.config.noshadow && (typeof wrapper.attachShadow === 'function');\n if (useShadowDom) {\n wrapper = wrapper.attachShadow({\n mode: 'open'\n });\n options.shadowRoot = wrapper;\n }\n element.parentNode.removeChild(element);\n wrapper.appendChild(element);\n // If this is inside of shadow dom, then we need to add the styles and scripts to the shadow dom.\n const libWrapper = useShadowDom ? wrapper : document.body;\n // Load the renderer styles.\n yield _a.addStyles(libWrapper, _a.config.embedCSS || `${_a.cdn.js}/formio.embed.css`);\n // Add a loader.\n _a.addLoader(wrapper);\n const formioSrc = _a.config.full ? 'formio.full' : 'formio.form';\n const renderer = _a.config.debug ? formioSrc : `${formioSrc}.min`;\n _a.FormioClass = yield _a.addScript(libWrapper, _a.formioScript(_a.config.script || `${_a.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');\n _a.FormioClass.cdn = _a.cdn;\n _a.FormioClass.setBaseUrl(options.baseUrl || _a.baseUrl || _a.config.base);\n _a.FormioClass.setProjectUrl(options.projectUrl || _a.projectUrl || _a.config.project);\n _a.FormioClass.language = _a.language;\n _a.setLicense(_a.license || _a.config.license || false);\n _a.modules.forEach((module) => {\n _a.FormioClass.use(module);\n });\n if (_a.icons) {\n _a.FormioClass.icons = _a.icons;\n }\n if (_a.pathType) {\n _a.FormioClass.setPathType(_a.pathType);\n }\n // Add libraries if they wish to include the libs.\n if (_a.config.template && _a.config.includeLibs) {\n yield _a.addLibrary(libWrapper, _a.config.libs[_a.config.template], _a.config.template);\n }\n if (!_a.config.libraries) {\n _a.config.libraries = _a.config.modules || {};\n }\n // Adding premium if it is provided via the config.\n if (_a.config.premium) {\n _a.config.libraries.premium = _a.config.premium;\n }\n // Allow adding dynamic modules.\n if (_a.config.libraries) {\n for (const name in _a.config.libraries) {\n const lib = _a.config.libraries[name];\n lib.use = lib.use || true;\n yield _a.addLibrary(libWrapper, lib, name);\n }\n }\n yield _a.addStyles(libWrapper, _a.formioScript(_a.config.style || `${_a.cdn.js}/${renderer}.css`, builder));\n if (_a.config.before) {\n yield _a.config.before(_a.FormioClass, element, _a.config);\n }\n _a.FormioClass.license = true;\n _a._formioReady(_a.FormioClass);\n return wrapper;\n });\n }\n // Called after an instance has been created.\n static afterCreate(instance, wrapper, readyEvent) {\n return __awaiter(this, void 0, void 0, function* () {\n const loader = wrapper.querySelector('.formio-loader');\n if (loader) {\n wrapper.removeChild(loader);\n }\n _a.FormioClass.events.emit(readyEvent, instance);\n if (_a.config.after) {\n _a.debug('Calling ready callback');\n _a.config.after(instance, _a.config);\n }\n return instance;\n });\n }\n // Create a new form.\n static createForm(element, form, options = {}) {\n return __awaiter(this, void 0, void 0, function* () {\n if (_a.FormioClass) {\n return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true }));\n }\n const wrapper = yield _a.init(element, options);\n return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true })).then((instance) => {\n // Set the default submission data.\n if (_a.config.submission) {\n _a.debug('Setting submission', _a.config.submission);\n instance.submission = _a.config.submission;\n }\n // Call the after create method.\n _a.afterCreate(instance, wrapper, 'formEmbedded');\n return instance;\n });\n });\n }\n // Create a form builder.\n static builder(element, form, options = {}) {\n var _b;\n return __awaiter(this, void 0, void 0, function* () {\n if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.builder) {\n return _a.FormioClass.builder(element, form, options);\n }\n const wrapper = yield _a.init(element, options, true);\n return _a.FormioClass.builder(element, form, options).then((instance) => {\n _a.afterCreate(instance, wrapper, 'builderEmbedded');\n return instance;\n });\n });\n }\n}\nexports.Formio = Formio;\n_a = Formio;\nFormio.FormioClass = null;\nFormio.config = {};\nFormio.modules = [];\nFormio.icons = '';\nFormio.license = '';\nFormio.formioReady = new Promise((ready, reject) => {\n _a._formioReady = ready;\n _a._formioReadyReject = reject;\n});\nFormio.version = '5.0.0-rc.93';\n// Create a report.\nFormio.Report = {\n create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {\n var _b;\n if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.Report) {\n return _a.FormioClass.Report.create(element, submission, options);\n }\n const wrapper = yield _a.init(element, options, true);\n return _a.FormioClass.Report.create(element, submission, options).then((instance) => {\n _a.afterCreate(instance, wrapper, 'reportEmbedded');\n return instance;\n });\n })\n};\nCDN_js_1.default.defaultCDN = Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';\nclass Form {\n constructor(element, form, options) {\n this.form = form;\n this.element = element;\n this.options = options || {};\n this.init();\n this.instance = {\n proxy: true,\n ready: this.ready,\n destroy: () => { }\n };\n }\n init() {\n if (this.instance && !this.instance.proxy) {\n this.instance.destroy();\n }\n this.element.innerHTML = '';\n this.ready = this.create().then((instance) => {\n this.instance = instance;\n this.form = instance.form;\n return instance;\n });\n }\n create() {\n return Formio.createForm(this.element, this.form, this.options);\n }\n setForm(form) {\n this.form = form;\n if (this.instance) {\n this.instance.setForm(form);\n }\n }\n setDisplay(display) {\n if (this.instance.proxy) {\n return this.ready;\n }\n this.form.display = display;\n this.instance.destroy();\n this.ready = this.create().then((instance) => {\n this.instance = instance;\n this.setForm(this.form);\n });\n return this.ready;\n }\n}\nexports.Form = Form;\nclass FormBuilder extends Form {\n create() {\n return Formio.builder(this.element, this.form, this.options);\n }\n}\nexports.FormBuilder = FormBuilder;\nFormio.Form = Form;\nFormio.FormBuilder = FormBuilder;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/Embed.js?");
|
8918
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a;\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.FormBuilder = exports.Form = exports.Formio = void 0;\nconst CDN_js_1 = __importDefault(__webpack_require__(/*! ./CDN.js */ \"./lib/cjs/CDN.js\"));\nclass Formio {\n static setLicense(license, norecurse = false) {\n _a.license = license;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setLicense(license);\n }\n }\n static setBaseUrl(url, norecurse = false) {\n _a.baseUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setBaseUrl(url);\n }\n }\n static setApiUrl(url, norecurse = false) {\n _a.baseUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setApiUrl(url);\n }\n }\n static setProjectUrl(url, norecurse = false) {\n _a.projectUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setProjectUrl(url);\n }\n }\n static setAppUrl(url, norecurse = false) {\n _a.projectUrl = url;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setAppUrl(url);\n }\n }\n static setPathType(type, norecurse = false) {\n _a.pathType = type;\n if (!norecurse && _a.FormioClass) {\n _a.FormioClass.setPathType(type);\n }\n }\n static debug(...args) {\n if (_a.config.debug) {\n console.log(...args);\n }\n }\n static clearCache() {\n if (_a.FormioClass) {\n _a.FormioClass.clearCache();\n }\n }\n static global(prop, flag = '') {\n const globalValue = window[prop];\n if (flag && globalValue && !globalValue[flag]) {\n return null;\n }\n _a.debug(`Getting global ${prop}`, globalValue);\n return globalValue;\n }\n static use(module) {\n if (_a.FormioClass && _a.FormioClass.isRenderer) {\n _a.FormioClass.use(module);\n }\n else {\n _a.modules.push(module);\n }\n }\n static createElement(type, attrs, children) {\n const element = document.createElement(type);\n if (!attrs) {\n return element;\n }\n Object.keys(attrs).forEach(key => {\n element.setAttribute(key, attrs[key]);\n });\n (children || []).forEach(child => {\n element.appendChild(_a.createElement(child.tag, child.attrs, child.children));\n });\n return element;\n }\n static addScript(wrapper, src, name, flag = '') {\n return __awaiter(this, void 0, void 0, function* () {\n if (!src) {\n return Promise.resolve();\n }\n if (typeof src !== 'string' && src.length) {\n return Promise.all(src.map(ref => _a.addScript(wrapper, ref)));\n }\n if (name && _a.global(name, flag)) {\n _a.debug(`${name} already loaded.`);\n return Promise.resolve(_a.global(name));\n }\n _a.debug('Adding Script', src);\n try {\n wrapper.appendChild(_a.createElement('script', {\n src\n }));\n }\n catch (err) {\n _a.debug(err);\n return Promise.resolve();\n }\n if (!name) {\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n _a.debug(`Waiting to load ${name}`);\n const wait = setInterval(() => {\n if (_a.global(name, flag)) {\n clearInterval(wait);\n _a.debug(`${name} loaded.`);\n resolve(_a.global(name));\n }\n }, 100);\n });\n });\n }\n static addStyles(wrapper, href) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!href) {\n return;\n }\n if (typeof href !== 'string' && href.length) {\n href.forEach(ref => _a.addStyles(wrapper, ref));\n return;\n }\n _a.debug('Adding Styles', href);\n wrapper.appendChild(_a.createElement('link', {\n rel: 'stylesheet',\n href\n }));\n });\n }\n static submitDone(instance, submission) {\n return __awaiter(this, void 0, void 0, function* () {\n _a.debug('Submision Complete', submission);\n if (_a.config.submitDone) {\n _a.config.submitDone(submission, instance);\n }\n const successMessage = (_a.config.success || '').toString();\n if (successMessage && successMessage.toLowerCase() !== 'false' && instance.element) {\n instance.element.innerHTML = `<div class=\"alert-success\" role=\"alert\">${successMessage}</div>`;\n }\n let returnUrl = _a.config.redirect;\n // Allow form based configuration for return url.\n if (!returnUrl &&\n (instance._form &&\n instance._form.settings &&\n (instance._form.settings.returnUrl ||\n instance._form.settings.redirect))) {\n _a.debug('Return url found in form configuration');\n returnUrl = instance._form.settings.returnUrl || instance._form.settings.redirect;\n }\n if (returnUrl) {\n const formSrc = instance.formio ? instance.formio.formUrl : '';\n const hasQuery = !!returnUrl.match(/\\?/);\n const isOrigin = returnUrl.indexOf(location.origin) === 0;\n returnUrl += hasQuery ? '&' : '?';\n returnUrl += `sub=${submission._id}`;\n if (!isOrigin && formSrc) {\n returnUrl += `&form=${encodeURIComponent(formSrc)}`;\n }\n _a.debug('Return URL', returnUrl);\n window.location.href = returnUrl;\n if (isOrigin) {\n window.location.reload();\n }\n }\n });\n }\n // Return the full script if the builder is being used.\n static formioScript(script, builder) {\n builder = builder || _a.config.includeBuilder;\n if (_a.fullAdded || builder) {\n _a.fullAdded = true;\n return script.replace('formio.form', 'formio.full');\n }\n return script;\n }\n static addLibrary(libWrapper, lib, name) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!lib) {\n return;\n }\n if (lib.dependencies) {\n for (let i = 0; i < lib.dependencies.length; i++) {\n const libName = lib.dependencies[i];\n yield _a.addLibrary(libWrapper, _a.config.libs[libName], libName);\n }\n }\n if (lib.css) {\n yield _a.addStyles((lib.global ? document.body : libWrapper), lib.css);\n }\n if (lib.js) {\n const module = yield _a.addScript((lib.global ? document.body : libWrapper), lib.js, lib.use ? name : false);\n if (lib.use) {\n _a.debug(`Using ${name}`);\n const options = lib.options || {};\n if (!options.license && _a.license) {\n options.license = _a.license;\n }\n _a.use((typeof lib.use === 'function' ? lib.use(module) : module), options);\n }\n }\n if (lib.globalStyle) {\n const style = _a.createElement('style');\n style.type = 'text/css';\n style.innerHTML = lib.globalStyle;\n document.body.appendChild(style);\n }\n });\n }\n static addLoader(wrapper) {\n return __awaiter(this, void 0, void 0, function* () {\n wrapper.appendChild(_a.createElement('div', {\n 'class': 'formio-loader'\n }, [{\n tag: 'div',\n attrs: {\n class: 'loader-wrapper'\n },\n children: [{\n tag: 'div',\n attrs: {\n class: 'loader text-center'\n }\n }]\n }]));\n });\n }\n // eslint-disable-next-line max-statements\n static init(element, options = {}, builder = false) {\n return __awaiter(this, void 0, void 0, function* () {\n _a.cdn = new CDN_js_1.default(_a.config.cdn, _a.config.cdnUrls || {});\n _a.config.libs = _a.config.libs || {\n uswds: {\n dependencies: ['fontawesome'],\n js: `${_a.cdn.uswds}/uswds.min.js`,\n css: `${_a.cdn.uswds}/uswds.min.css`,\n use: true\n },\n fontawesome: {\n // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need\n // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.\n css: `https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css`,\n globalStyle: `@font-face {\n font-family: 'FontAwesome';\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0');\n src: url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');\n font-weight: normal;\n font-style: normal;\n }`\n },\n bootstrap4: {\n dependencies: ['fontawesome'],\n css: `${_a.cdn.bootstrap4}/css/bootstrap.min.css`\n },\n bootstrap: {\n dependencies: ['bootstrap-icons'],\n css: `${_a.cdn.bootstrap}/css/bootstrap.min.css`\n },\n 'bootstrap-icons': {\n // Due to an issue with font-face not loading in the shadowdom (https://issues.chromium.org/issues/41085401), we need\n // to do 2 things. 1.) Load the fonts from the global cdn, and 2.) add the font-face to the global styles on the page.\n css: 'https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.min.css',\n globalStyle: `@font-face {\n font-display: block;\n font-family: \"bootstrap-icons\";\n src: url(\"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6\") format(\"woff2\"),\n url(\"https://cdn.jsdelivr.net/npm/bootstrap-icons/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6\") format(\"woff\");\n }`\n }\n };\n // Add all bootswatch templates.\n ['cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'litera', 'lumen', 'lux', 'materia', 'minty', 'pulse', 'sandstone', 'simplex', 'sketchy', 'slate', 'solar', 'spacelab', 'superhero', 'united', 'yeti'].forEach((template) => {\n _a.config.libs[template] = {\n dependencies: ['bootstrap-icons'],\n css: `${_a.cdn.bootswatch}/dist/${template}/bootstrap.min.css`\n };\n });\n const id = _a.config.id || `formio-${Math.random().toString(36).substring(7)}`;\n // Create a new wrapper and add the element inside of a new wrapper.\n let wrapper = _a.createElement('div', {\n 'id': `${id}-wrapper`\n });\n element.parentNode.insertBefore(wrapper, element);\n // If we include the libraries, then we will attempt to run this in shadow dom.\n const useShadowDom = _a.config.includeLibs && !_a.config.noshadow && (typeof wrapper.attachShadow === 'function');\n if (useShadowDom) {\n wrapper = wrapper.attachShadow({\n mode: 'open'\n });\n options.shadowRoot = wrapper;\n }\n element.parentNode.removeChild(element);\n wrapper.appendChild(element);\n // If this is inside of shadow dom, then we need to add the styles and scripts to the shadow dom.\n const libWrapper = useShadowDom ? wrapper : document.body;\n // Load the renderer styles.\n yield _a.addStyles(libWrapper, _a.config.embedCSS || `${_a.cdn.js}/formio.embed.css`);\n // Add a loader.\n _a.addLoader(wrapper);\n const formioSrc = _a.config.full ? 'formio.full' : 'formio.form';\n const renderer = _a.config.debug ? formioSrc : `${formioSrc}.min`;\n _a.FormioClass = yield _a.addScript(libWrapper, _a.formioScript(_a.config.script || `${_a.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');\n _a.FormioClass.cdn = _a.cdn;\n _a.FormioClass.setBaseUrl(options.baseUrl || _a.baseUrl || _a.config.base);\n _a.FormioClass.setProjectUrl(options.projectUrl || _a.projectUrl || _a.config.project);\n _a.FormioClass.language = _a.language;\n _a.setLicense(_a.license || _a.config.license || false);\n _a.modules.forEach((module) => {\n _a.FormioClass.use(module);\n });\n if (_a.icons) {\n _a.FormioClass.icons = _a.icons;\n }\n if (_a.pathType) {\n _a.FormioClass.setPathType(_a.pathType);\n }\n // Add libraries if they wish to include the libs.\n if (_a.config.template && _a.config.includeLibs) {\n yield _a.addLibrary(libWrapper, _a.config.libs[_a.config.template], _a.config.template);\n }\n if (!_a.config.libraries) {\n _a.config.libraries = _a.config.modules || {};\n }\n // Adding premium if it is provided via the config.\n if (_a.config.premium) {\n _a.config.libraries.premium = _a.config.premium;\n }\n // Allow adding dynamic modules.\n if (_a.config.libraries) {\n for (const name in _a.config.libraries) {\n const lib = _a.config.libraries[name];\n lib.use = lib.use || true;\n yield _a.addLibrary(libWrapper, lib, name);\n }\n }\n yield _a.addStyles(libWrapper, _a.formioScript(_a.config.style || `${_a.cdn.js}/${renderer}.css`, builder));\n if (_a.config.before) {\n yield _a.config.before(_a.FormioClass, element, _a.config);\n }\n _a.FormioClass.license = true;\n _a._formioReady(_a.FormioClass);\n return wrapper;\n });\n }\n // Called after an instance has been created.\n static afterCreate(instance, wrapper, readyEvent) {\n return __awaiter(this, void 0, void 0, function* () {\n const loader = wrapper.querySelector('.formio-loader');\n if (loader) {\n wrapper.removeChild(loader);\n }\n _a.FormioClass.events.emit(readyEvent, instance);\n if (_a.config.after) {\n _a.debug('Calling ready callback');\n _a.config.after(instance, _a.config);\n }\n return instance;\n });\n }\n // Create a new form.\n static createForm(element, form, options = {}) {\n return __awaiter(this, void 0, void 0, function* () {\n if (_a.FormioClass) {\n return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true }));\n }\n const wrapper = yield _a.init(element, options);\n return _a.FormioClass.createForm(element, form, Object.assign(Object.assign({}, options), { noLoader: true })).then((instance) => {\n // Set the default submission data.\n if (_a.config.submission) {\n _a.debug('Setting submission', _a.config.submission);\n instance.submission = _a.config.submission;\n }\n // Call the after create method.\n _a.afterCreate(instance, wrapper, 'formEmbedded');\n return instance;\n });\n });\n }\n // Create a form builder.\n static builder(element, form, options = {}) {\n var _b;\n return __awaiter(this, void 0, void 0, function* () {\n if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.builder) {\n return _a.FormioClass.builder(element, form, options);\n }\n const wrapper = yield _a.init(element, options, true);\n return _a.FormioClass.builder(element, form, options).then((instance) => {\n _a.afterCreate(instance, wrapper, 'builderEmbedded');\n return instance;\n });\n });\n }\n}\nexports.Formio = Formio;\n_a = Formio;\nFormio.FormioClass = null;\nFormio.config = {};\nFormio.modules = [];\nFormio.icons = '';\nFormio.license = '';\nFormio.formioReady = new Promise((ready, reject) => {\n _a._formioReady = ready;\n _a._formioReadyReject = reject;\n});\nFormio.version = '5.0.0-rc.95';\n// Create a report.\nFormio.Report = {\n create: (element, submission, options = {}) => __awaiter(void 0, void 0, void 0, function* () {\n var _b;\n if ((_b = _a.FormioClass) === null || _b === void 0 ? void 0 : _b.Report) {\n return _a.FormioClass.Report.create(element, submission, options);\n }\n const wrapper = yield _a.init(element, options, true);\n return _a.FormioClass.Report.create(element, submission, options).then((instance) => {\n _a.afterCreate(instance, wrapper, 'reportEmbedded');\n return instance;\n });\n })\n};\nCDN_js_1.default.defaultCDN = Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';\nclass Form {\n constructor(element, form, options) {\n this.form = form;\n this.element = element;\n this.options = options || {};\n this.init();\n this.instance = {\n proxy: true,\n ready: this.ready,\n destroy: () => { }\n };\n }\n init() {\n if (this.instance && !this.instance.proxy) {\n this.instance.destroy();\n }\n this.element.innerHTML = '';\n this.ready = this.create().then((instance) => {\n this.instance = instance;\n this.form = instance.form;\n return instance;\n });\n }\n create() {\n return Formio.createForm(this.element, this.form, this.options);\n }\n setForm(form) {\n this.form = form;\n if (this.instance) {\n this.instance.setForm(form);\n }\n }\n setDisplay(display) {\n if (this.instance.proxy) {\n return this.ready;\n }\n this.form.display = display;\n this.instance.destroy();\n this.ready = this.create().then((instance) => {\n this.instance = instance;\n this.setForm(this.form);\n });\n return this.ready;\n }\n}\nexports.Form = Form;\nclass FormBuilder extends Form {\n create() {\n return Formio.builder(this.element, this.form, this.options);\n }\n}\nexports.FormBuilder = FormBuilder;\nFormio.Form = Form;\nFormio.FormBuilder = FormBuilder;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/Embed.js?");
|
8908
8919
|
|
8909
8920
|
/***/ }),
|
8910
8921
|
|
@@ -8915,7 +8926,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
|
|
8915
8926
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
8916
8927
|
|
8917
8928
|
"use strict";
|
8918
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Formio = void 0;\nconst sdk_1 = __webpack_require__(/*! @formio/core/sdk */ \"./node_modules/@formio/core/lib/sdk/index.js\");\nObject.defineProperty(exports, \"Formio\", ({ enumerable: true, get: function () { return sdk_1.Formio; } }));\nconst Embed_1 = __webpack_require__(/*! ./Embed */ \"./lib/cjs/Embed.js\");\nconst CDN_1 = __importDefault(__webpack_require__(/*! ./CDN */ \"./lib/cjs/CDN.js\"));\nconst providers_1 = __importDefault(__webpack_require__(/*! ./providers */ \"./lib/cjs/providers/index.js\"));\nsdk_1.Formio.cdn = new CDN_1.default();\nsdk_1.Formio.Providers = providers_1.default;\nsdk_1.Formio.version = '5.0.0-rc.
|
8929
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Formio = void 0;\nconst sdk_1 = __webpack_require__(/*! @formio/core/sdk */ \"./node_modules/@formio/core/lib/sdk/index.js\");\nObject.defineProperty(exports, \"Formio\", ({ enumerable: true, get: function () { return sdk_1.Formio; } }));\nconst Embed_1 = __webpack_require__(/*! ./Embed */ \"./lib/cjs/Embed.js\");\nconst CDN_1 = __importDefault(__webpack_require__(/*! ./CDN */ \"./lib/cjs/CDN.js\"));\nconst providers_1 = __importDefault(__webpack_require__(/*! ./providers */ \"./lib/cjs/providers/index.js\"));\nsdk_1.Formio.cdn = new CDN_1.default();\nsdk_1.Formio.Providers = providers_1.default;\nsdk_1.Formio.version = '5.0.0-rc.95';\nCDN_1.default.defaultCDN = sdk_1.Formio.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';\nconst isNil = (val) => val === null || val === undefined;\nsdk_1.Formio.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {\n const requestArgs = {\n provider: storage,\n method: 'upload',\n file: file,\n fileName: fileName,\n dir: dir\n };\n fileKey = fileKey || 'file';\n const request = sdk_1.Formio.pluginWait('preRequest', requestArgs)\n .then(() => {\n return sdk_1.Formio.pluginGet('fileRequest', requestArgs)\n .then((result) => {\n if (storage && isNil(result)) {\n const Provider = providers_1.default.getProvider('storage', storage);\n if (Provider) {\n const provider = new Provider(this);\n if (uploadStartCallback) {\n uploadStartCallback();\n }\n return provider.uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback, multipartOptions);\n }\n else {\n throw ('Storage provider not found');\n }\n }\n return result || { url: '' };\n });\n });\n return sdk_1.Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n};\nsdk_1.Formio.prototype.downloadFile = function (file, options) {\n const requestArgs = {\n method: 'download',\n file: file\n };\n const request = sdk_1.Formio.pluginWait('preRequest', requestArgs)\n .then(() => {\n return sdk_1.Formio.pluginGet('fileRequest', requestArgs)\n .then((result) => {\n if (file.storage && isNil(result)) {\n const Provider = providers_1.default.getProvider('storage', file.storage);\n if (Provider) {\n const provider = new Provider(this);\n return provider.downloadFile(file, options);\n }\n else {\n throw ('Storage provider not found');\n }\n }\n return result || { url: '' };\n });\n });\n return sdk_1.Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n};\nsdk_1.Formio.prototype.deleteFile = function (file, options) {\n const requestArgs = {\n method: 'delete',\n file: file\n };\n const request = sdk_1.Formio.pluginWait('preRequest', requestArgs)\n .then(() => {\n return sdk_1.Formio.pluginGet('fileRequest', requestArgs)\n .then((result) => {\n if (file.storage && isNil(result)) {\n const Provider = providers_1.default.getProvider('storage', file.storage);\n if (Provider) {\n const provider = new Provider(this);\n return provider.deleteFile(file, options);\n }\n else {\n throw ('Storage provider not found');\n }\n }\n return result || { url: '' };\n });\n });\n return sdk_1.Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n};\n// Esnure we proxy the following methods to the FormioEmbed class.\n['setBaseUrl', 'setApiUrl', 'setAppUrl', 'setProjectUrl', 'setPathType', 'setLicense'].forEach((fn) => {\n const baseFn = sdk_1.Formio[fn];\n sdk_1.Formio[fn] = function (arg) {\n const retVal = Embed_1.Formio[fn](arg, true);\n return baseFn ? baseFn.call(this, arg) : retVal;\n };\n});\n// For reverse compatability.\nsdk_1.Formio.Promise = Promise;\nsdk_1.Formio.formioReady = Embed_1.Formio.formioReady;\nsdk_1.Formio.config = Embed_1.Formio.config;\nsdk_1.Formio.builder = Embed_1.Formio.builder;\nsdk_1.Formio.Report = Embed_1.Formio.Report;\nsdk_1.Formio.Form = Embed_1.Formio.Form;\nsdk_1.Formio.FormBuilder = Embed_1.Formio.FormBuilder;\nsdk_1.Formio.use = Embed_1.Formio.use;\nsdk_1.Formio.createForm = Embed_1.Formio.createForm;\nsdk_1.Formio.submitDone = Embed_1.Formio.submitDone;\nsdk_1.Formio.addLibrary = Embed_1.Formio.addLibrary;\nsdk_1.Formio.addLoader = Embed_1.Formio.addLoader;\nsdk_1.Formio.addToGlobal = (global) => {\n if (typeof global === 'object' && !global.Formio) {\n global.Formio = sdk_1.Formio;\n }\n};\nif (typeof __webpack_require__.g !== 'undefined') {\n sdk_1.Formio.addToGlobal(__webpack_require__.g);\n}\nif (typeof window !== 'undefined') {\n sdk_1.Formio.addToGlobal(window);\n}\nEmbed_1.Formio._formioReady(sdk_1.Formio);\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/Formio.js?");
|
8919
8930
|
|
8920
8931
|
/***/ }),
|
8921
8932
|
|