uni-app-fe 0.1.21 → 0.1.22

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.
@@ -7,9 +7,28 @@ import esMessages from 'devextreme/localization/messages/es.json';
7
7
  import itMessages from 'devextreme/localization/messages/it.json';
8
8
  import { firstValueFrom } from 'rxjs';
9
9
  import { UniHttpManager } from 'uni-manager/http';
10
- import { UniLocaleManager } from 'uni-manager/locale';
10
+ import { UniLocaleManager, Locale } from 'uni-manager/locale';
11
11
 
12
12
  class UniLocaleManagerAngular {
13
+ /* ------------------------------------------------------------------------------- */
14
+ /* ------------------------------------ Http ------------------------------------- */
15
+ /* ------------------------------------------------------------------------------- */
16
+ /**
17
+ * Recupera il dizionario delle traduzioni dal server remoto in base al locale corrente.
18
+ * Una volta completata la chiamata HTTP, aggiorna automaticamente lo store interno tramite il metodo setTranslations.
19
+ */
20
+ static async fetchTranslation(uniLocale) {
21
+ /* API */
22
+ const res = await firstValueFrom(UniHttpManager.read$({
23
+ ref: 'locale',
24
+ path: `/Locale/${uniLocale}`,
25
+ }));
26
+ /* Translations */
27
+ UniLocaleManager.setLocalesSupported(res?.localesSupported);
28
+ UniLocaleManager.setTranslations(Object.fromEntries(Object.entries(res?.translations ?? {}).map((x) => [x[0].toLowerCase(), x[1]])));
29
+ /* Versione backend */
30
+ localStorage.setItem('uni-version-be', res?.version);
31
+ }
13
32
  /* ------------------------------------------------------------------------------- */
14
33
  /* ----------------------------------- Config ------------------------------------ */
15
34
  /* ------------------------------------------------------------------------------- */
@@ -17,31 +36,27 @@ class UniLocaleManagerAngular {
17
36
  * Registra i dati specifici del locale nel framework Angular.
18
37
  * Necessario per garantire che le pipe built-in (es. DatePipe, CurrencyPipe) operino secondo le convenzioni del paese corrente.
19
38
  */
20
- static setLocaleAngular(currentLocale) {
21
- if (!currentLocale)
22
- return;
39
+ static setLocaleAngular(uniLocale) {
23
40
  /* Imposta i dati del locale corrente in Angular necessari per le pipe */
24
- if (currentLocale === 'it-IT') {
25
- registerLocaleData(localeIt, 'it-IT');
41
+ if (uniLocale === Locale.IT) {
42
+ registerLocaleData(localeIt, Locale.IT);
26
43
  }
27
- else if (currentLocale === 'es-CL') {
28
- registerLocaleData(localeEsCl, 'es-CL');
44
+ else if (uniLocale === Locale.ES) {
45
+ registerLocaleData(localeEsCl, Locale.ES);
29
46
  }
30
47
  }
31
48
  /**
32
49
  * Inizializza la localizzazione specifica per i componenti DevExtreme.
33
50
  * Imposta il locale per le formattazioni native dei widget e carica i file di messaggi JSON per la traduzione dei testi di sistema.
34
51
  */
35
- static setLocaleDevextreme(currentLocale) {
36
- if (!currentLocale)
37
- return;
52
+ static setLocaleDevextreme(uniLocale) {
38
53
  /* Imposta la lingua */
39
- locale(currentLocale);
54
+ locale(uniLocale);
40
55
  /* Forza la valuta a mano in base alla stringa esatta */
41
- if (currentLocale === 'it-IT') {
56
+ if (uniLocale === Locale.IT) {
42
57
  config({ defaultCurrency: 'EUR' });
43
58
  }
44
- else if (currentLocale === 'es-CL') {
59
+ else if (uniLocale === Locale.ES) {
45
60
  config({ defaultCurrency: 'CLP' });
46
61
  }
47
62
  /* Carica i messaggi di traduzione */
@@ -56,25 +71,6 @@ class UniLocaleManagerAngular {
56
71
  }
57
72
  }
58
73
  }
59
- /* ------------------------------------------------------------------------------- */
60
- /* ------------------------------------ Http ------------------------------------- */
61
- /* ------------------------------------------------------------------------------- */
62
- /**
63
- * Recupera il dizionario delle traduzioni dal server remoto in base al locale corrente.
64
- * Una volta completata la chiamata HTTP, aggiorna automaticamente lo store interno
65
- * tramite il metodo setTranslations.
66
- */
67
- static async fetchTranslation(currentLocale) {
68
- if (!currentLocale)
69
- return;
70
- const res = await firstValueFrom(UniHttpManager.read$({
71
- ref: 'locale',
72
- path: `/Locale/${currentLocale}`,
73
- }));
74
- localStorage.setItem('uni-version-be', res?.version);
75
- UniLocaleManager.setLocalesSupported(res?.localesSupported);
76
- UniLocaleManager.setTranslations(Object.fromEntries(Object.entries(res?.translations ?? {}).map((x) => [x[0].toLowerCase(), x[1]])));
77
- }
78
74
  }
79
75
 
80
76
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"uni-app-fe-manager.mjs","sources":["../../../projects/uni-app-fe/manager/locale.manager.ts","../../../projects/uni-app-fe/manager/uni-app-fe-manager.ts"],"sourcesContent":["import { registerLocaleData } from '@angular/common';\r\nimport localeEsCl from '@angular/common/locales/es-CL';\r\nimport localeIt from '@angular/common/locales/it';\r\nimport { config } from 'devextreme-angular/common';\r\nimport { loadMessages, locale } from 'devextreme-angular/common/core/localization';\r\nimport esMessages from 'devextreme/localization/messages/es.json';\r\nimport itMessages from 'devextreme/localization/messages/it.json';\r\nimport { firstValueFrom } from 'rxjs';\r\nimport { UniHttpManager } from 'uni-manager/http';\r\nimport { UniLocaleManager } from 'uni-manager/locale';\r\n\r\nexport class UniLocaleManagerAngular {\r\n /* ------------------------------------------------------------------------------- */\r\n /* ----------------------------------- Config ------------------------------------ */\r\n /* ------------------------------------------------------------------------------- */\r\n /**\r\n * Registra i dati specifici del locale nel framework Angular.\r\n * Necessario per garantire che le pipe built-in (es. DatePipe, CurrencyPipe) operino secondo le convenzioni del paese corrente.\r\n */\r\n public static setLocaleAngular(currentLocale: string): void {\r\n if (!currentLocale) return;\r\n\r\n /* Imposta i dati del locale corrente in Angular necessari per le pipe */\r\n if (currentLocale === 'it-IT') {\r\n registerLocaleData(localeIt, 'it-IT');\r\n } else if (currentLocale === 'es-CL') {\r\n registerLocaleData(localeEsCl, 'es-CL');\r\n }\r\n }\r\n\r\n /**\r\n * Inizializza la localizzazione specifica per i componenti DevExtreme.\r\n * Imposta il locale per le formattazioni native dei widget e carica i file di messaggi JSON per la traduzione dei testi di sistema.\r\n */\r\n public static setLocaleDevextreme(currentLocale: string): void {\r\n if (!currentLocale) return;\r\n\r\n /* Imposta la lingua */\r\n locale(currentLocale);\r\n\r\n /* Forza la valuta a mano in base alla stringa esatta */\r\n if (currentLocale === 'it-IT') {\r\n config({ defaultCurrency: 'EUR' });\r\n } else if (currentLocale === 'es-CL') {\r\n config({ defaultCurrency: 'CLP' });\r\n }\r\n\r\n /* Carica i messaggi di traduzione */\r\n switch (UniLocaleManager.language) {\r\n case 'it': {\r\n loadMessages(itMessages);\r\n break;\r\n }\r\n case 'es': {\r\n loadMessages(esMessages);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* ------------------------------------ Http ------------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /**\r\n * Recupera il dizionario delle traduzioni dal server remoto in base al locale corrente.\r\n * Una volta completata la chiamata HTTP, aggiorna automaticamente lo store interno\r\n * tramite il metodo setTranslations.\r\n */\r\n public static async fetchTranslation(currentLocale: string): Promise<void> {\r\n if (!currentLocale) return;\r\n\r\n const res = await firstValueFrom(\r\n UniHttpManager.read$<{\r\n version: string;\r\n locale: string;\r\n localesSupported: string[];\r\n translations: Record<string, string>;\r\n }>({\r\n ref: 'locale',\r\n path: `/Locale/${currentLocale}`,\r\n }),\r\n );\r\n\r\n localStorage.setItem('uni-version-be', res?.version);\r\n UniLocaleManager.setLocalesSupported(res?.localesSupported);\r\n UniLocaleManager.setTranslations(\r\n Object.fromEntries(\r\n Object.entries(res?.translations ?? {}).map((x) => [x[0].toLowerCase(), x[1]]),\r\n ),\r\n );\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;MAWa,uBAAuB,CAAA;;;;AAIlC;;;AAGG;IACI,OAAO,gBAAgB,CAAC,aAAqB,EAAA;AAClD,QAAA,IAAI,CAAC,aAAa;YAAE;;AAGpB,QAAA,IAAI,aAAa,KAAK,OAAO,EAAE;AAC7B,YAAA,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC;QACvC;AAAO,aAAA,IAAI,aAAa,KAAK,OAAO,EAAE;AACpC,YAAA,kBAAkB,CAAC,UAAU,EAAE,OAAO,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;;AAEG;;;;"}
1
+ {"version":3,"file":"uni-app-fe-manager.mjs","sources":["../../../projects/uni-app-fe/manager/locale.manager.ts","../../../projects/uni-app-fe/manager/uni-app-fe-manager.ts"],"sourcesContent":["import { registerLocaleData } from '@angular/common';\r\nimport localeEsCl from '@angular/common/locales/es-CL';\r\nimport localeIt from '@angular/common/locales/it';\r\nimport { config } from 'devextreme-angular/common';\r\nimport { loadMessages, locale } from 'devextreme-angular/common/core/localization';\r\nimport esMessages from 'devextreme/localization/messages/es.json';\r\nimport itMessages from 'devextreme/localization/messages/it.json';\r\nimport { firstValueFrom } from 'rxjs';\r\nimport { UniHttpManager } from 'uni-manager/http';\r\nimport { Locale, UniLocaleManager } from 'uni-manager/locale';\r\n\r\nexport class UniLocaleManagerAngular {\r\n /* ------------------------------------------------------------------------------- */\r\n /* ------------------------------------ Http ------------------------------------- */\r\n /* ------------------------------------------------------------------------------- */\r\n /**\r\n * Recupera il dizionario delle traduzioni dal server remoto in base al locale corrente.\r\n * Una volta completata la chiamata HTTP, aggiorna automaticamente lo store interno tramite il metodo setTranslations.\r\n */\r\n public static async fetchTranslation(uniLocale: Locale): Promise<void> {\r\n /* API */\r\n const res = await firstValueFrom(\r\n UniHttpManager.read$<{\r\n version: string;\r\n locale: string;\r\n localesSupported: string[];\r\n translations: Record<string, string>;\r\n }>({\r\n ref: 'locale',\r\n path: `/Locale/${uniLocale}`,\r\n }),\r\n );\r\n\r\n /* Translations */\r\n UniLocaleManager.setLocalesSupported(res?.localesSupported);\r\n UniLocaleManager.setTranslations(\r\n Object.fromEntries(\r\n Object.entries(res?.translations ?? {}).map((x) => [x[0].toLowerCase(), x[1]]),\r\n ),\r\n );\r\n\r\n /* Versione backend */\r\n localStorage.setItem('uni-version-be', res?.version);\r\n }\r\n\r\n /* ------------------------------------------------------------------------------- */\r\n /* ----------------------------------- Config ------------------------------------ */\r\n /* ------------------------------------------------------------------------------- */\r\n /**\r\n * Registra i dati specifici del locale nel framework Angular.\r\n * Necessario per garantire che le pipe built-in (es. DatePipe, CurrencyPipe) operino secondo le convenzioni del paese corrente.\r\n */\r\n public static setLocaleAngular(uniLocale: Locale): void {\r\n /* Imposta i dati del locale corrente in Angular necessari per le pipe */\r\n if (uniLocale === Locale.IT) {\r\n registerLocaleData(localeIt, Locale.IT);\r\n } else if (uniLocale === Locale.ES) {\r\n registerLocaleData(localeEsCl, Locale.ES);\r\n }\r\n }\r\n\r\n /**\r\n * Inizializza la localizzazione specifica per i componenti DevExtreme.\r\n * Imposta il locale per le formattazioni native dei widget e carica i file di messaggi JSON per la traduzione dei testi di sistema.\r\n */\r\n public static setLocaleDevextreme(uniLocale: Locale): void {\r\n /* Imposta la lingua */\r\n locale(uniLocale);\r\n\r\n /* Forza la valuta a mano in base alla stringa esatta */\r\n if (uniLocale === Locale.IT) {\r\n config({ defaultCurrency: 'EUR' });\r\n } else if (uniLocale === Locale.ES) {\r\n config({ defaultCurrency: 'CLP' });\r\n }\r\n\r\n /* Carica i messaggi di traduzione */\r\n switch (UniLocaleManager.language) {\r\n case 'it': {\r\n loadMessages(itMessages);\r\n break;\r\n }\r\n case 'es': {\r\n loadMessages(esMessages);\r\n break;\r\n }\r\n }\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;MAWa,uBAAuB,CAAA;;;;AAIlC;;;AAGG;AACI,IAAA,aAAa,gBAAgB,CAAC,SAAiB,EAAA;;QAEpD,MAAM,GAAG,GAAG,MAAM,cAAc,CAC9B,cAAc,CAAC,KAAK,CAKjB;AACD,YAAA,GAAG,EAAE,QAAQ;YACb,IAAI,EAAE,CAAA,QAAA,EAAW,SAAS,CAAA,CAAE;AAC7B,SAAA,CAAC,CACH;;AAGD,QAAA,gBAAgB,CAAC,mBAAmB,CAAC,GAAG,EAAE,gBAAgB,CAAC;AAC3D,QAAA,gBAAgB,CAAC,eAAe,CAC9B,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC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5
5
  "@angular/common": ">=21.2.0",
6
6
  "@angular/core": ">=21.2.0",
7
7
  "devextreme": ">=25.2.0",
8
8
  "devextreme-angular": ">=25.2.0",
9
- "uni-model-type": ">=0.1.14",
9
+ "uni-model-type": ">=0.1.18",
10
10
  "uni-error": ">=0.1.22",
11
- "uni-manager": ">=0.1.38"
11
+ "uni-manager": ">=0.1.44"
12
12
  },
13
13
  "dependencies": {
14
14
  "tslib": "^2.3.0"
@@ -6,6 +6,7 @@ import { ErrorStore, Combo } from 'uni-model-type/type';
6
6
  import { DatePipe } from '@angular/common';
7
7
  import { IconDefinition as IconDefinition$1 } from '@fortawesome/fontawesome-svg-core';
8
8
  import { ValueChangedEvent } from 'devextreme/ui/select_box_types';
9
+ import * as uni_manager_locale from 'uni-manager/locale';
9
10
  import { ValueChangedEvent as ValueChangedEvent$1 } from 'devextreme/ui/switch_types';
10
11
  import { UniLoaderService } from 'uni-app-fe/service';
11
12
 
@@ -140,8 +141,8 @@ declare class UniSideMenu {
140
141
  readonly menuItems: _angular_core.InputSignal<MenuItem[]>;
141
142
  readonly menuInteractions: _angular_core.InputSignal<MenuInteraction[]>;
142
143
  evtToggleMenu: _angular_core.OutputEmitterRef<false>;
143
- locale: string;
144
- localesSupported: string[];
144
+ locale: uni_manager_locale.Locale;
145
+ localesSupported: uni_manager_locale.Locale[];
145
146
  darkMode: _angular_core.WritableSignal<boolean>;
146
147
  readonly ICON: {
147
148
  USER: _fortawesome_fontawesome_common_types.IconDefinition;
@@ -1,20 +1,21 @@
1
+ import { Locale } from 'uni-manager/locale';
2
+
1
3
  declare class UniLocaleManagerAngular {
4
+ /**
5
+ * Recupera il dizionario delle traduzioni dal server remoto in base al locale corrente.
6
+ * Una volta completata la chiamata HTTP, aggiorna automaticamente lo store interno tramite il metodo setTranslations.
7
+ */
8
+ static fetchTranslation(uniLocale: Locale): Promise<void>;
2
9
  /**
3
10
  * Registra i dati specifici del locale nel framework Angular.
4
11
  * Necessario per garantire che le pipe built-in (es. DatePipe, CurrencyPipe) operino secondo le convenzioni del paese corrente.
5
12
  */
6
- static setLocaleAngular(currentLocale: string): void;
13
+ static setLocaleAngular(uniLocale: Locale): void;
7
14
  /**
8
15
  * Inizializza la localizzazione specifica per i componenti DevExtreme.
9
16
  * Imposta il locale per le formattazioni native dei widget e carica i file di messaggi JSON per la traduzione dei testi di sistema.
10
17
  */
11
- static setLocaleDevextreme(currentLocale: string): void;
12
- /**
13
- * Recupera il dizionario delle traduzioni dal server remoto in base al locale corrente.
14
- * Una volta completata la chiamata HTTP, aggiorna automaticamente lo store interno
15
- * tramite il metodo setTranslations.
16
- */
17
- static fetchTranslation(currentLocale: string): Promise<void>;
18
+ static setLocaleDevextreme(uniLocale: Locale): void;
18
19
  }
19
20
 
20
21
  export { UniLocaleManagerAngular };