jsuites 5.0.18 → 5.0.21

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 +104 -60
  2. package/package.json +1 -1
package/dist/jsuites.js CHANGED
@@ -1395,7 +1395,7 @@ function Mask() {
1395
1395
  // Number
1396
1396
  numeric: [ '0{1}(.{1}0+)?' ],
1397
1397
  // Data tokens
1398
- datetime: [ 'YYYY', 'YYY', 'YY', 'MMMMM', 'MMMM', 'MMM', 'MM', 'DDDDD', 'DDDD', 'DDD', 'DD', 'DY', 'DAY', 'WD', 'D', 'Q', 'MONTH', 'MON', 'HH24', 'HH12', 'HH', '\\[H\\]', 'H', 'AM/PM', 'PM', 'AM', 'MI', 'SS', 'MS', 'Y', 'M' ],
1398
+ datetime: [ 'YYYY', 'YYY', 'YY', 'MMMMM', 'MMMM', 'MMM', 'MM', 'DDDDD', 'DDDD', 'DDD', 'DD', 'DY', 'DAY', 'WD', 'D', 'Q', 'MONTH', 'MON', 'HH24', 'HH12', 'HH', '\\[H\\]', 'H', 'AM/PM', 'MI', 'SS', 'MS', 'Y', 'M' ],
1399
1399
  // Other
1400
1400
  general: [ 'A', '0', '[0-9a-zA-Z\$]+', '.']
1401
1401
  }
@@ -1430,11 +1430,19 @@ function Mask() {
1430
1430
  if (this.mask.toLowerCase().indexOf('[h]') !== -1) {
1431
1431
  v = parseInt(this.date[3]);
1432
1432
  } else {
1433
- v = parseInt(this.date[3]) % 24;
1433
+ let h = parseInt(this.date[3]);
1434
+ if (h < 13 && this.values.indexOf('PM') !== -1) {
1435
+ v = (h+12) % 24;
1436
+ } else {
1437
+ v = h % 24;
1438
+ }
1434
1439
  }
1435
1440
  if (this.date[4]) {
1436
1441
  v += parseFloat(this.date[4] / 60);
1437
1442
  }
1443
+ if (this.date[5]) {
1444
+ v += parseFloat(this.date[5] / 3600);
1445
+ }
1438
1446
  v /= 24;
1439
1447
  } else if (this.date[0] || this.date[1] || this.date[2] || this.date[3] || this.date[4] || this.date[5]) {
1440
1448
  if (this.date[0] && this.date[1] && ! this.date[2]) {
@@ -1459,12 +1467,14 @@ function Mask() {
1459
1467
  }
1460
1468
 
1461
1469
  var isFormula = function(value) {
1462
- return (''+value).chartAt(0) == '=';
1470
+ var v = (''+value)[0];
1471
+ return v == '=' ? true : false;
1463
1472
  }
1464
1473
 
1465
1474
  var isNumeric = function(t) {
1466
1475
  return t === 'currency' || t === 'percentage' || t === 'numeric' ? true : false;
1467
1476
  }
1477
+
1468
1478
  /**
1469
1479
  * Get the decimal defined in the mask configuration
1470
1480
  */
@@ -1564,7 +1574,7 @@ function Mask() {
1564
1574
  }
1565
1575
 
1566
1576
  var FormatValue = function(v, event) {
1567
- if (v == '') {
1577
+ if (v === '') {
1568
1578
  return '';
1569
1579
  }
1570
1580
  // Get decimal
@@ -1573,25 +1583,33 @@ function Mask() {
1573
1583
  var o = this.options;
1574
1584
  // Parse value
1575
1585
  v = ParseValue.call(this, v);
1576
- if (v == '') {
1586
+ if (v === '') {
1577
1587
  return '';
1578
1588
  }
1589
+ var t = null;
1579
1590
  // Temporary value
1580
1591
  if (v[0]) {
1581
- var t = parseFloat(v[0] + '.1');
1582
- if (o.style == 'percent') {
1583
- t /= 100;
1592
+ if (o.style === 'percent') {
1593
+ t = parseFloat(v[0]) / 100;
1594
+ } else {
1595
+ t = parseFloat(v[0] + '.1');
1584
1596
  }
1585
- } else {
1586
- var t = null;
1587
1597
  }
1588
1598
 
1589
- if ((v[0] == '-' || v[0] == '-00') && ! v[1] && (event && event.inputType == "deleteContentBackward")) {
1599
+ if ((v[0] === '-' || v[0] === '-00') && ! v[1] && (event && event.inputType == "deleteContentBackward")) {
1590
1600
  return '';
1591
1601
  }
1592
1602
 
1593
1603
  var n = new Intl.NumberFormat(this.locale, o).format(t);
1594
1604
  n = n.split(d);
1605
+
1606
+ if (o.style === 'percent') {
1607
+ if (n[0].indexOf('%') !== -1) {
1608
+ n[0] = n[0].replace('%', '');
1609
+ n[2] = '%';
1610
+ }
1611
+ }
1612
+
1595
1613
  if (typeof(n[1]) !== 'undefined') {
1596
1614
  var s = n[1].replace(/[0-9]*/g, '');
1597
1615
  if (s) {
@@ -1615,7 +1633,6 @@ function Mask() {
1615
1633
  }
1616
1634
 
1617
1635
  // Get decimal
1618
- var d = getDecimal.call(this);
1619
1636
  var n = FormatValue.call(this, v, event);
1620
1637
  var t = (n.length) - v.length;
1621
1638
  var index = Caret.call(e) + t;
@@ -1665,7 +1682,7 @@ function Mask() {
1665
1682
  if (adjustNumeric) {
1666
1683
  var p = null;
1667
1684
  for (var i = 0; i < n.length; i++) {
1668
- if (n[i].match(/[\-0-9]/g) || n[i] == '.' || n[i] == ',') {
1685
+ if (n[i].match(/[\-0-9]/g) || n[i] === '.' || n[i] === ',') {
1669
1686
  p = i;
1670
1687
  }
1671
1688
  }
@@ -1986,7 +2003,6 @@ function Mask() {
1986
2003
  }
1987
2004
  },
1988
2005
  'HH24': function(v, two) {
1989
- var test = false;
1990
2006
  if (parseInt(v) >= 0 && parseInt(v) < 10) {
1991
2007
  if (this.values[this.index] == null || this.values[this.index] == '') {
1992
2008
  if (parseInt(v) > 2 && parseInt(v) < 10) {
@@ -2000,9 +2016,15 @@ function Mask() {
2000
2016
  }
2001
2017
  } else {
2002
2018
  if (this.values[this.index] == 2 && parseInt(v) < 4) {
2019
+ if (! two && this.values[this.index] === '0') {
2020
+ this.values[this.index] = '';
2021
+ }
2003
2022
  this.date[3] = this.values[this.index] += v;
2004
2023
  this.index++;
2005
2024
  } else if (this.values[this.index] < 2 && parseInt(v) < 10) {
2025
+ if (! two && this.values[this.index] === '0') {
2026
+ this.values[this.index] = '';
2027
+ }
2006
2028
  this.date[3] = this.values[this.index] += v;
2007
2029
  this.index++;
2008
2030
  }
@@ -2052,15 +2074,20 @@ function Mask() {
2052
2074
  parser.N60.call(this, v, 5);
2053
2075
  },
2054
2076
  'AM/PM': function(v) {
2055
- this.values[this.index] = '';
2056
- if (v) {
2057
- if (this.date[3] > 12) {
2058
- this.values[this.index] = 'PM';
2059
- } else {
2060
- this.values[this.index] = 'AM';
2077
+ if (typeof(this.values[this.index]) === 'undefined') {
2078
+ this.values[this.index] = '';
2079
+ }
2080
+
2081
+ if (this.values[this.index] === '') {
2082
+ if (v.match(/a/i) && this.date[3] < 13) {
2083
+ this.values[this.index] += 'A';
2084
+ } else if (v.match(/p/i)) {
2085
+ this.values[this.index] += 'P';
2061
2086
  }
2087
+ } else if (this.values[this.index] === 'A' || this.values[this.index] === 'P') {
2088
+ this.values[this.index] += 'M';
2089
+ this.index++;
2062
2090
  }
2063
- this.index++;
2064
2091
  },
2065
2092
  'WD': function(v) {
2066
2093
  if (typeof(this.values[this.index]) === 'undefined') {
@@ -2069,7 +2096,7 @@ function Mask() {
2069
2096
  if (parseInt(v) >= 0 && parseInt(v) < 7) {
2070
2097
  this.values[this.index] = v;
2071
2098
  }
2072
- if (this.value[this.index].length == 1) {
2099
+ if (this.values[this.index].length == 1) {
2073
2100
  this.index++;
2074
2101
  }
2075
2102
  },
@@ -2340,11 +2367,6 @@ function Mask() {
2340
2367
  }
2341
2368
  }
2342
2369
 
2343
- var isFormula = function(value) {
2344
- var v = (''+value)[0];
2345
- return v == '=' ? true : false;
2346
- }
2347
-
2348
2370
  var toPlainString = function(num) {
2349
2371
  return (''+ +num).replace(/(-?)(\d*)\.?(\d*)e([+-]\d+)/,
2350
2372
  function(a,b,c,d,e) {
@@ -2474,8 +2496,12 @@ function Mask() {
2474
2496
  if (o.mask.indexOf('##') !== -1) {
2475
2497
  var d = o.mask.split(';');
2476
2498
  if (d[0]) {
2499
+ if (typeof(e) == 'object') {
2500
+ d[0] = d[0].replace(new RegExp(/_\)/g), '');
2501
+ d[0] = d[0].replace(new RegExp(/_\(/g), '');
2502
+ }
2477
2503
  d[0] = d[0].replace('*', '\t');
2478
- d[0] = d[0].replace(new RegExp(/_-/g), ' ');
2504
+ d[0] = d[0].replace(new RegExp(/_-/g), '');
2479
2505
  d[0] = d[0].replace(new RegExp(/_/g), '');
2480
2506
  d[0] = d[0].replace('##0.###','##0.000');
2481
2507
  d[0] = d[0].replace('##0.##','##0.00');
@@ -2486,6 +2512,12 @@ function Mask() {
2486
2512
  }
2487
2513
  o.mask = d[0];
2488
2514
  }
2515
+ // Remove back slashes
2516
+ if (o.mask.indexOf('\\') !== -1) {
2517
+ var d = o.mask.split(';');
2518
+ d[0] = d[0].replace(new RegExp(/\\/g), '');
2519
+ o.mask = d[0];
2520
+ }
2489
2521
  // Get type
2490
2522
  if (! o.type) {
2491
2523
  o.type = getType.call(o, o.mask);
@@ -2724,6 +2756,10 @@ function Mask() {
2724
2756
  if (options.mask) {
2725
2757
  if (options.mask.indexOf(';') !== -1) {
2726
2758
  var t = options.mask.split(';');
2759
+ if (! fullMask) {
2760
+ t[0] = t[0].replace(new RegExp(/_\)/g), '');
2761
+ t[0] = t[0].replace(new RegExp(/_\(/g), '');
2762
+ }
2727
2763
  options.mask = t[0];
2728
2764
  }
2729
2765
  options.mask = options.mask.replace(new RegExp(/\[h]/),'|h|');
@@ -3030,7 +3066,11 @@ function Mask() {
3030
3066
  } else if (s === 'Q') {
3031
3067
  v = Math.floor((calendar.getMonth() + 3) / 3);
3032
3068
  } else if (s === 'HH24' || s === 'HH') {
3033
- v = helpers.two(this.data[3]);
3069
+ v = this.data[3];
3070
+ if (v > 12 && this.tokens.indexOf('am/pm') !== -1) {
3071
+ v -= 12;
3072
+ }
3073
+ v = helpers.two(v);
3034
3074
  } else if (s === 'HH12') {
3035
3075
  if (this.data[3] > 12) {
3036
3076
  v = helpers.two(this.data[3] - 12);
@@ -3039,6 +3079,10 @@ function Mask() {
3039
3079
  }
3040
3080
  } else if (s === 'H') {
3041
3081
  v = this.data[3];
3082
+ if (v > 12 && this.tokens.indexOf('am/pm') !== -1) {
3083
+ v -= 12;
3084
+ v = helpers.two(v);
3085
+ }
3042
3086
  } else if (s === 'MI') {
3043
3087
  v = helpers.two(this.data[4]);
3044
3088
  } else if (s === 'SS') {
@@ -3075,14 +3119,6 @@ function Mask() {
3075
3119
  return value;
3076
3120
  }
3077
3121
 
3078
- if (typeof document !== 'undefined') {
3079
- document.addEventListener('input', function(e) {
3080
- if (e.target.getAttribute('data-mask') || e.target.mask) {
3081
- obj(e);
3082
- }
3083
- });
3084
- }
3085
-
3086
3122
  return obj;
3087
3123
  }
3088
3124
 
@@ -12548,8 +12584,11 @@ var sha512_default = /*#__PURE__*/__webpack_require__.n(sha512);
12548
12584
 
12549
12585
 
12550
12586
  var jSuites = {
12587
+ // Helpers
12588
+ ...dictionary,
12589
+ ...helpers,
12551
12590
  /** Current version */
12552
- version: '5.0.18',
12591
+ version: '5.0.21',
12553
12592
  /** Bind new extensions to Jsuites */
12554
12593
  setExtensions: function(o) {
12555
12594
  if (typeof(o) == 'object') {
@@ -12559,10 +12598,7 @@ var jSuites = {
12559
12598
  }
12560
12599
  }
12561
12600
  },
12562
- // Helpers
12563
12601
  tracking: Tracking,
12564
- ...dictionary,
12565
- ...helpers,
12566
12602
  path: Path,
12567
12603
  sorting: Sorting,
12568
12604
  lazyLoading: LazyLoading,
@@ -12610,11 +12646,11 @@ jSuites.sha512 = (sha512_default());
12610
12646
 
12611
12647
 
12612
12648
  /** Core events */
12613
- var Events = function() {
12649
+ const Events = function() {
12614
12650
 
12615
12651
  document.jsuitesComponents = [];
12616
12652
 
12617
- var find = function(DOMElement, component) {
12653
+ const find = function(DOMElement, component) {
12618
12654
  if (DOMElement[component.type] && DOMElement[component.type] == component) {
12619
12655
  return true;
12620
12656
  }
@@ -12627,7 +12663,7 @@ var Events = function() {
12627
12663
  return false;
12628
12664
  }
12629
12665
 
12630
- var isOpened = function(e) {
12666
+ const isOpened = function(e) {
12631
12667
  if (document.jsuitesComponents && document.jsuitesComponents.length > 0) {
12632
12668
  for (var i = 0; i < document.jsuitesComponents.length; i++) {
12633
12669
  if (document.jsuitesComponents[i] && ! find(e, document.jsuitesComponents[i])) {
@@ -12638,26 +12674,26 @@ var Events = function() {
12638
12674
  }
12639
12675
 
12640
12676
  // Width of the border
12641
- var cornerSize = 15;
12677
+ let cornerSize = 15;
12642
12678
 
12643
12679
  // Current element
12644
- var element = null;
12680
+ let element = null;
12645
12681
 
12646
12682
  // Controllers
12647
- var editorAction = false;
12683
+ let editorAction = false;
12648
12684
 
12649
12685
  // Event state
12650
- var state = {
12686
+ let state = {
12651
12687
  x: null,
12652
12688
  y: null,
12653
12689
  }
12654
12690
 
12655
12691
  // Tooltip element
12656
- var tooltip = document.createElement('div')
12692
+ let tooltip = document.createElement('div')
12657
12693
  tooltip.classList.add('jtooltip');
12658
12694
 
12659
12695
  // Events
12660
- var mouseDown = function(e) {
12696
+ const mouseDown = function(e) {
12661
12697
  // Check if this is the floating
12662
12698
  var item = jSuites.findElement(e.target, 'jpanel');
12663
12699
  // Jfloating found
@@ -12730,7 +12766,7 @@ var Events = function() {
12730
12766
  isOpened(element);
12731
12767
  }
12732
12768
 
12733
- var mouseUp = function(e) {
12769
+ const mouseUp = function(e) {
12734
12770
  if (editorAction && editorAction.e) {
12735
12771
  if (typeof(editorAction.e.refresh) == 'function' && state.actioned) {
12736
12772
  editorAction.e.refresh();
@@ -12747,7 +12783,7 @@ var Events = function() {
12747
12783
  editorAction = false;
12748
12784
  }
12749
12785
 
12750
- var mouseMove = function(e) {
12786
+ const mouseMove = function(e) {
12751
12787
  if (editorAction) {
12752
12788
  var x = e.clientX || e.pageX;
12753
12789
  var y = e.clientY || e.pageY;
@@ -12845,7 +12881,7 @@ var Events = function() {
12845
12881
  }
12846
12882
  }
12847
12883
 
12848
- var mouseOver = function(e) {
12884
+ const mouseOver = function(e) {
12849
12885
  var message = e.target.getAttribute('data-tooltip');
12850
12886
  if (message) {
12851
12887
  // Instructions
@@ -12869,7 +12905,7 @@ var Events = function() {
12869
12905
  }
12870
12906
  }
12871
12907
 
12872
- var dblClick = function(e) {
12908
+ const dblClick = function(e) {
12873
12909
  var item = jSuites.findElement(e.target, 'jpanel');
12874
12910
  if (item && typeof(item.dblclick) == 'function') {
12875
12911
  // Create edition
@@ -12877,7 +12913,7 @@ var Events = function() {
12877
12913
  }
12878
12914
  }
12879
12915
 
12880
- var contextMenu = function(e) {
12916
+ const contextMenu = function(e) {
12881
12917
  var item = document.activeElement;
12882
12918
  if (item && typeof(item.contextmenu) == 'function') {
12883
12919
  // Create edition
@@ -12904,10 +12940,10 @@ var Events = function() {
12904
12940
  }
12905
12941
  }
12906
12942
 
12907
- var keyDown = function(e) {
12908
- var item = document.activeElement;
12943
+ const keyDown = function(e) {
12944
+ let item = document.activeElement;
12909
12945
  if (item) {
12910
- if (e.key == "Delete" && typeof(item.delete) == 'function') {
12946
+ if (e.key === "Delete" && typeof(item.delete) == 'function') {
12911
12947
  item.delete();
12912
12948
  e.preventDefault();
12913
12949
  e.stopImmediatePropagation();
@@ -12915,8 +12951,9 @@ var Events = function() {
12915
12951
  }
12916
12952
 
12917
12953
  if (document.jsuitesComponents && document.jsuitesComponents.length) {
12918
- if (item = document.jsuitesComponents[document.jsuitesComponents.length - 1]) {
12919
- if (e.key == "Escape" && typeof(item.isOpened) == 'function' && typeof(item.close) == 'function') {
12954
+ item = document.jsuitesComponents[document.jsuitesComponents.length - 1]
12955
+ if (item) {
12956
+ if (e.key === "Escape" && typeof(item.isOpened) == 'function' && typeof(item.close) == 'function') {
12920
12957
  if (item.isOpened()) {
12921
12958
  item.close();
12922
12959
  e.preventDefault();
@@ -12927,6 +12964,12 @@ var Events = function() {
12927
12964
  }
12928
12965
  }
12929
12966
 
12967
+ const input = function(e) {
12968
+ if (e.target.getAttribute('data-mask') || e.target.mask) {
12969
+ jSuites.mask(e);
12970
+ }
12971
+ }
12972
+
12930
12973
  document.addEventListener('mouseup', mouseUp);
12931
12974
  document.addEventListener("mousedown", mouseDown);
12932
12975
  document.addEventListener('mousemove', mouseMove);
@@ -12934,6 +12977,7 @@ var Events = function() {
12934
12977
  document.addEventListener('dblclick', dblClick);
12935
12978
  document.addEventListener('keydown', keyDown);
12936
12979
  document.addEventListener('contextmenu', contextMenu);
12980
+ document.addEventListener('input', input);
12937
12981
  }
12938
12982
 
12939
12983
  if (typeof(document) !== "undefined" && ! document.jsuitesComponents) {
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "main": "dist/jsuites.js",
27
27
  "types": "dist/jsuites.d.ts",
28
- "version": "5.0.18",
28
+ "version": "5.0.21",
29
29
  "bugs": "https://github.com/jsuites/jsuites/issues",
30
30
  "homepage": "https://github.com/jsuites/jsuites",
31
31
  "docs": "https://jsuites.net",