@formio/js 5.1.0-dev.6080.9f2079e → 5.1.0-dev.6082.6dd4100
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 +4 -4
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +4 -4
- 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/components/textfield/TextField.js +2 -2
- package/lib/cjs/providers/storage/uploadAdapter.js +5 -3
- package/lib/cjs/utils/utils.d.ts +9 -0
- package/lib/cjs/utils/utils.js +16 -1
- package/lib/cjs/widgets/CalendarWidget.js +6 -1
- package/lib/mjs/components/textfield/TextField.js +2 -2
- package/lib/mjs/providers/storage/uploadAdapter.js +5 -3
- package/lib/mjs/utils/utils.d.ts +9 -0
- package/lib/mjs/utils/utils.js +14 -0
- package/lib/mjs/widgets/CalendarWidget.js +7 -2
- package/package.json +1 -1
@@ -102,8 +102,8 @@ class TextFieldComponent extends Input_1.default {
|
|
102
102
|
if (((_c = this.component.widget) === null || _c === void 0 ? void 0 : _c.type) === 'calendar') {
|
103
103
|
this.component.widget = Object.assign(Object.assign({}, this.component.widget), { readOnly: this.options.readOnly, timezone,
|
104
104
|
displayInTimezone, locale: this.component.widget.locale || this.options.language, saveAs: 'text' });
|
105
|
-
// update originalComponent to include widget settings after component initialization
|
106
|
-
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
105
|
+
// update originalComponent to include widget settings after component initialization
|
106
|
+
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
107
107
|
this.originalComponent = FormioUtils.fastCloneDeep(this.component);
|
108
108
|
}
|
109
109
|
}
|
@@ -49,9 +49,11 @@ class FormioUploadAdapter {
|
|
49
49
|
}
|
50
50
|
}
|
51
51
|
}
|
52
|
-
const getFormioUploadAdapterPlugin = (fileService, component) =>
|
53
|
-
|
54
|
-
|
52
|
+
const getFormioUploadAdapterPlugin = (fileService, component) => {
|
53
|
+
return function (editor) {
|
54
|
+
editor.plugins.get('FileRepository').createUploadAdapter = (loader) => {
|
55
|
+
return new FormioUploadAdapter(loader, fileService, component);
|
56
|
+
};
|
55
57
|
};
|
56
58
|
};
|
57
59
|
exports.getFormioUploadAdapterPlugin = getFormioUploadAdapterPlugin;
|
package/lib/cjs/utils/utils.d.ts
CHANGED
@@ -490,6 +490,15 @@ export function getFocusableElements(element: HTMLElement): NodeList<HTMLElement
|
|
490
490
|
* @returns {Array<string>|null} - The saved types for the component
|
491
491
|
*/
|
492
492
|
export function getComponentSavedTypes(fullSchema: import('@formio/core').Component): Array<string> | null;
|
493
|
+
/**
|
494
|
+
* Checks if a string has timezone information encoded in it
|
495
|
+
* Example: 2024-01-01T00:00:00Z -> true
|
496
|
+
* Example: 2024-01-01T00:00:00+03:00 -> true
|
497
|
+
* Example: 2011-05-03T00:00:00 -> false
|
498
|
+
* @param {string} value the string value to check
|
499
|
+
* @returns {boolean} if value has encoded timezone
|
500
|
+
*/
|
501
|
+
export function hasEncodedTimezone(value: string): boolean;
|
493
502
|
export * from "./formUtils";
|
494
503
|
/**
|
495
504
|
* Map values through unfold and return first non-nil value.
|
package/lib/cjs/utils/utils.js
CHANGED
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
19
|
};
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
21
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.convertFormatToMoment = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.momentDate = exports.loadZones = exports.shouldLoadZones = exports.zonesLoaded = 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 = exports.moment = exports.ConditionOperators = exports.jsonLogic = void 0;
|
22
|
-
exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = 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.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = void 0;
|
22
|
+
exports.hasEncodedTimezone = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = 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.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = void 0;
|
23
23
|
const lodash_1 = __importDefault(require("lodash"));
|
24
24
|
exports._ = lodash_1.default;
|
25
25
|
const json_logic_js_1 = __importDefault(require("json-logic-js"));
|
@@ -1646,3 +1646,18 @@ const interpolateErrors = (component, errors, interpolateFn) => {
|
|
1646
1646
|
});
|
1647
1647
|
};
|
1648
1648
|
exports.interpolateErrors = interpolateErrors;
|
1649
|
+
/**
|
1650
|
+
* Checks if a string has timezone information encoded in it
|
1651
|
+
* Example: 2024-01-01T00:00:00Z -> true
|
1652
|
+
* Example: 2024-01-01T00:00:00+03:00 -> true
|
1653
|
+
* Example: 2011-05-03T00:00:00 -> false
|
1654
|
+
* @param {string} value the string value to check
|
1655
|
+
* @returns {boolean} if value has encoded timezone
|
1656
|
+
*/
|
1657
|
+
function hasEncodedTimezone(value) {
|
1658
|
+
if (typeof value !== 'string') {
|
1659
|
+
return false;
|
1660
|
+
}
|
1661
|
+
return (value.substring(value.length - 1) === 'z' || value.substring(value.length - 1) === 'Z' || value.match(/[+|-][0-9]+:[0-9]+/));
|
1662
|
+
}
|
1663
|
+
exports.hasEncodedTimezone = hasEncodedTimezone;
|
@@ -286,6 +286,11 @@ class CalendarWidget extends InputWidget_1.default {
|
|
286
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;
|
287
287
|
return super.setValue(value);
|
288
288
|
}
|
289
|
+
// If the component is a textfield that does not have timezone information included in the string value then skip
|
290
|
+
// the timezone offset
|
291
|
+
if (this.component.type === 'textfield' && !(utils_1.hasEncodedTimezone)(value)) {
|
292
|
+
this.settings.skipOffset = true;
|
293
|
+
}
|
289
294
|
const zonesLoading = this.loadZones();
|
290
295
|
if (value) {
|
291
296
|
if (!saveAsText && this.settings.readOnly && !zonesLoading) {
|
@@ -453,7 +458,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
453
458
|
return (date, format) => {
|
454
459
|
// Only format this if this is the altFormat and the form is readOnly.
|
455
460
|
if (this.settings.readOnly && (format === this.settings.altFormat)) {
|
456
|
-
if (!this.settings.enableTime || this.loadZones()) {
|
461
|
+
if (!this.settings.enableTime || this.loadZones() || this.settings.skipOffset) {
|
457
462
|
return Flatpickr.formatDate(date, format);
|
458
463
|
}
|
459
464
|
const currentValue = new Date(this.getValue());
|
@@ -86,8 +86,8 @@ export default class TextFieldComponent extends Input {
|
|
86
86
|
locale: this.component.widget.locale || this.options.language,
|
87
87
|
saveAs: 'text'
|
88
88
|
};
|
89
|
-
// update originalComponent to include widget settings after component initialization
|
90
|
-
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
89
|
+
// update originalComponent to include widget settings after component initialization
|
90
|
+
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
91
91
|
this.originalComponent = FormioUtils.fastCloneDeep(this.component);
|
92
92
|
}
|
93
93
|
}
|
@@ -46,9 +46,11 @@ class FormioUploadAdapter {
|
|
46
46
|
}
|
47
47
|
}
|
48
48
|
}
|
49
|
-
const getFormioUploadAdapterPlugin = (fileService, component) =>
|
50
|
-
|
51
|
-
|
49
|
+
const getFormioUploadAdapterPlugin = (fileService, component) => {
|
50
|
+
return function (editor) {
|
51
|
+
editor.plugins.get('FileRepository').createUploadAdapter = (loader) => {
|
52
|
+
return new FormioUploadAdapter(loader, fileService, component);
|
53
|
+
};
|
52
54
|
};
|
53
55
|
};
|
54
56
|
export { getFormioUploadAdapterPlugin };
|
package/lib/mjs/utils/utils.d.ts
CHANGED
@@ -490,6 +490,15 @@ export function getFocusableElements(element: HTMLElement): NodeList<HTMLElement
|
|
490
490
|
* @returns {Array<string>|null} - The saved types for the component
|
491
491
|
*/
|
492
492
|
export function getComponentSavedTypes(fullSchema: import('@formio/core').Component): Array<string> | null;
|
493
|
+
/**
|
494
|
+
* Checks if a string has timezone information encoded in it
|
495
|
+
* Example: 2024-01-01T00:00:00Z -> true
|
496
|
+
* Example: 2024-01-01T00:00:00+03:00 -> true
|
497
|
+
* Example: 2011-05-03T00:00:00 -> false
|
498
|
+
* @param {string} value the string value to check
|
499
|
+
* @returns {boolean} if value has encoded timezone
|
500
|
+
*/
|
501
|
+
export function hasEncodedTimezone(value: string): boolean;
|
493
502
|
export * from "./formUtils";
|
494
503
|
/**
|
495
504
|
* Map values through unfold and return first non-nil value.
|
package/lib/mjs/utils/utils.js
CHANGED
@@ -1554,3 +1554,17 @@ export const interpolateErrors = (component, errors, interpolateFn) => {
|
|
1554
1554
|
return { ...error, message: unescapeHTML(interpolateFn(toInterpolate, context)), context: { ...context } };
|
1555
1555
|
});
|
1556
1556
|
};
|
1557
|
+
/**
|
1558
|
+
* Checks if a string has timezone information encoded in it
|
1559
|
+
* Example: 2024-01-01T00:00:00Z -> true
|
1560
|
+
* Example: 2024-01-01T00:00:00+03:00 -> true
|
1561
|
+
* Example: 2011-05-03T00:00:00 -> false
|
1562
|
+
* @param {string} value the string value to check
|
1563
|
+
* @returns {boolean} if value has encoded timezone
|
1564
|
+
*/
|
1565
|
+
export function hasEncodedTimezone(value) {
|
1566
|
+
if (typeof value !== 'string') {
|
1567
|
+
return false;
|
1568
|
+
}
|
1569
|
+
return (value.substring(value.length - 1) === 'z' || value.substring(value.length - 1) === 'Z' || value.match(/[+|-][0-9]+:[0-9]+/));
|
1570
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Formio } from '../Formio';
|
2
2
|
import InputWidget from './InputWidget';
|
3
|
-
import { convertFormatToFlatpickr, convertFormatToMask, convertFormatToMoment, formatDate, formatOffset, getBrowserInfo, getDateSetting, getLocaleDateFormatInfo, momentDate, zonesLoaded, shouldLoadZones, loadZones, } from '../utils/utils';
|
3
|
+
import { convertFormatToFlatpickr, convertFormatToMask, convertFormatToMoment, formatDate, formatOffset, getBrowserInfo, getDateSetting, getLocaleDateFormatInfo, momentDate, zonesLoaded, shouldLoadZones, loadZones, hasEncodedTimezone, } from '../utils/utils';
|
4
4
|
import moment from 'moment';
|
5
5
|
import _ from 'lodash';
|
6
6
|
const DEFAULT_FORMAT = 'yyyy-MM-dd hh:mm a';
|
@@ -278,6 +278,11 @@ export default class CalendarWidget extends InputWidget {
|
|
278
278
|
value = value ? formatDate(this.timezonesUrl, value, convertFormatToMoment(this.settings.format), this.timezone, convertFormatToMoment(this.valueMomentFormat)) : value;
|
279
279
|
return super.setValue(value);
|
280
280
|
}
|
281
|
+
// If the component is a textfield that does not have timezone information included in the string value then skip
|
282
|
+
// the timezone offset
|
283
|
+
if (this.component.type === 'textfield' && !(hasEncodedTimezone)(value)) {
|
284
|
+
this.settings.skipOffset = true;
|
285
|
+
}
|
281
286
|
const zonesLoading = this.loadZones();
|
282
287
|
if (value) {
|
283
288
|
if (!saveAsText && this.settings.readOnly && !zonesLoading) {
|
@@ -443,7 +448,7 @@ export default class CalendarWidget extends InputWidget {
|
|
443
448
|
return (date, format) => {
|
444
449
|
// Only format this if this is the altFormat and the form is readOnly.
|
445
450
|
if (this.settings.readOnly && (format === this.settings.altFormat)) {
|
446
|
-
if (!this.settings.enableTime || this.loadZones()) {
|
451
|
+
if (!this.settings.enableTime || this.loadZones() || this.settings.skipOffset) {
|
447
452
|
return Flatpickr.formatDate(date, format);
|
448
453
|
}
|
449
454
|
const currentValue = new Date(this.getValue());
|