@formio/js 5.1.0-dev.6094.c49181e → 5.1.0-dev.6102.8eddaab
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/dist/formio.form.js +84 -117
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +90 -123
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +33 -44
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +44 -66
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Element.js +13 -36
- package/lib/cjs/EventEmitter.js +2 -25
- package/lib/cjs/Form.js +2 -25
- package/lib/cjs/PDF.js +1 -1
- package/lib/cjs/PDFBuilder.js +4 -5
- package/lib/cjs/Webform.js +5 -6
- package/lib/cjs/WebformBuilder.d.ts +1 -0
- package/lib/cjs/WebformBuilder.js +22 -9
- package/lib/cjs/Wizard.js +1 -1
- package/lib/cjs/WizardBuilder.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
- package/lib/cjs/components/_classes/component/Component.js +29 -53
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -1
- package/lib/cjs/components/_classes/input/Input.js +1 -1
- package/lib/cjs/components/_classes/list/ListComponent.js +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +6 -6
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
- package/lib/cjs/components/address/Address.js +1 -1
- package/lib/cjs/components/alert/Alert.js +1 -1
- package/lib/cjs/components/button/Button.d.ts +1 -1
- package/lib/cjs/components/button/Button.js +4 -4
- package/lib/cjs/components/checkbox/Checkbox.js +1 -1
- package/lib/cjs/components/container/Container.js +1 -1
- package/lib/cjs/components/currency/Currency.js +1 -1
- package/lib/cjs/components/datagrid/DataGrid.js +1 -1
- package/lib/cjs/components/datamap/DataMap.d.ts +1 -1
- package/lib/cjs/components/datamap/DataMap.js +4 -4
- package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/cjs/components/datetime/DateTime.js +13 -15
- package/lib/cjs/components/day/Day.js +1 -1
- package/lib/cjs/components/editgrid/EditGrid.js +1 -1
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/cjs/components/file/File.js +1 -1
- package/lib/cjs/components/form/Form.js +1 -1
- package/lib/cjs/components/number/Number.js +1 -1
- package/lib/cjs/components/panel/Panel.js +1 -1
- package/lib/cjs/components/radio/Radio.js +1 -1
- package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/cjs/components/select/Select.js +1 -1
- package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
- package/lib/cjs/components/signature/Signature.js +1 -1
- package/lib/cjs/components/survey/Survey.js +1 -1
- package/lib/cjs/components/tags/Tags.js +1 -1
- package/lib/cjs/components/textarea/TextArea.js +3 -3
- package/lib/cjs/components/textfield/TextField.js +7 -30
- package/lib/cjs/components/time/Time.js +1 -1
- package/lib/cjs/formio.form.js +3 -3
- package/lib/cjs/i18n.js +1 -1
- package/lib/cjs/providers/storage/uploadAdapter.js +1 -1
- package/lib/cjs/utils/Evaluator.d.ts +13 -6
- package/lib/cjs/utils/Evaluator.js +27 -15
- package/lib/cjs/utils/builder.js +5 -5
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
- package/lib/cjs/utils/i18n.js +3 -3
- package/lib/cjs/utils/index.d.ts +160 -2
- package/lib/cjs/utils/index.js +12 -2
- package/lib/cjs/utils/utils.d.ts +28 -23
- package/lib/cjs/utils/utils.js +91 -89
- package/lib/cjs/widgets/CalendarWidget.d.ts +7 -0
- package/lib/cjs/widgets/CalendarWidget.js +37 -13
- package/lib/mjs/Element.js +6 -6
- package/lib/mjs/EventEmitter.js +2 -2
- package/lib/mjs/Form.js +1 -1
- package/lib/mjs/PDF.js +1 -1
- package/lib/mjs/PDFBuilder.js +1 -2
- package/lib/mjs/Webform.js +3 -4
- package/lib/mjs/WebformBuilder.d.ts +1 -0
- package/lib/mjs/WebformBuilder.js +14 -2
- package/lib/mjs/Wizard.js +1 -1
- package/lib/mjs/WizardBuilder.js +1 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
- package/lib/mjs/components/_classes/component/Component.js +2 -3
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -1
- package/lib/mjs/components/_classes/input/Input.js +1 -1
- package/lib/mjs/components/_classes/list/ListComponent.js +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +6 -6
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
- package/lib/mjs/components/address/Address.js +1 -1
- package/lib/mjs/components/alert/Alert.js +1 -1
- package/lib/mjs/components/button/Button.d.ts +1 -1
- package/lib/mjs/components/button/Button.js +1 -1
- package/lib/mjs/components/checkbox/Checkbox.js +1 -1
- package/lib/mjs/components/container/Container.js +1 -1
- package/lib/mjs/components/currency/Currency.js +1 -1
- package/lib/mjs/components/datagrid/DataGrid.js +1 -1
- package/lib/mjs/components/datamap/DataMap.d.ts +1 -1
- package/lib/mjs/components/datamap/DataMap.js +1 -1
- package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/mjs/components/datetime/DateTime.js +13 -15
- package/lib/mjs/components/day/Day.js +1 -1
- package/lib/mjs/components/editgrid/EditGrid.js +1 -1
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/mjs/components/file/File.js +1 -1
- package/lib/mjs/components/form/Form.js +1 -1
- package/lib/mjs/components/number/Number.js +1 -1
- package/lib/mjs/components/panel/Panel.js +1 -1
- package/lib/mjs/components/radio/Radio.js +1 -1
- package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/mjs/components/select/Select.js +1 -1
- package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/lib/mjs/components/survey/Survey.js +1 -1
- package/lib/mjs/components/tags/Tags.js +1 -1
- package/lib/mjs/components/textarea/TextArea.js +3 -3
- package/lib/mjs/components/textfield/TextField.js +1 -1
- package/lib/mjs/components/time/Time.js +1 -1
- package/lib/mjs/formio.form.js +2 -2
- package/lib/mjs/i18n.js +1 -1
- package/lib/mjs/providers/storage/uploadAdapter.js +1 -1
- package/lib/mjs/utils/Evaluator.d.ts +13 -6
- package/lib/mjs/utils/Evaluator.js +21 -13
- package/lib/mjs/utils/builder.js +1 -1
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
- package/lib/mjs/utils/i18n.js +1 -1
- package/lib/mjs/utils/index.d.ts +160 -2
- package/lib/mjs/utils/index.js +11 -1
- package/lib/mjs/utils/utils.d.ts +28 -23
- package/lib/mjs/utils/utils.js +83 -67
- package/lib/mjs/widgets/CalendarWidget.d.ts +7 -0
- package/lib/mjs/widgets/CalendarWidget.js +37 -13
- package/package.json +2 -3
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const Formio_1 = require("../Formio");
|
7
7
|
const InputWidget_1 = __importDefault(require("./InputWidget"));
|
8
|
-
const utils_1 = require("../utils
|
8
|
+
const utils_1 = require("../utils");
|
9
9
|
const moment_1 = __importDefault(require("moment"));
|
10
10
|
const lodash_1 = __importDefault(require("lodash"));
|
11
11
|
const DEFAULT_FORMAT = 'yyyy-MM-dd hh:mm a';
|
@@ -51,6 +51,29 @@ class CalendarWidget extends InputWidget_1.default {
|
|
51
51
|
else if (this.settings.time_24hr) {
|
52
52
|
this.settings.format = this.settings.format.replace(/hh:mm a$/g, 'HH:mm');
|
53
53
|
}
|
54
|
+
this.zoneLoading = false;
|
55
|
+
this.timezonesUrl = `${Formio_1.Formio.cdn['moment-timezone']}/data/packed/latest.json`;
|
56
|
+
}
|
57
|
+
/**
|
58
|
+
* Load the timezones.
|
59
|
+
* @returns {boolean} TRUE if the zones are loading, FALSE otherwise.
|
60
|
+
*/
|
61
|
+
loadZones() {
|
62
|
+
const timezone = this.timezone;
|
63
|
+
if (this.zoneLoading) {
|
64
|
+
return true;
|
65
|
+
}
|
66
|
+
if (!(0, utils_1.zonesLoaded)() && (0, utils_1.shouldLoadZones)(timezone)) {
|
67
|
+
this.zoneLoading = true;
|
68
|
+
(0, utils_1.loadZones)(this.timezonesUrl, timezone).then(() => {
|
69
|
+
this.zoneLoading = false;
|
70
|
+
this.emit('redraw');
|
71
|
+
});
|
72
|
+
// Return zones are loading.
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
// Zones are already loaded.
|
76
|
+
return false;
|
54
77
|
}
|
55
78
|
attach(input) {
|
56
79
|
var _a;
|
@@ -62,7 +85,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
62
85
|
};
|
63
86
|
this.closedOn = 0;
|
64
87
|
this.valueFormat = (this.settings.saveAs === 'date') ? ISO_8601_FORMAT : this.settings.dateFormat || ISO_8601_FORMAT;
|
65
|
-
this.valueMomentFormat = (0, utils_1.
|
88
|
+
this.valueMomentFormat = (0, utils_1.convertFormatToMoment)(this.valueFormat);
|
66
89
|
const isReadOnly = this.settings.readOnly;
|
67
90
|
this.settings.minDate = isReadOnly ? null : (0, utils_1.getDateSetting)(this.settings.minDate);
|
68
91
|
this.settings.maxDate = isReadOnly ? null : (0, utils_1.getDateSetting)(this.settings.maxDate);
|
@@ -226,9 +249,9 @@ class CalendarWidget extends InputWidget_1.default {
|
|
226
249
|
*/
|
227
250
|
getDateValue(date, format, useTimezone) {
|
228
251
|
if (useTimezone) {
|
229
|
-
return (0, utils_1.
|
252
|
+
return (0, utils_1.momentDate)(date, this.valueFormat, this.timezone).format((0, utils_1.convertFormatToMoment)(format));
|
230
253
|
}
|
231
|
-
return (0, moment_1.default)(date).format((0, utils_1.
|
254
|
+
return (0, moment_1.default)(date).format((0, utils_1.convertFormatToMoment)(format));
|
232
255
|
}
|
233
256
|
/**
|
234
257
|
* Return the value of the selected date.
|
@@ -260,7 +283,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
260
283
|
setValue(value) {
|
261
284
|
const saveAsText = (this.settings.saveAs === 'text');
|
262
285
|
if (!this.calendar) {
|
263
|
-
value = value ? (0, utils_1.formatDate)(value, (0, utils_1.
|
286
|
+
value = value ? (0, utils_1.formatDate)(this.timezonesUrl, value, (0, utils_1.convertFormatToMoment)(this.settings.format), this.timezone, (0, utils_1.convertFormatToMoment)(this.valueMomentFormat)) : value;
|
264
287
|
return super.setValue(value);
|
265
288
|
}
|
266
289
|
// If the component is a textfield that does not have timezone information included in the string value then skip
|
@@ -268,9 +291,10 @@ class CalendarWidget extends InputWidget_1.default {
|
|
268
291
|
if (this.component.type === 'textfield' && !(0, utils_1.hasEncodedTimezone)(value)) {
|
269
292
|
this.settings.skipOffset = true;
|
270
293
|
}
|
294
|
+
const zonesLoading = this.loadZones();
|
271
295
|
if (value) {
|
272
|
-
if (!saveAsText && this.settings.readOnly) {
|
273
|
-
this.calendar.setDate((0, utils_1.
|
296
|
+
if (!saveAsText && this.settings.readOnly && !zonesLoading) {
|
297
|
+
this.calendar.setDate((0, utils_1.momentDate)(value, this.valueFormat, this.timezone).format(), false);
|
274
298
|
}
|
275
299
|
else if (this.isValueISO8601(value)) {
|
276
300
|
this.calendar.setDate(value, false);
|
@@ -287,9 +311,9 @@ class CalendarWidget extends InputWidget_1.default {
|
|
287
311
|
const inputFormat = format || this.dateFormat;
|
288
312
|
const valueFormat = this.calendar ? this.valueFormat : this.settings.dateFormat;
|
289
313
|
if (this.settings.saveAs === 'text' && this.componentInstance.parent && !this.settings.readOnly) {
|
290
|
-
return (0, moment_1.default)(value, (0, utils_1.
|
314
|
+
return (0, moment_1.default)(value, (0, utils_1.convertFormatToMoment)(valueFormat)).format((0, utils_1.convertFormatToMoment)(valueFormat));
|
291
315
|
}
|
292
|
-
return (0, utils_1.formatDate)(value, inputFormat, this.timezone, (0, utils_1.
|
316
|
+
return (0, utils_1.formatDate)(this.timezonesUrl, value, inputFormat, this.timezone, (0, utils_1.convertFormatToMoment)(valueFormat));
|
293
317
|
}
|
294
318
|
setErrorClasses(hasErrors) {
|
295
319
|
if (!this.input) {
|
@@ -382,7 +406,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
382
406
|
const relatedTarget = event.relatedTarget ? event.relatedTarget : activeElement;
|
383
407
|
if (!(isIEBrowser && !relatedTarget) && !this.isCalendarElement(relatedTarget)) {
|
384
408
|
const inputValue = this.calendar.input.value;
|
385
|
-
const dateValue = inputValue ? (0, moment_1.default)(this.calendar.input.value, (0, utils_1.
|
409
|
+
const dateValue = inputValue ? (0, moment_1.default)(this.calendar.input.value, (0, utils_1.convertFormatToMoment)(this.valueFormat)).toDate() : inputValue;
|
386
410
|
this.calendar.setDate(dateValue, true, this.settings.altFormat);
|
387
411
|
}
|
388
412
|
else if (!this.calendar.input.value && this.calendar.config.noCalendar) {
|
@@ -434,14 +458,14 @@ class CalendarWidget extends InputWidget_1.default {
|
|
434
458
|
return (date, format) => {
|
435
459
|
// Only format this if this is the altFormat and the form is readOnly.
|
436
460
|
if (this.settings.readOnly && (format === this.settings.altFormat)) {
|
437
|
-
if (!this.settings.enableTime || this.settings.skipOffset) {
|
461
|
+
if (!this.settings.enableTime || this.loadZones() || this.settings.skipOffset) {
|
438
462
|
return Flatpickr.formatDate(date, format);
|
439
463
|
}
|
440
464
|
const currentValue = new Date(this.getValue());
|
441
465
|
if (currentValue.toString() === date.toString()) {
|
442
|
-
return (0, utils_1.formatOffset)(Flatpickr.formatDate.bind(Flatpickr), new Date(this.componentValue), format, this.timezone);
|
466
|
+
return (0, utils_1.formatOffset)(this.timezonesUrl, Flatpickr.formatDate.bind(Flatpickr), new Date(this.componentValue), format, this.timezone);
|
443
467
|
}
|
444
|
-
return (0, utils_1.formatOffset)(Flatpickr.formatDate.bind(Flatpickr), date, format, this.timezone);
|
468
|
+
return (0, utils_1.formatOffset)(this.timezonesUrl, Flatpickr.formatDate.bind(Flatpickr), date, format, this.timezone);
|
445
469
|
}
|
446
470
|
return Flatpickr.formatDate(date, format);
|
447
471
|
};
|
package/lib/mjs/Element.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
import EventEmitter from './EventEmitter';
|
2
|
-
import { Formio } from './Formio';
|
3
|
-
import * as FormioUtils from './utils/utils';
|
4
|
-
import { I18n } from './utils/i18n';
|
5
1
|
import _ from 'lodash';
|
6
2
|
import moment from 'moment';
|
7
3
|
import maskInput from '@formio/vanilla-text-mask';
|
4
|
+
import EventEmitter from './EventEmitter';
|
5
|
+
import { Formio } from './Formio';
|
6
|
+
import { I18n } from './utils/i18n';
|
7
|
+
import FormioUtils from './utils';
|
8
8
|
/**
|
9
9
|
* The root component for all elements within the Form.io renderer.
|
10
10
|
*/
|
@@ -523,9 +523,9 @@ export default class Element {
|
|
523
523
|
if (this.component.filter === string && !this.options.building) {
|
524
524
|
const evalContext = this.evalContext(data);
|
525
525
|
evalContext.data = _.mapValues(evalContext.data, (val) => _.isString(val) ? encodeURIComponent(val) : val);
|
526
|
-
return FormioUtils.interpolate(string, evalContext, options);
|
526
|
+
return FormioUtils.Evaluator.interpolate(string, evalContext, options);
|
527
527
|
}
|
528
|
-
return FormioUtils.interpolate(string, this.evalContext(data), options);
|
528
|
+
return FormioUtils.Evaluator.interpolate(string, this.evalContext(data), options);
|
529
529
|
}
|
530
530
|
/**
|
531
531
|
* Performs an evaluation using the evaluation context of this component.
|
package/lib/mjs/EventEmitter.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { EventEmitter as EventEmitter3 } from 'eventemitter3';
|
2
|
-
import
|
2
|
+
import { observeOverload } from './utils';
|
3
3
|
export default class EventEmitter extends EventEmitter3 {
|
4
4
|
constructor(conf = {}) {
|
5
5
|
const { loadLimit = 1000, eventsSafeInterval = 300 } = conf;
|
@@ -7,7 +7,7 @@ export default class EventEmitter extends EventEmitter3 {
|
|
7
7
|
const overloadHandler = () => {
|
8
8
|
console.warn(`There were more than ${loadLimit} events emitted in ${eventsSafeInterval} ms. It might be caused by events' infinite loop`, this.id);
|
9
9
|
};
|
10
|
-
const dispatch =
|
10
|
+
const dispatch = observeOverload(overloadHandler, {
|
11
11
|
limit: loadLimit,
|
12
12
|
delay: eventsSafeInterval
|
13
13
|
});
|
package/lib/mjs/Form.js
CHANGED
@@ -2,7 +2,7 @@ import Element from './Element';
|
|
2
2
|
import { Formio } from './Formio';
|
3
3
|
import Displays from './displays';
|
4
4
|
import templates from './templates';
|
5
|
-
import
|
5
|
+
import FormioUtils from './utils';
|
6
6
|
export default class Form extends Element {
|
7
7
|
/**
|
8
8
|
* Represents a JSON value.
|
package/lib/mjs/PDF.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Formio } from './Formio';
|
2
2
|
import Webform from './Webform';
|
3
|
-
import { fastCloneDeep, eachComponent } from './utils
|
3
|
+
import { fastCloneDeep, eachComponent } from './utils';
|
4
4
|
export default class PDF extends Webform {
|
5
5
|
constructor(element, options) {
|
6
6
|
options.display = 'pdf';
|
package/lib/mjs/PDFBuilder.js
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import { Formio } from './Formio';
|
3
3
|
import WebformBuilder from './WebformBuilder';
|
4
|
-
import { fastCloneDeep, getElementRect, getBrowserInfo } from './utils
|
5
|
-
import { eachComponent } from './utils/formUtils';
|
4
|
+
import { fastCloneDeep, getElementRect, getBrowserInfo, eachComponent } from './utils';
|
6
5
|
import BuilderUtils from './utils/builder';
|
7
6
|
import PDF from './PDF';
|
8
7
|
export default class PDFBuilder extends WebformBuilder {
|
package/lib/mjs/Webform.js
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
import _ from 'lodash';
|
2
|
+
import moment from 'moment';
|
2
3
|
import { compareVersions } from 'compare-versions';
|
3
4
|
import EventEmitter from './EventEmitter';
|
4
5
|
import i18nDefaults from './i18n';
|
5
6
|
import { Formio } from './Formio';
|
6
7
|
import Components from './components/Components';
|
7
8
|
import NestedDataComponent from './components/_classes/nesteddata/NestedDataComponent';
|
8
|
-
import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, } from './utils
|
9
|
-
import { eachComponent } from './utils/formUtils';
|
10
|
-
import dayjs from "dayjs";
|
9
|
+
import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, eachComponent } from './utils';
|
11
10
|
// We need this here because dragula pulls in CustomEvent class that requires global to exist.
|
12
11
|
if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
|
13
12
|
window.global = window;
|
@@ -1317,7 +1316,7 @@ export default class Webform extends NestedDataComponent {
|
|
1317
1316
|
submission.metadata = submission.metadata || {};
|
1318
1317
|
_.defaults(submission.metadata, {
|
1319
1318
|
timezone: _.get(this, '_submission.metadata.timezone', currentTimezone()),
|
1320
|
-
offset: parseInt(_.get(this, '_submission.metadata.offset',
|
1319
|
+
offset: parseInt(_.get(this, '_submission.metadata.offset', moment().utcOffset()), 10),
|
1321
1320
|
origin: document.location.origin,
|
1322
1321
|
referrer: document.referrer,
|
1323
1322
|
browserName: navigator.appName,
|
@@ -77,6 +77,7 @@ export default class WebformBuilder extends Component {
|
|
77
77
|
removeComponent(component: any, parent: any, original: any, componentInstance: any): boolean | undefined;
|
78
78
|
replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
|
79
79
|
updateComponent(component: any, changed: any): void;
|
80
|
+
originalDefaultValue: any;
|
80
81
|
findRepeatablePaths(): any[];
|
81
82
|
highlightInvalidComponents(): void;
|
82
83
|
/**
|
@@ -3,8 +3,7 @@ import Component from './components/_classes/component/Component';
|
|
3
3
|
import tippy from 'tippy.js';
|
4
4
|
import Components from './components/Components';
|
5
5
|
import { Formio } from './Formio';
|
6
|
-
import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath } from './utils
|
7
|
-
import { eachComponent, getComponent } from './utils/formUtils';
|
6
|
+
import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath, eachComponent, getComponent, } from './utils';
|
8
7
|
import BuilderUtils from './utils/builder';
|
9
8
|
import _ from 'lodash';
|
10
9
|
import autoScroll from 'dom-autoscroller';
|
@@ -1054,6 +1053,16 @@ export default class WebformBuilder extends Component {
|
|
1054
1053
|
'fields.month.required',
|
1055
1054
|
'fields.year.required',
|
1056
1055
|
]));
|
1056
|
+
if (defaultValueComponent.component.components) {
|
1057
|
+
if (!this.originalDefaultValue) {
|
1058
|
+
this.originalDefaultValue = fastCloneDeep(defaultValueComponent.component);
|
1059
|
+
}
|
1060
|
+
eachComponent(defaultValueComponent.component.components, (comp => {
|
1061
|
+
if (comp.validate?.required) {
|
1062
|
+
comp.validate.required = false;
|
1063
|
+
}
|
1064
|
+
}));
|
1065
|
+
}
|
1057
1066
|
const parentComponent = defaultValueComponent.parent;
|
1058
1067
|
let tabIndex = -1;
|
1059
1068
|
let index = -1;
|
@@ -1145,6 +1154,9 @@ export default class WebformBuilder extends Component {
|
|
1145
1154
|
if (index !== -1) {
|
1146
1155
|
let submissionData = this.editForm.submission.data;
|
1147
1156
|
submissionData = submissionData.componentJson || submissionData;
|
1157
|
+
if (submissionData.components && this.originalDefaultValue) {
|
1158
|
+
submissionData.components = this.originalDefaultValue.components;
|
1159
|
+
}
|
1148
1160
|
const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
|
1149
1161
|
this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
|
1150
1162
|
this.hook('beforeSaveComponentSettings', submissionData);
|
package/lib/mjs/Wizard.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import Webform from './Webform';
|
3
3
|
import { Formio } from './Formio';
|
4
|
-
import { fastCloneDeep, checkCondition, firstNonNil, uniqueKey, eachComponent, } from './utils
|
4
|
+
import { fastCloneDeep, checkCondition, firstNonNil, uniqueKey, eachComponent, } from './utils';
|
5
5
|
export default class Wizard extends Webform {
|
6
6
|
/**
|
7
7
|
* Constructor for wizard-based forms.
|
package/lib/mjs/WizardBuilder.js
CHANGED
@@ -2,7 +2,7 @@ import WebformBuilder from './WebformBuilder';
|
|
2
2
|
import Webform from './Webform';
|
3
3
|
import BuilderUtils from './utils/builder';
|
4
4
|
import _ from 'lodash';
|
5
|
-
import { fastCloneDeep } from './utils
|
5
|
+
import { fastCloneDeep } from './utils';
|
6
6
|
export default class WizardBuilder extends WebformBuilder {
|
7
7
|
constructor() {
|
8
8
|
let element, options;
|
@@ -165,7 +165,6 @@ declare class Component extends Element {
|
|
165
165
|
get componentsMap(): object;
|
166
166
|
/**
|
167
167
|
* Returns if the parent should conditionally clear.
|
168
|
-
*
|
169
168
|
* @returns {boolean} - If the parent should conditionally clear.
|
170
169
|
*/
|
171
170
|
parentShouldConditionallyClear(): boolean;
|
@@ -5,8 +5,8 @@ import _ from 'lodash';
|
|
5
5
|
import isMobile from 'ismobilejs';
|
6
6
|
import { processOne, processOneSync, validateProcessInfo } from '@formio/core/process';
|
7
7
|
import { Formio } from '../../../Formio';
|
8
|
-
import
|
9
|
-
import { fastCloneDeep, boolValue, currentTimezone, getScriptPlugin, getContextualRowData } from '../../../utils
|
8
|
+
import FormioUtils from '../../../utils';
|
9
|
+
import { fastCloneDeep, boolValue, currentTimezone, getScriptPlugin, getContextualRowData } from '../../../utils';
|
10
10
|
import Element from '../../../Element';
|
11
11
|
import ComponentModal from '../componentModal/ComponentModal';
|
12
12
|
import Widgets from '../../../widgets';
|
@@ -424,7 +424,6 @@ export default class Component extends Element {
|
|
424
424
|
}
|
425
425
|
/**
|
426
426
|
* Returns if the parent should conditionally clear.
|
427
|
-
*
|
428
427
|
* @returns {boolean} - If the parent should conditionally clear.
|
429
428
|
*/
|
430
429
|
parentShouldConditionallyClear() {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import _ from 'lodash';
|
2
|
-
import { fastCloneDeep } from '../../../utils
|
2
|
+
import { fastCloneDeep } from '../../../utils';
|
3
3
|
export default class ComponentModal {
|
4
4
|
static render(component, data, topLevel) {
|
5
5
|
const children = component.renderTemplate('component', data, topLevel);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import Multivalue from '../multivalue/Multivalue';
|
2
|
-
import { convertStringToHTMLElement } from '../../../utils
|
2
|
+
import { convertStringToHTMLElement } from '../../../utils';
|
3
3
|
import Widgets from '../../../widgets';
|
4
4
|
import _ from 'lodash';
|
5
5
|
export default class Input extends Multivalue {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import Field from '../field/Field';
|
2
2
|
import { Formio } from '../../../Formio';
|
3
3
|
import _ from 'lodash';
|
4
|
-
import { getItemTemplateKeys } from '../../../utils
|
4
|
+
import { getItemTemplateKeys } from '../../../utils';
|
5
5
|
export default class ListComponent extends Field {
|
6
6
|
static schema(...extend) {
|
7
7
|
return Field.schema({
|
@@ -3,7 +3,7 @@ import _ from 'lodash';
|
|
3
3
|
import Field from '../field/Field';
|
4
4
|
import Components from '../../Components';
|
5
5
|
'';
|
6
|
-
import
|
6
|
+
import FormioUtils from '../../../utils';
|
7
7
|
import { process as processAsync, processSync } from '@formio/core/process';
|
8
8
|
/**
|
9
9
|
* NestedComponent class.
|
@@ -204,7 +204,7 @@ export default class NestedComponent extends Field {
|
|
204
204
|
*/
|
205
205
|
set rowIndex(value) {
|
206
206
|
this._rowIndex = value;
|
207
|
-
this.paths = getComponentPaths(this.component, this.parent?.component, {
|
207
|
+
this.paths = FormioUtils.getComponentPaths(this.component, this.parent?.component, {
|
208
208
|
...(this.parent?.paths || {}),
|
209
209
|
...{ dataIndex: value }
|
210
210
|
});
|
@@ -308,7 +308,7 @@ export default class NestedComponent extends Field {
|
|
308
308
|
* @returns {any} - The component that is located.
|
309
309
|
*/
|
310
310
|
getComponent(path) {
|
311
|
-
path = getStringFromComponentPath(path);
|
311
|
+
path = FormioUtils.getStringFromComponentPath(path);
|
312
312
|
const matches = {
|
313
313
|
path: undefined,
|
314
314
|
fullPath: undefined,
|
@@ -320,7 +320,7 @@ export default class NestedComponent extends Field {
|
|
320
320
|
};
|
321
321
|
this.everyComponent((component) => {
|
322
322
|
// All searches are relative to this component so replace this path from the child paths.
|
323
|
-
componentMatches(component.component, {
|
323
|
+
FormioUtils.componentMatches(component.component, {
|
324
324
|
path: component.paths?.path?.replace(new RegExp(`^${this.paths?.path}\\.?`), ''),
|
325
325
|
fullPath: component.paths?.fullPath?.replace(new RegExp(`^${this.paths?.fullPath}\\.?`), ''),
|
326
326
|
localPath: component.paths?.localPath?.replace(new RegExp(`^${this.paths?.localPath}\\.?`), ''),
|
@@ -332,7 +332,7 @@ export default class NestedComponent extends Field {
|
|
332
332
|
return match;
|
333
333
|
});
|
334
334
|
});
|
335
|
-
return getBestMatch(matches)?.instance;
|
335
|
+
return FormioUtils.getBestMatch(matches)?.instance;
|
336
336
|
}
|
337
337
|
/**
|
338
338
|
* Return a component provided the Id of the component.
|
@@ -374,7 +374,7 @@ export default class NestedComponent extends Field {
|
|
374
374
|
options.localRoot = this.localRoot;
|
375
375
|
options.skipInit = true;
|
376
376
|
if (!(options.display === 'pdf' && this.builderMode)) {
|
377
|
-
component.id = getRandomComponentId();
|
377
|
+
component.id = FormioUtils.getRandomComponentId();
|
378
378
|
}
|
379
379
|
const comp = Components.create(component, options, data, true);
|
380
380
|
comp.init();
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import _ from 'lodash';
|
3
3
|
import { Utils } from '@formio/core/utils';
|
4
4
|
const { getComponentPaths } = Utils;
|
5
|
-
import { componentValueTypes, isLayoutComponent } from '../../../utils
|
5
|
+
import { componentValueTypes, isLayoutComponent } from '../../../utils';
|
6
6
|
import Component from '../component/Component';
|
7
7
|
import NestedDataComponent from '../nesteddata/NestedDataComponent';
|
8
8
|
export default class NestedArrayComponent extends NestedDataComponent {
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import Component from '../component/Component';
|
3
3
|
import NestedComponent from '../nested/NestedComponent';
|
4
4
|
import _ from 'lodash';
|
5
|
-
import { componentValueTypes, getComponentSavedTypes } from '../../../utils
|
5
|
+
import { componentValueTypes, getComponentSavedTypes } from '../../../utils';
|
6
6
|
export default class NestedDataComponent extends NestedComponent {
|
7
7
|
hasChanged(newValue, oldValue) {
|
8
8
|
// If we do not have a value and are getting set to anything other than undefined or null, then we changed.
|
@@ -5,7 +5,7 @@ import { GoogleAddressProvider } from '../../providers/address/GoogleAddressProv
|
|
5
5
|
import Field from '../_classes/field/Field';
|
6
6
|
import NestedComponent from '../_classes/nested/NestedComponent';
|
7
7
|
import ContainerComponent from '../container/Container';
|
8
|
-
import { componentValueTypes, getComponentSavedTypes } from '../../utils
|
8
|
+
import { componentValueTypes, getComponentSavedTypes } from '../../utils';
|
9
9
|
export const AddressComponentMode = {
|
10
10
|
Autocomplete: 'autocomplete',
|
11
11
|
Manual: 'manual',
|
@@ -7,7 +7,7 @@ export default class ButtonComponent extends Field {
|
|
7
7
|
weight: number;
|
8
8
|
schema: any;
|
9
9
|
};
|
10
|
-
static savedValueTypes(schema: any):
|
10
|
+
static savedValueTypes(schema: any): any;
|
11
11
|
constructor(component: any, options: any, data: any);
|
12
12
|
filesUploading: any[];
|
13
13
|
get inputInfo(): any;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import Field from '../_classes/field/Field';
|
3
3
|
import Input from '../_classes/input/Input';
|
4
|
-
import { componentValueTypes, eachComponent, getArrayFromComponentPath, getComponentSavedTypes } from '../../utils/
|
4
|
+
import { componentValueTypes, eachComponent, getArrayFromComponentPath, getComponentSavedTypes } from '../../utils/formUtils';
|
5
5
|
export default class ButtonComponent extends Field {
|
6
6
|
static schema(...extend) {
|
7
7
|
return Input.schema({
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import _ from 'lodash';
|
2
|
-
import { componentValueTypes, getComponentSavedTypes } from '../../utils
|
2
|
+
import { componentValueTypes, getComponentSavedTypes } from '../../utils';
|
3
3
|
import Field from '../_classes/field/Field';
|
4
4
|
export default class CheckBoxComponent extends Field {
|
5
5
|
static schema(...extend) {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import _ from 'lodash';
|
2
|
-
import { componentValueTypes, getComponentSavedTypes, getFocusableElements } from '../../utils
|
2
|
+
import { componentValueTypes, getComponentSavedTypes, getFocusableElements } from '../../utils';
|
3
3
|
import Component from '../_classes/component/Component';
|
4
4
|
import Field from '../_classes/field/Field';
|
5
5
|
import NestedDataComponent from '../_classes/nesteddata/NestedDataComponent';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { createNumberMask } from '@formio/text-mask-addons';
|
2
2
|
import { maskInput } from '@formio/vanilla-text-mask';
|
3
3
|
import _ from 'lodash';
|
4
|
-
import { getCurrencyAffixes } from '../../utils
|
4
|
+
import { getCurrencyAffixes } from '../../utils';
|
5
5
|
import NumberComponent from '../number/Number';
|
6
6
|
export default class CurrencyComponent extends NumberComponent {
|
7
7
|
static schema(...extend) {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
|
3
|
-
import { fastCloneDeep, getFocusableElements } from '../../utils
|
3
|
+
import { fastCloneDeep, getFocusableElements } from '../../utils';
|
4
4
|
export default class DataGridComponent extends NestedArrayComponent {
|
5
5
|
static schema(...extend) {
|
6
6
|
return NestedArrayComponent.schema({
|
@@ -2,7 +2,7 @@ import Component from '../_classes/component/Component';
|
|
2
2
|
import DataGridComponent from '../datagrid/DataGrid';
|
3
3
|
import _ from 'lodash';
|
4
4
|
import EventEmitter from 'eventemitter3';
|
5
|
-
import { componentValueTypes, getComponentSavedTypes, uniqueKey } from '../../utils/
|
5
|
+
import { componentValueTypes, getComponentSavedTypes, uniqueKey } from '../../utils/formUtils';
|
6
6
|
export default class DataMapComponent extends DataGridComponent {
|
7
7
|
static schema(...extend) {
|
8
8
|
return Component.schema({
|
@@ -17,7 +17,7 @@ export default class DateTimeComponent extends Input {
|
|
17
17
|
};
|
18
18
|
static savedValueTypes(schema: any): string[];
|
19
19
|
get emptyValue(): string;
|
20
|
-
get
|
20
|
+
get momentFormat(): string;
|
21
21
|
createWrapper(): boolean;
|
22
22
|
checkValidity(data: any, dirty: any, rowData: any): boolean;
|
23
23
|
getValueAsString(value: any, options: any): any;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _ from 'lodash';
|
2
|
-
import
|
2
|
+
import moment from 'moment';
|
3
3
|
import FormioUtils from '../../utils';
|
4
|
-
import { componentValueTypes, fastCloneDeep, getComponentSavedTypes } from '../../utils
|
4
|
+
import { componentValueTypes, fastCloneDeep, getComponentSavedTypes } from '../../utils';
|
5
5
|
import Input from '../_classes/input/Input';
|
6
6
|
export default class DateTimeComponent extends Input {
|
7
7
|
static schema(...extend) {
|
@@ -147,8 +147,8 @@ export default class DateTimeComponent extends Input {
|
|
147
147
|
get emptyValue() {
|
148
148
|
return '';
|
149
149
|
}
|
150
|
-
get
|
151
|
-
return FormioUtils.
|
150
|
+
get momentFormat() {
|
151
|
+
return FormioUtils.convertFormatToMoment(this.component.format);
|
152
152
|
}
|
153
153
|
isEmpty(value = this.dataValue) {
|
154
154
|
if (value && (value.toString() === 'Invalid Date')) {
|
@@ -157,14 +157,12 @@ export default class DateTimeComponent extends Input {
|
|
157
157
|
return super.isEmpty(value);
|
158
158
|
}
|
159
159
|
formatValue(input) {
|
160
|
-
|
161
|
-
|
162
|
-
}
|
163
|
-
return input;
|
160
|
+
const result = moment.utc(input).toISOString();
|
161
|
+
return result === 'Invalid date' ? input : result;
|
164
162
|
}
|
165
163
|
isEqual(valueA, valueB = this.dataValue) {
|
166
164
|
return (this.isEmpty(valueA) && this.isEmpty(valueB))
|
167
|
-
||
|
165
|
+
|| moment.utc(valueA).format(this.momentFormat) === moment.utc(valueB).format(this.momentFormat);
|
168
166
|
}
|
169
167
|
createWrapper() {
|
170
168
|
return false;
|
@@ -180,18 +178,18 @@ export default class DateTimeComponent extends Input {
|
|
180
178
|
return super.checkValidity(data, dirty, rowData);
|
181
179
|
}
|
182
180
|
getValueAsString(value, options) {
|
183
|
-
let format = FormioUtils.
|
181
|
+
let format = FormioUtils.convertFormatToMoment(this.component.format);
|
182
|
+
format += format.match(/z$/) ? '' : ' z';
|
184
183
|
const timezone = this.timezone;
|
185
184
|
if (value && !this.attached && timezone) {
|
186
|
-
format += format.match(/z$/) ? '' : ' z';
|
187
185
|
if (Array.isArray(value) && this.component.multiple) {
|
188
|
-
return value.map(item => _.trim(FormioUtils.
|
186
|
+
return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone, options).format(format))).join(', ');
|
189
187
|
}
|
190
|
-
return _.trim(FormioUtils.
|
188
|
+
return _.trim(FormioUtils.momentDate(value, format, timezone, options).format(format));
|
191
189
|
}
|
192
190
|
if (Array.isArray(value) && this.component.multiple) {
|
193
|
-
return value.map(item => _.trim(
|
191
|
+
return value.map(item => _.trim(moment(item).format(format))).join(', ');
|
194
192
|
}
|
195
|
-
return (value ? _.trim(
|
193
|
+
return (value ? _.trim(moment(value).format(format)) : value) || '';
|
196
194
|
}
|
197
195
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import moment from 'moment';
|
3
3
|
import Field from '../_classes/field/Field';
|
4
|
-
import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils
|
4
|
+
import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils';
|
5
5
|
import { getDayFormat } from '@formio/core';
|
6
6
|
export default class DayComponent extends Field {
|
7
7
|
static schema(...extend) {
|
@@ -4,7 +4,7 @@ import { editgrid as templates } from '@formio/bootstrap/components';
|
|
4
4
|
import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
|
5
5
|
import Component from '../_classes/component/Component';
|
6
6
|
import Alert from '../alert/Alert';
|
7
|
-
import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent } from '../../utils
|
7
|
+
import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent } from '../../utils';
|
8
8
|
const EditRowState = {
|
9
9
|
New: 'new',
|
10
10
|
Editing: 'editing',
|