@formio/js 5.1.0-dev.6048.569bfc1 → 5.1.0-dev.6049.6110ca0
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/Changelog.md +99 -310
- package/README.md +7 -0
- package/dist/formio.builder.css +1 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.form.css +1 -0
- package/dist/formio.form.js +658 -669
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -1
- package/dist/formio.full.css +1 -0
- package/dist/formio.full.js +685 -696
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -1
- package/dist/formio.js +90 -68
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +103 -81
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +3 -1
- package/lib/cjs/Element.d.ts +2 -1
- package/lib/cjs/Element.js +18 -39
- 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.d.ts +1 -0
- package/lib/cjs/PDFBuilder.js +10 -11
- package/lib/cjs/Webform.d.ts +2 -2
- package/lib/cjs/Webform.js +14 -15
- package/lib/cjs/WebformBuilder.d.ts +2 -1
- package/lib/cjs/WebformBuilder.js +62 -20
- package/lib/cjs/Wizard.d.ts +2 -2
- package/lib/cjs/Wizard.js +40 -26
- package/lib/cjs/WizardBuilder.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +44 -13
- package/lib/cjs/components/_classes/component/Component.js +156 -95
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +19 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/utils.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 +3 -3
- package/lib/cjs/components/_classes/nested/NestedComponent.form.js +13 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.js +15 -8
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +0 -2
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -12
- package/lib/cjs/components/address/Address.d.ts +8 -0
- package/lib/cjs/components/address/Address.js +32 -9
- package/lib/cjs/components/address/editForm/Address.edit.display.d.ts +4 -0
- package/lib/cjs/components/address/editForm/Address.edit.display.js +1 -0
- package/lib/cjs/components/address/editForm/Address.edit.provider.js +8 -8
- 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 +7 -11
- package/lib/cjs/components/checkbox/Checkbox.js +1 -1
- package/lib/cjs/components/container/Container.js +1 -1
- package/lib/cjs/components/content/editForm/Content.edit.display.js +8 -0
- package/lib/cjs/components/currency/Currency.js +1 -1
- package/lib/cjs/components/currency/editForm/Currency.edit.display.js +12 -0
- package/lib/cjs/components/datagrid/DataGrid.js +5 -1
- package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/cjs/components/datetime/DateTime.js +15 -13
- package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.d.ts +66 -15
- package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.js +68 -47
- package/lib/cjs/components/day/Day.js +2 -2
- package/lib/cjs/components/day/editForm/Day.edit.display.js +8 -0
- package/lib/cjs/components/editgrid/EditGrid.js +4 -2
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/cjs/components/email/editForm/Email.edit.display.js +12 -0
- package/lib/cjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
- package/lib/cjs/components/file/File.js +6 -2
- package/lib/cjs/components/file/editForm/File.edit.file.d.ts +13 -0
- package/lib/cjs/components/file/editForm/File.edit.file.js +1 -0
- package/lib/cjs/components/form/Form.d.ts +0 -1
- package/lib/cjs/components/form/Form.js +31 -23
- package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
- package/lib/cjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
- package/lib/cjs/components/html/editForm/HTML.edit.display.js +8 -0
- package/lib/cjs/components/number/Number.js +1 -1
- package/lib/cjs/components/number/editForm/Number.edit.display.js +12 -0
- package/lib/cjs/components/panel/Panel.js +1 -1
- package/lib/cjs/components/password/editForm/Password.edit.display.js +13 -1
- package/lib/cjs/components/phonenumber/PhoneNumber.form.js +9 -1
- package/lib/cjs/components/radio/Radio.d.ts +8 -0
- package/lib/cjs/components/radio/Radio.js +16 -6
- package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/cjs/components/select/Select.d.ts +1 -0
- package/lib/cjs/components/select/Select.js +21 -5
- package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +68 -110
- package/lib/cjs/components/select/editForm/Select.edit.data.js +2 -37
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/cjs/components/selectboxes/SelectBoxes.js +7 -1
- package/lib/cjs/components/signature/Signature.js +1 -1
- package/lib/cjs/components/survey/Survey.js +2 -2
- package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
- package/lib/cjs/components/tags/Tags.js +1 -1
- package/lib/cjs/components/textarea/TextArea.js +10 -2
- package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
- package/lib/cjs/components/textfield/TextField.js +9 -32
- package/lib/cjs/components/time/Time.js +1 -1
- package/lib/cjs/components/unknown/Unknown.form.d.ts +2 -1
- package/lib/cjs/components/unknown/Unknown.form.js +13 -9
- package/lib/cjs/components/url/editForm/Url.edit.display.js +12 -0
- package/lib/cjs/components/well/editForm/Well.edit.display.js +8 -0
- package/lib/cjs/formio.form.js +5 -5
- package/lib/cjs/providers/storage/uploadAdapter.js +8 -6
- package/lib/cjs/translations/en.d.ts +1 -234
- package/lib/cjs/translations/en.js +4 -2
- package/lib/cjs/utils/Evaluator.d.ts +20 -6
- package/lib/cjs/utils/Evaluator.js +38 -15
- package/lib/cjs/utils/builder.js +5 -5
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/index.d.ts +169 -2
- package/lib/cjs/utils/index.js +22 -2
- package/lib/cjs/utils/utils.d.ts +31 -37
- package/lib/cjs/utils/utils.js +80 -135
- package/lib/cjs/widgets/CalendarWidget.d.ts +1 -8
- package/lib/cjs/widgets/CalendarWidget.js +19 -40
- package/lib/mjs/Element.d.ts +2 -1
- package/lib/mjs/Element.js +11 -9
- 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.d.ts +1 -0
- package/lib/mjs/PDFBuilder.js +9 -10
- package/lib/mjs/Webform.d.ts +2 -2
- package/lib/mjs/Webform.js +12 -13
- package/lib/mjs/WebformBuilder.d.ts +2 -1
- package/lib/mjs/WebformBuilder.js +53 -13
- package/lib/mjs/Wizard.d.ts +2 -2
- package/lib/mjs/Wizard.js +38 -24
- package/lib/mjs/WizardBuilder.js +1 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +44 -13
- package/lib/mjs/components/_classes/component/Component.js +129 -45
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +19 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/utils.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 +3 -3
- package/lib/mjs/components/_classes/nested/NestedComponent.form.js +13 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.js +15 -8
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +0 -2
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -12
- package/lib/mjs/components/address/Address.d.ts +8 -0
- package/lib/mjs/components/address/Address.js +32 -9
- package/lib/mjs/components/address/editForm/Address.edit.display.d.ts +4 -0
- package/lib/mjs/components/address/editForm/Address.edit.display.js +1 -0
- package/lib/mjs/components/address/editForm/Address.edit.provider.js +8 -8
- 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 +7 -10
- package/lib/mjs/components/checkbox/Checkbox.js +1 -1
- package/lib/mjs/components/container/Container.js +1 -1
- package/lib/mjs/components/content/editForm/Content.edit.display.js +8 -0
- package/lib/mjs/components/currency/Currency.js +1 -1
- package/lib/mjs/components/currency/editForm/Currency.edit.display.js +12 -0
- package/lib/mjs/components/datagrid/DataGrid.js +5 -1
- package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/mjs/components/datetime/DateTime.js +15 -13
- package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.d.ts +66 -15
- package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.js +68 -47
- package/lib/mjs/components/day/Day.js +2 -2
- package/lib/mjs/components/day/editForm/Day.edit.display.js +8 -0
- package/lib/mjs/components/editgrid/EditGrid.js +4 -2
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/mjs/components/email/editForm/Email.edit.display.js +12 -0
- package/lib/mjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
- package/lib/mjs/components/file/File.js +6 -2
- package/lib/mjs/components/file/editForm/File.edit.file.d.ts +13 -0
- package/lib/mjs/components/file/editForm/File.edit.file.js +1 -0
- package/lib/mjs/components/form/Form.d.ts +0 -1
- package/lib/mjs/components/form/Form.js +30 -23
- package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
- package/lib/mjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
- package/lib/mjs/components/html/editForm/HTML.edit.display.js +8 -0
- package/lib/mjs/components/number/Number.js +1 -1
- package/lib/mjs/components/number/editForm/Number.edit.display.js +12 -0
- package/lib/mjs/components/panel/Panel.js +1 -1
- package/lib/mjs/components/password/editForm/Password.edit.display.js +13 -1
- package/lib/mjs/components/phonenumber/PhoneNumber.form.js +9 -1
- package/lib/mjs/components/radio/Radio.d.ts +8 -0
- package/lib/mjs/components/radio/Radio.js +16 -6
- package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/mjs/components/select/Select.d.ts +1 -0
- package/lib/mjs/components/select/Select.js +21 -5
- package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +68 -110
- package/lib/mjs/components/select/editForm/Select.edit.data.js +2 -37
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/mjs/components/selectboxes/SelectBoxes.js +7 -1
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/lib/mjs/components/survey/Survey.js +2 -2
- package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
- package/lib/mjs/components/tags/Tags.js +1 -1
- package/lib/mjs/components/textarea/TextArea.js +10 -2
- package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
- package/lib/mjs/components/textfield/TextField.js +3 -3
- package/lib/mjs/components/time/Time.js +1 -1
- package/lib/mjs/components/unknown/Unknown.form.d.ts +2 -1
- package/lib/mjs/components/unknown/Unknown.form.js +13 -9
- package/lib/mjs/components/url/editForm/Url.edit.display.js +12 -0
- package/lib/mjs/components/well/editForm/Well.edit.display.js +8 -0
- package/lib/mjs/formio.form.js +3 -3
- package/lib/mjs/providers/storage/uploadAdapter.js +8 -6
- package/lib/mjs/translations/en.d.ts +1 -234
- package/lib/mjs/translations/en.js +6 -47
- package/lib/mjs/utils/Evaluator.d.ts +20 -6
- package/lib/mjs/utils/Evaluator.js +31 -13
- package/lib/mjs/utils/builder.js +1 -1
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/index.d.ts +169 -2
- package/lib/mjs/utils/index.js +18 -1
- package/lib/mjs/utils/utils.d.ts +31 -37
- package/lib/mjs/utils/utils.js +72 -109
- package/lib/mjs/widgets/CalendarWidget.d.ts +1 -8
- package/lib/mjs/widgets/CalendarWidget.js +19 -40
- package/package.json +8 -6
- package/lib/cjs/i18n.d.ts +0 -13
- package/lib/cjs/i18n.js +0 -19
- package/lib/cjs/utils/i18n.d.ts +0 -19
- package/lib/cjs/utils/i18n.js +0 -120
- package/lib/mjs/i18n.d.ts +0 -13
- package/lib/mjs/i18n.js +0 -14
- package/lib/mjs/utils/i18n.d.ts +0 -19
- package/lib/mjs/utils/i18n.js +0 -112
package/lib/cjs/utils/utils.js
CHANGED
@@ -1,56 +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.
|
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
|
-
__exportStar(require("./formUtils"), exports);
|
40
|
-
// Configure JsonLogic
|
41
|
-
operators_1.lodashOperators.forEach((name) => json_logic_js_1.default.add_operation(`_${name}`, lodash_1.default[name]));
|
42
|
-
// Retrieve Any Date
|
43
|
-
json_logic_js_1.default.add_operation('getDate', (date) => {
|
44
|
-
return (0, moment_timezone_1.default)(date).toISOString();
|
45
|
-
});
|
46
|
-
// Set Relative Minimum Date
|
47
|
-
json_logic_js_1.default.add_operation('relativeMinDate', (relativeMinDate) => {
|
48
|
-
return (0, moment_timezone_1.default)().subtract(relativeMinDate, 'days').toISOString();
|
49
|
-
});
|
50
|
-
// Set Relative Maximum Date
|
51
|
-
json_logic_js_1.default.add_operation('relativeMaxDate', (relativeMaxDate) => {
|
52
|
-
return (0, moment_timezone_1.default)().add(relativeMaxDate, 'days').toISOString();
|
53
|
-
});
|
21
|
+
dayjs_1.default.extend(timezone_1.default);
|
22
|
+
dayjs_1.default.extend(advancedFormat_1.default);
|
23
|
+
dayjs_1.default.extend(utc_1.default);
|
54
24
|
/**
|
55
25
|
* Evaluate a method.
|
56
26
|
* @param {Function|string|object} func - The function to evaluate.
|
@@ -239,13 +209,20 @@ function checkSimpleConditional(component, condition, row, data, instance) {
|
|
239
209
|
return true;
|
240
210
|
}
|
241
211
|
const conditionsResult = lodash_1.default.map(conditions, (cond) => {
|
242
|
-
var _a, _b;
|
243
212
|
const { value: comparedValue, operator, component: conditionComponentPath } = cond;
|
244
213
|
if (!conditionComponentPath) {
|
245
214
|
return true;
|
246
215
|
}
|
247
216
|
const splittedConditionPath = conditionComponentPath.split('.');
|
248
|
-
const
|
217
|
+
const checkParentTypeInTree = (instance, componentType) => {
|
218
|
+
if (!(instance === null || instance === void 0 ? void 0 : instance.parent)) {
|
219
|
+
return false;
|
220
|
+
}
|
221
|
+
return (instance === null || instance === void 0 ? void 0 : instance.parent.type) === componentType || checkParentTypeInTree(instance.parent, componentType);
|
222
|
+
};
|
223
|
+
const conditionalPaths = checkParentTypeInTree(instance, 'datagrid') || checkParentTypeInTree(instance, 'editgrid')
|
224
|
+
? []
|
225
|
+
: getConditionalPathsRecursive(splittedConditionPath, data);
|
249
226
|
if (conditionalPaths.length > 0) {
|
250
227
|
return conditionalPaths.map((path) => {
|
251
228
|
const value = getComponentActualValue(path, data, row);
|
@@ -271,7 +248,7 @@ function checkSimpleConditional(component, condition, row, data, instance) {
|
|
271
248
|
default:
|
272
249
|
result = lodash_1.default.every(conditionsResult.flat(), res => !!res);
|
273
250
|
}
|
274
|
-
return show ? result : !result;
|
251
|
+
return (0, core_1.convertShowToBoolean)(show) ? result : !result;
|
275
252
|
}
|
276
253
|
}
|
277
254
|
exports.checkSimpleConditional = checkSimpleConditional;
|
@@ -334,7 +311,7 @@ exports.checkCustomConditional = checkCustomConditional;
|
|
334
311
|
*/
|
335
312
|
function checkJsonConditional(component, json, row, data, form, onError) {
|
336
313
|
try {
|
337
|
-
return
|
314
|
+
return core_1.jsonLogic.apply(json, {
|
338
315
|
data,
|
339
316
|
row,
|
340
317
|
form,
|
@@ -364,7 +341,7 @@ function getRow(component, row, instance, conditional) {
|
|
364
341
|
}
|
365
342
|
const dataParent = getDataParentComponent(instance);
|
366
343
|
if (dataParent) {
|
367
|
-
const parentPath = (_a = dataParent.paths) === null || _a === void 0 ? void 0 : _a.
|
344
|
+
const parentPath = (_a = dataParent.paths) === null || _a === void 0 ? void 0 : _a.localPath;
|
368
345
|
const isTriggerCondtionComponentPath = condition.when || !condition.conditions
|
369
346
|
? (_b = condition.when) === null || _b === void 0 ? void 0 : _b.startsWith((_c = dataParent.paths) === null || _c === void 0 ? void 0 : _c.localPath)
|
370
347
|
: lodash_1.default.some(condition.conditions, cond => { var _a; return cond.component.startsWith((_a = dataParent.paths) === null || _a === void 0 ? void 0 : _a.localPath); });
|
@@ -552,7 +529,7 @@ exports.guid = guid;
|
|
552
529
|
/**
|
553
530
|
* Return a translated date setting.
|
554
531
|
* @param {string|Date} date - The date to translate.
|
555
|
-
* @returns {(null|
|
532
|
+
* @returns {(null|dayjs.Dayjs)} - The translated date.
|
556
533
|
*/
|
557
534
|
function getDateSetting(date) {
|
558
535
|
if (lodash_1.default.isNil(date) || lodash_1.default.isNaN(date) || date === '') {
|
@@ -572,13 +549,13 @@ function getDateSetting(date) {
|
|
572
549
|
try {
|
573
550
|
const value = Evaluator_1.Evaluator.evaluator(`return ${date};`, 'moment')(moment_timezone_1.default);
|
574
551
|
if (typeof value === 'string') {
|
575
|
-
dateSetting = (0,
|
552
|
+
dateSetting = (0, dayjs_1.default)(value);
|
576
553
|
}
|
577
554
|
else if (typeof value.toDate === 'function') {
|
578
|
-
dateSetting = (0,
|
555
|
+
dateSetting = (0, dayjs_1.default)(value.toDate().toUTCString());
|
579
556
|
}
|
580
557
|
else if (value instanceof Date) {
|
581
|
-
dateSetting = (0,
|
558
|
+
dateSetting = (0, dayjs_1.default)(value);
|
582
559
|
}
|
583
560
|
}
|
584
561
|
catch (e) {
|
@@ -608,18 +585,18 @@ exports.isValidDate = isValidDate;
|
|
608
585
|
* @returns {string} - The current timezone.
|
609
586
|
*/
|
610
587
|
function currentTimezone() {
|
611
|
-
if (
|
612
|
-
return
|
588
|
+
if (dayjs_1.default.currentTimezone) {
|
589
|
+
return dayjs_1.default.currentTimezone;
|
613
590
|
}
|
614
|
-
|
615
|
-
return
|
591
|
+
dayjs_1.default.currentTimezone = jstimezonedetect_1.default.determine().name();
|
592
|
+
return dayjs_1.default.currentTimezone;
|
616
593
|
}
|
617
594
|
exports.currentTimezone = currentTimezone;
|
618
595
|
/**
|
619
596
|
* Get an offset date provided a date object and timezone object.
|
620
597
|
* @param {Date} date - The date to offset.
|
621
598
|
* @param {string} timezone - The timezone to offset the date to.
|
622
|
-
* @returns {Date} - The offset date.
|
599
|
+
* @returns {{date: Date, abbr: string}} - The offset date.
|
623
600
|
*/
|
624
601
|
function offsetDate(date, timezone) {
|
625
602
|
if (timezone === 'UTC') {
|
@@ -628,7 +605,7 @@ function offsetDate(date, timezone) {
|
|
628
605
|
abbr: 'UTC'
|
629
606
|
};
|
630
607
|
}
|
631
|
-
const dateMoment = (0,
|
608
|
+
const dateMoment = (0, dayjs_1.default)(date).tz(timezone);
|
632
609
|
return {
|
633
610
|
date: new Date(date.getTime() + ((dateMoment.utcOffset() + date.getTimezoneOffset()) * 60000)),
|
634
611
|
abbr: dateMoment.format('z')
|
@@ -636,132 +613,85 @@ function offsetDate(date, timezone) {
|
|
636
613
|
}
|
637
614
|
exports.offsetDate = offsetDate;
|
638
615
|
/**
|
639
|
-
* Returns if
|
640
|
-
* @returns {boolean} - TRUE if the zones are loaded; FALSE otherwise.
|
641
|
-
*/
|
642
|
-
function zonesLoaded() {
|
643
|
-
return moment_timezone_1.default.zonesLoaded;
|
644
|
-
}
|
645
|
-
exports.zonesLoaded = zonesLoaded;
|
646
|
-
/**
|
647
|
-
* Returns if we should load the zones.
|
616
|
+
* Returns if we should handle a timezone difference.
|
648
617
|
* @param {string} timezone - The timezone to check if we should load the zones.
|
649
|
-
* @returns {boolean} - TRUE if we should
|
618
|
+
* @returns {boolean} - TRUE if we should handle timezones; FALSE otherwise.
|
650
619
|
*/
|
651
|
-
function
|
652
|
-
|
653
|
-
return false;
|
654
|
-
}
|
655
|
-
return true;
|
620
|
+
function shouldHandleTimezone(timezone) {
|
621
|
+
return !(timezone === currentTimezone() || timezone === 'UTC');
|
656
622
|
}
|
657
|
-
exports.
|
658
|
-
/**
|
659
|
-
* Externally load the timezone data.
|
660
|
-
* @param {string} url - The URL to load the timezone data from.
|
661
|
-
* @param {string} timezone - The timezone to load.
|
662
|
-
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
663
|
-
*/
|
664
|
-
function loadZones(url, timezone) {
|
665
|
-
if (timezone && !shouldLoadZones(timezone)) {
|
666
|
-
// Return non-resolving promise.
|
667
|
-
return new Promise(lodash_1.default.noop);
|
668
|
-
}
|
669
|
-
if (moment_timezone_1.default.zonesPromise) {
|
670
|
-
return moment_timezone_1.default.zonesPromise;
|
671
|
-
}
|
672
|
-
return moment_timezone_1.default.zonesPromise = fetch(url)
|
673
|
-
.then(resp => resp.json().then(zones => {
|
674
|
-
moment_timezone_1.default.tz.load(zones);
|
675
|
-
moment_timezone_1.default.zonesLoaded = true;
|
676
|
-
// Trigger a global event that the timezones have finished loading.
|
677
|
-
if (document && document.createEvent && document.body && document.body.dispatchEvent) {
|
678
|
-
var event = document.createEvent('Event');
|
679
|
-
event.initEvent('zonesLoaded', true, true);
|
680
|
-
document.body.dispatchEvent(event);
|
681
|
-
}
|
682
|
-
}));
|
683
|
-
}
|
684
|
-
exports.loadZones = loadZones;
|
623
|
+
exports.shouldHandleTimezone = shouldHandleTimezone;
|
685
624
|
/**
|
686
|
-
* Get the
|
687
|
-
* @param {string|Date} value - The value to convert into a
|
625
|
+
* Get the Dayjs date object for translating dates with timezones.
|
626
|
+
* @param {string|Date} value - The value to convert into a dayjs date.
|
688
627
|
* @param {string} format - The format to convert the date to.
|
689
628
|
* @param {string} timezone - The timezone to convert the date to.
|
690
629
|
* @param {object} options - The options object
|
691
|
-
* @returns {
|
630
|
+
* @returns {dayjs.Dayjs} - The dayjs date object.
|
692
631
|
*/
|
693
|
-
function
|
694
|
-
const
|
632
|
+
function dayjsDate(value, format, timezone, options) {
|
633
|
+
const dayjsDate = (0, dayjs_1.default)(value);
|
695
634
|
if (!timezone) {
|
696
|
-
return
|
635
|
+
return dayjsDate;
|
697
636
|
}
|
698
637
|
if (timezone === 'UTC') {
|
699
638
|
timezone = 'Etc/UTC';
|
700
639
|
}
|
701
|
-
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (
|
702
|
-
return
|
640
|
+
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (shouldHandleTimezone(timezone) || (options === null || options === void 0 ? void 0 : options.email))) {
|
641
|
+
return dayjsDate.tz(timezone);
|
703
642
|
}
|
704
|
-
return
|
643
|
+
return dayjsDate;
|
705
644
|
}
|
706
|
-
exports.
|
645
|
+
exports.dayjsDate = dayjsDate;
|
707
646
|
/**
|
708
647
|
* Format a date provided a value, format, and timezone object.
|
709
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
710
648
|
* @param {string|Date} value - The value to format.
|
711
649
|
* @param {string} format - The format to format the date to.
|
712
650
|
* @param {string} timezone - The timezone to format the date to.
|
713
651
|
* @param {string} flatPickrInputFormat - The format to use for flatpickr input.
|
714
652
|
* @returns {string} - The formatted date.
|
715
653
|
*/
|
716
|
-
function formatDate(
|
717
|
-
const
|
654
|
+
function formatDate(value, format, timezone, flatPickrInputFormat) {
|
655
|
+
const dayjsDate = (0, dayjs_1.default)(value, flatPickrInputFormat || undefined);
|
718
656
|
if (timezone === currentTimezone()) {
|
719
657
|
// See if our format contains a "z" timezone character.
|
720
658
|
if (format.match(/\s(z$|z\s)/)) {
|
721
|
-
|
722
|
-
|
723
|
-
return momentDate.tz(timezone).format(convertFormatToMoment(format));
|
659
|
+
if (shouldHandleTimezone(timezone)) {
|
660
|
+
return dayjsDate.tz(timezone).format(convertFormatToDayjs(format));
|
724
661
|
}
|
725
662
|
else {
|
726
|
-
return
|
663
|
+
return dayjsDate.format(convertFormatToDayjs(format.replace(/\s(z$|z\s)/, '')));
|
727
664
|
}
|
728
665
|
}
|
729
666
|
// Return the standard format.
|
730
|
-
return
|
667
|
+
return dayjsDate.format(convertFormatToDayjs(format));
|
731
668
|
}
|
732
669
|
if (timezone === 'UTC') {
|
733
|
-
const offset = offsetDate(
|
734
|
-
return `${(0,
|
670
|
+
const offset = offsetDate(dayjsDate.toDate(), 'UTC');
|
671
|
+
return `${(0, dayjs_1.default)(offset.date).format(convertFormatToDayjs(format))} UTC`;
|
735
672
|
}
|
736
|
-
|
737
|
-
|
738
|
-
if (moment_timezone_1.default.zonesLoaded && timezone) {
|
739
|
-
return momentDate.tz(timezone).format(`${convertFormatToMoment(format)} z`);
|
740
|
-
}
|
741
|
-
else {
|
742
|
-
return momentDate.format(convertFormatToMoment(format));
|
673
|
+
if (shouldHandleTimezone(timezone)) {
|
674
|
+
return dayjsDate.tz(timezone).format(`${convertFormatToDayjs(format)} z`);
|
743
675
|
}
|
676
|
+
return dayjsDate.format(convertFormatToDayjs(format));
|
744
677
|
}
|
745
678
|
exports.formatDate = formatDate;
|
746
679
|
/**
|
747
680
|
* Pass a format function to format within a timezone.
|
748
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
749
681
|
* @param {Function} formatFn - The format function to use.
|
750
682
|
* @param {Date|string} date - The date to format.
|
751
683
|
* @param {string} format - The format to format the date to.
|
752
684
|
* @param {string} timezone - The timezone to format the date to.
|
753
685
|
* @returns {string} - The formatted date.
|
754
686
|
*/
|
755
|
-
function formatOffset(
|
687
|
+
function formatOffset(formatFn, date, format, timezone) {
|
756
688
|
if (timezone === currentTimezone()) {
|
757
689
|
return formatFn(date, format);
|
758
690
|
}
|
759
691
|
if (timezone === 'UTC') {
|
760
692
|
return `${formatFn(offsetDate(date, 'UTC').date, format)} UTC`;
|
761
693
|
}
|
762
|
-
|
763
|
-
loadZones(timezonesUrl);
|
764
|
-
if (moment_timezone_1.default.zonesLoaded) {
|
694
|
+
if (shouldHandleTimezone(timezone)) {
|
765
695
|
const offset = offsetDate(date, timezone);
|
766
696
|
return `${formatFn(offset.date, format)} ${offset.abbr}`;
|
767
697
|
}
|
@@ -821,7 +751,7 @@ exports.convertFormatToFlatpickr = convertFormatToFlatpickr;
|
|
821
751
|
* @param {string} format - The format to convert.
|
822
752
|
* @returns {string} - The converted format.
|
823
753
|
*/
|
824
|
-
function
|
754
|
+
function convertFormatToDayjs(format) {
|
825
755
|
return format
|
826
756
|
// Year conversion.
|
827
757
|
.replace(/y/g, 'Y')
|
@@ -834,7 +764,7 @@ function convertFormatToMoment(format) {
|
|
834
764
|
// Unix Timestamp
|
835
765
|
.replace(/U/g, 'X');
|
836
766
|
}
|
837
|
-
exports.
|
767
|
+
exports.convertFormatToDayjs = convertFormatToDayjs;
|
838
768
|
/**
|
839
769
|
* Convert the format from the angular-datepicker module to mask format.
|
840
770
|
* @param {string} format - The format to convert.
|
@@ -1394,7 +1324,7 @@ exports.fastCloneDeep = fastCloneDeep;
|
|
1394
1324
|
/**
|
1395
1325
|
* Returns if the component is an input component.
|
1396
1326
|
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
1397
|
-
* @returns {
|
1327
|
+
* @returns {boolean} - TRUE if the component is an input component; FALSE otherwise.
|
1398
1328
|
*/
|
1399
1329
|
function isInputComponent(componentJson) {
|
1400
1330
|
if (componentJson.input === false || componentJson.input === true) {
|
@@ -1419,7 +1349,7 @@ exports.isInputComponent = isInputComponent;
|
|
1419
1349
|
/**
|
1420
1350
|
* Takes a component path, and returns a component path array.
|
1421
1351
|
* @param {string} pathStr - The path string to convert to an array.
|
1422
|
-
* @returns {
|
1352
|
+
* @returns {Array<string>} - The array of paths.
|
1423
1353
|
*/
|
1424
1354
|
function getArrayFromComponentPath(pathStr) {
|
1425
1355
|
if (!pathStr || !lodash_1.default.isString(pathStr)) {
|
@@ -1645,3 +1575,18 @@ const interpolateErrors = (component, errors, interpolateFn) => {
|
|
1645
1575
|
});
|
1646
1576
|
};
|
1647
1577
|
exports.interpolateErrors = interpolateErrors;
|
1578
|
+
/**
|
1579
|
+
* Checks if a string has timezone information encoded in it
|
1580
|
+
* Example: 2024-01-01T00:00:00Z -> true
|
1581
|
+
* Example: 2024-01-01T00:00:00+03:00 -> true
|
1582
|
+
* Example: 2011-05-03T00:00:00 -> false
|
1583
|
+
* @param {string} value the string value to check
|
1584
|
+
* @returns {boolean} if value has encoded timezone
|
1585
|
+
*/
|
1586
|
+
function hasEncodedTimezone(value) {
|
1587
|
+
if (typeof value !== 'string') {
|
1588
|
+
return false;
|
1589
|
+
}
|
1590
|
+
return (value.substring(value.length - 1) === 'z' || value.substring(value.length - 1) === 'Z' || value.match(/[+|-][0-9]{2}:[0-9]{2}$/));
|
1591
|
+
}
|
1592
|
+
exports.hasEncodedTimezone = hasEncodedTimezone;
|
@@ -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;
|
@@ -84,7 +77,7 @@ export default class CalendarWidget extends InputWidget {
|
|
84
77
|
* @returns {void}
|
85
78
|
*/
|
86
79
|
setValue(value: any): void;
|
87
|
-
getValueAsString(value: any, format
|
80
|
+
getValueAsString(value: any, format?: string): string;
|
88
81
|
setErrorClasses(hasErrors: any): void;
|
89
82
|
isCalendarElement(element: any): any;
|
90
83
|
initFlatpickr(Flatpickr: any): void;
|
@@ -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,13 +260,15 @@ 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
|
267
|
+
// the timezone offset
|
268
|
+
this.settings.skipOffset = this.component.type === 'textfield' && !(0, utils_1.hasEncodedTimezone)(value);
|
290
269
|
if (value) {
|
291
|
-
if (!saveAsText && this.settings.readOnly
|
292
|
-
this.calendar.setDate((0, utils_1.
|
270
|
+
if (!saveAsText && this.settings.readOnly) {
|
271
|
+
this.calendar.setDate((0, utils_1.dayjsDate)(value, this.valueFormat, this.timezone).format(), false);
|
293
272
|
}
|
294
273
|
else if (this.isValueISO8601(value)) {
|
295
274
|
this.calendar.setDate(value, false);
|
@@ -302,13 +281,13 @@ class CalendarWidget extends InputWidget_1.default {
|
|
302
281
|
this.calendar.clear(false);
|
303
282
|
}
|
304
283
|
}
|
305
|
-
getValueAsString(value, format) {
|
284
|
+
getValueAsString(value, format = '') {
|
306
285
|
const inputFormat = format || this.dateFormat;
|
307
286
|
const valueFormat = this.calendar ? this.valueFormat : this.settings.dateFormat;
|
308
287
|
if (this.settings.saveAs === 'text' && this.componentInstance.parent && !this.settings.readOnly) {
|
309
|
-
return (0, moment_1.default)(value, (0, utils_1.
|
288
|
+
return (0, moment_1.default)(value, (0, utils_1.convertFormatToDayjs)(valueFormat)).format((0, utils_1.convertFormatToDayjs)(valueFormat));
|
310
289
|
}
|
311
|
-
return (0, utils_1.formatDate)(
|
290
|
+
return (0, utils_1.formatDate)(value, inputFormat, this.timezone, (0, utils_1.convertFormatToDayjs)(valueFormat));
|
312
291
|
}
|
313
292
|
setErrorClasses(hasErrors) {
|
314
293
|
if (!this.input) {
|
@@ -401,7 +380,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
401
380
|
const relatedTarget = event.relatedTarget ? event.relatedTarget : activeElement;
|
402
381
|
if (!(isIEBrowser && !relatedTarget) && !this.isCalendarElement(relatedTarget)) {
|
403
382
|
const inputValue = this.calendar.input.value;
|
404
|
-
const dateValue = inputValue ? (0, moment_1.default)(this.calendar.input.value, (0, utils_1.
|
383
|
+
const dateValue = inputValue ? (0, moment_1.default)(this.calendar.input.value, (0, utils_1.convertFormatToDayjs)(this.valueFormat)).toDate() : inputValue;
|
405
384
|
this.calendar.setDate(dateValue, true, this.settings.altFormat);
|
406
385
|
}
|
407
386
|
else if (!this.calendar.input.value && this.calendar.config.noCalendar) {
|
@@ -453,14 +432,14 @@ class CalendarWidget extends InputWidget_1.default {
|
|
453
432
|
return (date, format) => {
|
454
433
|
// Only format this if this is the altFormat and the form is readOnly.
|
455
434
|
if (this.settings.readOnly && (format === this.settings.altFormat)) {
|
456
|
-
if (!this.settings.enableTime || this.
|
435
|
+
if (!this.settings.enableTime || this.settings.skipOffset) {
|
457
436
|
return Flatpickr.formatDate(date, format);
|
458
437
|
}
|
459
438
|
const currentValue = new Date(this.getValue());
|
460
439
|
if (currentValue.toString() === date.toString()) {
|
461
|
-
return (0, utils_1.formatOffset)(
|
440
|
+
return (0, utils_1.formatOffset)(Flatpickr.formatDate.bind(Flatpickr), new Date(this.componentValue), format, this.timezone);
|
462
441
|
}
|
463
|
-
return (0, utils_1.formatOffset)(
|
442
|
+
return (0, utils_1.formatOffset)(Flatpickr.formatDate.bind(Flatpickr), date, format, this.timezone);
|
464
443
|
}
|
465
444
|
return Flatpickr.formatDate(date, format);
|
466
445
|
};
|
package/lib/mjs/Element.d.ts
CHANGED
@@ -170,10 +170,11 @@ export default class Element {
|
|
170
170
|
/**
|
171
171
|
* Translate a text using the i18n system.
|
172
172
|
* @param {string|Array<string>} text - The i18n identifier.
|
173
|
+
* @param {any} data - contextual data object containing data, component, row, etc.
|
173
174
|
* @param {...any} args - The arguments to pass to the i18n translation.
|
174
175
|
* @returns {string} - The translated text.
|
175
176
|
*/
|
176
|
-
t(text: string | Array<string>, ...args: any[]): string;
|
177
|
+
t(text: string | Array<string>, data: any, ...args: any[]): string;
|
177
178
|
/**
|
178
179
|
* Alias to create a text node.
|
179
180
|
* @param {string} text - The text to create.
|
package/lib/mjs/Element.js
CHANGED
@@ -1,10 +1,11 @@
|
|
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 FormioUtils from './utils';
|
7
|
+
import { I18n } from '@formio/core';
|
8
|
+
import enTranslation from './translations/en';
|
8
9
|
/**
|
9
10
|
* The root component for all elements within the Form.io renderer.
|
10
11
|
*/
|
@@ -38,7 +39,7 @@ export default class Element {
|
|
38
39
|
if (this.options?.language) {
|
39
40
|
this.options.i18n.language = this.options.language;
|
40
41
|
}
|
41
|
-
this.options.i18next = this.i18next = this.options.i18next || I18n.init(this.options.i18n);
|
42
|
+
this.options.i18next = this.i18next = this.options.i18next || I18n.init({ en: enTranslation, ...this.options.i18n });
|
42
43
|
/**
|
43
44
|
* An instance of the EventEmitter class to handle the emitting and registration of events.
|
44
45
|
* @type {EventEmitter}
|
@@ -385,11 +386,12 @@ export default class Element {
|
|
385
386
|
/**
|
386
387
|
* Translate a text using the i18n system.
|
387
388
|
* @param {string|Array<string>} text - The i18n identifier.
|
389
|
+
* @param {any} data - contextual data object containing data, component, row, etc.
|
388
390
|
* @param {...any} args - The arguments to pass to the i18n translation.
|
389
391
|
* @returns {string} - The translated text.
|
390
392
|
*/
|
391
|
-
t(text, ...args) {
|
392
|
-
return this.i18next ? this.i18next.t(text, ...args) : text;
|
393
|
+
t(text, data, ...args) {
|
394
|
+
return this.i18next ? this.i18next.t(text, data, ...args) : text;
|
393
395
|
}
|
394
396
|
/**
|
395
397
|
* Alias to create a text node.
|
@@ -523,9 +525,9 @@ export default class Element {
|
|
523
525
|
if (this.component.filter === string && !this.options.building) {
|
524
526
|
const evalContext = this.evalContext(data);
|
525
527
|
evalContext.data = _.mapValues(evalContext.data, (val) => _.isString(val) ? encodeURIComponent(val) : val);
|
526
|
-
return FormioUtils.interpolate(string, evalContext, options);
|
528
|
+
return FormioUtils.Evaluator.interpolate(string, evalContext, options);
|
527
529
|
}
|
528
|
-
return FormioUtils.interpolate(string, this.evalContext(data), options);
|
530
|
+
return FormioUtils.Evaluator.interpolate(string, this.evalContext(data), options);
|
529
531
|
}
|
530
532
|
/**
|
531
533
|
* 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.d.ts
CHANGED