jsuites 6.5.0 → 6.5.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.
Files changed (2) hide show
  1. package/dist/jsuites.js +56 -24
  2. package/package.json +5 -5
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',
@@ -6085,6 +6094,18 @@ if (! Modal && "function" === 'function') {
6085
6094
  return s;
6086
6095
  }
6087
6096
 
6097
+ // Any scroll outside the menu closes it (matches the OS context menu:
6098
+ // the menu refers to the spot that was right-clicked, and scrolling
6099
+ // moves that content away). Capture phase: scroll does not bubble.
6100
+ // Scrolling INSIDE a long menu list keeps it open. Listening only
6101
+ // while the menu is open: a window listener kept for good would also
6102
+ // keep the menu, and what holds it, alive after it is gone
6103
+ const scroll = function(e) {
6104
+ if (! self.isClosed() && ! (e.target instanceof Node && self.el.contains(e.target))) {
6105
+ self.close(0);
6106
+ }
6107
+ }
6108
+
6088
6109
  self.isClosed = function() {
6089
6110
  return self.modals[0].modal.closed === true;
6090
6111
  }
@@ -6162,6 +6183,7 @@ if (! Modal && "function" === 'function') {
6162
6183
  }
6163
6184
  });
6164
6185
  }
6186
+ window.addEventListener("scroll", scroll, true);
6165
6187
  // Focus
6166
6188
  self.el.classList.add('lm-menu-focus');
6167
6189
  // Focus on the contextmenu. preventScroll stops the browser from
@@ -6186,6 +6208,7 @@ if (! Modal && "function" === 'function') {
6186
6208
 
6187
6209
  // Close event
6188
6210
  if (level === 0) {
6211
+ window.removeEventListener("scroll", scroll, true);
6189
6212
  self.el.classList.remove('lm-menu-focus');
6190
6213
 
6191
6214
  Dispatch.call(self, self.onclose, 'close', {
@@ -6205,16 +6228,6 @@ if (! Modal && "function" === 'function') {
6205
6228
  }
6206
6229
  });
6207
6230
 
6208
- // Any scroll outside the menu closes it (matches the OS context menu:
6209
- // the menu refers to the spot that was right-clicked, and scrolling
6210
- // moves that content away). Capture phase: scroll does not bubble.
6211
- // Scrolling INSIDE a long menu list keeps it open
6212
- window.addEventListener("scroll", function(e) {
6213
- if (! self.isClosed() && ! (e.target instanceof Node && self.el.contains(e.target))) {
6214
- self.close(0);
6215
- }
6216
- }, true);
6217
-
6218
6231
  // Keyboard event
6219
6232
  self.el.addEventListener("keydown", function(e) {
6220
6233
  // Menu object
@@ -7618,8 +7631,6 @@ if (!lemonade && "function" === 'function') {
7618
7631
  }
7619
7632
  }
7620
7633
 
7621
- // References
7622
- const modals = [];
7623
7634
  // State of the resize and move modal
7624
7635
  let state = {};
7625
7636
  // Internal controls of the action of resize and move
@@ -7637,8 +7648,11 @@ if (!lemonade && "function" === 'function') {
7637
7648
  */
7638
7649
  const sendToFront = function (container) {
7639
7650
  let highestXIndex = defaultZIndex;
7651
+ // The modals on the page. A registry of the instances would keep
7652
+ // every modal ever created alive, the ones of destroyed components too
7653
+ const modals = document.querySelectorAll('.lm-modal');
7640
7654
  for (let i = 0; i < modals.length; i++) {
7641
- const zIndex = parseInt(modals[i].el.style.zIndex);
7655
+ const zIndex = parseInt(modals[i].style.zIndex);
7642
7656
  if (zIndex > highestXIndex) {
7643
7657
  highestXIndex = zIndex;
7644
7658
  }
@@ -8023,9 +8037,6 @@ if (!lemonade && "function" === 'function') {
8023
8037
  // Make sure keep the state as boolean
8024
8038
  self.closed = !!self.closed;
8025
8039
 
8026
- // Keep all modals references
8027
- modals.push(self);
8028
-
8029
8040
  // External onload remove from the lifecycle
8030
8041
  let change = self.onchange;
8031
8042
  self.onchange = null;
@@ -18788,7 +18799,11 @@ function Toolbar(el, options) {
18788
18799
 
18789
18800
  obj.refresh = function() {
18790
18801
  if (obj.options.responsive == true) {
18791
- // Width of the c
18802
+ // A toolbar destroyed before the scheduled refresh runs has no parent
18803
+ if (! el.parentNode) {
18804
+ return;
18805
+ }
18806
+ // Width of the container
18792
18807
  var rect = el.parentNode.getBoundingClientRect();
18793
18808
  if (! obj.options.maxWidth) {
18794
18809
  obj.options.maxWidth = rect.width;
@@ -20713,12 +20728,29 @@ function Validations() {
20713
20728
  },
20714
20729
  };
20715
20730
 
20716
- component.date = function(data, options) {
20717
- if (isNumeric(data) && data > 0 && data < 1000000) {
20718
- data = validations_HelpersDate.numToDate(data);
20731
+ /**
20732
+ * Timestamp of a date in local time. A number is an Excel serial, and
20733
+ * a date without time is the local midnight, not the UTC midnight of
20734
+ * new Date('YYYY-MM-DD'), so it compares with the date and time the
20735
+ * calendar writes into the cell
20736
+ */
20737
+ const getTime = function(date) {
20738
+ if (isNumeric(date) && date > 0 && date < 1000000) {
20739
+ date = validations_HelpersDate.numToDate(date);
20740
+ } else if (typeof date === 'string') {
20741
+ let d = date.trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);
20742
+ if (d) {
20743
+ let t = new Date(d[1], d[2] - 1, d[3]);
20744
+ // No overflow into the next month: 2023-15-07 is not a date
20745
+ return t.getMonth() === d[2] - 1 && t.getDate() === Number(d[3]) ? t.getTime() : NaN;
20746
+ }
20719
20747
  }
20720
20748
 
20721
- if (new Date(data) == 'Invalid Date') {
20749
+ return new Date(date).getTime();
20750
+ }
20751
+
20752
+ component.date = function(data, options) {
20753
+ if (isNaN(getTime(data))) {
20722
20754
  return false;
20723
20755
  }
20724
20756
 
@@ -20735,10 +20767,10 @@ function Validations() {
20735
20767
  return relativeDates[date]().getTime();
20736
20768
  }
20737
20769
 
20738
- return new Date(date).getTime();
20770
+ return getTime(date);
20739
20771
  });
20740
20772
 
20741
- return dateCriterias[options.criteria](new Date(data).getTime(), values);
20773
+ return dateCriterias[options.criteria](getTime(data), values);
20742
20774
  }
20743
20775
 
20744
20776
  component.text = function(data, options) {
@@ -23519,7 +23551,7 @@ var jSuites = {
23519
23551
  ...dictionary,
23520
23552
  ...helpers,
23521
23553
  /** Current version */
23522
- version: '6.5.0',
23554
+ version: '6.5.2',
23523
23555
  /** Bind new extensions to Jsuites */
23524
23556
  setExtensions: function(o) {
23525
23557
  if (typeof(o) == 'object') {
package/package.json CHANGED
@@ -26,22 +26,22 @@
26
26
  },
27
27
  "main": "dist/jsuites.js",
28
28
  "types": "dist/jsuites.d.ts",
29
- "version": "6.5.0",
29
+ "version": "6.5.2",
30
30
  "bugs": "https://github.com/jsuites/jsuites/issues",
31
31
  "homepage": "https://github.com/jsuites/jsuites",
32
32
  "docs": "https://jsuites.net",
33
33
  "download": "https://github.com/jsuites/jsuites/archive/master.zip",
34
34
  "dependencies": {
35
- "@jsuites/utils": "^6.1.0",
35
+ "@jsuites/utils": "^6.1.1",
36
36
  "@lemonadejs/calendar": "^5.9.3",
37
37
  "@lemonadejs/color": "^5.8.0",
38
- "@lemonadejs/contextmenu": "^5.8.4",
39
- "@lemonadejs/dropdown": "^5.8.3",
38
+ "@lemonadejs/contextmenu": "^5.8.6",
39
+ "@lemonadejs/dropdown": "^5.8.4",
40
40
  "@lemonadejs/modal": "^5.8.3",
41
41
  "@lemonadejs/rating": "^5.8.1",
42
42
  "@lemonadejs/switch": "^5.8.0",
43
43
  "@lemonadejs/tabs": "^5.8.0",
44
- "@lemonadejs/topmenu": "^5.8.0"
44
+ "@lemonadejs/topmenu": "^5.8.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@babel/preset-env": "^7.28.5",