@formio/js 5.0.0-dev.5615.4672b8c → 5.0.0-dev.5620.dedc19b

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.
Files changed (37) hide show
  1. package/Changelog.md +4 -2
  2. package/dist/formio.form.js +17 -7
  3. package/dist/formio.form.min.js +1 -1
  4. package/dist/formio.form.min.js.LICENSE.txt +2 -0
  5. package/dist/formio.full.js +18 -8
  6. package/dist/formio.full.min.js +1 -1
  7. package/dist/formio.full.min.js.LICENSE.txt +2 -0
  8. package/dist/formio.utils.js +13 -3
  9. package/dist/formio.utils.min.js +1 -1
  10. package/dist/formio.utils.min.js.LICENSE.txt +2 -0
  11. package/lib/cjs/components/_classes/component/Component.js +2 -2
  12. package/lib/cjs/components/radio/Radio.d.ts +1 -1
  13. package/lib/cjs/components/radio/Radio.js +5 -3
  14. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.d.ts +5 -0
  15. package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +3 -0
  16. package/lib/cjs/components/select/Select.js +6 -1
  17. package/lib/cjs/components/select/fixtures/comp23.d.ts +47 -0
  18. package/lib/cjs/components/select/fixtures/comp23.js +40 -0
  19. package/lib/cjs/components/select/fixtures/index.d.ts +2 -1
  20. package/lib/cjs/components/select/fixtures/index.js +3 -1
  21. package/lib/cjs/components/selectboxes/SelectBoxes.js +4 -1
  22. package/lib/cjs/utils/utils.d.ts +6 -0
  23. package/lib/cjs/utils/utils.js +16 -2
  24. package/lib/mjs/components/_classes/component/Component.js +3 -3
  25. package/lib/mjs/components/radio/Radio.d.ts +1 -1
  26. package/lib/mjs/components/radio/Radio.js +5 -3
  27. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.d.ts +5 -0
  28. package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +3 -0
  29. package/lib/mjs/components/select/Select.js +6 -1
  30. package/lib/mjs/components/select/fixtures/comp23.d.ts +47 -0
  31. package/lib/mjs/components/select/fixtures/comp23.js +38 -0
  32. package/lib/mjs/components/select/fixtures/index.d.ts +2 -1
  33. package/lib/mjs/components/select/fixtures/index.js +2 -1
  34. package/lib/mjs/components/selectboxes/SelectBoxes.js +4 -1
  35. package/lib/mjs/utils/utils.d.ts +6 -0
  36. package/lib/mjs/utils/utils.js +13 -0
  37. package/package.json +2 -2
@@ -12,6 +12,8 @@
12
12
 
13
13
  /*! @license DOMPurify 3.1.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.0/LICENSE */
14
14
 
15
+ /*! @license DOMPurify 3.1.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.4/LICENSE */
16
+
15
17
  /*! formiojs v5.0.0-rc.43 | https://unpkg.com/formiojs@5.0.0-rc.43/LICENSE.txt */
16
18
 
17
19
  /**
@@ -3257,7 +3257,7 @@ Component.requireLibrary = function (name, property, src, polling) {
3257
3257
  }.bind(Component.externalLibraries[name]);
3258
3258
  }
3259
3259
  // See if the plugin already exists.
3260
- const plugin = lodash_1.default.get(window, property);
3260
+ const plugin = (0, utils_1.getScriptPlugin)(property);
3261
3261
  if (plugin) {
3262
3262
  Component.externalLibraries[name].resolve(plugin);
3263
3263
  }
@@ -3300,7 +3300,7 @@ Component.requireLibrary = function (name, property, src, polling) {
3300
3300
  // if no callback is provided, then check periodically for the script.
3301
3301
  if (polling) {
3302
3302
  setTimeout(function checkLibrary() {
3303
- const plugin = lodash_1.default.get(window, property);
3303
+ const plugin = (0, utils_1.getScriptPlugin)(property);
3304
3304
  if (plugin) {
3305
3305
  Component.externalLibraries[name].resolve(plugin);
3306
3306
  }
@@ -71,7 +71,7 @@ export default class RadioComponent extends ListComponent {
71
71
  detach(element: any): void;
72
72
  validateValueProperty(): boolean;
73
73
  validateValueAvailability(setting: any, value: any): boolean;
74
- getValueAsString(value: any): any;
74
+ getValueAsString(value: any, options?: {}): any;
75
75
  setValueAt(index: any, value: any): void;
76
76
  loadItems(url: any, search: any, headers: any, options: any, method: any, body: any): void;
77
77
  loadItemsFromMetadata(): void;
@@ -226,17 +226,19 @@ class RadioComponent extends ListComponent_1.default {
226
226
  }
227
227
  return false;
228
228
  }
229
- getValueAsString(value) {
229
+ getValueAsString(value, options = {}) {
230
230
  if (lodash_1.default.isObject(value)) {
231
231
  value = JSON.stringify(value);
232
232
  }
233
233
  else if (!lodash_1.default.isString(value)) {
234
234
  value = lodash_1.default.toString(value);
235
235
  }
236
- if (this.component.dataSrc !== 'values') {
236
+ const isModalPreviewWithUrlDataSource = options.modalPreview && this.component.dataSrc === 'url';
237
+ if (this.component.dataSrc !== 'values' && !isModalPreviewWithUrlDataSource) {
237
238
  return value;
238
239
  }
239
- const option = lodash_1.default.find(this.component.values, (v) => v.value === value);
240
+ const values = isModalPreviewWithUrlDataSource ? this.loadedOptions : this.component.values;
241
+ const option = lodash_1.default.find(values, (v) => v.value === value);
240
242
  if (!value) {
241
243
  return lodash_1.default.get(option, 'label', '');
242
244
  }
@@ -7,6 +7,9 @@ declare const _default: ({
7
7
  label: string;
8
8
  value: string;
9
9
  }[];
10
+ validate: {
11
+ required: boolean;
12
+ };
10
13
  weight: number;
11
14
  input?: undefined;
12
15
  dataSrc?: undefined;
@@ -28,6 +31,7 @@ declare const _default: ({
28
31
  custom(context: any): any[];
29
32
  };
30
33
  values?: undefined;
34
+ validate?: undefined;
31
35
  ignore?: undefined;
32
36
  } | {
33
37
  key: string;
@@ -36,6 +40,7 @@ declare const _default: ({
36
40
  tooltip?: undefined;
37
41
  type?: undefined;
38
42
  values?: undefined;
43
+ validate?: undefined;
39
44
  weight?: undefined;
40
45
  input?: undefined;
41
46
  dataSrc?: undefined;
@@ -17,6 +17,9 @@ exports.default = [
17
17
  value: 'buttonClick'
18
18
  }
19
19
  ],
20
+ validate: {
21
+ required: true
22
+ },
20
23
  weight: 650
21
24
  },
22
25
  {
@@ -228,9 +228,10 @@ class SelectComponent extends ListComponent_1.default {
228
228
  }
229
229
  selectValueAndLabel(data) {
230
230
  const value = this.getOptionValue((this.isEntireObjectDisplay() && !this.itemValue(data)) ? data : this.itemValue(data));
231
+ const readOnlyResourceLabelData = this.options.readOnly && (this.component.dataSrc === 'resource' || this.component.dataSrc === 'url') && this.selectData;
231
232
  return {
232
233
  value,
233
- label: this.itemTemplate((this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data)) ? { data: data } : data, value)
234
+ label: this.itemTemplate((this.isEntireObjectDisplay() && !lodash_1.default.isObject(data.data)) ? { data: data } : readOnlyResourceLabelData || data, value)
234
235
  };
235
236
  }
236
237
  itemTemplate(data, value) {
@@ -1470,6 +1471,10 @@ class SelectComponent extends ListComponent_1.default {
1470
1471
  asString(value, options = {}) {
1471
1472
  var _a;
1472
1473
  value = value !== null && value !== void 0 ? value : this.getValue();
1474
+ if (options.modalPreview && this.selectData) {
1475
+ const { label } = this.selectValueAndLabel(value);
1476
+ return label;
1477
+ }
1473
1478
  //need to convert values to strings to be able to compare values with available options that are strings
1474
1479
  const convertToString = (data, valueProperty) => {
1475
1480
  if (valueProperty) {
@@ -0,0 +1,47 @@
1
+ declare namespace _default {
2
+ let title: string;
3
+ let name: string;
4
+ let path: string;
5
+ let type: string;
6
+ let display: string;
7
+ let components: ({
8
+ label: string;
9
+ widget: string;
10
+ tableView: boolean;
11
+ dataSrc: string;
12
+ data: {
13
+ resource: string;
14
+ };
15
+ template: string;
16
+ validate: {
17
+ select: boolean;
18
+ };
19
+ key: string;
20
+ type: string;
21
+ searchField: string;
22
+ input: boolean;
23
+ noRefreshOnScroll: boolean;
24
+ addResource: boolean;
25
+ reference: boolean;
26
+ valueProperty: string;
27
+ disableOnInvalid?: undefined;
28
+ } | {
29
+ type: string;
30
+ label: string;
31
+ key: string;
32
+ disableOnInvalid: boolean;
33
+ input: boolean;
34
+ tableView: boolean;
35
+ widget?: undefined;
36
+ dataSrc?: undefined;
37
+ data?: undefined;
38
+ template?: undefined;
39
+ validate?: undefined;
40
+ searchField?: undefined;
41
+ noRefreshOnScroll?: undefined;
42
+ addResource?: undefined;
43
+ reference?: undefined;
44
+ valueProperty?: undefined;
45
+ })[];
46
+ }
47
+ export default _default;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ title: 'FIO-8234',
5
+ name: 'fio8234',
6
+ path: 'fio8234',
7
+ type: 'form',
8
+ display: 'form',
9
+ components: [
10
+ {
11
+ label: 'Select',
12
+ widget: 'choicesjs',
13
+ tableView: true,
14
+ dataSrc: 'resource',
15
+ data: {
16
+ resource: '665446284c9b0163c3e0c7e6',
17
+ },
18
+ template: '<span>{{ item.data.textField1 }}</span>',
19
+ validate: {
20
+ select: false,
21
+ },
22
+ key: 'select',
23
+ type: 'select',
24
+ searchField: 'data.textField2__regex',
25
+ input: true,
26
+ noRefreshOnScroll: false,
27
+ addResource: false,
28
+ reference: false,
29
+ valueProperty: 'data.textField2',
30
+ },
31
+ {
32
+ type: 'button',
33
+ label: 'Submit',
34
+ key: 'submit',
35
+ disableOnInvalid: true,
36
+ input: true,
37
+ tableView: false,
38
+ },
39
+ ],
40
+ };
@@ -19,5 +19,6 @@ import comp19 from './comp19';
19
19
  import comp20 from './comp20';
20
20
  import comp21 from './comp21';
21
21
  import comp22 from './comp22';
22
- export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, comp21, comp22 };
22
+ import comp23 from './comp23';
23
+ export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, comp21, comp22, comp23 };
23
24
  export { multiSelect, multiSelectOptions } from "./comp3";
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.comp22 = exports.comp21 = exports.comp20 = exports.comp19 = exports.comp18 = exports.comp17 = exports.comp16 = exports.comp15 = exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp2 = exports.comp1 = exports.multiSelectOptions = exports.multiSelect = void 0;
6
+ exports.comp23 = exports.comp22 = exports.comp21 = exports.comp20 = exports.comp19 = exports.comp18 = exports.comp17 = exports.comp16 = exports.comp15 = exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp2 = exports.comp1 = exports.multiSelectOptions = exports.multiSelect = void 0;
7
7
  const comp1_1 = __importDefault(require("./comp1"));
8
8
  exports.comp1 = comp1_1.default;
9
9
  const comp2_1 = __importDefault(require("./comp2"));
@@ -49,3 +49,5 @@ const comp21_1 = __importDefault(require("./comp21"));
49
49
  exports.comp21 = comp21_1.default;
50
50
  const comp22_1 = __importDefault(require("./comp22"));
51
51
  exports.comp22 = comp22_1.default;
52
+ const comp23_1 = __importDefault(require("./comp23"));
53
+ exports.comp23 = comp23_1.default;
@@ -164,11 +164,14 @@ class SelectBoxesComponent extends Radio_1.default {
164
164
  }
165
165
  return changed;
166
166
  }
167
- getValueAsString(value) {
167
+ getValueAsString(value, options = {}) {
168
168
  if (!value) {
169
169
  return '';
170
170
  }
171
171
  if (this.isSelectURL) {
172
+ if (options.modalPreview && this.loadedOptions) {
173
+ return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
174
+ }
172
175
  return (0, lodash_1.default)(value).pickBy((val) => val).keys().join(', ');
173
176
  }
174
177
  return (0, lodash_1.default)(this.component.values || [])
@@ -27,6 +27,12 @@ export function getElementRect(element: any): {
27
27
  width: string;
28
28
  height: string;
29
29
  };
30
+ /**
31
+ * Get non HTMLElement property in the window object
32
+ * @param {String} property
33
+ * @return {any || undefined}
34
+ */
35
+ export function getScriptPlugin(property: string): any;
30
36
  /**
31
37
  * Determines the boolean value of a setting.
32
38
  *
@@ -30,8 +30,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
30
30
  return (mod && mod.__esModule) ? mod : { "default": mod };
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.observeOverload = exports.withSwitch = exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.convertFormatToMoment = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.momentDate = exports.loadZones = exports.shouldLoadZones = exports.zonesLoaded = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = exports.moment = exports.ConditionOperators = exports.jsonLogic = void 0;
34
- exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = void 0;
33
+ exports.withSwitch = exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.convertFormatToMoment = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.momentDate = exports.loadZones = exports.shouldLoadZones = exports.zonesLoaded = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getScriptPlugin = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = exports.moment = exports.ConditionOperators = exports.jsonLogic = void 0;
34
+ exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = void 0;
35
35
  const lodash_1 = __importDefault(require("lodash"));
36
36
  exports._ = lodash_1.default;
37
37
  const fetch_ponyfill_1 = __importDefault(require("fetch-ponyfill"));
@@ -172,6 +172,20 @@ function getElementRect(element) {
172
172
  };
173
173
  }
174
174
  exports.getElementRect = getElementRect;
175
+ /**
176
+ * Get non HTMLElement property in the window object
177
+ * @param {String} property
178
+ * @return {any || undefined}
179
+ */
180
+ function getScriptPlugin(property) {
181
+ const obj = window[property];
182
+ if (typeof HTMLElement === 'object' ? obj instanceof HTMLElement : //DOM2
183
+ obj && typeof obj === 'object' && true && obj.nodeType === 1 && typeof obj.nodeName === 'string') {
184
+ return undefined;
185
+ }
186
+ return obj;
187
+ }
188
+ exports.getScriptPlugin = getScriptPlugin;
175
189
  /**
176
190
  * Determines the boolean value of a setting.
177
191
  *
@@ -6,7 +6,7 @@ import isMobile from 'ismobilejs';
6
6
  import { processOne, processOneSync, validateProcessInfo } from '@formio/core/process';
7
7
  import { Formio } from '../../../Formio';
8
8
  import * as FormioUtils from '../../../utils/utils';
9
- import { fastCloneDeep, boolValue, getComponentPath, isInsideScopingComponent, currentTimezone } from '../../../utils/utils';
9
+ import { fastCloneDeep, boolValue, getComponentPath, isInsideScopingComponent, currentTimezone, getScriptPlugin } from '../../../utils/utils';
10
10
  import Element from '../../../Element';
11
11
  import ComponentModal from '../componentModal/ComponentModal';
12
12
  import Widgets from '../../../widgets';
@@ -3220,7 +3220,7 @@ Component.requireLibrary = function (name, property, src, polling) {
3220
3220
  }.bind(Component.externalLibraries[name]);
3221
3221
  }
3222
3222
  // See if the plugin already exists.
3223
- const plugin = _.get(window, property);
3223
+ const plugin = getScriptPlugin(property);
3224
3224
  if (plugin) {
3225
3225
  Component.externalLibraries[name].resolve(plugin);
3226
3226
  }
@@ -3263,7 +3263,7 @@ Component.requireLibrary = function (name, property, src, polling) {
3263
3263
  // if no callback is provided, then check periodically for the script.
3264
3264
  if (polling) {
3265
3265
  setTimeout(function checkLibrary() {
3266
- const plugin = _.get(window, property);
3266
+ const plugin = getScriptPlugin(property);
3267
3267
  if (plugin) {
3268
3268
  Component.externalLibraries[name].resolve(plugin);
3269
3269
  }
@@ -71,7 +71,7 @@ export default class RadioComponent extends ListComponent {
71
71
  detach(element: any): void;
72
72
  validateValueProperty(): boolean;
73
73
  validateValueAvailability(setting: any, value: any): boolean;
74
- getValueAsString(value: any): any;
74
+ getValueAsString(value: any, options?: {}): any;
75
75
  setValueAt(index: any, value: any): void;
76
76
  loadItems(url: any, search: any, headers: any, options: any, method: any, body: any): void;
77
77
  loadItemsFromMetadata(): void;
@@ -226,17 +226,19 @@ export default class RadioComponent extends ListComponent {
226
226
  }
227
227
  return false;
228
228
  }
229
- getValueAsString(value) {
229
+ getValueAsString(value, options = {}) {
230
230
  if (_.isObject(value)) {
231
231
  value = JSON.stringify(value);
232
232
  }
233
233
  else if (!_.isString(value)) {
234
234
  value = _.toString(value);
235
235
  }
236
- if (this.component.dataSrc !== 'values') {
236
+ const isModalPreviewWithUrlDataSource = options.modalPreview && this.component.dataSrc === 'url';
237
+ if (this.component.dataSrc !== 'values' && !isModalPreviewWithUrlDataSource) {
237
238
  return value;
238
239
  }
239
- const option = _.find(this.component.values, (v) => v.value === value);
240
+ const values = isModalPreviewWithUrlDataSource ? this.loadedOptions : this.component.values;
241
+ const option = _.find(values, (v) => v.value === value);
240
242
  if (!value) {
241
243
  return _.get(option, 'label', '');
242
244
  }
@@ -7,6 +7,9 @@ declare const _default: ({
7
7
  label: string;
8
8
  value: string;
9
9
  }[];
10
+ validate: {
11
+ required: boolean;
12
+ };
10
13
  weight: number;
11
14
  input?: undefined;
12
15
  dataSrc?: undefined;
@@ -28,6 +31,7 @@ declare const _default: ({
28
31
  custom(context: any): any[];
29
32
  };
30
33
  values?: undefined;
34
+ validate?: undefined;
31
35
  ignore?: undefined;
32
36
  } | {
33
37
  key: string;
@@ -36,6 +40,7 @@ declare const _default: ({
36
40
  tooltip?: undefined;
37
41
  type?: undefined;
38
42
  values?: undefined;
43
+ validate?: undefined;
39
44
  weight?: undefined;
40
45
  input?: undefined;
41
46
  dataSrc?: undefined;
@@ -15,6 +15,9 @@ export default [
15
15
  value: 'buttonClick'
16
16
  }
17
17
  ],
18
+ validate: {
19
+ required: true
20
+ },
18
21
  weight: 650
19
22
  },
20
23
  {
@@ -226,9 +226,10 @@ export default class SelectComponent extends ListComponent {
226
226
  }
227
227
  selectValueAndLabel(data) {
228
228
  const value = this.getOptionValue((this.isEntireObjectDisplay() && !this.itemValue(data)) ? data : this.itemValue(data));
229
+ const readOnlyResourceLabelData = this.options.readOnly && (this.component.dataSrc === 'resource' || this.component.dataSrc === 'url') && this.selectData;
229
230
  return {
230
231
  value,
231
- label: this.itemTemplate((this.isEntireObjectDisplay() && !_.isObject(data.data)) ? { data: data } : data, value)
232
+ label: this.itemTemplate((this.isEntireObjectDisplay() && !_.isObject(data.data)) ? { data: data } : readOnlyResourceLabelData || data, value)
232
233
  };
233
234
  }
234
235
  itemTemplate(data, value) {
@@ -1495,6 +1496,10 @@ export default class SelectComponent extends ListComponent {
1495
1496
  }
1496
1497
  asString(value, options = {}) {
1497
1498
  value = value ?? this.getValue();
1499
+ if (options.modalPreview && this.selectData) {
1500
+ const { label } = this.selectValueAndLabel(value);
1501
+ return label;
1502
+ }
1498
1503
  //need to convert values to strings to be able to compare values with available options that are strings
1499
1504
  const convertToString = (data, valueProperty) => {
1500
1505
  if (valueProperty) {
@@ -0,0 +1,47 @@
1
+ declare namespace _default {
2
+ let title: string;
3
+ let name: string;
4
+ let path: string;
5
+ let type: string;
6
+ let display: string;
7
+ let components: ({
8
+ label: string;
9
+ widget: string;
10
+ tableView: boolean;
11
+ dataSrc: string;
12
+ data: {
13
+ resource: string;
14
+ };
15
+ template: string;
16
+ validate: {
17
+ select: boolean;
18
+ };
19
+ key: string;
20
+ type: string;
21
+ searchField: string;
22
+ input: boolean;
23
+ noRefreshOnScroll: boolean;
24
+ addResource: boolean;
25
+ reference: boolean;
26
+ valueProperty: string;
27
+ disableOnInvalid?: undefined;
28
+ } | {
29
+ type: string;
30
+ label: string;
31
+ key: string;
32
+ disableOnInvalid: boolean;
33
+ input: boolean;
34
+ tableView: boolean;
35
+ widget?: undefined;
36
+ dataSrc?: undefined;
37
+ data?: undefined;
38
+ template?: undefined;
39
+ validate?: undefined;
40
+ searchField?: undefined;
41
+ noRefreshOnScroll?: undefined;
42
+ addResource?: undefined;
43
+ reference?: undefined;
44
+ valueProperty?: undefined;
45
+ })[];
46
+ }
47
+ export default _default;
@@ -0,0 +1,38 @@
1
+ export default {
2
+ title: 'FIO-8234',
3
+ name: 'fio8234',
4
+ path: 'fio8234',
5
+ type: 'form',
6
+ display: 'form',
7
+ components: [
8
+ {
9
+ label: 'Select',
10
+ widget: 'choicesjs',
11
+ tableView: true,
12
+ dataSrc: 'resource',
13
+ data: {
14
+ resource: '665446284c9b0163c3e0c7e6',
15
+ },
16
+ template: '<span>{{ item.data.textField1 }}</span>',
17
+ validate: {
18
+ select: false,
19
+ },
20
+ key: 'select',
21
+ type: 'select',
22
+ searchField: 'data.textField2__regex',
23
+ input: true,
24
+ noRefreshOnScroll: false,
25
+ addResource: false,
26
+ reference: false,
27
+ valueProperty: 'data.textField2',
28
+ },
29
+ {
30
+ type: 'button',
31
+ label: 'Submit',
32
+ key: 'submit',
33
+ disableOnInvalid: true,
34
+ input: true,
35
+ tableView: false,
36
+ },
37
+ ],
38
+ };
@@ -19,5 +19,6 @@ import comp19 from './comp19';
19
19
  import comp20 from './comp20';
20
20
  import comp21 from './comp21';
21
21
  import comp22 from './comp22';
22
- export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, comp21, comp22 };
22
+ import comp23 from './comp23';
23
+ export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, comp21, comp22, comp23 };
23
24
  export { multiSelect, multiSelectOptions } from "./comp3";
@@ -20,4 +20,5 @@ import comp19 from './comp19';
20
20
  import comp20 from './comp20';
21
21
  import comp21 from './comp21';
22
22
  import comp22 from './comp22';
23
- export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, comp21, comp22 };
23
+ import comp23 from './comp23';
24
+ export { comp1, comp2, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, comp15, comp16, comp17, comp18, comp19, comp20, comp21, comp22, comp23 };
@@ -162,11 +162,14 @@ export default class SelectBoxesComponent extends RadioComponent {
162
162
  }
163
163
  return changed;
164
164
  }
165
- getValueAsString(value) {
165
+ getValueAsString(value, options = {}) {
166
166
  if (!value) {
167
167
  return '';
168
168
  }
169
169
  if (this.isSelectURL) {
170
+ if (options.modalPreview && this.loadedOptions) {
171
+ return this.loadedOptions.filter((option) => value[option.value]).map((option) => option.label).join(', ');
172
+ }
170
173
  return _(value).pickBy((val) => val).keys().join(', ');
171
174
  }
172
175
  return _(this.component.values || [])
@@ -27,6 +27,12 @@ export function getElementRect(element: any): {
27
27
  width: string;
28
28
  height: string;
29
29
  };
30
+ /**
31
+ * Get non HTMLElement property in the window object
32
+ * @param {String} property
33
+ * @return {any || undefined}
34
+ */
35
+ export function getScriptPlugin(property: string): any;
30
36
  /**
31
37
  * Determines the boolean value of a setting.
32
38
  *
@@ -131,6 +131,19 @@ export function getElementRect(element) {
131
131
  height: getPropertyValue(style, 'height')
132
132
  };
133
133
  }
134
+ /**
135
+ * Get non HTMLElement property in the window object
136
+ * @param {String} property
137
+ * @return {any || undefined}
138
+ */
139
+ export function getScriptPlugin(property) {
140
+ const obj = window[property];
141
+ if (typeof HTMLElement === 'object' ? obj instanceof HTMLElement : //DOM2
142
+ obj && typeof obj === 'object' && true && obj.nodeType === 1 && typeof obj.nodeName === 'string') {
143
+ return undefined;
144
+ }
145
+ return obj;
146
+ }
134
147
  /**
135
148
  * Determines the boolean value of a setting.
136
149
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5615.4672b8c",
3
+ "version": "5.0.0-dev.5620.dedc19b",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -89,7 +89,7 @@
89
89
  "core-js": "^3.37.0",
90
90
  "dialog-polyfill": "^0.5.6",
91
91
  "dom-autoscroller": "^2.3.4",
92
- "dompurify": "^3.1.0",
92
+ "dompurify": "^3.1.1",
93
93
  "downloadjs": "^1.4.7",
94
94
  "dragula": "^3.7.3",
95
95
  "eventemitter3": "^5.0.1",