@formio/js 5.1.0-dev.5982.b1aad89 → 5.1.0-dev.5984.de9f6d7

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/lib/cjs/Form.js CHANGED
@@ -281,7 +281,9 @@ class Form extends Element_1.default {
281
281
  this.form.display = display;
282
282
  this.instance.destroy();
283
283
  this.instance = this.create(display);
284
- return this.setForm(this.form);
284
+ return this.setForm(this.form).then(() => {
285
+ this.instance.emit('setDisplay', this.form.display);
286
+ });
285
287
  }
286
288
  empty() {
287
289
  if (this.element) {
@@ -218,7 +218,7 @@ class AddressComponent extends Container_1.default {
218
218
  super.dataValue = value;
219
219
  }
220
220
  get dataValue() {
221
- const resultValue = lodash_1.default.get(this._data, this.component.path);
221
+ const resultValue = lodash_1.default.get(this._data, this.path);
222
222
  if (!lodash_1.default.isArray(resultValue) && this.component.multiple) {
223
223
  return [resultValue];
224
224
  }
@@ -93,6 +93,8 @@ class CalendarWidget extends InputWidget_1.default {
93
93
  this.settings.disableWeekends ? this.settings.disable.push(this.disableWeekends) : '';
94
94
  this.settings.disableWeekdays ? this.settings.disable.push(this.disableWeekdays) : '';
95
95
  this.settings.disableFunction ? this.settings.disable.push(this.disableFunction) : '';
96
+ this.settings.wasDefaultValueChanged = false;
97
+ this.settings.defaultValue = '';
96
98
  this.settings.manualInputValue = '';
97
99
  this.settings.isManuallyOverriddenValue = false;
98
100
  this.settings.currentValue = '';
@@ -113,6 +115,10 @@ class CalendarWidget extends InputWidget_1.default {
113
115
  this.calendar._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
114
116
  this.emit('update');
115
117
  }
118
+ if (this.settings.wasDefaultValueChanged) {
119
+ this.calendar._input.value = this.settings.defaultValue;
120
+ this.settings.wasDefaultValueChanged = false;
121
+ }
116
122
  if (this.calendar) {
117
123
  this.emit('blur');
118
124
  }
@@ -354,6 +360,14 @@ class CalendarWidget extends InputWidget_1.default {
354
360
  this.settings.currentValue = event.target.value;
355
361
  this.emit('update');
356
362
  }
363
+ if (event.target.value === '' && this.calendar.selectedDates.length > 0) {
364
+ this.settings.wasDefaultValueChanged = true;
365
+ this.settings.defaultValue = event.target.value;
366
+ this.calendar.clear();
367
+ }
368
+ else {
369
+ this.settings.wasDefaultValueChanged = false;
370
+ }
357
371
  });
358
372
  if (this.calendar.daysContainer) {
359
373
  this.calendar.daysContainer.addEventListener('click', () => {
package/lib/mjs/Form.js CHANGED
@@ -350,7 +350,9 @@ export default class Form extends Element {
350
350
  this.form.display = display;
351
351
  this.instance.destroy();
352
352
  this.instance = this.create(display);
353
- return this.setForm(this.form);
353
+ return this.setForm(this.form).then(() => {
354
+ this.instance.emit('setDisplay', this.form.display);
355
+ });
354
356
  }
355
357
  empty() {
356
358
  if (this.element) {
@@ -214,7 +214,7 @@ export default class AddressComponent extends ContainerComponent {
214
214
  super.dataValue = value;
215
215
  }
216
216
  get dataValue() {
217
- const resultValue = _.get(this._data, this.component.path);
217
+ const resultValue = _.get(this._data, this.path);
218
218
  if (!_.isArray(resultValue) && this.component.multiple) {
219
219
  return [resultValue];
220
220
  }
@@ -87,6 +87,8 @@ export default class CalendarWidget extends InputWidget {
87
87
  this.settings.disableWeekends ? this.settings.disable.push(this.disableWeekends) : '';
88
88
  this.settings.disableWeekdays ? this.settings.disable.push(this.disableWeekdays) : '';
89
89
  this.settings.disableFunction ? this.settings.disable.push(this.disableFunction) : '';
90
+ this.settings.wasDefaultValueChanged = false;
91
+ this.settings.defaultValue = '';
90
92
  this.settings.manualInputValue = '';
91
93
  this.settings.isManuallyOverriddenValue = false;
92
94
  this.settings.currentValue = '';
@@ -107,6 +109,10 @@ export default class CalendarWidget extends InputWidget {
107
109
  this.calendar._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
108
110
  this.emit('update');
109
111
  }
112
+ if (this.settings.wasDefaultValueChanged) {
113
+ this.calendar._input.value = this.settings.defaultValue;
114
+ this.settings.wasDefaultValueChanged = false;
115
+ }
110
116
  if (this.calendar) {
111
117
  this.emit('blur');
112
118
  }
@@ -345,6 +351,14 @@ export default class CalendarWidget extends InputWidget {
345
351
  this.settings.currentValue = event.target.value;
346
352
  this.emit('update');
347
353
  }
354
+ if (event.target.value === '' && this.calendar.selectedDates.length > 0) {
355
+ this.settings.wasDefaultValueChanged = true;
356
+ this.settings.defaultValue = event.target.value;
357
+ this.calendar.clear();
358
+ }
359
+ else {
360
+ this.settings.wasDefaultValueChanged = false;
361
+ }
348
362
  });
349
363
  if (this.calendar.daysContainer) {
350
364
  this.calendar.daysContainer.addEventListener('click', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.5982.b1aad89",
3
+ "version": "5.1.0-dev.5984.de9f6d7",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {