@formio/js 5.0.0-dev.5837.9b0fdec → 5.0.0-dev.5838.2779c5d

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Component_1 = __importDefault(require("./_classes/component/Component"));
7
7
  const utils_1 = __importDefault(require("./_classes/component/editForm/utils"));
8
8
  const Component_form_1 = __importDefault(require("./_classes/component/Component.form"));
9
+ const utils_2 = require("../utils/utils");
9
10
  const lodash_1 = __importDefault(require("lodash"));
10
11
  class Components {
11
12
  static set EditFormUtils(value) {
@@ -56,7 +57,8 @@ class Components {
56
57
  static getComponentPath(component) {
57
58
  var _a;
58
59
  let path = '';
59
- if (component.component.key) {
60
+ const componentKey = (0, utils_2.getComponentKey)(component.component);
61
+ if (componentKey) {
60
62
  let thisPath = ((_a = component.options) === null || _a === void 0 ? void 0 : _a.parent) || component;
61
63
  while (thisPath && !thisPath.allowData && thisPath.parent) {
62
64
  thisPath = thisPath.parent;
@@ -68,7 +70,7 @@ class Components {
68
70
  const rowIndex = component.row;
69
71
  const rowIndexPath = rowIndex && !['container'].includes(thisPath.component.type) ? `[${Number.parseInt(rowIndex)}]` : '';
70
72
  path = `${thisPath.path}${rowIndexPath}.`;
71
- path += component.component.key;
73
+ path += componentKey;
72
74
  return lodash_1.default.trim(path, '.');
73
75
  }
74
76
  return path;
@@ -2965,7 +2965,7 @@ class Component extends Element_1.default {
2965
2965
  if (this.options.alwaysDirty) {
2966
2966
  flags.dirty = true;
2967
2967
  }
2968
- if (flags.fromSubmission && this.hasValue(data)) {
2968
+ if (flags.fromSubmission && this.hasValue(data) && !(this.pristine && this.protected)) {
2969
2969
  flags.dirty = true;
2970
2970
  }
2971
2971
  this.setDirty(flags.dirty);
@@ -190,6 +190,7 @@ class ListComponent extends Field_1.default {
190
190
  return;
191
191
  }
192
192
  let { url } = this.component.data;
193
+ url = lodash_1.default.trim(url);
193
194
  let method;
194
195
  let body;
195
196
  if (url.startsWith('/')) {
@@ -214,6 +214,16 @@ class AddressComponent extends Container_1.default {
214
214
  isValueInLegacyFormat(value) {
215
215
  return value && !value.mode;
216
216
  }
217
+ set dataValue(value) {
218
+ super.dataValue = value;
219
+ }
220
+ get dataValue() {
221
+ const resultValue = lodash_1.default.get(this._data, this.component.path);
222
+ if (!lodash_1.default.isArray(resultValue) && this.component.multiple) {
223
+ return [resultValue];
224
+ }
225
+ return super.dataValue;
226
+ }
217
227
  normalizeValue(value) {
218
228
  return (this.manualModeEnabled && this.isValueInLegacyFormat(value))
219
229
  ? {
@@ -500,20 +500,26 @@ class DayComponent extends Field_1.default {
500
500
  day = parseInt(this.refs.day.value, 10);
501
501
  }
502
502
  if (day === undefined || lodash_1.default.isNaN(day)) {
503
- day = defaults[DAY] && !lodash_1.default.isNaN(defaults[DAY]) ? defaults[DAY] : 0;
503
+ day = (defaults.length !== 3 && value)
504
+ ? this.getDayWithHiddenFields(defaults).day
505
+ : (defaults[DAY] && !lodash_1.default.isNaN(defaults[DAY]) ? defaults[DAY] : 0);
504
506
  }
505
507
  if (this.showMonth && this.refs.month) {
506
508
  // Months are 0 indexed.
507
509
  month = parseInt(this.refs.month.value, 10);
508
510
  }
509
511
  if (month === undefined || lodash_1.default.isNaN(month)) {
510
- month = defaults[MONTH] && !lodash_1.default.isNaN(defaults[MONTH]) ? defaults[MONTH] : 0;
512
+ month = (defaults.length !== 3 && value)
513
+ ? this.getDayWithHiddenFields(defaults).month
514
+ : (defaults[MONTH] && !lodash_1.default.isNaN(defaults[MONTH]) ? defaults[MONTH] : 0);
511
515
  }
512
516
  if (this.showYear && this.refs.year) {
513
517
  year = parseInt(this.refs.year.value);
514
518
  }
515
519
  if (year === undefined || lodash_1.default.isNaN(year)) {
516
- year = defaults[YEAR] && !lodash_1.default.isNaN(defaults[YEAR]) ? defaults[YEAR] : 0;
520
+ year = (defaults.length !== 3 && value)
521
+ ? this.getDayWithHiddenFields(defaults).year
522
+ : (defaults[YEAR] && !lodash_1.default.isNaN(defaults[YEAR]) ? defaults[YEAR] : 0);
517
523
  }
518
524
  let result;
519
525
  if (!day && !month && !year) {
@@ -79,6 +79,14 @@ class RadioComponent extends ListComponent_1.default {
79
79
  }
80
80
  return defaultValue;
81
81
  }
82
+ resetValue() {
83
+ this.unset();
84
+ this.setValue(this.emptyValue, {
85
+ noUpdateEvent: true,
86
+ noValidate: true,
87
+ resetValue: true
88
+ });
89
+ }
82
90
  get inputInfo() {
83
91
  var _a;
84
92
  const info = super.elementInfo();
@@ -1,6 +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
5
  import _ from 'lodash';
5
6
  export default class Components {
6
7
  static _editFormUtils = EditFormUtils;
@@ -52,7 +53,8 @@ export default class Components {
52
53
  */
53
54
  static getComponentPath(component) {
54
55
  let path = '';
55
- if (component.component.key) {
56
+ const componentKey = getComponentKey(component.component);
57
+ if (componentKey) {
56
58
  let thisPath = component.options?.parent || component;
57
59
  while (thisPath && !thisPath.allowData && thisPath.parent) {
58
60
  thisPath = thisPath.parent;
@@ -64,7 +66,7 @@ export default class Components {
64
66
  const rowIndex = component.row;
65
67
  const rowIndexPath = rowIndex && !['container'].includes(thisPath.component.type) ? `[${Number.parseInt(rowIndex)}]` : '';
66
68
  path = `${thisPath.path}${rowIndexPath}.`;
67
- path += component.component.key;
69
+ path += componentKey;
68
70
  return _.trim(path, '.');
69
71
  }
70
72
  return path;
@@ -2929,7 +2929,7 @@ export default class Component extends Element {
2929
2929
  if (this.options.alwaysDirty) {
2930
2930
  flags.dirty = true;
2931
2931
  }
2932
- if (flags.fromSubmission && this.hasValue(data)) {
2932
+ if (flags.fromSubmission && this.hasValue(data) && !(this.pristine && this.protected)) {
2933
2933
  flags.dirty = true;
2934
2934
  }
2935
2935
  this.setDirty(flags.dirty);
@@ -185,6 +185,7 @@ export default class ListComponent extends Field {
185
185
  return;
186
186
  }
187
187
  let { url } = this.component.data;
188
+ url = _.trim(url);
188
189
  let method;
189
190
  let body;
190
191
  if (url.startsWith('/')) {
@@ -210,6 +210,16 @@ export default class AddressComponent extends ContainerComponent {
210
210
  isValueInLegacyFormat(value) {
211
211
  return value && !value.mode;
212
212
  }
213
+ set dataValue(value) {
214
+ super.dataValue = value;
215
+ }
216
+ get dataValue() {
217
+ const resultValue = _.get(this._data, this.component.path);
218
+ if (!_.isArray(resultValue) && this.component.multiple) {
219
+ return [resultValue];
220
+ }
221
+ return super.dataValue;
222
+ }
213
223
  normalizeValue(value) {
214
224
  return (this.manualModeEnabled && this.isValueInLegacyFormat(value))
215
225
  ? {
@@ -498,20 +498,26 @@ export default class DayComponent extends Field {
498
498
  day = parseInt(this.refs.day.value, 10);
499
499
  }
500
500
  if (day === undefined || _.isNaN(day)) {
501
- day = defaults[DAY] && !_.isNaN(defaults[DAY]) ? defaults[DAY] : 0;
501
+ day = (defaults.length !== 3 && value)
502
+ ? this.getDayWithHiddenFields(defaults).day
503
+ : (defaults[DAY] && !_.isNaN(defaults[DAY]) ? defaults[DAY] : 0);
502
504
  }
503
505
  if (this.showMonth && this.refs.month) {
504
506
  // Months are 0 indexed.
505
507
  month = parseInt(this.refs.month.value, 10);
506
508
  }
507
509
  if (month === undefined || _.isNaN(month)) {
508
- month = defaults[MONTH] && !_.isNaN(defaults[MONTH]) ? defaults[MONTH] : 0;
510
+ month = (defaults.length !== 3 && value)
511
+ ? this.getDayWithHiddenFields(defaults).month
512
+ : (defaults[MONTH] && !_.isNaN(defaults[MONTH]) ? defaults[MONTH] : 0);
509
513
  }
510
514
  if (this.showYear && this.refs.year) {
511
515
  year = parseInt(this.refs.year.value);
512
516
  }
513
517
  if (year === undefined || _.isNaN(year)) {
514
- year = defaults[YEAR] && !_.isNaN(defaults[YEAR]) ? defaults[YEAR] : 0;
518
+ year = (defaults.length !== 3 && value)
519
+ ? this.getDayWithHiddenFields(defaults).year
520
+ : (defaults[YEAR] && !_.isNaN(defaults[YEAR]) ? defaults[YEAR] : 0);
515
521
  }
516
522
  let result;
517
523
  if (!day && !month && !year) {
@@ -80,6 +80,14 @@ export default class RadioComponent extends ListComponent {
80
80
  }
81
81
  return defaultValue;
82
82
  }
83
+ resetValue() {
84
+ this.unset();
85
+ this.setValue(this.emptyValue, {
86
+ noUpdateEvent: true,
87
+ noValidate: true,
88
+ resetValue: true
89
+ });
90
+ }
83
91
  get inputInfo() {
84
92
  const info = super.elementInfo();
85
93
  info.type = 'input';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5837.9b0fdec",
3
+ "version": "5.0.0-dev.5838.2779c5d",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {