@senior-agronegocio/angular-components 0.0.983 → 0.0.9852

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 (46) hide show
  1. package/bundles/senior-agronegocio-angular-components.umd.js +239 -15
  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 +3 -0
  8. package/esm2015/common/agro-object-stringifier.class.js +31 -0
  9. package/esm2015/common/agro-platform-utils.class.js +8 -7
  10. package/esm2015/common/agro-regex.constant.js +5 -2
  11. package/esm2015/common/agro-string-utils.class.js +71 -8
  12. package/esm2015/pipe/cnpj-cpf/cnpj-cpf.pipe.module.js +1 -1
  13. package/esm2015/pipe/index.js +3 -1
  14. package/esm2015/pipe/stringifier/index.js +3 -0
  15. package/esm2015/pipe/stringifier/stringifier.pipe.js +13 -0
  16. package/esm2015/pipe/stringifier/stringifier.pipe.module.js +15 -0
  17. package/esm2015/pipe/telephone/index.js +3 -0
  18. package/esm2015/pipe/telephone/telephone.pipe.js +82 -0
  19. package/esm2015/pipe/telephone/telephone.pipe.module.js +15 -0
  20. package/esm2015/services/lib-translation.service.js +2 -2
  21. package/esm5/common/agro-object-stringifier.class.js +35 -0
  22. package/esm5/common/agro-platform-utils.class.js +8 -7
  23. package/esm5/common/agro-regex.constant.js +5 -2
  24. package/esm5/common/agro-string-utils.class.js +71 -8
  25. package/esm5/pipe/cnpj-cpf/cnpj-cpf.pipe.module.js +1 -1
  26. package/esm5/pipe/index.js +3 -1
  27. package/esm5/pipe/stringifier/index.js +3 -0
  28. package/esm5/pipe/stringifier/stringifier.pipe.js +16 -0
  29. package/esm5/pipe/stringifier/stringifier.pipe.module.js +18 -0
  30. package/esm5/pipe/telephone/index.js +3 -0
  31. package/esm5/pipe/telephone/telephone.pipe.js +86 -0
  32. package/esm5/pipe/telephone/telephone.pipe.module.js +18 -0
  33. package/esm5/services/lib-translation.service.js +2 -2
  34. package/fesm2015/senior-agronegocio-angular-components.js +220 -16
  35. package/fesm2015/senior-agronegocio-angular-components.js.map +1 -1
  36. package/fesm5/senior-agronegocio-angular-components.js +236 -16
  37. package/fesm5/senior-agronegocio-angular-components.js.map +1 -1
  38. package/package.json +1 -1
  39. package/pipe/index.d.ts +2 -0
  40. package/pipe/stringifier/index.d.ts +2 -0
  41. package/pipe/stringifier/stringifier.pipe.d.ts +9 -0
  42. package/pipe/stringifier/stringifier.pipe.module.d.ts +2 -0
  43. package/pipe/telephone/index.d.ts +2 -0
  44. package/pipe/telephone/telephone.pipe.d.ts +21 -0
  45. package/pipe/telephone/telephone.pipe.module.d.ts +2 -0
  46. 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}[0-9]{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
 
@@ -2263,13 +2266,19 @@
2263
2266
  */
2264
2267
  AgroStringUtils.isEmpty = function (str) {
2265
2268
  var _a;
2266
- return !str || ((_a = str.trim()) === null || _a === void 0 ? void 0 : _a.length) === exports.AGRO_NUMBERS.ZERO;
2269
+ if (str && AgroStringUtils.isString(str)) {
2270
+ return ((_a = str === null || str === void 0 ? void 0 : str.trim()) === null || _a === void 0 ? void 0 : _a.length) === exports.AGRO_NUMBERS.ZERO;
2271
+ }
2272
+ return true;
2267
2273
  };
2268
2274
  /**
2269
2275
  * Verifica se a string não está vazia.
2270
2276
  */
2271
2277
  AgroStringUtils.isNotEmpty = function (str) {
2272
- return !AgroStringUtils.isEmpty(str);
2278
+ if (str && AgroStringUtils.isString(str)) {
2279
+ return !AgroStringUtils.isEmpty(str);
2280
+ }
2281
+ return false;
2273
2282
  };
2274
2283
  /** Verifica se a string é nula, indefinida ou contém apenas espaços em branco */
2275
2284
  AgroStringUtils.isBlank = function (str) {
@@ -2324,7 +2333,7 @@
2324
2333
  return AGRO_REGEX.isUUID.test(str);
2325
2334
  };
2326
2335
  AgroStringUtils.isNumber = function (str) {
2327
- return AGRO_REGEX.isNumber.test(str);
2336
+ return [AGRO_REGEX.isNumber.test(str), AGRO_REGEX.isDecimal.test(str)].includes(true);
2328
2337
  };
2329
2338
  AgroStringUtils.validateCPF = function (cpf) {
2330
2339
  cpf = cpf.replace(/\D/g, "");
@@ -2493,20 +2502,68 @@
2493
2502
  var maskChars = mask.split("");
2494
2503
  var unmaskedValue = "";
2495
2504
  var j = 0;
2505
+ var isDigit = function (c) { return /\d/.test(c); };
2506
+ var isAlpha = function (c) { return /[A-Za-z]/.test(c); };
2507
+ var isAlnum = function (c) { return /[A-Za-z0-9]/.test(c); };
2496
2508
  try {
2497
2509
  for (var maskChars_1 = __values(maskChars), maskChars_1_1 = maskChars_1.next(); !maskChars_1_1.done; maskChars_1_1 = maskChars_1.next()) {
2498
2510
  var maskChar = maskChars_1_1.value;
2499
2511
  if (j >= valueChars.length)
2500
2512
  break;
2513
+ var current = valueChars[j];
2514
+ // Placeholder para dígito '9'
2501
2515
  if (maskChar === "9") {
2502
- // posição de dado (mantém)
2503
- unmaskedValue += valueChars[j];
2516
+ // procura próximo dígito a partir de j
2517
+ var k = j;
2518
+ while (k < valueChars.length && !isDigit(valueChars[k]))
2519
+ k++;
2520
+ if (k < valueChars.length) {
2521
+ // encontrou dígito: consome
2522
+ unmaskedValue += valueChars[k];
2523
+ j = k + 1;
2524
+ }
2525
+ else {
2526
+ // não há dígito futuro: captura o caractere atual como dado
2527
+ unmaskedValue += valueChars[j];
2528
+ j++;
2529
+ }
2530
+ continue;
2531
+ }
2532
+ // Placeholder para letra 'A'
2533
+ if (maskChar === "A") {
2534
+ // procura próxima letra a partir de j
2535
+ var k = j;
2536
+ while (k < valueChars.length && !isAlpha(valueChars[k]))
2537
+ k++;
2538
+ if (k < valueChars.length) {
2539
+ unmaskedValue += valueChars[k];
2540
+ j = k + 1;
2541
+ }
2542
+ else {
2543
+ unmaskedValue += valueChars[j];
2544
+ j++;
2545
+ }
2546
+ continue;
2547
+ }
2548
+ // maskChar é um separador literal opcional.
2549
+ if (current === maskChar) {
2550
+ // separador presente no valor: consome-o
2504
2551
  j++;
2552
+ continue;
2505
2553
  }
2506
- else if (valueChars[j] === maskChar) {
2507
- // posição de caractere fixo pula se coincidir
2554
+ // separador ausente:
2555
+ // - se o caractere atual for alfanumérico, trata como dado e captura;
2556
+ // - se não for alfanumérico (pontuação), ignora — não avança j, permite
2557
+ // que o próximo placeholder pule/consuma ou procure pelo tipo esperado.
2558
+ if (isAlnum(current)) {
2559
+ unmaskedValue += current;
2508
2560
  j++;
2509
2561
  }
2562
+ else {
2563
+ // ignora caractere não-alfanumérico no lugar do separador (não consome)
2564
+ // assim o próximo placeholder poderá procurar o caractere do tipo esperado
2565
+ // sem perder a posição atual.
2566
+ }
2510
2567
  }
2511
2568
  }
2512
2569
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -2559,6 +2616,15 @@
2559
2616
  AgroStringUtils.isInvalid = function (str) {
2560
2617
  return !AgroStringUtils.isValid(str);
2561
2618
  };
2619
+ AgroStringUtils.isISODate = function (value) {
2620
+ return AGRO_REGEX.isISODate.test(value);
2621
+ };
2622
+ AgroStringUtils.isISOTime = function (value) {
2623
+ return AGRO_REGEX.isISOTime.test(value);
2624
+ };
2625
+ AgroStringUtils.isISODatetime = function (value) {
2626
+ return AGRO_REGEX.isISODateTime.test(value);
2627
+ };
2562
2628
  AgroStringUtils.CNPJ_TRADICIONAL_PESOS_1 = [
2563
2629
  exports.AGRO_NUMBERS.FIVE,
2564
2630
  exports.AGRO_NUMBERS.FOUR,
@@ -2634,7 +2700,7 @@
2634
2700
  * @returns
2635
2701
  */
2636
2702
  AgroPlatformUtils.getCurrentTenant = function () {
2637
- var tenant = AgroPlatformUtils.getTokenField('tenantName');
2703
+ var tenant = AgroPlatformUtils.getTokenField("tenantName");
2638
2704
  if (tenant) {
2639
2705
  return tenant;
2640
2706
  }
@@ -2646,17 +2712,18 @@
2646
2712
  * @returns
2647
2713
  */
2648
2714
  AgroPlatformUtils.getCurrentTenantLocale = function () {
2649
- var locale = AgroPlatformUtils.getTokenField('locale');
2715
+ var locale = AgroPlatformUtils.getTokenField("locale");
2650
2716
  if (locale) {
2651
2717
  return locale;
2652
2718
  }
2653
- throw new Error("Cookie: \"" + COOKIE_TOKEN + "\" n\u00E3o encontrado.");
2719
+ throw new Error("'locale' n\u00E3o encontrado para o tenant atual.");
2654
2720
  };
2655
2721
  /**
2656
2722
  * @deprecated Use getCurrentTenantLocale()
2657
2723
  * Mantido por compatibilidade retroativa.
2658
2724
  */
2659
2725
  AgroPlatformUtils.getCurrenTenantLocale = function () {
2726
+ // legacy typo retained
2660
2727
  return AgroPlatformUtils.getCurrentTenantLocale();
2661
2728
  };
2662
2729
  /**
@@ -2665,7 +2732,7 @@
2665
2732
  * @returns string || null
2666
2733
  */
2667
2734
  AgroPlatformUtils.getCurrentUserName = function () {
2668
- var name = AgroPlatformUtils.getTokenField('fullName');
2735
+ var name = AgroPlatformUtils.getTokenField("fullName");
2669
2736
  return name || null;
2670
2737
  };
2671
2738
  /**
@@ -2674,7 +2741,7 @@
2674
2741
  * @returns string
2675
2742
  */
2676
2743
  AgroPlatformUtils.getCurrentUserEmail = function () {
2677
- var email = AgroPlatformUtils.getTokenField('email');
2744
+ var email = AgroPlatformUtils.getTokenField("email");
2678
2745
  if (!email) {
2679
2746
  console.info("Cookie: \"" + COOKIE_TOKEN + "\" n\u00E3o encontrado.");
2680
2747
  }
@@ -2709,7 +2776,7 @@
2709
2776
  * Caso contrário, retorna uma instância de Error
2710
2777
  */
2711
2778
  AgroPlatformUtils.getCurrentAccessToken = function () {
2712
- var token = AgroPlatformUtils.getTokenField('access_token');
2779
+ var token = AgroPlatformUtils.getTokenField("access_token");
2713
2780
  if (!token) {
2714
2781
  console.info("Cookie: \"" + COOKIE_TOKEN + "\" n\u00E3o encontrado.");
2715
2782
  }
@@ -4448,7 +4515,7 @@
4448
4515
  this.setLang(this.getLangOfUser());
4449
4516
  }
4450
4517
  LibTranslationService.prototype.getLangOfUser = function () {
4451
- return AgroPlatformUtils.getCurrenTenantLocale() || "pt-BR";
4518
+ return AgroPlatformUtils.getCurrentTenantLocale() || "pt-BR";
4452
4519
  };
4453
4520
  LibTranslationService.prototype.setLang = function (lang) {
4454
4521
  this.currentTranslation = this.availableTranslations[lang] || {};
@@ -6710,6 +6777,159 @@
6710
6777
  return CnpjCpfPipeModule;
6711
6778
  }());
6712
6779
 
6780
+ var AgroObjectStringifier = /** @class */ (function () {
6781
+ function AgroObjectStringifier() {
6782
+ }
6783
+ /**
6784
+ * Formata um objeto concatenando valores segundo as chaves e pipes informados.
6785
+ *
6786
+ * @param separator Separador entre os valores (ex: "-")
6787
+ * @param fields Campos a extrair. Podem conter subpropriedades ("propriedade.subPropriedade") e pipes ("propriedade|nomeDaPipe:arg1:arg2")
6788
+ * @param obj Objeto origem
6789
+ */
6790
+ AgroObjectStringifier.formatObject = function (separator, fields, obj, usePipes) {
6791
+ function mapField(field) {
6792
+ var value = AgroObjectStringifier.resolvePath(obj, field);
6793
+ if (usePipes === null || usePipes === void 0 ? void 0 : usePipes.hasOwnProperty(field)) {
6794
+ return usePipes[field].transform(value);
6795
+ }
6796
+ return value !== null && value !== void 0 ? value : "";
6797
+ }
6798
+ function filterValid(v) {
6799
+ return AgroStringUtils.isValid(v);
6800
+ }
6801
+ return fields.map(mapField).filter(filterValid).join(" " + separator + " ");
6802
+ };
6803
+ /** Resolve um caminho tipo "empresa.cargo" dentro de um objeto */
6804
+ AgroObjectStringifier.resolvePath = function (obj, path) {
6805
+ function reducer(acc, key) {
6806
+ return acc === null || acc === void 0 ? void 0 : acc[key];
6807
+ }
6808
+ return path.split(".").reduce(reducer, obj);
6809
+ };
6810
+ return AgroObjectStringifier;
6811
+ }());
6812
+
6813
+ var StringifierPipe = /** @class */ (function () {
6814
+ function StringifierPipe() {
6815
+ }
6816
+ StringifierPipe.prototype.transform = function (value, separator, paths, pipes) {
6817
+ return AgroObjectStringifier.formatObject(separator, paths, value, pipes);
6818
+ };
6819
+ StringifierPipe = __decorate([
6820
+ core.Pipe({ name: "stringifier" })
6821
+ ], StringifierPipe);
6822
+ return StringifierPipe;
6823
+ }());
6824
+
6825
+ var StringifierPipeModule = /** @class */ (function () {
6826
+ function StringifierPipeModule() {
6827
+ }
6828
+ StringifierPipeModule = __decorate([
6829
+ core.NgModule({
6830
+ declarations: [StringifierPipe],
6831
+ imports: [common.CommonModule],
6832
+ exports: [StringifierPipe],
6833
+ })
6834
+ ], StringifierPipeModule);
6835
+ return StringifierPipeModule;
6836
+ }());
6837
+
6838
+ var TelephonePipe = /** @class */ (function () {
6839
+ function TelephonePipe() {
6840
+ }
6841
+ /**
6842
+ * Transforma um número de telefone aplicando máscara automaticamente.
6843
+ * @param value Valor do telefone.
6844
+ * @param withDDI Define se deve forçar formatação com DDI (mesmo que não exista).
6845
+ */
6846
+ TelephonePipe.prototype.transform = function (value, withDDI) {
6847
+ if (withDDI === void 0) { withDDI = false; }
6848
+ if (!value)
6849
+ return "";
6850
+ var digits = this.cleanDigits(value);
6851
+ if (!digits)
6852
+ return value.toString();
6853
+ var _a = this.extractParts(digits, withDDI), ddi = _a.ddi, ddd = _a.ddd, number = _a.number;
6854
+ return this.formatPhone(ddi, ddd, number, value.toString(), withDDI);
6855
+ };
6856
+ /** Remove todos os caracteres não numéricos */
6857
+ TelephonePipe.prototype.cleanDigits = function (value) {
6858
+ return value.toString().replace(/\D+/g, "");
6859
+ };
6860
+ /** Extrai DDI, DDD e número, considerando se deve aplicar DDI forçado */
6861
+ TelephonePipe.prototype.extractParts = function (digits, withDDI) {
6862
+ var len = digits.length;
6863
+ if (withDDI) {
6864
+ return this.extractWithDDI(digits);
6865
+ }
6866
+ if (len <= exports.AGRO_NUMBERS.NINE) {
6867
+ return { ddi: "", ddd: "", number: digits };
6868
+ }
6869
+ if (len <= exports.AGRO_NUMBERS.ELEVEN) {
6870
+ return this.extractWithDDD(digits);
6871
+ }
6872
+ return this.extractWithDDI(digits);
6873
+ };
6874
+ /** Extrai DDD e número (sem DDI) */
6875
+ TelephonePipe.prototype.extractWithDDD = function (digits) {
6876
+ var ddd = digits.slice(0, 2);
6877
+ var number = digits.slice(2);
6878
+ return { ddi: "", ddd: ddd, number: number };
6879
+ };
6880
+ /** Extrai DDI, DDD e número */
6881
+ TelephonePipe.prototype.extractWithDDI = function (digits) {
6882
+ var len = digits.length;
6883
+ var ddiLen = 1;
6884
+ if (len >= 14)
6885
+ ddiLen = 3;
6886
+ else if (len >= 12)
6887
+ ddiLen = 2;
6888
+ var ddi = digits.slice(0, ddiLen);
6889
+ var ddd = digits.slice(ddiLen, ddiLen + 2);
6890
+ var number = digits.slice(ddiLen + 2);
6891
+ return { ddi: ddi, ddd: ddd, number: number };
6892
+ };
6893
+ /** Monta o número formatado */
6894
+ TelephonePipe.prototype.formatPhone = function (ddi, ddd, number, fallback, withDDI) {
6895
+ if (!number)
6896
+ return fallback;
6897
+ var formatted = "";
6898
+ if (withDDI || ddi)
6899
+ formatted += "+" + (ddi || "55") + " ";
6900
+ if (ddd)
6901
+ formatted += "(" + ddd + ") ";
6902
+ formatted += this.formatNumber(number);
6903
+ return formatted;
6904
+ };
6905
+ /** Aplica máscara de 8 ou 9 dígitos */
6906
+ TelephonePipe.prototype.formatNumber = function (number) {
6907
+ var len = number.length;
6908
+ if (len === 9)
6909
+ return number.slice(0, 5) + "-" + number.slice(5);
6910
+ if (len === 8)
6911
+ return number.slice(0, 4) + "-" + number.slice(4);
6912
+ return number;
6913
+ };
6914
+ TelephonePipe = __decorate([
6915
+ core.Pipe({ name: "telephone" })
6916
+ ], TelephonePipe);
6917
+ return TelephonePipe;
6918
+ }());
6919
+
6920
+ var TelephonePipeModule = /** @class */ (function () {
6921
+ function TelephonePipeModule() {
6922
+ }
6923
+ TelephonePipeModule = __decorate([
6924
+ core.NgModule({
6925
+ declarations: [TelephonePipe],
6926
+ imports: [common.CommonModule],
6927
+ exports: [TelephonePipe],
6928
+ })
6929
+ ], TelephonePipeModule);
6930
+ return TelephonePipeModule;
6931
+ }());
6932
+
6713
6933
  var HostProjectConfigsInjectionToken = new core.InjectionToken("hostProjectConfigs");
6714
6934
  var AgroAngularComponentsModule = /** @class */ (function () {
6715
6935
  function AgroAngularComponentsModule() {
@@ -6777,6 +6997,10 @@
6777
6997
  exports.ProducerInvoiceModule = ProducerInvoiceModule;
6778
6998
  exports.RuralEstateModule = RuralEstateModule;
6779
6999
  exports.SharedModule = SharedModule;
7000
+ exports.StringifierPipe = StringifierPipe;
7001
+ exports.StringifierPipeModule = StringifierPipeModule;
7002
+ exports.TelephonePipe = TelephonePipe;
7003
+ exports.TelephonePipeModule = TelephonePipeModule;
6780
7004
  exports.TicketModule = TicketModule;
6781
7005
  exports.TransferModule = TransferModule;
6782
7006
  exports.UserInformationService = UserInformationService;