@libs-ui/utils 0.2.278 → 0.2.280
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/index.mjs +1 -5
- package/fesm2022/libs-ui-utils.mjs +189 -198
- package/fesm2022/libs-ui-utils.mjs.map +1 -1
- package/format-text.d.ts +5 -0
- package/index.d.ts +0 -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
|
@@ -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'));
|
|
@@ -920,11 +1105,11 @@ const pad = (number, length) => {
|
|
|
920
1105
|
}
|
|
921
1106
|
return str;
|
|
922
1107
|
};
|
|
923
|
-
const listColorDefine
|
|
1108
|
+
const listColorDefine = ['#E62222', '#B81B1B', '#EB4E4E', '#F97316', '#C75C12', '#FA8F45', '#FFB700', '#CC9200', '#FFC533', '#84CC16', '#6AA312', '#9dd645', '#00BC62', '#00A757', '#33DA8A', '#06B6D4', '#1B59C4', '#4E8CF7', '#0EA5E9',
|
|
924
1109
|
'#1B59C4', '#4E8CF7', '#226FF5', '#1B59C4', '#4E8CF7', '#6366F1', '#4F52C1', '#8285F4', '#5B04B3', '#49038F', '#7C36C2', '#D946EF', '#AE38BF', '#E16BF2', '#EC4899', '#BD3A7A', '#F06DAD', '#F43F5E', '#C3324B', '#F6657E', '#757380', '#5E5C66', '#918F99',
|
|
925
1110
|
'#202020', '#1A1A1A', '#4D4D4D'
|
|
926
1111
|
];
|
|
927
|
-
const
|
|
1112
|
+
const getColorById = (str) => {
|
|
928
1113
|
let hashString = 0;
|
|
929
1114
|
if (!str) {
|
|
930
1115
|
return '';
|
|
@@ -934,7 +1119,7 @@ const GetColorById = (str) => {
|
|
|
934
1119
|
hashString = ((hashString << 5) - hashString) + char;
|
|
935
1120
|
hashString = hashString & hashString;
|
|
936
1121
|
}
|
|
937
|
-
return listColorDefine
|
|
1122
|
+
return listColorDefine[Math.abs(hashString) % listColorDefine.length];
|
|
938
1123
|
};
|
|
939
1124
|
|
|
940
1125
|
let key = '12~@#loqwsxacva(3rdhaq12';
|
|
@@ -1789,115 +1974,6 @@ const viewDataNumberByLanguage = (value, acceptNegativeValue, parseFixed = 1, ig
|
|
|
1789
1974
|
}
|
|
1790
1975
|
};
|
|
1791
1976
|
|
|
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
1977
|
let functionXssFilter = async (value) => {
|
|
1902
1978
|
return value;
|
|
1903
1979
|
};
|
|
@@ -2368,94 +2444,9 @@ const convertUrlToFile = (url, fileName) => {
|
|
|
2368
2444
|
});
|
|
2369
2445
|
};
|
|
2370
2446
|
|
|
2371
|
-
const highlightByKeyword = (value, search, ignoreHighlight, classHightLight) => {
|
|
2372
|
-
if (!value) {
|
|
2373
|
-
return '—';
|
|
2374
|
-
}
|
|
2375
|
-
try {
|
|
2376
|
-
if (!search || ignoreHighlight) {
|
|
2377
|
-
return value;
|
|
2378
|
-
}
|
|
2379
|
-
const keysReplace = getValueReplace(search, value);
|
|
2380
|
-
if (!keysReplace || !keysReplace.length) {
|
|
2381
|
-
return value;
|
|
2382
|
-
}
|
|
2383
|
-
if (!classHightLight) {
|
|
2384
|
-
classHightLight = 'bg-[#19344a] text-white';
|
|
2385
|
-
}
|
|
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
|
-
}
|
|
2416
|
-
return uppercaseByPosition(text, 0, options);
|
|
2417
|
-
};
|
|
2418
|
-
const uppercaseByPosition = (text, position, options) => {
|
|
2419
|
-
if (!text) {
|
|
2420
|
-
return text;
|
|
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();
|
|
2431
|
-
}
|
|
2432
|
-
if (options?.lowercaseOtherCharactor) {
|
|
2433
|
-
text = text.toLowerCase();
|
|
2434
|
-
}
|
|
2435
|
-
if (options?.trim) {
|
|
2436
|
-
text = text.trim();
|
|
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);
|
|
2454
|
-
};
|
|
2455
|
-
|
|
2456
2447
|
/**
|
|
2457
2448
|
* Generated bundle index. Do not edit.
|
|
2458
2449
|
*/
|
|
2459
2450
|
|
|
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,
|
|
2451
|
+
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, 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
2452
|
//# sourceMappingURL=libs-ui-utils.mjs.map
|