@formio/js 5.1.0-dev.6079.1fdf7d9 → 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.
@@ -1157,11 +1157,8 @@ class Webform extends NestedDataComponent_1.default {
1157
1157
  };
1158
1158
  errors.forEach(({ message, context, fromServer, component }, index) => {
1159
1159
  const text = !(component === null || component === void 0 ? void 0 : component.label) || (context === null || context === void 0 ? void 0 : context.hasLabel) || fromServer
1160
- ? this.t('alertMessage', { message: this.t(message) })
1161
- : this.t('alertMessageWithLabel', {
1162
- label: this.t(component === null || component === void 0 ? void 0 : component.label),
1163
- message: this.t(message),
1164
- });
1160
+ ? this.t(message)
1161
+ : `${this.t(component === null || component === void 0 ? void 0 : component.label)}: ${this.t(message)}`;
1165
1162
  displayedErrors.push(createListItem(text, index));
1166
1163
  });
1167
1164
  }
@@ -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
  }
@@ -4,8 +4,6 @@ declare const _default: {
4
4
  invalidRowError: string;
5
5
  invalidOption: string;
6
6
  invalidDay: string;
7
- alertMessageWithLabel: string;
8
- alertMessage: string;
9
7
  complete: string;
10
8
  error: string;
11
9
  errorListHotkey: string;
@@ -5,6 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  var _a;
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const bootstrap_1 = __importDefault(require("@formio/bootstrap"));
8
- exports.default = Object.assign(Object.assign({}, (((_a = bootstrap_1.default === null || bootstrap_1.default === void 0 ? void 0 : bootstrap_1.default.translations) === null || _a === void 0 ? void 0 : _a.en) || {})), { unsavedRowsError: 'Please save all rows before proceeding.', invalidRowsError: 'Please correct invalid rows before proceeding.', invalidRowError: 'Invalid row. Please correct it or delete.', invalidOption: '{{field}} is an invalid value.', invalidDay: '{{field}} is not a valid day.', alertMessageWithLabel: '{{label}}: {{message}}', alertMessage: '{{message}}', complete: 'Submission Complete', error: 'Please fix the following errors before submitting.', errorListHotkey: 'Press Ctrl + Alt + X to go back to the error list.', errorsListNavigationMessage: 'Click to navigate to the field with following error.', submitError: 'Please check the form and correct all errors before submitting.', required: '{{field}} is required', unique: '{{field}} must be unique', array: '{{field}} must be an array', array_nonempty: '{{field}} must be a non-empty array', nonarray: '{{field}} must not be an array', select: '{{field}} contains an invalid selection', pattern: '{{field}} does not match the pattern {{pattern}}', minLength: '{{field}} must have at least {{length}} characters.', maxLength: '{{field}} must have no more than {{length}} characters.', minWords: '{{field}} must have at least {{length}} words.', maxWords: '{{field}} must have no more than {{length}} words.', min: '{{field}} cannot be less than {{min}}.', max: '{{field}} cannot be greater than {{max}}.', maxDate: '{{field}} should not contain date after {{maxDate}}', minDate: '{{field}} should not contain date before {{minDate}}', maxYear: '{{field}} should not contain year greater than {{maxYear}}', minYear: '{{field}} should not contain year less than {{minYear}}', minSelectedCount: 'You must select at least {{minCount}} items', maxSelectedCount: 'You may only select up to {{maxCount}} items', invalid_email: '{{field}} must be a valid email.', invalid_url: '{{field}} must be a valid url.', invalid_regex: '{{field}} does not match the pattern {{regex}}.', invalid_date: '{{field}} is not a valid date.', invalid_day: '{{field}} is not a valid day.', invalidValueProperty: 'Invalid Value Property', mask: '{{field}} does not match the mask.', valueIsNotAvailable: '{{ field }} is an invalid value.', stripe: '{{stripe}}', month: 'Month', day: 'Day', year: 'Year', january: 'January', february: 'February', march: 'March', april: 'April', may: 'May', june: 'June', july: 'July', august: 'August', september: 'September', october: 'October', november: 'November', december: 'December', next: 'Next', previous: 'Previous', cancel: 'Cancel', submit: 'Submit Form', confirmCancel: 'Are you sure you want to cancel?', saveDraftInstanceError: 'Cannot save draft because there is no formio instance.', saveDraftAuthError: 'Cannot save draft unless a user is authenticated.', restoreDraftInstanceError: 'Cannot restore draft because there is no formio instance.', saveDraftError: 'Unable to save draft.', restoreDraftError: 'Unable to restore draft.', time: 'Invalid time', cancelButtonAriaLabel: 'Cancel button. Click to reset the form', previousButtonAriaLabel: 'Previous button. Click to go back to the previous tab', nextButtonAriaLabel: 'Next button. Click to go to the next tab', submitButtonAriaLabel: 'Submit Form button. Click to submit the form', reCaptchaTokenValidationError: 'ReCAPTCHA: Token validation error', reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission', apiKey: 'API Key is not unique: {{key}}', typeRemaining: '{{ remaining }} {{ type }} remaining.', typeCount: '{{ count }} {{ type }}', requiredDayField: '{{ field }} is required', requiredDayEmpty: '{{ field }} is required', requiredMonthField: '{{ field }} is required', requiredYearField: '{{ field }} is required', formNotReady: 'Form not ready. Use form.ready promise', noFormElement: 'No DOM element for form.', notUniqueKey: 'API Key is not unique', newFormSchema: 'Form schema is for a newer version, please upgrade your renderer. Some functionality may not work.', missingUrl: 'Missing URL argument', urlNotAttachedToBtn: 'You should add a URL to this button.', loadingProjectSettingsError: 'Could not load project settings', sessionStorageSupportError: 'Session storage is not supported in this browser.', builderUniqueError: `You cannot add more than one {{componentKeyOrTitle}} component to one page.`, pageNotFound: 'Page not found', noDragInfoError: 'There is no Drag Info available for either dragged or sibling element', addonSupportTypeError: 'Addon {{label}} does not support component of type {{type}}', setPathError: 'Should not be setting the path of a component.', calculatedPathDeprecation: 'component.calculatedPath was deprecated, use component.path instead.', unknownTemplate: 'Unknown template: {{name}}', unknownComponent: 'Unknown component: {{type}}', renderTemplateFunctionDeprecation: `Form.io 'render' template function is deprecated.
8
+ exports.default = Object.assign(Object.assign({}, (((_a = bootstrap_1.default === null || bootstrap_1.default === void 0 ? void 0 : bootstrap_1.default.translations) === null || _a === void 0 ? void 0 : _a.en) || {})), { unsavedRowsError: 'Please save all rows before proceeding.', invalidRowsError: 'Please correct invalid rows before proceeding.', invalidRowError: 'Invalid row. Please correct it or delete.', invalidOption: '{{field}} is an invalid value.', invalidDay: '{{field}} is not a valid day.', complete: 'Submission Complete', error: 'Please fix the following errors before submitting.', errorListHotkey: 'Press Ctrl + Alt + X to go back to the error list.', errorsListNavigationMessage: 'Click to navigate to the field with following error.', submitError: 'Please check the form and correct all errors before submitting.', required: '{{field}} is required', unique: '{{field}} must be unique', array: '{{field}} must be an array', array_nonempty: '{{field}} must be a non-empty array', nonarray: '{{field}} must not be an array', select: '{{field}} contains an invalid selection', pattern: '{{field}} does not match the pattern {{pattern}}', minLength: '{{field}} must have at least {{length}} characters.', maxLength: '{{field}} must have no more than {{length}} characters.', minWords: '{{field}} must have at least {{length}} words.', maxWords: '{{field}} must have no more than {{length}} words.', min: '{{field}} cannot be less than {{min}}.', max: '{{field}} cannot be greater than {{max}}.', maxDate: '{{field}} should not contain date after {{maxDate}}', minDate: '{{field}} should not contain date before {{minDate}}', maxYear: '{{field}} should not contain year greater than {{maxYear}}', minYear: '{{field}} should not contain year less than {{minYear}}', minSelectedCount: 'You must select at least {{minCount}} items', maxSelectedCount: 'You may only select up to {{maxCount}} items', invalid_email: '{{field}} must be a valid email.', invalid_url: '{{field}} must be a valid url.', invalid_regex: '{{field}} does not match the pattern {{regex}}.', invalid_date: '{{field}} is not a valid date.', invalid_day: '{{field}} is not a valid day.', invalidValueProperty: 'Invalid Value Property', mask: '{{field}} does not match the mask.', valueIsNotAvailable: '{{ field }} is an invalid value.', stripe: '{{stripe}}', month: 'Month', day: 'Day', year: 'Year', january: 'January', february: 'February', march: 'March', april: 'April', may: 'May', june: 'June', july: 'July', august: 'August', september: 'September', october: 'October', november: 'November', december: 'December', next: 'Next', previous: 'Previous', cancel: 'Cancel', submit: 'Submit Form', confirmCancel: 'Are you sure you want to cancel?', saveDraftInstanceError: 'Cannot save draft because there is no formio instance.', saveDraftAuthError: 'Cannot save draft unless a user is authenticated.', restoreDraftInstanceError: 'Cannot restore draft because there is no formio instance.', saveDraftError: 'Unable to save draft.', restoreDraftError: 'Unable to restore draft.', time: 'Invalid time', cancelButtonAriaLabel: 'Cancel button. Click to reset the form', previousButtonAriaLabel: 'Previous button. Click to go back to the previous tab', nextButtonAriaLabel: 'Next button. Click to go to the next tab', submitButtonAriaLabel: 'Submit Form button. Click to submit the form', reCaptchaTokenValidationError: 'ReCAPTCHA: Token validation error', reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission', apiKey: 'API Key is not unique: {{key}}', typeRemaining: '{{ remaining }} {{ type }} remaining.', typeCount: '{{ count }} {{ type }}', requiredDayField: '{{ field }} is required', requiredDayEmpty: '{{ field }} is required', requiredMonthField: '{{ field }} is required', requiredYearField: '{{ field }} is required', formNotReady: 'Form not ready. Use form.ready promise', noFormElement: 'No DOM element for form.', notUniqueKey: 'API Key is not unique', newFormSchema: 'Form schema is for a newer version, please upgrade your renderer. Some functionality may not work.', missingUrl: 'Missing URL argument', urlNotAttachedToBtn: 'You should add a URL to this button.', loadingProjectSettingsError: 'Could not load project settings', sessionStorageSupportError: 'Session storage is not supported in this browser.', builderUniqueError: `You cannot add more than one {{componentKeyOrTitle}} component to one page.`, pageNotFound: 'Page not found', noDragInfoError: 'There is no Drag Info available for either dragged or sibling element', addonSupportTypeError: 'Addon {{label}} does not support component of type {{type}}', setPathError: 'Should not be setting the path of a component.', calculatedPathDeprecation: 'component.calculatedPath was deprecated, use component.path instead.', unknownTemplate: 'Unknown template: {{name}}', unknownComponent: 'Unknown component: {{type}}', renderTemplateFunctionDeprecation: `Form.io 'render' template function is deprecated.
9
9
  If you need to render template (template A) inside of another template (template B),
10
10
  pass pre-compiled template A (use this.renderTemplate('template_A_name') as template context variable for template B`, whenReadyDeprecation: 'The whenReady() method has been deprecated. Please use the dataReady property instead.', loadResourcesError: 'Unable to load resources for {{componentKey}}', noSelectDataConfiguration: 'Select component {{componentKey}} does not have data configuration.', indexedDBSupportError: "Your browser doesn't support current version of indexedDB", caretPositionSavingError: 'An error occurred while trying to save caret position', iteratableRowsError: 'Getter #iteratableRows() is not implemented', checkRowDeprecation: 'Deprecation Warning: checkRow method has been replaced with processRow', noOAuthBtn: 'You must add the OAuth button to a form for it to function properly', noOAuthConfiguration: 'OAuth not configured. You must configure oauth for your project before it will work.', oAuthErrorsTitle: 'The Following Error Has Occured', noOAuthFormUrl: 'You must attach a Form API url to your form in order to use OAuth buttons.', oAuthStateError: 'OAuth state does not match. Please try logging in again.', componentInvalidRowValidation: 'Invalid row validation for {{componentKey}}', videoPlayerNotFound: 'Video player not found in template.', synchronizationFailed: 'Synchronization is failed', fileWithDuplicatedNameInProgress: 'File with the same name is already being uploaded', fileWithDuplicatedNameLoaded: 'File with the same name is already uploaded', nestedForm: 'Nested form', noDataProvided: 'No data provided', subformSubmissionLoadingError: 'Unable to load subform submission {{submissionId}}:', noDelimiterSet: 'In order for thousands separator to work properly, you must set the delimiter to true in the component json', noSiteKey: 'There is no Site Key specified in settings in form JSON', failedToNormalize: 'Failed to normalize value', failedToCompareItems: 'Error while comparing items', editorFocusError: 'An editor did not initialize properly when trying to focus:', quillImageUploadFailed: 'Quill image upload failed', noFilesSelected: 'No files selected', needConfigurationForQuill: 'The WYSIWYG settings are configured for CKEditor. For this renderer, you will need to use configurations for the Quill Editor. See https://quilljs.com/docs/configuration for more information.', waitPdfConverting: 'Converting PDF. Please wait.', uploading: 'Uploading', pasteBelow: 'Paste below', copy: 'Copy', move: 'Move', edit: 'Edit', editJson: 'Edit JSON', remove: 'Remove', clickToSetValue: 'Click to set value', words: 'words', characters: 'characters', addAnother: 'Add Another', yes: 'Yes', no: 'No', wantToClearData: 'Do you want to clear data?', yesDelete: 'Yes, delete it', waitFileProcessing: 'Processing file. Please wait...', wrongFileType: 'File is the wrong type; it must be {{ pattern }}', fileTooSmall: 'File is too small; it must be at least {{ size }}', fileTooBig: 'File is too big; it must be at most {{ size }}', noFileService: 'File Service not provided.', fileProcessingFailed: 'File processing has been failed.', readyForUpload: 'Ready to be uploaded into storage', readyForRemovingFromStorage: 'Ready to be removed from storage', preparingFileToRemove: 'Preparing file to remove', succefullyRemoved: 'Succefully removed', succefullyUploaded: 'Succefully uploaded', maxSelectItems: 'You may only select up to {{maxCount}} items', minSelectItems: 'You must select at least {{minCount}} items', clickToSign: 'Click to Sign', surveyQuestion: 'Question', surveyQuestionValue: 'Value', success: 'Success', noResultsFound: 'No results found', noChoices: 'No choices to choose from', typeToSearch: 'Type to search', loading: 'Loading' });
@@ -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.
@@ -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());
@@ -1158,11 +1158,8 @@ export default class Webform extends NestedDataComponent {
1158
1158
  };
1159
1159
  errors.forEach(({ message, context, fromServer, component }, index) => {
1160
1160
  const text = !component?.label || context?.hasLabel || fromServer
1161
- ? this.t('alertMessage', { message: this.t(message) })
1162
- : this.t('alertMessageWithLabel', {
1163
- label: this.t(component?.label),
1164
- message: this.t(message),
1165
- });
1161
+ ? this.t(message)
1162
+ : `${this.t(component?.label)}: ${this.t(message)}`;
1166
1163
  displayedErrors.push(createListItem(text, index));
1167
1164
  });
1168
1165
  }
@@ -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
  }
@@ -4,8 +4,6 @@ declare const _default: {
4
4
  invalidRowError: string;
5
5
  invalidOption: string;
6
6
  invalidDay: string;
7
- alertMessageWithLabel: string;
8
- alertMessage: string;
9
7
  complete: string;
10
8
  error: string;
11
9
  errorListHotkey: string;
@@ -6,8 +6,6 @@ export default {
6
6
  invalidRowError: 'Invalid row. Please correct it or delete.',
7
7
  invalidOption: '{{field}} is an invalid value.',
8
8
  invalidDay: '{{field}} is not a valid day.',
9
- alertMessageWithLabel: '{{label}}: {{message}}',
10
- alertMessage: '{{message}}',
11
9
  complete: 'Submission Complete',
12
10
  error: 'Please fix the following errors before submitting.',
13
11
  errorListHotkey: 'Press Ctrl + Alt + X to go back to the error list.',
@@ -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.
@@ -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());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6079.1fdf7d9",
3
+ "version": "5.1.0-dev.6082.6dd4100",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {