@eternalcodestudio/primeng-table 19.1.0 → 19.1.2

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.
@@ -789,8 +789,14 @@ class TableCell {
789
789
  const effectiveTimezone = dateTimezone ?? this.dateTimezone;
790
790
  const effectiveCulture = dateCulture ?? this.dateCulture;
791
791
  if (value) { // If value is not undefined
792
- const dateUtc = new Date(value + 'Z'); // Make sure the date is treated as UTC
793
- formattedDate = this.datePipe.transform(dateUtc, effectiveFormat, effectiveTimezone, effectiveCulture); // Perform the date masking
792
+ let dateToParse = value;
793
+ if (typeof value === 'string' && !value.endsWith('Z') && !/[+-]\d{2}:\d{2}$/.test(value)) { // Check if the date does not contain Z
794
+ dateToParse += 'Z';
795
+ }
796
+ const dateUtc = new Date(dateToParse);
797
+ if (!isNaN(dateUtc.getTime())) { // Check that the date is valid before performing transformation
798
+ formattedDate = this.datePipe.transform(dateUtc, effectiveFormat, effectiveTimezone, effectiveCulture); // Perform the date masking
799
+ }
794
800
  }
795
801
  return formattedDate ?? ''; // Returns the date formatted, or as empty string if an issue was found (or value was undefined).
796
802
  }
@@ -1823,14 +1829,15 @@ class ECSPrimengTable {
1823
1829
  */
1824
1830
  onPredefinedFilterChange(filterName, selectedValues) {
1825
1831
  const filters = { ...this.dt.filters }; // Create a shallow copy of the current filters to avoid mutating the original filters directly
1832
+ const newValue = selectedValues && selectedValues.length ? selectedValues.map(value => value.value) : null; // Convert empty selection to null so PrimeNG removes the filter instead of applying an empty array
1826
1833
  if (Array.isArray(filters[filterName])) { // Check if the filter for the given filterName is an array
1827
1834
  filters[filterName].forEach(criteria => {
1828
- criteria.value = selectedValues.map(value => value.value); // Update the value of each criteria with the values from selectedValues
1835
+ criteria.value = newValue; // Update the value of each criteria with the values from selectedValues
1829
1836
  });
1830
1837
  }
1831
1838
  else if (filters[filterName]) { // Check if the filter for the given filterName exists and is not an array
1832
1839
  const criteria = filters[filterName]; // Cast the filter criteria to FilterMetadata
1833
- criteria.value = selectedValues.map(value => value.value); // Update the value of the criteria with the values from selectedValues
1840
+ criteria.value = newValue; // Update the value of the criteria with the values from selectedValues
1834
1841
  }
1835
1842
  this.dt.filters = filters; // Update the data table's filters with the modified filters object
1836
1843
  this.dt._filter(); // Trigger the filtering operation on the data table to apply the new filters
@@ -1959,9 +1966,9 @@ class ECSPrimengTable {
1959
1966
  if (!sameColumnsAsBefore) {
1960
1967
  this.tableOptions.isActive = false;
1961
1968
  this.clearSorts(this.dt, true);
1969
+ this.clearFilters(this.dt, true, false);
1962
1970
  setTimeout(() => {
1963
1971
  this.tableOptions.isActive = true;
1964
- this.clearSorts(this.dt, true);
1965
1972
  }, 1);
1966
1973
  }
1967
1974
  }