ngx-dsxlibrary 1.21.37 → 1.21.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/ngx-dsxlibrary-src-lib-utils.mjs +51 -0
- package/fesm2022/ngx-dsxlibrary-src-lib-utils.mjs.map +1 -0
- package/fesm2022/ngx-dsxlibrary.mjs +87 -4
- package/fesm2022/ngx-dsxlibrary.mjs.map +1 -1
- package/ngx-dsxlibrary-1.21.39.tgz +0 -0
- package/package.json +5 -1
- package/types/ngx-dsxlibrary-src-lib-utils.d.ts +34 -0
- package/types/ngx-dsxlibrary.d.ts +43 -4
- package/ngx-dsxlibrary-1.21.37.tgz +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formateador de moneda por defecto para Guatemala.
|
|
3
|
+
*
|
|
4
|
+
* Usa la configuración regional `es-GT` y el código de moneda `GTQ`.
|
|
5
|
+
* Siempre muestra 2 decimales.
|
|
6
|
+
*
|
|
7
|
+
* Ejemplo de uso:
|
|
8
|
+
* ```ts
|
|
9
|
+
* GTQFormatter.format(1234.5); // "Q 1,234.50"
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
const GTQFormatter = new Intl.NumberFormat('es-GT', {
|
|
13
|
+
style: 'currency',
|
|
14
|
+
currency: 'GTQ',
|
|
15
|
+
minimumFractionDigits: 2,
|
|
16
|
+
maximumFractionDigits: 2,
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Crea un formateador de moneda personalizado.
|
|
20
|
+
*
|
|
21
|
+
* Permite definir la configuración regional (`locale`) y el código de moneda (`currency`)
|
|
22
|
+
* manteniendo 2 decimales fijos.
|
|
23
|
+
*
|
|
24
|
+
* Ejemplos de uso:
|
|
25
|
+
* ```ts
|
|
26
|
+
* const usdFormatter = createCurrencyFormatter('en-US', 'USD');
|
|
27
|
+
* usdFormatter.format(1000); // "$1,000.00"
|
|
28
|
+
*
|
|
29
|
+
* const mxnFormatter = createCurrencyFormatter('es-MX', 'MXN');
|
|
30
|
+
* mxnFormatter.format(1500.75); // "$1,500.75"
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param locale Código de configuración regional, por ejemplo: `es-GT`, `en-US`.
|
|
34
|
+
* @param currency Código de moneda ISO 4217, por ejemplo: `GTQ`, `USD`, `EUR`.
|
|
35
|
+
* @returns Instancia de `Intl.NumberFormat` configurada para moneda.
|
|
36
|
+
*/
|
|
37
|
+
function createCurrencyFormatter(locale, currency) {
|
|
38
|
+
return new Intl.NumberFormat(locale, {
|
|
39
|
+
style: 'currency',
|
|
40
|
+
currency,
|
|
41
|
+
minimumFractionDigits: 2,
|
|
42
|
+
maximumFractionDigits: 2,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Generated bundle index. Do not edit.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
export { GTQFormatter, createCurrencyFormatter };
|
|
51
|
+
//# sourceMappingURL=ngx-dsxlibrary-src-lib-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-dsxlibrary-src-lib-utils.mjs","sources":["../../../projects/ngx-dsx/src/lib/utils/currency.util.ts","../../../projects/ngx-dsx/src/lib/utils/ngx-dsxlibrary-src-lib-utils.ts"],"sourcesContent":["/**\r\n * Formateador de moneda por defecto para Guatemala.\r\n *\r\n * Usa la configuración regional `es-GT` y el código de moneda `GTQ`.\r\n * Siempre muestra 2 decimales.\r\n *\r\n * Ejemplo de uso:\r\n * ```ts\r\n * GTQFormatter.format(1234.5); // \"Q 1,234.50\"\r\n * ```\r\n */\r\nexport const GTQFormatter = new Intl.NumberFormat('es-GT', {\r\n style: 'currency',\r\n currency: 'GTQ',\r\n minimumFractionDigits: 2,\r\n maximumFractionDigits: 2,\r\n});\r\n\r\n/**\r\n * Crea un formateador de moneda personalizado.\r\n *\r\n * Permite definir la configuración regional (`locale`) y el código de moneda (`currency`)\r\n * manteniendo 2 decimales fijos.\r\n *\r\n * Ejemplos de uso:\r\n * ```ts\r\n * const usdFormatter = createCurrencyFormatter('en-US', 'USD');\r\n * usdFormatter.format(1000); // \"$1,000.00\"\r\n *\r\n * const mxnFormatter = createCurrencyFormatter('es-MX', 'MXN');\r\n * mxnFormatter.format(1500.75); // \"$1,500.75\"\r\n * ```\r\n *\r\n * @param locale Código de configuración regional, por ejemplo: `es-GT`, `en-US`.\r\n * @param currency Código de moneda ISO 4217, por ejemplo: `GTQ`, `USD`, `EUR`.\r\n * @returns Instancia de `Intl.NumberFormat` configurada para moneda.\r\n */\r\nexport function createCurrencyFormatter(\r\n locale: string,\r\n currency: string,\r\n): Intl.NumberFormat {\r\n return new Intl.NumberFormat(locale, {\r\n style: 'currency',\r\n currency,\r\n minimumFractionDigits: 2,\r\n maximumFractionDigits: 2,\r\n });\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;;;;;;;;;AAUG;AACI,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;AACzD,IAAA,KAAK,EAAE,UAAU;AACjB,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,qBAAqB,EAAE,CAAC;AACxB,IAAA,qBAAqB,EAAE,CAAC;AACzB,CAAA;AAED;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,uBAAuB,CACrC,MAAc,EACd,QAAgB,EAAA;AAEhB,IAAA,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;AACnC,QAAA,KAAK,EAAE,UAAU;QACjB,QAAQ;AACR,QAAA,qBAAqB,EAAE,CAAC;AACxB,QAAA,qBAAqB,EAAE,CAAC;AACzB,KAAA,CAAC;AACJ;;AC/CA;;AAEG;;;;"}
|
|
@@ -1352,17 +1352,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
1352
1352
|
* - Dígitos (0-9)
|
|
1353
1353
|
* - Separadores punto (.)
|
|
1354
1354
|
* - Rango con guión (-)
|
|
1355
|
+
* - O bien un comodín completo "*" que representa "todos"
|
|
1355
1356
|
*
|
|
1356
1357
|
* Ejemplos válidos:
|
|
1357
1358
|
* - 1.2.3
|
|
1358
1359
|
* - 4-6
|
|
1359
1360
|
* - 1.3.5-9
|
|
1361
|
+
* - * (comodín: todos)
|
|
1360
1362
|
*
|
|
1361
1363
|
* Restringe:
|
|
1362
1364
|
* - Letras
|
|
1363
1365
|
* - Espacios
|
|
1364
|
-
* - Caracteres especiales
|
|
1366
|
+
* - Caracteres especiales (salvo "*")
|
|
1365
1367
|
* - Doble punto (..), doble guión (--), o combinaciones como (.-)
|
|
1368
|
+
* - Mezclas de comodín con números (por ejemplo: *1, 1.*)
|
|
1366
1369
|
*/
|
|
1367
1370
|
class OnlyRangoPatternDirective {
|
|
1368
1371
|
el;
|
|
@@ -1381,6 +1384,9 @@ class OnlyRangoPatternDirective {
|
|
|
1381
1384
|
const input = this.el.nativeElement;
|
|
1382
1385
|
const currentValue = input.value;
|
|
1383
1386
|
const cursorPos = input.selectionStart ?? 0;
|
|
1387
|
+
const selectionStart = input.selectionStart ?? 0;
|
|
1388
|
+
const selectionEnd = input.selectionEnd ?? 0;
|
|
1389
|
+
const hasFullSelection = selectionStart === 0 && selectionEnd === currentValue.length;
|
|
1384
1390
|
const nextValue = currentValue.slice(0, cursorPos) +
|
|
1385
1391
|
event.key +
|
|
1386
1392
|
currentValue.slice(cursorPos);
|
|
@@ -1395,6 +1401,22 @@ class OnlyRangoPatternDirective {
|
|
|
1395
1401
|
];
|
|
1396
1402
|
if (allowedKeys.includes(event.key))
|
|
1397
1403
|
return;
|
|
1404
|
+
// Si ya hay comodín "*" sin selección completa, no se permiten más caracteres
|
|
1405
|
+
// (solo borrar/navegar). Si todo el texto está seleccionado, se permite
|
|
1406
|
+
// sobrescribirlo.
|
|
1407
|
+
if (currentValue === '*' && !hasFullSelection) {
|
|
1408
|
+
event.preventDefault();
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
// Permitir comodín "*" si el campo está vacío o si todo el contenido
|
|
1412
|
+
// está seleccionado (para poder reemplazar rápidamente los números).
|
|
1413
|
+
if (event.key === '*') {
|
|
1414
|
+
if (!currentValue || hasFullSelection) {
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
event.preventDefault();
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1398
1420
|
if (!this.keyRegex.test(event.key)) {
|
|
1399
1421
|
event.preventDefault();
|
|
1400
1422
|
return;
|
|
@@ -1416,6 +1438,10 @@ class OnlyRangoPatternDirective {
|
|
|
1416
1438
|
onPaste(event) {
|
|
1417
1439
|
const pasted = event.clipboardData?.getData('text') ?? '';
|
|
1418
1440
|
const sanitized = pasted.trim();
|
|
1441
|
+
// Permitir comodín completo "*" pegado
|
|
1442
|
+
if (sanitized === '*') {
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1419
1445
|
// Patrón completo de cadena válida: ej. 1.2.3.4-6
|
|
1420
1446
|
const pattern = /^(\d+(-\d+)?)(\.\d+(-\d+)?)*$/;
|
|
1421
1447
|
if (!pattern.test(sanitized)) {
|
|
@@ -2761,7 +2787,10 @@ class UtilityAddService {
|
|
|
2761
2787
|
* Adaptador para procesar eventos de input y extraer rangos numéricos.
|
|
2762
2788
|
*
|
|
2763
2789
|
* @param event - Objeto Event del DOM, preferiblemente de un elemento input
|
|
2764
|
-
* @returns
|
|
2790
|
+
* @returns
|
|
2791
|
+
* - Array de números generado a partir del valor del input, cuando hay
|
|
2792
|
+
* números/rangos.
|
|
2793
|
+
* - El carácter comodín "*" cuando el valor del input es exactamente "*".
|
|
2765
2794
|
*
|
|
2766
2795
|
* @example
|
|
2767
2796
|
* // Uso en template Angular
|
|
@@ -2782,7 +2811,16 @@ class UtilityAddService {
|
|
|
2782
2811
|
* Para otros tipos de eventos (ej. Angular Material) puede necesitar ajustes
|
|
2783
2812
|
*/
|
|
2784
2813
|
processNumericRangesFromEvent(event) {
|
|
2785
|
-
const
|
|
2814
|
+
const rawValue = event.target.value ?? '';
|
|
2815
|
+
const inputValue = rawValue.trim();
|
|
2816
|
+
// Si el valor es exactamente el comodín "*", lo devolvemos tal cual
|
|
2817
|
+
// para que el consumidor pueda interpretarlo como "todos".
|
|
2818
|
+
if (inputValue === '*') {
|
|
2819
|
+
return '*';
|
|
2820
|
+
}
|
|
2821
|
+
// Para mezclas de números y asteriscos, parseNumericRanges elimina
|
|
2822
|
+
// cualquier carácter no numérico/rango (como "*"), dando prioridad
|
|
2823
|
+
// a los números y omitiendo el comodín.
|
|
2786
2824
|
return this.parseNumericRanges(inputValue);
|
|
2787
2825
|
}
|
|
2788
2826
|
/**
|
|
@@ -2845,6 +2883,51 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
2845
2883
|
}]
|
|
2846
2884
|
}] });
|
|
2847
2885
|
|
|
2886
|
+
/**
|
|
2887
|
+
* Formateador de moneda por defecto para Guatemala.
|
|
2888
|
+
*
|
|
2889
|
+
* Usa la configuración regional `es-GT` y el código de moneda `GTQ`.
|
|
2890
|
+
* Siempre muestra 2 decimales.
|
|
2891
|
+
*
|
|
2892
|
+
* Ejemplo de uso:
|
|
2893
|
+
* ```ts
|
|
2894
|
+
* GTQFormatter.format(1234.5); // "Q 1,234.50"
|
|
2895
|
+
* ```
|
|
2896
|
+
*/
|
|
2897
|
+
const GTQFormatter = new Intl.NumberFormat('es-GT', {
|
|
2898
|
+
style: 'currency',
|
|
2899
|
+
currency: 'GTQ',
|
|
2900
|
+
minimumFractionDigits: 2,
|
|
2901
|
+
maximumFractionDigits: 2,
|
|
2902
|
+
});
|
|
2903
|
+
/**
|
|
2904
|
+
* Crea un formateador de moneda personalizado.
|
|
2905
|
+
*
|
|
2906
|
+
* Permite definir la configuración regional (`locale`) y el código de moneda (`currency`)
|
|
2907
|
+
* manteniendo 2 decimales fijos.
|
|
2908
|
+
*
|
|
2909
|
+
* Ejemplos de uso:
|
|
2910
|
+
* ```ts
|
|
2911
|
+
* const usdFormatter = createCurrencyFormatter('en-US', 'USD');
|
|
2912
|
+
* usdFormatter.format(1000); // "$1,000.00"
|
|
2913
|
+
*
|
|
2914
|
+
* const mxnFormatter = createCurrencyFormatter('es-MX', 'MXN');
|
|
2915
|
+
* mxnFormatter.format(1500.75); // "$1,500.75"
|
|
2916
|
+
* ```
|
|
2917
|
+
*
|
|
2918
|
+
* @param locale Código de configuración regional, por ejemplo: `es-GT`, `en-US`.
|
|
2919
|
+
* @param currency Código de moneda ISO 4217, por ejemplo: `GTQ`, `USD`, `EUR`.
|
|
2920
|
+
* @returns Instancia de `Intl.NumberFormat` configurada para moneda.
|
|
2921
|
+
*/
|
|
2922
|
+
function createCurrencyFormatter(locale, currency) {
|
|
2923
|
+
return new Intl.NumberFormat(locale, {
|
|
2924
|
+
style: 'currency',
|
|
2925
|
+
currency,
|
|
2926
|
+
minimumFractionDigits: 2,
|
|
2927
|
+
maximumFractionDigits: 2,
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2848
2931
|
/**
|
|
2849
2932
|
* Valida que el control contenga un rango de fechas válido (dos fechas no nulas y válidas).
|
|
2850
2933
|
*/
|
|
@@ -3126,5 +3209,5 @@ function CUICorrecto(cui) {
|
|
|
3126
3209
|
* Generated bundle index. Do not edit.
|
|
3127
3210
|
*/
|
|
3128
3211
|
|
|
3129
|
-
export { AlertaService, AppMessageErrorComponent, AuthorizeService, CACHE_KEYS, CacheService, CssV2Component, DsxAddToolsModule, DteService, ENVIRONMENT, EndpointService, ErrorHandlerService, FileComponent, INITIAL_PARAMETERS, IconDsxComponent, JsonHighlightPipe, JsonValuesDebujComponent, KpicardComponent, LoadingComponent, LoadingLottieComponent, NavbarDsxComponent, OnlyRangoPatternDirective, ParameterValuesService, PrimeNgModule, SWEET_ALERT_THEMES, SecurityService, SelectAllOnFocusDirective, SpinnerLoadingService, TruncatePipe, UtilityAddService, atLeastOneFieldRequiredValidator, createInitialCache, createTypedCacheProvider, cuiValidator, dateMinMaxValidator, dateRangeValidator, dateRangeValidatorFromTo, httpAuthorizeInterceptor, nitValidator, provideEnvironment, validateEnvironmentConfig };
|
|
3212
|
+
export { AlertaService, AppMessageErrorComponent, AuthorizeService, CACHE_KEYS, CacheService, CssV2Component, DsxAddToolsModule, DteService, ENVIRONMENT, EndpointService, ErrorHandlerService, FileComponent, GTQFormatter, INITIAL_PARAMETERS, IconDsxComponent, JsonHighlightPipe, JsonValuesDebujComponent, KpicardComponent, LoadingComponent, LoadingLottieComponent, NavbarDsxComponent, OnlyRangoPatternDirective, ParameterValuesService, PrimeNgModule, SWEET_ALERT_THEMES, SecurityService, SelectAllOnFocusDirective, SpinnerLoadingService, TruncatePipe, UtilityAddService, atLeastOneFieldRequiredValidator, createCurrencyFormatter, createInitialCache, createTypedCacheProvider, cuiValidator, dateMinMaxValidator, dateRangeValidator, dateRangeValidatorFromTo, httpAuthorizeInterceptor, nitValidator, provideEnvironment, validateEnvironmentConfig };
|
|
3130
3213
|
//# sourceMappingURL=ngx-dsxlibrary.mjs.map
|