cloud-ide-element 1.1.19 → 1.1.20

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.
@@ -735,22 +735,19 @@ class CideInputComponent {
735
735
  }
736
736
  }
737
737
  else if (type === 'datetime-local' && typeof value === 'string' && value) {
738
- // Ensure datetime-local is in YYYY-MM-DDTHH:mm format
739
- const datetimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/;
740
- if (datetimeRegex.test(value) && !isNaN(Date.parse(value))) {
741
- return value; // Already in correct format
742
- }
743
- else {
744
- // Try to parse and format unformatted datetime to YYYY-MM-DDTHH:mm
745
- const parsedDate = new Date(value);
746
- if (!isNaN(parsedDate.getTime())) {
747
- const year = parsedDate.getFullYear();
748
- const month = String(parsedDate.getMonth() + 1).padStart(2, '0');
749
- const day = String(parsedDate.getDate()).padStart(2, '0');
750
- const hours = String(parsedDate.getHours()).padStart(2, '0');
751
- const minutes = String(parsedDate.getMinutes()).padStart(2, '0');
752
- return `${year}-${month}-${day}T${hours}:${minutes}`;
738
+ // Try to parse and format datetime to YYYY-MM-DDTHH:mm
739
+ const parsedDate = new Date(value);
740
+ if (!isNaN(parsedDate.getTime())) {
741
+ // Check if already in correct format YYYY-MM-DDTHH:mm
742
+ if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(value)) {
743
+ return value; // Already in correct format
753
744
  }
745
+ const year = parsedDate.getFullYear();
746
+ const month = String(parsedDate.getMonth() + 1).padStart(2, '0');
747
+ const day = String(parsedDate.getDate()).padStart(2, '0');
748
+ const hours = String(parsedDate.getHours()).padStart(2, '0');
749
+ const minutes = String(parsedDate.getMinutes()).padStart(2, '0');
750
+ return `${year}-${month}-${day}T${hours}:${minutes}`;
754
751
  }
755
752
  }
756
753
  else if (type === 'url' && typeof value === 'string' && value) {
@@ -844,9 +841,8 @@ class CideInputComponent {
844
841
  if (typeof (value) == 'string') {
845
842
  if (value?.length > 0) {
846
843
  console.log(value, "value, datetime-local");
847
- // Validate datetime-local format (YYYY-MM-DDTHH:mm:ss or YYYY-MM-DDTHH:mm)
848
- const datetimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?$/;
849
- return datetimeRegex.test(value) && !isNaN(Date.parse(value));
844
+ // Just check if it can be parsed as a valid date (no regex validation)
845
+ return !isNaN(Date.parse(value));
850
846
  }
851
847
  else {
852
848
  return false;
@@ -964,34 +960,27 @@ class CideInputComponent {
964
960
  else if (this.type == 'datetime-local') {
965
961
  if (typeof (value) == 'string' && value) {
966
962
  console.log(value, "value, datetime-local, isControlValid");
967
- // Validate datetime-local format and parse
968
- const datetimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/;
969
- if (!datetimeRegex.test(value)) {
963
+ // Validate datetime by parsing (no regex validation)
964
+ const parsedDate = Date.parse(value);
965
+ if (isNaN(parsedDate)) {
970
966
  validation_status.status = true;
971
- validation_status.validation.required = `Invalid datetime format (YYYY-MM-DDTHH:mm)!`;
967
+ validation_status.validation.required = `Invalid datetime!`;
972
968
  }
973
969
  else {
974
- const parsedDate = Date.parse(value);
975
- if (isNaN(parsedDate)) {
976
- validation_status.status = true;
977
- validation_status.validation.required = `Invalid datetime!`;
978
- }
979
- else {
980
- // Validate min datetime
981
- if (this.min && typeof this.min === 'string') {
982
- const minDate = Date.parse(this.min);
983
- if (!isNaN(minDate) && parsedDate < minDate) {
984
- validation_status.status = true;
985
- validation_status.validation.required = `Datetime must be after ${this.min}!`;
986
- }
970
+ // Validate min datetime
971
+ if (this.min && typeof this.min === 'string') {
972
+ const minDate = Date.parse(this.min);
973
+ if (!isNaN(minDate) && parsedDate < minDate) {
974
+ validation_status.status = true;
975
+ validation_status.validation.required = `Datetime must be after ${this.min}!`;
987
976
  }
988
- // Validate max datetime
989
- if (this.max && typeof this.max === 'string') {
990
- const maxDate = Date.parse(this.max);
991
- if (!isNaN(maxDate) && parsedDate > maxDate) {
992
- validation_status.status = true;
993
- validation_status.validation.required = `Datetime must be before ${this.max}!`;
994
- }
977
+ }
978
+ // Validate max datetime
979
+ if (this.max && typeof this.max === 'string') {
980
+ const maxDate = Date.parse(this.max);
981
+ if (!isNaN(maxDate) && parsedDate > maxDate) {
982
+ validation_status.status = true;
983
+ validation_status.validation.required = `Datetime must be before ${this.max}!`;
995
984
  }
996
985
  }
997
986
  }