@formio/js 5.1.0-dev.6108.401a61f → 5.1.0-dev.6112.06b0f26
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/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 +116 -149
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.css +1 -0
- package/dist/formio.full.js +123 -156
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +65 -54
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +76 -76
- package/dist/formio.utils.min.js +1 -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 +9 -9
- package/lib/cjs/WebformBuilder.d.ts +1 -1
- package/lib/cjs/WebformBuilder.js +45 -21
- package/lib/cjs/Wizard.d.ts +1 -2
- package/lib/cjs/Wizard.js +18 -24
- 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 +55 -62
- 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.d.ts +1 -1
- package/lib/cjs/components/_classes/input/Input.js +3 -3
- package/lib/cjs/components/_classes/list/ListComponent.js +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.js +7 -7
- 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.js +1 -1
- 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.js +7 -2
- 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 +2 -2
- 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/fieldset/Fieldset.js +1 -0
- 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.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 +20 -4
- package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- 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 +9 -4
- package/lib/cjs/components/textfield/TextField.js +13 -31
- package/lib/cjs/components/time/Time.js +1 -1
- package/lib/cjs/formio.form.js +5 -5
- package/lib/cjs/providers/storage/uploadAdapter.js +1 -1
- package/lib/cjs/translations/en.d.ts +1 -232
- 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 +22 -37
- package/lib/cjs/utils/utils.js +64 -135
- package/lib/cjs/widgets/CalendarWidget.d.ts +1 -8
- package/lib/cjs/widgets/CalendarWidget.js +17 -43
- 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 +7 -7
- package/lib/mjs/WebformBuilder.d.ts +1 -1
- package/lib/mjs/WebformBuilder.js +36 -13
- package/lib/mjs/Wizard.d.ts +1 -2
- package/lib/mjs/Wizard.js +17 -23
- 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 +28 -12
- 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.d.ts +1 -1
- package/lib/mjs/components/_classes/input/Input.js +3 -3
- package/lib/mjs/components/_classes/list/ListComponent.js +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.js +7 -7
- 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.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.js +7 -2
- 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 +2 -2
- 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/fieldset/Fieldset.js +1 -0
- 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.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 +20 -4
- package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- 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 +9 -4
- package/lib/mjs/components/textfield/TextField.js +7 -2
- package/lib/mjs/components/time/Time.js +1 -1
- package/lib/mjs/formio.form.js +3 -3
- package/lib/mjs/providers/storage/uploadAdapter.js +1 -1
- package/lib/mjs/translations/en.d.ts +1 -232
- package/lib/mjs/translations/en.js +8 -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 +22 -37
- package/lib/mjs/utils/utils.js +57 -109
- package/lib/mjs/widgets/CalendarWidget.d.ts +1 -8
- package/lib/mjs/widgets/CalendarWidget.js +17 -43
- package/package.json +5 -5
- 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/index.js
CHANGED
@@ -22,11 +22,31 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
22
|
__setModuleDefault(result, mod);
|
23
23
|
return result;
|
24
24
|
};
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
27
|
+
};
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
30
|
+
};
|
25
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.Utils = void 0;
|
27
|
-
const
|
32
|
+
exports.registerEvaluator = exports.Evaluator = exports.Utils = void 0;
|
33
|
+
const utils = __importStar(require("./utils"));
|
34
|
+
const formUtils = __importStar(require("./formUtils"));
|
35
|
+
const Evaluator_1 = require("./Evaluator");
|
36
|
+
Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
|
37
|
+
Object.defineProperty(exports, "registerEvaluator", { enumerable: true, get: function () { return Evaluator_1.registerEvaluator; } });
|
38
|
+
const conditionOperators_1 = __importDefault(require("./conditionOperators"));
|
39
|
+
const lodash_1 = __importDefault(require("lodash"));
|
40
|
+
const moment_1 = __importDefault(require("moment"));
|
41
|
+
const FormioUtils = Object.assign(Object.assign(Object.assign({}, utils), formUtils), { Evaluator: Evaluator_1.Evaluator,
|
42
|
+
interpolate: Evaluator_1.interpolate,
|
43
|
+
ConditionOperators: conditionOperators_1.default,
|
44
|
+
_: lodash_1.default,
|
45
|
+
moment: moment_1.default });
|
28
46
|
exports.Utils = FormioUtils;
|
29
47
|
if (typeof global === 'object') {
|
30
48
|
global.FormioUtils = FormioUtils;
|
31
49
|
}
|
50
|
+
__exportStar(require("./utils"), exports);
|
51
|
+
__exportStar(require("./formUtils"), exports);
|
32
52
|
exports.default = FormioUtils;
|
package/lib/cjs/utils/utils.d.ts
CHANGED
@@ -164,9 +164,9 @@ export function guid(): string;
|
|
164
164
|
/**
|
165
165
|
* Return a translated date setting.
|
166
166
|
* @param {string|Date} date - The date to translate.
|
167
|
-
* @returns {(null|
|
167
|
+
* @returns {(null|dayjs.Dayjs)} - The translated date.
|
168
168
|
*/
|
169
|
-
export function getDateSetting(date: string | Date): (null |
|
169
|
+
export function getDateSetting(date: string | Date): (null | dayjs.Dayjs);
|
170
170
|
/**
|
171
171
|
* Returns true if the date is a valid date. False otherwise.
|
172
172
|
* @param {Date|string} date - The date to check for validity.
|
@@ -182,56 +182,45 @@ export function currentTimezone(): string;
|
|
182
182
|
* Get an offset date provided a date object and timezone object.
|
183
183
|
* @param {Date} date - The date to offset.
|
184
184
|
* @param {string} timezone - The timezone to offset the date to.
|
185
|
-
* @returns {Date} - The offset date.
|
185
|
+
* @returns {{date: Date, abbr: string}} - The offset date.
|
186
186
|
*/
|
187
|
-
export function offsetDate(date: Date, timezone: string):
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
*/
|
192
|
-
export function zonesLoaded(): boolean;
|
187
|
+
export function offsetDate(date: Date, timezone: string): {
|
188
|
+
date: Date;
|
189
|
+
abbr: string;
|
190
|
+
};
|
193
191
|
/**
|
194
|
-
* Returns if we should
|
192
|
+
* Returns if we should handle a timezone difference.
|
195
193
|
* @param {string} timezone - The timezone to check if we should load the zones.
|
196
|
-
* @returns {boolean} - TRUE if we should
|
197
|
-
*/
|
198
|
-
export function shouldLoadZones(timezone: string): boolean;
|
199
|
-
/**
|
200
|
-
* Externally load the timezone data.
|
201
|
-
* @param {string} url - The URL to load the timezone data from.
|
202
|
-
* @param {string} timezone - The timezone to load.
|
203
|
-
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
194
|
+
* @returns {boolean} - TRUE if we should handle timezones; FALSE otherwise.
|
204
195
|
*/
|
205
|
-
export function
|
196
|
+
export function shouldHandleTimezone(timezone: string): boolean;
|
206
197
|
/**
|
207
|
-
* Get the
|
208
|
-
* @param {string|Date} value - The value to convert into a
|
198
|
+
* Get the Dayjs date object for translating dates with timezones.
|
199
|
+
* @param {string|Date} value - The value to convert into a dayjs date.
|
209
200
|
* @param {string} format - The format to convert the date to.
|
210
201
|
* @param {string} timezone - The timezone to convert the date to.
|
211
202
|
* @param {object} options - The options object
|
212
|
-
* @returns {
|
203
|
+
* @returns {dayjs.Dayjs} - The dayjs date object.
|
213
204
|
*/
|
214
|
-
export function
|
205
|
+
export function dayjsDate(value: string | Date, format: string, timezone: string, options: object): dayjs.Dayjs;
|
215
206
|
/**
|
216
207
|
* Format a date provided a value, format, and timezone object.
|
217
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
218
208
|
* @param {string|Date} value - The value to format.
|
219
209
|
* @param {string} format - The format to format the date to.
|
220
210
|
* @param {string} timezone - The timezone to format the date to.
|
221
211
|
* @param {string} flatPickrInputFormat - The format to use for flatpickr input.
|
222
212
|
* @returns {string} - The formatted date.
|
223
213
|
*/
|
224
|
-
export function formatDate(
|
214
|
+
export function formatDate(value: string | Date, format: string, timezone: string, flatPickrInputFormat: string): string;
|
225
215
|
/**
|
226
216
|
* Pass a format function to format within a timezone.
|
227
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
228
217
|
* @param {Function} formatFn - The format function to use.
|
229
218
|
* @param {Date|string} date - The date to format.
|
230
219
|
* @param {string} format - The format to format the date to.
|
231
220
|
* @param {string} timezone - The timezone to format the date to.
|
232
221
|
* @returns {string} - The formatted date.
|
233
222
|
*/
|
234
|
-
export function formatOffset(
|
223
|
+
export function formatOffset(formatFn: Function, date: Date | string, format: string, timezone: string): string;
|
235
224
|
/**
|
236
225
|
* Returns the local date format information.
|
237
226
|
* @param {Intl.LocalesArgument} locale - The locale to get the date format for.
|
@@ -249,7 +238,7 @@ export function convertFormatToFlatpickr(format: string): string;
|
|
249
238
|
* @param {string} format - The format to convert.
|
250
239
|
* @returns {string} - The converted format.
|
251
240
|
*/
|
252
|
-
export function
|
241
|
+
export function convertFormatToDayjs(format: string): string;
|
253
242
|
/**
|
254
243
|
* Convert the format from the angular-datepicker module to mask format.
|
255
244
|
* @param {string} format - The format to convert.
|
@@ -414,15 +403,15 @@ export function fastCloneDeep(obj: any): any;
|
|
414
403
|
/**
|
415
404
|
* Returns if the component is an input component.
|
416
405
|
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
417
|
-
* @returns {
|
406
|
+
* @returns {boolean} - TRUE if the component is an input component; FALSE otherwise.
|
418
407
|
*/
|
419
|
-
export function isInputComponent(componentJson: import('@formio/core').Component):
|
408
|
+
export function isInputComponent(componentJson: import('@formio/core').Component): boolean;
|
420
409
|
/**
|
421
410
|
* Takes a component path, and returns a component path array.
|
422
411
|
* @param {string} pathStr - The path string to convert to an array.
|
423
|
-
* @returns {
|
412
|
+
* @returns {Array<string>} - The array of paths.
|
424
413
|
*/
|
425
|
-
export function getArrayFromComponentPath(pathStr: string):
|
414
|
+
export function getArrayFromComponentPath(pathStr: string): Array<string>;
|
426
415
|
/**
|
427
416
|
* Returns true if the component is a child of the parent.
|
428
417
|
* @param {any} child - The child component to check.
|
@@ -499,7 +488,6 @@ export function getComponentSavedTypes(fullSchema: import('@formio/core').Compon
|
|
499
488
|
* @returns {boolean} if value has encoded timezone
|
500
489
|
*/
|
501
490
|
export function hasEncodedTimezone(value: string): boolean;
|
502
|
-
export * from "./formUtils";
|
503
491
|
/**
|
504
492
|
* Map values through unfold and return first non-nil value.
|
505
493
|
* @param {Array<T>} collection - The collection to map through unfold.;
|
@@ -516,7 +504,4 @@ export namespace componentValueTypes {
|
|
516
504
|
let any: string;
|
517
505
|
}
|
518
506
|
export function interpolateErrors(component: Component, errors: FieldError[], interpolateFn: Function): [];
|
519
|
-
import
|
520
|
-
import { Evaluator } from './Evaluator';
|
521
|
-
export const interpolate: typeof Evaluator.interpolate;
|
522
|
-
export { jsonLogic, ConditionOperators, moment, Evaluator, _ };
|
507
|
+
import dayjs from "dayjs";
|
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.
|
@@ -240,13 +209,20 @@ function checkSimpleConditional(component, condition, row, data, instance) {
|
|
240
209
|
return true;
|
241
210
|
}
|
242
211
|
const conditionsResult = lodash_1.default.map(conditions, (cond) => {
|
243
|
-
var _a, _b;
|
244
212
|
const { value: comparedValue, operator, component: conditionComponentPath } = cond;
|
245
213
|
if (!conditionComponentPath) {
|
246
214
|
return true;
|
247
215
|
}
|
248
216
|
const splittedConditionPath = conditionComponentPath.split('.');
|
249
|
-
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);
|
250
226
|
if (conditionalPaths.length > 0) {
|
251
227
|
return conditionalPaths.map((path) => {
|
252
228
|
const value = getComponentActualValue(path, data, row);
|
@@ -335,7 +311,7 @@ exports.checkCustomConditional = checkCustomConditional;
|
|
335
311
|
*/
|
336
312
|
function checkJsonConditional(component, json, row, data, form, onError) {
|
337
313
|
try {
|
338
|
-
return
|
314
|
+
return core_1.jsonLogic.apply(json, {
|
339
315
|
data,
|
340
316
|
row,
|
341
317
|
form,
|
@@ -365,7 +341,7 @@ function getRow(component, row, instance, conditional) {
|
|
365
341
|
}
|
366
342
|
const dataParent = getDataParentComponent(instance);
|
367
343
|
if (dataParent) {
|
368
|
-
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;
|
369
345
|
const isTriggerCondtionComponentPath = condition.when || !condition.conditions
|
370
346
|
? (_b = condition.when) === null || _b === void 0 ? void 0 : _b.startsWith((_c = dataParent.paths) === null || _c === void 0 ? void 0 : _c.localPath)
|
371
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); });
|
@@ -553,7 +529,7 @@ exports.guid = guid;
|
|
553
529
|
/**
|
554
530
|
* Return a translated date setting.
|
555
531
|
* @param {string|Date} date - The date to translate.
|
556
|
-
* @returns {(null|
|
532
|
+
* @returns {(null|dayjs.Dayjs)} - The translated date.
|
557
533
|
*/
|
558
534
|
function getDateSetting(date) {
|
559
535
|
if (lodash_1.default.isNil(date) || lodash_1.default.isNaN(date) || date === '') {
|
@@ -573,13 +549,13 @@ function getDateSetting(date) {
|
|
573
549
|
try {
|
574
550
|
const value = Evaluator_1.Evaluator.evaluator(`return ${date};`, 'moment')(moment_timezone_1.default);
|
575
551
|
if (typeof value === 'string') {
|
576
|
-
dateSetting = (0,
|
552
|
+
dateSetting = (0, dayjs_1.default)(value);
|
577
553
|
}
|
578
554
|
else if (typeof value.toDate === 'function') {
|
579
|
-
dateSetting = (0,
|
555
|
+
dateSetting = (0, dayjs_1.default)(value.toDate().toUTCString());
|
580
556
|
}
|
581
557
|
else if (value instanceof Date) {
|
582
|
-
dateSetting = (0,
|
558
|
+
dateSetting = (0, dayjs_1.default)(value);
|
583
559
|
}
|
584
560
|
}
|
585
561
|
catch (e) {
|
@@ -609,18 +585,18 @@ exports.isValidDate = isValidDate;
|
|
609
585
|
* @returns {string} - The current timezone.
|
610
586
|
*/
|
611
587
|
function currentTimezone() {
|
612
|
-
if (
|
613
|
-
return
|
588
|
+
if (dayjs_1.default.currentTimezone) {
|
589
|
+
return dayjs_1.default.currentTimezone;
|
614
590
|
}
|
615
|
-
|
616
|
-
return
|
591
|
+
dayjs_1.default.currentTimezone = jstimezonedetect_1.default.determine().name();
|
592
|
+
return dayjs_1.default.currentTimezone;
|
617
593
|
}
|
618
594
|
exports.currentTimezone = currentTimezone;
|
619
595
|
/**
|
620
596
|
* Get an offset date provided a date object and timezone object.
|
621
597
|
* @param {Date} date - The date to offset.
|
622
598
|
* @param {string} timezone - The timezone to offset the date to.
|
623
|
-
* @returns {Date} - The offset date.
|
599
|
+
* @returns {{date: Date, abbr: string}} - The offset date.
|
624
600
|
*/
|
625
601
|
function offsetDate(date, timezone) {
|
626
602
|
if (timezone === 'UTC') {
|
@@ -629,7 +605,7 @@ function offsetDate(date, timezone) {
|
|
629
605
|
abbr: 'UTC'
|
630
606
|
};
|
631
607
|
}
|
632
|
-
const dateMoment = (0,
|
608
|
+
const dateMoment = (0, dayjs_1.default)(date).tz(timezone);
|
633
609
|
return {
|
634
610
|
date: new Date(date.getTime() + ((dateMoment.utcOffset() + date.getTimezoneOffset()) * 60000)),
|
635
611
|
abbr: dateMoment.format('z')
|
@@ -637,132 +613,85 @@ function offsetDate(date, timezone) {
|
|
637
613
|
}
|
638
614
|
exports.offsetDate = offsetDate;
|
639
615
|
/**
|
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.
|
616
|
+
* Returns if we should handle a timezone difference.
|
649
617
|
* @param {string} timezone - The timezone to check if we should load the zones.
|
650
|
-
* @returns {boolean} - TRUE if we should
|
618
|
+
* @returns {boolean} - TRUE if we should handle timezones; FALSE otherwise.
|
651
619
|
*/
|
652
|
-
function
|
653
|
-
|
654
|
-
return false;
|
655
|
-
}
|
656
|
-
return true;
|
620
|
+
function shouldHandleTimezone(timezone) {
|
621
|
+
return !(timezone === currentTimezone() || timezone === 'UTC');
|
657
622
|
}
|
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;
|
623
|
+
exports.shouldHandleTimezone = shouldHandleTimezone;
|
686
624
|
/**
|
687
|
-
* Get the
|
688
|
-
* @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.
|
689
627
|
* @param {string} format - The format to convert the date to.
|
690
628
|
* @param {string} timezone - The timezone to convert the date to.
|
691
629
|
* @param {object} options - The options object
|
692
|
-
* @returns {
|
630
|
+
* @returns {dayjs.Dayjs} - The dayjs date object.
|
693
631
|
*/
|
694
|
-
function
|
695
|
-
const
|
632
|
+
function dayjsDate(value, format, timezone, options) {
|
633
|
+
const dayjsDate = (0, dayjs_1.default)(value);
|
696
634
|
if (!timezone) {
|
697
|
-
return
|
635
|
+
return dayjsDate;
|
698
636
|
}
|
699
637
|
if (timezone === 'UTC') {
|
700
638
|
timezone = 'Etc/UTC';
|
701
639
|
}
|
702
|
-
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (
|
703
|
-
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);
|
704
642
|
}
|
705
|
-
return
|
643
|
+
return dayjsDate;
|
706
644
|
}
|
707
|
-
exports.
|
645
|
+
exports.dayjsDate = dayjsDate;
|
708
646
|
/**
|
709
647
|
* Format a date provided a value, format, and timezone object.
|
710
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
711
648
|
* @param {string|Date} value - The value to format.
|
712
649
|
* @param {string} format - The format to format the date to.
|
713
650
|
* @param {string} timezone - The timezone to format the date to.
|
714
651
|
* @param {string} flatPickrInputFormat - The format to use for flatpickr input.
|
715
652
|
* @returns {string} - The formatted date.
|
716
653
|
*/
|
717
|
-
function formatDate(
|
718
|
-
const
|
654
|
+
function formatDate(value, format, timezone, flatPickrInputFormat) {
|
655
|
+
const dayjsDate = (0, dayjs_1.default)(value, flatPickrInputFormat || undefined);
|
719
656
|
if (timezone === currentTimezone()) {
|
720
657
|
// See if our format contains a "z" timezone character.
|
721
658
|
if (format.match(/\s(z$|z\s)/)) {
|
722
|
-
|
723
|
-
|
724
|
-
return momentDate.tz(timezone).format(convertFormatToMoment(format));
|
659
|
+
if (shouldHandleTimezone(timezone)) {
|
660
|
+
return dayjsDate.tz(timezone).format(convertFormatToDayjs(format));
|
725
661
|
}
|
726
662
|
else {
|
727
|
-
return
|
663
|
+
return dayjsDate.format(convertFormatToDayjs(format.replace(/\s(z$|z\s)/, '')));
|
728
664
|
}
|
729
665
|
}
|
730
666
|
// Return the standard format.
|
731
|
-
return
|
667
|
+
return dayjsDate.format(convertFormatToDayjs(format));
|
732
668
|
}
|
733
669
|
if (timezone === 'UTC') {
|
734
|
-
const offset = offsetDate(
|
735
|
-
return `${(0,
|
670
|
+
const offset = offsetDate(dayjsDate.toDate(), 'UTC');
|
671
|
+
return `${(0, dayjs_1.default)(offset.date).format(convertFormatToDayjs(format))} UTC`;
|
736
672
|
}
|
737
|
-
|
738
|
-
|
739
|
-
if (moment_timezone_1.default.zonesLoaded && timezone) {
|
740
|
-
return momentDate.tz(timezone).format(`${convertFormatToMoment(format)} z`);
|
741
|
-
}
|
742
|
-
else {
|
743
|
-
return momentDate.format(convertFormatToMoment(format));
|
673
|
+
if (shouldHandleTimezone(timezone)) {
|
674
|
+
return dayjsDate.tz(timezone).format(`${convertFormatToDayjs(format)} z`);
|
744
675
|
}
|
676
|
+
return dayjsDate.format(convertFormatToDayjs(format));
|
745
677
|
}
|
746
678
|
exports.formatDate = formatDate;
|
747
679
|
/**
|
748
680
|
* Pass a format function to format within a timezone.
|
749
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
750
681
|
* @param {Function} formatFn - The format function to use.
|
751
682
|
* @param {Date|string} date - The date to format.
|
752
683
|
* @param {string} format - The format to format the date to.
|
753
684
|
* @param {string} timezone - The timezone to format the date to.
|
754
685
|
* @returns {string} - The formatted date.
|
755
686
|
*/
|
756
|
-
function formatOffset(
|
687
|
+
function formatOffset(formatFn, date, format, timezone) {
|
757
688
|
if (timezone === currentTimezone()) {
|
758
689
|
return formatFn(date, format);
|
759
690
|
}
|
760
691
|
if (timezone === 'UTC') {
|
761
692
|
return `${formatFn(offsetDate(date, 'UTC').date, format)} UTC`;
|
762
693
|
}
|
763
|
-
|
764
|
-
loadZones(timezonesUrl);
|
765
|
-
if (moment_timezone_1.default.zonesLoaded) {
|
694
|
+
if (shouldHandleTimezone(timezone)) {
|
766
695
|
const offset = offsetDate(date, timezone);
|
767
696
|
return `${formatFn(offset.date, format)} ${offset.abbr}`;
|
768
697
|
}
|
@@ -822,7 +751,7 @@ exports.convertFormatToFlatpickr = convertFormatToFlatpickr;
|
|
822
751
|
* @param {string} format - The format to convert.
|
823
752
|
* @returns {string} - The converted format.
|
824
753
|
*/
|
825
|
-
function
|
754
|
+
function convertFormatToDayjs(format) {
|
826
755
|
return format
|
827
756
|
// Year conversion.
|
828
757
|
.replace(/y/g, 'Y')
|
@@ -835,7 +764,7 @@ function convertFormatToMoment(format) {
|
|
835
764
|
// Unix Timestamp
|
836
765
|
.replace(/U/g, 'X');
|
837
766
|
}
|
838
|
-
exports.
|
767
|
+
exports.convertFormatToDayjs = convertFormatToDayjs;
|
839
768
|
/**
|
840
769
|
* Convert the format from the angular-datepicker module to mask format.
|
841
770
|
* @param {string} format - The format to convert.
|
@@ -1395,7 +1324,7 @@ exports.fastCloneDeep = fastCloneDeep;
|
|
1395
1324
|
/**
|
1396
1325
|
* Returns if the component is an input component.
|
1397
1326
|
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
1398
|
-
* @returns {
|
1327
|
+
* @returns {boolean} - TRUE if the component is an input component; FALSE otherwise.
|
1399
1328
|
*/
|
1400
1329
|
function isInputComponent(componentJson) {
|
1401
1330
|
if (componentJson.input === false || componentJson.input === true) {
|
@@ -1420,7 +1349,7 @@ exports.isInputComponent = isInputComponent;
|
|
1420
1349
|
/**
|
1421
1350
|
* Takes a component path, and returns a component path array.
|
1422
1351
|
* @param {string} pathStr - The path string to convert to an array.
|
1423
|
-
* @returns {
|
1352
|
+
* @returns {Array<string>} - The array of paths.
|
1424
1353
|
*/
|
1425
1354
|
function getArrayFromComponentPath(pathStr) {
|
1426
1355
|
if (!pathStr || !lodash_1.default.isString(pathStr)) {
|
@@ -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;
|