@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
@@ -184,7 +184,10 @@ var AGRO_REGEX = {
184
184
  * Validação de Placa de Veículo Antiga
185
185
  * Formato: AAA-0000
186
186
  */
187
- isOldLicensePlate: /^[A-Z]{3}[0-9]{4}$/
187
+ isOldLicensePlate: /^[A-Z]{3}[0-9]{4}$/,
188
+ isISODate: /^\d{4}-\d{2}-\d{2}$/,
189
+ isISOTime: /^\d{2}:\d{2}:\d{2}$/,
190
+ isISODateTime: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/,
188
191
  };
189
192
 
190
193
  var NumberComparisonType;
@@ -2087,13 +2090,19 @@ var AgroStringUtils = /** @class */ (function () {
2087
2090
  */
2088
2091
  AgroStringUtils.isEmpty = function (str) {
2089
2092
  var _a;
2090
- return !str || ((_a = str.trim()) === null || _a === void 0 ? void 0 : _a.length) === AGRO_NUMBERS.ZERO;
2093
+ if (str && AgroStringUtils.isString(str)) {
2094
+ return ((_a = str === null || str === void 0 ? void 0 : str.trim()) === null || _a === void 0 ? void 0 : _a.length) === AGRO_NUMBERS.ZERO;
2095
+ }
2096
+ return true;
2091
2097
  };
2092
2098
  /**
2093
2099
  * Verifica se a string não está vazia.
2094
2100
  */
2095
2101
  AgroStringUtils.isNotEmpty = function (str) {
2096
- return !AgroStringUtils.isEmpty(str);
2102
+ if (str && AgroStringUtils.isString(str)) {
2103
+ return !AgroStringUtils.isEmpty(str);
2104
+ }
2105
+ return false;
2097
2106
  };
2098
2107
  /** Verifica se a string é nula, indefinida ou contém apenas espaços em branco */
2099
2108
  AgroStringUtils.isBlank = function (str) {
@@ -2148,7 +2157,7 @@ var AgroStringUtils = /** @class */ (function () {
2148
2157
  return AGRO_REGEX.isUUID.test(str);
2149
2158
  };
2150
2159
  AgroStringUtils.isNumber = function (str) {
2151
- return AGRO_REGEX.isNumber.test(str);
2160
+ return [AGRO_REGEX.isNumber.test(str), AGRO_REGEX.isDecimal.test(str)].includes(true);
2152
2161
  };
2153
2162
  AgroStringUtils.validateCPF = function (cpf) {
2154
2163
  cpf = cpf.replace(/\D/g, "");
@@ -2317,20 +2326,68 @@ var AgroStringUtils = /** @class */ (function () {
2317
2326
  var maskChars = mask.split("");
2318
2327
  var unmaskedValue = "";
2319
2328
  var j = 0;
2329
+ var isDigit = function (c) { return /\d/.test(c); };
2330
+ var isAlpha = function (c) { return /[A-Za-z]/.test(c); };
2331
+ var isAlnum = function (c) { return /[A-Za-z0-9]/.test(c); };
2320
2332
  try {
2321
2333
  for (var maskChars_1 = __values(maskChars), maskChars_1_1 = maskChars_1.next(); !maskChars_1_1.done; maskChars_1_1 = maskChars_1.next()) {
2322
2334
  var maskChar = maskChars_1_1.value;
2323
2335
  if (j >= valueChars.length)
2324
2336
  break;
2337
+ var current = valueChars[j];
2338
+ // Placeholder para dígito '9'
2325
2339
  if (maskChar === "9") {
2326
- // posição de dado (mantém)
2327
- unmaskedValue += valueChars[j];
2340
+ // procura próximo dígito a partir de j
2341
+ var k = j;
2342
+ while (k < valueChars.length && !isDigit(valueChars[k]))
2343
+ k++;
2344
+ if (k < valueChars.length) {
2345
+ // encontrou dígito: consome
2346
+ unmaskedValue += valueChars[k];
2347
+ j = k + 1;
2348
+ }
2349
+ else {
2350
+ // não há dígito futuro: captura o caractere atual como dado
2351
+ unmaskedValue += valueChars[j];
2352
+ j++;
2353
+ }
2354
+ continue;
2355
+ }
2356
+ // Placeholder para letra 'A'
2357
+ if (maskChar === "A") {
2358
+ // procura próxima letra a partir de j
2359
+ var k = j;
2360
+ while (k < valueChars.length && !isAlpha(valueChars[k]))
2361
+ k++;
2362
+ if (k < valueChars.length) {
2363
+ unmaskedValue += valueChars[k];
2364
+ j = k + 1;
2365
+ }
2366
+ else {
2367
+ unmaskedValue += valueChars[j];
2368
+ j++;
2369
+ }
2370
+ continue;
2371
+ }
2372
+ // maskChar é um separador literal opcional.
2373
+ if (current === maskChar) {
2374
+ // separador presente no valor: consome-o
2328
2375
  j++;
2376
+ continue;
2329
2377
  }
2330
- else if (valueChars[j] === maskChar) {
2331
- // posição de caractere fixo pula se coincidir
2378
+ // separador ausente:
2379
+ // - se o caractere atual for alfanumérico, trata como dado e captura;
2380
+ // - se não for alfanumérico (pontuação), ignora — não avança j, permite
2381
+ // que o próximo placeholder pule/consuma ou procure pelo tipo esperado.
2382
+ if (isAlnum(current)) {
2383
+ unmaskedValue += current;
2332
2384
  j++;
2333
2385
  }
2386
+ else {
2387
+ // ignora caractere não-alfanumérico no lugar do separador (não consome)
2388
+ // assim o próximo placeholder poderá procurar o caractere do tipo esperado
2389
+ // sem perder a posição atual.
2390
+ }
2334
2391
  }
2335
2392
  }
2336
2393
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -2383,6 +2440,15 @@ var AgroStringUtils = /** @class */ (function () {
2383
2440
  AgroStringUtils.isInvalid = function (str) {
2384
2441
  return !AgroStringUtils.isValid(str);
2385
2442
  };
2443
+ AgroStringUtils.isISODate = function (value) {
2444
+ return AGRO_REGEX.isISODate.test(value);
2445
+ };
2446
+ AgroStringUtils.isISOTime = function (value) {
2447
+ return AGRO_REGEX.isISOTime.test(value);
2448
+ };
2449
+ AgroStringUtils.isISODatetime = function (value) {
2450
+ return AGRO_REGEX.isISODateTime.test(value);
2451
+ };
2386
2452
  AgroStringUtils.CNPJ_TRADICIONAL_PESOS_1 = [
2387
2453
  AGRO_NUMBERS.FIVE,
2388
2454
  AGRO_NUMBERS.FOUR,
@@ -2458,7 +2524,7 @@ var AgroPlatformUtils = /** @class */ (function () {
2458
2524
  * @returns
2459
2525
  */
2460
2526
  AgroPlatformUtils.getCurrentTenant = function () {
2461
- var tenant = AgroPlatformUtils.getTokenField('tenantName');
2527
+ var tenant = AgroPlatformUtils.getTokenField("tenantName");
2462
2528
  if (tenant) {
2463
2529
  return tenant;
2464
2530
  }
@@ -2470,17 +2536,18 @@ var AgroPlatformUtils = /** @class */ (function () {
2470
2536
  * @returns
2471
2537
  */
2472
2538
  AgroPlatformUtils.getCurrentTenantLocale = function () {
2473
- var locale = AgroPlatformUtils.getTokenField('locale');
2539
+ var locale = AgroPlatformUtils.getTokenField("locale");
2474
2540
  if (locale) {
2475
2541
  return locale;
2476
2542
  }
2477
- throw new Error("Cookie: \"" + COOKIE_TOKEN + "\" n\u00E3o encontrado.");
2543
+ throw new Error("'locale' n\u00E3o encontrado para o tenant atual.");
2478
2544
  };
2479
2545
  /**
2480
2546
  * @deprecated Use getCurrentTenantLocale()
2481
2547
  * Mantido por compatibilidade retroativa.
2482
2548
  */
2483
2549
  AgroPlatformUtils.getCurrenTenantLocale = function () {
2550
+ // legacy typo retained
2484
2551
  return AgroPlatformUtils.getCurrentTenantLocale();
2485
2552
  };
2486
2553
  /**
@@ -2489,7 +2556,7 @@ var AgroPlatformUtils = /** @class */ (function () {
2489
2556
  * @returns string || null
2490
2557
  */
2491
2558
  AgroPlatformUtils.getCurrentUserName = function () {
2492
- var name = AgroPlatformUtils.getTokenField('fullName');
2559
+ var name = AgroPlatformUtils.getTokenField("fullName");
2493
2560
  return name || null;
2494
2561
  };
2495
2562
  /**
@@ -2498,7 +2565,7 @@ var AgroPlatformUtils = /** @class */ (function () {
2498
2565
  * @returns string
2499
2566
  */
2500
2567
  AgroPlatformUtils.getCurrentUserEmail = function () {
2501
- var email = AgroPlatformUtils.getTokenField('email');
2568
+ var email = AgroPlatformUtils.getTokenField("email");
2502
2569
  if (!email) {
2503
2570
  console.info("Cookie: \"" + COOKIE_TOKEN + "\" n\u00E3o encontrado.");
2504
2571
  }
@@ -2533,7 +2600,7 @@ var AgroPlatformUtils = /** @class */ (function () {
2533
2600
  * Caso contrário, retorna uma instância de Error
2534
2601
  */
2535
2602
  AgroPlatformUtils.getCurrentAccessToken = function () {
2536
- var token = AgroPlatformUtils.getTokenField('access_token');
2603
+ var token = AgroPlatformUtils.getTokenField("access_token");
2537
2604
  if (!token) {
2538
2605
  console.info("Cookie: \"" + COOKIE_TOKEN + "\" n\u00E3o encontrado.");
2539
2606
  }
@@ -4272,7 +4339,7 @@ var LibTranslationService = /** @class */ (function () {
4272
4339
  this.setLang(this.getLangOfUser());
4273
4340
  }
4274
4341
  LibTranslationService.prototype.getLangOfUser = function () {
4275
- return AgroPlatformUtils.getCurrenTenantLocale() || "pt-BR";
4342
+ return AgroPlatformUtils.getCurrentTenantLocale() || "pt-BR";
4276
4343
  };
4277
4344
  LibTranslationService.prototype.setLang = function (lang) {
4278
4345
  this.currentTranslation = this.availableTranslations[lang] || {};
@@ -6534,6 +6601,159 @@ var CnpjCpfPipeModule = /** @class */ (function () {
6534
6601
  return CnpjCpfPipeModule;
6535
6602
  }());
6536
6603
 
6604
+ var AgroObjectStringifier = /** @class */ (function () {
6605
+ function AgroObjectStringifier() {
6606
+ }
6607
+ /**
6608
+ * Formata um objeto concatenando valores segundo as chaves e pipes informados.
6609
+ *
6610
+ * @param separator Separador entre os valores (ex: "-")
6611
+ * @param fields Campos a extrair. Podem conter subpropriedades ("propriedade.subPropriedade") e pipes ("propriedade|nomeDaPipe:arg1:arg2")
6612
+ * @param obj Objeto origem
6613
+ */
6614
+ AgroObjectStringifier.formatObject = function (separator, fields, obj, usePipes) {
6615
+ function mapField(field) {
6616
+ var value = AgroObjectStringifier.resolvePath(obj, field);
6617
+ if (usePipes === null || usePipes === void 0 ? void 0 : usePipes.hasOwnProperty(field)) {
6618
+ return usePipes[field].transform(value);
6619
+ }
6620
+ return value !== null && value !== void 0 ? value : "";
6621
+ }
6622
+ function filterValid(v) {
6623
+ return AgroStringUtils.isValid(v);
6624
+ }
6625
+ return fields.map(mapField).filter(filterValid).join(" " + separator + " ");
6626
+ };
6627
+ /** Resolve um caminho tipo "empresa.cargo" dentro de um objeto */
6628
+ AgroObjectStringifier.resolvePath = function (obj, path) {
6629
+ function reducer(acc, key) {
6630
+ return acc === null || acc === void 0 ? void 0 : acc[key];
6631
+ }
6632
+ return path.split(".").reduce(reducer, obj);
6633
+ };
6634
+ return AgroObjectStringifier;
6635
+ }());
6636
+
6637
+ var StringifierPipe = /** @class */ (function () {
6638
+ function StringifierPipe() {
6639
+ }
6640
+ StringifierPipe.prototype.transform = function (value, separator, paths, pipes) {
6641
+ return AgroObjectStringifier.formatObject(separator, paths, value, pipes);
6642
+ };
6643
+ StringifierPipe = __decorate([
6644
+ Pipe({ name: "stringifier" })
6645
+ ], StringifierPipe);
6646
+ return StringifierPipe;
6647
+ }());
6648
+
6649
+ var StringifierPipeModule = /** @class */ (function () {
6650
+ function StringifierPipeModule() {
6651
+ }
6652
+ StringifierPipeModule = __decorate([
6653
+ NgModule({
6654
+ declarations: [StringifierPipe],
6655
+ imports: [CommonModule],
6656
+ exports: [StringifierPipe],
6657
+ })
6658
+ ], StringifierPipeModule);
6659
+ return StringifierPipeModule;
6660
+ }());
6661
+
6662
+ var TelephonePipe = /** @class */ (function () {
6663
+ function TelephonePipe() {
6664
+ }
6665
+ /**
6666
+ * Transforma um número de telefone aplicando máscara automaticamente.
6667
+ * @param value Valor do telefone.
6668
+ * @param withDDI Define se deve forçar formatação com DDI (mesmo que não exista).
6669
+ */
6670
+ TelephonePipe.prototype.transform = function (value, withDDI) {
6671
+ if (withDDI === void 0) { withDDI = false; }
6672
+ if (!value)
6673
+ return "";
6674
+ var digits = this.cleanDigits(value);
6675
+ if (!digits)
6676
+ return value.toString();
6677
+ var _a = this.extractParts(digits, withDDI), ddi = _a.ddi, ddd = _a.ddd, number = _a.number;
6678
+ return this.formatPhone(ddi, ddd, number, value.toString(), withDDI);
6679
+ };
6680
+ /** Remove todos os caracteres não numéricos */
6681
+ TelephonePipe.prototype.cleanDigits = function (value) {
6682
+ return value.toString().replace(/\D+/g, "");
6683
+ };
6684
+ /** Extrai DDI, DDD e número, considerando se deve aplicar DDI forçado */
6685
+ TelephonePipe.prototype.extractParts = function (digits, withDDI) {
6686
+ var len = digits.length;
6687
+ if (withDDI) {
6688
+ return this.extractWithDDI(digits);
6689
+ }
6690
+ if (len <= AGRO_NUMBERS.NINE) {
6691
+ return { ddi: "", ddd: "", number: digits };
6692
+ }
6693
+ if (len <= AGRO_NUMBERS.ELEVEN) {
6694
+ return this.extractWithDDD(digits);
6695
+ }
6696
+ return this.extractWithDDI(digits);
6697
+ };
6698
+ /** Extrai DDD e número (sem DDI) */
6699
+ TelephonePipe.prototype.extractWithDDD = function (digits) {
6700
+ var ddd = digits.slice(0, 2);
6701
+ var number = digits.slice(2);
6702
+ return { ddi: "", ddd: ddd, number: number };
6703
+ };
6704
+ /** Extrai DDI, DDD e número */
6705
+ TelephonePipe.prototype.extractWithDDI = function (digits) {
6706
+ var len = digits.length;
6707
+ var ddiLen = 1;
6708
+ if (len >= 14)
6709
+ ddiLen = 3;
6710
+ else if (len >= 12)
6711
+ ddiLen = 2;
6712
+ var ddi = digits.slice(0, ddiLen);
6713
+ var ddd = digits.slice(ddiLen, ddiLen + 2);
6714
+ var number = digits.slice(ddiLen + 2);
6715
+ return { ddi: ddi, ddd: ddd, number: number };
6716
+ };
6717
+ /** Monta o número formatado */
6718
+ TelephonePipe.prototype.formatPhone = function (ddi, ddd, number, fallback, withDDI) {
6719
+ if (!number)
6720
+ return fallback;
6721
+ var formatted = "";
6722
+ if (withDDI || ddi)
6723
+ formatted += "+" + (ddi || "55") + " ";
6724
+ if (ddd)
6725
+ formatted += "(" + ddd + ") ";
6726
+ formatted += this.formatNumber(number);
6727
+ return formatted;
6728
+ };
6729
+ /** Aplica máscara de 8 ou 9 dígitos */
6730
+ TelephonePipe.prototype.formatNumber = function (number) {
6731
+ var len = number.length;
6732
+ if (len === 9)
6733
+ return number.slice(0, 5) + "-" + number.slice(5);
6734
+ if (len === 8)
6735
+ return number.slice(0, 4) + "-" + number.slice(4);
6736
+ return number;
6737
+ };
6738
+ TelephonePipe = __decorate([
6739
+ Pipe({ name: "telephone" })
6740
+ ], TelephonePipe);
6741
+ return TelephonePipe;
6742
+ }());
6743
+
6744
+ var TelephonePipeModule = /** @class */ (function () {
6745
+ function TelephonePipeModule() {
6746
+ }
6747
+ TelephonePipeModule = __decorate([
6748
+ NgModule({
6749
+ declarations: [TelephonePipe],
6750
+ imports: [CommonModule],
6751
+ exports: [TelephonePipe],
6752
+ })
6753
+ ], TelephonePipeModule);
6754
+ return TelephonePipeModule;
6755
+ }());
6756
+
6537
6757
  var HostProjectConfigsInjectionToken = new InjectionToken("hostProjectConfigs");
6538
6758
  var AgroAngularComponentsModule = /** @class */ (function () {
6539
6759
  function AgroAngularComponentsModule() {
@@ -6561,5 +6781,5 @@ var AgroAngularComponentsModule = /** @class */ (function () {
6561
6781
  * Generated bundle index. Do not edit.
6562
6782
  */
6563
6783
 
6564
- export { AGRO_NUMBERS, AGRO_REGEX, AgroAngularComponentsModule, AgroArrayUtils, AgroCookieUtils, AgroDateUtils, AgroEntityStatus, AgroFormValidator, AgroLogics, AgroNameUtils, AgroNumberUtils, AgroObjectUtils, AgroPlatformUtils, AgroStringMasks, AgroStringUtils, AsyncLock, CancelEventDialogComponent, CancelEventDialogModule, CnpjCpfPipe, CnpjCpfPipeModule, Colors, DateComparisonType, E001TnsModule, E001pesModule, E070EmpModule, E070FilModule, E075DerModule, E205depService, EventControlBoardComponent, EventControlBoardModule, EventControlBoardService, EventControlItemModule, EventControlModule, EventStepsComponent, EventStepsModule, ExternalInvoiceModule, FixationModule, HostProjectConfigsInjectionToken, HttpCodes, InvoiceModule, LibTranslatePipe, LibTranslationModule, LibTranslationService, NumberComparisonType, OriginationModule, PaginatorStorageService, PrimitiveManager, ProducerInvoiceModule, RuralEstateModule, SharedModule, TicketModule, TransferModule, UserInformationService, WebsocketModule, WebsocketService, LibTranslatePipe as ɵa, LibTranslationService as ɵb };
6784
+ export { AGRO_NUMBERS, AGRO_REGEX, AgroAngularComponentsModule, AgroArrayUtils, AgroCookieUtils, AgroDateUtils, AgroEntityStatus, AgroFormValidator, AgroLogics, AgroNameUtils, AgroNumberUtils, AgroObjectUtils, AgroPlatformUtils, AgroStringMasks, AgroStringUtils, AsyncLock, CancelEventDialogComponent, CancelEventDialogModule, CnpjCpfPipe, CnpjCpfPipeModule, Colors, DateComparisonType, E001TnsModule, E001pesModule, E070EmpModule, E070FilModule, E075DerModule, E205depService, EventControlBoardComponent, EventControlBoardModule, EventControlBoardService, EventControlItemModule, EventControlModule, EventStepsComponent, EventStepsModule, ExternalInvoiceModule, FixationModule, HostProjectConfigsInjectionToken, HttpCodes, InvoiceModule, LibTranslatePipe, LibTranslationModule, LibTranslationService, NumberComparisonType, OriginationModule, PaginatorStorageService, PrimitiveManager, ProducerInvoiceModule, RuralEstateModule, SharedModule, StringifierPipe, StringifierPipeModule, TelephonePipe, TelephonePipeModule, TicketModule, TransferModule, UserInformationService, WebsocketModule, WebsocketService, LibTranslatePipe as ɵa, LibTranslationService as ɵb };
6565
6785
  //# sourceMappingURL=senior-agronegocio-angular-components.js.map