jsuites 6.5.0 → 6.5.1

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.
Files changed (2) hide show
  1. package/dist/jsuites.js +38 -8
  2. package/package.json +1 -1
package/dist/jsuites.js CHANGED
@@ -2766,6 +2766,11 @@ var jSuites;
2766
2766
  return null;
2767
2767
  }
2768
2768
 
2769
+ // Every date or time shape carries a digit: plain text never reaches the parsers
2770
+ if (!/\d/.test(value)) {
2771
+ return null;
2772
+ }
2773
+
2769
2774
  // Smart pattern detection based on the structure of the string
2770
2775
 
2771
2776
  // 1. Analyze the structure to determine possible formats
@@ -2924,6 +2929,10 @@ var jSuites;
2924
2929
 
2925
2930
  // If no patterns detected, try some common formats as fallback
2926
2931
  if (candidateMasks.length === 0) {
2932
+ // Every fallback format separates digit groups with /, - or :
2933
+ if (!/\d[\/\-:]\d/.test(value)) {
2934
+ return null;
2935
+ }
2927
2936
  if (userLocale.startsWith('en-US')) {
2928
2937
  candidateMasks.push(
2929
2938
  'mm/dd/yyyy', 'mm-dd-yyyy', 'yyyy-mm-dd',
@@ -18788,7 +18797,11 @@ function Toolbar(el, options) {
18788
18797
 
18789
18798
  obj.refresh = function() {
18790
18799
  if (obj.options.responsive == true) {
18791
- // Width of the c
18800
+ // A toolbar destroyed before the scheduled refresh runs has no parent
18801
+ if (! el.parentNode) {
18802
+ return;
18803
+ }
18804
+ // Width of the container
18792
18805
  var rect = el.parentNode.getBoundingClientRect();
18793
18806
  if (! obj.options.maxWidth) {
18794
18807
  obj.options.maxWidth = rect.width;
@@ -20713,12 +20726,29 @@ function Validations() {
20713
20726
  },
20714
20727
  };
20715
20728
 
20716
- component.date = function(data, options) {
20717
- if (isNumeric(data) && data > 0 && data < 1000000) {
20718
- data = validations_HelpersDate.numToDate(data);
20729
+ /**
20730
+ * Timestamp of a date in local time. A number is an Excel serial, and
20731
+ * a date without time is the local midnight, not the UTC midnight of
20732
+ * new Date('YYYY-MM-DD'), so it compares with the date and time the
20733
+ * calendar writes into the cell
20734
+ */
20735
+ const getTime = function(date) {
20736
+ if (isNumeric(date) && date > 0 && date < 1000000) {
20737
+ date = validations_HelpersDate.numToDate(date);
20738
+ } else if (typeof date === 'string') {
20739
+ let d = date.trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);
20740
+ if (d) {
20741
+ let t = new Date(d[1], d[2] - 1, d[3]);
20742
+ // No overflow into the next month: 2023-15-07 is not a date
20743
+ return t.getMonth() === d[2] - 1 && t.getDate() === Number(d[3]) ? t.getTime() : NaN;
20744
+ }
20719
20745
  }
20720
20746
 
20721
- if (new Date(data) == 'Invalid Date') {
20747
+ return new Date(date).getTime();
20748
+ }
20749
+
20750
+ component.date = function(data, options) {
20751
+ if (isNaN(getTime(data))) {
20722
20752
  return false;
20723
20753
  }
20724
20754
 
@@ -20735,10 +20765,10 @@ function Validations() {
20735
20765
  return relativeDates[date]().getTime();
20736
20766
  }
20737
20767
 
20738
- return new Date(date).getTime();
20768
+ return getTime(date);
20739
20769
  });
20740
20770
 
20741
- return dateCriterias[options.criteria](new Date(data).getTime(), values);
20771
+ return dateCriterias[options.criteria](getTime(data), values);
20742
20772
  }
20743
20773
 
20744
20774
  component.text = function(data, options) {
@@ -23519,7 +23549,7 @@ var jSuites = {
23519
23549
  ...dictionary,
23520
23550
  ...helpers,
23521
23551
  /** Current version */
23522
- version: '6.5.0',
23552
+ version: '6.5.1',
23523
23553
  /** Bind new extensions to Jsuites */
23524
23554
  setExtensions: function(o) {
23525
23555
  if (typeof(o) == 'object') {
package/package.json CHANGED
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "main": "dist/jsuites.js",
28
28
  "types": "dist/jsuites.d.ts",
29
- "version": "6.5.0",
29
+ "version": "6.5.1",
30
30
  "bugs": "https://github.com/jsuites/jsuites/issues",
31
31
  "homepage": "https://github.com/jsuites/jsuites",
32
32
  "docs": "https://jsuites.net",