@shival99/z-ui 1.2.12 → 1.2.13

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, inject, signal, InjectionToken, PLATFORM_ID, effect } from '@angular/core';
2
+ import { Injectable, InjectionToken, inject, signal, PLATFORM_ID, effect } from '@angular/core';
3
3
  import { zFormatNumExcel, zConvertColorToArgb } from '@shival99/z-ui/utils';
4
4
  import * as ExcelJS from 'exceljs';
5
5
  import { saveAs } from 'file-saver';
@@ -1311,77 +1311,63 @@ class ZIndexDbService {
1311
1311
  }
1312
1312
  }
1313
1313
 
1314
- const LANG_CACHE_KEY = 'Z_LANGUAGE';
1315
- const DEFAULT_LANG = 'vi';
1314
+ const Z_THEME_CONFIG = new InjectionToken('Z_THEME_CONFIG');
1315
+ const Z_DEFAULT_THEME = 'neutral';
1316
+ const Z_THEME_CACHE_KEY = 'z-theme';
1317
+ const Z_DARK_MODE_CACHE_KEY = 'z-dark-mode';
1318
+ const Z_THEME_CSS_MAP = {
1319
+ neutral: '',
1320
+ green: 'assets/css/themes/green.css',
1321
+ orange: 'assets/css/themes/orange.css',
1322
+ violet: 'assets/css/themes/violet.css',
1323
+ stone: 'assets/css/themes/stone.css',
1324
+ zinc: 'assets/css/themes/zinc.css',
1325
+ gray: 'assets/css/themes/gray.css',
1326
+ slate: 'assets/css/themes/slate.css',
1327
+ hospital: 'assets/css/themes/hospital.css',
1328
+ };
1329
+
1330
+ const Z_LANG_CACHE_KEY = 'Z_LANGUAGE';
1331
+
1316
1332
  class ZTranslateService {
1317
1333
  _translate = inject(TranslateService);
1318
- currentLang = signal(DEFAULT_LANG, ...(ngDevMode ? [{ debugName: "currentLang" }] : []));
1334
+ currentLang = signal('vi', ...(ngDevMode ? [{ debugName: "currentLang" }] : []));
1319
1335
  availableLangs = signal(['vi', 'en'], ...(ngDevMode ? [{ debugName: "availableLangs" }] : []));
1320
1336
  constructor() {
1321
1337
  this._initialize();
1322
1338
  }
1323
1339
  _initialize() {
1324
- const currentLang = this._translate.getCurrentLang() || ZCacheService.get(LANG_CACHE_KEY) || DEFAULT_LANG;
1340
+ const currentLang = this._translate.getCurrentLang() || ZCacheService.get(Z_LANG_CACHE_KEY) || 'vi';
1325
1341
  this.currentLang.set(currentLang);
1342
+ document.documentElement.lang = currentLang;
1326
1343
  }
1327
- /**
1328
- * Change the current language
1329
- * @param lang - Language code
1330
- */
1331
1344
  use(lang) {
1332
1345
  this._translate.use(lang);
1333
- ZCacheService.set(LANG_CACHE_KEY, lang);
1346
+ ZCacheService.set(Z_LANG_CACHE_KEY, lang);
1334
1347
  this.currentLang.set(lang);
1348
+ document.documentElement.lang = lang;
1335
1349
  }
1336
- /**
1337
- * Get the current language code
1338
- */
1339
1350
  getLang() {
1340
- return this._translate.getCurrentLang() ?? DEFAULT_LANG;
1351
+ return this._translate.getCurrentLang() ?? 'vi';
1341
1352
  }
1342
- /**
1343
- * Get translation synchronously (returns key if not found)
1344
- * @param key - Translation key
1345
- * @param params - Interpolation parameters
1346
- */
1347
1353
  instant(key, params) {
1348
1354
  if (!key) {
1349
1355
  return '';
1350
1356
  }
1351
1357
  return this._translate.instant(key, params);
1352
1358
  }
1353
- /**
1354
- * Get translation asynchronously
1355
- * @param key - Translation key
1356
- * @param params - Interpolation parameters
1357
- */
1358
1359
  async get(key, params) {
1359
1360
  if (!key) {
1360
1361
  return '';
1361
1362
  }
1362
1363
  return firstValueFrom(this._translate.get(key, params));
1363
1364
  }
1364
- /**
1365
- * Get translation as observable
1366
- * @param key - Translation key
1367
- * @param params - Interpolation parameters
1368
- */
1369
1365
  get$(key, params) {
1370
1366
  return this._translate.get(key, params);
1371
1367
  }
1372
- /**
1373
- * Stream translations (re-emits on language change)
1374
- * @param key - Translation key
1375
- * @param params - Interpolation parameters
1376
- */
1377
1368
  stream$(key, params) {
1378
1369
  return this._translate.stream(key, params);
1379
1370
  }
1380
- /**
1381
- * Get multiple translations at once
1382
- * @param keys - Array of translation keys
1383
- * @param params - Interpolation parameters (applied to all)
1384
- */
1385
1371
  async getMany(keys, params) {
1386
1372
  const results = {};
1387
1373
  await Promise.all(keys.map(async (key) => {
@@ -1389,26 +1375,13 @@ class ZTranslateService {
1389
1375
  }));
1390
1376
  return results;
1391
1377
  }
1392
- /**
1393
- * Check if a translation key exists
1394
- * @param key - Translation key
1395
- */
1396
1378
  has(key) {
1397
1379
  const translation = this._translate.instant(key);
1398
1380
  return translation !== key;
1399
1381
  }
1400
- /**
1401
- * Add translations dynamically
1402
- * @param lang - Language code
1403
- * @param translations - Translation object
1404
- * @param shouldMerge - Whether to merge with existing translations
1405
- */
1406
1382
  setTranslation(lang, translations, shouldMerge = true) {
1407
1383
  this._translate.setTranslation(lang, translations, shouldMerge);
1408
1384
  }
1409
- /**
1410
- * Get the underlying TranslateService for advanced usage
1411
- */
1412
1385
  getNgxTranslate() {
1413
1386
  return this._translate;
1414
1387
  }
@@ -1863,22 +1836,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
1863
1836
  }]
1864
1837
  }] });
1865
1838
 
1866
- const Z_THEME_CONFIG = new InjectionToken('Z_THEME_CONFIG');
1867
- const Z_DEFAULT_THEME = 'neutral';
1868
- const Z_THEME_CACHE_KEY = 'z-theme';
1869
- const Z_DARK_MODE_CACHE_KEY = 'z-dark-mode';
1870
- const Z_THEME_CSS_MAP = {
1871
- neutral: '',
1872
- green: 'assets/css/themes/green.css',
1873
- orange: 'assets/css/themes/orange.css',
1874
- violet: 'assets/css/themes/violet.css',
1875
- stone: 'assets/css/themes/stone.css',
1876
- zinc: 'assets/css/themes/zinc.css',
1877
- gray: 'assets/css/themes/gray.css',
1878
- slate: 'assets/css/themes/slate.css',
1879
- hospital: 'assets/css/themes/hospital.css',
1880
- };
1881
-
1882
1839
  class ZThemeService {
1883
1840
  _document = inject(DOCUMENT);
1884
1841
  _platformId = inject(PLATFORM_ID);
@@ -1996,5 +1953,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
1996
1953
  * Generated bundle index. Do not edit.
1997
1954
  */
1998
1955
 
1999
- export { ZCacheService, ZExcelService, ZHttpAbstractService, ZIndexDbService, ZSubjectService, ZThemeService, ZTranslateService, Z_DARK_MODE_CACHE_KEY, Z_DEFAULT_THEME, Z_EXCEL_BORDER_THIN, Z_EXCEL_CHAR_WIDTH_MAP, Z_EXCEL_COLORS, Z_EXCEL_DEFAULT_CONFIG, Z_EXCEL_FONT_MULTIPLIERS, Z_EXCEL_WIDTH_LIMITS, Z_THEME_CACHE_KEY, Z_THEME_CONFIG, Z_THEME_CSS_MAP };
1956
+ export { ZCacheService, ZExcelService, ZHttpAbstractService, ZIndexDbService, ZSubjectService, ZThemeService, ZTranslateService, Z_DARK_MODE_CACHE_KEY, Z_DEFAULT_THEME, Z_EXCEL_BORDER_THIN, Z_EXCEL_CHAR_WIDTH_MAP, Z_EXCEL_COLORS, Z_EXCEL_DEFAULT_CONFIG, Z_EXCEL_FONT_MULTIPLIERS, Z_EXCEL_WIDTH_LIMITS, Z_LANG_CACHE_KEY, Z_THEME_CACHE_KEY, Z_THEME_CONFIG, Z_THEME_CSS_MAP };
2000
1957
  //# sourceMappingURL=shival99-z-ui-services.mjs.map