@libs-ui/utils 0.2.306-4 → 0.2.307-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.
@@ -90,7 +90,7 @@ const highlightByKeyword = (value, search, ignoreHighlight, classHightLight) =>
90
90
  if (!classHightLight) {
91
91
  classHightLight = 'bg-[#19344a] text-white';
92
92
  }
93
- keysReplace.forEach(key => {
93
+ keysReplace.forEach((key) => {
94
94
  const regExp = new RegExp(key, 'gi');
95
95
  value = value?.replace(regExp, `<span class="${classHightLight}">$&</span>`);
96
96
  });
@@ -119,7 +119,7 @@ const formatTextCompare = (text, options) => {
119
119
  if (!text) {
120
120
  return text;
121
121
  }
122
- text = text.normalize("NFC");
122
+ text = text.normalize('NFC');
123
123
  return formatByOptions(text, options);
124
124
  };
125
125
  const fullNameFormat = (value) => {
@@ -133,7 +133,10 @@ const capitalize = (text, options) => {
133
133
  return text;
134
134
  }
135
135
  text = formatByOptions(text, options);
136
- return text.split(' ').map(word => firstLetterToUpperCase(word)).join(' ');
136
+ return text
137
+ .split(' ')
138
+ .map((word) => firstLetterToUpperCase(word))
139
+ .join(' ');
137
140
  };
138
141
  const firstLetterToUpperCase = (text, options) => {
139
142
  if (!text) {
@@ -159,7 +162,7 @@ const formatByOptions = (text, options) => {
159
162
  text = text.toLowerCase();
160
163
  }
161
164
  if (options?.removeMultipleSpace) {
162
- text = text.replace(/\u200B|\u00A0/g, "");
165
+ text = text.replace(/\u200B|\u00A0/g, '');
163
166
  text = text.replace(/\s+/g, ' ');
164
167
  }
165
168
  if (options?.removeEmoji) {
@@ -177,12 +180,7 @@ const escapeHtml = (str) => {
177
180
  if (!str || typeof str !== 'string') {
178
181
  return str;
179
182
  }
180
- return str
181
- .replace(/&/g, "&amp;")
182
- .replace(/</g, "&lt;")
183
- .replace(/>/g, "&gt;")
184
- .replace(/"/g, "&quot;")
185
- .replace(/'/g, "&#039;");
183
+ return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;');
186
184
  };
187
185
  const decodeEscapeHtml = (str) => {
188
186
  const htmlTag = document.createElement('textarea');
@@ -213,9 +211,9 @@ const deleteUnicode = (str) => {
213
211
  str = str.replace(/Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ/g, 'U');
214
212
  str = str.replace(/Ỳ|Ý|Ỵ|Ỷ|Ỹ/g, 'Y');
215
213
  str = str.replace(/Đ/g, 'D');
216
- str = str.replace(/\u0300|\u0301|\u0303|\u0309|\u0323/g, ""); // ̀ ́ ̃ ̉ ̣ huyền, sắc, ngã, hỏi, nặng
217
- str = str.replace(/\u02C6|\u0306|\u031B/g, ""); // ˆ ̆ ̛ Â, Ê, Ă, Ơ, Ư
218
- return str.normalize("NFC");
214
+ str = str.replace(/\u0300|\u0301|\u0303|\u0309|\u0323/g, ''); // ̀ ́ ̃ ̉ ̣ huyền, sắc, ngã, hỏi, nặng
215
+ str = str.replace(/\u02C6|\u0306|\u031B/g, ''); // ˆ ̆ ̛ Â, Ê, Ă, Ơ, Ư
216
+ return str.normalize('NFC');
219
217
  };
220
218
  const removeEmoji = (text) => {
221
219
  if (!text || !text.trim()) {
@@ -290,10 +288,7 @@ const checkViewInScreen = (container, element, elementScroll, maxTopLeft) => {
290
288
  const limitLeft = leftContainer + scrollLeftContainer + widthContainer;
291
289
  const maxTopItem = top + (maxTopLeft?.top || 0);
292
290
  const maxLeftItem = left + (maxTopLeft?.left || 0);
293
- if (topContainer <= maxTopItem &&
294
- maxTopItem <= limitTop &&
295
- leftContainer <= maxLeftItem &&
296
- maxLeftItem <= limitLeft) {
291
+ if (topContainer <= maxTopItem && maxTopItem <= limitTop && leftContainer <= maxLeftItem && maxLeftItem <= limitLeft) {
297
292
  return true;
298
293
  }
299
294
  return false;
@@ -307,10 +302,7 @@ const checkMouseOverInContainer = (mousePosition, element, rect) => {
307
302
  const limitLeft = left + width;
308
303
  const limitTop = top + height;
309
304
  const { clientX, clientY } = mousePosition;
310
- if (left <= clientX &&
311
- clientX <= limitLeft &&
312
- top <= clientY &&
313
- clientY <= limitTop) {
305
+ if (left <= clientX && clientX <= limitLeft && top <= clientY && clientY <= limitTop) {
314
306
  return true;
315
307
  }
316
308
  return false;
@@ -348,13 +340,11 @@ const getDragEventByElement = (config) => {
348
340
  e.stopPropagation();
349
341
  config.functionMouseMove?.(e);
350
342
  }), takeUntil(mouseup));
351
- return mouseDown.pipe(mergeMap((e) => config.isStartWithMouseDownEvent
352
- ? mousemove.pipe(startWith(e))
353
- : mousemove), takeUntil(config.onDestroy), finalize(removeClass));
343
+ return mouseDown.pipe(mergeMap((e) => (config.isStartWithMouseDownEvent ? mousemove.pipe(startWith(e)) : mousemove)), takeUntil(config.onDestroy), finalize(removeClass));
354
344
  };
355
345
  const getHTMLFromQuill = async (data, options) => {
356
346
  const { replaceNewLineTo = '<br>', replaceTagBRTo, replaceTags, replaceBrToDiv } = options || {};
357
- const delta = (typeof data === 'string') ? await getDeltaFromHTML(data) : data;
347
+ const delta = typeof data === 'string' ? await getDeltaFromHTML(data) : data;
358
348
  if (options?.functionReplaceDelta) {
359
349
  options.functionReplaceDelta(delta);
360
350
  }
@@ -498,17 +488,19 @@ class UtilsUrlSearchParams {
498
488
  return this.instance;
499
489
  }
500
490
  static toStringParamObject(params) {
501
- const paramsArr = Object.keys(params).map(key => {
491
+ const paramsArr = Object.keys(params).map((key) => {
502
492
  return {
503
493
  key,
504
- value: params[key]
494
+ value: params[key],
505
495
  };
506
496
  });
507
497
  return UtilsUrlSearchParams.ToString(paramsArr);
508
498
  }
509
499
  static ToString(params) {
510
500
  let paramsStr = '';
511
- params.sort((item1, item2) => item1.key.localeCompare(item2.key)).forEach((item) => {
501
+ params
502
+ .sort((item1, item2) => item1.key.localeCompare(item2.key))
503
+ .forEach((item) => {
512
504
  const { key, value } = item;
513
505
  paramsStr = `${paramsStr}${paramsStr ? '&' : ''}${key}=${value}`;
514
506
  });
@@ -525,14 +517,14 @@ class UtilsUrlSearchParams {
525
517
  }
526
518
  const params = paramString.replace(/\S+[?]/g, '').split('&');
527
519
  if (params) {
528
- params.forEach(param => {
520
+ params.forEach((param) => {
529
521
  if (param.indexOf('=') < 0) {
530
522
  return;
531
523
  }
532
524
  let [key, value] = param.split('=');
533
525
  key = key.replace(/[?&]+/g, '');
534
526
  value = decodeURIComponent(value.replace(/\+/g, ' '));
535
- if (!paramsBuild.some(param => param.key === key)) {
527
+ if (!paramsBuild.some((param) => param.key === key)) {
536
528
  paramsBuild.push({ key, value });
537
529
  }
538
530
  });
@@ -540,7 +532,7 @@ class UtilsUrlSearchParams {
540
532
  return paramsBuild;
541
533
  }
542
534
  set(key, value) {
543
- const paramByKey = this.params.find(param => param.key === key);
535
+ const paramByKey = this.params.find((param) => param.key === key);
544
536
  if (!paramByKey) {
545
537
  this.params.push({ key, value: decodeURIComponent(value.replace(/\+/g, ' ')) });
546
538
  return;
@@ -548,13 +540,13 @@ class UtilsUrlSearchParams {
548
540
  paramByKey['value'] = value;
549
541
  }
550
542
  get(key) {
551
- return this.params.find(param => param.key === key)?.value;
543
+ return this.params.find((param) => param.key === key)?.value;
552
544
  }
553
545
  has(key) {
554
- return this.params.some(param => param.key === key);
546
+ return this.params.some((param) => param.key === key);
555
547
  }
556
548
  delete(key) {
557
- const index = this.params.findIndex(param => param.key === key);
549
+ const index = this.params.findIndex((param) => param.key === key);
558
550
  if (index >= 0) {
559
551
  this.params.splice(index, 1);
560
552
  }
@@ -568,7 +560,7 @@ class UtilsUrlSearchParams {
568
560
  }
569
561
  getParamObject() {
570
562
  const params = {};
571
- this.params.forEach(item => {
563
+ this.params.forEach((item) => {
572
564
  params[item.key] = item.value;
573
565
  });
574
566
  return params;
@@ -596,7 +588,7 @@ const keyStore$1 = () => {
596
588
  };
597
589
  const encrypt = (plainData) => {
598
590
  if (!keyStore$1()) {
599
- throw Error("lỗi chưa setup key mã hóa");
591
+ throw Error('lỗi chưa setup key mã hóa');
600
592
  }
601
593
  const key = CryptoES.enc.Hex.parse(keyStore$1());
602
594
  const iv = CryptoES.enc.Hex.parse(keyStore$1());
@@ -607,7 +599,7 @@ const encrypt = (plainData) => {
607
599
  };
608
600
  const decrypt = (encryptedData) => {
609
601
  if (!keyStore$1()) {
610
- throw Error("lỗi chưa setup key mã hóa");
602
+ throw Error('lỗi chưa setup key mã hóa');
611
603
  }
612
604
  const key = CryptoES.enc.Hex.parse(keyStore$1());
613
605
  const iv = CryptoES.enc.Hex.parse(keyStore$1());
@@ -637,6 +629,85 @@ const uuid = () => {
637
629
  return md5(shuffledString);
638
630
  };
639
631
 
632
+ /* eslint-disable @typescript-eslint/no-explicit-any */
633
+ const UtilsHttpParamsRequestInstance = (options, instance) => {
634
+ return new UtilsHttpParamsRequest(options, instance);
635
+ };
636
+ class UtilsHttpParamsRequest extends HttpParams {
637
+ params = new HttpParams();
638
+ constructor(options, instance) {
639
+ super(options);
640
+ if (!instance) {
641
+ this.params = new HttpParams(options);
642
+ return;
643
+ }
644
+ if (instance instanceof UtilsHttpParamsRequest) {
645
+ this.params = instance.getInstance();
646
+ return;
647
+ }
648
+ if (instance instanceof HttpParams) {
649
+ this.params = instance;
650
+ return;
651
+ }
652
+ }
653
+ getInstance() {
654
+ return this.params;
655
+ }
656
+ setInstance(instance) {
657
+ if (instance instanceof UtilsHttpParamsRequest) {
658
+ this.params = instance.getInstance();
659
+ return;
660
+ }
661
+ if (instance instanceof HttpParams) {
662
+ this.params = instance;
663
+ return;
664
+ }
665
+ }
666
+ set(param, value) {
667
+ this.params = this.params.set(param, value);
668
+ return this;
669
+ }
670
+ has(param) {
671
+ return this.params.has(param);
672
+ }
673
+ get(param) {
674
+ return this.params.get(param);
675
+ }
676
+ getAll(param) {
677
+ return this.params.getAll(param);
678
+ }
679
+ keys() {
680
+ return this.params.keys();
681
+ }
682
+ append(param, value) {
683
+ this.params = this.params.append(param, value);
684
+ return this;
685
+ }
686
+ appendAll(params) {
687
+ this.params = this.params.appendAll(params);
688
+ return this;
689
+ }
690
+ delete(param, value) {
691
+ this.params = this.params.delete(param, value);
692
+ return this;
693
+ }
694
+ toString() {
695
+ return this.params.toString();
696
+ }
697
+ }
698
+ // Demo su dung GET_PATH_VARIABLE
699
+ // interface Person {
700
+ // name: string;
701
+ // age: number;
702
+ // location: string;
703
+ // }
704
+ // type c = GET_PATH_VARIABLE<Person, unknown>;
705
+ // const a: c = {
706
+ // "pathVariable-age": 1,
707
+ // "pathVariable-location": '12',
708
+ // "pathVariable-name": '124',
709
+ // };
710
+
640
711
  let key = '12~@#loqwsxacva(3rdhaq12';
641
712
  /**
642
713
  * @description Thiết lập key mã hóa
@@ -653,7 +724,7 @@ const keyStore = () => {
653
724
  };
654
725
  const encrypt3rd = (plainData) => {
655
726
  if (!keyStore()) {
656
- throw Error("lỗi chưa setup key mã hóa");
727
+ throw Error('lỗi chưa setup key mã hóa');
657
728
  }
658
729
  const key = CryptoES.enc.Hex.parse(keyStore());
659
730
  const iv = CryptoES.enc.Hex.parse(keyStore());
@@ -664,7 +735,7 @@ const encrypt3rd = (plainData) => {
664
735
  };
665
736
  const decrypt3rd = (encryptedData) => {
666
737
  if (!keyStore()) {
667
- throw Error("lỗi chưa setup key mã hóa");
738
+ throw Error('lỗi chưa setup key mã hóa');
668
739
  }
669
740
  const key = CryptoES.enc.Hex.parse(keyStore());
670
741
  const iv = CryptoES.enc.Hex.parse(keyStore());
@@ -711,7 +782,9 @@ class UtilsCommunicateMicro {
711
782
  if (!this.subs.get(COMMUNICATE_MICRO_KEY_GET_ALL_MESSAGE)) {
712
783
  this.subs.set(COMMUNICATE_MICRO_KEY_GET_ALL_MESSAGE, UtilsCommunicateMicro.allMessageSub);
713
784
  }
714
- fromEvent(currentWindow, 'message').pipe(takeUntil(onDestroy)).subscribe(e => {
785
+ fromEvent(currentWindow, 'message')
786
+ .pipe(takeUntil(onDestroy))
787
+ .subscribe((e) => {
715
788
  const event = { data: { ...e.data } };
716
789
  const data = event.data;
717
790
  const type = data.type;
@@ -739,7 +812,9 @@ class UtilsCommunicateMicro {
739
812
  this.allMessageSub.next(event);
740
813
  }
741
814
  });
742
- UtilsCommunicateMicro.GetMessage(UtilsCache.typeKeyClearLocalStorage).pipe(filter(e => e.data.response !== UtilsCache.idService), takeUntil(onDestroy)).subscribe(() => {
815
+ UtilsCommunicateMicro.GetMessage(UtilsCache.typeKeyClearLocalStorage)
816
+ .pipe(filter((e) => e.data.response !== UtilsCache.idService), takeUntil(onDestroy))
817
+ .subscribe(() => {
743
818
  console.log('clear all cache by event');
744
819
  UtilsCache.ClearAll();
745
820
  });
@@ -748,10 +823,10 @@ class UtilsCommunicateMicro {
748
823
  data = this.convertData(data);
749
824
  try {
750
825
  if (isEmbedFrame()) {
751
- window?.parent?.postMessage(data, "*");
826
+ window?.parent?.postMessage(data, '*');
752
827
  return;
753
828
  }
754
- window?.top?.postMessage(data, "*");
829
+ window?.top?.postMessage(data, '*');
755
830
  }
756
831
  catch (error) {
757
832
  console.log(error);
@@ -759,8 +834,8 @@ class UtilsCommunicateMicro {
759
834
  }
760
835
  static PostMessageToChildren(data) {
761
836
  data = this.convertData(data);
762
- const iframes = document.querySelectorAll("iframe");
763
- Array.from(iframes).forEach(iframe => {
837
+ const iframes = document.querySelectorAll('iframe');
838
+ Array.from(iframes).forEach((iframe) => {
764
839
  iframe?.contentWindow?.postMessage(data, '*');
765
840
  });
766
841
  }
@@ -798,7 +873,7 @@ class UtilsCommunicateMicro {
798
873
  }
799
874
  static GetMessage(messageType) {
800
875
  if (!this.initdEvent) {
801
- throw Error("chưa khơi tạo hàm lắng nghe sự kiện, gọi UtilsCommunicateMicro.initEvent(window) tại root component");
876
+ throw Error('chưa khơi tạo hàm lắng nghe sự kiện, gọi UtilsCommunicateMicro.initEvent(window) tại root component');
802
877
  }
803
878
  if (typeof messageType === 'string') {
804
879
  let sub = this.subs.get(messageType);
@@ -826,8 +901,8 @@ class UtilsCommunicateMicro {
826
901
  return sub;
827
902
  }
828
903
  static initSubject(subRoot, messageType) {
829
- messageType.forEach(key => {
830
- this.GetMessage(key).subscribe(e => {
904
+ messageType.forEach((key) => {
905
+ this.GetMessage(key).subscribe((e) => {
831
906
  subRoot.next(e);
832
907
  });
833
908
  });
@@ -835,33 +910,33 @@ class UtilsCommunicateMicro {
835
910
  }
836
911
 
837
912
  class UtilsLanguageConstants {
838
- static VI = "vi"; // Tiếng Việt
839
- static EN = "en"; // Tiếng Anh
840
- static FR = "fr"; // Tiếng Pháp
841
- static DE = "de"; // Tiếng Đức
842
- static ES = "es"; // Tiếng Tây Ban Nha
843
- static ZH = "zh"; // Tiếng Trung (Giản thể)
844
- static ZH_TW = "zh-TW"; // Tiếng Trung (Phồn thể)
845
- static JA = "ja"; // Tiếng Nhật
846
- static KO = "ko"; // Tiếng Hàn
847
- static RU = "ru"; // Tiếng Nga
848
- static IT = "it"; // Tiếng Ý
849
- static PT = "pt"; // Tiếng Bồ Đào Nha
850
- static TH = "th"; // Tiếng Thái
851
- static ID = "id"; // Tiếng Indonesia
852
- static MS = "ms"; // Tiếng Malaysia
853
- static AR = "ar"; // Tiếng Ả Rập
854
- static HI = "hi"; // Tiếng Hindi
855
- static BN = "bn"; // Tiếng Bengal
856
- static TR = "tr"; // Tiếng Thổ Nhĩ Kỳ
857
- static NL = "nl"; // Tiếng Hà Lan
858
- static KM = "km"; // Tiếng Khmer (Campuchia)
859
- static LO = "lo"; // Tiếng Lào
860
- static MY = "my"; // Tiếng Miến Điện (Myanmar)
861
- static TL = "tl"; // Tiếng Tagalog (Philippines)
862
- static CEB = "ceb"; // Tiếng Cebuano (Philippines)
863
- static JV = "jv"; // Tiếng Java (Indonesia)
864
- static SU = "su"; // Tiếng Sundanese (Indonesia)
913
+ static VI = 'vi'; // Tiếng Việt
914
+ static EN = 'en'; // Tiếng Anh
915
+ static FR = 'fr'; // Tiếng Pháp
916
+ static DE = 'de'; // Tiếng Đức
917
+ static ES = 'es'; // Tiếng Tây Ban Nha
918
+ static ZH = 'zh'; // Tiếng Trung (Giản thể)
919
+ static ZH_TW = 'zh-TW'; // Tiếng Trung (Phồn thể)
920
+ static JA = 'ja'; // Tiếng Nhật
921
+ static KO = 'ko'; // Tiếng Hàn
922
+ static RU = 'ru'; // Tiếng Nga
923
+ static IT = 'it'; // Tiếng Ý
924
+ static PT = 'pt'; // Tiếng Bồ Đào Nha
925
+ static TH = 'th'; // Tiếng Thái
926
+ static ID = 'id'; // Tiếng Indonesia
927
+ static MS = 'ms'; // Tiếng Malaysia
928
+ static AR = 'ar'; // Tiếng Ả Rập
929
+ static HI = 'hi'; // Tiếng Hindi
930
+ static BN = 'bn'; // Tiếng Bengal
931
+ static TR = 'tr'; // Tiếng Thổ Nhĩ Kỳ
932
+ static NL = 'nl'; // Tiếng Hà Lan
933
+ static KM = 'km'; // Tiếng Khmer (Campuchia)
934
+ static LO = 'lo'; // Tiếng Lào
935
+ static MY = 'my'; // Tiếng Miến Điện (Myanmar)
936
+ static TL = 'tl'; // Tiếng Tagalog (Philippines)
937
+ static CEB = 'ceb'; // Tiếng Cebuano (Philippines)
938
+ static JV = 'jv'; // Tiếng Java (Indonesia)
939
+ static SU = 'su'; // Tiếng Sundanese (Indonesia)
865
940
  // Ngôn ngữ mặc định
866
941
  static defaultLang = UtilsLanguageConstants.VI;
867
942
  // Danh sách các ngôn ngữ được hỗ trợ
@@ -947,7 +1022,7 @@ class UtilsCache {
947
1022
  return this.Get(this.languageKeyCache, UtilsLanguageConstants.defaultLang);
948
1023
  }
949
1024
  static openDB() {
950
- return new Promise(resolve => {
1025
+ return new Promise((resolve) => {
951
1026
  const request = indexedDB.open(this.dbName, this.dbVersion);
952
1027
  request.onupgradeneeded = (event) => {
953
1028
  const db = event.target.result;
@@ -1019,7 +1094,7 @@ class UtilsCache {
1019
1094
  clear: () => {
1020
1095
  this.storage = {};
1021
1096
  localStorage.clear();
1022
- }
1097
+ },
1023
1098
  };
1024
1099
  }
1025
1100
  static getLocalStorageFake() {
@@ -1038,7 +1113,7 @@ class UtilsCache {
1038
1113
  },
1039
1114
  clear: () => {
1040
1115
  this.storage = {};
1041
- }
1116
+ },
1042
1117
  };
1043
1118
  }
1044
1119
  static async GetAsync(key, default_value, isKeyMD5 = false) {
@@ -1057,7 +1132,7 @@ class UtilsCache {
1057
1132
  if (data.expire === this.CACHE_EXPIRE_NONE) {
1058
1133
  return resolve(data.json);
1059
1134
  }
1060
- const currentMillisecond = (new Date().valueOf() / 1000);
1135
+ const currentMillisecond = new Date().valueOf() / 1000;
1061
1136
  if (data.expire < currentMillisecond) {
1062
1137
  return resolve(default_value);
1063
1138
  }
@@ -1070,6 +1145,7 @@ class UtilsCache {
1070
1145
  });
1071
1146
  }
1072
1147
  static Get(key, default_value) {
1148
+ // support cho những file không thể inject UtilsCache
1073
1149
  if (!key) {
1074
1150
  return this.GetDefaultValueBySpecificKey(key, default_value);
1075
1151
  }
@@ -1082,7 +1158,7 @@ class UtilsCache {
1082
1158
  if (data.expire === this.CACHE_EXPIRE_NONE) {
1083
1159
  return data.value ?? default_value;
1084
1160
  }
1085
- const currentMillisecond = (new Date().valueOf() / 1000);
1161
+ const currentMillisecond = new Date().valueOf() / 1000;
1086
1162
  if (data.expire < currentMillisecond) {
1087
1163
  return this.GetDefaultValueBySpecificKey(key, default_value);
1088
1164
  }
@@ -1097,11 +1173,12 @@ class UtilsCache {
1097
1173
  return default_value;
1098
1174
  }
1099
1175
  static async SetAsync(key, value, expireTimeBySecond = this.CACHE_EXPIRE_TIME_DEFAULT, isKeyMD5 = false) {
1176
+ // support inject UtilsCache
1100
1177
  return new Promise(async (resolve) => {
1101
1178
  const objectStore = await this.getObjectStore();
1102
1179
  key = isKeyMD5 ? key : md5(key);
1103
1180
  try {
1104
- const currentMillisecond = expireTimeBySecond === this.CACHE_EXPIRE_NONE ? this.CACHE_EXPIRE_NONE : (new Date().valueOf() / 1000) + expireTimeBySecond;
1181
+ const currentMillisecond = expireTimeBySecond === this.CACHE_EXPIRE_NONE ? this.CACHE_EXPIRE_NONE : new Date().valueOf() / 1000 + expireTimeBySecond;
1105
1182
  const data = {
1106
1183
  value: encrypt(JSON.stringify({ json: value, expire: currentMillisecond })),
1107
1184
  };
@@ -1127,10 +1204,11 @@ class UtilsCache {
1127
1204
  });
1128
1205
  }
1129
1206
  static Set(key, value, expireTimeBySecond = this.CACHE_EXPIRE_TIME_DEFAULT) {
1130
- const currentMillisecond = expireTimeBySecond === this.CACHE_EXPIRE_NONE ? this.CACHE_EXPIRE_NONE : (new Date().valueOf() / 1000) + expireTimeBySecond;
1207
+ // support cho những file không inject UtilsCache
1208
+ const currentMillisecond = expireTimeBySecond === this.CACHE_EXPIRE_NONE ? this.CACHE_EXPIRE_NONE : new Date().valueOf() / 1000 + expireTimeBySecond;
1131
1209
  const data = {
1132
1210
  value: value,
1133
- expire: currentMillisecond
1211
+ expire: currentMillisecond,
1134
1212
  };
1135
1213
  try {
1136
1214
  this.LocalStorage.setItem(key, encrypt(JSON.stringify(data)));
@@ -1185,13 +1263,13 @@ class UtilsCache {
1185
1263
  const data = {
1186
1264
  type: this.typeKeyClearLocalStorage,
1187
1265
  response: {
1188
- idEvent: this.idService
1189
- }
1266
+ idEvent: this.idService,
1267
+ },
1190
1268
  };
1191
1269
  UtilsCommunicateMicro.PostMessageToParent(data);
1192
1270
  }
1193
1271
  const keys = [...this.listKeyKeepWhenClearALll];
1194
- Object.keys(this.LocalStorage).forEach(key => {
1272
+ Object.keys(this.LocalStorage).forEach((key) => {
1195
1273
  if (key.includes('kc-callback-')) {
1196
1274
  keys.push(key);
1197
1275
  }
@@ -1237,7 +1315,7 @@ class UtilsCache {
1237
1315
  if (!Array.isArray(data)) {
1238
1316
  return resolve({});
1239
1317
  }
1240
- data.forEach(obj => {
1318
+ data.forEach((obj) => {
1241
1319
  if (obj[this.itemIndexByKey].startsWith(keyCacheStartWith)) {
1242
1320
  this.ClearAsync(obj[this.itemIndexByKey], true);
1243
1321
  }
@@ -1255,7 +1333,7 @@ class UtilsCache {
1255
1333
  if (!keys || !keys.length) {
1256
1334
  return;
1257
1335
  }
1258
- keys.forEach(key => {
1336
+ keys.forEach((key) => {
1259
1337
  if (key.startsWith(keyCache)) {
1260
1338
  this.Clear(key);
1261
1339
  }
@@ -1270,9 +1348,8 @@ class UtilsCache {
1270
1348
  resolve({ deleteSuccess: true });
1271
1349
  };
1272
1350
  request.onerror = (event) => {
1273
- const error = event.target.error;
1274
- console.trace('Error deleting database:', error);
1275
- resolve({ messageError: get(error || {}, 'message'), deleteSuccess: false });
1351
+ console.trace('Error deleting database:', event.target.error);
1352
+ resolve({ messageError: get(event.target.error, 'message'), deleteSuccess: false });
1276
1353
  };
1277
1354
  request.onblocked = () => {
1278
1355
  console.trace('Delete request is blocked');
@@ -1287,7 +1364,7 @@ dayjs.extend(updateLocale);
1287
1364
  dayjs.extend(utc);
1288
1365
  dayjs.extend(timezone);
1289
1366
  dayjs.extend(customParseFormat);
1290
- let timeZoneSetup = "Asia/Ho_Chi_Minh";
1367
+ let timeZoneSetup = 'Asia/Ho_Chi_Minh';
1291
1368
  const setDefaultTimeZone = (localeZone = timeZoneSetup) => {
1292
1369
  timeZoneSetup = localeZone;
1293
1370
  dayjs.tz.setDefault(localeZone);
@@ -1297,13 +1374,13 @@ const updateFunctionFormatDate = (functionCustom) => {
1297
1374
  functionFormatDate = functionCustom;
1298
1375
  };
1299
1376
  /**
1300
- * @description Lấy đối tượng dayjs theo config
1301
- * @param config nếu không có config sẽ trả về đối tượng dayjs là thời gian hiện tại
1302
- * @param config.date thời gian cần lấy
1303
- * @param config.returnDayjsIfConfigDateNotExist true nếu muốn trả về đối tượng dayjs nếu config.date không có
1304
- * @param config.utc true nếu muốn lấy thời gian UTC
1305
- * @param config.formatOfDate định dạng thời gian đang được truyền vào
1306
- */
1377
+ * @description Lấy đối tượng dayjs theo config
1378
+ * @param config nếu không có config sẽ trả về đối tượng dayjs là thời gian hiện tại
1379
+ * @param config.date thời gian cần lấy
1380
+ * @param config.returnDayjsIfConfigDateNotExist true nếu muốn trả về đối tượng dayjs nếu config.date không có
1381
+ * @param config.utc true nếu muốn lấy thời gian UTC
1382
+ * @param config.formatOfDate định dạng thời gian đang được truyền vào
1383
+ */
1307
1384
  const getDayjs = (config) => {
1308
1385
  if (!config) {
1309
1386
  return dayjs().tz();
@@ -1396,7 +1473,7 @@ const formatDate = (date, formatOutput = 'YYYY/MM/DD HH:mm', lang, formatInput)
1396
1473
  date = getDayjs({ date, formatOfDate: formatInput }).locale(lang);
1397
1474
  if (lang === 'vi') {
1398
1475
  dayjs.updateLocale('vi', {
1399
- monthsShort: 'Thg 1_Thg 2_Thg 3_Thg 4_Thg 5_Thg 6_Thg 7_Thg 8_Thg 9_Thg 10_Thg 11_Thg 12'.split('_')
1476
+ monthsShort: 'Thg 1_Thg 2_Thg 3_Thg 4_Thg 5_Thg 6_Thg 7_Thg 8_Thg 9_Thg 10_Thg 11_Thg 12'.split('_'),
1400
1477
  });
1401
1478
  }
1402
1479
  return date.format(getFormatData(getTypeByFormat(formatOutput), lang)) || '';
@@ -1461,85 +1538,6 @@ const getFormatData = (type, lang) => {
1461
1538
  }
1462
1539
  };
1463
1540
 
1464
- /* eslint-disable @typescript-eslint/no-explicit-any */
1465
- const UtilsHttpParamsRequestInstance = (options, instance) => {
1466
- return new UtilsHttpParamsRequest(options, instance);
1467
- };
1468
- class UtilsHttpParamsRequest extends HttpParams {
1469
- params = new HttpParams();
1470
- constructor(options, instance) {
1471
- super(options);
1472
- if (!instance) {
1473
- this.params = new HttpParams(options);
1474
- return;
1475
- }
1476
- if (instance instanceof UtilsHttpParamsRequest) {
1477
- this.params = instance.getInstance();
1478
- return;
1479
- }
1480
- if (instance instanceof HttpParams) {
1481
- this.params = instance;
1482
- return;
1483
- }
1484
- }
1485
- getInstance() {
1486
- return this.params;
1487
- }
1488
- setInstance(instance) {
1489
- if (instance instanceof UtilsHttpParamsRequest) {
1490
- this.params = instance.getInstance();
1491
- return;
1492
- }
1493
- if (instance instanceof HttpParams) {
1494
- this.params = instance;
1495
- return;
1496
- }
1497
- }
1498
- set(param, value) {
1499
- this.params = this.params.set(param, value);
1500
- return this;
1501
- }
1502
- has(param) {
1503
- return this.params.has(param);
1504
- }
1505
- get(param) {
1506
- return this.params.get(param);
1507
- }
1508
- getAll(param) {
1509
- return this.params.getAll(param);
1510
- }
1511
- keys() {
1512
- return this.params.keys();
1513
- }
1514
- append(param, value) {
1515
- this.params = this.params.append(param, value);
1516
- return this;
1517
- }
1518
- appendAll(params) {
1519
- this.params = this.params.appendAll(params);
1520
- return this;
1521
- }
1522
- delete(param, value) {
1523
- this.params = this.params.delete(param, value);
1524
- return this;
1525
- }
1526
- toString() {
1527
- return this.params.toString();
1528
- }
1529
- }
1530
- // Demo su dung GET_PATH_VARIABLE
1531
- // interface Person {
1532
- // name: string;
1533
- // age: number;
1534
- // location: string;
1535
- // }
1536
- // type c = GET_PATH_VARIABLE<Person, unknown>;
1537
- // const a: c = {
1538
- // "pathVariable-age": 1,
1539
- // "pathVariable-location": '12',
1540
- // "pathVariable-name": '124',
1541
- // };
1542
-
1543
1541
  /* eslint-disable @typescript-eslint/no-explicit-any */
1544
1542
  /**Các hàm tương tự thư viện lodash */
1545
1543
  /**
@@ -1659,7 +1657,7 @@ const omitBy = (objData, predicate) => {
1659
1657
  * get(null, 'any.path'); // undefined
1660
1658
  * get(undefined, 'any.path', 'fallback'); // 'fallback'
1661
1659
  */
1662
- const get = (obj, path, defaultValue, keepLastValueIfSignal) => {
1660
+ const get = (obj, path, defaultValue = undefined, keepLastValueIfSignal) => {
1663
1661
  if (isNil(obj)) {
1664
1662
  return defaultValue;
1665
1663
  }
@@ -2101,11 +2099,10 @@ const generateInterface = (obj, interfaceName) => {
2101
2099
  return interfaceStr;
2102
2100
  };
2103
2101
 
2104
- ;
2105
2102
  const step = 20;
2106
2103
  const percent = 0.05;
2107
2104
  const colorStepContrastFromOrigin = (color, stepNumber) => {
2108
- return colorContrastFromOrigin(color).find(item => item.step === stepNumber);
2105
+ return colorContrastFromOrigin(color).find((item) => item.step === stepNumber);
2109
2106
  };
2110
2107
  const colorContrastFromOrigin = (color) => {
2111
2108
  const parsedColorsArray = parseColorValues(color);
@@ -2140,10 +2137,10 @@ const parseColorValues = (colorValues) => {
2140
2137
  return colorValuesArray;
2141
2138
  };
2142
2139
  const calculateShades = (colorValue) => {
2143
- return calculate(colorValue, rgbShade).concat("000000");
2140
+ return calculate(colorValue, rgbShade).concat('000000');
2144
2141
  };
2145
2142
  const calculateTints = (colorValue) => {
2146
- return calculate(colorValue, rgbTint).concat("ffffff");
2143
+ return calculate(colorValue, rgbTint).concat('ffffff');
2147
2144
  };
2148
2145
  const calculate = (colorValue, shadeOrTint) => {
2149
2146
  const color = hexToRGB(colorValue);
@@ -2153,11 +2150,21 @@ const calculate = (colorValue, shadeOrTint) => {
2153
2150
  }
2154
2151
  return shadeValues;
2155
2152
  };
2156
- const rgbShade = (rgb, i) => { return { red: rgb.red * (1 - percent * i), green: rgb.green * (1 - percent * i), blue: rgb.blue * (1 - percent * i) }; };
2157
- const rgbTint = (rgb, i) => { return { red: rgb.red + (255 - rgb.red) * i * percent, green: rgb.green + (255 - rgb.green) * i * percent, blue: rgb.blue + (255 - rgb.blue) * i * percent }; };
2158
- const rgbToHex = (rgb) => { return intToHex(rgb.red) + intToHex(rgb.green) + intToHex(rgb.blue); };
2159
- const hexToRGB = (colorValue) => { return { red: parseInt(colorValue.substr(0, 2), 16), green: parseInt(colorValue.substr(2, 2), 16), blue: parseInt(colorValue.substr(4, 2), 16) }; };
2160
- const intToHex = (rgbint) => { return pad(Math.min(Math.max(Math.round(rgbint), 0), 255).toString(16), 2); };
2153
+ const rgbShade = (rgb, i) => {
2154
+ return { red: rgb.red * (1 - percent * i), green: rgb.green * (1 - percent * i), blue: rgb.blue * (1 - percent * i) };
2155
+ };
2156
+ const rgbTint = (rgb, i) => {
2157
+ return { red: rgb.red + (255 - rgb.red) * i * percent, green: rgb.green + (255 - rgb.green) * i * percent, blue: rgb.blue + (255 - rgb.blue) * i * percent };
2158
+ };
2159
+ const rgbToHex = (rgb) => {
2160
+ return intToHex(rgb.red) + intToHex(rgb.green) + intToHex(rgb.blue);
2161
+ };
2162
+ const hexToRGB = (colorValue) => {
2163
+ return { red: parseInt(colorValue.substr(0, 2), 16), green: parseInt(colorValue.substr(2, 2), 16), blue: parseInt(colorValue.substr(4, 2), 16) };
2164
+ };
2165
+ const intToHex = (rgbint) => {
2166
+ return pad(Math.min(Math.max(Math.round(rgbint), 0), 255).toString(16), 2);
2167
+ };
2161
2168
  const pad = (number, length) => {
2162
2169
  let str = '' + number;
2163
2170
  while (str.length < length) {
@@ -2165,9 +2172,52 @@ const pad = (number, length) => {
2165
2172
  }
2166
2173
  return str;
2167
2174
  };
2168
- const listColorDefine = ['#E62222', '#B81B1B', '#EB4E4E', '#F97316', '#C75C12', '#FA8F45', '#FFB700', '#CC9200', '#FFC533', '#84CC16', '#6AA312', '#9dd645', '#00BC62', '#00A757', '#33DA8A', '#06B6D4', '#1B59C4', '#4E8CF7', '#0EA5E9',
2169
- '#1B59C4', '#4E8CF7', '#226FF5', '#1B59C4', '#4E8CF7', '#6366F1', '#4F52C1', '#8285F4', '#5B04B3', '#49038F', '#7C36C2', '#D946EF', '#AE38BF', '#E16BF2', '#EC4899', '#BD3A7A', '#F06DAD', '#F43F5E', '#C3324B', '#F6657E', '#757380', '#5E5C66', '#918F99',
2170
- '#202020', '#1A1A1A', '#4D4D4D'
2175
+ const listColorDefine = [
2176
+ '#E62222',
2177
+ '#B81B1B',
2178
+ '#EB4E4E',
2179
+ '#F97316',
2180
+ '#C75C12',
2181
+ '#FA8F45',
2182
+ '#FFB700',
2183
+ '#CC9200',
2184
+ '#FFC533',
2185
+ '#84CC16',
2186
+ '#6AA312',
2187
+ '#9dd645',
2188
+ '#00BC62',
2189
+ '#00A757',
2190
+ '#33DA8A',
2191
+ '#06B6D4',
2192
+ '#1B59C4',
2193
+ '#4E8CF7',
2194
+ '#0EA5E9',
2195
+ '#1B59C4',
2196
+ '#4E8CF7',
2197
+ '#226FF5',
2198
+ '#1B59C4',
2199
+ '#4E8CF7',
2200
+ '#6366F1',
2201
+ '#4F52C1',
2202
+ '#8285F4',
2203
+ '#5B04B3',
2204
+ '#49038F',
2205
+ '#7C36C2',
2206
+ '#D946EF',
2207
+ '#AE38BF',
2208
+ '#E16BF2',
2209
+ '#EC4899',
2210
+ '#BD3A7A',
2211
+ '#F06DAD',
2212
+ '#F43F5E',
2213
+ '#C3324B',
2214
+ '#F6657E',
2215
+ '#757380',
2216
+ '#5E5C66',
2217
+ '#918F99',
2218
+ '#202020',
2219
+ '#1A1A1A',
2220
+ '#4D4D4D',
2171
2221
  ];
2172
2222
  const getColorById = (str) => {
2173
2223
  let hashString = 0;
@@ -2176,7 +2226,7 @@ const getColorById = (str) => {
2176
2226
  }
2177
2227
  for (let i = 0; i < str.length; i++) {
2178
2228
  const char = str.charCodeAt(i);
2179
- hashString = ((hashString << 5) - hashString) + char;
2229
+ hashString = (hashString << 5) - hashString + char;
2180
2230
  hashString = hashString & hashString;
2181
2231
  }
2182
2232
  return listColorDefine[Math.abs(hashString) % listColorDefine.length];
@@ -2316,8 +2366,8 @@ const getKeyCacheByArrayObject = (keyCache, argumentsValue) => {
2316
2366
  keyBuild = `${keyBuild}${JSON.stringify(item)}`;
2317
2367
  return;
2318
2368
  }
2319
- const keys = (item instanceof HttpParams ? item.keys() : Object.keys(item)).sort(((str1, str2) => str1.localeCompare(str2)));
2320
- keys.forEach(key => {
2369
+ const keys = (item instanceof HttpParams ? item.keys() : Object.keys(item)).sort((str1, str2) => str1.localeCompare(str2));
2370
+ keys.forEach((key) => {
2321
2371
  if (key.toLocaleLowerCase() === 'pem') {
2322
2372
  return;
2323
2373
  }
@@ -2361,7 +2411,7 @@ const viewDataNumberByLanguage = (value, acceptNegativeValue, parseFixed = 1, ig
2361
2411
  return Math.round(value * fixed) / fixed;
2362
2412
  };
2363
2413
  if (parseFixed > (floatStr?.length || 0)) {
2364
- const maxParseFixed = (acceptNegativeValue && +value < 0) ? 17 : 16;
2414
+ const maxParseFixed = acceptNegativeValue && +value < 0 ? 17 : 16;
2365
2415
  const fixed = maxParseFixed - (intStr?.length || 0);
2366
2416
  parseFixed = parseFixed < fixed ? parseFixed : fixed;
2367
2417
  }
@@ -2388,7 +2438,10 @@ const viewDataNumberByLanguage = (value, acceptNegativeValue, parseFixed = 1, ig
2388
2438
  if (lang === UtilsLanguageConstants.EN) {
2389
2439
  return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
2390
2440
  }
2391
- return value.toString().replace('.', ',').replace(/\B(?=(\d{3})+(?!\d))/g, '.');
2441
+ return value
2442
+ .toString()
2443
+ .replace('.', ',')
2444
+ .replace(/\B(?=(\d{3})+(?!\d))/g, '.');
2392
2445
  }
2393
2446
  };
2394
2447
 
@@ -2430,12 +2483,12 @@ const convertObjectToSignal = (data, cloneDeepIfNotSignal = true, isSignalPrimit
2430
2483
  return seen.get(data);
2431
2484
  }
2432
2485
  if (Array.isArray(data)) {
2433
- seen.set(data, signal(data.map(item => convertObjectToSignal(item, cloneDeepIfNotSignal, isSignalPrimitiveType, acceptConvertObjectInnerWritableSignal, seen))));
2486
+ seen.set(data, signal(data.map((item) => convertObjectToSignal(item, cloneDeepIfNotSignal, isSignalPrimitiveType, acceptConvertObjectInnerWritableSignal, seen))));
2434
2487
  return seen.get(data);
2435
2488
  }
2436
2489
  if (data instanceof Map) {
2437
2490
  const mapCopy = new Map();
2438
- Array.from(data.keys()).forEach(key => {
2491
+ Array.from(data.keys()).forEach((key) => {
2439
2492
  mapCopy.set(key, convertObjectToSignal(data.get(key), cloneDeepIfNotSignal, isSignalPrimitiveType, acceptConvertObjectInnerWritableSignal));
2440
2493
  });
2441
2494
  seen.set(data, signal(mapCopy));
@@ -2448,7 +2501,19 @@ const convertObjectToSignal = (data, cloneDeepIfNotSignal = true, isSignalPrimit
2448
2501
  seen.set(data, data);
2449
2502
  for (const key in data()) {
2450
2503
  const value = data()[key];
2451
- if (value instanceof TemplateRef || value instanceof File || value instanceof Blob || Object.prototype.toString.call(value) === '[object File]' || value instanceof ElementRef || value instanceof Element || value instanceof Date || value instanceof RegExp || value instanceof Set || value instanceof Map || value instanceof Promise || value instanceof Observable || value instanceof HttpParams) {
2504
+ if (value instanceof TemplateRef ||
2505
+ value instanceof File ||
2506
+ value instanceof Blob ||
2507
+ Object.prototype.toString.call(value) === '[object File]' ||
2508
+ value instanceof ElementRef ||
2509
+ value instanceof Element ||
2510
+ value instanceof Date ||
2511
+ value instanceof RegExp ||
2512
+ value instanceof Set ||
2513
+ value instanceof Map ||
2514
+ value instanceof Promise ||
2515
+ value instanceof Observable ||
2516
+ value instanceof HttpParams) {
2452
2517
  continue;
2453
2518
  }
2454
2519
  if (Object.prototype.hasOwnProperty.call(data(), key)) {
@@ -2483,12 +2548,12 @@ const convertSignalToObject = (data, isCloneDeep = true, seen = new WeakMap()) =
2483
2548
  if (!isSignal(data[0])) {
2484
2549
  return data;
2485
2550
  }
2486
- seen.set(data, data.map(item => convertSignalToObject((isCloneDeep ? cloneDeep(item) : item), isCloneDeep, seen)));
2551
+ seen.set(data, data.map((item) => convertSignalToObject(isCloneDeep ? cloneDeep(item) : item, isCloneDeep, seen)));
2487
2552
  return seen.get(data);
2488
2553
  }
2489
2554
  if (data instanceof Map) {
2490
2555
  const mapCopy = new Map();
2491
- Array.from(data.keys()).forEach(key => {
2556
+ Array.from(data.keys()).forEach((key) => {
2492
2557
  mapCopy.set(key, convertSignalToObject(isCloneDeep ? cloneDeep(data.get(key)) : data.get(key), isCloneDeep));
2493
2558
  });
2494
2559
  seen.set(data, mapCopy);
@@ -2513,9 +2578,12 @@ const convertSignalToObject = (data, isCloneDeep = true, seen = new WeakMap()) =
2513
2578
 
2514
2579
  const ENCODE_URI_PATTERN = /%([0-9A-F]{2})/g;
2515
2580
  const decodeURI = (value) => {
2516
- return decodeURIComponent(value.split('').map((c) => {
2581
+ return decodeURIComponent(value
2582
+ .split('')
2583
+ .map((c) => {
2517
2584
  return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
2518
- }).join(''));
2585
+ })
2586
+ .join(''));
2519
2587
  };
2520
2588
  const encodeURI = (value) => {
2521
2589
  return encodeURIComponent(value).replace(ENCODE_URI_PATTERN, (match, p1) => {
@@ -2523,7 +2591,7 @@ const encodeURI = (value) => {
2523
2591
  });
2524
2592
  };
2525
2593
  const endCodeUrl = (params, isBody) => {
2526
- params = omitBy(params, param => param === '' || isNil(param));
2594
+ params = omitBy(params, (param) => param === '' || isNil(param));
2527
2595
  let res = '';
2528
2596
  for (const p in params) {
2529
2597
  res += `&${p}=${encodeURIComponent(params[p])}`;
@@ -2601,7 +2669,7 @@ const downloadFileByUrl = async (fileUrl, filename, onlyOpen) => {
2601
2669
  const downloadImageFromELement = (imageElement, typeFileDownload, nameFile) => {
2602
2670
  const parentElement = imageElement?.src;
2603
2671
  const blobData = convertBase64ToBlob(parentElement);
2604
- const blob = new Blob([blobData], { type: typeFileDownload || "image/png" });
2672
+ const blob = new Blob([blobData], { type: typeFileDownload || 'image/png' });
2605
2673
  const url = window.URL.createObjectURL(blob);
2606
2674
  const link = document.createElement('a');
2607
2675
  link.href = url;
@@ -2613,12 +2681,22 @@ const LINK_IMAGE_ERROR_TOKEN_INJECT = new InjectionToken('LINK_IMAGE_ERROR_TOKEN
2613
2681
  const PROCESS_BAR_STANDARD_CONFIG_DEFAULT_TOKEN_INJECT = new InjectionToken('PROCESS_BAR_STANDARD_CONFIG_DEFAULT_TOKEN_INJECT');
2614
2682
  const PROCESS_BAR_STEPS_CONFIG_DEFAULT_TOKEN_INJECT = new InjectionToken('PROCESS_BAR_STEPS_CONFIG_DEFAULT_TOKEN_INJECT');
2615
2683
 
2616
- const isTypeImage = (file) => file.type.match(/image.*/) ? true : false;
2617
- const isTypeVideo = (file) => file.type.match(/video.*/) ? true : false;
2618
- const isTypeAudio = (file) => file.type.match(/audio.*/) ? true : false;
2619
- const isTypeFile = (file) => file instanceof File || Object.prototype.toString.call(file) === '[object File]' ? true : false;
2684
+ const isTypeImage = (file) => (file.type.match(/image.*/) ? true : false);
2685
+ const isTypeVideo = (file) => (file.type.match(/video.*/) ? true : false);
2686
+ const isTypeAudio = (file) => (file.type.match(/audio.*/) ? true : false);
2687
+ const isTypeFile = (file) => (file instanceof File || Object.prototype.toString.call(file) === '[object File]' ? true : false);
2620
2688
  const ExcelExtList = ['xls', 'xlsx', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
2621
- const DocumentExtList = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf', 'json', 'xml', 'application/msword',
2689
+ const DocumentExtList = [
2690
+ 'doc',
2691
+ 'docx',
2692
+ 'xls',
2693
+ 'xlsx',
2694
+ 'ppt',
2695
+ 'pptx',
2696
+ 'pdf',
2697
+ 'json',
2698
+ 'xml',
2699
+ 'application/msword',
2622
2700
  'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
2623
2701
  'application/vnd.ms-excel',
2624
2702
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
@@ -2626,7 +2704,8 @@ const DocumentExtList = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf', 'js
2626
2704
  'application/vnd.openxmlformats-officedocument.presentationml.presentation',
2627
2705
  'application/pdf',
2628
2706
  'application/json',
2629
- 'application/xml'];
2707
+ 'application/xml',
2708
+ ];
2630
2709
  const isIncludeDocumentExtList = (ext, listExt = DocumentExtList) => listExt.includes(ext) || listExt.includes(`application/${ext}`);
2631
2710
  const ImageExtList = ['gif', 'jpg', 'jpeg', 'png', 'image/gif', 'image/jpeg', 'image/jpeg', 'image/png'];
2632
2711
  const isIncludeImageExtList = (ext, listExt = ImageExtList) => listExt.includes(ext);
@@ -2651,7 +2730,7 @@ const getFileExtension = (file) => {
2651
2730
  fileName = url.split('/').pop() || '';
2652
2731
  set(file, 'name', fileName);
2653
2732
  }
2654
- const dots = fileName.split(".");
2733
+ const dots = fileName.split('.');
2655
2734
  if (!dots) {
2656
2735
  return;
2657
2736
  }
@@ -2677,7 +2756,6 @@ const convertUrlToFile = (url, fileName) => {
2677
2756
  const file = convertBase64ToBlob(reader.result);
2678
2757
  resolve(convertBlobToFile(file, fileName || Date.now().toLocaleString()));
2679
2758
  };
2680
- reader.onerror = () => resolve(undefined);
2681
2759
  reader.readAsDataURL(xhr.response);
2682
2760
  };
2683
2761
  xhr.onerror = (err) => {
@@ -2755,12 +2833,12 @@ const getSmartAxisScale = (originalMaxData, options) => {
2755
2833
  }
2756
2834
  const maxValuePositive = maxValue - Math.abs(minValue);
2757
2835
  tickCount = maxValuePositive - originalMaxData > Math.abs(step) && tickCount - 1 >= minTickCount ? tickCount - 1 : tickCount;
2758
- maxValue = (step * tickCount * scaleDirection) - (minValue * scaleDirection);
2836
+ maxValue = step * tickCount * scaleDirection - minValue * scaleDirection;
2759
2837
  return {
2760
2838
  stepSize: Math.abs(step),
2761
2839
  max: maxValue,
2762
2840
  min: minValue,
2763
- tickAmount: tickCount
2841
+ tickAmount: tickCount,
2764
2842
  };
2765
2843
  }
2766
2844
  }
@@ -2775,7 +2853,7 @@ const getSmartAxisScale = (originalMaxData, options) => {
2775
2853
  stepSize: Math.abs(step),
2776
2854
  max: maxValue,
2777
2855
  min: 0,
2778
- tickAmount: minTickCount
2856
+ tickAmount: minTickCount,
2779
2857
  };
2780
2858
  };
2781
2859
  // Cache cho các giá trị lũy thừa 10 để tối ưu hiệu suất
@@ -2831,7 +2909,7 @@ const getStepCandidates = (maxData, minStep, minNegative, acceptStepIsTypeFloat
2831
2909
  const checkAndSetNegativeSteps = (stepCandidates, acceptNegative, minNegative) => {
2832
2910
  if (acceptNegative && minNegative < 0) {
2833
2911
  // Tạo các step âm và thêm vào đầu danh sách
2834
- const negativeSteps = [...stepCandidates].map(step => -step);
2912
+ const negativeSteps = [...stepCandidates].map((step) => -step);
2835
2913
  stepCandidates.unshift(...negativeSteps);
2836
2914
  }
2837
2915
  };
@@ -2844,20 +2922,20 @@ const checkAndSetNegativeSteps = (stepCandidates, acceptNegative, minNegative) =
2844
2922
  const validateInputs = (maxData, options) => {
2845
2923
  // Kiểm tra maxData âm khi không chấp nhận giá trị âm
2846
2924
  if (maxData < 0 && !options?.acceptNegative) {
2847
- throw new Error("maxData is less than 0 and acceptNegative is false");
2925
+ throw new Error('maxData is less than 0 and acceptNegative is false');
2848
2926
  }
2849
2927
  if (options?.acceptNegative) {
2850
2928
  // Kiểm tra minNegative có được cung cấp không
2851
2929
  if (isNil(options.minNegative)) {
2852
- throw new Error("minNegative is required when acceptNegative is true");
2930
+ throw new Error('minNegative is required when acceptNegative is true');
2853
2931
  }
2854
2932
  // Kiểm tra maxData phải >= minNegative
2855
2933
  if (maxData < options.minNegative) {
2856
- throw new Error("maxData is less than minNegative");
2934
+ throw new Error('maxData is less than minNegative');
2857
2935
  }
2858
2936
  // Kiểm tra minNegative phải là số âm
2859
2937
  if (options.minNegative >= 0) {
2860
- throw new Error("minNegative must be negative");
2938
+ throw new Error('minNegative must be negative');
2861
2939
  }
2862
2940
  }
2863
2941
  };
@@ -2877,7 +2955,7 @@ const revealString = (encoded) => {
2877
2955
  const decoded = base
2878
2956
  .split('')
2879
2957
  .reverse()
2880
- .map(c => String.fromCharCode(c.charCodeAt(0) ^ xorKey))
2958
+ .map((c) => String.fromCharCode(c.charCodeAt(0) ^ xorKey))
2881
2959
  .join('');
2882
2960
  return decoded;
2883
2961
  };