@formio/js 5.1.0-dev.6114.02b6d9c → 5.1.0-dev.6123.055aa35
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.builder.css +6 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.css +1 -1
- package/dist/formio.embed.min.css +1 -1
- package/dist/formio.form.css +6 -0
- package/dist/formio.form.js +112 -123
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.css +6 -0
- package/dist/formio.full.js +119 -130
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +61 -50
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +72 -72
- 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.js +9 -10
- package/lib/cjs/Wizard.js +1 -1
- package/lib/cjs/WizardBuilder.js +1 -1
- package/lib/cjs/components/_classes/component/Component.js +29 -52
- 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 +15 -13
- 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 +14 -2
- package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
- 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 +161 -2
- package/lib/cjs/utils/index.js +12 -2
- package/lib/cjs/utils/utils.d.ts +18 -33
- package/lib/cjs/utils/utils.js +52 -130
- package/lib/cjs/widgets/CalendarWidget.d.ts +0 -7
- package/lib/cjs/widgets/CalendarWidget.js +15 -39
- 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.js +1 -2
- package/lib/mjs/Wizard.js +1 -1
- package/lib/mjs/WizardBuilder.js +1 -1
- package/lib/mjs/components/_classes/component/Component.js +2 -2
- 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 +15 -13
- 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 +13 -2
- package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
- 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 +161 -2
- package/lib/mjs/utils/index.js +11 -1
- package/lib/mjs/utils/utils.d.ts +18 -33
- package/lib/mjs/utils/utils.js +45 -105
- package/lib/mjs/widgets/CalendarWidget.d.ts +0 -7
- package/lib/mjs/widgets/CalendarWidget.js +15 -39
- package/package.json +3 -2
package/lib/cjs/utils/utils.js
CHANGED
@@ -1,57 +1,26 @@
|
|
1
1
|
"use strict";
|
2
|
-
/* global jQuery */
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
4
|
-
if (k2 === undefined) k2 = k;
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
8
|
-
}
|
9
|
-
Object.defineProperty(o, k2, desc);
|
10
|
-
}) : (function(o, m, k, k2) {
|
11
|
-
if (k2 === undefined) k2 = k;
|
12
|
-
o[k2] = m[k];
|
13
|
-
}));
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
16
|
-
};
|
17
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
18
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
19
4
|
};
|
20
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
21
|
-
exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.
|
22
|
-
exports.hasEncodedTimezone = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports.
|
6
|
+
exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.convertFormatToDayjs = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.dayjsDate = exports.shouldHandleTimezone = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.removeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getScriptPlugin = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = void 0;
|
7
|
+
exports.hasEncodedTimezone = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports.getFocusableElements = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.fastCloneDeep = exports.sanitize = void 0;
|
8
|
+
/* global jQuery */
|
23
9
|
const lodash_1 = __importDefault(require("lodash"));
|
24
|
-
exports._ = lodash_1.default;
|
25
|
-
const json_logic_js_1 = __importDefault(require("json-logic-js"));
|
26
|
-
exports.jsonLogic = json_logic_js_1.default;
|
27
10
|
const moment_timezone_1 = __importDefault(require("moment-timezone/moment-timezone"));
|
28
|
-
exports.moment = moment_timezone_1.default;
|
29
11
|
const jstimezonedetect_1 = __importDefault(require("jstimezonedetect"));
|
30
|
-
const operators_1 = require("./jsonlogic/operators");
|
31
12
|
const dompurify_1 = __importDefault(require("dompurify"));
|
13
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
14
|
+
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
15
|
+
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
16
|
+
const advancedFormat_1 = __importDefault(require("dayjs/plugin/advancedFormat"));
|
17
|
+
const core_1 = require("@formio/core");
|
32
18
|
const formUtils_1 = require("./formUtils");
|
33
19
|
const Evaluator_1 = require("./Evaluator");
|
34
|
-
Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
|
35
20
|
const conditionOperators_1 = __importDefault(require("./conditionOperators"));
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
exports.interpolate = interpolate;
|
40
|
-
__exportStar(require("./formUtils"), exports);
|
41
|
-
// Configure JsonLogic
|
42
|
-
operators_1.lodashOperators.forEach((name) => json_logic_js_1.default.add_operation(`_${name}`, lodash_1.default[name]));
|
43
|
-
// Retrieve Any Date
|
44
|
-
json_logic_js_1.default.add_operation('getDate', (date) => {
|
45
|
-
return (0, moment_timezone_1.default)(date).toISOString();
|
46
|
-
});
|
47
|
-
// Set Relative Minimum Date
|
48
|
-
json_logic_js_1.default.add_operation('relativeMinDate', (relativeMinDate) => {
|
49
|
-
return (0, moment_timezone_1.default)().subtract(relativeMinDate, 'days').toISOString();
|
50
|
-
});
|
51
|
-
// Set Relative Maximum Date
|
52
|
-
json_logic_js_1.default.add_operation('relativeMaxDate', (relativeMaxDate) => {
|
53
|
-
return (0, moment_timezone_1.default)().add(relativeMaxDate, 'days').toISOString();
|
54
|
-
});
|
21
|
+
dayjs_1.default.extend(timezone_1.default);
|
22
|
+
dayjs_1.default.extend(advancedFormat_1.default);
|
23
|
+
dayjs_1.default.extend(utc_1.default);
|
55
24
|
/**
|
56
25
|
* Evaluate a method.
|
57
26
|
* @param {Function|string|object} func - The function to evaluate.
|
@@ -335,7 +304,7 @@ exports.checkCustomConditional = checkCustomConditional;
|
|
335
304
|
*/
|
336
305
|
function checkJsonConditional(component, json, row, data, form, onError) {
|
337
306
|
try {
|
338
|
-
return
|
307
|
+
return core_1.jsonLogic.apply(json, {
|
339
308
|
data,
|
340
309
|
row,
|
341
310
|
form,
|
@@ -553,7 +522,7 @@ exports.guid = guid;
|
|
553
522
|
/**
|
554
523
|
* Return a translated date setting.
|
555
524
|
* @param {string|Date} date - The date to translate.
|
556
|
-
* @returns {(null|
|
525
|
+
* @returns {(null|dayjs.Dayjs)} - The translated date.
|
557
526
|
*/
|
558
527
|
function getDateSetting(date) {
|
559
528
|
if (lodash_1.default.isNil(date) || lodash_1.default.isNaN(date) || date === '') {
|
@@ -573,13 +542,13 @@ function getDateSetting(date) {
|
|
573
542
|
try {
|
574
543
|
const value = Evaluator_1.Evaluator.evaluator(`return ${date};`, 'moment')(moment_timezone_1.default);
|
575
544
|
if (typeof value === 'string') {
|
576
|
-
dateSetting = (0,
|
545
|
+
dateSetting = (0, dayjs_1.default)(value);
|
577
546
|
}
|
578
547
|
else if (typeof value.toDate === 'function') {
|
579
|
-
dateSetting = (0,
|
548
|
+
dateSetting = (0, dayjs_1.default)(value.toDate().toUTCString());
|
580
549
|
}
|
581
550
|
else if (value instanceof Date) {
|
582
|
-
dateSetting = (0,
|
551
|
+
dateSetting = (0, dayjs_1.default)(value);
|
583
552
|
}
|
584
553
|
}
|
585
554
|
catch (e) {
|
@@ -609,18 +578,18 @@ exports.isValidDate = isValidDate;
|
|
609
578
|
* @returns {string} - The current timezone.
|
610
579
|
*/
|
611
580
|
function currentTimezone() {
|
612
|
-
if (
|
613
|
-
return
|
581
|
+
if (dayjs_1.default.currentTimezone) {
|
582
|
+
return dayjs_1.default.currentTimezone;
|
614
583
|
}
|
615
|
-
|
616
|
-
return
|
584
|
+
dayjs_1.default.currentTimezone = jstimezonedetect_1.default.determine().name();
|
585
|
+
return dayjs_1.default.currentTimezone;
|
617
586
|
}
|
618
587
|
exports.currentTimezone = currentTimezone;
|
619
588
|
/**
|
620
589
|
* Get an offset date provided a date object and timezone object.
|
621
590
|
* @param {Date} date - The date to offset.
|
622
591
|
* @param {string} timezone - The timezone to offset the date to.
|
623
|
-
* @returns {Date} - The offset date.
|
592
|
+
* @returns {{date: Date, abbr: string}} - The offset date.
|
624
593
|
*/
|
625
594
|
function offsetDate(date, timezone) {
|
626
595
|
if (timezone === 'UTC') {
|
@@ -629,7 +598,7 @@ function offsetDate(date, timezone) {
|
|
629
598
|
abbr: 'UTC'
|
630
599
|
};
|
631
600
|
}
|
632
|
-
const dateMoment = (0,
|
601
|
+
const dateMoment = (0, dayjs_1.default)(date).tz(timezone);
|
633
602
|
return {
|
634
603
|
date: new Date(date.getTime() + ((dateMoment.utcOffset() + date.getTimezoneOffset()) * 60000)),
|
635
604
|
abbr: dateMoment.format('z')
|
@@ -637,132 +606,85 @@ function offsetDate(date, timezone) {
|
|
637
606
|
}
|
638
607
|
exports.offsetDate = offsetDate;
|
639
608
|
/**
|
640
|
-
* Returns if
|
641
|
-
* @returns {boolean} - TRUE if the zones are loaded; FALSE otherwise.
|
642
|
-
*/
|
643
|
-
function zonesLoaded() {
|
644
|
-
return moment_timezone_1.default.zonesLoaded;
|
645
|
-
}
|
646
|
-
exports.zonesLoaded = zonesLoaded;
|
647
|
-
/**
|
648
|
-
* Returns if we should load the zones.
|
609
|
+
* Returns if we should handle a timezone difference.
|
649
610
|
* @param {string} timezone - The timezone to check if we should load the zones.
|
650
|
-
* @returns {boolean} - TRUE if we should
|
611
|
+
* @returns {boolean} - TRUE if we should handle timezones; FALSE otherwise.
|
651
612
|
*/
|
652
|
-
function
|
653
|
-
|
654
|
-
return false;
|
655
|
-
}
|
656
|
-
return true;
|
613
|
+
function shouldHandleTimezone(timezone) {
|
614
|
+
return !(timezone === currentTimezone() || timezone === 'UTC');
|
657
615
|
}
|
658
|
-
exports.
|
659
|
-
/**
|
660
|
-
* Externally load the timezone data.
|
661
|
-
* @param {string} url - The URL to load the timezone data from.
|
662
|
-
* @param {string} timezone - The timezone to load.
|
663
|
-
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
664
|
-
*/
|
665
|
-
function loadZones(url, timezone) {
|
666
|
-
if (timezone && !shouldLoadZones(timezone)) {
|
667
|
-
// Return non-resolving promise.
|
668
|
-
return new Promise(lodash_1.default.noop);
|
669
|
-
}
|
670
|
-
if (moment_timezone_1.default.zonesPromise) {
|
671
|
-
return moment_timezone_1.default.zonesPromise;
|
672
|
-
}
|
673
|
-
return moment_timezone_1.default.zonesPromise = fetch(url)
|
674
|
-
.then(resp => resp.json().then(zones => {
|
675
|
-
moment_timezone_1.default.tz.load(zones);
|
676
|
-
moment_timezone_1.default.zonesLoaded = true;
|
677
|
-
// Trigger a global event that the timezones have finished loading.
|
678
|
-
if (document && document.createEvent && document.body && document.body.dispatchEvent) {
|
679
|
-
var event = document.createEvent('Event');
|
680
|
-
event.initEvent('zonesLoaded', true, true);
|
681
|
-
document.body.dispatchEvent(event);
|
682
|
-
}
|
683
|
-
}));
|
684
|
-
}
|
685
|
-
exports.loadZones = loadZones;
|
616
|
+
exports.shouldHandleTimezone = shouldHandleTimezone;
|
686
617
|
/**
|
687
|
-
* Get the
|
688
|
-
* @param {string|Date} value - The value to convert into a
|
618
|
+
* Get the Dayjs date object for translating dates with timezones.
|
619
|
+
* @param {string|Date} value - The value to convert into a dayjs date.
|
689
620
|
* @param {string} format - The format to convert the date to.
|
690
621
|
* @param {string} timezone - The timezone to convert the date to.
|
691
622
|
* @param {object} options - The options object
|
692
|
-
* @returns {
|
623
|
+
* @returns {dayjs.Dayjs} - The dayjs date object.
|
693
624
|
*/
|
694
|
-
function
|
695
|
-
const
|
625
|
+
function dayjsDate(value, format, timezone, options) {
|
626
|
+
const dayjsDate = (0, dayjs_1.default)(value);
|
696
627
|
if (!timezone) {
|
697
|
-
return
|
628
|
+
return dayjsDate;
|
698
629
|
}
|
699
630
|
if (timezone === 'UTC') {
|
700
631
|
timezone = 'Etc/UTC';
|
701
632
|
}
|
702
|
-
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (
|
703
|
-
return
|
633
|
+
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (shouldHandleTimezone(timezone) || (options === null || options === void 0 ? void 0 : options.email))) {
|
634
|
+
return dayjsDate.tz(timezone);
|
704
635
|
}
|
705
|
-
return
|
636
|
+
return dayjsDate;
|
706
637
|
}
|
707
|
-
exports.
|
638
|
+
exports.dayjsDate = dayjsDate;
|
708
639
|
/**
|
709
640
|
* Format a date provided a value, format, and timezone object.
|
710
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
711
641
|
* @param {string|Date} value - The value to format.
|
712
642
|
* @param {string} format - The format to format the date to.
|
713
643
|
* @param {string} timezone - The timezone to format the date to.
|
714
644
|
* @param {string} flatPickrInputFormat - The format to use for flatpickr input.
|
715
645
|
* @returns {string} - The formatted date.
|
716
646
|
*/
|
717
|
-
function formatDate(
|
718
|
-
const
|
647
|
+
function formatDate(value, format, timezone, flatPickrInputFormat) {
|
648
|
+
const dayjsDate = (0, dayjs_1.default)(value, flatPickrInputFormat || undefined);
|
719
649
|
if (timezone === currentTimezone()) {
|
720
650
|
// See if our format contains a "z" timezone character.
|
721
651
|
if (format.match(/\s(z$|z\s)/)) {
|
722
|
-
|
723
|
-
|
724
|
-
return momentDate.tz(timezone).format(convertFormatToMoment(format));
|
652
|
+
if (shouldHandleTimezone(timezone)) {
|
653
|
+
return dayjsDate.tz(timezone).format(convertFormatToDayjs(format));
|
725
654
|
}
|
726
655
|
else {
|
727
|
-
return
|
656
|
+
return dayjsDate.format(convertFormatToDayjs(format.replace(/\s(z$|z\s)/, '')));
|
728
657
|
}
|
729
658
|
}
|
730
659
|
// Return the standard format.
|
731
|
-
return
|
660
|
+
return dayjsDate.format(convertFormatToDayjs(format));
|
732
661
|
}
|
733
662
|
if (timezone === 'UTC') {
|
734
|
-
const offset = offsetDate(
|
735
|
-
return `${(0,
|
736
|
-
}
|
737
|
-
// Load the zones since we need timezone information.
|
738
|
-
loadZones(timezonesUrl);
|
739
|
-
if (moment_timezone_1.default.zonesLoaded && timezone) {
|
740
|
-
return momentDate.tz(timezone).format(`${convertFormatToMoment(format)} z`);
|
663
|
+
const offset = offsetDate(dayjsDate.toDate(), 'UTC');
|
664
|
+
return `${(0, dayjs_1.default)(offset.date).format(convertFormatToDayjs(format))} UTC`;
|
741
665
|
}
|
742
|
-
|
743
|
-
return
|
666
|
+
if (shouldHandleTimezone(timezone)) {
|
667
|
+
return dayjsDate.tz(timezone).format(`${convertFormatToDayjs(format)} z`);
|
744
668
|
}
|
669
|
+
return dayjsDate.format(convertFormatToDayjs(format));
|
745
670
|
}
|
746
671
|
exports.formatDate = formatDate;
|
747
672
|
/**
|
748
673
|
* Pass a format function to format within a timezone.
|
749
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
750
674
|
* @param {Function} formatFn - The format function to use.
|
751
675
|
* @param {Date|string} date - The date to format.
|
752
676
|
* @param {string} format - The format to format the date to.
|
753
677
|
* @param {string} timezone - The timezone to format the date to.
|
754
678
|
* @returns {string} - The formatted date.
|
755
679
|
*/
|
756
|
-
function formatOffset(
|
680
|
+
function formatOffset(formatFn, date, format, timezone) {
|
757
681
|
if (timezone === currentTimezone()) {
|
758
682
|
return formatFn(date, format);
|
759
683
|
}
|
760
684
|
if (timezone === 'UTC') {
|
761
685
|
return `${formatFn(offsetDate(date, 'UTC').date, format)} UTC`;
|
762
686
|
}
|
763
|
-
|
764
|
-
loadZones(timezonesUrl);
|
765
|
-
if (moment_timezone_1.default.zonesLoaded) {
|
687
|
+
if (shouldHandleTimezone(timezone)) {
|
766
688
|
const offset = offsetDate(date, timezone);
|
767
689
|
return `${formatFn(offset.date, format)} ${offset.abbr}`;
|
768
690
|
}
|
@@ -822,7 +744,7 @@ exports.convertFormatToFlatpickr = convertFormatToFlatpickr;
|
|
822
744
|
* @param {string} format - The format to convert.
|
823
745
|
* @returns {string} - The converted format.
|
824
746
|
*/
|
825
|
-
function
|
747
|
+
function convertFormatToDayjs(format) {
|
826
748
|
return format
|
827
749
|
// Year conversion.
|
828
750
|
.replace(/y/g, 'Y')
|
@@ -835,7 +757,7 @@ function convertFormatToMoment(format) {
|
|
835
757
|
// Unix Timestamp
|
836
758
|
.replace(/U/g, 'X');
|
837
759
|
}
|
838
|
-
exports.
|
760
|
+
exports.convertFormatToDayjs = convertFormatToDayjs;
|
839
761
|
/**
|
840
762
|
* Convert the format from the angular-datepicker module to mask format.
|
841
763
|
* @param {string} format - The format to convert.
|
@@ -22,13 +22,6 @@ export default class CalendarWidget extends InputWidget {
|
|
22
22
|
minDate: string;
|
23
23
|
maxDate: string;
|
24
24
|
};
|
25
|
-
zoneLoading: boolean;
|
26
|
-
timezonesUrl: string;
|
27
|
-
/**
|
28
|
-
* Load the timezones.
|
29
|
-
* @returns {boolean} TRUE if the zones are loading, FALSE otherwise.
|
30
|
-
*/
|
31
|
-
loadZones(): boolean;
|
32
25
|
attach(input: any): Promise<any>;
|
33
26
|
defaultFormat: {
|
34
27
|
date: string;
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const Formio_1 = require("../Formio");
|
7
|
-
const InputWidget_1 = __importDefault(require("./InputWidget"));
|
8
|
-
const utils_1 = require("../utils/utils");
|
9
6
|
const moment_1 = __importDefault(require("moment"));
|
10
7
|
const lodash_1 = __importDefault(require("lodash"));
|
8
|
+
const Formio_1 = require("../Formio");
|
9
|
+
const InputWidget_1 = __importDefault(require("./InputWidget"));
|
10
|
+
const utils_1 = require("../utils");
|
11
11
|
const DEFAULT_FORMAT = 'yyyy-MM-dd hh:mm a';
|
12
12
|
const ISO_8601_FORMAT = 'yyyy-MM-ddTHH:mm:ssZ';
|
13
13
|
const isIEBrowser = (0, utils_1.getBrowserInfo)().ie;
|
@@ -51,29 +51,6 @@ 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;
|
77
54
|
}
|
78
55
|
attach(input) {
|
79
56
|
var _a;
|
@@ -85,7 +62,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
85
62
|
};
|
86
63
|
this.closedOn = 0;
|
87
64
|
this.valueFormat = (this.settings.saveAs === 'date') ? ISO_8601_FORMAT : this.settings.dateFormat || ISO_8601_FORMAT;
|
88
|
-
this.valueMomentFormat = (0, utils_1.
|
65
|
+
this.valueMomentFormat = (0, utils_1.convertFormatToDayjs)(this.valueFormat);
|
89
66
|
const isReadOnly = this.settings.readOnly;
|
90
67
|
this.settings.minDate = isReadOnly ? null : (0, utils_1.getDateSetting)(this.settings.minDate);
|
91
68
|
this.settings.maxDate = isReadOnly ? null : (0, utils_1.getDateSetting)(this.settings.maxDate);
|
@@ -249,9 +226,9 @@ class CalendarWidget extends InputWidget_1.default {
|
|
249
226
|
*/
|
250
227
|
getDateValue(date, format, useTimezone) {
|
251
228
|
if (useTimezone) {
|
252
|
-
return (0, utils_1.
|
229
|
+
return (0, utils_1.dayjsDate)(date, this.valueFormat, this.timezone).format((0, utils_1.convertFormatToDayjs)(format));
|
253
230
|
}
|
254
|
-
return (0, moment_1.default)(date).format((0, utils_1.
|
231
|
+
return (0, moment_1.default)(date).format((0, utils_1.convertFormatToDayjs)(format));
|
255
232
|
}
|
256
233
|
/**
|
257
234
|
* Return the value of the selected date.
|
@@ -283,7 +260,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
283
260
|
setValue(value) {
|
284
261
|
const saveAsText = (this.settings.saveAs === 'text');
|
285
262
|
if (!this.calendar) {
|
286
|
-
value = value ? (0, utils_1.formatDate)(
|
263
|
+
value = value ? (0, utils_1.formatDate)(value, (0, utils_1.convertFormatToDayjs)(this.settings.format), this.timezone, (0, utils_1.convertFormatToDayjs)(this.valueMomentFormat)) : value;
|
287
264
|
return super.setValue(value);
|
288
265
|
}
|
289
266
|
// If the component is a textfield that does not have timezone information included in the string value then skip
|
@@ -291,10 +268,9 @@ class CalendarWidget extends InputWidget_1.default {
|
|
291
268
|
if (this.component.type === 'textfield' && !(0, utils_1.hasEncodedTimezone)(value)) {
|
292
269
|
this.settings.skipOffset = true;
|
293
270
|
}
|
294
|
-
const zonesLoading = this.loadZones();
|
295
271
|
if (value) {
|
296
|
-
if (!saveAsText && this.settings.readOnly
|
297
|
-
this.calendar.setDate((0, utils_1.
|
272
|
+
if (!saveAsText && this.settings.readOnly) {
|
273
|
+
this.calendar.setDate((0, utils_1.dayjsDate)(value, this.valueFormat, this.timezone).format(), false);
|
298
274
|
}
|
299
275
|
else if (this.isValueISO8601(value)) {
|
300
276
|
this.calendar.setDate(value, false);
|
@@ -311,9 +287,9 @@ class CalendarWidget extends InputWidget_1.default {
|
|
311
287
|
const inputFormat = format || this.dateFormat;
|
312
288
|
const valueFormat = this.calendar ? this.valueFormat : this.settings.dateFormat;
|
313
289
|
if (this.settings.saveAs === 'text' && this.componentInstance.parent && !this.settings.readOnly) {
|
314
|
-
return (0, moment_1.default)(value, (0, utils_1.
|
290
|
+
return (0, moment_1.default)(value, (0, utils_1.convertFormatToDayjs)(valueFormat)).format((0, utils_1.convertFormatToDayjs)(valueFormat));
|
315
291
|
}
|
316
|
-
return (0, utils_1.formatDate)(
|
292
|
+
return (0, utils_1.formatDate)(value, inputFormat, this.timezone, (0, utils_1.convertFormatToDayjs)(valueFormat));
|
317
293
|
}
|
318
294
|
setErrorClasses(hasErrors) {
|
319
295
|
if (!this.input) {
|
@@ -406,7 +382,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
406
382
|
const relatedTarget = event.relatedTarget ? event.relatedTarget : activeElement;
|
407
383
|
if (!(isIEBrowser && !relatedTarget) && !this.isCalendarElement(relatedTarget)) {
|
408
384
|
const inputValue = this.calendar.input.value;
|
409
|
-
const dateValue = inputValue ? (0, moment_1.default)(this.calendar.input.value, (0, utils_1.
|
385
|
+
const dateValue = inputValue ? (0, moment_1.default)(this.calendar.input.value, (0, utils_1.convertFormatToDayjs)(this.valueFormat)).toDate() : inputValue;
|
410
386
|
this.calendar.setDate(dateValue, true, this.settings.altFormat);
|
411
387
|
}
|
412
388
|
else if (!this.calendar.input.value && this.calendar.config.noCalendar) {
|
@@ -458,14 +434,14 @@ class CalendarWidget extends InputWidget_1.default {
|
|
458
434
|
return (date, format) => {
|
459
435
|
// Only format this if this is the altFormat and the form is readOnly.
|
460
436
|
if (this.settings.readOnly && (format === this.settings.altFormat)) {
|
461
|
-
if (!this.settings.enableTime || this.
|
437
|
+
if (!this.settings.enableTime || this.settings.skipOffset) {
|
462
438
|
return Flatpickr.formatDate(date, format);
|
463
439
|
}
|
464
440
|
const currentValue = new Date(this.getValue());
|
465
441
|
if (currentValue.toString() === date.toString()) {
|
466
|
-
return (0, utils_1.formatOffset)(
|
442
|
+
return (0, utils_1.formatOffset)(Flatpickr.formatDate.bind(Flatpickr), new Date(this.componentValue), format, this.timezone);
|
467
443
|
}
|
468
|
-
return (0, utils_1.formatOffset)(
|
444
|
+
return (0, utils_1.formatOffset)(Flatpickr.formatDate.bind(Flatpickr), date, format, this.timezone);
|
469
445
|
}
|
470
446
|
return Flatpickr.formatDate(date, format);
|
471
447
|
};
|
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';
|
3
2
|
import { compareVersions } from 'compare-versions';
|
4
3
|
import EventEmitter from './EventEmitter';
|
5
4
|
import i18nDefaults from './i18n';
|
6
5
|
import { Formio } from './Formio';
|
7
6
|
import Components from './components/Components';
|
8
7
|
import NestedDataComponent from './components/_classes/nesteddata/NestedDataComponent';
|
9
|
-
import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, } from './utils
|
10
|
-
import
|
8
|
+
import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, eachComponent } from './utils';
|
9
|
+
import dayjs from "dayjs";
|
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', dayjs().utcOffset()), 10),
|
1321
1320
|
origin: document.location.origin,
|
1322
1321
|
referrer: document.referrer,
|
1323
1322
|
browserName: navigator.appName,
|
@@ -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';
|
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;
|
@@ -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';
|
@@ -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 {
|