ngx-dsxlibrary 1.21.37 → 1.21.38
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.
|
@@ -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
|
/**
|