@libs-ui/utils 0.2.279 → 0.2.281
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/color.d.ts +1 -1
- package/esm2022/color.mjs +2 -2
- package/esm2022/dom.mjs +2 -2
- package/esm2022/format-text.mjs +82 -18
- package/esm2022/get-smart-axis-scale.mjs +31 -0
- package/esm2022/helpers.mjs +4 -1
- package/esm2022/index.mjs +2 -5
- package/fesm2022/libs-ui-utils.mjs +218 -193
- package/fesm2022/libs-ui-utils.mjs.map +1 -1
- package/format-text.d.ts +5 -0
- package/get-smart-axis-scale.d.ts +9 -0
- package/index.d.ts +1 -4
- package/package.json +2 -2
- package/delete-unicode.d.ts +0 -1
- package/escape-html.d.ts +0 -2
- package/esm2022/delete-unicode.mjs +0 -20
- package/esm2022/escape-html.mjs +0 -26
- package/esm2022/get-color-by-id.mjs +0 -17
- package/esm2022/remove-emoji.mjs +0 -10
- package/get-color-by-id.d.ts +0 -1
- package/remove-emoji.d.ts +0 -2
package/esm2022/index.mjs
CHANGED
|
@@ -11,12 +11,8 @@ export * from './language';
|
|
|
11
11
|
export * from './key-cache';
|
|
12
12
|
export * from './cache';
|
|
13
13
|
export * from './format-number';
|
|
14
|
-
export * from './remove-emoji';
|
|
15
|
-
export * from './escape-html';
|
|
16
14
|
export * from './communicate-micro';
|
|
17
15
|
export * from './function-check-embed-frame';
|
|
18
|
-
export * from './delete-unicode';
|
|
19
|
-
export * from './get-color-by-id';
|
|
20
16
|
export * from './constants';
|
|
21
17
|
export * from './pattern';
|
|
22
18
|
export * from './xss-filter';
|
|
@@ -28,4 +24,5 @@ export * from './inject-token';
|
|
|
28
24
|
export * from './file';
|
|
29
25
|
export * from './uri';
|
|
30
26
|
export * from './format-text';
|
|
31
|
-
|
|
27
|
+
export * from './get-smart-axis-scale';
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9saWJzLXVpL3V0aWxzL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLE9BQU8sQ0FBQztBQUN0QixjQUFjLHFCQUFxQixDQUFDO0FBQ3BDLGNBQWMsUUFBUSxDQUFDO0FBQ3ZCLGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMsU0FBUyxDQUFDO0FBQ3hCLGNBQWMsVUFBVSxDQUFDO0FBQ3pCLGNBQWMsY0FBYyxDQUFDO0FBQzdCLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMsZUFBZSxDQUFDO0FBQzlCLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsU0FBUyxDQUFDO0FBQ3hCLGNBQWMsaUJBQWlCLENBQUM7QUFDaEMsY0FBYyxxQkFBcUIsQ0FBQztBQUNwQyxjQUFjLDhCQUE4QixDQUFDO0FBQzdDLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMsY0FBYyxDQUFDO0FBQzdCLGNBQWMseUJBQXlCLENBQUM7QUFDeEMsY0FBYyxRQUFRLENBQUM7QUFDdkIsY0FBYyxZQUFZLENBQUM7QUFDM0IsY0FBYyxVQUFVLENBQUM7QUFDekIsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLFFBQVEsQ0FBQztBQUN2QixjQUFjLE9BQU8sQ0FBQztBQUN0QixjQUFjLGVBQWUsQ0FBQztBQUM5QixjQUFjLHdCQUF3QixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9kb20nO1xuZXhwb3J0ICogZnJvbSAnLi91cmwtc2VhcmNoLXBhcmFtcyc7XG5leHBvcnQgKiBmcm9tICcuL3V1aWQnO1xuZXhwb3J0ICogZnJvbSAnLi9oZWxwZXJzJztcbmV4cG9ydCAqIGZyb20gJy4vY29sb3InO1xuZXhwb3J0ICogZnJvbSAnLi9jcnlwdG8nO1xuZXhwb3J0ICogZnJvbSAnLi9jcnlwdG8tM3JkJztcbmV4cG9ydCAqIGZyb20gJy4va2V5LWNvZGUnO1xuZXhwb3J0ICogZnJvbSAnLi9odHRwLXBhcmFtcyc7XG5leHBvcnQgKiBmcm9tICcuL2xhbmd1YWdlJztcbmV4cG9ydCAqIGZyb20gJy4va2V5LWNhY2hlJztcbmV4cG9ydCAqIGZyb20gJy4vY2FjaGUnO1xuZXhwb3J0ICogZnJvbSAnLi9mb3JtYXQtbnVtYmVyJztcbmV4cG9ydCAqIGZyb20gJy4vY29tbXVuaWNhdGUtbWljcm8nO1xuZXhwb3J0ICogZnJvbSAnLi9mdW5jdGlvbi1jaGVjay1lbWJlZC1mcmFtZSc7XG5leHBvcnQgKiBmcm9tICcuL2NvbnN0YW50cyc7XG5leHBvcnQgKiBmcm9tICcuL3BhdHRlcm4nO1xuZXhwb3J0ICogZnJvbSAnLi94c3MtZmlsdGVyJztcbmV4cG9ydCAqIGZyb20gJy4vdHdvLXdheS1zaWduYWwtb2JqZWN0JztcbmV4cG9ydCAqIGZyb20gJy4vZGF0ZSc7XG5leHBvcnQgKiBmcm9tICcuL2Rvd25sb2FkJztcbmV4cG9ydCAqIGZyb20gJy4vYmFzZTY0JztcbmV4cG9ydCAqIGZyb20gJy4vaW5qZWN0LXRva2VuJztcbmV4cG9ydCAqIGZyb20gJy4vZmlsZSc7XG5leHBvcnQgKiBmcm9tICcuL3VyaSc7XG5leHBvcnQgKiBmcm9tICcuL2Zvcm1hdC10ZXh0JztcbmV4cG9ydCAqIGZyb20gJy4vZ2V0LXNtYXJ0LWF4aXMtc2NhbGUnOyJdfQ==
|
|
@@ -12,6 +12,166 @@ import timezone from 'dayjs/plugin/timezone';
|
|
|
12
12
|
import updateLocale from 'dayjs/plugin/updateLocale';
|
|
13
13
|
import utc from 'dayjs/plugin/utc';
|
|
14
14
|
|
|
15
|
+
/* eslint-disable no-useless-escape */
|
|
16
|
+
const patternEmail = () => {
|
|
17
|
+
return /^[A-z0-9]+[A-z0-9\_\.\+\-]*[A-z0-9]@[A-z0-9]+[A-z0-9\_\.\+\-]*[A-z0-9]\.[A-z0-9]+[A-z0-9\_\.\+\-]*[A-z0-9]$/;
|
|
18
|
+
};
|
|
19
|
+
const patternUrl = () => {
|
|
20
|
+
return /^(http|https|ftp):(\/){2}[^\s]+[.]{1}[^\s]+$/;
|
|
21
|
+
};
|
|
22
|
+
const patternHostUrl = () => {
|
|
23
|
+
return /^((https|http|ftp):[/]{2}[^/\s]+)/;
|
|
24
|
+
};
|
|
25
|
+
const patternDomain = () => {
|
|
26
|
+
return /^([a-zA-Z0-9])(([a-z0-9-]{1,61})?[a-z0-9]{1})?(\.[a-z0-9](([a-z0-9-]{1,61})?[a-z0-9]{1})?)?(\.[a-zA-Z]{2,4})+$/;
|
|
27
|
+
};
|
|
28
|
+
const patternMobilePhone = () => {
|
|
29
|
+
return /^(\+?84|0|84)([0-9]{9})$/;
|
|
30
|
+
};
|
|
31
|
+
const patternPhone = () => {
|
|
32
|
+
return /^(\+?84|[0-9]|84)([0-9]{2,9})$/;
|
|
33
|
+
};
|
|
34
|
+
const patternPhoneNormal = () => {
|
|
35
|
+
return /^(\+?84|[0-9]|84)([0-9]{9,10})$/;
|
|
36
|
+
};
|
|
37
|
+
const patternNumber = () => {
|
|
38
|
+
return /\d+/g;
|
|
39
|
+
};
|
|
40
|
+
const patternEncodeUri = () => {
|
|
41
|
+
return /%([0-9A-F]{2})/g;
|
|
42
|
+
};
|
|
43
|
+
const patternName = () => {
|
|
44
|
+
return /^\w+[A-Za-z\s\d]+$/;
|
|
45
|
+
};
|
|
46
|
+
const patternNameUtf8 = () => {
|
|
47
|
+
return /^[ àáảãạăắằẵặẳâầấậẫẩđèéẻẽẹêềếểễệìíỉĩịòóỏõọôồốổỗộơờớởỡợùúủũụưừứửữựỳýỷỹÀÁẢÃẠĂẮẰẴẶẲÂẦẤẬẪẨĐÈÉẺẼẸÊỀẾỂỄỆÌÍỈĨỊÒÓỎÕỌÔỒỐỔỖỘƠỜỚỞỠỢÙÚỦŨỤƯỪỨỬỮỰỲÝỶỸA-Za-z0-9]+$/;
|
|
48
|
+
};
|
|
49
|
+
const patternNameSpecial = () => {
|
|
50
|
+
return /[~!@#$%^&*()-+=<>,?\/\\:;"']/;
|
|
51
|
+
};
|
|
52
|
+
const patternNameProfile = () => {
|
|
53
|
+
return /([\w\W\d\s]+)+/;
|
|
54
|
+
};
|
|
55
|
+
const patternEmoji = () => {
|
|
56
|
+
return /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;
|
|
57
|
+
};
|
|
58
|
+
const patternRuleFieldReplace = () => {
|
|
59
|
+
return /[{]{2}[a-zA-Z_-]+[}]{2}/g;
|
|
60
|
+
};
|
|
61
|
+
const patternGetFieldByRuleFieldReplace = () => {
|
|
62
|
+
return /[a-zA-Z_-]+/g;
|
|
63
|
+
};
|
|
64
|
+
const patternPem = () => {
|
|
65
|
+
return /^(0|1):([0-9]{1,2}):(\{\{path-api\}\}):([a-zA-Z0-9\/]+)$/g;
|
|
66
|
+
};
|
|
67
|
+
const patternTax = () => {
|
|
68
|
+
return /^([0-9]){10}(-[0-9]{3})?$/;
|
|
69
|
+
};
|
|
70
|
+
const patternKey = () => {
|
|
71
|
+
return /^([0-9]){10}(-[0-9]{3})?$/;
|
|
72
|
+
};
|
|
73
|
+
const patternAccount = () => {
|
|
74
|
+
return /^(?=.*@)[a-z0-9@._-]{2,63}$/;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const highlightByKeyword = (value, search, ignoreHighlight, classHightLight) => {
|
|
78
|
+
if (!value) {
|
|
79
|
+
return '—';
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
if (!search || ignoreHighlight) {
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
const keysReplace = getValueReplace(search, value);
|
|
86
|
+
if (!keysReplace || !keysReplace.length) {
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
if (!classHightLight) {
|
|
90
|
+
classHightLight = 'bg-[#19344a] text-white';
|
|
91
|
+
}
|
|
92
|
+
keysReplace.forEach(key => {
|
|
93
|
+
const regExp = new RegExp(key, 'gi');
|
|
94
|
+
value = value?.replace(regExp, `<span class="${classHightLight}">$&</span>`);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.log(error);
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
// eslint-disable-next-line no-unsafe-finally
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const getValueReplace = (search, value) => {
|
|
106
|
+
const searchConvert = deleteUnicode(search).toLowerCase();
|
|
107
|
+
const valueConvert = deleteUnicode(value).toLowerCase();
|
|
108
|
+
const keys = new Set();
|
|
109
|
+
let i = 0;
|
|
110
|
+
while ((i = valueConvert.indexOf(searchConvert, i)) >= 0) {
|
|
111
|
+
const endIndex = i + search.length;
|
|
112
|
+
keys.add(value.substring(i, endIndex));
|
|
113
|
+
i += +valueConvert.length;
|
|
114
|
+
}
|
|
115
|
+
return Array.from(keys);
|
|
116
|
+
};
|
|
117
|
+
const formatTextCompare = (text, options) => {
|
|
118
|
+
if (!text) {
|
|
119
|
+
return text;
|
|
120
|
+
}
|
|
121
|
+
text = text.normalize("NFC");
|
|
122
|
+
return formatByOptions(text, options);
|
|
123
|
+
};
|
|
124
|
+
const fullNameFormat = (value) => {
|
|
125
|
+
if (!value) {
|
|
126
|
+
return value;
|
|
127
|
+
}
|
|
128
|
+
return capitalize(value, { lowercaseOtherCharacter: true, trim: true, removeMultipleSpace: true, removeEmoji: true });
|
|
129
|
+
};
|
|
130
|
+
const capitalize = (text, options) => {
|
|
131
|
+
if (!text) {
|
|
132
|
+
return text;
|
|
133
|
+
}
|
|
134
|
+
text = formatByOptions(text, options);
|
|
135
|
+
return text.split(' ').map(word => firstLetterToUpperCase(word)).join(' ');
|
|
136
|
+
};
|
|
137
|
+
const firstLetterToUpperCase = (text, options) => {
|
|
138
|
+
if (!text) {
|
|
139
|
+
return text;
|
|
140
|
+
}
|
|
141
|
+
return uppercaseByPosition(text, 0, options);
|
|
142
|
+
};
|
|
143
|
+
const uppercaseByPosition = (text, position, options) => {
|
|
144
|
+
if (!text) {
|
|
145
|
+
return text;
|
|
146
|
+
}
|
|
147
|
+
text = formatByOptions(text, options);
|
|
148
|
+
return `${text.substring(0, position)}${text.charAt(position).toUpperCase()}${text.substring(position + 1)}`;
|
|
149
|
+
};
|
|
150
|
+
const formatByOptions = (text, options) => {
|
|
151
|
+
if (!text || !options) {
|
|
152
|
+
return text;
|
|
153
|
+
}
|
|
154
|
+
if (options?.uppercaseOtherCharacter) {
|
|
155
|
+
text = text.toUpperCase();
|
|
156
|
+
}
|
|
157
|
+
if (options?.lowercaseOtherCharacter) {
|
|
158
|
+
text = text.toLowerCase();
|
|
159
|
+
}
|
|
160
|
+
if (options?.removeMultipleSpace) {
|
|
161
|
+
text = text.replace(/\u200B|\u00A0/g, "");
|
|
162
|
+
text = text.replace(/\s+/g, ' ');
|
|
163
|
+
}
|
|
164
|
+
if (options?.removeEmoji) {
|
|
165
|
+
text = removeEmoji(text);
|
|
166
|
+
}
|
|
167
|
+
if (options?.removeUnicode) {
|
|
168
|
+
text = deleteUnicode(text);
|
|
169
|
+
}
|
|
170
|
+
if (options?.trim) {
|
|
171
|
+
text = text.trim();
|
|
172
|
+
}
|
|
173
|
+
return text;
|
|
174
|
+
};
|
|
15
175
|
const escapeHtml = (str) => {
|
|
16
176
|
if (!str || typeof str !== 'string') {
|
|
17
177
|
return str;
|
|
@@ -37,6 +197,31 @@ const decodeEscapeHtml = (str) => {
|
|
|
37
197
|
}
|
|
38
198
|
return str;
|
|
39
199
|
};
|
|
200
|
+
const deleteUnicode = (str) => {
|
|
201
|
+
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, 'a');
|
|
202
|
+
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ|ễ/g, 'e');
|
|
203
|
+
str = str.replace(/ì|í|ị|ỉ|ĩ/g, 'i');
|
|
204
|
+
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, 'o');
|
|
205
|
+
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, 'u');
|
|
206
|
+
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, 'y');
|
|
207
|
+
str = str.replace(/đ/g, 'd');
|
|
208
|
+
str = str.replace(/À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ/g, 'A');
|
|
209
|
+
str = str.replace(/È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ/g, 'E');
|
|
210
|
+
str = str.replace(/Ì|Í|Ị|Ỉ|Ĩ/g, 'I');
|
|
211
|
+
str = str.replace(/Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ/g, 'O');
|
|
212
|
+
str = str.replace(/Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ/g, 'U');
|
|
213
|
+
str = str.replace(/Ỳ|Ý|Ỵ|Ỷ|Ỹ/g, 'Y');
|
|
214
|
+
str = str.replace(/Đ/g, 'D');
|
|
215
|
+
str = str.replace(/\u0300|\u0301|\u0303|\u0309|\u0323/g, ""); // ̀ ́ ̃ ̉ ̣ huyền, sắc, ngã, hỏi, nặng
|
|
216
|
+
str = str.replace(/\u02C6|\u0306|\u031B/g, ""); // ˆ ̆ ̛ Â, Ê, Ă, Ơ, Ư
|
|
217
|
+
return str.normalize("NFC");
|
|
218
|
+
};
|
|
219
|
+
const removeEmoji = (text) => {
|
|
220
|
+
if (!text || !text.trim()) {
|
|
221
|
+
return text;
|
|
222
|
+
}
|
|
223
|
+
return text.replace(patternEmoji(), '');
|
|
224
|
+
};
|
|
40
225
|
|
|
41
226
|
const parser = new DOMParser();
|
|
42
227
|
const quill = new Quill(document.createElement('div'));
|
|
@@ -433,6 +618,9 @@ const isNil = (value) => {
|
|
|
433
618
|
* isEmpty({ a: 1 }); // false
|
|
434
619
|
*/
|
|
435
620
|
const isEmpty = (value) => {
|
|
621
|
+
while (isSignal(value)) {
|
|
622
|
+
value = value();
|
|
623
|
+
}
|
|
436
624
|
return value === null || value === '' || value === undefined || (typeof value === 'object' && (JSON.stringify(value) === '{}' || JSON.stringify(value) === '[]'));
|
|
437
625
|
};
|
|
438
626
|
/**
|
|
@@ -920,11 +1108,11 @@ const pad = (number, length) => {
|
|
|
920
1108
|
}
|
|
921
1109
|
return str;
|
|
922
1110
|
};
|
|
923
|
-
const listColorDefine
|
|
1111
|
+
const listColorDefine = ['#E62222', '#B81B1B', '#EB4E4E', '#F97316', '#C75C12', '#FA8F45', '#FFB700', '#CC9200', '#FFC533', '#84CC16', '#6AA312', '#9dd645', '#00BC62', '#00A757', '#33DA8A', '#06B6D4', '#1B59C4', '#4E8CF7', '#0EA5E9',
|
|
924
1112
|
'#1B59C4', '#4E8CF7', '#226FF5', '#1B59C4', '#4E8CF7', '#6366F1', '#4F52C1', '#8285F4', '#5B04B3', '#49038F', '#7C36C2', '#D946EF', '#AE38BF', '#E16BF2', '#EC4899', '#BD3A7A', '#F06DAD', '#F43F5E', '#C3324B', '#F6657E', '#757380', '#5E5C66', '#918F99',
|
|
925
1113
|
'#202020', '#1A1A1A', '#4D4D4D'
|
|
926
1114
|
];
|
|
927
|
-
const
|
|
1115
|
+
const getColorById = (str) => {
|
|
928
1116
|
let hashString = 0;
|
|
929
1117
|
if (!str) {
|
|
930
1118
|
return '';
|
|
@@ -934,7 +1122,7 @@ const GetColorById = (str) => {
|
|
|
934
1122
|
hashString = ((hashString << 5) - hashString) + char;
|
|
935
1123
|
hashString = hashString & hashString;
|
|
936
1124
|
}
|
|
937
|
-
return listColorDefine
|
|
1125
|
+
return listColorDefine[Math.abs(hashString) % listColorDefine.length];
|
|
938
1126
|
};
|
|
939
1127
|
|
|
940
1128
|
let key = '12~@#loqwsxacva(3rdhaq12';
|
|
@@ -1789,115 +1977,6 @@ const viewDataNumberByLanguage = (value, acceptNegativeValue, parseFixed = 1, ig
|
|
|
1789
1977
|
}
|
|
1790
1978
|
};
|
|
1791
1979
|
|
|
1792
|
-
const emojiPattern = () => {
|
|
1793
|
-
return /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;
|
|
1794
|
-
};
|
|
1795
|
-
const removeEmoji = (text) => {
|
|
1796
|
-
if (!text || !text.trim()) {
|
|
1797
|
-
return text;
|
|
1798
|
-
}
|
|
1799
|
-
return text.replace(emojiPattern(), '');
|
|
1800
|
-
};
|
|
1801
|
-
|
|
1802
|
-
const deleteUnicode = (str) => {
|
|
1803
|
-
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, 'a');
|
|
1804
|
-
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ|ễ/g, 'e');
|
|
1805
|
-
str = str.replace(/ì|í|ị|ỉ|ĩ/g, 'i');
|
|
1806
|
-
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, 'o');
|
|
1807
|
-
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, 'u');
|
|
1808
|
-
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, 'y');
|
|
1809
|
-
str = str.replace(/đ/g, 'd');
|
|
1810
|
-
str = str.replace(/À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ/g, 'A');
|
|
1811
|
-
str = str.replace(/È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ/g, 'E');
|
|
1812
|
-
str = str.replace(/Ì|Í|Ị|Ỉ|Ĩ/g, 'I');
|
|
1813
|
-
str = str.replace(/Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ/g, 'O');
|
|
1814
|
-
str = str.replace(/Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ/g, 'U');
|
|
1815
|
-
str = str.replace(/Ỳ|Ý|Ỵ|Ỷ|Ỹ/g, 'Y');
|
|
1816
|
-
str = str.replace(/Đ/g, 'D');
|
|
1817
|
-
str = str.replace(/\u0300|\u0301|\u0303|\u0309|\u0323/g, ""); // ̀ ́ ̃ ̉ ̣ huyền, sắc, ngã, hỏi, nặng
|
|
1818
|
-
str = str.replace(/\u02C6|\u0306|\u031B/g, ""); // ˆ ̆ ̛ Â, Ê, Ă, Ơ, Ư
|
|
1819
|
-
return str.normalize();
|
|
1820
|
-
};
|
|
1821
|
-
|
|
1822
|
-
const listColorDefine = ['#E62222', '#B81B1B', '#EB4E4E', '#F97316', '#C75C12', '#FA8F45', '#FFB700', '#CC9200', '#FFC533', '#84CC16', '#6AA312', '#9dd645', '#00BC62', '#00A757', '#33DA8A', '#06B6D4', '#1B59C4', '#4E8CF7', '#0EA5E9',
|
|
1823
|
-
'#1B59C4', '#4E8CF7', '#226FF5', '#1B59C4', '#4E8CF7', '#6366F1', '#4F52C1', '#8285F4', '#5B04B3', '#49038F', '#7C36C2', '#D946EF', '#AE38BF', '#E16BF2', '#EC4899', '#BD3A7A', '#F06DAD', '#F43F5E', '#C3324B', '#F6657E', '#757380', '#5E5C66', '#918F99',
|
|
1824
|
-
'#202020', '#1A1A1A', '#4D4D4D'
|
|
1825
|
-
];
|
|
1826
|
-
const getColorById = (str) => {
|
|
1827
|
-
let hashString = 0;
|
|
1828
|
-
if (!str) {
|
|
1829
|
-
return '';
|
|
1830
|
-
}
|
|
1831
|
-
for (let i = 0; i < str.length; i++) {
|
|
1832
|
-
const char = str.charCodeAt(i);
|
|
1833
|
-
hashString = ((hashString << 5) - hashString) + char;
|
|
1834
|
-
hashString = hashString & hashString;
|
|
1835
|
-
}
|
|
1836
|
-
return listColorDefine[Math.abs(hashString) % listColorDefine.length];
|
|
1837
|
-
};
|
|
1838
|
-
|
|
1839
|
-
/* eslint-disable no-useless-escape */
|
|
1840
|
-
const patternEmail = () => {
|
|
1841
|
-
return /^[A-z0-9]+[A-z0-9\_\.\+\-]*[A-z0-9]@[A-z0-9]+[A-z0-9\_\.\+\-]*[A-z0-9]\.[A-z0-9]+[A-z0-9\_\.\+\-]*[A-z0-9]$/;
|
|
1842
|
-
};
|
|
1843
|
-
const patternUrl = () => {
|
|
1844
|
-
return /^(http|https|ftp):(\/){2}[^\s]+[.]{1}[^\s]+$/;
|
|
1845
|
-
};
|
|
1846
|
-
const patternHostUrl = () => {
|
|
1847
|
-
return /^((https|http|ftp):[/]{2}[^/\s]+)/;
|
|
1848
|
-
};
|
|
1849
|
-
const patternDomain = () => {
|
|
1850
|
-
return /^([a-zA-Z0-9])(([a-z0-9-]{1,61})?[a-z0-9]{1})?(\.[a-z0-9](([a-z0-9-]{1,61})?[a-z0-9]{1})?)?(\.[a-zA-Z]{2,4})+$/;
|
|
1851
|
-
};
|
|
1852
|
-
const patternMobilePhone = () => {
|
|
1853
|
-
return /^(\+?84|0|84)([0-9]{9})$/;
|
|
1854
|
-
};
|
|
1855
|
-
const patternPhone = () => {
|
|
1856
|
-
return /^(\+?84|[0-9]|84)([0-9]{2,9})$/;
|
|
1857
|
-
};
|
|
1858
|
-
const patternPhoneNormal = () => {
|
|
1859
|
-
return /^(\+?84|[0-9]|84)([0-9]{9,10})$/;
|
|
1860
|
-
};
|
|
1861
|
-
const patternNumber = () => {
|
|
1862
|
-
return /\d+/g;
|
|
1863
|
-
};
|
|
1864
|
-
const patternEncodeUri = () => {
|
|
1865
|
-
return /%([0-9A-F]{2})/g;
|
|
1866
|
-
};
|
|
1867
|
-
const patternName = () => {
|
|
1868
|
-
return /^\w+[A-Za-z\s\d]+$/;
|
|
1869
|
-
};
|
|
1870
|
-
const patternNameUtf8 = () => {
|
|
1871
|
-
return /^[ àáảãạăắằẵặẳâầấậẫẩđèéẻẽẹêềếểễệìíỉĩịòóỏõọôồốổỗộơờớởỡợùúủũụưừứửữựỳýỷỹÀÁẢÃẠĂẮẰẴẶẲÂẦẤẬẪẨĐÈÉẺẼẸÊỀẾỂỄỆÌÍỈĨỊÒÓỎÕỌÔỒỐỔỖỘƠỜỚỞỠỢÙÚỦŨỤƯỪỨỬỮỰỲÝỶỸA-Za-z0-9]+$/;
|
|
1872
|
-
};
|
|
1873
|
-
const patternNameSpecial = () => {
|
|
1874
|
-
return /[~!@#$%^&*()-+=<>,?\/\\:;"']/;
|
|
1875
|
-
};
|
|
1876
|
-
const patternNameProfile = () => {
|
|
1877
|
-
return /([\w\W\d\s]+)+/;
|
|
1878
|
-
};
|
|
1879
|
-
const patternEmoji = () => {
|
|
1880
|
-
return /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;
|
|
1881
|
-
};
|
|
1882
|
-
const patternRuleFieldReplace = () => {
|
|
1883
|
-
return /[{]{2}[a-zA-Z_-]+[}]{2}/g;
|
|
1884
|
-
};
|
|
1885
|
-
const patternGetFieldByRuleFieldReplace = () => {
|
|
1886
|
-
return /[a-zA-Z_-]+/g;
|
|
1887
|
-
};
|
|
1888
|
-
const patternPem = () => {
|
|
1889
|
-
return /^(0|1):([0-9]{1,2}):(\{\{path-api\}\}):([a-zA-Z0-9\/]+)$/g;
|
|
1890
|
-
};
|
|
1891
|
-
const patternTax = () => {
|
|
1892
|
-
return /^([0-9]){10}(-[0-9]{3})?$/;
|
|
1893
|
-
};
|
|
1894
|
-
const patternKey = () => {
|
|
1895
|
-
return /^([0-9]){10}(-[0-9]{3})?$/;
|
|
1896
|
-
};
|
|
1897
|
-
const patternAccount = () => {
|
|
1898
|
-
return /^(?=.*@)[a-z0-9@._-]{2,63}$/;
|
|
1899
|
-
};
|
|
1900
|
-
|
|
1901
1980
|
let functionXssFilter = async (value) => {
|
|
1902
1981
|
return value;
|
|
1903
1982
|
};
|
|
@@ -2368,94 +2447,40 @@ const convertUrlToFile = (url, fileName) => {
|
|
|
2368
2447
|
});
|
|
2369
2448
|
};
|
|
2370
2449
|
|
|
2371
|
-
const
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
if (
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2450
|
+
const getSmartAxisScale = (maxData, options) => {
|
|
2451
|
+
const stepCandidates = options?.stepCandidates || [1, 2, 5, 10, 20, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000];
|
|
2452
|
+
for (const step of stepCandidates) {
|
|
2453
|
+
let tickCount = Math.ceil(maxData / step) + 1;
|
|
2454
|
+
let maxY = step * tickCount;
|
|
2455
|
+
if (tickCount >= (options?.minTickCount || 5) && tickCount <= (options?.maxTickCount || 10)) {
|
|
2456
|
+
if (maxData < maxY) {
|
|
2457
|
+
tickCount = maxData - (tickCount - 1) * step < -1 * (step / 4) ? tickCount - 1 : tickCount;
|
|
2458
|
+
maxY = step * tickCount;
|
|
2459
|
+
return {
|
|
2460
|
+
step: step,
|
|
2461
|
+
maxY: maxY,
|
|
2462
|
+
ticks: tickCount
|
|
2463
|
+
};
|
|
2464
|
+
}
|
|
2385
2465
|
}
|
|
2386
|
-
keysReplace.forEach(key => {
|
|
2387
|
-
const regExp = new RegExp(key, 'gi');
|
|
2388
|
-
value = value?.replace(regExp, `<span class="${classHightLight}">$&</span>`);
|
|
2389
|
-
});
|
|
2390
|
-
}
|
|
2391
|
-
catch (error) {
|
|
2392
|
-
console.log(error);
|
|
2393
|
-
}
|
|
2394
|
-
finally {
|
|
2395
|
-
// eslint-disable-next-line no-unsafe-finally
|
|
2396
|
-
return value;
|
|
2397
|
-
}
|
|
2398
|
-
};
|
|
2399
|
-
const fullNameFormat = (value) => {
|
|
2400
|
-
if (!value) {
|
|
2401
|
-
return value;
|
|
2402
|
-
}
|
|
2403
|
-
return capitalize(value, { lowercaseOtherCharactor: true, trim: true, removeMutilSpace: true });
|
|
2404
|
-
};
|
|
2405
|
-
const capitalize = (text, options) => {
|
|
2406
|
-
if (!text) {
|
|
2407
|
-
return text;
|
|
2408
|
-
}
|
|
2409
|
-
text = formatByOptions(text, options);
|
|
2410
|
-
return text.split(' ').map(word => firstLetterToUpperCase(word)).join(' ');
|
|
2411
|
-
};
|
|
2412
|
-
const firstLetterToUpperCase = (text, options) => {
|
|
2413
|
-
if (!text) {
|
|
2414
|
-
return text;
|
|
2415
2466
|
}
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
if (
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
text = formatByOptions(text, options);
|
|
2423
|
-
return `${text.substring(0, position)}${text.charAt(position).toUpperCase()}${text.substring(position + 1)}`;
|
|
2424
|
-
};
|
|
2425
|
-
const formatByOptions = (text, options) => {
|
|
2426
|
-
if (!text || !options) {
|
|
2427
|
-
return text;
|
|
2428
|
-
}
|
|
2429
|
-
if (options?.uppercaseOtherCharactor) {
|
|
2430
|
-
text = text.toUpperCase();
|
|
2467
|
+
const tickCount = options?.maxTickCount || 10;
|
|
2468
|
+
let step = Math.ceil(maxData / tickCount);
|
|
2469
|
+
let maxY = step * tickCount;
|
|
2470
|
+
if (maxData === maxY) {
|
|
2471
|
+
step = step + Math.ceil(step / 10);
|
|
2472
|
+
maxY = step * tickCount;
|
|
2431
2473
|
}
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
}
|
|
2438
|
-
if (options?.removeMutilSpace) {
|
|
2439
|
-
text = text.replace(/\s+/g, ' ');
|
|
2440
|
-
}
|
|
2441
|
-
return text;
|
|
2442
|
-
};
|
|
2443
|
-
const getValueReplace = (search, value) => {
|
|
2444
|
-
const searchConvert = deleteUnicode(search).toLowerCase();
|
|
2445
|
-
const valueConvert = deleteUnicode(value).toLowerCase();
|
|
2446
|
-
const keys = new Set();
|
|
2447
|
-
let i = 0;
|
|
2448
|
-
while ((i = valueConvert.indexOf(searchConvert, i)) >= 0) {
|
|
2449
|
-
const endIndex = i + search.length;
|
|
2450
|
-
keys.add(value.substring(i, endIndex));
|
|
2451
|
-
i += +valueConvert.length;
|
|
2452
|
-
}
|
|
2453
|
-
return Array.from(keys);
|
|
2474
|
+
return {
|
|
2475
|
+
step: step,
|
|
2476
|
+
maxY: maxY,
|
|
2477
|
+
ticks: tickCount
|
|
2478
|
+
};
|
|
2454
2479
|
};
|
|
2455
2480
|
|
|
2456
2481
|
/**
|
|
2457
2482
|
* Generated bundle index. Do not edit.
|
|
2458
2483
|
*/
|
|
2459
2484
|
|
|
2460
|
-
export { AudioExtList, CHARACTER_DATA_EMPTY, COMMUNICATE_MICRO_KEY_GET_ALL_MESSAGE, COMMUNICATE_MICRO_PREFIX_TYPE, DEFAULT_START_PAGE_0, DocumentExtList, ENCODE_URI_PATTERN, ERROR_MESSAGE_EMPTY_VALID, ERROR_MESSAGE_MAX_LENGTH, ERROR_MESSAGE_MAX_VALID, ERROR_MESSAGE_MIN_LENGTH, ERROR_MESSAGE_MIN_VALID, ERROR_MESSAGE_PATTEN_VALID,
|
|
2485
|
+
export { AudioExtList, CHARACTER_DATA_EMPTY, COMMUNICATE_MICRO_KEY_GET_ALL_MESSAGE, COMMUNICATE_MICRO_PREFIX_TYPE, DEFAULT_START_PAGE_0, DocumentExtList, ENCODE_URI_PATTERN, ERROR_MESSAGE_EMPTY_VALID, ERROR_MESSAGE_MAX_LENGTH, ERROR_MESSAGE_MAX_VALID, ERROR_MESSAGE_MIN_LENGTH, ERROR_MESSAGE_MIN_VALID, ERROR_MESSAGE_PATTEN_VALID, ImageExtList, LINK_IMAGE_ERROR_TOKEN_INJECT, PROCESS_BAR_STANDARD_CONFIG_DEFAULT_TOKEN_INJECT, PROCESS_BAR_STEPS_CONFIG_DEFAULT_TOKEN_INJECT, UtilsCache, UtilsCommunicateMicro, UtilsCommunicateMicroKeyGlobal, UtilsHttpParamsRequest, UtilsHttpParamsRequestInstance, UtilsKeyCodeConstant, UtilsLanguageConstants, UtilsUrlSearchParams, VideoExtList, base64Decode, base64Encode, capitalize, checkMouseOverInContainer, checkViewInScreen, cloneDeep, cloneIBoundingClientRect, colorContrastFromOrigin, colorStepContrastFromOrigin, convertBase64ToBlob, convertBlobToFile, convertFileToBase64, convertFileToBase64_ObjectUrl, convertObjectToSignal, convertSignalToObject, convertUrlToFile, decodeEscapeHtml, decodeURI, decrypt, decrypt3rd, deleteUnicode, downloadFileByUrl, downloadFileByUrlUseXmlRequest, downloadImageFromELement, encodeURI, encrypt, encrypt3rd, endCodeUrl, escapeHtml, firstLetterToUpperCase, formatDate, formatNumber, formatTextCompare, fullNameFormat, generateInterface, get, getColorById, getDayjs, getDocumentByString, getDragEventByElement, getFileExtension, getHTMLFromQuill, getKeyCacheByArrayObject, getLabelBySizeFile, getPlatFromBrowser, getSmartAxisScale, getViewport, groupBy, highlightByKeyword, isDifferenceDay, isDifferenceMonth, isDifferenceYear, isEmbedFrame, isEmpty, isEqual, isIncludeAudioExtList, isIncludeDocumentExtList, isIncludeImageExtList, isIncludeVideoExtList, isNil, isTypeAudio, isTypeFile, isTypeImage, isTypeVideo, keyBy, listColorDefine, md5, omitBy, patternAccount, patternDomain, patternEmail, patternEmoji, patternEncodeUri, patternGetFieldByRuleFieldReplace, patternHostUrl, patternKey, patternMobilePhone, patternName, patternNameProfile, patternNameSpecial, patternNameUtf8, patternNumber, patternPem, patternPhone, patternPhoneNormal, patternRuleFieldReplace, patternTax, patternUrl, range, removeEmoji, rgbToHex, set, setCaretPosition, setDefaultTimeZone, setKeyCrypto, setKeyCrypto3rd, setStylesElement, uniqBy, updateFunctionCheckEmbedFrame, updateFunctionFormatDate, updateFunctionXssFilter, uppercaseByPosition, uuid, viewDataNumberByLanguage, xssFilter };
|
|
2461
2486
|
//# sourceMappingURL=libs-ui-utils.mjs.map
|