ngx-vector-components 5.112.0 → 5.113.0
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.
- package/CHANGELOG.md +6 -0
- package/esm2022/lib/components/fields/data-table/data-table.component.mjs +7 -2
- package/esm2022/lib/components/fields/dropdown-field/dropdown-field.component.mjs +86 -2
- package/fesm2022/ngx-vector-components.mjs +91 -2
- package/fesm2022/ngx-vector-components.mjs.map +1 -1
- package/lib/components/badge/badge.component.d.ts +1 -1
- package/lib/components/fields/dropdown-field/dropdown-field.component.d.ts +5 -0
- package/package.json +1 -1
|
@@ -3238,7 +3238,12 @@ class DropdownFieldComponent {
|
|
|
3238
3238
|
.getPaged(encodeURIComponent(this.currentSearchQuery), this.currentScrollPage, this.limitScrollPage, this.dependencies)
|
|
3239
3239
|
.subscribe({
|
|
3240
3240
|
next: (response) => {
|
|
3241
|
-
|
|
3241
|
+
const formattedResponse = response.map((item) => ({
|
|
3242
|
+
...item,
|
|
3243
|
+
name: this.formatDropdownValue(item.name),
|
|
3244
|
+
}));
|
|
3245
|
+
this.pagedSuggestions =
|
|
3246
|
+
this.currentScrollPage === 0 ? formattedResponse : this.pagedSuggestions?.concat(formattedResponse);
|
|
3242
3247
|
const controlValue = typeof this.control.value == 'object' ? this.control.value?.code : this.control.value;
|
|
3243
3248
|
if (this.control.value && this.pagedSuggestions?.find((item) => item.code == controlValue)) {
|
|
3244
3249
|
this.setControlValueFromSuggestions();
|
|
@@ -3296,6 +3301,85 @@ class DropdownFieldComponent {
|
|
|
3296
3301
|
filterListByQuery(list = [], query) {
|
|
3297
3302
|
return list.filter((opt) => String(opt.code).toUpperCase().includes(query) || opt.name.toUpperCase().includes(query));
|
|
3298
3303
|
}
|
|
3304
|
+
formatDropdownValue(value) {
|
|
3305
|
+
const firstDigitIndex = value.search(/\d/);
|
|
3306
|
+
if (firstDigitIndex === -1)
|
|
3307
|
+
return value;
|
|
3308
|
+
const prefix = value.slice(0, firstDigitIndex);
|
|
3309
|
+
const suffixWithNumbers = value.slice(firstDigitIndex);
|
|
3310
|
+
const match = suffixWithNumbers.match(/^(\d+)(.*)$/);
|
|
3311
|
+
if (!match)
|
|
3312
|
+
return value;
|
|
3313
|
+
const rawNumber = match[1];
|
|
3314
|
+
const suffix = match[2];
|
|
3315
|
+
const formatted = this.applyDynamicCpfCnpjMask(rawNumber);
|
|
3316
|
+
return `${prefix}${formatted}${suffix}`;
|
|
3317
|
+
}
|
|
3318
|
+
applyDynamicCpfCnpjMask(value) {
|
|
3319
|
+
if (!value)
|
|
3320
|
+
return '';
|
|
3321
|
+
const alphanumerics = value.replace(/[^a-zA-Z0-9]/g, '');
|
|
3322
|
+
const isOnlyDigits = /^\d+$/.test(alphanumerics);
|
|
3323
|
+
if (isOnlyDigits && !this.isCpfOrCnpj(alphanumerics))
|
|
3324
|
+
return value;
|
|
3325
|
+
let masked = '';
|
|
3326
|
+
const isCpf = alphanumerics.length <= 11;
|
|
3327
|
+
if (isCpf) {
|
|
3328
|
+
for (let i = 0; i < alphanumerics.length; i++) {
|
|
3329
|
+
masked += alphanumerics[i];
|
|
3330
|
+
if (i === 2 || i === 5)
|
|
3331
|
+
masked += '.';
|
|
3332
|
+
else if (i === 8)
|
|
3333
|
+
masked += '-';
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
else {
|
|
3337
|
+
for (let i = 0; i < alphanumerics.length; i++) {
|
|
3338
|
+
masked += alphanumerics[i];
|
|
3339
|
+
if (i === 1 || i === 4)
|
|
3340
|
+
masked += '.';
|
|
3341
|
+
else if (i === 7)
|
|
3342
|
+
masked += '/';
|
|
3343
|
+
else if (i === 11)
|
|
3344
|
+
masked += '-';
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
return masked;
|
|
3348
|
+
}
|
|
3349
|
+
isCpfOrCnpj(value) {
|
|
3350
|
+
const cleaned = value.replace(/\D/g, '');
|
|
3351
|
+
return this.isValidCpf(cleaned) || this.isValidCnpj(cleaned);
|
|
3352
|
+
}
|
|
3353
|
+
isValidCpf(cpf) {
|
|
3354
|
+
if (cpf.length !== 11 || /^(\d)\1+$/.test(cpf))
|
|
3355
|
+
return false;
|
|
3356
|
+
const digits = cpf.split('').map(Number);
|
|
3357
|
+
const calcVerifier = (factor) => {
|
|
3358
|
+
let total = 0;
|
|
3359
|
+
for (let i = 0; i < factor - 1; i++) {
|
|
3360
|
+
total += digits[i] * (factor - i);
|
|
3361
|
+
}
|
|
3362
|
+
const rest = total % 11;
|
|
3363
|
+
return rest < 2 ? 0 : 11 - rest;
|
|
3364
|
+
};
|
|
3365
|
+
const dv1 = calcVerifier(10);
|
|
3366
|
+
const dv2 = calcVerifier(11);
|
|
3367
|
+
return dv1 === digits[9] && dv2 === digits[10];
|
|
3368
|
+
}
|
|
3369
|
+
isValidCnpj(cnpj) {
|
|
3370
|
+
if (cnpj.length !== 14 || /^(\d)\1+$/.test(cnpj))
|
|
3371
|
+
return false;
|
|
3372
|
+
const digits = cnpj.split('').map(Number);
|
|
3373
|
+
const calcVerifier = (length) => {
|
|
3374
|
+
const weights = length === 12 ? [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2] : [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
3375
|
+
const total = digits.slice(0, length).reduce((sum, num, idx) => sum + num * weights[idx], 0);
|
|
3376
|
+
const rest = total % 11;
|
|
3377
|
+
return rest < 2 ? 0 : 11 - rest;
|
|
3378
|
+
};
|
|
3379
|
+
const dv1 = calcVerifier(12);
|
|
3380
|
+
const dv2 = calcVerifier(13);
|
|
3381
|
+
return dv1 === digits[12] && dv2 === digits[13];
|
|
3382
|
+
}
|
|
3299
3383
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DropdownFieldComponent, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3300
3384
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: DropdownFieldComponent, selector: "vector-dropdown-field", inputs: { options: "options", isNgContent: "isNgContent", forceSelection: "forceSelection", isRequired: "isRequired", control: "control", label: "label", service: "service", paged: "paged", buttonAction: "buttonAction", dependencies: "dependencies", hiddenErrorMessage: "hiddenErrorMessage", dynamicFilters: "dynamicFilters", minLengthToService: "minLengthToService", initialLoad: "initialLoad", disabled: "disabled", limitScrollPage: "limitScrollPage", inputId: "inputId" }, outputs: { onFocus: "onFocus", onChange: "onChange" }, ngImport: i0, template: "<div class=\"relative\">\r\n <div class=\"input-container\">\r\n <div class=\"input-inner-container\" *ngIf=\"!isNgContent\">\r\n <p-dropdown\r\n *ngIf=\"dynamicFilters\"\r\n appendTo=\"body\"\r\n optionLabel=\"name\"\r\n optionValue=\"code\"\r\n [(ngModel)]=\"selectedDynamicFilter\"\r\n [options]=\"dynamicFilters\"\r\n [disabled]=\"disabled\"\r\n [inputId]=\"inputId\"\r\n >\r\n </p-dropdown>\r\n <p-autoComplete\r\n appendTo=\"body\"\r\n field=\"name\"\r\n [forceSelection]=\"forceSelection\"\r\n [dropdown]=\"true\"\r\n [formControl]=\"control\"\r\n [placeholder]=\"placeholder\"\r\n [suggestions]=\"pagedSuggestions\"\r\n [dropdownIcon]=\"dynamicFilters ? 'pi pi-search' : 'pi pi-chevron-down'\"\r\n [delay]=\"800\"\r\n (completeMethod)=\"search($event)\"\r\n (onShow)=\"onOpenAutocompletePanel()\"\r\n (onHide)=\"onHideAutocompletePanel()\"\r\n (onFocus)=\"onFocus.emit($event)\"\r\n (onChange)=\"onChange.emit($event)\"\r\n [disabled]=\"disabled\"\r\n [inputId]=\"inputId\"\r\n >\r\n </p-autoComplete>\r\n </div>\r\n\r\n <div class=\"input-inner-container\" *ngIf=\"isNgContent\">\r\n <p-autoComplete\r\n appendTo=\"body\"\r\n field=\"name\"\r\n [forceSelection]=\"forceSelection\"\r\n [dropdown]=\"true\"\r\n [formControl]=\"control\"\r\n [placeholder]=\"placeholder\"\r\n [suggestions]=\"pagedSuggestions\"\r\n [dropdownIcon]=\"dynamicFilters ? 'pi pi-search' : 'pi pi-chevron-down'\"\r\n [delay]=\"800\"\r\n (completeMethod)=\"search($event)\"\r\n (onShow)=\"onOpenAutocompletePanel()\"\r\n (onHide)=\"onHideAutocompletePanel()\"\r\n (onFocus)=\"onFocus.emit($event)\"\r\n (onChange)=\"onChange.emit($event)\"\r\n [disabled]=\"disabled\"\r\n [inputId]=\"inputId\"\r\n >\r\n <ng-template let-option pTemplate=\"item\">\r\n <div class=\"option-content\">\r\n <span class=\"option-label\">{{ option.name }}</span>\r\n <br />\r\n <span class=\"option-sublabel\">{{ option.code }}</span>\r\n </div>\r\n </ng-template>\r\n </p-autoComplete>\r\n </div>\r\n\r\n <vector-button\r\n *ngIf=\"buttonAction\"\r\n [label]=\"buttonAction.label\"\r\n [disabled]=\"disabled\"\r\n (onClick)=\"buttonAction.onClick(control.value)\"\r\n ></vector-button>\r\n </div>\r\n <vector-field-error-message *ngIf=\"!hiddenErrorMessage\" [control]=\"control\"></vector-field-error-message>\r\n</div>\r\n", styles: [".input-container{display:flex;align-items:flex-end;width:100%}@media (max-width: 575px){.input-container{align-items:flex-start;flex-direction:column}}.input-container p-autoComplete{flex:1}@media (max-width: 575px){.input-container p-autoComplete{width:100%}}.input-container vector-button{margin-left:15px}@media (max-width: 575px){.input-container vector-button{margin-left:0;margin-top:10px;width:100%}}.input-container p-dropdown{margin-right:-5px;width:150px}@media (max-width: 575px){.input-container p-dropdown{width:100px}}.input-container .input-inner-container{display:flex;width:100%}.p-dropdown-panel,.p-autocomplete-panel,.p-multiselect-panel{max-width:100%!important}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$5.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i1$5.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i2$2.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "component", type: i4$3.Dropdown, selector: "p-dropdown", inputs: ["id", "scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "filterPlaceholder", "filterLocale", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "dropdownIcon", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "disabled", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "filterValue", "options"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }, { kind: "component", type: i5$1.AutoComplete, selector: "p-autoComplete", inputs: ["minLength", "delay", "style", "panelStyle", "styleClass", "panelStyleClass", "inputStyle", "inputId", "inputStyleClass", "placeholder", "readonly", "disabled", "scrollHeight", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "maxlength", "name", "required", "size", "appendTo", "autoHighlight", "forceSelection", "type", "autoZIndex", "baseZIndex", "ariaLabel", "dropdownAriaLabel", "ariaLabelledBy", "dropdownIcon", "unique", "group", "completeOnFocus", "showClear", "field", "dropdown", "showEmptyMessage", "dropdownMode", "multiple", "tabindex", "dataKey", "emptyMessage", "showTransitionOptions", "hideTransitionOptions", "autofocus", "autocomplete", "optionGroupChildren", "optionGroupLabel", "overlayOptions", "suggestions", "itemSize", "optionLabel", "id", "searchMessage", "emptySelectionMessage", "selectionMessage", "autoOptionFocus", "selectOnFocus", "searchLocale", "optionDisabled", "focusOnHover"], outputs: ["completeMethod", "onSelect", "onUnselect", "onFocus", "onBlur", "onDropdownClick", "onClear", "onKeyUp", "onShow", "onHide", "onLazyLoad"] }, { kind: "component", type: ButtonComponent, selector: "vector-button", inputs: ["disabled", "label", "type", "leftIcon", "rightIcon", "noShadow", "round", "style", "loading"], outputs: ["onClick"] }, { kind: "component", type: FieldErrorMessageComponent, selector: "vector-field-error-message", inputs: ["control"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
3301
3385
|
}
|
|
@@ -3761,7 +3845,12 @@ class DataTableComponent {
|
|
|
3761
3845
|
content += `<div class="text-centered"><i class="${iconClass} status-table-field table-button"></i></div>`;
|
|
3762
3846
|
break;
|
|
3763
3847
|
case TableColumnType.MASK:
|
|
3764
|
-
|
|
3848
|
+
if (col.mask === 'dynamicCpfCnpj') {
|
|
3849
|
+
content += MaskUtil.formatDocument(cellText);
|
|
3850
|
+
}
|
|
3851
|
+
else {
|
|
3852
|
+
content += MaskUtil.doMaskString(cellText, col.mask);
|
|
3853
|
+
}
|
|
3765
3854
|
break;
|
|
3766
3855
|
case TableColumnType.CURRENCY:
|
|
3767
3856
|
content += Number(cellText).toLocaleString('pt-BR', {
|