jsuites 5.0.21 → 5.0.22
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.
- package/dist/jsuites.js +81 -22
- package/package.json +1 -1
package/dist/jsuites.js
CHANGED
|
@@ -9710,11 +9710,11 @@ function Validations() {
|
|
|
9710
9710
|
* Value
|
|
9711
9711
|
*/
|
|
9712
9712
|
|
|
9713
|
-
|
|
9713
|
+
const isNumeric = function(num) {
|
|
9714
9714
|
return !isNaN(num) && num !== null && num !== '';
|
|
9715
9715
|
}
|
|
9716
9716
|
|
|
9717
|
-
|
|
9717
|
+
const numberCriterias = {
|
|
9718
9718
|
'between': function(value, range) {
|
|
9719
9719
|
return value >= range[0] && value <= range[1];
|
|
9720
9720
|
},
|
|
@@ -9741,13 +9741,16 @@ function Validations() {
|
|
|
9741
9741
|
},
|
|
9742
9742
|
}
|
|
9743
9743
|
|
|
9744
|
-
|
|
9744
|
+
const dateCriterias = {
|
|
9745
9745
|
'valid date': function() {
|
|
9746
9746
|
return true;
|
|
9747
9747
|
},
|
|
9748
9748
|
'=': function(value, range) {
|
|
9749
9749
|
return value === range[0];
|
|
9750
9750
|
},
|
|
9751
|
+
'!=': function(value, range) {
|
|
9752
|
+
return value !== range[0];
|
|
9753
|
+
},
|
|
9751
9754
|
'<': function(value, range) {
|
|
9752
9755
|
return value < range[0];
|
|
9753
9756
|
},
|
|
@@ -9768,7 +9771,7 @@ function Validations() {
|
|
|
9768
9771
|
},
|
|
9769
9772
|
}
|
|
9770
9773
|
|
|
9771
|
-
|
|
9774
|
+
const textCriterias = {
|
|
9772
9775
|
'contains': function(value, range) {
|
|
9773
9776
|
return value.includes(range[0]);
|
|
9774
9777
|
},
|
|
@@ -9784,6 +9787,9 @@ function Validations() {
|
|
|
9784
9787
|
'=': function(value, range) {
|
|
9785
9788
|
return value === range[0];
|
|
9786
9789
|
},
|
|
9790
|
+
'!=': function(value, range) {
|
|
9791
|
+
return value !== range[0];
|
|
9792
|
+
},
|
|
9787
9793
|
'valid email': function(value) {
|
|
9788
9794
|
var pattern = new RegExp(/^[^\s@]+@[^\s@]+\.[^\s@]+$/);
|
|
9789
9795
|
|
|
@@ -9797,12 +9803,11 @@ function Validations() {
|
|
|
9797
9803
|
}
|
|
9798
9804
|
|
|
9799
9805
|
// Component router
|
|
9800
|
-
|
|
9806
|
+
const component = function(value, options) {
|
|
9801
9807
|
if (typeof(component[options.type]) === 'function') {
|
|
9802
9808
|
if (options.allowBlank && value === '') {
|
|
9803
9809
|
return true;
|
|
9804
9810
|
}
|
|
9805
|
-
|
|
9806
9811
|
return component[options.type](value, options);
|
|
9807
9812
|
}
|
|
9808
9813
|
return null;
|
|
@@ -9815,7 +9820,7 @@ function Validations() {
|
|
|
9815
9820
|
|
|
9816
9821
|
component.email = function(data) {
|
|
9817
9822
|
var pattern = new RegExp(/^[^\s@]+@[^\s@]+\.[^\s@]+$/);
|
|
9818
|
-
return data && pattern.test(data) ? true : false;
|
|
9823
|
+
return data && pattern.test(data) ? true : false;
|
|
9819
9824
|
}
|
|
9820
9825
|
|
|
9821
9826
|
component.required = function(data) {
|
|
@@ -9823,19 +9828,19 @@ function Validations() {
|
|
|
9823
9828
|
}
|
|
9824
9829
|
|
|
9825
9830
|
component.exist = function(data, options) {
|
|
9826
|
-
return !!data.toString();
|
|
9831
|
+
return !!data.toString().trim();
|
|
9827
9832
|
}
|
|
9828
9833
|
|
|
9829
9834
|
component['not exist'] = function(data, options) {
|
|
9830
|
-
return !data.toString();
|
|
9835
|
+
return !data.toString().trim();
|
|
9831
9836
|
}
|
|
9832
9837
|
|
|
9833
9838
|
component.empty = function(data) {
|
|
9834
|
-
return !data.toString();
|
|
9839
|
+
return !data.toString().trim();
|
|
9835
9840
|
}
|
|
9836
9841
|
|
|
9837
9842
|
component.notEmpty = function(data) {
|
|
9838
|
-
return !!data.toString();
|
|
9843
|
+
return !!data.toString().trim();
|
|
9839
9844
|
}
|
|
9840
9845
|
|
|
9841
9846
|
component.number = function(data, options) {
|
|
@@ -9851,7 +9856,7 @@ function Validations() {
|
|
|
9851
9856
|
return false;
|
|
9852
9857
|
}
|
|
9853
9858
|
|
|
9854
|
-
|
|
9859
|
+
let values = options.value.map(function(num) {
|
|
9855
9860
|
return parseFloat(num);
|
|
9856
9861
|
})
|
|
9857
9862
|
|
|
@@ -9859,28 +9864,78 @@ function Validations() {
|
|
|
9859
9864
|
};
|
|
9860
9865
|
|
|
9861
9866
|
component.login = function(data) {
|
|
9862
|
-
|
|
9867
|
+
let pattern = new RegExp(/^[a-zA-Z0-9._-]+$/);
|
|
9863
9868
|
return data && pattern.test(data) ? true : false;
|
|
9864
9869
|
}
|
|
9865
9870
|
|
|
9866
9871
|
component.list = function(data, options) {
|
|
9867
|
-
|
|
9872
|
+
let dataType = typeof data;
|
|
9868
9873
|
if (dataType !== 'string' && dataType !== 'number') {
|
|
9869
9874
|
return false;
|
|
9870
9875
|
}
|
|
9876
|
+
let list;
|
|
9871
9877
|
if (typeof(options.value[0]) === 'string') {
|
|
9872
|
-
|
|
9878
|
+
list = options.value[0].split(',');
|
|
9873
9879
|
} else {
|
|
9874
|
-
|
|
9880
|
+
list = options.value[0];
|
|
9875
9881
|
}
|
|
9876
9882
|
|
|
9877
|
-
|
|
9878
|
-
return
|
|
9879
|
-
}
|
|
9883
|
+
if (! Array.isArray(list)) {
|
|
9884
|
+
return false;
|
|
9885
|
+
} else {
|
|
9886
|
+
let validOption = list.findIndex(function (item) {
|
|
9887
|
+
return item == data;
|
|
9888
|
+
});
|
|
9889
|
+
|
|
9890
|
+
return validOption > -1;
|
|
9891
|
+
}
|
|
9892
|
+
}
|
|
9880
9893
|
|
|
9881
|
-
|
|
9894
|
+
const getCurrentDateWithoutTime = function() {
|
|
9895
|
+
let date = new Date();
|
|
9896
|
+
date.setHours(0, 0, 0, 0);
|
|
9897
|
+
return date;
|
|
9882
9898
|
}
|
|
9883
9899
|
|
|
9900
|
+
const relativeDates = {
|
|
9901
|
+
'one year ago': function() {
|
|
9902
|
+
let date = getCurrentDateWithoutTime();
|
|
9903
|
+
|
|
9904
|
+
date.setFullYear(date.getFullYear() - 1);
|
|
9905
|
+
|
|
9906
|
+
return date;
|
|
9907
|
+
},
|
|
9908
|
+
'one month ago': function() {
|
|
9909
|
+
let date = getCurrentDateWithoutTime();
|
|
9910
|
+
|
|
9911
|
+
date.setMonth(date.getMonth() - 1);
|
|
9912
|
+
|
|
9913
|
+
return date;
|
|
9914
|
+
},
|
|
9915
|
+
'one week ago': function() {
|
|
9916
|
+
let date = getCurrentDateWithoutTime();
|
|
9917
|
+
|
|
9918
|
+
date.setDate(date.getDate() - 7);
|
|
9919
|
+
|
|
9920
|
+
return date;
|
|
9921
|
+
},
|
|
9922
|
+
yesterday: function() {
|
|
9923
|
+
let date = getCurrentDateWithoutTime();
|
|
9924
|
+
|
|
9925
|
+
date.setDate(date.getDate() - 1);
|
|
9926
|
+
|
|
9927
|
+
return date;
|
|
9928
|
+
},
|
|
9929
|
+
today: getCurrentDateWithoutTime,
|
|
9930
|
+
tomorrow: function() {
|
|
9931
|
+
let date = getCurrentDateWithoutTime();
|
|
9932
|
+
|
|
9933
|
+
date.setDate(date.getDate() + 1);
|
|
9934
|
+
|
|
9935
|
+
return date;
|
|
9936
|
+
},
|
|
9937
|
+
};
|
|
9938
|
+
|
|
9884
9939
|
component.date = function(data, options) {
|
|
9885
9940
|
if (new Date(data) == 'Invalid Date') {
|
|
9886
9941
|
return false;
|
|
@@ -9894,7 +9949,11 @@ function Validations() {
|
|
|
9894
9949
|
return false;
|
|
9895
9950
|
}
|
|
9896
9951
|
|
|
9897
|
-
|
|
9952
|
+
let values = options.value.map(function(date) {
|
|
9953
|
+
if (typeof date === 'string' && relativeDates[date]) {
|
|
9954
|
+
return relativeDates[date]().getTime();
|
|
9955
|
+
}
|
|
9956
|
+
|
|
9898
9957
|
return new Date(date).getTime();
|
|
9899
9958
|
});
|
|
9900
9959
|
|
|
@@ -12588,7 +12647,7 @@ var jSuites = {
|
|
|
12588
12647
|
...dictionary,
|
|
12589
12648
|
...helpers,
|
|
12590
12649
|
/** Current version */
|
|
12591
|
-
version: '5.0.
|
|
12650
|
+
version: '5.0.22',
|
|
12592
12651
|
/** Bind new extensions to Jsuites */
|
|
12593
12652
|
setExtensions: function(o) {
|
|
12594
12653
|
if (typeof(o) == 'object') {
|
package/package.json
CHANGED