@libs-ui/services-config-project 0.2.5

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.
@@ -0,0 +1,913 @@
1
+ import * as i0 from '@angular/core';
2
+ import { signal, computed, effect, Injectable, inject, importProvidersFrom } from '@angular/core';
3
+ import { colorStepContrastFromOrigin, get, UtilsCache } from '@libs-ui/utils';
4
+ import { HttpClient, provideHttpClient } from '@angular/common/http';
5
+ import { TranslateService, TranslateLoader, TranslateCompiler, TranslateStore, TranslateParser, MissingTranslationHandler, TranslateModule } from '@ngx-translate/core';
6
+ import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler';
7
+ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
8
+ import { take } from 'rxjs';
9
+
10
+ const fontConfig = {
11
+ name: 'SVN-Poppins',
12
+ uri_regular: 'SVN-Poppins-Regular.ttf',
13
+ uri_medium: 'SVN-Poppins-Medium.ttf',
14
+ uri_semibold: 'SVN-Poppins-SemiBold.ttf',
15
+ uri_bold: 'SVN-Poppins-Bold.ttf'
16
+ };
17
+ const weights = {
18
+ uri_regular: '400',
19
+ uri_medium: '500',
20
+ uri_semibold: '600',
21
+ uri_bold: '700'
22
+ };
23
+ const configHeading = {
24
+ h1r: {
25
+ "font-size": '30px',
26
+ "font-weight": '400',
27
+ "line-height": '38px',
28
+ "letter-spacing": 'calc(30px * (0.5 / 100))'
29
+ },
30
+ h1m: {
31
+ "font-size": '30px',
32
+ "font-weight": '500',
33
+ "line-height": '38px',
34
+ "letter-spacing": 'calc(30px * (0.5 / 100))'
35
+ },
36
+ h1s: {
37
+ "font-size": '30px',
38
+ "font-weight": '600',
39
+ "line-height": '38px',
40
+ "letter-spacing": 'calc(30px * (0.5 / 100))'
41
+ },
42
+ h1b: {
43
+ "font-size": '30px',
44
+ "font-weight": '700',
45
+ "line-height": '38px',
46
+ "letter-spacing": 'calc(30px * (0.5 / 100))'
47
+ },
48
+ h2r: {
49
+ "font-size": '20px',
50
+ "font-weight": '400',
51
+ "line-height": '26px',
52
+ "letter-spacing": 'calc(20px * (0.5 / 100))'
53
+ },
54
+ h2m: {
55
+ "font-size": '20px',
56
+ "font-weight": '500',
57
+ "line-height": '26px',
58
+ "letter-spacing": 'calc(20px * (0.5 / 100))'
59
+ },
60
+ h2s: {
61
+ "font-size": '20px',
62
+ "font-weight": '600',
63
+ "line-height": '26px',
64
+ "letter-spacing": 'calc(20px * (0.5 / 100))'
65
+ },
66
+ h2b: {
67
+ "font-size": '20px',
68
+ "font-weight": '400',
69
+ "line-height": '76px',
70
+ "letter-spacing": 'calc(20px * (0.5 / 100))'
71
+ },
72
+ h3r: {
73
+ "font-size": '16px',
74
+ "font-weight": '400',
75
+ "line-height": '20px',
76
+ "letter-spacing": 'calc(16px * (0.5 / 100))'
77
+ },
78
+ h3m: {
79
+ "font-size": '16px',
80
+ "font-weight": '500',
81
+ "line-height": '20px',
82
+ "letter-spacing": 'calc(16px * (0.5 / 100))'
83
+ },
84
+ h3s: {
85
+ "font-size": '16px',
86
+ "font-weight": '600',
87
+ "line-height": '20px',
88
+ "letter-spacing": 'calc(16px * (0.5 / 100))'
89
+ },
90
+ h3b: {
91
+ "font-size": '16px',
92
+ "font-weight": '700',
93
+ "line-height": '20px',
94
+ "letter-spacing": 'calc(16px * (0.5 / 100))'
95
+ },
96
+ h4r: {
97
+ "font-size": '13px',
98
+ "font-weight": '400',
99
+ "line-height": '16px',
100
+ "letter-spacing": 'calc(13px * (0.5 / 100))'
101
+ },
102
+ h4m: {
103
+ "font-size": '13px',
104
+ "font-weight": '500',
105
+ "line-height": '16px',
106
+ "letter-spacing": 'calc(13px * (0.5 / 100))'
107
+ },
108
+ h4s: {
109
+ "font-size": '13px',
110
+ "font-weight": '600',
111
+ "line-height": '16px',
112
+ "letter-spacing": 'calc(13px * (0.5 / 100))'
113
+ },
114
+ h4b: {
115
+ "font-size": '13px',
116
+ "font-weight": '700',
117
+ "line-height": '16px',
118
+ "letter-spacing": 'calc(13px * (0.5 / 100))'
119
+ },
120
+ h5r: {
121
+ "font-size": '12px',
122
+ "font-weight": '400',
123
+ "line-height": '16px',
124
+ "letter-spacing": 'calc(12px * (0.5 / 100))'
125
+ },
126
+ h5m: {
127
+ "font-size": '12px',
128
+ "font-weight": '500',
129
+ "line-height": '16px',
130
+ "letter-spacing": 'calc(12px * (0.5 / 100))'
131
+ },
132
+ h5s: {
133
+ "font-size": '12px',
134
+ "font-weight": '600',
135
+ "line-height": '16px',
136
+ "letter-spacing": 'calc(12px * (0.5 / 100))'
137
+ },
138
+ h5b: {
139
+ "font-size": '12px',
140
+ "font-weight": '700',
141
+ "line-height": '16px',
142
+ "letter-spacing": 'calc(12px * (0.5 / 100))'
143
+ },
144
+ h6r: {
145
+ "font-size": '11px',
146
+ "font-weight": '400',
147
+ "line-height": '16px',
148
+ "letter-spacing": 'calc(11px * (0.5 / 100))'
149
+ },
150
+ h6m: {
151
+ "font-size": '11px',
152
+ "font-weight": '500',
153
+ "line-height": '16px',
154
+ "letter-spacing": 'calc(11px * (0.5 / 100))'
155
+ },
156
+ h6s: {
157
+ "font-size": '11px',
158
+ "font-weight": '700',
159
+ "line-height": '16px',
160
+ "letter-spacing": 'calc(11px * (0.5 / 100))'
161
+ },
162
+ h6b: {
163
+ "font-size": '11px',
164
+ "font-weight": '700',
165
+ "line-height": '16px',
166
+ "letter-spacing": 'calc(11px * (0.5 / 100))'
167
+ },
168
+ h7r: {
169
+ "font-size": '10px',
170
+ "font-weight": '400',
171
+ "line-height": '16px',
172
+ "letter-spacing": 'calc(11px * (0.5 / 100))'
173
+ },
174
+ h7m: {
175
+ "font-size": '10px',
176
+ "font-weight": '500',
177
+ "line-height": '16px',
178
+ "letter-spacing": 'calc(11px * (0.5 / 100))'
179
+ },
180
+ h7s: {
181
+ "font-size": '10px',
182
+ "font-weight": '600',
183
+ "line-height": '16px',
184
+ "letter-spacing": 'calc(11px * (0.5 / 100))'
185
+ },
186
+ h7b: {
187
+ "font-size": '10px',
188
+ "font-weight": '700',
189
+ "line-height": '16px',
190
+ "letter-spacing": 'calc(11px * (0.5 / 100))'
191
+ },
192
+ };
193
+ const configButtonColor = (rootColorInTheme) => {
194
+ return {
195
+ "button-primary": {
196
+ configStepColor: {
197
+ text: "white",
198
+ text_hover: "white",
199
+ text_active: "white",
200
+ text_disable: "#CDD0D6",
201
+ background: 0,
202
+ background_hover: 20,
203
+ background_active: -20,
204
+ background_disable: "#F8F9FA",
205
+ border: 0,
206
+ border_hover: 20,
207
+ border_active: -20,
208
+ border_disable: "#F8F9FA"
209
+ },
210
+ rootColor: rootColorInTheme
211
+ },
212
+ "button-primary-revert": {
213
+ configStepColor: {
214
+ text: 0,
215
+ text_hover: "white",
216
+ text_active: "white",
217
+ text_disable: "#CDD0D6",
218
+ background: "white",
219
+ background_hover: 20,
220
+ background_active: -20,
221
+ background_disable: "#F8F9FA",
222
+ border: 0,
223
+ border_hover: 20,
224
+ border_active: -20,
225
+ border_disable: "#F8F9FA"
226
+ },
227
+ rootColor: rootColorInTheme
228
+ },
229
+ "button-secondary": {
230
+ configStepColor: {
231
+ text: 0,
232
+ text_hover: 20,
233
+ text_active: -20,
234
+ text_disable: "#CDD0D6",
235
+ background: 90,
236
+ background_hover: 90,
237
+ background_active: 90,
238
+ background_disable: "#F8F9FA",
239
+ border: 90,
240
+ border_hover: 90,
241
+ border_active: 90,
242
+ border_disable: "#F8F9FA"
243
+ },
244
+ rootColor: rootColorInTheme
245
+ },
246
+ "button-third": {
247
+ configStepColor: {
248
+ text: "#6A7383",
249
+ text_hover: 20,
250
+ text_active: -20,
251
+ text_disable: "#CDD0D6",
252
+ background: "#F8F9FA",
253
+ background_hover: 90,
254
+ background_active: 90,
255
+ background_disable: "#F8F9FA",
256
+ border: "#F8F9FA",
257
+ border_hover: 90,
258
+ border_active: 90,
259
+ border_disable: "#F8F9FA"
260
+ },
261
+ rootColor: rootColorInTheme
262
+ },
263
+ "button-secondary-red": {
264
+ configStepColor: {
265
+ text: 0,
266
+ text_hover: -20,
267
+ text_active: -20,
268
+ text_disable: "#CDD0D6",
269
+ background: 90,
270
+ background_hover: 90,
271
+ background_active: 90,
272
+ background_disable: "#F8F9FA",
273
+ border: 90,
274
+ border_hover: 90,
275
+ border_active: 90,
276
+ border_disable: "#F8F9FA"
277
+ },
278
+ rootColor: '#EE2D41'
279
+ },
280
+ "button-outline": {
281
+ configStepColor: {
282
+ text: "#6A7383",
283
+ text_hover: 20,
284
+ text_active: -20,
285
+ text_disable: "#CDD0D6",
286
+ background: "white",
287
+ background_hover: "white",
288
+ background_active: "white",
289
+ background_disable: "#F8F9FA",
290
+ border: "#e6e7ea",
291
+ border_hover: 20,
292
+ border_active: -20,
293
+ border_disable: "#E6E7EA"
294
+ },
295
+ rootColor: rootColorInTheme
296
+ },
297
+ "button-danger-high": {
298
+ configStepColor: {
299
+ text: "white",
300
+ text_hover: "white",
301
+ text_active: "white",
302
+ text_disable: "#CDD0D6",
303
+ background: 0,
304
+ background_hover: 20,
305
+ background_active: -20,
306
+ background_disable: "#F8F9FA",
307
+ border: 0,
308
+ border_hover: 20,
309
+ border_active: -20,
310
+ border_disable: "#F8F9FA"
311
+ },
312
+ rootColor: "#ee2d41"
313
+ },
314
+ "button-danger-low": {
315
+ configStepColor: {
316
+ text: "white",
317
+ text_hover: "white",
318
+ text_active: "white",
319
+ text_disable: "#CDD0D6",
320
+ background: 0,
321
+ background_hover: 20,
322
+ background_active: -20,
323
+ background_disable: "#F8F9FA",
324
+ border: 0,
325
+ border_hover: 20,
326
+ border_active: -20,
327
+ border_disable: "#F8F9FA"
328
+ },
329
+ rootColor: "#ffa621"
330
+ },
331
+ "button-green": {
332
+ configStepColor: {
333
+ text: "white",
334
+ text_hover: "white",
335
+ text_active: "white",
336
+ text_disable: "#CDD0D6",
337
+ background: 0,
338
+ background_hover: 20,
339
+ background_active: -20,
340
+ background_disable: "#F8F9FA",
341
+ border: 0,
342
+ border_hover: 20,
343
+ border_active: -20,
344
+ border_disable: "#F8F9FA"
345
+ },
346
+ rootColor: "#00d16d"
347
+ },
348
+ "button-violet": {
349
+ configStepColor: {
350
+ text: "white",
351
+ text_hover: "white",
352
+ text_active: "white",
353
+ text_disable: "#CDD0D6",
354
+ background: 0,
355
+ background_hover: 20,
356
+ background_active: -20,
357
+ background_disable: "#F8F9FA",
358
+ border: 0,
359
+ border_hover: 20,
360
+ border_active: -20,
361
+ border_disable: "#F8F9FA"
362
+ },
363
+ rootColor: "#7239ea"
364
+ },
365
+ "button-outline-green": {
366
+ configStepColor: {
367
+ text: "#6A7383",
368
+ text_hover: 20,
369
+ text_active: -20,
370
+ text_disable: "#CDD0D6",
371
+ background: "white",
372
+ background_hover: "white",
373
+ background_active: "white",
374
+ background_disable: "#F8F9FA",
375
+ border: "#e6e7ea",
376
+ border_hover: 20,
377
+ border_active: -20,
378
+ border_disable: "#E6E7EA"
379
+ },
380
+ rootColor: "#00d16d"
381
+ },
382
+ "button-secondary-green": {
383
+ configStepColor: {
384
+ text: 0,
385
+ text_hover: "white",
386
+ text_active: "white",
387
+ text_disable: "#CDD0D6",
388
+ background: 90,
389
+ background_hover: 0,
390
+ background_active: 0,
391
+ background_disable: "#F8F9FA",
392
+ border: 0,
393
+ border_hover: 0,
394
+ border_active: 0,
395
+ border_disable: "#F8F9FA"
396
+ },
397
+ rootColor: "#00d16d"
398
+ },
399
+ "button-outline-secondary": {
400
+ configStepColor: {
401
+ text: 0,
402
+ text_hover: "white",
403
+ text_active: "white",
404
+ text_disable: "#CDD0D6",
405
+ background: 90,
406
+ background_hover: 0,
407
+ background_active: 0,
408
+ background_disable: "#F8F9FA",
409
+ border: 0,
410
+ border_hover: 0,
411
+ border_active: 0,
412
+ border_disable: "#E6E7EA"
413
+ },
414
+ rootColor: rootColorInTheme
415
+ },
416
+ "button-outline-hover-danger": {
417
+ configStepColor: {
418
+ text: "#6A7383",
419
+ text_hover: 0,
420
+ text_active: -20,
421
+ text_disable: "#CDD0D6",
422
+ background: "white",
423
+ background_hover: "white",
424
+ background_active: "white",
425
+ background_disable: "#F8F9FA",
426
+ border: "#e6e7ea",
427
+ border_hover: 0,
428
+ border_active: -20,
429
+ border_disable: "#e6e7ea"
430
+ },
431
+ rootColor: "#f15767"
432
+ }
433
+ };
434
+ };
435
+ const configLinkButton = (rootColorInTheme) => {
436
+ return {
437
+ "button-link-primary": {
438
+ configStepColor: {
439
+ text: 0,
440
+ text_hover: 20,
441
+ text_active: -20,
442
+ text_disable: "#CDD0D6"
443
+ },
444
+ rootColor: rootColorInTheme
445
+ },
446
+ "button-link-third": {
447
+ configStepColor: {
448
+ text: "#6A7383",
449
+ text_hover: 20,
450
+ text_active: -20,
451
+ text_disable: "#CDD0D6",
452
+ },
453
+ rootColor: rootColorInTheme
454
+ },
455
+ "button-link-danger-high": {
456
+ configStepColor: {
457
+ text: 0,
458
+ text_hover: 20,
459
+ text_active: -20,
460
+ text_disable: "#CDD0D6",
461
+ },
462
+ rootColor: "#ee2d41"
463
+ },
464
+ "button-link-danger-low": {
465
+ configStepColor: {
466
+ text: 0,
467
+ text_hover: 20,
468
+ text_active: -20,
469
+ text_disable: "#CDD0D6",
470
+ },
471
+ rootColor: "#ffa621"
472
+ },
473
+ "button-link-green": {
474
+ configStepColor: {
475
+ text: 0,
476
+ text_hover: 20,
477
+ text_active: -20,
478
+ text_disable: "#CDD0D6",
479
+ },
480
+ rootColor: "#00d16d"
481
+ },
482
+ "button-link-violet": {
483
+ configStepColor: {
484
+ text: 0,
485
+ text_hover: 20,
486
+ text_active: -20,
487
+ text_disable: "#CDD0D6",
488
+ },
489
+ rootColor: "#7239ea"
490
+ }
491
+ };
492
+ };
493
+ const configButtonStatus = () => {
494
+ return {
495
+ "blue": {
496
+ color: "#226FF5",
497
+ background: "#E9F1FE"
498
+ },
499
+ "green": {
500
+ color: "#00D16D",
501
+ background: "#E6FAF0"
502
+ },
503
+ "red": {
504
+ color: "#EE2D41",
505
+ background: "#FDEAEC"
506
+ },
507
+ "orange": {
508
+ color: "#F05800",
509
+ background: "#FEEEE6"
510
+ },
511
+ "yellow": {
512
+ color: "#FFA621",
513
+ background: "#FFF6E9"
514
+ },
515
+ "cyan": {
516
+ color: "#04C8C8",
517
+ background: "#E6FAFA"
518
+ },
519
+ "purple": {
520
+ color: "#7239EA",
521
+ background: "#F1EBFD"
522
+ },
523
+ "brown": {
524
+ color: "#663259",
525
+ background: "#F0EBEE"
526
+ }
527
+ };
528
+ };
529
+ const configButtonTab = () => {
530
+ return {
531
+ "blue": {
532
+ color: "#226FF5",
533
+ background: "#F4F8FF",
534
+ background_badge: "#E9F1FE"
535
+ },
536
+ "green": {
537
+ color: "#00D16D",
538
+ background: "#F2FCF7",
539
+ background_badge: "#E6FAF0"
540
+ },
541
+ "red": {
542
+ color: "#EE2D41",
543
+ background: "#FDEAEC",
544
+ background_badge: "#FEE9F1"
545
+ },
546
+ "orange": {
547
+ color: "#F05800",
548
+ background: "#FEF7F2",
549
+ background_badge: "#FEEEE6"
550
+ },
551
+ "yellow": {
552
+ color: "#FFA621",
553
+ background: "#FFFBF4",
554
+ background_badge: "#FFF6E9"
555
+ },
556
+ "cyan": {
557
+ color: "#04C8C8",
558
+ background: "#F2FCFC",
559
+ background_badge: "#E6FAFA"
560
+ },
561
+ "purple": {
562
+ color: "#7239EA",
563
+ background: "#F8F5FE",
564
+ background_badge: "#F1EBFD"
565
+ },
566
+ "brown": {
567
+ color: "#663259",
568
+ background: "#F7F5F7",
569
+ background_badge: "#F0EBEE"
570
+ }
571
+ };
572
+ };
573
+ const styleButtonTab = (type, config) => {
574
+ const background = config.background || colorStepContrastFromOrigin(config.color, 95)?.light;
575
+ const backgroundBadge = config.background_badge || colorStepContrastFromOrigin(config.color, 90)?.light;
576
+ return `.libs-ui-button-tab-${type}[active="true"] {
577
+ background-color: ${background} !important;
578
+ }
579
+
580
+ .libs-ui-button-tab-${type}[active="true"] > .label {
581
+ color: ${config.color} !important;
582
+ }
583
+
584
+ .libs-ui-button-tab-${type}[active="true"] > .badge > .circle-tab {
585
+ color: ${config.color} !important;
586
+ background-color: ${backgroundBadge} !important;
587
+ }`;
588
+ };
589
+
590
+ /* eslint-disable @typescript-eslint/no-explicit-any */
591
+ class LibsUiConfigProjectService {
592
+ themeColor = signal('#226ff5');
593
+ borderColor = signal('#e6e7ea');
594
+ textErrorColor = signal('#ff5454');
595
+ borderErrorColor = signal('#ee2d41');
596
+ backgroundDisableColor = signal('#f8f9fa');
597
+ textReadonlyColor = signal('#071631');
598
+ textDisableColor = signal('#9ca2ad');
599
+ backgroundReadonlyColor = signal('#f8f9fa');
600
+ configFont = signal(fontConfig);
601
+ configHead = signal(configHeading);
602
+ configDefaultInterpolateParam = signal({ vi: {}, en: {} });
603
+ configButton = computed(() => {
604
+ return { ...configButtonColor(this.themeColor()), ...configLinkButton(this.themeColor()) };
605
+ });
606
+ configButtonStatus = signal(configButtonStatus());
607
+ configButtonTab = signal(configButtonTab());
608
+ styleClassGlobalEl = document.createElement('style');
609
+ styleClassHeadEl = document.createElement('style');
610
+ styleClassButtonTabEl = document.createElement('style');
611
+ constructor() {
612
+ effect(() => {
613
+ this.setThemeColor();
614
+ });
615
+ effect(() => {
616
+ this.setupFontFamily();
617
+ });
618
+ effect(() => {
619
+ this.setupFontHead();
620
+ });
621
+ effect(() => {
622
+ this.setupButtonTab();
623
+ });
624
+ this.configString();
625
+ this.setClassGlobal();
626
+ }
627
+ set ThemeColor(color) {
628
+ this.themeColor.set(color || '#226ff5');
629
+ }
630
+ set BorderColor(color) {
631
+ this.borderColor.set(color || '#e6e7ea');
632
+ }
633
+ set BorderErrorColor(color) {
634
+ this.borderErrorColor.set(color || '#ee2d41');
635
+ }
636
+ set TextErrorColor(color) {
637
+ this.textErrorColor.set(color || '#ff5454');
638
+ }
639
+ set BackgroundReadonlyColor(color) {
640
+ this.backgroundReadonlyColor.set(color || '#f8f9fa');
641
+ }
642
+ set TextReadonlyColor(color) {
643
+ this.textReadonlyColor.set(color || '#071631');
644
+ }
645
+ set BackgroundDisableColor(color) {
646
+ this.backgroundDisableColor.set(color || '#f8f9fa');
647
+ }
648
+ set TextDisableColor(color) {
649
+ this.textDisableColor.set(color || '#9ca2ad');
650
+ }
651
+ set ConfigFont(configFont) {
652
+ this.configFont.set({ ...configFont });
653
+ }
654
+ set ConfigFontHead(configHead) {
655
+ this.configHead.set({ ...configHead });
656
+ }
657
+ get ConfigDefaultInterpolateParam() {
658
+ return this.configDefaultInterpolateParam;
659
+ }
660
+ get ConfigButton() {
661
+ return this.configButton;
662
+ }
663
+ get ConfigButtonStatus() {
664
+ return this.configButtonStatus();
665
+ }
666
+ set ConfigButtonStatus(config) {
667
+ this.configButtonStatus.set(config);
668
+ }
669
+ set ConfigButtonTab(config) {
670
+ this.configButtonTab.set(config);
671
+ }
672
+ // public hàm để sử dụng cho component input sử dụng tagInput = frameArea;
673
+ setupFontFamily(currentDoc) {
674
+ currentDoc = currentDoc || document;
675
+ const doc = currentDoc.documentElement;
676
+ doc.style.setProperty('--libs-ui-font-family-name', `${this.configFont().name},Arial, Helvetica, sans-serif`);
677
+ Object.keys(weights).forEach(key => {
678
+ const fontFace = new FontFace(this.configFont().name, `url(${get(this.configFont(), key)})`, { weight: get(weights, key) });
679
+ fontFace.load().then(loadedFont => {
680
+ if ('add' in currentDoc.fonts) {
681
+ currentDoc.fonts.add(loadedFont);
682
+ }
683
+ });
684
+ });
685
+ }
686
+ setupFontHead() {
687
+ const configHeads = this.configHead();
688
+ let styles = '';
689
+ Object.keys(configHeads).forEach(keyConfig => {
690
+ let style = `font-family:var(--libs-ui-font-family-name,'Arial');`;
691
+ const config = get(configHeading, keyConfig);
692
+ Object.keys(config).forEach(key => {
693
+ style = `${style}${key}:${get(config, key)};`;
694
+ });
695
+ styles = `${styles} .libs-ui-font-${keyConfig}{${style}}`;
696
+ });
697
+ styles = `*{box-sizing: border-box !important;}${styles}`;
698
+ this.styleClassHeadEl.innerHTML = styles;
699
+ document.head.append(this.styleClassHeadEl);
700
+ }
701
+ setupButtonTab() {
702
+ const configButtonTab = this.configButtonTab();
703
+ let styles = '';
704
+ Object.keys(configButtonTab).forEach(key => {
705
+ const config = get(configButtonTab, key);
706
+ const style = config ? styleButtonTab(key, config) : '';
707
+ styles = `${styles}${style}`;
708
+ });
709
+ this.styleClassButtonTabEl.innerHTML = styles;
710
+ document.head.append(this.styleClassButtonTabEl);
711
+ }
712
+ setThemeColor() {
713
+ const doc = document.documentElement;
714
+ [{
715
+ group: 'libs-ui',
716
+ type: 'color',
717
+ property: {
718
+ default: colorStepContrastFromOrigin(this.themeColor(), 0)?.light,
719
+ light_1: colorStepContrastFromOrigin(this.themeColor(), 20)?.light,
720
+ light_2: colorStepContrastFromOrigin(this.themeColor(), 90)?.light,
721
+ light_3: colorStepContrastFromOrigin(this.themeColor(), 95)?.light,
722
+ light_4: colorStepContrastFromOrigin(this.themeColor(), 50)?.light,
723
+ light_5: colorStepContrastFromOrigin(this.themeColor(), 70)?.light,
724
+ light_6: colorStepContrastFromOrigin(this.themeColor(), 80)?.light,
725
+ dark: colorStepContrastFromOrigin(this.themeColor(), 20)?.dark,
726
+ border: this.borderColor(),
727
+ border_error: this.borderErrorColor(),
728
+ text_error: this.textErrorColor(),
729
+ background_readonly: this.backgroundReadonlyColor(),
730
+ text_readonly: this.textReadonlyColor(),
731
+ background_disable: this.backgroundDisableColor(),
732
+ text_disable: this.textDisableColor(),
733
+ gradient_from: this.themeColor().toLocaleUpperCase() === '#226FF5' ? colorStepContrastFromOrigin(this.themeColor(), 10)?.light : colorStepContrastFromOrigin(this.themeColor(), 0)?.light,
734
+ gradient_to: this.themeColor().toLocaleUpperCase() === '#226FF5' ? colorStepContrastFromOrigin('#5B2EBB', 10)?.light : colorStepContrastFromOrigin(this.themeColor(), 20)?.dark,
735
+ }
736
+ }].forEach(item => {
737
+ const name = `--${item.group.replace(/[_]/g, '-')}-${item.type.replace(/[_]/g, '-')}`;
738
+ Object.keys(item.property).forEach(key => doc.style.setProperty(`${name}-${key.replace(/[_]/g, '-')}`, item.property[key]));
739
+ });
740
+ }
741
+ colorStepContrastFromOrigin(step, color) {
742
+ return colorStepContrastFromOrigin(color || this.themeColor(), step || 0);
743
+ }
744
+ setClassGlobal() {
745
+ this.styleClassGlobalEl.innerHTML = `
746
+ .libs-ui-border-primary-general{border: 1px solid var(--libs-ui-color-default, #226FF5);}
747
+ .libs-ui-border-primary-focus-general{border: 1px solid var(--libs-ui-color-light-1, #4e8cf7);}
748
+ .libs-ui-border-primary-hover-general{border: 1px solid var(--libs-ui-color-light-3, #f4f8ff);}
749
+ .libs-ui-border-general{ border: 1px solid var(--libs-ui-color-border, #e6e7ea);}
750
+ .libs-ui-border-top-general{border-top: 1px solid var(--libs-ui-color-border, #e6e7ea);}
751
+ .libs-ui-border-right-general{border-right: 1px solid var(--libs-ui-color-border, #e6e7ea);}
752
+ .libs-ui-border-bottom-general{border-bottom: 1px solid var(--libs-ui-color-border, #e6e7ea);}
753
+ .libs-ui-border-dashed-bottom-general{border-bottom: dashed 1px var(--libs-ui-color-border, #e6e7ea);}
754
+ .libs-ui-border-left-general{border-left: 1px solid var(--libs-ui-color-border, #e6e7ea);}
755
+ .libs-ui-border-x-general{border-left: 1px solid var(--libs-ui-color-border, #e6e7ea); border-right: 1px solid var(--libs-ui-color-border, #e6e7ea);}
756
+ .libs-ui-border-y-general{border-top: 1px solid var(--libs-ui-color-border, #e6e7ea); border-bottom: 1px solid var(--libs-ui-color-border, #e6e7ea);}
757
+ .libs-ui-border-left-top-general{border-left: 1px solid var(--libs-ui-color-border, #e6e7ea); border-top: 1px solid var(--libs-ui-color-border, #e6e7ea);}
758
+ .libs-ui-border-left-bottom-general{border-left: 1px solid var(--libs-ui-color-border, #e6e7ea); border-bottom: 1px solid var(--libs-ui-color-border, #e6e7ea);}
759
+ .libs-ui-border-right-top-general{border-right: 1px solid var(--libs-ui-color-border, #e6e7ea); border-top: 1px solid var(--libs-ui-color-border, #e6e7ea);}
760
+ .libs-ui-border-right-bottom-general{border-right: 1px solid var(--libs-ui-color-border, #e6e7ea); border-bottom: 1px solid var(--libs-ui-color-border, #e6e7ea);}
761
+ .libs-ui-border-error-general{border: 1px solid var(--libs-ui-color-border-error, #ee2d41);}
762
+ .libs-ui-bg-list-hover:hover {background-color: #f8f9fa;}
763
+ .libs-ui-bg-list-hover-active:hover {background-color: #f8f9fa;}
764
+ .libs-ui-bg-list-hover-active:active {background-color: var(--libs-ui-color-light-3, #f4f8ff);}
765
+ .libs-ui-text-error {color: var(--libs-ui-color-text-error, #ff5454); !important}
766
+ .libs-ui-text-error::before {color: var(--libs-ui-color-text-error, #ff5454);}
767
+ .libs-ui-disable {cursor: default !important;text-decoration: none;color:var(--libs-ui-color-text-disable, #cdd0d6) !important}
768
+ .libs-ui-disable::before {color:var(--libs-ui-color-text-disable, #9ca2ad) !important}
769
+ .libs-ui-disable-background{background: var(--libs-ui-color-background-disable, #f8f9fa) !important;}
770
+ .libs-ui-disable-active {color:var(--libs-ui-color-light-4,#91b7fa) !important}
771
+ .libs-ui-disable-active::before {color:var(--libs-ui-color-light-4,#91b7fa) !important}
772
+ .libs-ui-readonly {cursor: default !important;color:var(--libs-ui-color-text-readonly, #071631) !important;}
773
+ .libs-ui-readonly::before {color:var(--libs-ui-color-text-readonly, #071631) !important;}
774
+ .libs-ui-readonly-background{background: var(--libs-ui-color-background-readonly, #f8f9fa) !important;}
775
+ `;
776
+ document.head.append(this.styleClassGlobalEl);
777
+ }
778
+ configString() {
779
+ const prototype = String.prototype;
780
+ prototype.replaceAt = function (index, replacement) {
781
+ const values = this.split('');
782
+ values[index] = replacement;
783
+ return values.join('');
784
+ };
785
+ prototype.replaceAll = function (index, separator, replacement) {
786
+ const regex = new RegExp(separator, 'g');
787
+ return `${this.substr(0, index)}${this.substr(index + 1 + (replacement?.length || 0)).replace(regex, replacement)}`;
788
+ };
789
+ prototype.occurrencesByCharacter = function (character) {
790
+ const values = this.split('');
791
+ if (!values || !values.length) {
792
+ return 0;
793
+ }
794
+ return values.filter((char) => char === character).length;
795
+ };
796
+ prototype.indexesOfCharacter = function (character) {
797
+ const values = this.split('');
798
+ const indexes = [];
799
+ if (!values || !values.length) {
800
+ return indexes;
801
+ }
802
+ for (const indexValue in values) {
803
+ if (values[indexValue] === character) {
804
+ indexes.push(+indexValue);
805
+ }
806
+ }
807
+ return indexes;
808
+ };
809
+ prototype.indexesByString = function (str) {
810
+ const values = this;
811
+ const indexes = [];
812
+ if (!values || !values.length || !str || !str.length || values.length < str.length) {
813
+ return indexes;
814
+ }
815
+ for (const indexValue in values) {
816
+ if (values[indexValue] !== str[0] || ((+indexValue) + str.length) > values.length) {
817
+ continue;
818
+ }
819
+ for (const index in str.split('')) {
820
+ if (values[(+indexValue) + (+index)] !== str[index]) {
821
+ break;
822
+ }
823
+ }
824
+ indexes.push(+indexValue);
825
+ }
826
+ return indexes;
827
+ };
828
+ }
829
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiConfigProjectService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
830
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiConfigProjectService, providedIn: 'root' });
831
+ }
832
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiConfigProjectService, decorators: [{
833
+ type: Injectable,
834
+ args: [{
835
+ providedIn: 'root'
836
+ }]
837
+ }], ctorParameters: () => [] });
838
+
839
+ ;
840
+ ;
841
+ ;
842
+
843
+ const dataTranslation = () => {
844
+ return {
845
+ vi: { "i18n_character": "Ký tự", "i18n_search": "Tìm kiếm", "i18n_color_custom": "Màu tuỳ chỉnh", "i18n_add_new": "Thêm giá trị mới", "i18n_cancel": "Hủy bỏ", "i18n_apply": "Áp dụng" },
846
+ en: { "i18n_character": "character", "i18n_search": "Search", "i18n_color_custom": "Custom theme color", "i18n_add_new": "Add new value", "i18n_cancel": "Cancel", "i18n_apply": "Apply" }
847
+ };
848
+ };
849
+
850
+ /* eslint-disable @typescript-eslint/no-explicit-any */
851
+ class LibsUiTranslateService extends TranslateService {
852
+ configProjectService = inject(LibsUiConfigProjectService);
853
+ interpolateParam = computed(() => this.configProjectService.ConfigDefaultInterpolateParam());
854
+ constructor(store, currentLoader, compiler, parser, missingTranslationHandler, useDefaultLang, isolate, extend, defaultLanguage) {
855
+ super(store, currentLoader, compiler, parser, missingTranslationHandler, useDefaultLang, isolate, extend, defaultLanguage);
856
+ }
857
+ instant(key, interpolateParams) {
858
+ const val = super.instant(key, { ...this.interpolateParam()[UtilsCache.getLang()], ...(interpolateParams || {}) });
859
+ return val;
860
+ }
861
+ get(key, interpolateParams) {
862
+ return super.get(key, { ...this.interpolateParam()[UtilsCache.getLang()], ...(interpolateParams || {}) });
863
+ }
864
+ getParsedResult(translations, key, interpolateParams) {
865
+ return super.getParsedResult(translations, key, { ...this.interpolateParam()[UtilsCache.getLang()], ...(interpolateParams || {}) });
866
+ }
867
+ use(lang) {
868
+ const event = super.use(lang);
869
+ this.get(lang).pipe(take(1)).subscribe(() => super.setTranslation(lang, get(dataTranslation(), lang), true));
870
+ UtilsCache.setLang(lang);
871
+ return event;
872
+ }
873
+ }
874
+
875
+ let link = '/i18n/';
876
+ const httpLoaderFactory = (http) => {
877
+ return new TranslateHttpLoader(http, link, '.json');
878
+ };
879
+ const TranslateForRootConfig = {
880
+ loader: {
881
+ provide: TranslateLoader,
882
+ useFactory: httpLoaderFactory,
883
+ deps: [HttpClient]
884
+ },
885
+ compiler: {
886
+ provide: TranslateCompiler,
887
+ useClass: TranslateMessageFormatCompiler,
888
+ }
889
+ };
890
+ const TranslateProviderConfig = {
891
+ provide: TranslateService,
892
+ useFactory: (store, currentLoader, compiler, parser, missingTranslationHandler, useDefaultLang, isolate, extend, defaultLanguage) => {
893
+ return new LibsUiTranslateService(store, currentLoader, compiler, parser, missingTranslationHandler, useDefaultLang, isolate, extend, defaultLanguage);
894
+ },
895
+ deps: [TranslateStore, TranslateLoader, TranslateCompiler, TranslateParser, MissingTranslationHandler],
896
+ };
897
+ const GET_CONFIG_TRANSLATE = (linkFileI18n) => {
898
+ if (linkFileI18n !== undefined) {
899
+ link = linkFileI18n;
900
+ }
901
+ return [
902
+ provideHttpClient(),
903
+ importProvidersFrom(TranslateModule.forRoot(TranslateForRootConfig)),
904
+ TranslateProviderConfig
905
+ ];
906
+ };
907
+
908
+ /**
909
+ * Generated bundle index. Do not edit.
910
+ */
911
+
912
+ export { GET_CONFIG_TRANSLATE, LibsUiConfigProjectService };
913
+ //# sourceMappingURL=libs-ui-services-config-project.mjs.map