ngx-dsxlibrary 1.21.36 → 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 Array de números generado a partir del valor del input
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 inputValue = event.target.value;
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
  /**
@@ -2871,6 +2909,55 @@ function dateRangeValidator(control) {
2871
2909
  }
2872
2910
  return null; // Si el control no contiene un array válido, no hay error
2873
2911
  }
2912
+ /**
2913
+ * Validador a nivel de formulario que verifica que la fecha "hasta"
2914
+ * (toKey) sea mayor o igual que la fecha "desde" (fromKey),
2915
+ * comparando ambas como instancias de Date.
2916
+ *
2917
+ * Reglas:
2918
+ * - Si una o ambas fechas están vacías (null/undefined), no se genera error
2919
+ * y se delega la obligatoriedad a otros validadores como `required`.
2920
+ * - Si ambas fechas tienen valor, la fecha "hasta" debe ser >= fecha "desde"
2921
+ * según su valor numérico (`getTime()`).
2922
+ * - Si los valores no son fechas válidas, el comportamiento dependerá
2923
+ * de cómo los controles entreguen el valor (se recomienda usar Date).
2924
+ *
2925
+ * @param fromKey Nombre del control que representa la fecha inicial.
2926
+ * @param toKey Nombre del control que representa la fecha final.
2927
+ * @returns Un ValidatorFn que devuelve `null` si el rango es válido o está
2928
+ * incompleto; y un objeto con la clave `invalidDateRange` si el
2929
+ * rango es inválido.
2930
+ */
2931
+ function dateRangeValidatorFromTo(fromKey, toKey) {
2932
+ return (group) => {
2933
+ const fromControl = group.get(fromKey);
2934
+ const toControl = group.get(toKey);
2935
+ const from = fromControl?.value;
2936
+ const to = toControl?.value;
2937
+ if (!from || !to)
2938
+ return null;
2939
+ // Rango válido: limpiar error en el control "hasta" si existe
2940
+ if (to.getTime() >= from.getTime()) {
2941
+ if (toControl && toControl.errors?.['invalidDateRange']) {
2942
+ const { invalidDateRange, ...rest } = toControl.errors;
2943
+ toControl.setErrors(Object.keys(rest).length ? rest : null);
2944
+ }
2945
+ return null;
2946
+ }
2947
+ // Rango inválido: asignar error tanto al grupo como al control "hasta"
2948
+ const error = {
2949
+ invalidDateRange: {
2950
+ message: 'La fecha final debe ser mayor o igual que la fecha inicial.',
2951
+ requiredLength: 2,
2952
+ },
2953
+ };
2954
+ if (toControl) {
2955
+ const currentErrors = toControl.errors || {};
2956
+ toControl.setErrors({ ...currentErrors, ...error });
2957
+ }
2958
+ return error;
2959
+ };
2960
+ }
2874
2961
  /**
2875
2962
  * Valida que una fecha única esté dentro de un rango mínimo y máximo.
2876
2963
  * Las fechas deben utilizar la función de convertirFechaISOString para asegurar el formato correcto y que funcione con el componente primeNg.
@@ -3077,5 +3164,5 @@ function CUICorrecto(cui) {
3077
3164
  * Generated bundle index. Do not edit.
3078
3165
  */
3079
3166
 
3080
- 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, httpAuthorizeInterceptor, nitValidator, provideEnvironment, validateEnvironmentConfig };
3167
+ 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 };
3081
3168
  //# sourceMappingURL=ngx-dsxlibrary.mjs.map