@senior-agronegocio/angular-components 0.0.9865 → 0.0.9867

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.
Files changed (68) hide show
  1. package/bundles/senior-agronegocio-angular-components.umd.js +601 -168
  2. package/bundles/senior-agronegocio-angular-components.umd.js.map +1 -1
  3. package/bundles/senior-agronegocio-angular-components.umd.min.js +2 -2
  4. package/bundles/senior-agronegocio-angular-components.umd.min.js.map +1 -1
  5. package/common/agro-object-stringifier.class.d.ts +16 -0
  6. package/common/agro-regex.constant.d.ts +3 -0
  7. package/common/agro-string-utils.class.d.ts +8 -0
  8. package/components/event-control-board/event-control-board.component.d.ts +4 -5
  9. package/components/event-control-board/service/event-control/event-control.service.d.ts +0 -20
  10. package/components/financial-title-table/financial-title-table.component.d.ts +65 -3
  11. package/esm2015/common/agro-object-stringifier.class.js +31 -0
  12. package/esm2015/common/agro-platform-utils.class.js +8 -7
  13. package/esm2015/common/agro-regex.constant.js +5 -2
  14. package/esm2015/common/agro-string-utils.class.js +89 -11
  15. package/esm2015/components/event-control-board/event-control-board.component.js +77 -58
  16. package/esm2015/components/event-control-board/service/event-control/event-control.service.js +1 -5
  17. package/esm2015/components/financial-title-table/financial-title-table.component.js +196 -82
  18. package/esm2015/pipe/cnpj-cpf/cnpj-cpf.pipe.js +28 -0
  19. package/esm2015/pipe/cnpj-cpf/cnpj-cpf.pipe.module.js +15 -0
  20. package/esm2015/pipe/cnpj-cpf/index.js +3 -0
  21. package/esm2015/pipe/index.js +4 -1
  22. package/esm2015/pipe/stringifier/index.js +3 -0
  23. package/esm2015/pipe/stringifier/stringifier.pipe.js +13 -0
  24. package/esm2015/pipe/stringifier/stringifier.pipe.module.js +15 -0
  25. package/esm2015/pipe/telephone/index.js +3 -0
  26. package/esm2015/pipe/telephone/telephone.pipe.js +91 -0
  27. package/esm2015/pipe/telephone/telephone.pipe.module.js +15 -0
  28. package/esm2015/public-api.js +3 -3
  29. package/esm2015/senior-agronegocio-angular-components.js +3 -2
  30. package/esm2015/services/lib-translation.service.js +2 -2
  31. package/esm5/common/agro-object-stringifier.class.js +35 -0
  32. package/esm5/common/agro-platform-utils.class.js +8 -7
  33. package/esm5/common/agro-regex.constant.js +5 -2
  34. package/esm5/common/agro-string-utils.class.js +106 -17
  35. package/esm5/components/event-control-board/event-control-board.component.js +77 -59
  36. package/esm5/components/event-control-board/service/event-control/event-control.service.js +1 -5
  37. package/esm5/components/financial-title-table/financial-title-table.component.js +198 -83
  38. package/esm5/pipe/cnpj-cpf/cnpj-cpf.pipe.js +35 -0
  39. package/esm5/pipe/cnpj-cpf/cnpj-cpf.pipe.module.js +18 -0
  40. package/esm5/pipe/cnpj-cpf/index.js +3 -0
  41. package/esm5/pipe/index.js +4 -1
  42. package/esm5/pipe/stringifier/index.js +3 -0
  43. package/esm5/pipe/stringifier/stringifier.pipe.js +16 -0
  44. package/esm5/pipe/stringifier/stringifier.pipe.module.js +18 -0
  45. package/esm5/pipe/telephone/index.js +3 -0
  46. package/esm5/pipe/telephone/telephone.pipe.js +95 -0
  47. package/esm5/pipe/telephone/telephone.pipe.module.js +18 -0
  48. package/esm5/public-api.js +3 -3
  49. package/esm5/senior-agronegocio-angular-components.js +3 -2
  50. package/esm5/services/lib-translation.service.js +2 -2
  51. package/fesm2015/senior-agronegocio-angular-components.js +550 -161
  52. package/fesm2015/senior-agronegocio-angular-components.js.map +1 -1
  53. package/fesm5/senior-agronegocio-angular-components.js +594 -168
  54. package/fesm5/senior-agronegocio-angular-components.js.map +1 -1
  55. package/package.json +7 -55
  56. package/pipe/cnpj-cpf/cnpj-cpf.pipe.d.ts +4 -0
  57. package/pipe/cnpj-cpf/cnpj-cpf.pipe.module.d.ts +2 -0
  58. package/pipe/cnpj-cpf/index.d.ts +2 -0
  59. package/pipe/index.d.ts +3 -0
  60. package/pipe/stringifier/index.d.ts +2 -0
  61. package/pipe/stringifier/stringifier.pipe.d.ts +9 -0
  62. package/pipe/stringifier/stringifier.pipe.module.d.ts +2 -0
  63. package/pipe/telephone/index.d.ts +2 -0
  64. package/pipe/telephone/telephone.pipe.d.ts +21 -0
  65. package/pipe/telephone/telephone.pipe.module.d.ts +2 -0
  66. package/public-api.d.ts +2 -2
  67. package/senior-agronegocio-angular-components.d.ts +2 -1
  68. package/senior-agronegocio-angular-components.metadata.json +1 -1
@@ -360,7 +360,10 @@
360
360
  * Validação de Placa de Veículo Antiga
361
361
  * Formato: AAA-0000
362
362
  */
363
- isOldLicensePlate: /^[A-Z]{3}[0-9]{4}$/
363
+ isOldLicensePlate: /^[A-Z]{3}\d{4}$/,
364
+ isISODate: /^\d{4}-\d{2}-\d{2}$/,
365
+ isISOTime: /^\d{2}:\d{2}:\d{2}$/,
366
+ isISODateTime: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/,
364
367
  };
365
368
 
366
369
 
@@ -2290,13 +2293,19 @@
2290
2293
  */
2291
2294
  AgroStringUtils.isEmpty = function (str) {
2292
2295
  var _a;
2293
- return !str || ((_a = str.trim()) === null || _a === void 0 ? void 0 : _a.length) === exports.AGRO_NUMBERS.ZERO;
2296
+ if (str && AgroStringUtils.isString(str)) {
2297
+ return ((_a = str === null || str === void 0 ? void 0 : str.trim()) === null || _a === void 0 ? void 0 : _a.length) === exports.AGRO_NUMBERS.ZERO;
2298
+ }
2299
+ return true;
2294
2300
  };
2295
2301
  /**
2296
2302
  * Verifica se a string não está vazia.
2297
2303
  */
2298
2304
  AgroStringUtils.isNotEmpty = function (str) {
2299
- return !AgroStringUtils.isEmpty(str);
2305
+ if (str && AgroStringUtils.isString(str)) {
2306
+ return !AgroStringUtils.isEmpty(str);
2307
+ }
2308
+ return false;
2300
2309
  };
2301
2310
  /** Verifica se a string é nula, indefinida ou contém apenas espaços em branco */
2302
2311
  AgroStringUtils.isBlank = function (str) {
@@ -2351,7 +2360,7 @@
2351
2360
  return AGRO_REGEX.isUUID.test(str);
2352
2361
  };
2353
2362
  AgroStringUtils.isNumber = function (str) {
2354
- return AGRO_REGEX.isNumber.test(str);
2363
+ return [AGRO_REGEX.isNumber.test(str), AGRO_REGEX.isDecimal.test(str)].includes(true);
2355
2364
  };
2356
2365
  AgroStringUtils.validateCPF = function (cpf) {
2357
2366
  cpf = cpf.replace(/\D/g, "");
@@ -2368,7 +2377,7 @@
2368
2377
  };
2369
2378
  var digit1 = calcVerifier(cpf, exports.AGRO_NUMBERS.NINE);
2370
2379
  var digit2 = calcVerifier(cpf, exports.AGRO_NUMBERS.TEN);
2371
- return digit1 === parseInt(cpf[exports.AGRO_NUMBERS.NINE], exports.AGRO_NUMBERS.TEN) && digit2 === parseInt(cpf[exports.AGRO_NUMBERS.TEN], exports.AGRO_NUMBERS.TEN);
2380
+ return (digit1 === parseInt(cpf[exports.AGRO_NUMBERS.NINE], exports.AGRO_NUMBERS.TEN) && digit2 === parseInt(cpf[exports.AGRO_NUMBERS.TEN], exports.AGRO_NUMBERS.TEN));
2372
2381
  };
2373
2382
  /**
2374
2383
  * Detecta automaticamente se é CNPJ antigo ou novo formato.
@@ -2411,7 +2420,8 @@
2411
2420
  }
2412
2421
  resto = soma % exports.AGRO_NUMBERS.ELEVEN;
2413
2422
  var digito2 = resto < exports.AGRO_NUMBERS.TWO ? exports.AGRO_NUMBERS.ZERO : exports.AGRO_NUMBERS.ELEVEN - resto;
2414
- return parseInt(cnpj.charAt(exports.AGRO_NUMBERS.TWELVE), exports.AGRO_NUMBERS.TEN) === digito1 && parseInt(cnpj.charAt(exports.AGRO_NUMBERS.THIRTEEN), exports.AGRO_NUMBERS.TEN) === digito2;
2423
+ return (parseInt(cnpj.charAt(exports.AGRO_NUMBERS.TWELVE), exports.AGRO_NUMBERS.TEN) === digito1 &&
2424
+ parseInt(cnpj.charAt(exports.AGRO_NUMBERS.THIRTEEN), exports.AGRO_NUMBERS.TEN) === digito2);
2415
2425
  };
2416
2426
  /**
2417
2427
  * Valida o CNPJ em formato alfanumérico (padrão 2026)
@@ -2507,20 +2517,93 @@
2507
2517
  var matches = str.match(regex);
2508
2518
  return matches ? matches.length : exports.AGRO_NUMBERS.ZERO;
2509
2519
  };
2520
+ /**
2521
+ * Remove uma máscara simples da string fornecida.O padrão de máscaras é definido pelo enum AgroStringMasks ou
2522
+ * pode ser uma string personalizada onde '9' representa um dígito a ser mantido da string.
2523
+ */
2524
+ AgroStringUtils.removeMask = function (value, mask) {
2525
+ var e_1, _a;
2526
+ if (!value || !mask) {
2527
+ return value;
2528
+ }
2529
+ var valueChars = value.toString().split("");
2530
+ var maskChars = mask.split("");
2531
+ var unmaskedValue = "";
2532
+ var j = 0;
2533
+ var isDigit = function (c) { return /\d/.test(c); };
2534
+ var isAlpha = function (c) { return /[A-Za-z]/.test(c); };
2535
+ var isAlnum = function (c) { return /[A-Za-z0-9]/.test(c); };
2536
+ var extractNext = function (testFn) {
2537
+ var k = j;
2538
+ while (k < valueChars.length && !testFn(valueChars[k])) {
2539
+ k++;
2540
+ }
2541
+ if (k < valueChars.length) {
2542
+ var found = valueChars[k];
2543
+ j = k + 1;
2544
+ return found;
2545
+ }
2546
+ var fallback = valueChars[j];
2547
+ j++;
2548
+ return fallback;
2549
+ };
2550
+ var processMaskChar = function (maskChar) {
2551
+ var _a, _b;
2552
+ if (j >= valueChars.length) {
2553
+ return;
2554
+ }
2555
+ var current = valueChars[j];
2556
+ switch (maskChar) {
2557
+ case "9":
2558
+ unmaskedValue += (_a = extractNext(isDigit)) !== null && _a !== void 0 ? _a : "";
2559
+ break;
2560
+ case "A":
2561
+ unmaskedValue += (_b = extractNext(isAlpha)) !== null && _b !== void 0 ? _b : "";
2562
+ break;
2563
+ default:
2564
+ handleSeparator(maskChar, current);
2565
+ break;
2566
+ }
2567
+ };
2568
+ var handleSeparator = function (maskChar, current) {
2569
+ if (current === maskChar) {
2570
+ j++; // separador presente no valor
2571
+ }
2572
+ if (isAlnum(current)) {
2573
+ unmaskedValue += current;
2574
+ j++;
2575
+ }
2576
+ // se for pontuação diferente, apenas ignora (não consome j)
2577
+ };
2578
+ try {
2579
+ for (var maskChars_1 = __values(maskChars), maskChars_1_1 = maskChars_1.next(); !maskChars_1_1.done; maskChars_1_1 = maskChars_1.next()) {
2580
+ var maskChar = maskChars_1_1.value;
2581
+ processMaskChar(maskChar);
2582
+ }
2583
+ }
2584
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2585
+ finally {
2586
+ try {
2587
+ if (maskChars_1_1 && !maskChars_1_1.done && (_a = maskChars_1.return)) _a.call(maskChars_1);
2588
+ }
2589
+ finally { if (e_1) throw e_1.error; }
2590
+ }
2591
+ return unmaskedValue;
2592
+ };
2510
2593
  /**
2511
2594
  * Aplica uma máscara simples à string fornecida.O padrão de máscaras é definido pelo enum AgroStringMasks ou
2512
2595
  * pode ser uma string personalizada onde '9' representa um dígito a ser substituído pelo caractere correspondente
2513
2596
  * da string.
2514
2597
  */
2515
2598
  AgroStringUtils.applyMask = function (value, mask) {
2516
- var e_1, _a;
2517
- var valueChars = value.toString().split("");
2599
+ var e_2, _a;
2600
+ var valueChars = AgroStringUtils.removeMask(value, mask).toString().split("");
2518
2601
  var maskChars = mask.split("");
2519
2602
  var maskedValue = "";
2520
2603
  var j = exports.AGRO_NUMBERS.ZERO;
2521
2604
  try {
2522
- for (var maskChars_1 = __values(maskChars), maskChars_1_1 = maskChars_1.next(); !maskChars_1_1.done; maskChars_1_1 = maskChars_1.next()) {
2523
- var maskChar = maskChars_1_1.value;
2605
+ for (var maskChars_2 = __values(maskChars), maskChars_2_1 = maskChars_2.next(); !maskChars_2_1.done; maskChars_2_1 = maskChars_2.next()) {
2606
+ var maskChar = maskChars_2_1.value;
2524
2607
  if (j >= valueChars.length) {
2525
2608
  break;
2526
2609
  }
@@ -2533,12 +2616,12 @@
2533
2616
  }
2534
2617
  }
2535
2618
  }
2536
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2619
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2537
2620
  finally {
2538
2621
  try {
2539
- if (maskChars_1_1 && !maskChars_1_1.done && (_a = maskChars_1.return)) _a.call(maskChars_1);
2622
+ if (maskChars_2_1 && !maskChars_2_1.done && (_a = maskChars_2.return)) _a.call(maskChars_2);
2540
2623
  }
2541
- finally { if (e_1) throw e_1.error; }
2624
+ finally { if (e_2) throw e_2.error; }
2542
2625
  }
2543
2626
  return maskedValue;
2544
2627
  };
@@ -2548,6 +2631,15 @@
2548
2631
  AgroStringUtils.isInvalid = function (str) {
2549
2632
  return !AgroStringUtils.isValid(str);
2550
2633
  };
2634
+ AgroStringUtils.isISODate = function (value) {
2635
+ return AGRO_REGEX.isISODate.test(value);
2636
+ };
2637
+ AgroStringUtils.isISOTime = function (value) {
2638
+ return AGRO_REGEX.isISOTime.test(value);
2639
+ };
2640
+ AgroStringUtils.isISODatetime = function (value) {
2641
+ return AGRO_REGEX.isISODateTime.test(value);
2642
+ };
2551
2643
  AgroStringUtils.CNPJ_TRADICIONAL_PESOS_1 = [
2552
2644
  exports.AGRO_NUMBERS.FIVE,
2553
2645
  exports.AGRO_NUMBERS.FOUR,
@@ -2560,7 +2652,7 @@
2560
2652
  exports.AGRO_NUMBERS.FIVE,
2561
2653
  exports.AGRO_NUMBERS.FOUR,
2562
2654
  exports.AGRO_NUMBERS.THREE,
2563
- exports.AGRO_NUMBERS.TWO
2655
+ exports.AGRO_NUMBERS.TWO,
2564
2656
  ];
2565
2657
  AgroStringUtils.CNPJ_TRADICIONAL_PESOS_2 = [
2566
2658
  exports.AGRO_NUMBERS.SIX,
@@ -2575,7 +2667,7 @@
2575
2667
  exports.AGRO_NUMBERS.FIVE,
2576
2668
  exports.AGRO_NUMBERS.FOUR,
2577
2669
  exports.AGRO_NUMBERS.THREE,
2578
- exports.AGRO_NUMBERS.TWO
2670
+ exports.AGRO_NUMBERS.TWO,
2579
2671
  ];
2580
2672
  // Pesos utilizados para cálculo de dígitos verificadores do CNPJ alfanumérico (2026)
2581
2673
  AgroStringUtils.CNPJ_ALFANUMERICO_PESOS_1 = [
@@ -2590,7 +2682,7 @@
2590
2682
  exports.AGRO_NUMBERS.FIVE,
2591
2683
  exports.AGRO_NUMBERS.FOUR,
2592
2684
  exports.AGRO_NUMBERS.THREE,
2593
- exports.AGRO_NUMBERS.TWO
2685
+ exports.AGRO_NUMBERS.TWO,
2594
2686
  ];
2595
2687
  AgroStringUtils.CNPJ_ALFANUMERICO_PESOS_2 = [
2596
2688
  exports.AGRO_NUMBERS.SIX,
@@ -2605,7 +2697,7 @@
2605
2697
  exports.AGRO_NUMBERS.FIVE,
2606
2698
  exports.AGRO_NUMBERS.FOUR,
2607
2699
  exports.AGRO_NUMBERS.THREE,
2608
- exports.AGRO_NUMBERS.TWO
2700
+ exports.AGRO_NUMBERS.TWO,
2609
2701
  ];
2610
2702
  return AgroStringUtils;
2611
2703
  }());
@@ -2623,7 +2715,7 @@
2623
2715
  * @returns
2624
2716
  */
2625
2717
  AgroPlatformUtils.getCurrentTenant = function () {
2626
- var tenant = AgroPlatformUtils.getTokenField('tenantName');
2718
+ var tenant = AgroPlatformUtils.getTokenField("tenantName");
2627
2719
  if (tenant) {
2628
2720
  return tenant;
2629
2721
  }
@@ -2635,17 +2727,18 @@
2635
2727
  * @returns
2636
2728
  */
2637
2729
  AgroPlatformUtils.getCurrentTenantLocale = function () {
2638
- var locale = AgroPlatformUtils.getTokenField('locale');
2730
+ var locale = AgroPlatformUtils.getTokenField("locale");
2639
2731
  if (locale) {
2640
2732
  return locale;
2641
2733
  }
2642
- throw new Error("Cookie: \"" + COOKIE_TOKEN + "\" n\u00E3o encontrado.");
2734
+ throw new Error("'locale' n\u00E3o encontrado para o tenant atual.");
2643
2735
  };
2644
2736
  /**
2645
2737
  * @deprecated Use getCurrentTenantLocale()
2646
2738
  * Mantido por compatibilidade retroativa.
2647
2739
  */
2648
2740
  AgroPlatformUtils.getCurrenTenantLocale = function () {
2741
+ // legacy typo retained
2649
2742
  return AgroPlatformUtils.getCurrentTenantLocale();
2650
2743
  };
2651
2744
  /**
@@ -2654,7 +2747,7 @@
2654
2747
  * @returns string || null
2655
2748
  */
2656
2749
  AgroPlatformUtils.getCurrentUserName = function () {
2657
- var name = AgroPlatformUtils.getTokenField('fullName');
2750
+ var name = AgroPlatformUtils.getTokenField("fullName");
2658
2751
  return name || null;
2659
2752
  };
2660
2753
  /**
@@ -2663,7 +2756,7 @@
2663
2756
  * @returns string
2664
2757
  */
2665
2758
  AgroPlatformUtils.getCurrentUserEmail = function () {
2666
- var email = AgroPlatformUtils.getTokenField('email');
2759
+ var email = AgroPlatformUtils.getTokenField("email");
2667
2760
  if (!email) {
2668
2761
  console.info("Cookie: \"" + COOKIE_TOKEN + "\" n\u00E3o encontrado.");
2669
2762
  }
@@ -2698,7 +2791,7 @@
2698
2791
  * Caso contrário, retorna uma instância de Error
2699
2792
  */
2700
2793
  AgroPlatformUtils.getCurrentAccessToken = function () {
2701
- var token = AgroPlatformUtils.getTokenField('access_token');
2794
+ var token = AgroPlatformUtils.getTokenField("access_token");
2702
2795
  if (!token) {
2703
2796
  console.info("Cookie: \"" + COOKIE_TOKEN + "\" n\u00E3o encontrado.");
2704
2797
  }
@@ -4554,7 +4647,7 @@
4554
4647
  this.setLang(this.getLangOfUser());
4555
4648
  }
4556
4649
  LibTranslationService.prototype.getLangOfUser = function () {
4557
- return AgroPlatformUtils.getCurrenTenantLocale() || "pt-BR";
4650
+ return AgroPlatformUtils.getCurrentTenantLocale() || "pt-BR";
4558
4651
  };
4559
4652
  LibTranslationService.prototype.setLang = function (lang) {
4560
4653
  this.currentTranslation = this.availableTranslations[lang] || {};
@@ -5101,10 +5194,6 @@
5101
5194
  _this.translate = translate;
5102
5195
  return _this;
5103
5196
  }
5104
- EventControlService.prototype.getListEventControlWithFilters = function (listParams) {
5105
- return this.http.post(this.queriesUrl + "/listEventControlWithFilters", listParams)
5106
- .pipe(this.defaultCatch());
5107
- };
5108
5197
  EventControlService.ctorParameters = function () { return [
5109
5198
  { type: http.HttpClient },
5110
5199
  { type: api.MessageService },
@@ -5303,7 +5392,13 @@
5303
5392
  this.BadgeColors = angularComponents.BadgeColors;
5304
5393
  this.permissions = {};
5305
5394
  this.localeConfig = {};
5306
- this.currentListParams = { page: exports.AGRO_NUMBERS.ZERO, size: exports.AGRO_NUMBERS.TEN, sort: [], filterData: {} };
5395
+ this.currentListParams = {
5396
+ page: exports.AGRO_NUMBERS.ZERO,
5397
+ size: exports.AGRO_NUMBERS.TEN,
5398
+ displayFields: this.getDisplayFields(),
5399
+ sort: [],
5400
+ filterData: {}
5401
+ };
5307
5402
  this.ngUnsubscribe = new rxjs.Subject();
5308
5403
  this.eventItem = eventItem;
5309
5404
  this.inputFieldsPath = inputFieldsPath;
@@ -5458,12 +5553,16 @@
5458
5553
  EventControlBoardComponent.prototype.updateGrid = function (listParams) {
5459
5554
  var _this = this;
5460
5555
  if (listParams === void 0) { listParams = {}; }
5556
+ var _a;
5461
5557
  this.currentListParams = __assign(__assign({}, this.currentListParams), listParams);
5462
- var _a = this.currentListParams, page = _a.page, size = _a.size;
5463
- var order = this.getSortedFields();
5464
- var input = __assign(__assign({}, this.getInput()), { page: page, size: size, order: order });
5558
+ if (((_a = this.currentListParams.sort) === null || _a === void 0 ? void 0 : _a.length) <= 0) {
5559
+ this.currentListParams.sort = this.standalone ?
5560
+ [{ field: "createdDate", order: 1 }] :
5561
+ [{ field: "lastModifiedDate", order: -1 }];
5562
+ }
5563
+ this.currentListParams.filterQuery = this.getFilter();
5465
5564
  this.eventControlBoardService.eventControlService
5466
- .getListEventControlWithFilters(input)
5565
+ .list(this.currentListParams)
5467
5566
  .pipe(operators.takeUntil(this.ngUnsubscribe), operators.catchError(function (err) {
5468
5567
  _this.gridLoading = false;
5469
5568
  throw err;
@@ -5478,6 +5577,67 @@
5478
5577
  _this.processEventControlItems();
5479
5578
  });
5480
5579
  };
5580
+ EventControlBoardComponent.prototype.getFilter = function () {
5581
+ var _a, _b;
5582
+ var filterData = this.currentListParams.filterData;
5583
+ var filters = [];
5584
+ if ((_a = filterData["company"]) === null || _a === void 0 ? void 0 : _a.id) {
5585
+ filters.push("e070emp.id eq '" + filterData["company"].id + "'");
5586
+ }
5587
+ if ((_b = filterData["branch"]) === null || _b === void 0 ? void 0 : _b.id) {
5588
+ filters.push("e070fil.id eq '" + filterData["branch"].id + "'");
5589
+ }
5590
+ var controlCode = filterData["controlCode"];
5591
+ if (controlCode && Array.isArray(controlCode) && controlCode.length > 0) {
5592
+ var codes = controlCode.map(function (code) { return parseInt(code, 10); }).join(",");
5593
+ filters.push("controlCode in (" + codes + ")");
5594
+ }
5595
+ if (filterData["externalId"]) {
5596
+ filters.push("externalId eq '" + filterData["externalId"] + "'");
5597
+ }
5598
+ if (filterData["eventOrigin"]) {
5599
+ filters.push("eventOrigin eq '" + filterData["eventOrigin"] + "'");
5600
+ }
5601
+ if (filterData["status"]) {
5602
+ filters.push("eventControlItem.status eq '" + filterData["status"] + "'");
5603
+ }
5604
+ if (filterData["createdDate"]) {
5605
+ filters.push("createdDate ge '" + this.getStartDate(filterData["createdDate"]) + "'");
5606
+ filters.push("createdDate le '" + this.getEndDate(filterData["createdDate"]) + "'");
5607
+ }
5608
+ return filters.join(" and ");
5609
+ };
5610
+ EventControlBoardComponent.prototype.getEndDate = function (value) {
5611
+ var endDate = moment(value).endOf("day").format("YYYY-MM-DDTHH:mm:ss") + "Z";
5612
+ return endDate;
5613
+ };
5614
+ EventControlBoardComponent.prototype.getStartDate = function (value) {
5615
+ var startDate = moment(value).startOf("day").format("YYYY-MM-DDTHH:mm:ss") + "Z";
5616
+ return startDate;
5617
+ };
5618
+ EventControlBoardComponent.prototype.getDisplayFields = function () {
5619
+ return [
5620
+ '*',
5621
+ 'company.*',
5622
+ 'branch.*',
5623
+ 'eventControlItem.eventDomain',
5624
+ 'eventControlItem.id',
5625
+ 'eventControlItem.eventDomain',
5626
+ 'eventControlItem.eventService',
5627
+ 'eventControlItem.eventPrimitive',
5628
+ 'eventControlItem.eventControl',
5629
+ 'eventControlItem.eventGroup',
5630
+ 'eventControlItem.sequence',
5631
+ 'eventControlItem.eventOperation',
5632
+ 'eventControlItem.output',
5633
+ 'eventControlItem.status',
5634
+ 'eventControlItem.message',
5635
+ 'eventControlItem.createdBy',
5636
+ 'eventControlItem.createdDate',
5637
+ 'eventControlItem.lastModifiedBy',
5638
+ 'eventControlItem.lastModifiedDate',
5639
+ ];
5640
+ };
5481
5641
  EventControlBoardComponent.prototype.processEventControlItems = function () {
5482
5642
  var _this = this;
5483
5643
  this.gridData.forEach(function (item) {
@@ -5575,59 +5735,6 @@
5575
5735
  return value;
5576
5736
  }
5577
5737
  };
5578
- EventControlBoardComponent.prototype.getSortedFields = function () {
5579
- var _this = this;
5580
- var _a;
5581
- var order = "";
5582
- if (((_a = this.currentListParams.sort) === null || _a === void 0 ? void 0 : _a.length) > 0) {
5583
- order = this.currentListParams.sort
5584
- .map(function (sortItem) {
5585
- return _this.getFieldNameForSortRequest(sortItem.field) + " " + (sortItem.order === exports.AGRO_NUMBERS.ONE ? "asc" : "desc");
5586
- })
5587
- .join(", ");
5588
- }
5589
- else if (this.standalone) {
5590
- order = "createdDate asc";
5591
- }
5592
- else {
5593
- order = "lastModifiedDate desc";
5594
- }
5595
- return order;
5596
- };
5597
- EventControlBoardComponent.prototype.getInput = function () {
5598
- var _a, _b, _c, _d, _e, _f, _g;
5599
- var filterData = this.currentListParams.filterData;
5600
- var controlCode = filterData["controlCode"] && Array.isArray(filterData["controlCode"]) ? filterData["controlCode"] : null;
5601
- var filter = {
5602
- companyId: (_b = (_a = filterData["company"]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null,
5603
- branchId: (_d = (_c = filterData["branch"]) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : null,
5604
- controlCode: controlCode ? controlCode.map(function (code) { return parseInt(code); }) : null,
5605
- externalId: (_e = filterData["externalId"]) !== null && _e !== void 0 ? _e : null,
5606
- eventOrigin: (_f = filterData["eventOrigin"]) !== null && _f !== void 0 ? _f : null,
5607
- eventStatus: (_g = filterData["status"]) !== null && _g !== void 0 ? _g : null,
5608
- createdDateStart: filterData["createdDate"] ? this.getStartDate(filterData["createdDate"]) : null,
5609
- createdDateEnd: filterData["createdDate"] ? this.getEndDate(filterData["createdDate"]) : null,
5610
- };
5611
- return filter;
5612
- };
5613
- EventControlBoardComponent.prototype.getFieldNameForSortRequest = function (name) {
5614
- switch (name) {
5615
- case "company":
5616
- return "company.nomEmp";
5617
- case "branch":
5618
- return "branch.nomFil";
5619
- default:
5620
- return name;
5621
- }
5622
- };
5623
- EventControlBoardComponent.prototype.getEndDate = function (value) {
5624
- var endDate = moment(value).endOf("day").format("YYYY-MM-DDTHH:mm:ss") + "Z";
5625
- return endDate;
5626
- };
5627
- EventControlBoardComponent.prototype.getStartDate = function (value) {
5628
- var startDate = moment(value).startOf("day").format("YYYY-MM-DDTHH:mm:ss") + "Z";
5629
- return startDate;
5630
- };
5631
5738
  EventControlBoardComponent.prototype.onGridChange = function (event) {
5632
5739
  var size = event === null || event === void 0 ? void 0 : event.rows;
5633
5740
  var page = (event === null || event === void 0 ? void 0 : event.first) / size;
@@ -7020,7 +7127,7 @@
7020
7127
  this.form = new forms.FormGroup({
7021
7128
  titlesForm: new forms.FormArray([], []),
7022
7129
  });
7023
- this.currentListParams = { page: 0, size: 10, sort: [], filterData: {} };
7130
+ this.currentListParams = { first: 0, rows: 10, sortField: null, sortOrder: null, filters: {} };
7024
7131
  this.ngUnsubscribe = new core.EventEmitter();
7025
7132
  common.registerLocaleData(localePt);
7026
7133
  }
@@ -7031,38 +7138,40 @@
7031
7138
  enumerable: true,
7032
7139
  configurable: true
7033
7140
  });
7141
+ /**
7142
+ * Inicializa colunas da tabela e campos exibidos no sidebar,
7143
+ * depois dispara a primeira busca de títulos com os filtros informados em {@link options}.
7144
+ */
7034
7145
  FinancialTitleTableComponent.prototype.ngOnInit = function () {
7035
7146
  this.gridColumns = [
7036
- this.getFields("title", "agro.angular_components.title", ["numberTitle"], angularComponents.FieldType.String),
7037
- this.getFields("type", "agro.angular_components.type", ["titleType.cod", "titleType.desc"], angularComponents.FieldType.String),
7038
- this.getFields("entryDate", "agro.angular_components.entry", ["issueDate"], angularComponents.FieldType.Date),
7039
- this.getFields("dueDate", "agro.angular_components.due_date", ["dueDate"], angularComponents.FieldType.Date),
7040
- this.getFields("valueOrigin", "agro.angular_components.original_value", ["values.originalValue"], angularComponents.FieldType.Money),
7041
- this.getFields("valueOpen", "agro.angular_components.open_value", ["values.openValue"], angularComponents.FieldType.Money),
7042
- this.getFields("valueNet", "agro.angular_components.value_net", ["values.netValue"], angularComponents.FieldType.Money),
7043
- this.getFields("valuePaid", "agro.angular_components.value_to_pay", ["valuePaid"], angularComponents.FieldType.Money),
7147
+ this.getFields("title", "agro.angular_components.title", ["numberTitle"], angularComponents.FieldType.String, TitleFieldsOrderBy.NUMBER_TITLE),
7148
+ this.getFields("type", "agro.angular_components.type", ["titleType.cod", "titleType.desc"], angularComponents.FieldType.String, null),
7149
+ this.getFields("entryDate", "agro.angular_components.entry", ["issueDate"], angularComponents.FieldType.Date, TitleFieldsOrderBy.ISSUE_DATE),
7150
+ this.getFields("dueDate", "agro.angular_components.due_date", ["dueDate"], angularComponents.FieldType.Date, TitleFieldsOrderBy.DUE_DATE),
7151
+ this.getFields("valueOrigin", "agro.angular_components.original_value", ["values.originalValue"], angularComponents.FieldType.Money, TitleFieldsOrderBy.ORIGINAL_VALUE),
7152
+ this.getFields("valueOpen", "agro.angular_components.open_value", ["values.openValue"], angularComponents.FieldType.Money, TitleFieldsOrderBy.OPEN_VALUE),
7153
+ this.getFields("valueNet", "agro.angular_components.value_net", ["values.netValue"], angularComponents.FieldType.Money, TitleFieldsOrderBy.NET_VALUE),
7154
+ this.getFields("valuePaid", "agro.angular_components.value_to_pay", ["valuePaid"], angularComponents.FieldType.Money, null),
7044
7155
  ];
7045
7156
  this.sidebarFields = __spread([
7046
- this.getFields("company", "agro.angular_components.company", ["company.cod", "company.desc"], angularComponents.FieldType.String),
7047
- this.getFields("branch", "agro.angular_components.branch", ["branch.cod", "branch.desc"], angularComponents.FieldType.String),
7048
- this.getFields("producer", "agro.angular_components.producer", ["producer.cod", "producer.desc"], angularComponents.FieldType.String)
7157
+ this.getFields("company", "agro.angular_components.company", ["company.cod", "company.desc"], angularComponents.FieldType.String, null),
7158
+ this.getFields("branch", "agro.angular_components.branch", ["branch.cod", "branch.desc"], angularComponents.FieldType.String, null),
7159
+ this.getFields("producer", "agro.angular_components.producer", ["producer.cod", "producer.desc"], angularComponents.FieldType.String, null)
7049
7160
  ], this.gridColumns.filter(function (col) { return !["valuePaid", "valueNet"].includes(col.field); }), [
7050
- this.getFields("valueFees", "agro.angular_components.value_fees", ["values.feesValue"], angularComponents.FieldType.Money),
7051
- this.getFields("valueFine", "agro.angular_components.value_fine", ["values.fineValue"], angularComponents.FieldType.Money),
7052
- this.getFields("valueCharge", "agro.angular_components.value_charge", ["values.chargeValue"], angularComponents.FieldType.Money),
7053
- this.getFields("valueCorrection", "agro.angular_components.value_correction", ["values.monetaryCorrectionValue"], angularComponents.FieldType.Money),
7054
- this.getFields("valueAdditional", "agro.angular_components.value_additional", ["values.otherAdditionValue"], angularComponents.FieldType.Money),
7055
- this.getFields("valueDiscount", "agro.angular_components.value_discount", ["values.discountValue"], angularComponents.FieldType.Money),
7056
- this.getFields("valueOtherDiscount", "agro.angular_components.value_other_discount", ["values.otherDiscountValue"], angularComponents.FieldType.Money)
7161
+ this.getFields("valueFees", "agro.angular_components.value_fees", ["values.feesValue"], angularComponents.FieldType.Money, null),
7162
+ this.getFields("valueFine", "agro.angular_components.value_fine", ["values.fineValue"], angularComponents.FieldType.Money, null),
7163
+ this.getFields("valueCharge", "agro.angular_components.value_charge", ["values.chargeValue"], angularComponents.FieldType.Money, null),
7164
+ this.getFields("valueCorrection", "agro.angular_components.value_correction", ["values.monetaryCorrectionValue"], angularComponents.FieldType.Money, null),
7165
+ this.getFields("valueAdditional", "agro.angular_components.value_additional", ["values.otherAdditionValue"], angularComponents.FieldType.Money, null),
7166
+ this.getFields("valueDiscount", "agro.angular_components.value_discount", ["values.discountValue"], angularComponents.FieldType.Money, null),
7167
+ this.getFields("valueOtherDiscount", "agro.angular_components.value_other_discount", ["values.otherDiscountValue"], angularComponents.FieldType.Money, null)
7057
7168
  ], this.gridColumns.filter(function (col) { return ["valueNet"].includes(col.field); }));
7058
- this.updateGrid({
7059
- first: 0,
7060
- rows: this.getPageSize(),
7061
- sortField: this.getSortField(),
7062
- sortOrder: this.getSortOrder(),
7063
- });
7064
- this.subscribeToValuePaidChanges();
7169
+ this.updateGrid(this.currentListParams);
7065
7170
  };
7171
+ /**
7172
+ * Após a renderização da tabela, sincroniza o estado de checkbox/linha editável
7173
+ * com o array de títulos selecionados para evitar acesso a referências ainda não criadas.
7174
+ */
7066
7175
  FinancialTitleTableComponent.prototype.ngAfterViewInit = function () {
7067
7176
  this.tableInitialized = true;
7068
7177
  this.synchronizeCheckboxAndEditableFieldState();
@@ -7072,32 +7181,37 @@
7072
7181
  this.ngUnsubscribe.complete();
7073
7182
  };
7074
7183
  FinancialTitleTableComponent.prototype.getPageSize = function () {
7075
- return this.currentListParams.size;
7184
+ var _a;
7185
+ return (_a = this.currentListParams) === null || _a === void 0 ? void 0 : _a.rows;
7076
7186
  };
7077
7187
  FinancialTitleTableComponent.prototype.getRowIndex = function () {
7078
- return this.currentListParams.page * this.currentListParams.size;
7188
+ var _a;
7189
+ return (_a = this.currentListParams) === null || _a === void 0 ? void 0 : _a.first;
7079
7190
  };
7080
7191
  FinancialTitleTableComponent.prototype.getSortField = function () {
7081
- if (!this.currentListParams.sort || this.currentListParams.sort.length <= 0) {
7082
- return this.gridColumns[0].field;
7083
- }
7084
- return this.currentListParams.sort[0].field;
7192
+ var _a;
7193
+ return (_a = this.currentListParams) === null || _a === void 0 ? void 0 : _a.sortField;
7085
7194
  };
7086
7195
  FinancialTitleTableComponent.prototype.getSortOrder = function () {
7087
- if (!this.currentListParams.sort || this.currentListParams.sort.length <= 0) {
7088
- return 1;
7089
- }
7090
- return this.currentListParams.sort[0].order;
7196
+ var _a;
7197
+ return (_a = this.currentListParams) === null || _a === void 0 ? void 0 : _a.sortOrder;
7091
7198
  };
7199
+ /**
7200
+ * Faz requisição paginada/ordenada para listar os títulos, monta o formulário
7201
+ * reativo para cada linha e trata erros de backend exibindo mensagem ao usuário.
7202
+ *
7203
+ * @param event parâmetros de paginação, ordenação e filtros vindos do PrimeNG.
7204
+ */
7092
7205
  FinancialTitleTableComponent.prototype.updateGrid = function (event) {
7093
7206
  var _this = this;
7094
7207
  this.componentLoading = true;
7095
7208
  var size = event.rows;
7096
7209
  var page = event.first / size;
7097
- var sort = event.sortField;
7098
- this.currentListParams = __assign(__assign({}, this.currentListParams), { page: page, size: size, sort: sort });
7210
+ var field = event.sortField;
7211
+ var sortOrder = event.sortOrder;
7212
+ this.currentListParams = event;
7099
7213
  var input = {
7100
- pageRequest: { offset: page, size: size },
7214
+ pageRequest: { offset: page, orderBy: this.getRecOrderBy(field, sortOrder), size: size },
7101
7215
  filter: this.options,
7102
7216
  };
7103
7217
  this.financialService
@@ -7109,14 +7223,7 @@
7109
7223
  }))
7110
7224
  .subscribe(function (list) {
7111
7225
  _this.gridData = list.titles || [];
7112
- _this.form.get("titlesForm").reset([]);
7113
- _this.gridData.forEach(function (item, index) {
7114
- var selectedItem = _this.selected.find(function (sel) { return sel.id === item.id; });
7115
- _this.form.get("titlesForm").push(new forms.FormGroup({
7116
- id: new forms.FormControl(item.id || null, []),
7117
- valuePaid: new forms.FormControl((selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.valuePaid) || null, []),
7118
- }));
7119
- });
7226
+ _this.createFormGroupForTitle();
7120
7227
  _this.gridTotalRecords = list.totalElements;
7121
7228
  _this.componentLoading = false;
7122
7229
  _this.synchronizeCheckboxAndEditableFieldState();
@@ -7127,10 +7234,23 @@
7127
7234
  this.synchronizeCheckboxAndEditableFieldState();
7128
7235
  this.selectionChange.emit(this.selected);
7129
7236
  };
7237
+ /**
7238
+ * Quando um item é desmarcado, limpa o `valuePaid` correspondente
7239
+ * tanto no modelo da linha quanto no {@link titlesForm}, sem disparar novos eventos.
7240
+ *
7241
+ * @param event evento de desmarcação emitido pelo PrimeNG.
7242
+ */
7130
7243
  FinancialTitleTableComponent.prototype.onUnselect = function (event) {
7244
+ var _a;
7131
7245
  var row = this.gridData.find(function (r) { return r.id === event.data.id; });
7132
7246
  if (row) {
7133
7247
  row.valuePaid = null;
7248
+ // atualiza form control correspondente
7249
+ var idx = this.gridData.findIndex(function (g) { return g.id === row.id; });
7250
+ var ctrl = (_a = this.titlesForm.at(idx)) === null || _a === void 0 ? void 0 : _a.get("valuePaid");
7251
+ if (ctrl) {
7252
+ ctrl.setValue(null, { emitEvent: false });
7253
+ }
7134
7254
  }
7135
7255
  };
7136
7256
  FinancialTitleTableComponent.prototype.showDetails = function (rowData) {
@@ -7186,52 +7306,134 @@
7186
7306
  }
7187
7307
  return result;
7188
7308
  };
7189
- FinancialTitleTableComponent.prototype.subscribeToValuePaidChanges = function () {
7309
+ /**
7310
+ * Reconstrói o {@link titlesForm} com base na {@link gridData} atual,
7311
+ * preservando valores já informados em itens selecionados e registrando listeners de mudança.
7312
+ */
7313
+ FinancialTitleTableComponent.prototype.createFormGroupForTitle = function () {
7314
+ var _this = this;
7315
+ var titlesFormArray = this.form.get("titlesForm");
7316
+ titlesFormArray.clear();
7317
+ this.gridData.forEach(function (item) {
7318
+ var _a;
7319
+ var selectedItem = _this.selected.find(function (sel) { return sel.id === item.id; });
7320
+ var group = new forms.FormGroup({
7321
+ id: new forms.FormControl(item.id || null, []),
7322
+ valuePaid: new forms.FormControl((_a = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.valuePaid) !== null && _a !== void 0 ? _a : null, []),
7323
+ });
7324
+ _this.subscribeToValuePaidChanges(group, item);
7325
+ titlesFormArray.push(group);
7326
+ });
7327
+ };
7328
+ /**
7329
+ * Observa mudanças no campo `valuePaid` de uma linha.
7330
+ * Atualiza o array {@link selected} quando o título está selecionado,
7331
+ * aplica o limite do valor líquido (`netValue`) e evita loops de eventos usando
7332
+ * `setValue` com `emitEvent: false`.
7333
+ *
7334
+ * @param formGroup grupo de formulário associado à linha da tabela.
7335
+ * @param item título financeiro correspondente à linha.
7336
+ */
7337
+ FinancialTitleTableComponent.prototype.subscribeToValuePaidChanges = function (formGroup, item) {
7190
7338
  var _this = this;
7191
- this.form.get("titlesForm").valueChanges.subscribe(function (values) {
7192
- _this.selected.forEach(function (selectedRow) {
7193
- var _a, _b, _c, _d;
7194
- var updatedRow = values.find(function (v) { return v.id === selectedRow.id; });
7195
- if (updatedRow) {
7196
- selectedRow.valuePaid = updatedRow === null || updatedRow === void 0 ? void 0 : updatedRow.valuePaid;
7339
+ var valuePaidControl = formGroup.get("valuePaid");
7340
+ valuePaidControl.valueChanges.pipe(operators.takeUntil(this.ngUnsubscribe)).subscribe(function (rawValue) {
7341
+ var _a, _b, _c, _d;
7342
+ var valuePaid = _this.parseNumberSafe(rawValue);
7343
+ var titleId = (_a = formGroup.get("id")) === null || _a === void 0 ? void 0 : _a.value;
7344
+ // atualiza selected se o título estiver selecionado
7345
+ var selIndex = _this.selected.findIndex(function (s) { return s.id === titleId; });
7346
+ if (selIndex !== -1) {
7347
+ // garante que valuePaid seja numérico ou null
7348
+ _this.selected[selIndex].valuePaid = valuePaid;
7349
+ var net = Number((_c = (_b = _this.selected[selIndex]) === null || _b === void 0 ? void 0 : _b.values) === null || _c === void 0 ? void 0 : _c.netValue) || 0;
7350
+ if (valuePaid !== null && valuePaid > net) {
7351
+ _this.selected[selIndex].valuePaid = net;
7352
+ // Usado para evitar loop infinito de eventos
7353
+ valuePaidControl.setValue(net, { emitEvent: false });
7197
7354
  }
7198
- if ((selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.values.netValue) < (updatedRow === null || updatedRow === void 0 ? void 0 : updatedRow.valuePaid)) {
7199
- selectedRow.valuePaid = selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.values.netValue;
7200
- (_b = (_a = _this.titlesForm.at(_this.selected.indexOf(selectedRow))) === null || _a === void 0 ? void 0 : _a.get("valuePaid")) === null || _b === void 0 ? void 0 : _b.setValue(selectedRow.valuePaid);
7355
+ // atualiza flag de erro
7356
+ _this.selected[selIndex].hasError = valuePaidControl.invalid;
7357
+ // emite mudança de seleção
7358
+ _this.selectionChange.emit(_this.selected);
7359
+ }
7360
+ else {
7361
+ // se não estiver selecionado, apenas aplica limite local baseado no item
7362
+ var net = Number((_d = item === null || item === void 0 ? void 0 : item.values) === null || _d === void 0 ? void 0 : _d.netValue) || 0;
7363
+ if (valuePaid !== null && valuePaid > net) {
7364
+ valuePaidControl.setValue(net, { emitEvent: false });
7201
7365
  }
7202
- selectedRow.hasError = (_d = (_c = _this.titlesForm.at(_this.selected.indexOf(selectedRow))) === null || _c === void 0 ? void 0 : _c.get("valuePaid")) === null || _d === void 0 ? void 0 : _d.invalid;
7203
- });
7204
- _this.selectionChange.emit(_this.selected);
7366
+ }
7205
7367
  });
7206
7368
  };
7369
+ FinancialTitleTableComponent.prototype.parseNumberSafe = function (value) {
7370
+ if (value === null || value === undefined || value === "") {
7371
+ return null;
7372
+ }
7373
+ if (typeof value === "number") {
7374
+ return value;
7375
+ }
7376
+ if (typeof value === "string") {
7377
+ var cleaned = value.replace(/\./g, "").replace(",", ".");
7378
+ var n = parseFloat(cleaned);
7379
+ return isNaN(n) ? null : n;
7380
+ }
7381
+ return null;
7382
+ };
7383
+ /**
7384
+ * Inicia o modo de edição na linha da tabela PrimeNG e aplica regras de validação
7385
+ * no formulário reativo correspondente àquela linha.
7386
+ *
7387
+ * @param row objeto de linha recebido da tabela.
7388
+ */
7207
7389
  FinancialTitleTableComponent.prototype.initRowEdit = function (row) {
7208
7390
  if (this.table) {
7209
7391
  this.table.initRowEdit(row);
7210
7392
  this.applyValidationToRowEdit(row);
7211
7393
  }
7212
7394
  };
7395
+ /**
7396
+ * Adiciona validadores dinamicamente ao campo `valuePaid` da linha em edição,
7397
+ * marca o controle como sujo e força revalidação imediata para exibir erros na tela.
7398
+ *
7399
+ * @param row objeto de linha para aplicar validação.
7400
+ */
7213
7401
  FinancialTitleTableComponent.prototype.applyValidationToRowEdit = function (row) {
7214
- var _a, _b, _c;
7215
7402
  var rowIndex = this.gridData.findIndex(function (r) { return r.id === row.id; });
7216
7403
  var formGroup = this.titlesForm.at(rowIndex);
7217
- (_a = formGroup.get("valuePaid")) === null || _a === void 0 ? void 0 : _a.setValidators([this.getValidatorsForRowEdit(), forms.Validators.required]);
7218
- (_b = formGroup.get("valuePaid")) === null || _b === void 0 ? void 0 : _b.markAsDirty();
7219
- (_c = formGroup.get("valuePaid")) === null || _c === void 0 ? void 0 : _c.updateValueAndValidity();
7404
+ if (!formGroup) {
7405
+ return;
7406
+ }
7407
+ var valuePaidControl = formGroup.get("valuePaid");
7408
+ valuePaidControl === null || valuePaidControl === void 0 ? void 0 : valuePaidControl.setValidators([this.getValidatorsForRowEdit(), forms.Validators.required]);
7409
+ valuePaidControl === null || valuePaidControl === void 0 ? void 0 : valuePaidControl.markAsDirty();
7410
+ valuePaidControl === null || valuePaidControl === void 0 ? void 0 : valuePaidControl.updateValueAndValidity();
7220
7411
  };
7412
+ /**
7413
+ * Constrói o {@link ValidatorFn} que valida o `valuePaid`:
7414
+ * - deve ser maior que zero;
7415
+ * - não pode ultrapassar o valor líquido (`netValue`) do título.
7416
+ *
7417
+ * Retorna os erros consumidos pelo componente `s-control-errors`.
7418
+ */
7221
7419
  FinancialTitleTableComponent.prototype.getValidatorsForRowEdit = function () {
7222
7420
  var _this = this;
7223
7421
  return function (control) {
7224
7422
  var _a, _b;
7225
- var titleId = (_a = control.value) === null || _a === void 0 ? void 0 : _a.id;
7226
- var valuePaid = control.value;
7227
- var selectedRow = _this.selected.find(function (sel) { return sel.id === titleId; });
7423
+ var parent = control.parent;
7424
+ var titleId = (_a = parent === null || parent === void 0 ? void 0 : parent.get("id")) === null || _a === void 0 ? void 0 : _a.value;
7425
+ var rawValue = control.value;
7426
+ var valuePaid = _this.parseNumberSafe(rawValue);
7228
7427
  if (valuePaid === null || valuePaid === undefined) {
7229
7428
  return null;
7230
7429
  }
7231
7430
  if (valuePaid <= exports.AGRO_NUMBERS.ZERO) {
7232
7431
  return { lessThanZero: true };
7233
7432
  }
7234
- if (valuePaid > ((_b = selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.values) === null || _b === void 0 ? void 0 : _b.netValue)) {
7433
+ // procura pelo título no selected ou no gridData (prioriza selected)
7434
+ var selectedRow = _this.selected.find(function (sel) { return sel.id === titleId; }) || _this.gridData.find(function (g) { return g.id === titleId; });
7435
+ var netValue = Number((_b = selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.values) === null || _b === void 0 ? void 0 : _b.netValue) || 0;
7436
+ if (valuePaid > netValue) {
7235
7437
  return { greatherThanAllowed: true };
7236
7438
  }
7237
7439
  return null;
@@ -7242,30 +7444,39 @@
7242
7444
  this.table.cancelRowEdit(row);
7243
7445
  }
7244
7446
  };
7447
+ /**
7448
+ * Mantém o estado visual da tabela (checkbox marcado e linha editável) em
7449
+ * sincronia com o array de títulos selecionados, inclusive restaurando valores
7450
+ * digitados ao recarregar, ordenar ou paginar a grid.
7451
+ */
7245
7452
  FinancialTitleTableComponent.prototype.synchronizeCheckboxAndEditableFieldState = function () {
7246
7453
  var _this = this;
7247
7454
  if (!this.gridData || !this.tableInitialized) {
7248
7455
  return;
7249
7456
  }
7250
- this.selected.forEach(function (selectedRow) {
7251
- var index = _this.gridData.findIndex(function (row) { return row.id === selectedRow.id; });
7252
- if (index !== -1) {
7253
- _this.gridData[index].valuePaid = selectedRow.valuePaid;
7254
- _this.initRowEdit(_this.gridData[index]);
7255
- }
7256
- });
7257
- this.gridData.forEach(function (row) {
7258
- var isSelected = _this.selected.some(function (selectedRow) { return selectedRow.id === row.id; });
7259
- if (isSelected) {
7457
+ this.gridData.forEach(function (row, index) {
7458
+ var _a;
7459
+ var selectedRow = _this.selected.find(function (sel) { return sel.id === row.id; });
7460
+ var ctrl = (_a = _this.titlesForm.at(index)) === null || _a === void 0 ? void 0 : _a.get("valuePaid");
7461
+ if (selectedRow) {
7462
+ // Sincroniza o valor pago do item selecionado
7463
+ row.valuePaid = selectedRow.valuePaid;
7464
+ if (ctrl) {
7465
+ ctrl.setValue(selectedRow.valuePaid, { emitEvent: false });
7466
+ }
7260
7467
  _this.initRowEdit(row);
7261
7468
  }
7262
7469
  else {
7470
+ // Cancela a edição se não estiver selecionado
7471
+ if (ctrl) {
7472
+ ctrl.setValue(null, { emitEvent: false });
7473
+ }
7263
7474
  _this.cancelRowEdit(row);
7264
7475
  }
7265
7476
  });
7266
7477
  };
7267
- FinancialTitleTableComponent.prototype.getFields = function (field, header, path, type) {
7268
- return { field: field, path: path, type: type, header: this.translate.instant(header) };
7478
+ FinancialTitleTableComponent.prototype.getFields = function (field, header, path, type, fieldOrderBy) {
7479
+ return { field: field, path: path, type: type, header: this.translate.instant(header), orderBy: fieldOrderBy };
7269
7480
  };
7270
7481
  FinancialTitleTableComponent.prototype.addMessage = function (severity, summary, detail, sticky) {
7271
7482
  if (sticky === void 0) { sticky = false; }
@@ -7276,6 +7487,16 @@
7276
7487
  detail: this.translate.instant(detail),
7277
7488
  });
7278
7489
  };
7490
+ FinancialTitleTableComponent.prototype.getRecOrderBy = function (field, order) {
7491
+ var gridColumnField = this.gridColumns.find(function (col) { return col.field === field; });
7492
+ if ((gridColumnField === null || gridColumnField === void 0 ? void 0 : gridColumnField.orderBy) === null) {
7493
+ return null;
7494
+ }
7495
+ return {
7496
+ field: (gridColumnField === null || gridColumnField === void 0 ? void 0 : gridColumnField.orderBy) || TitleFieldsOrderBy.NUMBER_TITLE,
7497
+ order: order === 1 ? OrderByType.ASC : OrderByType.DESC,
7498
+ };
7499
+ };
7279
7500
  FinancialTitleTableComponent.ctorParameters = function () { return [
7280
7501
  { type: LibTranslationService },
7281
7502
  { type: AgroFinancialService },
@@ -7296,7 +7517,7 @@
7296
7517
  FinancialTitleTableComponent = __decorate([
7297
7518
  core.Component({
7298
7519
  selector: "s-financial-title-table",
7299
- template: "<ng-container *sLoadingState=\"componentLoading\">\r\n <div [hidden]=\"gridData?.length > 0\">\r\n <s-empty-state\r\n iconClass=\"fa fa-inbox\"\r\n title=\"{{ 'agro.angular_components.no_accounts_found_title' | libTranslate }}\"\r\n [showPrimaryAction]=\"false\"\r\n description=\"{{ 'agro.angular_components.no_accounts_found_description' | libTranslate }}\"\r\n ></s-empty-state>\r\n </div>\r\n <p-table\r\n #TitleTable\r\n [hidden]=\"gridData?.length === 0\"\r\n [value]=\"gridData\"\r\n [columns]=\"gridColumns\"\r\n dataKey=\"id\"\r\n [lazy]=\"true\"\r\n [paginator]=\"true\"\r\n [totalRecords]=\"gridTotalRecords\"\r\n [sortField]=\"getSortField()\"\r\n [sortOrder]=\"getSortOrder()\"\r\n [first]=\"getRowIndex()\"\r\n [rows]=\"getPageSize()\"\r\n [lazyLoadOnInit]=\"false\"\r\n [rowsPerPageOptions]=\"[10, 20, 50, 100]\"\r\n (onLazyLoad)=\"updateGrid($event)\"\r\n [(selection)]=\"selected\"\r\n (selectionChange)=\"onSelectionChange($event)\"\r\n (onRowUnselect)=\"onUnselect($event)\"\r\n sortMode=\"multiple\"\r\n [selectionMode]=\"'multiple'\"\r\n editMode=\"row\"\r\n [scrollable]=\"true\"\r\n [sTableFrozenPosition]=\"'right'\"\r\n [sTableFrozenValue]=\"gridData\"\r\n frozenWidth=\"160px\"\r\n >\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th class=\"table-checkbox-header\" scope=\"col\" [ngStyle]=\"getStyleColumns('checkbox')\">\r\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\r\n </th>\r\n <ng-container *ngFor=\"let col of columns; let i = index\">\r\n <ng-container *ngIf=\"!isLastColumn(i, columns); else lastColumn\">\r\n <th [pSortableColumn]=\"col.field\" [scope]=\"'col'\" [ngStyle]=\"getStyleColumns(col.field)\">\r\n {{ col.header }}\r\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\r\n </th>\r\n </ng-container>\r\n <ng-template #lastColumn>\r\n <th [scope]=\"'col'\" [ngStyle]=\"getStyleColumns(col.field)\">\r\n {{ col.header }}\r\n </th>\r\n </ng-template>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n <ng-template pTemplate=\"frozenheader\">\r\n <tr>\r\n <th scope=\"col\" pFrozenColumn>\r\n {{ 'agro.angular_components.details' | libTranslate }}\r\n </th>\r\n </tr>\r\n </ng-template>\r\n <ng-template\r\n pTemplate=\"body\"\r\n let-rowData\r\n let-columns=\"columns\"\r\n let-rowIndex=\"rowIndex\"\r\n let-editing=\"editing\"\r\n let-ri=\"rowIndex\"\r\n >\r\n <tr [pEditableRow]=\"rowData\" [formGroup]=\"$any(titlesForm.at(rowIndex))\">\r\n <td class=\"table-checkbox-header\" [ngStyle]=\"getStyleColumns('checkbox')\">\r\n <p-tableCheckbox [value]=\"rowData\"></p-tableCheckbox>\r\n </td>\r\n <td *ngFor=\"let col of columns; let i = index\" [ngStyle]=\"getStyleColumns(col.field)\">\r\n <p-cellEditor>\r\n <ng-template pTemplate=\"input\">\r\n <ng-container [ngSwitch]=\"col.field\">\r\n <ng-container *ngSwitchCase=\"'valuePaid'\">\r\n <input\r\n pInputText\r\n sNumberInput\r\n class=\"w-full\"\r\n id=\"valuePaid-input-{{ rowData.id || rowIndex }}\"\r\n decimalSeparator=\",\"\r\n thousandsSeparator=\".\"\r\n formControlName=\"valuePaid\"\r\n type=\"text\"\r\n [scale]=\"2\"\r\n [allowNegative]=\"false\"\r\n [attr.aria-label]=\"'agro.angular_components.value_paid' | libTranslate\"\r\n />\r\n <br />\r\n <s-control-errors\r\n [control]=\"$any(titlesForm.at(rowIndex)).get('valuePaid')\"\r\n [errorMessages]=\"errorMessage\"\r\n >\r\n </s-control-errors>\r\n </ng-container>\r\n <ng-container *ngSwitchDefault>\r\n {{ getProp(rowData, col) }}\r\n </ng-container>\r\n </ng-container>\r\n </ng-template>\r\n <ng-template pTemplate=\"output\">\r\n <ng-container [ngSwitch]=\"col.field\">\r\n <ng-container *ngSwitchCase=\"'valuePaid'\">\r\n {{ rowData['valuePaid'] || 0 | currency: 'BRL':'symbol':'1.2-2':'pt-BR' }}\r\n </ng-container>\r\n <ng-container *ngSwitchDefault>\r\n {{ getProp(rowData, col) }}\r\n </ng-container>\r\n </ng-container>\r\n </ng-template>\r\n </p-cellEditor>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n <ng-template pTemplate=\"frozenbody\" let-rowData let-columns>\r\n <tr [pEditableRow]=\"rowData\">\r\n <td pFrozenColumn>\r\n <s-button\r\n id=\"details-{{ rowData.id }}\"\r\n (click)=\"showDetails(rowData)\"\r\n (keydown.enter)=\"showDetails(rowData)\"\r\n label=\"{{ 'agro.angular_components.details' | libTranslate }}\"\r\n [priority]=\"buttonPriority.Default\"\r\n [disabled]=\"false\"\r\n [auxiliary]=\"true\"\r\n [size]=\"buttonSize.Small\"\r\n iconClass=\"fa fa-rocket\"\r\n ></s-button>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n </p-table>\r\n</ng-container>\r\n<s-sidebar\r\n [(visible)]=\"showSidebar\"\r\n position=\"right\"\r\n [header]=\"('agro.angular_components.account_details' | libTranslate) + ' ' + (selectedRow?.numberTitle || '')\"\r\n>\r\n <div class=\"ui-fluid\">\r\n <div class=\"ui-g\">\r\n <ng-container *ngFor=\"let field of sidebarFields\">\r\n <div class=\"ui-g-4\">\r\n <span>\r\n <strong>{{ field.header }}</strong>\r\n </span>\r\n <p>{{ getProp(selectedRow, field) || '-' }}</p>\r\n </div>\r\n </ng-container>\r\n <ng-template #noValue>-</ng-template>\r\n <div class=\"ui-g-4\">\r\n <span>\r\n <strong>{{ 'agro.angular_components.status_label' | libTranslate }}</strong>\r\n </span>\r\n <p>\r\n <ng-container [ngSwitch]=\"selectedRow?.status\">\r\n <span *ngSwitchCase=\"'OPEN'\">\r\n <s-badge\r\n [color]=\"badgeColors.Yellow\"\r\n text=\"{{ 'agro.angular_components.status_open' | libTranslate }}\"\r\n [selectable]=\"false\"\r\n ></s-badge>\r\n </span>\r\n <span *ngSwitchCase=\"'PAID'\">\r\n <s-badge\r\n [color]=\"badgeColors.Green\"\r\n text=\"{{ 'agro.angular_components.status_paid' | libTranslate }}\"\r\n [selectable]=\"false\"\r\n ></s-badge>\r\n </span>\r\n </ng-container>\r\n </p>\r\n </div>\r\n </div>\r\n </div>\r\n <s-footer>\r\n <s-button label=\"{{ 'agro.angular_components.close' | libTranslate }}\" (onClick)=\"closeDetails()\"> </s-button>\r\n </s-footer>\r\n</s-sidebar>\r\n",
7520
+ template: "<ng-container *sLoadingState=\"componentLoading\">\r\n <div [hidden]=\"gridData?.length > 0\">\r\n <s-empty-state\r\n iconClass=\"fa fa-inbox\"\r\n title=\"{{ 'agro.angular_components.no_accounts_found_title' | libTranslate }}\"\r\n [showPrimaryAction]=\"false\"\r\n description=\"{{ 'agro.angular_components.no_accounts_found_description' | libTranslate }}\"\r\n ></s-empty-state>\r\n </div>\r\n <p-table\r\n #TitleTable\r\n [hidden]=\"gridData?.length === 0\"\r\n [value]=\"gridData\"\r\n [columns]=\"gridColumns\"\r\n dataKey=\"id\"\r\n [lazy]=\"true\"\r\n [paginator]=\"true\"\r\n [totalRecords]=\"gridTotalRecords\"\r\n [sortField]=\"getSortField()\"\r\n [sortOrder]=\"getSortOrder()\"\r\n [first]=\"getRowIndex()\"\r\n [rows]=\"getPageSize()\"\r\n [lazyLoadOnInit]=\"false\"\r\n [rowsPerPageOptions]=\"[10, 20, 50, 100]\"\r\n (onLazyLoad)=\"updateGrid($event)\"\r\n [(selection)]=\"selected\"\r\n (selectionChange)=\"onSelectionChange($event)\"\r\n (onRowUnselect)=\"onUnselect($event)\"\r\n sortMode=\"single\"\r\n [selectionMode]=\"'multiple'\"\r\n editMode=\"row\"\r\n [scrollable]=\"true\"\r\n [sTableFrozenPosition]=\"'right'\"\r\n [sTableFrozenValue]=\"gridData\"\r\n frozenWidth=\"160px\"\r\n >\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th class=\"table-checkbox-header\" scope=\"col\" [ngStyle]=\"getStyleColumns('checkbox')\">\r\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\r\n </th>\r\n <ng-container *ngFor=\"let col of columns; let i = index\">\r\n <ng-container *ngIf=\"col.orderBy; else notSortable\">\r\n <th [pSortableColumn]=\"col.field\" [scope]=\"'col'\" [ngStyle]=\"getStyleColumns(col.field)\">\r\n {{ col.header }}\r\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\r\n </th>\r\n </ng-container>\r\n <ng-template #notSortable>\r\n <th [scope]=\"'col'\" [ngStyle]=\"getStyleColumns(col.field)\">\r\n {{ col.header }}\r\n </th>\r\n </ng-template>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n <ng-template pTemplate=\"frozenheader\">\r\n <tr>\r\n <th scope=\"col\" pFrozenColumn>\r\n {{ 'agro.angular_components.details' | libTranslate }}\r\n </th>\r\n </tr>\r\n </ng-template>\r\n <ng-template\r\n pTemplate=\"body\"\r\n let-rowData\r\n let-columns=\"columns\"\r\n let-rowIndex=\"rowIndex\"\r\n let-editing=\"editing\"\r\n let-ri=\"rowIndex\"\r\n >\r\n <tr [pEditableRow]=\"rowData\" [formGroup]=\"$any(titlesForm.at(rowIndex))\">\r\n <td class=\"table-checkbox-header\" [ngStyle]=\"getStyleColumns('checkbox')\">\r\n <p-tableCheckbox [value]=\"rowData\"></p-tableCheckbox>\r\n </td>\r\n <td *ngFor=\"let col of columns; let i = index\" [ngStyle]=\"getStyleColumns(col.field)\">\r\n <p-cellEditor>\r\n <ng-template pTemplate=\"input\">\r\n <ng-container [ngSwitch]=\"col.field\">\r\n <ng-container *ngSwitchCase=\"'valuePaid'\">\r\n <input\r\n pInputText\r\n sNumberInput\r\n class=\"w-full\"\r\n id=\"valuePaid-input-{{ rowData.id || rowIndex }}\"\r\n decimalSeparator=\",\"\r\n thousandsSeparator=\".\"\r\n formControlName=\"valuePaid\"\r\n type=\"text\"\r\n [scale]=\"2\"\r\n [allowNegative]=\"false\"\r\n [attr.aria-label]=\"'agro.angular_components.value_paid' | libTranslate\"\r\n />\r\n <br />\r\n <s-control-errors\r\n [control]=\"$any(titlesForm.at(rowIndex)).get('valuePaid')\"\r\n [errorMessages]=\"errorMessage\"\r\n >\r\n </s-control-errors>\r\n </ng-container>\r\n <ng-container *ngSwitchDefault>\r\n {{ getProp(rowData, col) }}\r\n </ng-container>\r\n </ng-container>\r\n </ng-template>\r\n <ng-template pTemplate=\"output\">\r\n <ng-container [ngSwitch]=\"col.field\">\r\n <ng-container *ngSwitchCase=\"'valuePaid'\">\r\n {{ rowData['valuePaid'] || 0 | currency: 'BRL':'symbol':'1.2-2':'pt-BR' }}\r\n </ng-container>\r\n <ng-container *ngSwitchDefault>\r\n {{ getProp(rowData, col) }}\r\n </ng-container>\r\n </ng-container>\r\n </ng-template>\r\n </p-cellEditor>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n <ng-template pTemplate=\"frozenbody\" let-rowData let-columns>\r\n <tr [pEditableRow]=\"rowData\">\r\n <td pFrozenColumn>\r\n <s-button\r\n id=\"details-{{ rowData.id }}\"\r\n (click)=\"showDetails(rowData)\"\r\n (keydown.enter)=\"showDetails(rowData)\"\r\n label=\"{{ 'agro.angular_components.details' | libTranslate }}\"\r\n [priority]=\"buttonPriority.Default\"\r\n [disabled]=\"false\"\r\n [auxiliary]=\"true\"\r\n [size]=\"buttonSize.Small\"\r\n iconClass=\"fa fa-rocket\"\r\n ></s-button>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n </p-table>\r\n</ng-container>\r\n<s-sidebar\r\n [(visible)]=\"showSidebar\"\r\n position=\"right\"\r\n [header]=\"('agro.angular_components.account_details' | libTranslate) + ' ' + (selectedRow?.numberTitle || '')\"\r\n>\r\n <div class=\"ui-fluid\">\r\n <div class=\"ui-g\">\r\n <ng-container *ngFor=\"let field of sidebarFields\">\r\n <div class=\"ui-g-4\">\r\n <span>\r\n <strong>{{ field.header }}</strong>\r\n </span>\r\n <p>{{ getProp(selectedRow, field) || '-' }}</p>\r\n </div>\r\n </ng-container>\r\n <ng-template #noValue>-</ng-template>\r\n <div class=\"ui-g-4\">\r\n <span>\r\n <strong>{{ 'agro.angular_components.status_label' | libTranslate }}</strong>\r\n </span>\r\n <p>\r\n <ng-container [ngSwitch]=\"selectedRow?.status\">\r\n <span *ngSwitchCase=\"'OPEN'\">\r\n <s-badge\r\n [color]=\"badgeColors.Yellow\"\r\n text=\"{{ 'agro.angular_components.status_open' | libTranslate }}\"\r\n [selectable]=\"false\"\r\n ></s-badge>\r\n </span>\r\n <span *ngSwitchCase=\"'PAID'\">\r\n <s-badge\r\n [color]=\"badgeColors.Green\"\r\n text=\"{{ 'agro.angular_components.status_paid' | libTranslate }}\"\r\n [selectable]=\"false\"\r\n ></s-badge>\r\n </span>\r\n </ng-container>\r\n </p>\r\n </div>\r\n </div>\r\n </div>\r\n <s-footer>\r\n <s-button label=\"{{ 'agro.angular_components.close' | libTranslate }}\" (onClick)=\"closeDetails()\"> </s-button>\r\n </s-footer>\r\n</s-sidebar>\r\n",
7300
7521
  styles: [".error-message{color:#c13018;margin-top:5px;font-size:12px}"]
7301
7522
  })
7302
7523
  ], FinancialTitleTableComponent);
@@ -7337,6 +7558,211 @@
7337
7558
  return FinancialTitleTableModule;
7338
7559
  }());
7339
7560
 
7561
+ var CnpjCpfPipe = /** @class */ (function () {
7562
+ function CnpjCpfPipe() {
7563
+ }
7564
+ CnpjCpfPipe.prototype.transform = function (value) {
7565
+ var args = [];
7566
+ for (var _i = 1; _i < arguments.length; _i++) {
7567
+ args[_i - 1] = arguments[_i];
7568
+ }
7569
+ if (typeof value !== "string" && typeof value === "number") {
7570
+ value = value === null || value === void 0 ? void 0 : value.toString();
7571
+ }
7572
+ if (typeof value !== "string") {
7573
+ return value;
7574
+ }
7575
+ if (AgroStringUtils.validateCNPJ(value)) {
7576
+ return AgroStringUtils.applyMask(value, exports.AgroStringMasks.CNPJ);
7577
+ }
7578
+ if (AgroStringUtils.validateCPF(value)) {
7579
+ return AgroStringUtils.applyMask(value, exports.AgroStringMasks.CPF);
7580
+ }
7581
+ return value;
7582
+ };
7583
+ CnpjCpfPipe = __decorate([
7584
+ core.Pipe({
7585
+ name: "cnpjCpf",
7586
+ })
7587
+ ], CnpjCpfPipe);
7588
+ return CnpjCpfPipe;
7589
+ }());
7590
+
7591
+ var CnpjCpfPipeModule = /** @class */ (function () {
7592
+ function CnpjCpfPipeModule() {
7593
+ }
7594
+ CnpjCpfPipeModule = __decorate([
7595
+ core.NgModule({
7596
+ declarations: [CnpjCpfPipe],
7597
+ imports: [common.CommonModule],
7598
+ exports: [CnpjCpfPipe],
7599
+ })
7600
+ ], CnpjCpfPipeModule);
7601
+ return CnpjCpfPipeModule;
7602
+ }());
7603
+
7604
+ var AgroObjectStringifier = /** @class */ (function () {
7605
+ function AgroObjectStringifier() {
7606
+ }
7607
+ /**
7608
+ * Formata um objeto concatenando valores segundo as chaves e pipes informados.
7609
+ *
7610
+ * @param separator Separador entre os valores (ex: "-")
7611
+ * @param fields Campos a extrair. Podem conter subpropriedades ("propriedade.subPropriedade") e pipes ("propriedade|nomeDaPipe:arg1:arg2")
7612
+ * @param obj Objeto origem
7613
+ */
7614
+ AgroObjectStringifier.formatObject = function (separator, fields, obj, usePipes) {
7615
+ function mapField(field) {
7616
+ var value = AgroObjectStringifier.resolvePath(obj, field);
7617
+ if (usePipes === null || usePipes === void 0 ? void 0 : usePipes.hasOwnProperty(field)) {
7618
+ return usePipes[field].transform(value);
7619
+ }
7620
+ return value !== null && value !== void 0 ? value : "";
7621
+ }
7622
+ function filterValid(v) {
7623
+ return typeof v === "number" || AgroStringUtils.isValid(v);
7624
+ }
7625
+ return fields.map(mapField).filter(filterValid).join(" " + separator + " ");
7626
+ };
7627
+ /** Resolve um caminho tipo "empresa.cargo" dentro de um objeto */
7628
+ AgroObjectStringifier.resolvePath = function (obj, path) {
7629
+ function reducer(acc, key) {
7630
+ return acc === null || acc === void 0 ? void 0 : acc[key];
7631
+ }
7632
+ return path.split(".").reduce(reducer, obj);
7633
+ };
7634
+ return AgroObjectStringifier;
7635
+ }());
7636
+
7637
+ var StringifierPipe = /** @class */ (function () {
7638
+ function StringifierPipe() {
7639
+ }
7640
+ StringifierPipe.prototype.transform = function (value, separator, paths, pipes) {
7641
+ return AgroObjectStringifier.formatObject(separator, paths, value, pipes);
7642
+ };
7643
+ StringifierPipe = __decorate([
7644
+ core.Pipe({ name: "stringifier" })
7645
+ ], StringifierPipe);
7646
+ return StringifierPipe;
7647
+ }());
7648
+
7649
+ var StringifierPipeModule = /** @class */ (function () {
7650
+ function StringifierPipeModule() {
7651
+ }
7652
+ StringifierPipeModule = __decorate([
7653
+ core.NgModule({
7654
+ declarations: [StringifierPipe],
7655
+ imports: [common.CommonModule],
7656
+ exports: [StringifierPipe],
7657
+ })
7658
+ ], StringifierPipeModule);
7659
+ return StringifierPipeModule;
7660
+ }());
7661
+
7662
+ var TelephonePipe = /** @class */ (function () {
7663
+ function TelephonePipe() {
7664
+ }
7665
+ /**
7666
+ * Transforma um número de telefone aplicando máscara automaticamente.
7667
+ * @param value Valor do telefone.
7668
+ * @param withDDI Define se deve forçar formatação com DDI (mesmo que não exista).
7669
+ */
7670
+ TelephonePipe.prototype.transform = function (value, withDDI) {
7671
+ if (withDDI === void 0) { withDDI = false; }
7672
+ if (!value) {
7673
+ return "";
7674
+ }
7675
+ var digits = this.cleanDigits(value);
7676
+ if (!digits) {
7677
+ return value.toString();
7678
+ }
7679
+ var _a = this.extractParts(digits, withDDI), ddi = _a.ddi, ddd = _a.ddd, number = _a.number;
7680
+ return this.formatPhone(ddi, ddd, number, value.toString(), withDDI);
7681
+ };
7682
+ /** Remove todos os caracteres não numéricos */
7683
+ TelephonePipe.prototype.cleanDigits = function (value) {
7684
+ return value.toString().replace(/\D+/g, "");
7685
+ };
7686
+ /** Extrai DDI, DDD e número, considerando se deve aplicar DDI forçado */
7687
+ TelephonePipe.prototype.extractParts = function (digits, withDDI) {
7688
+ var len = digits.length;
7689
+ if (withDDI) {
7690
+ return this.extractWithDDI(digits);
7691
+ }
7692
+ if (len <= exports.AGRO_NUMBERS.NINE) {
7693
+ return { ddi: "", ddd: "", number: digits };
7694
+ }
7695
+ if (len <= exports.AGRO_NUMBERS.ELEVEN) {
7696
+ return this.extractWithDDD(digits);
7697
+ }
7698
+ return this.extractWithDDI(digits);
7699
+ };
7700
+ /** Extrai DDD e número (sem DDI) */
7701
+ TelephonePipe.prototype.extractWithDDD = function (digits) {
7702
+ var ddd = digits.slice(0, 2);
7703
+ var number = digits.slice(2);
7704
+ return { ddi: "", ddd: ddd, number: number };
7705
+ };
7706
+ /** Extrai DDI, DDD e número */
7707
+ TelephonePipe.prototype.extractWithDDI = function (digits) {
7708
+ var len = digits.length;
7709
+ var ddiLen = exports.AGRO_NUMBERS.ONE;
7710
+ if (len >= exports.AGRO_NUMBERS.FOURTEEN) {
7711
+ ddiLen = exports.AGRO_NUMBERS.THREE;
7712
+ }
7713
+ if (len >= exports.AGRO_NUMBERS.TWELVE) {
7714
+ ddiLen = exports.AGRO_NUMBERS.TWO;
7715
+ }
7716
+ var ddi = digits.slice(exports.AGRO_NUMBERS.ZERO, ddiLen);
7717
+ var ddd = digits.slice(ddiLen, ddiLen + exports.AGRO_NUMBERS.TWO);
7718
+ var number = digits.slice(ddiLen + exports.AGRO_NUMBERS.TWO);
7719
+ return { ddi: ddi, ddd: ddd, number: number };
7720
+ };
7721
+ /** Monta o número formatado */
7722
+ TelephonePipe.prototype.formatPhone = function (ddi, ddd, number, fallback, withDDI) {
7723
+ if (!number) {
7724
+ return fallback;
7725
+ }
7726
+ var formatted = "";
7727
+ if (withDDI || ddi) {
7728
+ formatted += "+" + (ddi || "55") + " ";
7729
+ }
7730
+ if (ddd) {
7731
+ formatted += "(" + ddd + ") ";
7732
+ }
7733
+ formatted += this.formatNumber(number);
7734
+ return formatted;
7735
+ };
7736
+ /** Aplica máscara de 8 ou 9 dígitos */
7737
+ TelephonePipe.prototype.formatNumber = function (number) {
7738
+ var len = number.length;
7739
+ if (len === exports.AGRO_NUMBERS.NINE) {
7740
+ return number.slice(exports.AGRO_NUMBERS.ZERO, exports.AGRO_NUMBERS.FIVE) + "-" + number.slice(exports.AGRO_NUMBERS.FIVE);
7741
+ }
7742
+ if (len === exports.AGRO_NUMBERS.EIGHT) {
7743
+ return number.slice(exports.AGRO_NUMBERS.ZERO, exports.AGRO_NUMBERS.FOUR) + "-" + number.slice(exports.AGRO_NUMBERS.FOUR);
7744
+ }
7745
+ return number;
7746
+ };
7747
+ TelephonePipe = __decorate([
7748
+ core.Pipe({ name: "telephone" })
7749
+ ], TelephonePipe);
7750
+ return TelephonePipe;
7751
+ }());
7752
+
7753
+ var TelephonePipeModule = /** @class */ (function () {
7754
+ function TelephonePipeModule() {
7755
+ }
7756
+ TelephonePipeModule = __decorate([
7757
+ core.NgModule({
7758
+ declarations: [TelephonePipe],
7759
+ imports: [common.CommonModule],
7760
+ exports: [TelephonePipe],
7761
+ })
7762
+ ], TelephonePipeModule);
7763
+ return TelephonePipeModule;
7764
+ }());
7765
+
7340
7766
  var HostProjectConfigsInjectionToken = new core.InjectionToken("hostProjectConfigs");
7341
7767
  var AgroAngularComponentsModule = /** @class */ (function () {
7342
7768
  function AgroAngularComponentsModule() {
@@ -7376,6 +7802,8 @@
7376
7802
  exports.AsyncLock = AsyncLock;
7377
7803
  exports.CancelEventDialogComponent = CancelEventDialogComponent;
7378
7804
  exports.CancelEventDialogModule = CancelEventDialogModule;
7805
+ exports.CnpjCpfPipe = CnpjCpfPipe;
7806
+ exports.CnpjCpfPipeModule = CnpjCpfPipeModule;
7379
7807
  exports.Colors = Colors;
7380
7808
  exports.E001TnsModule = E001TnsModule;
7381
7809
  exports.E001pesModule = E001pesModule;
@@ -7405,12 +7833,17 @@
7405
7833
  exports.ProducerInvoiceModule = ProducerInvoiceModule;
7406
7834
  exports.RuralEstateModule = RuralEstateModule;
7407
7835
  exports.SharedModule = SharedModule;
7836
+ exports.StringifierPipe = StringifierPipe;
7837
+ exports.StringifierPipeModule = StringifierPipeModule;
7838
+ exports.TelephonePipe = TelephonePipe;
7839
+ exports.TelephonePipeModule = TelephonePipeModule;
7408
7840
  exports.TicketModule = TicketModule;
7409
7841
  exports.TransferModule = TransferModule;
7410
7842
  exports.UserInformationService = UserInformationService;
7411
7843
  exports.WebsocketModule = WebsocketModule;
7412
7844
  exports.WebsocketService = WebsocketService;
7413
- exports.ɵa = LibTranslationService;
7845
+ exports.ɵa = LibTranslatePipe;
7846
+ exports.ɵb = LibTranslationService;
7414
7847
 
7415
7848
  Object.defineProperty(exports, '__esModule', { value: true });
7416
7849