@formio/js 5.0.0-rc.90 → 5.0.0-rc.91

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@
20
20
 
21
21
  /*! @license DOMPurify 3.1.6 | (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.6/LICENSE */
22
22
 
23
- /*! formiojs v5.0.0-rc.90 | https://unpkg.com/formiojs@5.0.0-rc.90/LICENSE.txt */
23
+ /*! formiojs v5.0.0-rc.91 | https://unpkg.com/formiojs@5.0.0-rc.91/LICENSE.txt */
24
24
 
25
25
  /**
26
26
  * @license
@@ -70,6 +70,9 @@ class Components {
70
70
  const rowIndex = component.row;
71
71
  const rowIndexPath = rowIndex && !['container'].includes(thisPath.component.type) ? `[${Number.parseInt(rowIndex)}]` : '';
72
72
  path = `${thisPath.path}${rowIndexPath}.`;
73
+ if (rowIndexPath && (0, utils_2.getModelType)(thisPath) === 'nestedDataArray') {
74
+ path = `${path}data.`;
75
+ }
73
76
  path += componentKey;
74
77
  return lodash_1.default.trim(path, '.');
75
78
  }
@@ -2937,8 +2937,8 @@ class Component extends Element_1.default {
2937
2937
  if (this.options.alwaysDirty) {
2938
2938
  flags.dirty = true;
2939
2939
  }
2940
- if (flags.fromSubmission && this.hasValue(data) && !(this.pristine && this.protected)) {
2941
- flags.dirty = true;
2940
+ if (flags.fromSubmission && this.hasValue(data)) {
2941
+ flags.dirty = this.pristine && this.component.protected ? false : true;
2942
2942
  }
2943
2943
  this.setDirty(flags.dirty);
2944
2944
  return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission);
@@ -247,7 +247,11 @@ class SelectComponent extends ListComponent_1.default {
247
247
  const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;
248
248
  return this.sanitize(value, this.shouldSanitizeValue);
249
249
  }
250
- if (this.component.multiple && lodash_1.default.isArray(this.dataValue) ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val) : (this.dataValue === this.normalizeSingleValue(value))) {
250
+ // Inside DataTable component won't have dataValue set
251
+ const shouldUseSelectData = (this.component.multiple && lodash_1.default.isArray(this.dataValue)
252
+ ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val)
253
+ : (this.dataValue === this.normalizeSingleValue(value))) || this.inDataTable;
254
+ if (shouldUseSelectData) {
251
255
  const selectData = this.selectData;
252
256
  if (selectData) {
253
257
  const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
@@ -1214,7 +1218,7 @@ class SelectComponent extends ListComponent_1.default {
1214
1218
  // Check to see if we need to save off the template data into our metadata.
1215
1219
  const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
1216
1220
  const shouldSaveData = !valueIsObject || this.component.reference;
1217
- if (templateValue && shouldSaveData && this.templateData && this.templateData[templateValue] && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submission)) {
1221
+ if (!lodash_1.default.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submission)) {
1218
1222
  const submission = this.root.submission;
1219
1223
  if (!submission.metadata) {
1220
1224
  submission.metadata = {};
@@ -1469,8 +1473,12 @@ class SelectComponent extends ListComponent_1.default {
1469
1473
  asString(value, options = {}) {
1470
1474
  var _a;
1471
1475
  value = value !== null && value !== void 0 ? value : this.getValue();
1472
- if (options.modalPreview) {
1473
- const template = this.itemTemplate(value, value);
1476
+ if (options.modalPreview || this.inDataTable) {
1477
+ if (this.inDataTable) {
1478
+ value = this.undoValueTyping(value);
1479
+ }
1480
+ const templateValue = (this.isEntireObjectDisplay() && !lodash_1.default.isObject(value.data)) ? { data: value } : value;
1481
+ const template = this.itemTemplate(templateValue, value, options);
1474
1482
  return template;
1475
1483
  }
1476
1484
  //need to convert values to strings to be able to compare values with available options that are strings
@@ -1,7 +1,7 @@
1
1
  import Component from './_classes/component/Component';
2
2
  import EditFormUtils from './_classes/component/editForm/utils';
3
3
  import BaseEditForm from './_classes/component/Component.form';
4
- import { getComponentKey } from '../utils/utils';
4
+ import { getComponentKey, getModelType } from '../utils/utils';
5
5
  import _ from 'lodash';
6
6
  export default class Components {
7
7
  static _editFormUtils = EditFormUtils;
@@ -66,6 +66,9 @@ export default class Components {
66
66
  const rowIndex = component.row;
67
67
  const rowIndexPath = rowIndex && !['container'].includes(thisPath.component.type) ? `[${Number.parseInt(rowIndex)}]` : '';
68
68
  path = `${thisPath.path}${rowIndexPath}.`;
69
+ if (rowIndexPath && getModelType(thisPath) === 'nestedDataArray') {
70
+ path = `${path}data.`;
71
+ }
69
72
  path += componentKey;
70
73
  return _.trim(path, '.');
71
74
  }
@@ -2904,8 +2904,8 @@ export default class Component extends Element {
2904
2904
  if (this.options.alwaysDirty) {
2905
2905
  flags.dirty = true;
2906
2906
  }
2907
- if (flags.fromSubmission && this.hasValue(data) && !(this.pristine && this.protected)) {
2908
- flags.dirty = true;
2907
+ if (flags.fromSubmission && this.hasValue(data)) {
2908
+ flags.dirty = this.pristine && this.component.protected ? false : true;
2909
2909
  }
2910
2910
  this.setDirty(flags.dirty);
2911
2911
  return this.setComponentValidity(errors, flags.dirty, flags.silentCheck, flags.fromSubmission);
@@ -247,7 +247,11 @@ export default class SelectComponent extends ListComponent {
247
247
  const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;
248
248
  return this.sanitize(value, this.shouldSanitizeValue);
249
249
  }
250
- if (this.component.multiple && _.isArray(this.dataValue) ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val) : (this.dataValue === this.normalizeSingleValue(value))) {
250
+ // Inside DataTable component won't have dataValue set
251
+ const shouldUseSelectData = (this.component.multiple && _.isArray(this.dataValue)
252
+ ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val)
253
+ : (this.dataValue === this.normalizeSingleValue(value))) || this.inDataTable;
254
+ if (shouldUseSelectData) {
251
255
  const selectData = this.selectData;
252
256
  if (selectData) {
253
257
  const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
@@ -1242,7 +1246,7 @@ export default class SelectComponent extends ListComponent {
1242
1246
  // Check to see if we need to save off the template data into our metadata.
1243
1247
  const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
1244
1248
  const shouldSaveData = !valueIsObject || this.component.reference;
1245
- if (templateValue && shouldSaveData && this.templateData && this.templateData[templateValue] && this.root?.submission) {
1249
+ if (!_.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && this.root?.submission) {
1246
1250
  const submission = this.root.submission;
1247
1251
  if (!submission.metadata) {
1248
1252
  submission.metadata = {};
@@ -1496,8 +1500,12 @@ export default class SelectComponent extends ListComponent {
1496
1500
  }
1497
1501
  asString(value, options = {}) {
1498
1502
  value = value ?? this.getValue();
1499
- if (options.modalPreview) {
1500
- const template = this.itemTemplate(value, value);
1503
+ if (options.modalPreview || this.inDataTable) {
1504
+ if (this.inDataTable) {
1505
+ value = this.undoValueTyping(value);
1506
+ }
1507
+ const templateValue = (this.isEntireObjectDisplay() && !_.isObject(value.data)) ? { data: value } : value;
1508
+ const template = this.itemTemplate(templateValue, value, options);
1501
1509
  return template;
1502
1510
  }
1503
1511
  //need to convert values to strings to be able to compare values with available options that are strings
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-rc.90",
3
+ "version": "5.0.0-rc.91",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -79,9 +79,9 @@
79
79
  },
80
80
  "homepage": "https://github.com/formio/formio.js#readme",
81
81
  "dependencies": {
82
- "@formio/bootstrap": "3.0.0-rc.37",
82
+ "@formio/bootstrap": "3.0.0-rc.38",
83
83
  "@formio/choices.js": "^10.2.1",
84
- "@formio/core": "2.3.0-rc.9",
84
+ "@formio/core": "2.3.0-rc.10",
85
85
  "@formio/text-mask-addons": "^3.8.0-formio.2",
86
86
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
87
87
  "abortcontroller-polyfill": "^1.7.5",