@formio/js 5.1.0-dev.6094.c49181e → 5.1.0-dev.6096.8115e4f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formio.form.js +7 -7
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +8 -8
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.utils.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Webform.js +2 -2
- package/lib/cjs/WebformBuilder.d.ts +1 -0
- package/lib/cjs/WebformBuilder.js +14 -0
- package/lib/cjs/components/button/Button.d.ts +1 -1
- package/lib/cjs/components/button/Button.js +6 -10
- package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/cjs/components/datetime/DateTime.js +12 -14
- package/lib/cjs/components/file/File.js +4 -5
- package/lib/cjs/providers/storage/uploadAdapter.js +2 -2
- package/lib/cjs/utils/utils.d.ts +28 -18
- package/lib/cjs/utils/utils.js +89 -49
- package/lib/cjs/widgets/CalendarWidget.d.ts +7 -0
- package/lib/cjs/widgets/CalendarWidget.js +36 -12
- package/lib/mjs/Webform.js +2 -2
- package/lib/mjs/WebformBuilder.d.ts +1 -0
- package/lib/mjs/WebformBuilder.js +13 -0
- package/lib/mjs/components/button/Button.d.ts +1 -1
- package/lib/mjs/components/button/Button.js +6 -9
- package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/mjs/components/datetime/DateTime.js +12 -14
- package/lib/mjs/components/file/File.js +4 -5
- package/lib/mjs/providers/storage/uploadAdapter.js +2 -2
- package/lib/mjs/utils/utils.d.ts +28 -18
- package/lib/mjs/utils/utils.js +82 -44
- package/lib/mjs/widgets/CalendarWidget.d.ts +7 -0
- package/lib/mjs/widgets/CalendarWidget.js +37 -13
- package/package.json +1 -2
@@ -51,6 +51,29 @@ class CalendarWidget extends InputWidget_1.default {
|
|
51
51
|
else if (this.settings.time_24hr) {
|
52
52
|
this.settings.format = this.settings.format.replace(/hh:mm a$/g, 'HH:mm');
|
53
53
|
}
|
54
|
+
this.zoneLoading = false;
|
55
|
+
this.timezonesUrl = `${Formio_1.Formio.cdn['moment-timezone']}/data/packed/latest.json`;
|
56
|
+
}
|
57
|
+
/**
|
58
|
+
* Load the timezones.
|
59
|
+
* @returns {boolean} TRUE if the zones are loading, FALSE otherwise.
|
60
|
+
*/
|
61
|
+
loadZones() {
|
62
|
+
const timezone = this.timezone;
|
63
|
+
if (this.zoneLoading) {
|
64
|
+
return true;
|
65
|
+
}
|
66
|
+
if (!(0, utils_1.zonesLoaded)() && (0, utils_1.shouldLoadZones)(timezone)) {
|
67
|
+
this.zoneLoading = true;
|
68
|
+
(0, utils_1.loadZones)(this.timezonesUrl, timezone).then(() => {
|
69
|
+
this.zoneLoading = false;
|
70
|
+
this.emit('redraw');
|
71
|
+
});
|
72
|
+
// Return zones are loading.
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
// Zones are already loaded.
|
76
|
+
return false;
|
54
77
|
}
|
55
78
|
attach(input) {
|
56
79
|
var _a;
|
@@ -62,7 +85,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
62
85
|
};
|
63
86
|
this.closedOn = 0;
|
64
87
|
this.valueFormat = (this.settings.saveAs === 'date') ? ISO_8601_FORMAT : this.settings.dateFormat || ISO_8601_FORMAT;
|
65
|
-
this.valueMomentFormat = (0, utils_1.
|
88
|
+
this.valueMomentFormat = (0, utils_1.convertFormatToMoment)(this.valueFormat);
|
66
89
|
const isReadOnly = this.settings.readOnly;
|
67
90
|
this.settings.minDate = isReadOnly ? null : (0, utils_1.getDateSetting)(this.settings.minDate);
|
68
91
|
this.settings.maxDate = isReadOnly ? null : (0, utils_1.getDateSetting)(this.settings.maxDate);
|
@@ -226,9 +249,9 @@ class CalendarWidget extends InputWidget_1.default {
|
|
226
249
|
*/
|
227
250
|
getDateValue(date, format, useTimezone) {
|
228
251
|
if (useTimezone) {
|
229
|
-
return (0, utils_1.
|
252
|
+
return (0, utils_1.momentDate)(date, this.valueFormat, this.timezone).format((0, utils_1.convertFormatToMoment)(format));
|
230
253
|
}
|
231
|
-
return (0, moment_1.default)(date).format((0, utils_1.
|
254
|
+
return (0, moment_1.default)(date).format((0, utils_1.convertFormatToMoment)(format));
|
232
255
|
}
|
233
256
|
/**
|
234
257
|
* Return the value of the selected date.
|
@@ -260,7 +283,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
260
283
|
setValue(value) {
|
261
284
|
const saveAsText = (this.settings.saveAs === 'text');
|
262
285
|
if (!this.calendar) {
|
263
|
-
value = value ? (0, utils_1.formatDate)(value, (0, utils_1.
|
286
|
+
value = value ? (0, utils_1.formatDate)(this.timezonesUrl, value, (0, utils_1.convertFormatToMoment)(this.settings.format), this.timezone, (0, utils_1.convertFormatToMoment)(this.valueMomentFormat)) : value;
|
264
287
|
return super.setValue(value);
|
265
288
|
}
|
266
289
|
// If the component is a textfield that does not have timezone information included in the string value then skip
|
@@ -268,9 +291,10 @@ class CalendarWidget extends InputWidget_1.default {
|
|
268
291
|
if (this.component.type === 'textfield' && !(0, utils_1.hasEncodedTimezone)(value)) {
|
269
292
|
this.settings.skipOffset = true;
|
270
293
|
}
|
294
|
+
const zonesLoading = this.loadZones();
|
271
295
|
if (value) {
|
272
|
-
if (!saveAsText && this.settings.readOnly) {
|
273
|
-
this.calendar.setDate((0, utils_1.
|
296
|
+
if (!saveAsText && this.settings.readOnly && !zonesLoading) {
|
297
|
+
this.calendar.setDate((0, utils_1.momentDate)(value, this.valueFormat, this.timezone).format(), false);
|
274
298
|
}
|
275
299
|
else if (this.isValueISO8601(value)) {
|
276
300
|
this.calendar.setDate(value, false);
|
@@ -287,9 +311,9 @@ class CalendarWidget extends InputWidget_1.default {
|
|
287
311
|
const inputFormat = format || this.dateFormat;
|
288
312
|
const valueFormat = this.calendar ? this.valueFormat : this.settings.dateFormat;
|
289
313
|
if (this.settings.saveAs === 'text' && this.componentInstance.parent && !this.settings.readOnly) {
|
290
|
-
return (0, moment_1.default)(value, (0, utils_1.
|
314
|
+
return (0, moment_1.default)(value, (0, utils_1.convertFormatToMoment)(valueFormat)).format((0, utils_1.convertFormatToMoment)(valueFormat));
|
291
315
|
}
|
292
|
-
return (0, utils_1.formatDate)(value, inputFormat, this.timezone, (0, utils_1.
|
316
|
+
return (0, utils_1.formatDate)(this.timezonesUrl, value, inputFormat, this.timezone, (0, utils_1.convertFormatToMoment)(valueFormat));
|
293
317
|
}
|
294
318
|
setErrorClasses(hasErrors) {
|
295
319
|
if (!this.input) {
|
@@ -382,7 +406,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
382
406
|
const relatedTarget = event.relatedTarget ? event.relatedTarget : activeElement;
|
383
407
|
if (!(isIEBrowser && !relatedTarget) && !this.isCalendarElement(relatedTarget)) {
|
384
408
|
const inputValue = this.calendar.input.value;
|
385
|
-
const dateValue = inputValue ? (0, moment_1.default)(this.calendar.input.value, (0, utils_1.
|
409
|
+
const dateValue = inputValue ? (0, moment_1.default)(this.calendar.input.value, (0, utils_1.convertFormatToMoment)(this.valueFormat)).toDate() : inputValue;
|
386
410
|
this.calendar.setDate(dateValue, true, this.settings.altFormat);
|
387
411
|
}
|
388
412
|
else if (!this.calendar.input.value && this.calendar.config.noCalendar) {
|
@@ -434,14 +458,14 @@ class CalendarWidget extends InputWidget_1.default {
|
|
434
458
|
return (date, format) => {
|
435
459
|
// Only format this if this is the altFormat and the form is readOnly.
|
436
460
|
if (this.settings.readOnly && (format === this.settings.altFormat)) {
|
437
|
-
if (!this.settings.enableTime || this.settings.skipOffset) {
|
461
|
+
if (!this.settings.enableTime || this.loadZones() || this.settings.skipOffset) {
|
438
462
|
return Flatpickr.formatDate(date, format);
|
439
463
|
}
|
440
464
|
const currentValue = new Date(this.getValue());
|
441
465
|
if (currentValue.toString() === date.toString()) {
|
442
|
-
return (0, utils_1.formatOffset)(Flatpickr.formatDate.bind(Flatpickr), new Date(this.componentValue), format, this.timezone);
|
466
|
+
return (0, utils_1.formatOffset)(this.timezonesUrl, Flatpickr.formatDate.bind(Flatpickr), new Date(this.componentValue), format, this.timezone);
|
443
467
|
}
|
444
|
-
return (0, utils_1.formatOffset)(Flatpickr.formatDate.bind(Flatpickr), date, format, this.timezone);
|
468
|
+
return (0, utils_1.formatOffset)(this.timezonesUrl, Flatpickr.formatDate.bind(Flatpickr), date, format, this.timezone);
|
445
469
|
}
|
446
470
|
return Flatpickr.formatDate(date, format);
|
447
471
|
};
|
package/lib/mjs/Webform.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import _ from 'lodash';
|
2
|
+
import moment from 'moment';
|
2
3
|
import { compareVersions } from 'compare-versions';
|
3
4
|
import EventEmitter from './EventEmitter';
|
4
5
|
import i18nDefaults from './i18n';
|
@@ -7,7 +8,6 @@ import Components from './components/Components';
|
|
7
8
|
import NestedDataComponent from './components/_classes/nesteddata/NestedDataComponent';
|
8
9
|
import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, } from './utils/utils';
|
9
10
|
import { eachComponent } from './utils/formUtils';
|
10
|
-
import dayjs from "dayjs";
|
11
11
|
// We need this here because dragula pulls in CustomEvent class that requires global to exist.
|
12
12
|
if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
|
13
13
|
window.global = window;
|
@@ -1317,7 +1317,7 @@ export default class Webform extends NestedDataComponent {
|
|
1317
1317
|
submission.metadata = submission.metadata || {};
|
1318
1318
|
_.defaults(submission.metadata, {
|
1319
1319
|
timezone: _.get(this, '_submission.metadata.timezone', currentTimezone()),
|
1320
|
-
offset: parseInt(_.get(this, '_submission.metadata.offset',
|
1320
|
+
offset: parseInt(_.get(this, '_submission.metadata.offset', moment().utcOffset()), 10),
|
1321
1321
|
origin: document.location.origin,
|
1322
1322
|
referrer: document.referrer,
|
1323
1323
|
browserName: navigator.appName,
|
@@ -77,6 +77,7 @@ export default class WebformBuilder extends Component {
|
|
77
77
|
removeComponent(component: any, parent: any, original: any, componentInstance: any): boolean | undefined;
|
78
78
|
replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
|
79
79
|
updateComponent(component: any, changed: any): void;
|
80
|
+
originalDefaultValue: any;
|
80
81
|
findRepeatablePaths(): any[];
|
81
82
|
highlightInvalidComponents(): void;
|
82
83
|
/**
|
@@ -1054,6 +1054,16 @@ export default class WebformBuilder extends Component {
|
|
1054
1054
|
'fields.month.required',
|
1055
1055
|
'fields.year.required',
|
1056
1056
|
]));
|
1057
|
+
if (defaultValueComponent.component.components) {
|
1058
|
+
if (!this.originalDefaultValue) {
|
1059
|
+
this.originalDefaultValue = fastCloneDeep(defaultValueComponent.component);
|
1060
|
+
}
|
1061
|
+
eachComponent(defaultValueComponent.component.components, (comp => {
|
1062
|
+
if (comp.validate?.required) {
|
1063
|
+
comp.validate.required = false;
|
1064
|
+
}
|
1065
|
+
}));
|
1066
|
+
}
|
1057
1067
|
const parentComponent = defaultValueComponent.parent;
|
1058
1068
|
let tabIndex = -1;
|
1059
1069
|
let index = -1;
|
@@ -1145,6 +1155,9 @@ export default class WebformBuilder extends Component {
|
|
1145
1155
|
if (index !== -1) {
|
1146
1156
|
let submissionData = this.editForm.submission.data;
|
1147
1157
|
submissionData = submissionData.componentJson || submissionData;
|
1158
|
+
if (submissionData.components && this.originalDefaultValue) {
|
1159
|
+
submissionData.components = this.originalDefaultValue.components;
|
1160
|
+
}
|
1148
1161
|
const fieldsToRemoveDoubleQuotes = ['label', 'tooltip'];
|
1149
1162
|
this.replaceDoubleQuotes(submissionData, fieldsToRemoveDoubleQuotes);
|
1150
1163
|
this.hook('beforeSaveComponentSettings', submissionData);
|
@@ -9,7 +9,7 @@ export default class ButtonComponent extends Field {
|
|
9
9
|
};
|
10
10
|
static savedValueTypes(schema: any): string[];
|
11
11
|
constructor(component: any, options: any, data: any);
|
12
|
-
filesUploading:
|
12
|
+
filesUploading: number;
|
13
13
|
get inputInfo(): any;
|
14
14
|
get labelInfo(): {
|
15
15
|
hidden: boolean;
|
@@ -34,7 +34,7 @@ export default class ButtonComponent extends Field {
|
|
34
34
|
}
|
35
35
|
constructor(component, options, data) {
|
36
36
|
super(component, options, data);
|
37
|
-
this.filesUploading =
|
37
|
+
this.filesUploading = 0;
|
38
38
|
}
|
39
39
|
get defaultSchema() {
|
40
40
|
return ButtonComponent.schema();
|
@@ -142,16 +142,13 @@ export default class ButtonComponent extends Field {
|
|
142
142
|
this.addClass(this.refs.buttonMessageContainer, 'has-error');
|
143
143
|
this.setContent(this.refs.buttonMessage, resultMessage);
|
144
144
|
}, true);
|
145
|
-
this.on('fileUploadingStart', (
|
146
|
-
this.filesUploading
|
145
|
+
this.on('fileUploadingStart', () => {
|
146
|
+
this.filesUploading++;
|
147
147
|
this.disabled = true;
|
148
148
|
this.setDisabled(this.refs.button, this.disabled);
|
149
149
|
}, true);
|
150
|
-
this.on('fileUploadingEnd', (
|
151
|
-
|
152
|
-
if (index !== -1) {
|
153
|
-
this.filesUploading.splice(index, 1);
|
154
|
-
}
|
150
|
+
this.on('fileUploadingEnd', () => {
|
151
|
+
this.filesUploading--;
|
155
152
|
this.disabled = this.shouldDisabled ? true : false;
|
156
153
|
this.setDisabled(this.refs.button, this.disabled);
|
157
154
|
}, true);
|
@@ -247,7 +244,7 @@ export default class ButtonComponent extends Field {
|
|
247
244
|
}
|
248
245
|
}
|
249
246
|
get shouldDisabled() {
|
250
|
-
return super.shouldDisabled ||
|
247
|
+
return super.shouldDisabled || this.filesUploading > 0 || this.isDisabledOnInvalid;
|
251
248
|
}
|
252
249
|
attach(element) {
|
253
250
|
this.loadRefs(element, {
|
@@ -17,7 +17,7 @@ export default class DateTimeComponent extends Input {
|
|
17
17
|
};
|
18
18
|
static savedValueTypes(schema: any): string[];
|
19
19
|
get emptyValue(): string;
|
20
|
-
get
|
20
|
+
get momentFormat(): string;
|
21
21
|
createWrapper(): boolean;
|
22
22
|
checkValidity(data: any, dirty: any, rowData: any): boolean;
|
23
23
|
getValueAsString(value: any, options: any): any;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import _ from 'lodash';
|
2
|
-
import
|
2
|
+
import moment from 'moment';
|
3
3
|
import FormioUtils from '../../utils';
|
4
4
|
import { componentValueTypes, fastCloneDeep, getComponentSavedTypes } from '../../utils/utils';
|
5
5
|
import Input from '../_classes/input/Input';
|
@@ -147,8 +147,8 @@ export default class DateTimeComponent extends Input {
|
|
147
147
|
get emptyValue() {
|
148
148
|
return '';
|
149
149
|
}
|
150
|
-
get
|
151
|
-
return FormioUtils.
|
150
|
+
get momentFormat() {
|
151
|
+
return FormioUtils.convertFormatToMoment(this.component.format);
|
152
152
|
}
|
153
153
|
isEmpty(value = this.dataValue) {
|
154
154
|
if (value && (value.toString() === 'Invalid Date')) {
|
@@ -157,14 +157,12 @@ export default class DateTimeComponent extends Input {
|
|
157
157
|
return super.isEmpty(value);
|
158
158
|
}
|
159
159
|
formatValue(input) {
|
160
|
-
|
161
|
-
|
162
|
-
}
|
163
|
-
return input;
|
160
|
+
const result = moment.utc(input).toISOString();
|
161
|
+
return result === 'Invalid date' ? input : result;
|
164
162
|
}
|
165
163
|
isEqual(valueA, valueB = this.dataValue) {
|
166
164
|
return (this.isEmpty(valueA) && this.isEmpty(valueB))
|
167
|
-
||
|
165
|
+
|| moment.utc(valueA).format(this.momentFormat) === moment.utc(valueB).format(this.momentFormat);
|
168
166
|
}
|
169
167
|
createWrapper() {
|
170
168
|
return false;
|
@@ -180,18 +178,18 @@ export default class DateTimeComponent extends Input {
|
|
180
178
|
return super.checkValidity(data, dirty, rowData);
|
181
179
|
}
|
182
180
|
getValueAsString(value, options) {
|
183
|
-
let format = FormioUtils.
|
181
|
+
let format = FormioUtils.convertFormatToMoment(this.component.format);
|
182
|
+
format += format.match(/z$/) ? '' : ' z';
|
184
183
|
const timezone = this.timezone;
|
185
184
|
if (value && !this.attached && timezone) {
|
186
|
-
format += format.match(/z$/) ? '' : ' z';
|
187
185
|
if (Array.isArray(value) && this.component.multiple) {
|
188
|
-
return value.map(item => _.trim(FormioUtils.
|
186
|
+
return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone, options).format(format))).join(', ');
|
189
187
|
}
|
190
|
-
return _.trim(FormioUtils.
|
188
|
+
return _.trim(FormioUtils.momentDate(value, format, timezone, options).format(format));
|
191
189
|
}
|
192
190
|
if (Array.isArray(value) && this.component.multiple) {
|
193
|
-
return value.map(item => _.trim(
|
191
|
+
return value.map(item => _.trim(moment(item).format(format))).join(', ');
|
194
192
|
}
|
195
|
-
return (value ? _.trim(
|
193
|
+
return (value ? _.trim(moment(value).format(format)) : value) || '';
|
196
194
|
}
|
197
195
|
}
|
@@ -903,17 +903,16 @@ export default class FileComponent extends Field {
|
|
903
903
|
} : false;
|
904
904
|
}
|
905
905
|
async uploadFile(fileToSync) {
|
906
|
-
|
906
|
+
return await this.fileService.uploadFile(fileToSync.storage, fileToSync.file, fileToSync.name, fileToSync.dir,
|
907
907
|
// Progress callback
|
908
908
|
this.updateProgress.bind(this, fileToSync), fileToSync.url, fileToSync.options, fileToSync.fileKey, fileToSync.groupPermissions, fileToSync.groupResourceId, () => {
|
909
|
-
this.emit('fileUploadingStart'
|
909
|
+
this.emit('fileUploadingStart');
|
910
910
|
},
|
911
911
|
// Abort upload callback
|
912
912
|
(abort) => this.abortUploads.push({
|
913
913
|
id: fileToSync.id,
|
914
914
|
abort,
|
915
915
|
}), this.getMultipartOptions(fileToSync));
|
916
|
-
return await filePromise;
|
917
916
|
}
|
918
917
|
async upload() {
|
919
918
|
if (!this.filesToSync.filesToUpload.length) {
|
@@ -933,7 +932,7 @@ export default class FileComponent extends Field {
|
|
933
932
|
fileToSync.message = this.t('succefullyUploaded');
|
934
933
|
fileInfo.originalName = fileToSync.originalName;
|
935
934
|
fileInfo.hash = fileToSync.hash;
|
936
|
-
this.emit('fileUploadingEnd'
|
935
|
+
this.emit('fileUploadingEnd');
|
937
936
|
}
|
938
937
|
catch (response) {
|
939
938
|
fileToSync.status = 'error';
|
@@ -943,7 +942,7 @@ export default class FileComponent extends Field {
|
|
943
942
|
: response.type === 'abort'
|
944
943
|
? this.t('Request was aborted')
|
945
944
|
: response.toString();
|
946
|
-
this.emit('fileUploadingEnd'
|
945
|
+
this.emit('fileUploadingEnd');
|
947
946
|
this.emit('fileUploadError', {
|
948
947
|
fileToSync,
|
949
948
|
response,
|
@@ -24,7 +24,7 @@ class FormioUploadAdapter {
|
|
24
24
|
null,
|
25
25
|
null
|
26
26
|
];
|
27
|
-
|
27
|
+
this.fileService.uploadFile(...uploadParams, () => this.component.emit('fileUploadingStart')).then((result) => {
|
28
28
|
return this.fileService.downloadFile(result);
|
29
29
|
}).then((result) => {
|
30
30
|
return resolve({
|
@@ -34,7 +34,7 @@ class FormioUploadAdapter {
|
|
34
34
|
console.warn('An Error occured while uploading file', err);
|
35
35
|
reject(err);
|
36
36
|
}).finally(() => {
|
37
|
-
this.component.emit('fileUploadingEnd'
|
37
|
+
this.component.emit('fileUploadingEnd');
|
38
38
|
});
|
39
39
|
}));
|
40
40
|
}
|
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|Date)} - The translated date.
|
168
168
|
*/
|
169
|
-
export function getDateSetting(date: string | Date): (null |
|
169
|
+
export function getDateSetting(date: string | Date): (null | Date);
|
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,45 +182,56 @@ 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 {
|
185
|
+
* @returns {Date} - The offset date.
|
186
186
|
*/
|
187
|
-
export function offsetDate(date: Date, timezone: string):
|
188
|
-
|
189
|
-
|
190
|
-
};
|
187
|
+
export function offsetDate(date: Date, timezone: string): Date;
|
188
|
+
/**
|
189
|
+
* Returns if the zones are loaded.
|
190
|
+
* @returns {boolean} - TRUE if the zones are loaded; FALSE otherwise.
|
191
|
+
*/
|
192
|
+
export function zonesLoaded(): boolean;
|
191
193
|
/**
|
192
|
-
* Returns if we should
|
194
|
+
* Returns if we should load the zones.
|
193
195
|
* @param {string} timezone - The timezone to check if we should load the zones.
|
194
|
-
* @returns {boolean} - TRUE if we should
|
196
|
+
* @returns {boolean} - TRUE if we should load the zones; FALSE otherwise.
|
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.
|
195
204
|
*/
|
196
|
-
export function
|
205
|
+
export function loadZones(url: string, timezone: string): Promise<any> | any;
|
197
206
|
/**
|
198
|
-
* Get the
|
199
|
-
* @param {string|Date} value - The value to convert into a
|
207
|
+
* Get the moment date object for translating dates with timezones.
|
208
|
+
* @param {string|Date} value - The value to convert into a moment date.
|
200
209
|
* @param {string} format - The format to convert the date to.
|
201
210
|
* @param {string} timezone - The timezone to convert the date to.
|
202
211
|
* @param {object} options - The options object
|
203
|
-
* @returns {
|
212
|
+
* @returns {Date} - The moment date object.
|
204
213
|
*/
|
205
|
-
export function
|
214
|
+
export function momentDate(value: string | Date, format: string, timezone: string, options: object): Date;
|
206
215
|
/**
|
207
216
|
* Format a date provided a value, format, and timezone object.
|
217
|
+
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
208
218
|
* @param {string|Date} value - The value to format.
|
209
219
|
* @param {string} format - The format to format the date to.
|
210
220
|
* @param {string} timezone - The timezone to format the date to.
|
211
221
|
* @param {string} flatPickrInputFormat - The format to use for flatpickr input.
|
212
222
|
* @returns {string} - The formatted date.
|
213
223
|
*/
|
214
|
-
export function formatDate(value: string | Date, format: string, timezone: string, flatPickrInputFormat: string): string;
|
224
|
+
export function formatDate(timezonesUrl: string, value: string | Date, format: string, timezone: string, flatPickrInputFormat: string): string;
|
215
225
|
/**
|
216
226
|
* Pass a format function to format within a timezone.
|
227
|
+
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
217
228
|
* @param {Function} formatFn - The format function to use.
|
218
229
|
* @param {Date|string} date - The date to format.
|
219
230
|
* @param {string} format - The format to format the date to.
|
220
231
|
* @param {string} timezone - The timezone to format the date to.
|
221
232
|
* @returns {string} - The formatted date.
|
222
233
|
*/
|
223
|
-
export function formatOffset(formatFn: Function, date: Date | string, format: string, timezone: string): string;
|
234
|
+
export function formatOffset(timezonesUrl: string, formatFn: Function, date: Date | string, format: string, timezone: string): string;
|
224
235
|
/**
|
225
236
|
* Returns the local date format information.
|
226
237
|
* @param {Intl.LocalesArgument} locale - The locale to get the date format for.
|
@@ -238,7 +249,7 @@ export function convertFormatToFlatpickr(format: string): string;
|
|
238
249
|
* @param {string} format - The format to convert.
|
239
250
|
* @returns {string} - The converted format.
|
240
251
|
*/
|
241
|
-
export function
|
252
|
+
export function convertFormatToMoment(format: string): string;
|
242
253
|
/**
|
243
254
|
* Convert the format from the angular-datepicker module to mask format.
|
244
255
|
* @param {string} format - The format to convert.
|
@@ -505,7 +516,6 @@ export namespace componentValueTypes {
|
|
505
516
|
let any: string;
|
506
517
|
}
|
507
518
|
export function interpolateErrors(component: Component, errors: FieldError[], interpolateFn: Function): [];
|
508
|
-
import dayjs from "dayjs";
|
509
519
|
import ConditionOperators from './conditionOperators';
|
510
520
|
import { Evaluator } from './Evaluator';
|
511
521
|
export const interpolate: typeof Evaluator.interpolate;
|