pjc-fields 0.0.60 → 0.0.62

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.
@@ -1492,6 +1492,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1492
1492
  ], template: "<div class=\"flex flex-col gap-1 w-full\">\n @if (label()) {\n <p-floatlabel [variant]=\"labelVariant()\" class=\"w-full\">\n <p-datePicker\n [inputId]=\"id()\"\n [(ngModel)]=\"value\"\n (ngModelChange)=\"onValueChange($event)\"\n (onBlur)=\"onTouched()\"\n dateFormat=\"dd/mm/yy\"\n [showTime]=\"true\"\n [hourFormat]=\"'24'\"\n [showIcon]=\"true\"\n [showClear]=\"true\"\n [minDate]=\"minDate()\"\n [maxDate]=\"maxDate()\"\n [disabled]=\"disabled\"\n [readonlyInput]=\"readonly()\"\n placeholder=\"dd/mm/aaaa HH:MM\"\n appendTo=\"body\"\n class=\"w-full\"\n inputStyleClass=\"w-full p-2 outline-none bg-transparent\"\n [class.ng-invalid]=\"invalid\"\n [class.ng-dirty]=\"invalid\"\n ></p-datePicker>\n <label [for]=\"id()\">{{ label() }}</label>\n </p-floatlabel>\n } @else {\n <p-datePicker\n [inputId]=\"id()\"\n [(ngModel)]=\"value\"\n (ngModelChange)=\"onValueChange($event)\"\n (onBlur)=\"onTouched()\"\n dateFormat=\"dd/mm/yy\"\n [showTime]=\"true\"\n [hourFormat]=\"'24'\"\n [showIcon]=\"true\"\n [showClear]=\"true\"\n [minDate]=\"minDate()\"\n [maxDate]=\"maxDate()\"\n [disabled]=\"disabled\"\n [readonlyInput]=\"readonly()\"\n placeholder=\"dd/mm/aaaa HH:MM\"\n appendTo=\"body\"\n class=\"w-full\"\n inputStyleClass=\"w-full p-2 border border-surface-300 rounded-md outline-none bg-transparent focus:border-primary-500\"\n [class.ng-invalid]=\"invalid\"\n [class.ng-dirty]=\"invalid\"\n ></p-datePicker>\n }\n\n @if (errorMessage) {\n <p-message severity=\"error\" variant=\"simple\" size=\"small\">{{ errorMessage }}</p-message>\n }\n\n <ng-content></ng-content>\n</div>\n" }]
1493
1493
  }], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], minDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "minDate", required: false }] }], maxDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxDate", required: false }] }], labelVariant: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelVariant", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], erros: [{ type: i0.Input, args: [{ isSignal: true, alias: "erros", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }] } });
1494
1494
 
1495
+ class PjcDetalhesComponent {
1496
+ label = input.required(...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
1497
+ value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
1498
+ layout = input('column', ...(ngDevMode ? [{ debugName: "layout" }] : /* istanbul ignore next */ []));
1499
+ displayValue = computed(() => {
1500
+ const v = this.value();
1501
+ return v !== null && v !== undefined ? String(v) : 'Não Informado';
1502
+ }, ...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
1503
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: PjcDetalhesComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1504
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: PjcDetalhesComponent, isStandalone: true, selector: "pjc-detalhes", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, layout: { classPropertyName: "layout", publicName: "layout", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (layout() === 'column') {\n <div class=\"pjc-detalhes pjc-detalhes--column\">\n @if (label()) {\n <span class=\"pjc-detalhes__label\">{{ label() }}</span>\n }\n <span class=\"pjc-detalhes__value\" [class.pjc-detalhes__value--empty]=\"value() === null || value() === undefined\">\n {{ displayValue() }}\n </span>\n </div>\n} @else {\n <div class=\"pjc-detalhes pjc-detalhes--row\">\n @if (label()) {\n <span class=\"pjc-detalhes__label\">{{ label() }}:&nbsp;</span>\n }\n <span class=\"pjc-detalhes__value\" [class.pjc-detalhes__value--empty]=\"value() === null || value() === undefined\">\n {{ displayValue() }}\n </span>\n </div>\n}\n", styles: [".pjc-detalhes{display:flex}.pjc-detalhes--column{flex-direction:column}.pjc-detalhes--row{flex-direction:row;align-items:baseline;flex-wrap:wrap}.pjc-detalhes__label{font-weight:600;font-size:.875rem;color:var(--p-text-color)}.pjc-detalhes__value{font-size:.875rem;color:var(--p-text-color)}.pjc-detalhes__value--empty{font-style:italic;color:var(--p-text-muted-color)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1505
+ }
1506
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: PjcDetalhesComponent, decorators: [{
1507
+ type: Component,
1508
+ args: [{ selector: 'pjc-detalhes', changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (layout() === 'column') {\n <div class=\"pjc-detalhes pjc-detalhes--column\">\n @if (label()) {\n <span class=\"pjc-detalhes__label\">{{ label() }}</span>\n }\n <span class=\"pjc-detalhes__value\" [class.pjc-detalhes__value--empty]=\"value() === null || value() === undefined\">\n {{ displayValue() }}\n </span>\n </div>\n} @else {\n <div class=\"pjc-detalhes pjc-detalhes--row\">\n @if (label()) {\n <span class=\"pjc-detalhes__label\">{{ label() }}:&nbsp;</span>\n }\n <span class=\"pjc-detalhes__value\" [class.pjc-detalhes__value--empty]=\"value() === null || value() === undefined\">\n {{ displayValue() }}\n </span>\n </div>\n}\n", styles: [".pjc-detalhes{display:flex}.pjc-detalhes--column{flex-direction:column}.pjc-detalhes--row{flex-direction:row;align-items:baseline;flex-wrap:wrap}.pjc-detalhes__label{font-weight:600;font-size:.875rem;color:var(--p-text-color)}.pjc-detalhes__value{font-size:.875rem;color:var(--p-text-color)}.pjc-detalhes__value--empty{font-style:italic;color:var(--p-text-muted-color)}\n"] }]
1509
+ }], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], layout: [{ type: i0.Input, args: [{ isSignal: true, alias: "layout", required: false }] }] } });
1510
+
1495
1511
  class PjcEmailFieldComponent {
1496
1512
  label = input('E-mail', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
1497
1513
  placeholder = input('Digite o e-mail', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
@@ -2772,6 +2788,155 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2772
2788
  args: [{ selector: 'lib-pjc-fields', imports: [], template: ` <p>pjc-fields works!</p> ` }]
2773
2789
  }] });
2774
2790
 
2791
+ const unidadesM = ['', 'um', 'dois', 'três', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove'];
2792
+ const unidadesF = ['', 'uma', 'duas', 'três', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove'];
2793
+ const dezenasEspeciais = [
2794
+ 'dez',
2795
+ 'onze',
2796
+ 'doze',
2797
+ 'treze',
2798
+ 'quatorze',
2799
+ 'quinze',
2800
+ 'dezesseis',
2801
+ 'dezessete',
2802
+ 'dezoito',
2803
+ 'dezenove',
2804
+ ];
2805
+ const dezenas = [
2806
+ '',
2807
+ '',
2808
+ 'vinte',
2809
+ 'trinta',
2810
+ 'quarenta',
2811
+ 'cinquenta',
2812
+ 'sessenta',
2813
+ 'setenta',
2814
+ 'oitenta',
2815
+ 'noventa',
2816
+ ];
2817
+ const centenasM = [
2818
+ '',
2819
+ 'cento',
2820
+ 'duzentos',
2821
+ 'trezentos',
2822
+ 'quatrocentos',
2823
+ 'quinhentos',
2824
+ 'seiscentos',
2825
+ 'setecentos',
2826
+ 'oitocentos',
2827
+ 'novecentos',
2828
+ ];
2829
+ const centenasF = [
2830
+ '',
2831
+ 'cento',
2832
+ 'duzentas',
2833
+ 'trezentas',
2834
+ 'quatrocentas',
2835
+ 'quinhentas',
2836
+ 'seiscentas',
2837
+ 'setecentas',
2838
+ 'oitocentas',
2839
+ 'novecentas',
2840
+ ];
2841
+ const configUnidades = {
2842
+ // Nota: "Grama" (peso) é substantivo masculino ("dois gramas").
2843
+ grama: { singular: 'grama', plural: 'gramas', feminino: false },
2844
+ kilo: { singular: 'quilo', plural: 'quilos', feminino: false },
2845
+ unidade: { singular: 'unidade', plural: 'unidades', feminino: true },
2846
+ miligrama: { singular: 'miligrama', plural: 'miligramas', feminino: false },
2847
+ litro: { singular: 'litro', plural: 'litros', feminino: false },
2848
+ mililitro: { singular: 'mililitro', plural: 'mililitros', feminino: false },
2849
+ centigrama: { singular: 'centigrama', plural: 'centigramas', feminino: false },
2850
+ };
2851
+ class PjcUtils {
2852
+ /**
2853
+ * Converte um número inteiro para extenso.
2854
+ */
2855
+ static numeroPorExtenso(numero, isFeminino = false) {
2856
+ if (numero === 0)
2857
+ return 'zero';
2858
+ const partes = [];
2859
+ let temp = Math.floor(Math.abs(numero));
2860
+ while (temp > 0) {
2861
+ partes.push(temp % 1000);
2862
+ temp = Math.floor(temp / 1000);
2863
+ }
2864
+ const grandezasSingular = ['', 'mil', 'milhão', 'bilhão'];
2865
+ const grandezasPlural = ['', 'mil', 'milhões', 'bilhões'];
2866
+ const resultado = [];
2867
+ for (let i = 0; i < partes.length; i++) {
2868
+ const valor = partes[i];
2869
+ if (valor === 0)
2870
+ continue;
2871
+ if (i === 1 && valor === 1) {
2872
+ resultado.unshift('mil');
2873
+ }
2874
+ else {
2875
+ const strGrupo = PjcUtils.traduzirGrupo(valor, isFeminino);
2876
+ const grandeza = valor === 1 ? grandezasSingular[i] : grandezasPlural[i];
2877
+ resultado.unshift(grandeza ? `${strGrupo} ${grandeza}` : strGrupo);
2878
+ }
2879
+ }
2880
+ // Junta as casas maiores com vírgula e a última com "e"
2881
+ return resultado
2882
+ .join(', ')
2883
+ .replace(/,([^,]*)$/, ' e$1')
2884
+ .trim();
2885
+ }
2886
+ static traduzirGrupo(n, isFeminino) {
2887
+ if (n === 100)
2888
+ return 'cem';
2889
+ const u = isFeminino ? unidadesF : unidadesM;
2890
+ const c = isFeminino ? centenasF : centenasM;
2891
+ const centena = Math.floor(n / 100);
2892
+ const dezena = Math.floor((n % 100) / 10);
2893
+ const unidade = n % 10;
2894
+ const partes = [];
2895
+ if (centena > 0)
2896
+ partes.push(c[centena]);
2897
+ partes.push(PjcUtils.traduzirDezenaUnidade(dezena, unidade, u));
2898
+ return partes.filter(Boolean).join(' e ');
2899
+ }
2900
+ static traduzirDezenaUnidade(dezena, unidade, u) {
2901
+ if (dezena === 0 && unidade === 0)
2902
+ return '';
2903
+ if (dezena === 1)
2904
+ return dezenasEspeciais[unidade];
2905
+ const partes = [];
2906
+ if (dezena > 1)
2907
+ partes.push(dezenas[dezena]);
2908
+ if (unidade > 0)
2909
+ partes.push(u[unidade]);
2910
+ return partes.join(' e ');
2911
+ }
2912
+ /**
2913
+ * Converte valor monetário para extenso.
2914
+ */
2915
+ static valorMonetarioPorExtenso(valor, currencyName = 'real', currencyNamePlural = 'reais', centavoSingular = 'centavo', centavoPlural = 'centavos') {
2916
+ const inteiros = Math.floor(valor);
2917
+ const centavos = Math.round((valor - inteiros) * 100);
2918
+ const partes = [];
2919
+ if (inteiros > 0) {
2920
+ const moeda = inteiros === 1 ? currencyName : currencyNamePlural;
2921
+ partes.push(`${PjcUtils.numeroPorExtenso(inteiros)} ${moeda}`);
2922
+ }
2923
+ if (centavos > 0) {
2924
+ const cent = centavos === 1 ? centavoSingular : centavoPlural;
2925
+ partes.push(`${PjcUtils.numeroPorExtenso(centavos)} ${cent}`);
2926
+ }
2927
+ return partes.join(' e ') || `zero ${currencyNamePlural}`;
2928
+ }
2929
+ /**
2930
+ * Converte unidade de medida para extenso, respeitando gênero.
2931
+ */
2932
+ static unidadeMedidaPorExtenso(valor, unidade) {
2933
+ const config = configUnidades[unidade];
2934
+ const textoNumero = PjcUtils.numeroPorExtenso(valor, config.feminino);
2935
+ const textoUnidade = valor === 1 ? config.singular : config.plural;
2936
+ return `${textoNumero} ${textoUnidade}`;
2937
+ }
2938
+ }
2939
+
2775
2940
  /*
2776
2941
  * Public API Surface of pjc-fields
2777
2942
  */
@@ -2780,5 +2945,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2780
2945
  * Generated bundle index. Do not edit.
2781
2946
  */
2782
2947
 
2783
- export { ESTADOS, PJC_CIDADE_SERVICE, PJC_ENUM_SERVICE, PjcCepFieldComponent, PjcChassiFieldComponent, PjcChassiInputDirective, PjcCidadeFieldComponent, PjcCidadeService, PjcCnhFieldComponent, PjcCnpjFieldComponent, PjcCpfCnpjFieldComponent, PjcCpfFieldComponent, PjcDataFieldComponent, PjcDataHoraFieldComponent, PjcEmailFieldComponent, PjcEnumFieldComponent, PjcEnumService, PjcErroValidacaoComponent, PjcFields, PjcHoraFieldComponent, PjcImeiFieldComponent, PjcIntegerFieldComponent, PjcMoedaFieldComponent, PjcNumeroCartaoFieldComponent, PjcPasswordFieldComponent, PjcPlacaFieldComponent, PjcRenavamFieldComponent, PjcTelefoneFieldComponent, PjcTipoPessoaFieldComponent, PjcUfFieldComponent, PjcUppercaseFieldComponent, PjcValidators, TIPOS_PESSOA };
2948
+ export { ESTADOS, PJC_CIDADE_SERVICE, PJC_ENUM_SERVICE, PjcCepFieldComponent, PjcChassiFieldComponent, PjcChassiInputDirective, PjcCidadeFieldComponent, PjcCidadeService, PjcCnhFieldComponent, PjcCnpjFieldComponent, PjcCpfCnpjFieldComponent, PjcCpfFieldComponent, PjcDataFieldComponent, PjcDataHoraFieldComponent, PjcDetalhesComponent, PjcEmailFieldComponent, PjcEnumFieldComponent, PjcEnumService, PjcErroValidacaoComponent, PjcFields, PjcHoraFieldComponent, PjcImeiFieldComponent, PjcIntegerFieldComponent, PjcMoedaFieldComponent, PjcNumeroCartaoFieldComponent, PjcPasswordFieldComponent, PjcPlacaFieldComponent, PjcRenavamFieldComponent, PjcTelefoneFieldComponent, PjcTipoPessoaFieldComponent, PjcUfFieldComponent, PjcUppercaseFieldComponent, PjcUtils, PjcValidators, TIPOS_PESSOA };
2784
2949
  //# sourceMappingURL=pjc-fields.mjs.map