@webalternatif/js-core 1.1.2 → 1.2.0
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/cjs/array.js +46 -46
- package/dist/cjs/dom.js +154 -123
- package/dist/cjs/eventDispatcher.js +126 -86
- package/dist/cjs/i18n/agenda/en.js +65 -0
- package/dist/cjs/i18n/agenda/fr.js +67 -0
- package/dist/cjs/i18n/agenda/index.js +2 -0
- package/dist/cjs/i18n/ajaxform/en.js +5 -0
- package/dist/cjs/i18n/ajaxform/fr.js +5 -0
- package/dist/cjs/i18n/ajaxform/index.js +2 -0
- package/dist/cjs/i18n/ajaxupload/en.js +11 -0
- package/dist/cjs/i18n/ajaxupload/fr.js +11 -0
- package/dist/cjs/i18n/ajaxupload/index.js +2 -0
- package/dist/cjs/i18n/autocomplete/en.js +3 -0
- package/dist/cjs/i18n/autocomplete/fr.js +3 -0
- package/dist/cjs/i18n/autocomplete/index.js +2 -0
- package/dist/cjs/i18n/confirm/en.js +5 -0
- package/dist/cjs/i18n/confirm/fr.js +5 -0
- package/dist/cjs/i18n/confirm/index.js +2 -0
- package/dist/cjs/i18n/core/en.js +4 -0
- package/dist/cjs/i18n/core/fr.js +4 -0
- package/dist/cjs/i18n/core/index.js +2 -0
- package/dist/cjs/i18n/datagrid/en.js +8 -0
- package/dist/cjs/i18n/datagrid/fr.js +8 -0
- package/dist/cjs/i18n/datagrid/index.js +2 -0
- package/dist/cjs/i18n/date/en.js +47 -0
- package/dist/cjs/i18n/date/fr.js +47 -0
- package/dist/cjs/i18n/date/index.js +2 -0
- package/dist/cjs/i18n/datetimepicker/en.js +27 -0
- package/dist/cjs/i18n/datetimepicker/fr.js +27 -0
- package/dist/cjs/i18n/datetimepicker/index.js +2 -0
- package/dist/cjs/i18n/dialog/en.js +3 -0
- package/dist/cjs/i18n/dialog/fr.js +3 -0
- package/dist/cjs/i18n/dialog/index.js +2 -0
- package/dist/cjs/i18n/fulldayeventagenda/en.js +65 -0
- package/dist/cjs/i18n/fulldayeventagenda/fr.js +67 -0
- package/dist/cjs/i18n/fulldayeventagenda/index.js +2 -0
- package/dist/cjs/i18n/index.js +30 -0
- package/dist/cjs/i18n/richtexteditor/en.js +56 -0
- package/dist/cjs/i18n/richtexteditor/fr.js +56 -0
- package/dist/cjs/i18n/richtexteditor/index.js +2 -0
- package/dist/cjs/i18n/select/en.js +3 -0
- package/dist/cjs/i18n/select/fr.js +3 -0
- package/dist/cjs/i18n/select/index.js +2 -0
- package/dist/cjs/i18n/timepicker/en.js +3 -0
- package/dist/cjs/i18n/timepicker/fr.js +3 -0
- package/dist/cjs/i18n/timepicker/index.js +2 -0
- package/dist/cjs/i18n/useragenda/en.js +65 -0
- package/dist/cjs/i18n/useragenda/fr.js +67 -0
- package/dist/cjs/i18n/useragenda/index.js +2 -0
- package/dist/cjs/i18n.js +16 -25
- package/dist/cjs/index.js +24 -54
- package/dist/cjs/is.js +26 -45
- package/dist/cjs/math.js +27 -38
- package/dist/cjs/random.js +10 -23
- package/dist/cjs/string.js +162 -166
- package/dist/cjs/stringPrototype.js +10 -10
- package/dist/cjs/traversal.js +92 -61
- package/dist/cjs/utils.js +51 -43
- package/dist/esm/array.js +31 -20
- package/dist/esm/dom.js +142 -102
- package/dist/esm/eventDispatcher.js +123 -77
- package/dist/esm/i18n/agenda/en.js +65 -0
- package/dist/esm/i18n/agenda/fr.js +67 -0
- package/dist/esm/i18n/agenda/index.js +2 -0
- package/dist/esm/i18n/ajaxform/en.js +5 -0
- package/dist/esm/i18n/ajaxform/fr.js +5 -0
- package/dist/esm/i18n/ajaxform/index.js +2 -0
- package/dist/esm/i18n/ajaxupload/en.js +11 -0
- package/dist/esm/i18n/ajaxupload/fr.js +11 -0
- package/dist/esm/i18n/ajaxupload/index.js +2 -0
- package/dist/esm/i18n/autocomplete/en.js +3 -0
- package/dist/esm/i18n/autocomplete/fr.js +3 -0
- package/dist/esm/i18n/autocomplete/index.js +2 -0
- package/dist/esm/i18n/confirm/en.js +5 -0
- package/dist/esm/i18n/confirm/fr.js +5 -0
- package/dist/esm/i18n/confirm/index.js +2 -0
- package/dist/esm/i18n/core/en.js +4 -0
- package/dist/esm/i18n/core/fr.js +4 -0
- package/dist/esm/i18n/core/index.js +2 -0
- package/dist/esm/i18n/datagrid/en.js +8 -0
- package/dist/esm/i18n/datagrid/fr.js +8 -0
- package/dist/esm/i18n/datagrid/index.js +2 -0
- package/dist/esm/i18n/date/en.js +47 -0
- package/dist/esm/i18n/date/fr.js +47 -0
- package/dist/esm/i18n/date/index.js +2 -0
- package/dist/esm/i18n/datetimepicker/en.js +27 -0
- package/dist/esm/i18n/datetimepicker/fr.js +27 -0
- package/dist/esm/i18n/datetimepicker/index.js +2 -0
- package/dist/esm/i18n/dialog/en.js +3 -0
- package/dist/esm/i18n/dialog/fr.js +3 -0
- package/dist/esm/i18n/dialog/index.js +2 -0
- package/dist/esm/i18n/fulldayeventagenda/en.js +65 -0
- package/dist/esm/i18n/fulldayeventagenda/fr.js +67 -0
- package/dist/esm/i18n/fulldayeventagenda/index.js +2 -0
- package/dist/esm/i18n/index.js +30 -0
- package/dist/esm/i18n/richtexteditor/en.js +56 -0
- package/dist/esm/i18n/richtexteditor/fr.js +56 -0
- package/dist/esm/i18n/richtexteditor/index.js +2 -0
- package/dist/esm/i18n/select/en.js +3 -0
- package/dist/esm/i18n/select/fr.js +3 -0
- package/dist/esm/i18n/select/index.js +2 -0
- package/dist/esm/i18n/timepicker/en.js +3 -0
- package/dist/esm/i18n/timepicker/fr.js +3 -0
- package/dist/esm/i18n/timepicker/index.js +2 -0
- package/dist/esm/i18n/useragenda/en.js +65 -0
- package/dist/esm/i18n/useragenda/fr.js +67 -0
- package/dist/esm/i18n/useragenda/index.js +2 -0
- package/dist/esm/i18n.js +11 -10
- package/dist/esm/index.js +14 -13
- package/dist/esm/is.js +23 -22
- package/dist/esm/math.js +14 -13
- package/dist/esm/random.js +9 -9
- package/dist/esm/string.js +134 -99
- package/dist/esm/stringPrototype.js +8 -5
- package/dist/esm/traversal.js +79 -36
- package/dist/esm/utils.js +45 -24
- package/package.json +3 -2
package/dist/cjs/is.js
CHANGED
|
@@ -1,71 +1,53 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isUndefined = exports.isTouchDevice = exports.isString = exports.isScalar = exports.isPlainObject = exports.isObject = exports.isInteger = exports.isInt = exports.isFunction = exports.isFloat = exports.isEventSupported = exports.isEvent = exports.isDate = exports.isBoolean = exports.isBool = exports.isArrayLike = exports.isArray = void 0;
|
|
7
|
-
var _array = require("./array.js");
|
|
8
|
-
const isString = function (str) {
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
import { inArray } from "./array.js";
|
|
3
|
+
export var isString = function isString(str) {
|
|
9
4
|
return typeof str == 'string' || Object.prototype.toString.call(str) === '[object String]';
|
|
10
5
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return !!o && !isArray(o) && typeof o === 'object';
|
|
6
|
+
export var isObject = function isObject(o) {
|
|
7
|
+
return !!o && !isArray(o) && _typeof(o) === 'object';
|
|
14
8
|
};
|
|
15
|
-
|
|
16
|
-
const isFunction = function (f) {
|
|
9
|
+
export var isFunction = function isFunction(f) {
|
|
17
10
|
return !!f && typeof f === 'function';
|
|
18
11
|
};
|
|
19
|
-
|
|
20
|
-
const isPlainObject = function (o) {
|
|
12
|
+
export var isPlainObject = function isPlainObject(o) {
|
|
21
13
|
if (false === isObject(o)) return false;
|
|
22
14
|
if (undefined === o.constructor) return true;
|
|
23
15
|
if (false === isObject(o.constructor.prototype)) return false;
|
|
24
16
|
if (o.constructor.prototype.hasOwnProperty('isPrototypeOf') === false) return false;
|
|
25
17
|
return true;
|
|
26
18
|
};
|
|
27
|
-
|
|
28
|
-
const isBoolean = function (b) {
|
|
19
|
+
export var isBoolean = function isBoolean(b) {
|
|
29
20
|
return b === true || b === false;
|
|
30
21
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const isUndefined = function (v) {
|
|
22
|
+
export var isBool = isBoolean;
|
|
23
|
+
export var isUndefined = function isUndefined(v) {
|
|
34
24
|
return typeof v === 'undefined';
|
|
35
25
|
};
|
|
36
|
-
|
|
37
|
-
const isArrayLike = function (o) {
|
|
26
|
+
export var isArrayLike = function isArrayLike(o) {
|
|
38
27
|
return null !== o && !isString(o) && !isFunction(o) && isInt(o.length) && o.length >= 0 && Number.isFinite(o.length);
|
|
39
28
|
};
|
|
40
|
-
|
|
41
|
-
const isArray = function (a) {
|
|
29
|
+
export var isArray = function isArray(a) {
|
|
42
30
|
return Array.isArray(a);
|
|
43
31
|
};
|
|
44
|
-
|
|
45
|
-
const isDate = function (o) {
|
|
32
|
+
export var isDate = function isDate(o) {
|
|
46
33
|
return !!o && Object.prototype.toString.call(o) === '[object Date]';
|
|
47
34
|
};
|
|
48
|
-
|
|
49
|
-
const isEvent = function (o) {
|
|
35
|
+
export var isEvent = function isEvent(o) {
|
|
50
36
|
return isObject(o) && (!!o.preventDefault || /\[object Event\]/.test(o.constructor.toString()));
|
|
51
37
|
};
|
|
52
|
-
|
|
53
|
-
const isInteger = function (n) {
|
|
38
|
+
export var isInteger = function isInteger(n) {
|
|
54
39
|
return /^[\-]?\d+$/.test(n + '');
|
|
55
40
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const isFloat = function (n) {
|
|
41
|
+
export var isInt = isInteger;
|
|
42
|
+
export var isFloat = function isFloat(n) {
|
|
59
43
|
return /^[\-]?\d+(\.\d+)?$/.test(n + '');
|
|
60
44
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return value === null || (0, _array.inArray)(type, ['string', 'number', 'bigint', 'symbol', 'boolean']);
|
|
45
|
+
export var isScalar = function isScalar(value) {
|
|
46
|
+
var type = _typeof(value);
|
|
47
|
+
return value === null || inArray(type, ['string', 'number', 'bigint', 'symbol', 'boolean']);
|
|
65
48
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const TAGNAMES = {
|
|
49
|
+
export var isEventSupported = function () {
|
|
50
|
+
var TAGNAMES = {
|
|
69
51
|
select: 'input',
|
|
70
52
|
change: 'input',
|
|
71
53
|
submit: 'form',
|
|
@@ -75,15 +57,14 @@ const isEventSupported = exports.isEventSupported = function () {
|
|
|
75
57
|
abort: 'img'
|
|
76
58
|
};
|
|
77
59
|
function isEventSupported(eventName) {
|
|
78
|
-
|
|
60
|
+
var el = document.createElement(TAGNAMES[eventName] || 'div');
|
|
79
61
|
eventName = 'on' + eventName;
|
|
80
|
-
|
|
62
|
+
var isSupported = eventName in el;
|
|
81
63
|
el = null;
|
|
82
64
|
return isSupported;
|
|
83
65
|
}
|
|
84
66
|
return isEventSupported;
|
|
85
67
|
}();
|
|
86
|
-
|
|
68
|
+
export var isTouchDevice = function isTouchDevice() {
|
|
87
69
|
return isEventSupported('touchstart');
|
|
88
|
-
};
|
|
89
|
-
exports.isTouchDevice = isTouchDevice;
|
|
70
|
+
};
|
package/dist/cjs/math.js
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.round = exports.plancher = exports.min = exports.max = exports.hex2dec = exports.floorTo = exports.dec2hex = void 0;
|
|
7
|
-
var _traversal = require("./traversal.js");
|
|
8
|
-
var _is = require("./is.js");
|
|
9
|
-
var _string = require("./string.js");
|
|
10
|
-
const round = function (val, precision = 0) {
|
|
1
|
+
import { each } from "./traversal.js";
|
|
2
|
+
import { isArray, isFunction, isObject } from "./is.js";
|
|
3
|
+
import { reverse } from "./string.js";
|
|
4
|
+
export var round = function round(val) {
|
|
5
|
+
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
11
6
|
return Math.round(val * Math.pow(10, precision)) / Math.pow(10, precision);
|
|
12
7
|
};
|
|
13
|
-
|
|
14
|
-
const floorTo = function (n, precision) {
|
|
8
|
+
export var floorTo = function floorTo(n, precision) {
|
|
15
9
|
if (precision <= 0) throw new Error('Precision must be greater than 0');
|
|
16
10
|
return round(Math.floor(n / precision) * precision, 6);
|
|
17
11
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if ((0, _is.isArray)(list)) {
|
|
12
|
+
export var plancher = floorTo;
|
|
13
|
+
export var min = function min(list, cmp_func) {
|
|
14
|
+
if (isArray(list)) {
|
|
22
15
|
return Math.min.apply(null, list);
|
|
23
16
|
}
|
|
24
|
-
|
|
25
|
-
cmp_func =
|
|
17
|
+
var min;
|
|
18
|
+
cmp_func = isFunction(cmp_func) ? cmp_func : function (a, b) {
|
|
26
19
|
return a < b ? -1 : 1;
|
|
27
20
|
};
|
|
28
|
-
if (
|
|
29
|
-
|
|
21
|
+
if (isObject(list)) {
|
|
22
|
+
each(list, function (key, val, obj, index) {
|
|
30
23
|
if (index === 0) {
|
|
31
24
|
min = val;
|
|
32
25
|
} else {
|
|
@@ -36,17 +29,16 @@ const min = function (list, cmp_func) {
|
|
|
36
29
|
}
|
|
37
30
|
return min;
|
|
38
31
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if ((0, _is.isArray)(list)) {
|
|
32
|
+
export var max = function max(list, cmp_func) {
|
|
33
|
+
if (isArray(list)) {
|
|
42
34
|
return Math.max.apply(null, list);
|
|
43
35
|
}
|
|
44
|
-
|
|
45
|
-
cmp_func =
|
|
36
|
+
var max;
|
|
37
|
+
cmp_func = isFunction(cmp_func) ? cmp_func : function (a, b) {
|
|
46
38
|
return b - a;
|
|
47
39
|
};
|
|
48
|
-
if (
|
|
49
|
-
|
|
40
|
+
if (isObject(list)) {
|
|
41
|
+
each(list, function (key, val, obj, index) {
|
|
50
42
|
if (index === 0) {
|
|
51
43
|
max = val;
|
|
52
44
|
} else {
|
|
@@ -63,8 +55,7 @@ const max = function (list, cmp_func) {
|
|
|
63
55
|
* @param {number} n
|
|
64
56
|
* @returns {string}
|
|
65
57
|
*/
|
|
66
|
-
|
|
67
|
-
const dec2hex = function (n) {
|
|
58
|
+
export var dec2hex = function dec2hex(n) {
|
|
68
59
|
return n.toString(16);
|
|
69
60
|
};
|
|
70
61
|
|
|
@@ -74,13 +65,12 @@ const dec2hex = function (n) {
|
|
|
74
65
|
* @param {string} hex
|
|
75
66
|
* @returns {number}
|
|
76
67
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const index = c.indexOf(char);
|
|
68
|
+
export var hex2dec = function hex2dec(hex) {
|
|
69
|
+
hex = reverse(hex + '').toUpperCase();
|
|
70
|
+
var c = '0123456789ABCDEF';
|
|
71
|
+
var value = 0;
|
|
72
|
+
each(hex, function (i, _char) {
|
|
73
|
+
var index = c.indexOf(_char);
|
|
84
74
|
if (index === -1) {
|
|
85
75
|
value = 0;
|
|
86
76
|
return false;
|
|
@@ -88,5 +78,4 @@ const hex2dec = function (hex) {
|
|
|
88
78
|
value += index * Math.pow(2, 4 * i);
|
|
89
79
|
});
|
|
90
80
|
return value;
|
|
91
|
-
};
|
|
92
|
-
exports.hex2dec = hex2dec;
|
|
81
|
+
};
|
package/dist/cjs/random.js
CHANGED
|
@@ -1,38 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.uniqid = exports.randNum = exports.randAlphaNumCs = exports.randAlphaNum = exports.randAlphaCs = exports.randAlpha = exports.rand = void 0;
|
|
7
|
-
const uniqid = function () {
|
|
1
|
+
export var uniqid = function uniqid() {
|
|
8
2
|
return randAlpha(10);
|
|
9
3
|
};
|
|
10
|
-
|
|
11
|
-
const randAlpha = function (n) {
|
|
4
|
+
export var randAlpha = function randAlpha(n) {
|
|
12
5
|
return rand("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(','), n);
|
|
13
6
|
};
|
|
14
|
-
|
|
15
|
-
const randAlphaCs = function (n) {
|
|
7
|
+
export var randAlphaCs = function randAlphaCs(n) {
|
|
16
8
|
return rand("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z".split(','), n);
|
|
17
9
|
};
|
|
18
|
-
|
|
19
|
-
const randAlphaNum = function (n) {
|
|
10
|
+
export var randAlphaNum = function randAlphaNum(n) {
|
|
20
11
|
return rand("0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(','), n);
|
|
21
12
|
};
|
|
22
|
-
|
|
23
|
-
const randAlphaNumCs = function (n) {
|
|
13
|
+
export var randAlphaNumCs = function randAlphaNumCs(n) {
|
|
24
14
|
return rand("0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z".split(','), n);
|
|
25
15
|
};
|
|
26
|
-
|
|
27
|
-
const randNum = function (n) {
|
|
16
|
+
export var randNum = function randNum(n) {
|
|
28
17
|
return rand("0,1,2,3,4,5,6,7,8,9".split(','), n);
|
|
29
18
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
for (let i = 0; i < n; i++) {
|
|
19
|
+
export var rand = function rand(range, n) {
|
|
20
|
+
var rand = "";
|
|
21
|
+
for (var i = 0; i < n; i++) {
|
|
34
22
|
rand += range[Math.floor(Math.random() * 1000) % range.length];
|
|
35
23
|
}
|
|
36
24
|
return rand;
|
|
37
|
-
};
|
|
38
|
-
exports.rand = rand;
|
|
25
|
+
};
|