@formio/js 5.0.0-dev.5849.68c657d → 5.0.0-dev.5853.716ddda

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.
@@ -1319,14 +1319,14 @@ class WebformBuilder extends Component_1.default {
1319
1319
  this.hook('instanceOptionsPreview', instanceOptions);
1320
1320
  const instance = new ComponentClass(componentCopy, instanceOptions);
1321
1321
  const schema = this.hook('builderComponentSchema', component, instance);
1322
- this.editForm.setSubmission(isJsonEdit ? {
1322
+ this.editForm.submission = isJsonEdit ? {
1323
1323
  data: {
1324
1324
  componentJson: schema,
1325
1325
  showFullSchema: this.options.showFullJsonSchema
1326
1326
  },
1327
1327
  } : {
1328
1328
  data: instance.component,
1329
- }, { noValidate: true });
1329
+ };
1330
1330
  if (this.preview) {
1331
1331
  this.preview.destroy();
1332
1332
  }
@@ -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
  }
@@ -246,7 +246,11 @@ class SelectComponent extends ListComponent_1.default {
246
246
  const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;
247
247
  return this.sanitize(value, this.shouldSanitizeValue);
248
248
  }
249
- if (this.component.multiple && lodash_1.default.isArray(this.dataValue) ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val) : (this.dataValue === this.normalizeSingleValue(value))) {
249
+ // Inside DataTable component won't have dataValue set
250
+ const shouldUseSelectData = (this.component.multiple && lodash_1.default.isArray(this.dataValue)
251
+ ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val)
252
+ : (this.dataValue === this.normalizeSingleValue(value))) || this.inDataTable;
253
+ if (shouldUseSelectData) {
250
254
  const selectData = this.selectData;
251
255
  if (selectData) {
252
256
  const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
@@ -1213,7 +1217,7 @@ class SelectComponent extends ListComponent_1.default {
1213
1217
  // Check to see if we need to save off the template data into our metadata.
1214
1218
  const templateValue = this.component.reference && (value === null || value === void 0 ? void 0 : value._id) ? value._id.toString() : value;
1215
1219
  const shouldSaveData = !valueIsObject || this.component.reference;
1216
- if (templateValue && shouldSaveData && this.templateData && this.templateData[templateValue] && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submission)) {
1220
+ if (!lodash_1.default.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && ((_a = this.root) === null || _a === void 0 ? void 0 : _a.submission)) {
1217
1221
  const submission = this.root.submission;
1218
1222
  if (!submission.metadata) {
1219
1223
  submission.metadata = {};
@@ -1468,8 +1472,12 @@ class SelectComponent extends ListComponent_1.default {
1468
1472
  asString(value, options = {}) {
1469
1473
  var _a;
1470
1474
  value = value !== null && value !== void 0 ? value : this.getValue();
1471
- if (options.modalPreview) {
1472
- const template = this.itemTemplate(value, value);
1475
+ if (options.modalPreview || this.inDataTable) {
1476
+ if (this.inDataTable) {
1477
+ value = this.undoValueTyping(value);
1478
+ }
1479
+ const templateValue = (this.isEntireObjectDisplay() && !lodash_1.default.isObject(value.data)) ? { data: value } : value;
1480
+ const template = this.itemTemplate(templateValue, value, options);
1473
1481
  return template;
1474
1482
  }
1475
1483
  //need to convert values to strings to be able to compare values with available options that are strings
@@ -15,8 +15,8 @@ export const getComponentPath: typeof Utils.getComponentPath;
15
15
  export const isComponentNestedDataType: typeof Utils.isComponentNestedDataType;
16
16
  export const componentPath: typeof Utils.componentPath;
17
17
  export const componentChildPath: any;
18
- export const eachComponentDataAsync: (components: Component[], data: DataObject, fn: AsyncComponentDataCallback, path?: string | undefined, index?: number | undefined, parent?: any, includeAll?: boolean | undefined) => Promise<void>;
19
- export const eachComponentData: (components: Component[], data: DataObject, fn: ComponentDataCallback, path?: string | undefined, index?: number | undefined, parent?: any, includeAll?: boolean | undefined) => void;
18
+ export const eachComponentDataAsync: (components: Component[], data: DataObject, fn: EachComponentDataAsyncCallback, path?: string | undefined, index?: number | undefined, parent?: any, includeAll?: boolean | undefined) => Promise<void>;
19
+ export const eachComponentData: (components: Component[], data: DataObject, fn: EachComponentDataCallback, path?: string | undefined, index?: number | undefined, parent?: any, includeAll?: boolean | undefined) => void;
20
20
  export const getComponentKey: typeof Utils.getComponentKey;
21
21
  export const getContextualRowPath: typeof Utils.getContextualRowPath;
22
22
  export const getContextualRowData: typeof Utils.getContextualRowData;
@@ -1309,14 +1309,14 @@ export default class WebformBuilder extends Component {
1309
1309
  this.hook('instanceOptionsPreview', instanceOptions);
1310
1310
  const instance = new ComponentClass(componentCopy, instanceOptions);
1311
1311
  const schema = this.hook('builderComponentSchema', component, instance);
1312
- this.editForm.setSubmission(isJsonEdit ? {
1312
+ this.editForm.submission = isJsonEdit ? {
1313
1313
  data: {
1314
1314
  componentJson: schema,
1315
1315
  showFullSchema: this.options.showFullJsonSchema
1316
1316
  },
1317
1317
  } : {
1318
1318
  data: instance.component,
1319
- }, { noValidate: true });
1319
+ };
1320
1320
  if (this.preview) {
1321
1321
  this.preview.destroy();
1322
1322
  }
@@ -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
  }
@@ -246,7 +246,11 @@ export default class SelectComponent extends ListComponent {
246
246
  const value = (typeof itemLabel === 'string') ? this.t(itemLabel, { _userInput: true }) : itemLabel;
247
247
  return this.sanitize(value, this.shouldSanitizeValue);
248
248
  }
249
- if (this.component.multiple && _.isArray(this.dataValue) ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val) : (this.dataValue === this.normalizeSingleValue(value))) {
249
+ // Inside DataTable component won't have dataValue set
250
+ const shouldUseSelectData = (this.component.multiple && _.isArray(this.dataValue)
251
+ ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val)
252
+ : (this.dataValue === this.normalizeSingleValue(value))) || this.inDataTable;
253
+ if (shouldUseSelectData) {
250
254
  const selectData = this.selectData;
251
255
  if (selectData) {
252
256
  const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
@@ -1241,7 +1245,7 @@ export default class SelectComponent extends ListComponent {
1241
1245
  // Check to see if we need to save off the template data into our metadata.
1242
1246
  const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
1243
1247
  const shouldSaveData = !valueIsObject || this.component.reference;
1244
- if (templateValue && shouldSaveData && this.templateData && this.templateData[templateValue] && this.root?.submission) {
1248
+ if (!_.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && this.root?.submission) {
1245
1249
  const submission = this.root.submission;
1246
1250
  if (!submission.metadata) {
1247
1251
  submission.metadata = {};
@@ -1495,8 +1499,12 @@ export default class SelectComponent extends ListComponent {
1495
1499
  }
1496
1500
  asString(value, options = {}) {
1497
1501
  value = value ?? this.getValue();
1498
- if (options.modalPreview) {
1499
- const template = this.itemTemplate(value, value);
1502
+ if (options.modalPreview || this.inDataTable) {
1503
+ if (this.inDataTable) {
1504
+ value = this.undoValueTyping(value);
1505
+ }
1506
+ const templateValue = (this.isEntireObjectDisplay() && !_.isObject(value.data)) ? { data: value } : value;
1507
+ const template = this.itemTemplate(templateValue, value, options);
1500
1508
  return template;
1501
1509
  }
1502
1510
  //need to convert values to strings to be able to compare values with available options that are strings
@@ -15,8 +15,8 @@ export const getComponentPath: typeof Utils.getComponentPath;
15
15
  export const isComponentNestedDataType: typeof Utils.isComponentNestedDataType;
16
16
  export const componentPath: typeof Utils.componentPath;
17
17
  export const componentChildPath: any;
18
- export const eachComponentDataAsync: (components: Component[], data: DataObject, fn: AsyncComponentDataCallback, path?: string | undefined, index?: number | undefined, parent?: any, includeAll?: boolean | undefined) => Promise<void>;
19
- export const eachComponentData: (components: Component[], data: DataObject, fn: ComponentDataCallback, path?: string | undefined, index?: number | undefined, parent?: any, includeAll?: boolean | undefined) => void;
18
+ export const eachComponentDataAsync: (components: Component[], data: DataObject, fn: EachComponentDataAsyncCallback, path?: string | undefined, index?: number | undefined, parent?: any, includeAll?: boolean | undefined) => Promise<void>;
19
+ export const eachComponentData: (components: Component[], data: DataObject, fn: EachComponentDataCallback, path?: string | undefined, index?: number | undefined, parent?: any, includeAll?: boolean | undefined) => void;
20
20
  export const getComponentKey: typeof Utils.getComponentKey;
21
21
  export const getContextualRowPath: typeof Utils.getContextualRowPath;
22
22
  export const getContextualRowData: typeof Utils.getContextualRowData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5849.68c657d",
3
+ "version": "5.0.0-dev.5853.716ddda",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -82,7 +82,7 @@
82
82
  "dependencies": {
83
83
  "@formio/bootstrap": "3.0.0-dev.98.17ba6ea",
84
84
  "@formio/choices.js": "^10.2.1",
85
- "@formio/core": "v2.1.0-dev.156.78a83fd",
85
+ "@formio/core": "v2.1.0-dev.165.e6994a9",
86
86
  "@formio/text-mask-addons": "^3.8.0-formio.2",
87
87
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
88
88
  "abortcontroller-polyfill": "^1.7.5",