@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/mjs/utils/index.js
CHANGED
@@ -1,6 +1,23 @@
|
|
1
|
-
import * as
|
1
|
+
import * as utils from './utils';
|
2
|
+
import * as formUtils from './formUtils';
|
3
|
+
import { Evaluator, registerEvaluator, interpolate } from './Evaluator';
|
4
|
+
import ConditionOperators from './conditionOperators';
|
5
|
+
import _ from 'lodash';
|
6
|
+
import moment from 'moment';
|
7
|
+
const FormioUtils = {
|
8
|
+
...utils,
|
9
|
+
...formUtils,
|
10
|
+
Evaluator,
|
11
|
+
interpolate,
|
12
|
+
ConditionOperators,
|
13
|
+
_,
|
14
|
+
moment
|
15
|
+
};
|
2
16
|
if (typeof global === 'object') {
|
3
17
|
global.FormioUtils = FormioUtils;
|
4
18
|
}
|
5
19
|
export { FormioUtils as Utils };
|
20
|
+
export { Evaluator, registerEvaluator };
|
21
|
+
export * from './utils';
|
22
|
+
export * from './formUtils';
|
6
23
|
export default FormioUtils;
|
package/lib/mjs/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
|
194
|
+
* @returns {boolean} - TRUE if we should handle timezones; FALSE otherwise.
|
197
195
|
*/
|
198
|
-
export function
|
196
|
+
export function shouldHandleTimezone(timezone: string): boolean;
|
199
197
|
/**
|
200
|
-
*
|
201
|
-
* @param {string}
|
202
|
-
* @param {string} timezone - The timezone to load.
|
203
|
-
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
204
|
-
*/
|
205
|
-
export function loadZones(url: string, timezone: string): Promise<any> | any;
|
206
|
-
/**
|
207
|
-
* Get the moment date object for translating dates with timezones.
|
208
|
-
* @param {string|Date} value - The value to convert into a moment date.
|
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.
|
@@ -490,7 +479,15 @@ export function getFocusableElements(element: HTMLElement): NodeList<HTMLElement
|
|
490
479
|
* @returns {Array<string>|null} - The saved types for the component
|
491
480
|
*/
|
492
481
|
export function getComponentSavedTypes(fullSchema: import('@formio/core').Component): Array<string> | null;
|
493
|
-
|
482
|
+
/**
|
483
|
+
* Checks if a string has timezone information encoded in it
|
484
|
+
* Example: 2024-01-01T00:00:00Z -> true
|
485
|
+
* Example: 2024-01-01T00:00:00+03:00 -> true
|
486
|
+
* Example: 2011-05-03T00:00:00 -> false
|
487
|
+
* @param {string} value the string value to check
|
488
|
+
* @returns {boolean} if value has encoded timezone
|
489
|
+
*/
|
490
|
+
export function hasEncodedTimezone(value: string): boolean;
|
494
491
|
/**
|
495
492
|
* Map values through unfold and return first non-nil value.
|
496
493
|
* @param {Array<T>} collection - The collection to map through unfold.;
|
@@ -507,7 +504,4 @@ export namespace componentValueTypes {
|
|
507
504
|
let any: string;
|
508
505
|
}
|
509
506
|
export function interpolateErrors(component: Component, errors: FieldError[], interpolateFn: Function): [];
|
510
|
-
import
|
511
|
-
import { Evaluator } from './Evaluator';
|
512
|
-
export const interpolate: typeof Evaluator.interpolate;
|
513
|
-
export { jsonLogic, ConditionOperators, moment, Evaluator, _ };
|
507
|
+
import dayjs from "dayjs";
|
package/lib/mjs/utils/utils.js
CHANGED
@@ -1,30 +1,19 @@
|
|
1
1
|
/* global jQuery */
|
2
2
|
import _ from 'lodash';
|
3
|
-
import jsonLogic from 'json-logic-js';
|
4
3
|
import moment from 'moment-timezone/moment-timezone';
|
5
4
|
import jtz from 'jstimezonedetect';
|
6
|
-
import { lodashOperators } from './jsonlogic/operators';
|
7
5
|
import dompurify from 'dompurify';
|
6
|
+
import dayjs from "dayjs";
|
7
|
+
import utc from 'dayjs/plugin/utc';
|
8
|
+
import timezone from 'dayjs/plugin/timezone';
|
9
|
+
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
10
|
+
import { jsonLogic, convertShowToBoolean } from '@formio/core';
|
8
11
|
import { getValue } from './formUtils';
|
9
12
|
import { Evaluator } from './Evaluator';
|
10
13
|
import ConditionOperators from './conditionOperators';
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
lodashOperators.forEach((name) => jsonLogic.add_operation(`_${name}`, _[name]));
|
15
|
-
// Retrieve Any Date
|
16
|
-
jsonLogic.add_operation('getDate', (date) => {
|
17
|
-
return moment(date).toISOString();
|
18
|
-
});
|
19
|
-
// Set Relative Minimum Date
|
20
|
-
jsonLogic.add_operation('relativeMinDate', (relativeMinDate) => {
|
21
|
-
return moment().subtract(relativeMinDate, 'days').toISOString();
|
22
|
-
});
|
23
|
-
// Set Relative Maximum Date
|
24
|
-
jsonLogic.add_operation('relativeMaxDate', (relativeMaxDate) => {
|
25
|
-
return moment().add(relativeMaxDate, 'days').toISOString();
|
26
|
-
});
|
27
|
-
export { jsonLogic, ConditionOperators, moment };
|
14
|
+
dayjs.extend(timezone);
|
15
|
+
dayjs.extend(advancedFormat);
|
16
|
+
dayjs.extend(utc);
|
28
17
|
/**
|
29
18
|
* Evaluate a method.
|
30
19
|
* @param {Function|string|object} func - The function to evaluate.
|
@@ -210,7 +199,15 @@ export function checkSimpleConditional(component, condition, row, data, instance
|
|
210
199
|
return true;
|
211
200
|
}
|
212
201
|
const splittedConditionPath = conditionComponentPath.split('.');
|
213
|
-
const
|
202
|
+
const checkParentTypeInTree = (instance, componentType) => {
|
203
|
+
if (!instance?.parent) {
|
204
|
+
return false;
|
205
|
+
}
|
206
|
+
return instance?.parent.type === componentType || checkParentTypeInTree(instance.parent, componentType);
|
207
|
+
};
|
208
|
+
const conditionalPaths = checkParentTypeInTree(instance, 'datagrid') || checkParentTypeInTree(instance, 'editgrid')
|
209
|
+
? []
|
210
|
+
: getConditionalPathsRecursive(splittedConditionPath, data);
|
214
211
|
if (conditionalPaths.length > 0) {
|
215
212
|
return conditionalPaths.map((path) => {
|
216
213
|
const value = getComponentActualValue(path, data, row);
|
@@ -236,7 +233,7 @@ export function checkSimpleConditional(component, condition, row, data, instance
|
|
236
233
|
default:
|
237
234
|
result = _.every(conditionsResult.flat(), res => !!res);
|
238
235
|
}
|
239
|
-
return show ? result : !result;
|
236
|
+
return convertShowToBoolean(show) ? result : !result;
|
240
237
|
}
|
241
238
|
}
|
242
239
|
/**
|
@@ -324,7 +321,7 @@ function getRow(component, row, instance, conditional) {
|
|
324
321
|
}
|
325
322
|
const dataParent = getDataParentComponent(instance);
|
326
323
|
if (dataParent) {
|
327
|
-
const parentPath = dataParent.paths?.
|
324
|
+
const parentPath = dataParent.paths?.localPath;
|
328
325
|
const isTriggerCondtionComponentPath = condition.when || !condition.conditions
|
329
326
|
? condition.when?.startsWith(dataParent.paths?.localPath)
|
330
327
|
: _.some(condition.conditions, cond => cond.component.startsWith(dataParent.paths?.localPath));
|
@@ -504,7 +501,7 @@ export function guid() {
|
|
504
501
|
/**
|
505
502
|
* Return a translated date setting.
|
506
503
|
* @param {string|Date} date - The date to translate.
|
507
|
-
* @returns {(null|
|
504
|
+
* @returns {(null|dayjs.Dayjs)} - The translated date.
|
508
505
|
*/
|
509
506
|
export function getDateSetting(date) {
|
510
507
|
if (_.isNil(date) || _.isNaN(date) || date === '') {
|
@@ -524,13 +521,13 @@ export function getDateSetting(date) {
|
|
524
521
|
try {
|
525
522
|
const value = Evaluator.evaluator(`return ${date};`, 'moment')(moment);
|
526
523
|
if (typeof value === 'string') {
|
527
|
-
dateSetting =
|
524
|
+
dateSetting = dayjs(value);
|
528
525
|
}
|
529
526
|
else if (typeof value.toDate === 'function') {
|
530
|
-
dateSetting =
|
527
|
+
dateSetting = dayjs(value.toDate().toUTCString());
|
531
528
|
}
|
532
529
|
else if (value instanceof Date) {
|
533
|
-
dateSetting =
|
530
|
+
dateSetting = dayjs(value);
|
534
531
|
}
|
535
532
|
}
|
536
533
|
catch (e) {
|
@@ -558,17 +555,17 @@ export function isValidDate(date) {
|
|
558
555
|
* @returns {string} - The current timezone.
|
559
556
|
*/
|
560
557
|
export function currentTimezone() {
|
561
|
-
if (
|
562
|
-
return
|
558
|
+
if (dayjs.currentTimezone) {
|
559
|
+
return dayjs.currentTimezone;
|
563
560
|
}
|
564
|
-
|
565
|
-
return
|
561
|
+
dayjs.currentTimezone = jtz.determine().name();
|
562
|
+
return dayjs.currentTimezone;
|
566
563
|
}
|
567
564
|
/**
|
568
565
|
* Get an offset date provided a date object and timezone object.
|
569
566
|
* @param {Date} date - The date to offset.
|
570
567
|
* @param {string} timezone - The timezone to offset the date to.
|
571
|
-
* @returns {Date} - The offset date.
|
568
|
+
* @returns {{date: Date, abbr: string}} - The offset date.
|
572
569
|
*/
|
573
570
|
export function offsetDate(date, timezone) {
|
574
571
|
if (timezone === 'UTC') {
|
@@ -577,134 +574,89 @@ export function offsetDate(date, timezone) {
|
|
577
574
|
abbr: 'UTC'
|
578
575
|
};
|
579
576
|
}
|
580
|
-
const dateMoment =
|
577
|
+
const dateMoment = dayjs(date).tz(timezone);
|
581
578
|
return {
|
582
579
|
date: new Date(date.getTime() + ((dateMoment.utcOffset() + date.getTimezoneOffset()) * 60000)),
|
583
580
|
abbr: dateMoment.format('z')
|
584
581
|
};
|
585
582
|
}
|
586
583
|
/**
|
587
|
-
* Returns if
|
588
|
-
* @returns {boolean} - TRUE if the zones are loaded; FALSE otherwise.
|
589
|
-
*/
|
590
|
-
export function zonesLoaded() {
|
591
|
-
return moment.zonesLoaded;
|
592
|
-
}
|
593
|
-
/**
|
594
|
-
* Returns if we should load the zones.
|
584
|
+
* Returns if we should handle a timezone difference.
|
595
585
|
* @param {string} timezone - The timezone to check if we should load the zones.
|
596
|
-
* @returns {boolean} - TRUE if we should
|
586
|
+
* @returns {boolean} - TRUE if we should handle timezones; FALSE otherwise.
|
597
587
|
*/
|
598
|
-
export function
|
599
|
-
|
600
|
-
return false;
|
601
|
-
}
|
602
|
-
return true;
|
588
|
+
export function shouldHandleTimezone(timezone) {
|
589
|
+
return !(timezone === currentTimezone() || timezone === 'UTC');
|
603
590
|
}
|
604
591
|
/**
|
605
|
-
*
|
606
|
-
* @param {string}
|
607
|
-
* @param {string} timezone - The timezone to load.
|
608
|
-
* @returns {Promise<any> | *} - Resolves when the zones for this timezone are loaded.
|
609
|
-
*/
|
610
|
-
export function loadZones(url, timezone) {
|
611
|
-
if (timezone && !shouldLoadZones(timezone)) {
|
612
|
-
// Return non-resolving promise.
|
613
|
-
return new Promise(_.noop);
|
614
|
-
}
|
615
|
-
if (moment.zonesPromise) {
|
616
|
-
return moment.zonesPromise;
|
617
|
-
}
|
618
|
-
return moment.zonesPromise = fetch(url)
|
619
|
-
.then(resp => resp.json().then(zones => {
|
620
|
-
moment.tz.load(zones);
|
621
|
-
moment.zonesLoaded = true;
|
622
|
-
// Trigger a global event that the timezones have finished loading.
|
623
|
-
if (document && document.createEvent && document.body && document.body.dispatchEvent) {
|
624
|
-
var event = document.createEvent('Event');
|
625
|
-
event.initEvent('zonesLoaded', true, true);
|
626
|
-
document.body.dispatchEvent(event);
|
627
|
-
}
|
628
|
-
}));
|
629
|
-
}
|
630
|
-
/**
|
631
|
-
* Get the moment date object for translating dates with timezones.
|
632
|
-
* @param {string|Date} value - The value to convert into a moment date.
|
592
|
+
* Get the Dayjs date object for translating dates with timezones.
|
593
|
+
* @param {string|Date} value - The value to convert into a dayjs date.
|
633
594
|
* @param {string} format - The format to convert the date to.
|
634
595
|
* @param {string} timezone - The timezone to convert the date to.
|
635
596
|
* @param {object} options - The options object
|
636
|
-
* @returns {
|
597
|
+
* @returns {dayjs.Dayjs} - The dayjs date object.
|
637
598
|
*/
|
638
|
-
export function
|
639
|
-
const
|
599
|
+
export function dayjsDate(value, format, timezone, options) {
|
600
|
+
const dayjsDate = dayjs(value);
|
640
601
|
if (!timezone) {
|
641
|
-
return
|
602
|
+
return dayjsDate;
|
642
603
|
}
|
643
604
|
if (timezone === 'UTC') {
|
644
605
|
timezone = 'Etc/UTC';
|
645
606
|
}
|
646
|
-
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (
|
647
|
-
return
|
607
|
+
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (shouldHandleTimezone(timezone) || options?.email)) {
|
608
|
+
return dayjsDate.tz(timezone);
|
648
609
|
}
|
649
|
-
return
|
610
|
+
return dayjsDate;
|
650
611
|
}
|
651
612
|
/**
|
652
613
|
* Format a date provided a value, format, and timezone object.
|
653
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
654
614
|
* @param {string|Date} value - The value to format.
|
655
615
|
* @param {string} format - The format to format the date to.
|
656
616
|
* @param {string} timezone - The timezone to format the date to.
|
657
617
|
* @param {string} flatPickrInputFormat - The format to use for flatpickr input.
|
658
618
|
* @returns {string} - The formatted date.
|
659
619
|
*/
|
660
|
-
export function formatDate(
|
661
|
-
const
|
620
|
+
export function formatDate(value, format, timezone, flatPickrInputFormat) {
|
621
|
+
const dayjsDate = dayjs(value, flatPickrInputFormat || undefined);
|
662
622
|
if (timezone === currentTimezone()) {
|
663
623
|
// See if our format contains a "z" timezone character.
|
664
624
|
if (format.match(/\s(z$|z\s)/)) {
|
665
|
-
|
666
|
-
|
667
|
-
return momentDate.tz(timezone).format(convertFormatToMoment(format));
|
625
|
+
if (shouldHandleTimezone(timezone)) {
|
626
|
+
return dayjsDate.tz(timezone).format(convertFormatToDayjs(format));
|
668
627
|
}
|
669
628
|
else {
|
670
|
-
return
|
629
|
+
return dayjsDate.format(convertFormatToDayjs(format.replace(/\s(z$|z\s)/, '')));
|
671
630
|
}
|
672
631
|
}
|
673
632
|
// Return the standard format.
|
674
|
-
return
|
633
|
+
return dayjsDate.format(convertFormatToDayjs(format));
|
675
634
|
}
|
676
635
|
if (timezone === 'UTC') {
|
677
|
-
const offset = offsetDate(
|
678
|
-
return `${
|
679
|
-
}
|
680
|
-
// Load the zones since we need timezone information.
|
681
|
-
loadZones(timezonesUrl);
|
682
|
-
if (moment.zonesLoaded && timezone) {
|
683
|
-
return momentDate.tz(timezone).format(`${convertFormatToMoment(format)} z`);
|
636
|
+
const offset = offsetDate(dayjsDate.toDate(), 'UTC');
|
637
|
+
return `${dayjs(offset.date).format(convertFormatToDayjs(format))} UTC`;
|
684
638
|
}
|
685
|
-
|
686
|
-
return
|
639
|
+
if (shouldHandleTimezone(timezone)) {
|
640
|
+
return dayjsDate.tz(timezone).format(`${convertFormatToDayjs(format)} z`);
|
687
641
|
}
|
642
|
+
return dayjsDate.format(convertFormatToDayjs(format));
|
688
643
|
}
|
689
644
|
/**
|
690
645
|
* Pass a format function to format within a timezone.
|
691
|
-
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
692
646
|
* @param {Function} formatFn - The format function to use.
|
693
647
|
* @param {Date|string} date - The date to format.
|
694
648
|
* @param {string} format - The format to format the date to.
|
695
649
|
* @param {string} timezone - The timezone to format the date to.
|
696
650
|
* @returns {string} - The formatted date.
|
697
651
|
*/
|
698
|
-
export function formatOffset(
|
652
|
+
export function formatOffset(formatFn, date, format, timezone) {
|
699
653
|
if (timezone === currentTimezone()) {
|
700
654
|
return formatFn(date, format);
|
701
655
|
}
|
702
656
|
if (timezone === 'UTC') {
|
703
657
|
return `${formatFn(offsetDate(date, 'UTC').date, format)} UTC`;
|
704
658
|
}
|
705
|
-
|
706
|
-
loadZones(timezonesUrl);
|
707
|
-
if (moment.zonesLoaded) {
|
659
|
+
if (shouldHandleTimezone(timezone)) {
|
708
660
|
const offset = offsetDate(date, timezone);
|
709
661
|
return `${formatFn(offset.date, format)} ${offset.abbr}`;
|
710
662
|
}
|
@@ -761,7 +713,7 @@ export function convertFormatToFlatpickr(format) {
|
|
761
713
|
* @param {string} format - The format to convert.
|
762
714
|
* @returns {string} - The converted format.
|
763
715
|
*/
|
764
|
-
export function
|
716
|
+
export function convertFormatToDayjs(format) {
|
765
717
|
return format
|
766
718
|
// Year conversion.
|
767
719
|
.replace(/y/g, 'Y')
|
@@ -1310,11 +1262,10 @@ export function sanitize(string, options) {
|
|
1310
1262
|
export function fastCloneDeep(obj) {
|
1311
1263
|
return obj ? JSON.parse(JSON.stringify(obj)) : obj;
|
1312
1264
|
}
|
1313
|
-
export { Evaluator, interpolate };
|
1314
1265
|
/**
|
1315
1266
|
* Returns if the component is an input component.
|
1316
1267
|
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
1317
|
-
* @returns {
|
1268
|
+
* @returns {boolean} - TRUE if the component is an input component; FALSE otherwise.
|
1318
1269
|
*/
|
1319
1270
|
export function isInputComponent(componentJson) {
|
1320
1271
|
if (componentJson.input === false || componentJson.input === true) {
|
@@ -1338,7 +1289,7 @@ export function isInputComponent(componentJson) {
|
|
1338
1289
|
/**
|
1339
1290
|
* Takes a component path, and returns a component path array.
|
1340
1291
|
* @param {string} pathStr - The path string to convert to an array.
|
1341
|
-
* @returns {
|
1292
|
+
* @returns {Array<string>} - The array of paths.
|
1342
1293
|
*/
|
1343
1294
|
export function getArrayFromComponentPath(pathStr) {
|
1344
1295
|
if (!pathStr || !_.isString(pathStr)) {
|
@@ -1512,8 +1463,6 @@ export function getFocusableElements(element) {
|
|
1512
1463
|
textarea:not([disabled]), button:not([disabled]), [href]`;
|
1513
1464
|
return element.querySelectorAll(focusableSelector);
|
1514
1465
|
}
|
1515
|
-
// Export lodash to save space with other libraries.
|
1516
|
-
export { _ };
|
1517
1466
|
export const componentValueTypes = {
|
1518
1467
|
number: 'number',
|
1519
1468
|
string: 'string',
|
@@ -1553,3 +1502,17 @@ export const interpolateErrors = (component, errors, interpolateFn) => {
|
|
1553
1502
|
return { ...error, message: unescapeHTML(interpolateFn(toInterpolate, context)), context: { ...context } };
|
1554
1503
|
});
|
1555
1504
|
};
|
1505
|
+
/**
|
1506
|
+
* Checks if a string has timezone information encoded in it
|
1507
|
+
* Example: 2024-01-01T00:00:00Z -> true
|
1508
|
+
* Example: 2024-01-01T00:00:00+03:00 -> true
|
1509
|
+
* Example: 2011-05-03T00:00:00 -> false
|
1510
|
+
* @param {string} value the string value to check
|
1511
|
+
* @returns {boolean} if value has encoded timezone
|
1512
|
+
*/
|
1513
|
+
export function hasEncodedTimezone(value) {
|
1514
|
+
if (typeof value !== 'string') {
|
1515
|
+
return false;
|
1516
|
+
}
|
1517
|
+
return (value.substring(value.length - 1) === 'z' || value.substring(value.length - 1) === 'Z' || value.match(/[+|-][0-9]{2}:[0-9]{2}$/));
|
1518
|
+
}
|
@@ -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;
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { Formio } from '../Formio';
|
2
|
-
import InputWidget from './InputWidget';
|
3
|
-
import { convertFormatToFlatpickr, convertFormatToMask, convertFormatToMoment, formatDate, formatOffset, getBrowserInfo, getDateSetting, getLocaleDateFormatInfo, momentDate, zonesLoaded, shouldLoadZones, loadZones, } from '../utils/utils';
|
4
1
|
import moment from 'moment';
|
5
2
|
import _ from 'lodash';
|
3
|
+
import { Formio } from '../Formio';
|
4
|
+
import InputWidget from './InputWidget';
|
5
|
+
import { convertFormatToFlatpickr, convertFormatToMask, convertFormatToDayjs, formatDate, formatOffset, getBrowserInfo, getDateSetting, getLocaleDateFormatInfo, hasEncodedTimezone, dayjsDate } from '../utils';
|
6
6
|
const DEFAULT_FORMAT = 'yyyy-MM-dd hh:mm a';
|
7
7
|
const ISO_8601_FORMAT = 'yyyy-MM-ddTHH:mm:ssZ';
|
8
8
|
const isIEBrowser = getBrowserInfo().ie;
|
@@ -46,29 +46,6 @@ export default class CalendarWidget extends InputWidget {
|
|
46
46
|
else if (this.settings.time_24hr) {
|
47
47
|
this.settings.format = this.settings.format.replace(/hh:mm a$/g, 'HH:mm');
|
48
48
|
}
|
49
|
-
this.zoneLoading = false;
|
50
|
-
this.timezonesUrl = `${Formio.cdn['moment-timezone']}/data/packed/latest.json`;
|
51
|
-
}
|
52
|
-
/**
|
53
|
-
* Load the timezones.
|
54
|
-
* @returns {boolean} TRUE if the zones are loading, FALSE otherwise.
|
55
|
-
*/
|
56
|
-
loadZones() {
|
57
|
-
const timezone = this.timezone;
|
58
|
-
if (this.zoneLoading) {
|
59
|
-
return true;
|
60
|
-
}
|
61
|
-
if (!zonesLoaded() && shouldLoadZones(timezone)) {
|
62
|
-
this.zoneLoading = true;
|
63
|
-
loadZones(this.timezonesUrl, timezone).then(() => {
|
64
|
-
this.zoneLoading = false;
|
65
|
-
this.emit('redraw');
|
66
|
-
});
|
67
|
-
// Return zones are loading.
|
68
|
-
return true;
|
69
|
-
}
|
70
|
-
// Zones are already loaded.
|
71
|
-
return false;
|
72
49
|
}
|
73
50
|
attach(input) {
|
74
51
|
const superAttach = super.attach(input);
|
@@ -79,7 +56,7 @@ export default class CalendarWidget extends InputWidget {
|
|
79
56
|
};
|
80
57
|
this.closedOn = 0;
|
81
58
|
this.valueFormat = (this.settings.saveAs === 'date') ? ISO_8601_FORMAT : this.settings.dateFormat || ISO_8601_FORMAT;
|
82
|
-
this.valueMomentFormat =
|
59
|
+
this.valueMomentFormat = convertFormatToDayjs(this.valueFormat);
|
83
60
|
const isReadOnly = this.settings.readOnly;
|
84
61
|
this.settings.minDate = isReadOnly ? null : getDateSetting(this.settings.minDate);
|
85
62
|
this.settings.maxDate = isReadOnly ? null : getDateSetting(this.settings.maxDate);
|
@@ -241,9 +218,9 @@ export default class CalendarWidget extends InputWidget {
|
|
241
218
|
*/
|
242
219
|
getDateValue(date, format, useTimezone) {
|
243
220
|
if (useTimezone) {
|
244
|
-
return
|
221
|
+
return dayjsDate(date, this.valueFormat, this.timezone).format(convertFormatToDayjs(format));
|
245
222
|
}
|
246
|
-
return moment(date).format(
|
223
|
+
return moment(date).format(convertFormatToDayjs(format));
|
247
224
|
}
|
248
225
|
/**
|
249
226
|
* Return the value of the selected date.
|
@@ -275,13 +252,15 @@ export default class CalendarWidget extends InputWidget {
|
|
275
252
|
setValue(value) {
|
276
253
|
const saveAsText = (this.settings.saveAs === 'text');
|
277
254
|
if (!this.calendar) {
|
278
|
-
value = value ? formatDate(
|
255
|
+
value = value ? formatDate(value, convertFormatToDayjs(this.settings.format), this.timezone, convertFormatToDayjs(this.valueMomentFormat)) : value;
|
279
256
|
return super.setValue(value);
|
280
257
|
}
|
281
|
-
|
258
|
+
// If the component is a textfield that does not have timezone information included in the string value then skip
|
259
|
+
// the timezone offset
|
260
|
+
this.settings.skipOffset = this.component.type === 'textfield' && !hasEncodedTimezone(value);
|
282
261
|
if (value) {
|
283
|
-
if (!saveAsText && this.settings.readOnly
|
284
|
-
this.calendar.setDate(
|
262
|
+
if (!saveAsText && this.settings.readOnly) {
|
263
|
+
this.calendar.setDate(dayjsDate(value, this.valueFormat, this.timezone).format(), false);
|
285
264
|
}
|
286
265
|
else if (this.isValueISO8601(value)) {
|
287
266
|
this.calendar.setDate(value, false);
|
@@ -294,13 +273,13 @@ export default class CalendarWidget extends InputWidget {
|
|
294
273
|
this.calendar.clear(false);
|
295
274
|
}
|
296
275
|
}
|
297
|
-
getValueAsString(value, format) {
|
276
|
+
getValueAsString(value, format = '') {
|
298
277
|
const inputFormat = format || this.dateFormat;
|
299
278
|
const valueFormat = this.calendar ? this.valueFormat : this.settings.dateFormat;
|
300
279
|
if (this.settings.saveAs === 'text' && this.componentInstance.parent && !this.settings.readOnly) {
|
301
|
-
return moment(value,
|
280
|
+
return moment(value, convertFormatToDayjs(valueFormat)).format(convertFormatToDayjs(valueFormat));
|
302
281
|
}
|
303
|
-
return formatDate(
|
282
|
+
return formatDate(value, inputFormat, this.timezone, convertFormatToDayjs(valueFormat));
|
304
283
|
}
|
305
284
|
setErrorClasses(hasErrors) {
|
306
285
|
if (!this.input) {
|
@@ -391,7 +370,7 @@ export default class CalendarWidget extends InputWidget {
|
|
391
370
|
const relatedTarget = event.relatedTarget ? event.relatedTarget : activeElement;
|
392
371
|
if (!(isIEBrowser && !relatedTarget) && !this.isCalendarElement(relatedTarget)) {
|
393
372
|
const inputValue = this.calendar.input.value;
|
394
|
-
const dateValue = inputValue ? moment(this.calendar.input.value,
|
373
|
+
const dateValue = inputValue ? moment(this.calendar.input.value, convertFormatToDayjs(this.valueFormat)).toDate() : inputValue;
|
395
374
|
this.calendar.setDate(dateValue, true, this.settings.altFormat);
|
396
375
|
}
|
397
376
|
else if (!this.calendar.input.value && this.calendar.config.noCalendar) {
|
@@ -443,14 +422,14 @@ export default class CalendarWidget extends InputWidget {
|
|
443
422
|
return (date, format) => {
|
444
423
|
// Only format this if this is the altFormat and the form is readOnly.
|
445
424
|
if (this.settings.readOnly && (format === this.settings.altFormat)) {
|
446
|
-
if (!this.settings.enableTime || this.
|
425
|
+
if (!this.settings.enableTime || this.settings.skipOffset) {
|
447
426
|
return Flatpickr.formatDate(date, format);
|
448
427
|
}
|
449
428
|
const currentValue = new Date(this.getValue());
|
450
429
|
if (currentValue.toString() === date.toString()) {
|
451
|
-
return formatOffset(
|
430
|
+
return formatOffset(Flatpickr.formatDate.bind(Flatpickr), new Date(this.componentValue), format, this.timezone);
|
452
431
|
}
|
453
|
-
return formatOffset(
|
432
|
+
return formatOffset(Flatpickr.formatDate.bind(Flatpickr), date, format, this.timezone);
|
454
433
|
}
|
455
434
|
return Flatpickr.formatDate(date, format);
|
456
435
|
};
|