@formio/js 5.1.0-dev.6072.881b120 → 5.1.0-dev.6074.816c0e0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formio.form.js +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +2 -2
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/components/_classes/list/ListComponent.js +2 -2
- package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +18 -18
- package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -0
- package/lib/mjs/components/_classes/list/ListComponent.js +2 -2
- package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +18 -18
- package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -0
- package/package.json +1 -1
package/dist/formio.full.js
CHANGED
@@ -5666,7 +5666,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5666
5666
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
5667
5667
|
|
5668
5668
|
"use strict";
|
5669
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst Field_1 = __importDefault(__webpack_require__(/*! ../field/Field */ \"./lib/cjs/components/_classes/field/Field.js\"));\nconst Formio_1 = __webpack_require__(/*! ../../../Formio */ \"./lib/cjs/Formio.js\");\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst utils_1 = __webpack_require__(/*! ../../../utils/utils */ \"./lib/cjs/utils/utils.js\");\nclass ListComponent extends Field_1.default {\n static schema(...extend) {\n return Field_1.default.schema({\n dataSrc: 'values',\n authenticate: false,\n ignoreCache: false,\n template: '<span>{{ item.label }}</span>',\n validate: {\n onlyAvailableItems: false\n },\n }, ...extend);\n }\n get isSelectURL() {\n return this.component.dataSrc === 'url';\n }\n get selectData() {\n const selectData = lodash_1.default.get(this.root, 'submission.metadata.selectData', {});\n return lodash_1.default.get(selectData, this.path);\n }\n get dataReady() {\n // If the root submission has been set, and we are still not attached, then assume\n // that our data is ready.\n if (this.root &&\n this.root.submissionSet &&\n !this.attached) {\n return Promise.resolve();\n }\n return this.itemsLoaded;\n }\n get shouldLoad() {\n if (this.loadingError) {\n return false;\n }\n // Live forms should always load.\n if (!this.options.readOnly) {\n return true;\n }\n // If there are template keys, then we need to see if we have the data.\n if (this.templateKeys && this.templateKeys.length) {\n // See if we already have the data we need.\n const dataValue = this.dataValue;\n const selectData = this.selectData;\n return this.templateKeys.reduce((shouldLoad, key) => {\n const hasValue = lodash_1.default.has(dataValue, key) ||\n (lodash_1.default.isArray(selectData) ? selectData.every((data) => lodash_1.default.has(data, key)) : lodash_1.default.has(selectData, key));\n return shouldLoad || !hasValue;\n }, false);\n }\n // Return that we should load.\n return true;\n }\n getTemplateKeys() {\n const template = this.component.template;\n this.templateKeys = this.options.readOnly && template\n ? (0, utils_1.getItemTemplateKeys)(template)\n : [];\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 // Must be implemented in child classes.\n setItems() { }\n updateCustomItems() { }\n loadItems() { }\n getOptionTemplate(data, value, index) {\n if (!this.component.template) {\n return data.label;\n }\n const options = {\n noeval: true,\n data: {}\n };\n const template = this.sanitize(this.component.template\n ? this.interpolate(this.component.template, { item: data }, options)\n : data.label, this.shouldSanitizeValue);\n const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;\n if (templateValue && !lodash_1.default.isObject(templateValue) && options.data.item) {\n // If the value is not an object, then we need to save the template data off for when it is selected.\n this.templateData[templateValue] = options.data.item;\n }\n if (lodash_1.default.isNumber(index)) {\n this.templateData[index] = options.data.item;\n }\n return template;\n }\n itemTemplate(data, value, index) {\n if (lodash_1.default.isEmpty(data)) {\n return '';\n }\n const template = this.sanitize(this.getOptionTemplate(data, value, index), this.shouldSanitizeValue);\n if (template) {\n const label = template.replace(/<\\/?[^>]+(>|$)/g, '');\n if (!label)\n return;\n return template.replace(label, this.t(label, { _userInput: true }));\n }\n else {\n return this.sanitize(JSON.stringify(data), this.shouldSanitizeValue);\n }\n }\n get itemsLoaded() {\n return this._itemsLoaded || Promise.resolve();\n }\n set itemsLoaded(promise) {\n this._itemsLoaded = promise;\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(this.t('loadResourcesError', { componentKey: this.key }));\n }\n /* eslint-disable max-statements */\n updateItems(searchInput, forceUpdate) {\n if (!this.component.data) {\n console.warn(this.t('noSelectDataConfiguration', { componentKey: this.key }));\n this.itemsLoadedResolve();\n return;\n }\n // Only load the data if it is visible.\n if (!this.visible) {\n this.itemsLoadedResolve();\n return;\n }\n switch (this.component.dataSrc) {\n case 'values':\n this.setItems(this.component.data.values);\n break;\n case 'json':\n this.setItems(this.component.data.json);\n break;\n case 'custom':\n this.updateCustomItems(forceUpdate);\n break;\n case 'resource': {\n // If there is no resource, or we are lazyLoading, wait until active.\n if (!this.component.data.resource || (!forceUpdate && !this.active)) {\n this.itemsLoadedResolve();\n return;\n }\n let resourceUrl = this.options.formio ? this.options.formio.formsUrl : `${Formio_1.Formio.getProjectUrl()}/form`;\n resourceUrl += (`/${this.component.data.resource}/submission`);\n if (forceUpdate || this.additionalResourcesAvailable || !this.serverCount) {\n try {\n this.loadItems(resourceUrl, searchInput, this.requestHeaders);\n }\n catch (err) {\n console.warn(this.t('loadResourcesError', { componentKey: this.key }));\n }\n }\n else {\n this.setItems(this.downloadedResources);\n }\n break;\n }\n case 'url': {\n if (!forceUpdate && !this.active && !this.calculatedValue && this.component.type === 'select') {\n // If we are lazyLoading, wait until activated.\n this.itemsLoadedResolve();\n return;\n }\n let { url } = this.component.data;\n url = lodash_1.default.trim(url);\n let method;\n let body;\n if (url.startsWith('/')) {\n // if URL starts with '/project', we should use base URL to avoid issues with URL formed like <base_url>/<project_name>/project/<project_id>/...\n const baseUrl = url.startsWith('/project') ? Formio_1.Formio.getBaseUrl() : Formio_1.Formio.getProjectUrl() || Formio_1.Formio.getBaseUrl();\n url = baseUrl + url;\n }\n if (!this.component.data.method) {\n method = 'GET';\n }\n else {\n method = this.component.data.method;\n if (method.toUpperCase() === 'POST') {\n body = this.component.data.body;\n }\n else {\n body = null;\n }\n }\n const options = this.component.authenticate ? {} : { noToken: true };\n this.loadItems(url, searchInput, this.requestHeaders, options, method, body);\n break;\n }\n case 'indexeddb': {\n if (typeof window === 'undefined') {\n return;\n }\n if (!window.indexedDB) {\n window.alert(this.t('indexedDBSupportError'));\n }\n if (this.component.indexeddb && this.component.indexeddb.database && this.component.indexeddb.table) {\n const request = window.indexedDB.open(this.component.indexeddb.database);\n request.onupgradeneeded = (event) => {\n if (this.component.customOptions) {\n const db = event.target.result;\n const objectStore = db.createObjectStore(this.component.indexeddb.table, { keyPath: 'myKey', autoIncrement: true });\n objectStore.transaction.oncomplete = () => {\n const transaction = db.transaction(this.component.indexeddb.table, 'readwrite');\n this.component.customOptions.forEach((item) => {\n transaction.objectStore(this.component.indexeddb.table).put(item);\n });\n };\n }\n };\n request.onerror = () => {\n window.alert(request.errorCode);\n };\n request.onsuccess = (event) => {\n const db = event.target.result;\n const transaction = db.transaction(this.component.indexeddb.table, 'readwrite');\n const objectStore = transaction.objectStore(this.component.indexeddb.table);\n new Promise((resolve) => {\n const responseItems = [];\n objectStore.getAll().onsuccess = (event) => {\n event.target.result.forEach((item) => {\n responseItems.push(item);\n });\n resolve(responseItems);\n };\n }).then((items) => {\n if (!lodash_1.default.isEmpty(this.component.indexeddb.filter)) {\n items = lodash_1.default.filter(items, this.component.indexeddb.filter);\n }\n this.setItems(items);\n });\n };\n }\n }\n }\n }\n}\nexports[\"default\"] = ListComponent;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/_classes/list/ListComponent.js?");
|
5669
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nconst Field_1 = __importDefault(__webpack_require__(/*! ../field/Field */ \"./lib/cjs/components/_classes/field/Field.js\"));\nconst Formio_1 = __webpack_require__(/*! ../../../Formio */ \"./lib/cjs/Formio.js\");\nconst lodash_1 = __importDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nconst utils_1 = __webpack_require__(/*! ../../../utils/utils */ \"./lib/cjs/utils/utils.js\");\nclass ListComponent extends Field_1.default {\n static schema(...extend) {\n return Field_1.default.schema({\n dataSrc: 'values',\n authenticate: false,\n ignoreCache: false,\n template: '<span>{{ item.label }}</span>',\n validate: {\n onlyAvailableItems: false\n },\n }, ...extend);\n }\n get isSelectURL() {\n return this.component.dataSrc === 'url';\n }\n get selectData() {\n const selectData = lodash_1.default.get(this.root, 'submission.metadata.selectData', {});\n return lodash_1.default.get(selectData, this.path);\n }\n get dataReady() {\n // If the root submission has been set, and we are still not attached, then assume\n // that our data is ready.\n if ((this.root &&\n this.root.submissionSet &&\n !this.attached) || !this.visible) {\n return Promise.resolve();\n }\n return this.itemsLoaded;\n }\n get shouldLoad() {\n if (this.loadingError) {\n return false;\n }\n // Live forms should always load.\n if (!this.options.readOnly) {\n return true;\n }\n // If there are template keys, then we need to see if we have the data.\n if (this.templateKeys && this.templateKeys.length) {\n // See if we already have the data we need.\n const dataValue = this.dataValue;\n const selectData = this.selectData;\n return this.templateKeys.reduce((shouldLoad, key) => {\n const hasValue = lodash_1.default.has(dataValue, key) ||\n (lodash_1.default.isArray(selectData) ? selectData.every((data) => lodash_1.default.has(data, key)) : lodash_1.default.has(selectData, key));\n return shouldLoad || !hasValue;\n }, false);\n }\n // Return that we should load.\n return true;\n }\n getTemplateKeys() {\n const template = this.component.template;\n this.templateKeys = this.options.readOnly && template\n ? (0, utils_1.getItemTemplateKeys)(template)\n : [];\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 // Must be implemented in child classes.\n setItems() { }\n updateCustomItems() { }\n loadItems() { }\n getOptionTemplate(data, value, index) {\n if (!this.component.template) {\n return data.label;\n }\n const options = {\n noeval: true,\n data: {}\n };\n const template = this.sanitize(this.component.template\n ? this.interpolate(this.component.template, { item: data }, options)\n : data.label, this.shouldSanitizeValue);\n const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;\n if (templateValue && !lodash_1.default.isObject(templateValue) && options.data.item) {\n // If the value is not an object, then we need to save the template data off for when it is selected.\n this.templateData[templateValue] = options.data.item;\n }\n if (lodash_1.default.isNumber(index)) {\n this.templateData[index] = options.data.item;\n }\n return template;\n }\n itemTemplate(data, value, index) {\n if (lodash_1.default.isEmpty(data)) {\n return '';\n }\n const template = this.sanitize(this.getOptionTemplate(data, value, index), this.shouldSanitizeValue);\n if (template) {\n const label = template.replace(/<\\/?[^>]+(>|$)/g, '');\n if (!label)\n return;\n return template.replace(label, this.t(label, { _userInput: true }));\n }\n else {\n return this.sanitize(JSON.stringify(data), this.shouldSanitizeValue);\n }\n }\n get itemsLoaded() {\n return this._itemsLoaded || Promise.resolve();\n }\n set itemsLoaded(promise) {\n this._itemsLoaded = promise;\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(this.t('loadResourcesError', { componentKey: this.key }));\n }\n /* eslint-disable max-statements */\n updateItems(searchInput, forceUpdate) {\n if (!this.component.data) {\n console.warn(this.t('noSelectDataConfiguration', { componentKey: this.key }));\n this.itemsLoadedResolve();\n return;\n }\n // Only load the data if it is visible.\n if (!this.visible) {\n this.itemsLoadedResolve();\n return;\n }\n switch (this.component.dataSrc) {\n case 'values':\n this.setItems(this.component.data.values);\n break;\n case 'json':\n this.setItems(this.component.data.json);\n break;\n case 'custom':\n this.updateCustomItems(forceUpdate);\n break;\n case 'resource': {\n // If there is no resource, or we are lazyLoading, wait until active.\n if (!this.component.data.resource || (!forceUpdate && !this.active)) {\n this.itemsLoadedResolve();\n return;\n }\n let resourceUrl = this.options.formio ? this.options.formio.formsUrl : `${Formio_1.Formio.getProjectUrl()}/form`;\n resourceUrl += (`/${this.component.data.resource}/submission`);\n if (forceUpdate || this.additionalResourcesAvailable || !this.serverCount) {\n try {\n this.loadItems(resourceUrl, searchInput, this.requestHeaders);\n }\n catch (err) {\n console.warn(this.t('loadResourcesError', { componentKey: this.key }));\n }\n }\n else {\n this.setItems(this.downloadedResources);\n }\n break;\n }\n case 'url': {\n if (!forceUpdate && !this.active && !this.calculatedValue && this.component.type === 'select') {\n // If we are lazyLoading, wait until activated.\n this.itemsLoadedResolve();\n return;\n }\n let { url } = this.component.data;\n url = lodash_1.default.trim(url);\n let method;\n let body;\n if (url.startsWith('/')) {\n // if URL starts with '/project', we should use base URL to avoid issues with URL formed like <base_url>/<project_name>/project/<project_id>/...\n const baseUrl = url.startsWith('/project') ? Formio_1.Formio.getBaseUrl() : Formio_1.Formio.getProjectUrl() || Formio_1.Formio.getBaseUrl();\n url = baseUrl + url;\n }\n if (!this.component.data.method) {\n method = 'GET';\n }\n else {\n method = this.component.data.method;\n if (method.toUpperCase() === 'POST') {\n body = this.component.data.body;\n }\n else {\n body = null;\n }\n }\n const options = this.component.authenticate ? {} : { noToken: true };\n this.loadItems(url, searchInput, this.requestHeaders, options, method, body);\n break;\n }\n case 'indexeddb': {\n if (typeof window === 'undefined') {\n return;\n }\n if (!window.indexedDB) {\n window.alert(this.t('indexedDBSupportError'));\n }\n if (this.component.indexeddb && this.component.indexeddb.database && this.component.indexeddb.table) {\n const request = window.indexedDB.open(this.component.indexeddb.database);\n request.onupgradeneeded = (event) => {\n if (this.component.customOptions) {\n const db = event.target.result;\n const objectStore = db.createObjectStore(this.component.indexeddb.table, { keyPath: 'myKey', autoIncrement: true });\n objectStore.transaction.oncomplete = () => {\n const transaction = db.transaction(this.component.indexeddb.table, 'readwrite');\n this.component.customOptions.forEach((item) => {\n transaction.objectStore(this.component.indexeddb.table).put(item);\n });\n };\n }\n };\n request.onerror = () => {\n window.alert(request.errorCode);\n };\n request.onsuccess = (event) => {\n const db = event.target.result;\n const transaction = db.transaction(this.component.indexeddb.table, 'readwrite');\n const objectStore = transaction.objectStore(this.component.indexeddb.table);\n new Promise((resolve) => {\n const responseItems = [];\n objectStore.getAll().onsuccess = (event) => {\n event.target.result.forEach((item) => {\n responseItems.push(item);\n });\n resolve(responseItems);\n };\n }).then((items) => {\n if (!lodash_1.default.isEmpty(this.component.indexeddb.filter)) {\n items = lodash_1.default.filter(items, this.component.indexeddb.filter);\n }\n this.setItems(items);\n });\n };\n }\n }\n }\n }\n}\nexports[\"default\"] = ListComponent;\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/_classes/list/ListComponent.js?");
|
5670
5670
|
|
5671
5671
|
/***/ }),
|
5672
5672
|
|
@@ -6997,7 +6997,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6997
6997
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
6998
6998
|
|
6999
6999
|
"use strict";
|
7000
|
-
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 utils_1 = __webpack_require__(/*! ../../../utils/utils */ \"./lib/cjs/utils/utils.js\");\nconst calculateSingleSelectData = (context, defaultValue) => {\n const { instance, data } = context;\n const rawDefaultValue = instance.downloadedResources.find(resource => lodash_1.default.get(resource, data.valueProperty) === defaultValue);\n const options = { data: {}, noeval: true };\n instance.interpolate(data.template, {\n item: rawDefaultValue,\n }, options);\n return options.data.item;\n};\nconst calculateSelectData = (context) => {\n const { instance } = context;\n const defaultValue = instance.getValue();\n if (instance.component.multiple) {\n const multiSelectData = {};\n (defaultValue !== null && defaultValue !== void 0 ? defaultValue : []).forEach((defaultValueItem) => {\n multiSelectData[defaultValueItem] = calculateSingleSelectData(context, defaultValueItem);\n });\n return multiSelectData;\n }\n else {\n return calculateSingleSelectData(context, defaultValue);\n }\n};\nconst setSelectData = (context) => {\n // Wait before downloadedResources will be set\n setTimeout(() => {\n var _a, _b;\n const { instance, data } = context;\n const selectDataComponent = (_a = instance === null || instance === void 0 ? void 0 : instance.root) === null || _a === void 0 ? void 0 : _a.getComponent('selectData');\n // clear selectData if conditions are not met or clearing default value\n if (selectDataComponent && (!selectDataComponent.visible || !data.defaultValue)) {\n selectDataComponent.setValue(null, { resetValue: true });\n return;\n }\n // nothing can set if don't have downloaded resources\n if (!selectDataComponent || !instance.getValue() || !((_b = instance.downloadedResources) === null || _b === void 0 ? void 0 : _b.length)) {\n return;\n }\n const shouldCalculateUrlData = data.dataSrc === 'url' && data.data.url && data.valueProperty;\n const shouldCalculateResourceData = data.dataSrc === 'resource' && data.data.resource && data.valueProperty;\n const newValue = shouldCalculateUrlData || shouldCalculateResourceData ? calculateSelectData(context) : null;\n selectDataComponent.setValue(newValue, { resetValue: newValue === null });\n }, 0);\n};\nexports[\"default\"] = [\n {\n key: 'dataSrc',\n data: {\n values: [\n { label: 'Values', value: 'values' },\n { label: 'URL', value: 'url' },\n { label: 'Resource', value: 'resource' },\n { label: 'Custom', value: 'custom' },\n { label: 'Raw JSON', value: 'json' },\n ],\n },\n },\n {\n type: 'textarea',\n as: 'json',\n editor: 'ace',\n weight: 10,\n input: true,\n key: 'data.json',\n label: 'Data Source Raw JSON',\n tooltip: 'A valid JSON array to use as a data source.',\n description: '<div>Example: <pre>[\"apple\", \"banana\", \"orange\"].</pre></div> <div>Example 2: <pre>[{\"name\": \"John\", \"email\": \"john.doe@test.com\"}, {\"name\": \"Jane\", \"email\": \"jane.doe@test.com\"}].</pre></div>',\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'json'] },\n },\n },\n {\n type: 'checkbox',\n input: true,\n label: 'Lazy Load Data',\n key: 'lazyLoad',\n tooltip: 'When set, this will not fire off the request to the URL until this control is within focus. This can improve performance if you have many Select dropdowns on your form where the API\\'s will only fire when the control is activated.',\n weight: 11,\n conditional: {\n json: {\n and: [\n {\n in: [\n { var: 'data.dataSrc' },\n [\n 'resource',\n 'url',\n ],\n ],\n },\n {\n '!==': [\n { var: 'data.widget' },\n 'html5'\n ]\n }\n ]\n },\n },\n },\n {\n type: 'datagrid',\n input: true,\n label: 'Data Source Values',\n key: 'data.values',\n tooltip: 'Values to use as the data source. Labels are shown in the select field. Values are the corresponding values saved with the submission.',\n weight: 10,\n reorder: true,\n defaultValue: [{ label: '', value: '' }],\n components: [\n {\n label: 'Label',\n key: 'label',\n input: true,\n type: 'textfield',\n },\n {\n label: 'Value',\n key: 'value',\n input: true,\n type: 'textfield',\n allowCalculateOverride: true,\n calculateValue: 'value = _.camelCase(row.label);',\n },\n ],\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'values'] },\n },\n },\n {\n type: 'select',\n input: true,\n dataSrc: 'url',\n data: {\n url: '/form?type=resource&limit=1000000&select=_id,title',\n },\n authenticate: true,\n template: '<span>{{ item.title }}</span>',\n valueProperty: '_id',\n clearOnHide: false,\n label: 'Resource',\n key: 'data.resource',\n lazyLoad: false,\n weight: 10,\n tooltip: 'The resource to be used with this field.',\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n },\n },\n {\n type: 'textfield',\n input: true,\n label: 'Data Path',\n key: 'selectValues',\n weight: 12,\n description: 'The object path to the iterable items.',\n tooltip: 'The property within the source data, where iterable items reside. For example: results.items or results[0].items',\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'url'] },\n },\n },\n {\n type: 'select',\n input: true,\n label: 'Value Property',\n key: 'valueProperty',\n skipMerge: true,\n clearOnHide: false,\n tooltip: 'The field to use as the value.',\n weight: 11,\n refreshOn: 'data.resource',\n template: '<span>{{ item.label }}</span>',\n valueProperty: 'key',\n dataSrc: 'url',\n lazyLoad: false,\n onSetItems(component, form) {\n const newItems = form.type === 'resource'\n ? [{\n label: '{Entire Object}',\n key: 'data',\n }]\n : [];\n (0, utils_1.eachComponent)(form.components, (component, path) => {\n if (component.input) {\n newItems.push({\n label: component.label || component.key,\n key: `data.${path}`\n });\n }\n });\n return newItems;\n },\n onChange(context) {\n if (context && context.flags && context.flags.modified) {\n const valueProp = context.instance.data.valueProperty;\n const templateProp = valueProp ? valueProp : 'data';\n const template = `<span>{{ item.${templateProp} }}</span>`;\n const searchField = valueProp ? `${valueProp}__regex` : '';\n context.instance.root.getComponent('template').setValue(template);\n context.instance.root.getComponent('searchField').setValue(searchField);\n }\n },\n data: {\n url: '/form/{{ data.data.resource }}',\n },\n conditional: {\n json: {\n and: [\n { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n { '!==': [{ var: 'data.reference' }, true] },\n { var: 'data.data.resource' },\n ],\n },\n },\n },\n {\n type: 'select',\n input: true,\n label: 'Storage Type',\n key: 'dataType',\n clearOnHide: true,\n tooltip: 'The type to store the data. If you select something other than autotype, it will force it to that type.',\n weight: 12,\n template: '<span>{{ item.label }}</span>',\n dataSrc: 'values',\n data: {\n values: [\n { label: 'Autotype', value: 'auto' },\n { label: 'String', value: 'string' },\n { label: 'Number', value: 'number' },\n { label: 'Boolean', value: 'boolean' },\n { label: 'Object', value: 'object' },\n ],\n },\n },\n {\n type: 'textfield',\n input: true,\n key: 'idPath',\n weight: 12,\n label: 'ID Path',\n placeholder: 'id',\n tooltip: 'Path to the select option id.'\n },\n {\n type: 'textfield',\n input: true,\n label: 'Select Fields',\n key: 'selectFields',\n tooltip: 'The properties on the resource to return as part of the options. Separate property names by commas. If left blank, all properties will be returned.',\n placeholder: 'Comma separated list of fields to select.',\n weight: 14,\n conditional: {\n json: {\n and: [\n { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n { '===': [{ var: 'data.valueProperty' }, ''] },\n ],\n },\n },\n },\n {\n type: 'checkbox',\n input: true,\n key: 'disableLimit',\n label: 'Disable limiting response',\n tooltip: 'When enabled the request will not include the limit and skip options in the query string',\n weight: 15,\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'url'] },\n },\n },\n {\n type: 'textfield',\n input: true,\n key: 'searchField',\n label: 'Search Query Name',\n weight: 16,\n description: 'Name of URL query parameter',\n tooltip: 'The name of the search querystring parameter used when sending a request to filter results with. The server at the URL must handle this query parameter.',\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n ],\n ],\n },\n },\n },\n {\n type: 'number',\n input: true,\n key: 'searchDebounce',\n label: 'Search request delay',\n weight: 16,\n description: 'The delay (in seconds) before the search request is sent.',\n tooltip: 'The delay in seconds before the search request is sent, measured from the last character input in the search field.',\n validate: {\n min: 0,\n customMessage: '',\n json: '',\n max: 1,\n },\n delimiter: false,\n requireDecimal: false,\n encrypted: false,\n defaultValue: 0.3,\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n ],\n ],\n },\n },\n },\n {\n type: 'number',\n input: true,\n key: 'minSearch',\n weight: 17,\n label: 'Minimum Search Length',\n tooltip: 'The minimum amount of characters they must type before a search is made.',\n defaultValue: 0,\n conditional: {\n json: {\n and: [\n { '===': [{ var: 'data.dataSrc' }, 'url'] },\n { '!=': [{ var: 'data.searchField' }, ''] },\n ],\n },\n },\n },\n {\n type: 'textfield',\n input: true,\n key: 'filter',\n label: 'Filter Query',\n weight: 18,\n description: 'The filter query for results.',\n tooltip: 'Use this to provide additional filtering using query parameters.',\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n ],\n ],\n },\n },\n },\n {\n type: 'textfield',\n input: true,\n key: 'sort',\n label: 'Sort Query',\n weight: 18,\n description: 'The sort query for results',\n tooltip: 'Use this to provide additional sorting using query parameters',\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n ],\n ],\n },\n },\n },\n {\n type: 'number',\n input: true,\n key: 'limit',\n label: 'Limit',\n weight: 18,\n description: 'Maximum number of items to view per page of results.',\n tooltip: 'Use this to limit the number of items to request or view.',\n clearOnHide: false,\n conditional: {\n json: {\n and: [\n { in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource'\n ],\n ] },\n { '!==': [{ var: 'data.disableLimit' }, true] }\n ]\n },\n },\n },\n {\n type: 'textarea',\n input: true,\n key: 'data.custom',\n label: 'Custom Values',\n editor: 'ace',\n rows: 10,\n weight: 14,\n placeholder: \"values = data['mykey'] or values = Promise.resolve(['myValue'])\",\n tooltip: 'Write custom code to return the value options or a promise with value options. The form data object is available.',\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'custom'] },\n },\n },\n {\n type: 'select',\n input: true,\n key: 'refreshOn',\n label: 'Refresh Options On',\n weight: 19,\n tooltip: 'Refresh data when another field changes.',\n dataSrc: 'custom',\n valueProperty: 'value',\n data: {\n custom(context) {\n var values = [];\n values.push({ label: 'Any Change', value: 'data' });\n context.utils.eachComponent(context.instance.options.editForm.components, function (component, path) {\n if (component.key !== context.data.key) {\n values.push({\n label: component.label || component.key,\n value: path\n });\n }\n });\n return values;\n }\n },\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n 'values',\n 'custom'\n ],\n ],\n },\n },\n },\n {\n type: 'select',\n input: true,\n key: 'refreshOnBlur',\n label: 'Refresh Options On Blur',\n weight: 19,\n tooltip: 'Refresh data when another field is blured.',\n dataSrc: 'custom',\n valueProperty: 'value',\n data: {\n custom(context) {\n var values = [];\n values.push({ label: 'Any Change', value: 'data' });\n context.utils.eachComponent(context.instance.options.editForm.components, function (component, path) {\n if (component.key !== context.data.key) {\n values.push({\n label: component.label || component.key,\n value: path\n });\n }\n });\n return values;\n }\n },\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n 'values'\n ],\n ],\n },\n },\n },\n {\n type: 'checkbox',\n input: true,\n weight: 20,\n key: 'clearOnRefresh',\n label: 'Clear Value On Refresh Options',\n defaultValue: false,\n tooltip: 'When the Refresh On field is changed, clear this components value.',\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n 'values',\n 'custom'\n ],\n ],\n },\n },\n },\n {\n type: 'checkbox',\n input: true,\n weight: 21,\n key: 'searchEnabled',\n label: 'Enable Static Search',\n defaultValue: true,\n tooltip: 'When checked, the select dropdown will allow for searching within the static list of items provided.',\n },\n {\n type: 'checkbox',\n input: true,\n weight: 21,\n key: 'noRefreshOnScroll',\n label: 'Disable Options Refresh When Scrolling',\n defaultValue: false,\n tooltip: 'When checked, the select with search input won\\'t perform new api requests when scrolling through the list of options.',\n conditional: {\n json: {\n and: [\n { in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource'\n ],\n ] },\n { '===': [{ var: 'data.searchEnabled' }, true] }\n ]\n },\n },\n },\n {\n label: 'Search Threshold',\n mask: false,\n tableView: true,\n alwaysEnabled: false,\n type: 'number',\n input: true,\n key: 'selectThreshold',\n validate: {\n min: 0,\n customMessage: '',\n json: '',\n max: 1,\n },\n delimiter: false,\n requireDecimal: false,\n encrypted: false,\n defaultValue: 0.3,\n weight: 22,\n tooltip: 'At what point does the match algorithm give up. A threshold of 0.0 requires a perfect match, a threshold of 1.0 would match anything.',\n },\n {\n type: 'checkbox',\n input: true,\n weight: 23,\n key: 'addResource',\n label: 'Add Resource',\n tooltip: 'Allows to create a new resource while entering a submission.',\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n },\n },\n {\n type: 'textfield',\n label: 'Add Resource Label',\n key: 'addResourceLabel',\n tooltip: 'Set the text of the Add Resource button.',\n placeholder: 'Add Resource',\n weight: 24,\n input: true,\n conditional: {\n json: {\n and: [\n { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n { '!!': { var: 'data.addResource' } },\n ],\n },\n },\n },\n {\n type: 'checkbox',\n input: true,\n weight: 25,\n key: 'reference',\n label: 'Submit as reference',\n tooltip: 'Using this option will submit this field as a reference id and link its value to the value of the origin record.',\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n },\n },\n {\n type: 'checkbox',\n input: true,\n weight: 27,\n key: 'readOnlyValue',\n label: 'Read Only Value',\n tooltip: 'Check this if you would like to show just the value when in Read Only mode.',\n },\n {\n type: 'textarea',\n as: 'json',\n editor: 'ace',\n weight: 28,\n input: true,\n key: 'customOptions',\n label: 'Choices.js options',\n tooltip: 'A raw JSON object to use as options for the Select component (Choices JS).',\n defaultValue: {},\n },\n {\n type: 'checkbox',\n input: true,\n weight: 29,\n key: 'useExactSearch',\n label: 'Use exact search',\n tooltip: 'Disables search algorithm threshold.',\n },\n {\n key: 'defaultValue',\n onSetItems(component) {\n setSelectData(component.evalContext());\n },\n onChange(context) {\n if (context && context.flags && context.flags.modified) {\n setSelectData(context);\n }\n },\n },\n {\n key: 'selectData',\n type: 'hidden',\n conditional: {\n json: {\n and: [\n { var: 'data.valueProperty' },\n { '===': [{ var: 'data.lazyLoad' }, true] },\n { '!==': [{ var: 'data.widget' }, 'html5'] },\n {\n or: [\n { '===': [{ var: 'data.dataSrc' }, 'url'] },\n {\n and: [\n { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n // 'data' means entire object from resource will be used\n { '!==': [{ var: 'data.valueProperty' }, 'data'] },\n ],\n }\n ]\n }\n ]\n },\n },\n },\n {\n key: 'template',\n onChange(context) {\n if (context && context.flags && context.flags.modified) {\n const defaultValueComponent = context.instance.root.getComponent('defaultValue');\n if (!defaultValueComponent) {\n return;\n }\n setSelectData(defaultValueComponent.evalContext());\n }\n },\n },\n];\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/select/editForm/Select.edit.data.js?");
|
7000
|
+
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 utils_1 = __webpack_require__(/*! ../../../utils/utils */ \"./lib/cjs/utils/utils.js\");\nconst calculateSingleSelectData = (context, defaultValue) => {\n const { instance, data } = context;\n const rawDefaultValue = instance.downloadedResources.find(resource => lodash_1.default.get(resource, data.valueProperty) === defaultValue);\n const options = { data: {}, noeval: true };\n instance.interpolate(data.template, {\n item: rawDefaultValue,\n }, options);\n return options.data.item;\n};\nconst calculateSelectData = (context) => {\n const { instance } = context;\n const defaultValue = instance.getValue();\n if (instance.component.multiple) {\n const multiSelectData = {};\n (defaultValue !== null && defaultValue !== void 0 ? defaultValue : []).forEach((defaultValueItem) => {\n multiSelectData[defaultValueItem] = calculateSingleSelectData(context, defaultValueItem);\n });\n return multiSelectData;\n }\n else {\n return calculateSingleSelectData(context, defaultValue);\n }\n};\nconst setSelectData = (context) => {\n // Wait before downloadedResources will be set\n setTimeout(() => {\n var _a, _b;\n const { instance, data } = context;\n const selectDataComponent = (_a = instance === null || instance === void 0 ? void 0 : instance.root) === null || _a === void 0 ? void 0 : _a.getComponent('selectData');\n // clear selectData if conditions are not met or clearing default value\n if (selectDataComponent && (!selectDataComponent.visible || !data.defaultValue)) {\n selectDataComponent.setValue(null, { resetValue: true });\n return;\n }\n // nothing can set if don't have downloaded resources\n if (!selectDataComponent || !instance.getValue() || !((_b = instance.downloadedResources) === null || _b === void 0 ? void 0 : _b.length)) {\n return;\n }\n const shouldCalculateUrlData = data.dataSrc === 'url' && data.data.url && data.valueProperty;\n const shouldCalculateResourceData = data.dataSrc === 'resource' && data.data.resource && data.valueProperty;\n const newValue = shouldCalculateUrlData || shouldCalculateResourceData ? calculateSelectData(context) : null;\n selectDataComponent.setValue(newValue, { resetValue: newValue === null });\n }, 0);\n};\nexports[\"default\"] = [\n {\n key: 'dataSrc',\n data: {\n values: [\n { label: 'Values', value: 'values' },\n { label: 'URL', value: 'url' },\n { label: 'Resource', value: 'resource' },\n { label: 'Custom', value: 'custom' },\n { label: 'Raw JSON', value: 'json' },\n ],\n },\n },\n {\n type: 'textarea',\n as: 'json',\n editor: 'ace',\n weight: 10,\n input: true,\n key: 'data.json',\n label: 'Data Source Raw JSON',\n tooltip: 'A valid JSON array to use as a data source.',\n description: '<div>Example: <pre>[\"apple\", \"banana\", \"orange\"].</pre></div> <div>Example 2: <pre>[{\"name\": \"John\", \"email\": \"john.doe@test.com\"}, {\"name\": \"Jane\", \"email\": \"jane.doe@test.com\"}].</pre></div>',\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'json'] },\n },\n },\n {\n type: 'checkbox',\n input: true,\n label: 'Lazy Load Data',\n key: 'lazyLoad',\n tooltip: 'When set, this will not fire off the request to the URL until this control is within focus. This can improve performance if you have many Select dropdowns on your form where the API\\'s will only fire when the control is activated.',\n weight: 11,\n defaultValue: true,\n conditional: {\n json: {\n and: [\n {\n in: [\n { var: 'data.dataSrc' },\n [\n 'resource',\n 'url',\n ],\n ],\n },\n {\n '!==': [\n { var: 'data.widget' },\n 'html5'\n ]\n }\n ]\n },\n },\n },\n {\n type: 'datagrid',\n input: true,\n label: 'Data Source Values',\n key: 'data.values',\n tooltip: 'Values to use as the data source. Labels are shown in the select field. Values are the corresponding values saved with the submission.',\n weight: 10,\n reorder: true,\n defaultValue: [{ label: '', value: '' }],\n components: [\n {\n label: 'Label',\n key: 'label',\n input: true,\n type: 'textfield',\n },\n {\n label: 'Value',\n key: 'value',\n input: true,\n type: 'textfield',\n allowCalculateOverride: true,\n calculateValue: 'value = _.camelCase(row.label);',\n },\n ],\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'values'] },\n },\n },\n {\n type: 'select',\n input: true,\n dataSrc: 'url',\n data: {\n url: '/form?type=resource&limit=1000000&select=_id,title',\n },\n authenticate: true,\n template: '<span>{{ item.title }}</span>',\n valueProperty: '_id',\n clearOnHide: false,\n label: 'Resource',\n key: 'data.resource',\n lazyLoad: false,\n weight: 10,\n tooltip: 'The resource to be used with this field.',\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n },\n },\n {\n type: 'textfield',\n input: true,\n label: 'Data Path',\n key: 'selectValues',\n weight: 12,\n description: 'The object path to the iterable items.',\n tooltip: 'The property within the source data, where iterable items reside. For example: results.items or results[0].items',\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'url'] },\n },\n },\n {\n type: 'select',\n input: true,\n label: 'Value Property',\n key: 'valueProperty',\n skipMerge: true,\n clearOnHide: false,\n tooltip: 'The field to use as the value.',\n weight: 11,\n refreshOn: 'data.resource',\n template: '<span>{{ item.label }}</span>',\n valueProperty: 'key',\n dataSrc: 'url',\n lazyLoad: false,\n onSetItems(component, form) {\n const newItems = form.type === 'resource'\n ? [{\n label: '{Entire Object}',\n key: 'data',\n }]\n : [];\n (0, utils_1.eachComponent)(form.components, (component, path) => {\n if (component.input) {\n newItems.push({\n label: component.label || component.key,\n key: `data.${path}`\n });\n }\n });\n return newItems;\n },\n onChange(context) {\n if (context && context.flags && context.flags.modified) {\n const valueProp = context.instance.data.valueProperty;\n const templateProp = valueProp ? valueProp : 'data';\n const template = `<span>{{ item.${templateProp} }}</span>`;\n const searchField = valueProp ? `${valueProp}__regex` : '';\n context.instance.root.getComponent('template').setValue(template);\n context.instance.root.getComponent('searchField').setValue(searchField);\n }\n },\n data: {\n url: '/form/{{ data.data.resource }}',\n },\n conditional: {\n json: {\n and: [\n { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n { '!==': [{ var: 'data.reference' }, true] },\n { var: 'data.data.resource' },\n ],\n },\n },\n },\n {\n type: 'select',\n input: true,\n label: 'Storage Type',\n key: 'dataType',\n clearOnHide: true,\n tooltip: 'The type to store the data. If you select something other than autotype, it will force it to that type.',\n weight: 12,\n template: '<span>{{ item.label }}</span>',\n dataSrc: 'values',\n data: {\n values: [\n { label: 'Autotype', value: 'auto' },\n { label: 'String', value: 'string' },\n { label: 'Number', value: 'number' },\n { label: 'Boolean', value: 'boolean' },\n { label: 'Object', value: 'object' },\n ],\n },\n },\n {\n type: 'textfield',\n input: true,\n key: 'idPath',\n weight: 12,\n label: 'ID Path',\n placeholder: 'id',\n tooltip: 'Path to the select option id.'\n },\n {\n type: 'textfield',\n input: true,\n label: 'Select Fields',\n key: 'selectFields',\n tooltip: 'The properties on the resource to return as part of the options. Separate property names by commas. If left blank, all properties will be returned.',\n placeholder: 'Comma separated list of fields to select.',\n weight: 14,\n conditional: {\n json: {\n and: [\n { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n { '===': [{ var: 'data.valueProperty' }, ''] },\n ],\n },\n },\n },\n {\n type: 'checkbox',\n input: true,\n key: 'disableLimit',\n label: 'Disable limiting response',\n tooltip: 'When enabled the request will not include the limit and skip options in the query string',\n weight: 15,\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'url'] },\n },\n },\n {\n type: 'textfield',\n input: true,\n key: 'searchField',\n label: 'Search Query Name',\n weight: 16,\n description: 'Name of URL query parameter',\n tooltip: 'The name of the search querystring parameter used when sending a request to filter results with. The server at the URL must handle this query parameter.',\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n ],\n ],\n },\n },\n },\n {\n type: 'number',\n input: true,\n key: 'searchDebounce',\n label: 'Search request delay',\n weight: 16,\n description: 'The delay (in seconds) before the search request is sent.',\n tooltip: 'The delay in seconds before the search request is sent, measured from the last character input in the search field.',\n validate: {\n min: 0,\n customMessage: '',\n json: '',\n max: 1,\n },\n delimiter: false,\n requireDecimal: false,\n encrypted: false,\n defaultValue: 0.3,\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n ],\n ],\n },\n },\n },\n {\n type: 'number',\n input: true,\n key: 'minSearch',\n weight: 17,\n label: 'Minimum Search Length',\n tooltip: 'The minimum amount of characters they must type before a search is made.',\n defaultValue: 0,\n conditional: {\n json: {\n and: [\n { '===': [{ var: 'data.dataSrc' }, 'url'] },\n { '!=': [{ var: 'data.searchField' }, ''] },\n ],\n },\n },\n },\n {\n type: 'textfield',\n input: true,\n key: 'filter',\n label: 'Filter Query',\n weight: 18,\n description: 'The filter query for results.',\n tooltip: 'Use this to provide additional filtering using query parameters.',\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n ],\n ],\n },\n },\n },\n {\n type: 'textfield',\n input: true,\n key: 'sort',\n label: 'Sort Query',\n weight: 18,\n description: 'The sort query for results',\n tooltip: 'Use this to provide additional sorting using query parameters',\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n ],\n ],\n },\n },\n },\n {\n type: 'number',\n input: true,\n key: 'limit',\n label: 'Limit',\n weight: 18,\n description: 'Maximum number of items to view per page of results.',\n tooltip: 'Use this to limit the number of items to request or view.',\n clearOnHide: false,\n conditional: {\n json: {\n and: [\n { in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource'\n ],\n ] },\n { '!==': [{ var: 'data.disableLimit' }, true] }\n ]\n },\n },\n },\n {\n type: 'textarea',\n input: true,\n key: 'data.custom',\n label: 'Custom Values',\n editor: 'ace',\n rows: 10,\n weight: 14,\n placeholder: \"values = data['mykey'] or values = Promise.resolve(['myValue'])\",\n tooltip: 'Write custom code to return the value options or a promise with value options. The form data object is available.',\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'custom'] },\n },\n },\n {\n type: 'select',\n input: true,\n key: 'refreshOn',\n label: 'Refresh Options On',\n weight: 19,\n tooltip: 'Refresh data when another field changes.',\n dataSrc: 'custom',\n valueProperty: 'value',\n data: {\n custom(context) {\n var values = [];\n values.push({ label: 'Any Change', value: 'data' });\n context.utils.eachComponent(context.instance.options.editForm.components, function (component, path) {\n if (component.key !== context.data.key) {\n values.push({\n label: component.label || component.key,\n value: path\n });\n }\n });\n return values;\n }\n },\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n 'values',\n 'custom'\n ],\n ],\n },\n },\n },\n {\n type: 'select',\n input: true,\n key: 'refreshOnBlur',\n label: 'Refresh Options On Blur',\n weight: 19,\n tooltip: 'Refresh data when another field is blured.',\n dataSrc: 'custom',\n valueProperty: 'value',\n data: {\n custom(context) {\n var values = [];\n values.push({ label: 'Any Change', value: 'data' });\n context.utils.eachComponent(context.instance.options.editForm.components, function (component, path) {\n if (component.key !== context.data.key) {\n values.push({\n label: component.label || component.key,\n value: path\n });\n }\n });\n return values;\n }\n },\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n 'values'\n ],\n ],\n },\n },\n },\n {\n type: 'checkbox',\n input: true,\n weight: 20,\n key: 'clearOnRefresh',\n label: 'Clear Value On Refresh Options',\n defaultValue: false,\n tooltip: 'When the Refresh On field is changed, clear this components value.',\n conditional: {\n json: {\n in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource',\n 'values',\n 'custom'\n ],\n ],\n },\n },\n },\n {\n type: 'checkbox',\n input: true,\n weight: 21,\n key: 'searchEnabled',\n label: 'Enable Static Search',\n defaultValue: true,\n tooltip: 'When checked, the select dropdown will allow for searching within the static list of items provided.',\n },\n {\n type: 'checkbox',\n input: true,\n weight: 21,\n key: 'noRefreshOnScroll',\n label: 'Disable Options Refresh When Scrolling',\n defaultValue: false,\n tooltip: 'When checked, the select with search input won\\'t perform new api requests when scrolling through the list of options.',\n conditional: {\n json: {\n and: [\n { in: [\n { var: 'data.dataSrc' },\n [\n 'url',\n 'resource'\n ],\n ] },\n { '===': [{ var: 'data.searchEnabled' }, true] }\n ]\n },\n },\n },\n {\n label: 'Search Threshold',\n mask: false,\n tableView: true,\n alwaysEnabled: false,\n type: 'number',\n input: true,\n key: 'selectThreshold',\n validate: {\n min: 0,\n customMessage: '',\n json: '',\n max: 1,\n },\n delimiter: false,\n requireDecimal: false,\n encrypted: false,\n defaultValue: 0.3,\n weight: 22,\n tooltip: 'At what point does the match algorithm give up. A threshold of 0.0 requires a perfect match, a threshold of 1.0 would match anything.',\n },\n {\n type: 'checkbox',\n input: true,\n weight: 23,\n key: 'addResource',\n label: 'Add Resource',\n tooltip: 'Allows to create a new resource while entering a submission.',\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n },\n },\n {\n type: 'textfield',\n label: 'Add Resource Label',\n key: 'addResourceLabel',\n tooltip: 'Set the text of the Add Resource button.',\n placeholder: 'Add Resource',\n weight: 24,\n input: true,\n conditional: {\n json: {\n and: [\n { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n { '!!': { var: 'data.addResource' } },\n ],\n },\n },\n },\n {\n type: 'checkbox',\n input: true,\n weight: 25,\n key: 'reference',\n label: 'Submit as reference',\n tooltip: 'Using this option will submit this field as a reference id and link its value to the value of the origin record.',\n conditional: {\n json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n },\n },\n {\n type: 'checkbox',\n input: true,\n weight: 27,\n key: 'readOnlyValue',\n label: 'Read Only Value',\n tooltip: 'Check this if you would like to show just the value when in Read Only mode.',\n },\n {\n type: 'textarea',\n as: 'json',\n editor: 'ace',\n weight: 28,\n input: true,\n key: 'customOptions',\n label: 'Choices.js options',\n tooltip: 'A raw JSON object to use as options for the Select component (Choices JS).',\n defaultValue: {},\n },\n {\n type: 'checkbox',\n input: true,\n weight: 29,\n key: 'useExactSearch',\n label: 'Use exact search',\n tooltip: 'Disables search algorithm threshold.',\n },\n {\n key: 'defaultValue',\n onSetItems(component) {\n setSelectData(component.evalContext());\n },\n onChange(context) {\n if (context && context.flags && context.flags.modified) {\n setSelectData(context);\n }\n },\n },\n {\n key: 'selectData',\n type: 'hidden',\n conditional: {\n json: {\n and: [\n { var: 'data.valueProperty' },\n { '===': [{ var: 'data.lazyLoad' }, true] },\n { '!==': [{ var: 'data.widget' }, 'html5'] },\n {\n or: [\n { '===': [{ var: 'data.dataSrc' }, 'url'] },\n {\n and: [\n { '===': [{ var: 'data.dataSrc' }, 'resource'] },\n // 'data' means entire object from resource will be used\n { '!==': [{ var: 'data.valueProperty' }, 'data'] },\n ],\n }\n ]\n }\n ]\n },\n },\n },\n {\n key: 'template',\n onChange(context) {\n if (context && context.flags && context.flags.modified) {\n const defaultValueComponent = context.instance.root.getComponent('defaultValue');\n if (!defaultValueComponent) {\n return;\n }\n setSelectData(defaultValueComponent.evalContext());\n }\n },\n },\n];\n\n\n//# sourceURL=webpack://Formio/./lib/cjs/components/select/editForm/Select.edit.data.js?");
|
7001
7001
|
|
7002
7002
|
/***/ }),
|
7003
7003
|
|