@gipisistemas/ngx-core 1.0.26 → 1.0.28
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.
|
@@ -41,7 +41,9 @@
|
|
|
41
41
|
|
|
42
42
|
.g-confirm-dialog-content {
|
|
43
43
|
display: flex !important;
|
|
44
|
+
flex-direction: column !important;
|
|
44
45
|
align-items: flex-start !important;
|
|
46
|
+
gap: 1.6rem !important;
|
|
45
47
|
padding: 0 2rem !important;
|
|
46
48
|
color: $secondary-900 !important;
|
|
47
49
|
font-family: $font-family !important;
|
|
@@ -50,6 +52,14 @@
|
|
|
50
52
|
min-height: 8rem !important;
|
|
51
53
|
max-height: 30rem !important;
|
|
52
54
|
overflow-y: auto !important;
|
|
55
|
+
|
|
56
|
+
.g-confirm-dialog-list-message {
|
|
57
|
+
padding-left: 1.6rem !important;
|
|
58
|
+
|
|
59
|
+
> li {
|
|
60
|
+
line-height: 2.4 !important;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
53
63
|
}
|
|
54
64
|
|
|
55
65
|
.g-confirm-dialog-actions {
|
|
@@ -704,7 +704,8 @@ class StringUtil {
|
|
|
704
704
|
}
|
|
705
705
|
}
|
|
706
706
|
/**
|
|
707
|
-
* Trunca uma string para um tamanho máximo especificado e adiciona um sufixo (por padrão, '...')
|
|
707
|
+
* Trunca uma string para um tamanho máximo especificado e adiciona um sufixo (por padrão, '...')
|
|
708
|
+
* caso o limite seja ultrapassado.
|
|
708
709
|
*
|
|
709
710
|
* @param inp A string que será truncada.
|
|
710
711
|
* @param maxLength O tamanho máximo da string antes do truncamento. (padrão é 50)
|
|
@@ -1829,7 +1830,8 @@ class CurrencyUtil {
|
|
|
1829
1830
|
* @param inp Número a ser formatado.
|
|
1830
1831
|
* @param options Configurações de formatação:
|
|
1831
1832
|
* - `digitsInfo` (opcional): Define o formato dos dígitos, como `1.2-2` (mínimo 1 inteiro, 2 casas decimais).
|
|
1832
|
-
* - `isPercent` (opcional): Se `true`, formata como porcentagem (ex: `0.5` → `50%`); caso contrário,
|
|
1833
|
+
* - `isPercent` (opcional): Se `true`, formata como porcentagem (ex: `0.5` → `50%`); caso contrário,
|
|
1834
|
+
* como moeda (`R$`).
|
|
1833
1835
|
*
|
|
1834
1836
|
* @returns Uma string com o número formatado como moeda ou porcentagem.
|
|
1835
1837
|
*/
|
|
@@ -2167,17 +2169,25 @@ class DocumentUtil {
|
|
|
2167
2169
|
return index === input.length - 1;
|
|
2168
2170
|
}
|
|
2169
2171
|
/**
|
|
2170
|
-
*
|
|
2171
|
-
*
|
|
2172
|
-
*
|
|
2172
|
+
* Remove caracteres de formatação de um CPF/CNPJ.
|
|
2173
|
+
*
|
|
2174
|
+
* Caso o valor contenha letras, mantém apenas caracteres alfanuméricos.
|
|
2175
|
+
* Caso contrário, mantém apenas números.
|
|
2176
|
+
*
|
|
2177
|
+
* @param value O valor que terá a formatação removida.
|
|
2178
|
+
* @returns O valor sem caracteres de formatação.
|
|
2179
|
+
*
|
|
2173
2180
|
* @example
|
|
2174
|
-
* DocumentUtil.
|
|
2181
|
+
* DocumentUtil.clearFormat('00.123.123/0001-12'); // Retorna: '00123123000112'
|
|
2182
|
+
* DocumentUtil.clearFormat('XH.BYE.J7E/0001-67'); // Retorna: 'XHBYEJ7E000167'
|
|
2175
2183
|
*/
|
|
2176
2184
|
static clearFormat(value) {
|
|
2177
2185
|
if (StringUtil.isEmpty(value)) {
|
|
2178
2186
|
return '';
|
|
2179
2187
|
}
|
|
2180
|
-
return value
|
|
2188
|
+
return /[a-zA-Z]/.test(value)
|
|
2189
|
+
? value.replace(/[^a-zA-Z0-9]/g, '')
|
|
2190
|
+
: value.replace(/\D/g, '');
|
|
2181
2191
|
}
|
|
2182
2192
|
/**
|
|
2183
2193
|
* Formata um CPF.
|
|
@@ -2267,97 +2277,132 @@ class DocumentUtil {
|
|
|
2267
2277
|
return true;
|
|
2268
2278
|
}
|
|
2269
2279
|
/**
|
|
2270
|
-
* Formata um CNPJ.
|
|
2271
|
-
*
|
|
2272
|
-
*
|
|
2273
|
-
*
|
|
2280
|
+
* Formata um CNPJ numérico ou alfanumérico.
|
|
2281
|
+
*
|
|
2282
|
+
* A função remove automaticamente caracteres de formatação antes de aplicar
|
|
2283
|
+
* a máscara padrão de CNPJ: `00.000.000/0000-00`.
|
|
2284
|
+
*
|
|
2285
|
+
* Também suporta:
|
|
2286
|
+
* - CNPJ alfanumérico;
|
|
2287
|
+
* - preenchimento automático com zeros à esquerda (`pad`);
|
|
2288
|
+
* - formatação parcial para utilização em campos de digitação (`allowPartial`).
|
|
2289
|
+
*
|
|
2290
|
+
* Quando `allowPartial` estiver ativado, a máscara será aplicada
|
|
2291
|
+
* gradualmente conforme a quantidade de caracteres informados.
|
|
2292
|
+
*
|
|
2293
|
+
* Caso `allowPartial` esteja desativado, apenas valores com 14 caracteres
|
|
2294
|
+
* serão formatados. Caso contrário, será retornada uma string vazia.
|
|
2295
|
+
*
|
|
2296
|
+
* @param cnpj O CNPJ que será formatado.
|
|
2297
|
+
* @param options Opções de formatação.
|
|
2298
|
+
* @param options.pad Define se o valor deve ser preenchido com zeros à esquerda até atingir 14 caracteres.
|
|
2299
|
+
* @param options.allowPartial Define se a máscara parcial deve ser aplicada durante a digitação.
|
|
2300
|
+
*
|
|
2301
|
+
* @returns O CNPJ formatado ou uma string vazia caso o valor seja inválido.
|
|
2302
|
+
*
|
|
2274
2303
|
* @example
|
|
2275
|
-
* DocumentUtil.formatCnpj('
|
|
2276
|
-
* DocumentUtil.formatCnpj('
|
|
2304
|
+
* DocumentUtil.formatCnpj('12345678000190'); // Retorna: '12.345.678/0001-90'
|
|
2305
|
+
* DocumentUtil.formatCnpj('12ABC3450001XX'); // Retorna: '12.ABC.345/0001-XX'
|
|
2306
|
+
* DocumentUtil.formatCnpj('1234567890', { pad: true }); // Retorna: '00.001.234/5678-90'
|
|
2307
|
+
* DocumentUtil.formatCnpj('12ABC345', { allowPartial: true }); // Retorna: '12.ABC.345'
|
|
2308
|
+
* DocumentUtil.formatCnpj('123'); // Retorna: ''
|
|
2277
2309
|
*/
|
|
2278
|
-
static formatCnpj(cnpj,
|
|
2279
|
-
|
|
2310
|
+
static formatCnpj(cnpj, options) {
|
|
2311
|
+
const pad = options?.pad ?? false;
|
|
2312
|
+
const allowPartial = options?.allowPartial ?? false;
|
|
2313
|
+
let cleanCnpj = this.clearFormat(cnpj).toUpperCase();
|
|
2280
2314
|
if (pad) {
|
|
2281
|
-
|
|
2315
|
+
cleanCnpj = cleanCnpj.padStart(14, '0');
|
|
2282
2316
|
}
|
|
2283
|
-
|
|
2284
|
-
const
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
.split('')
|
|
2289
|
-
.reduce((acc, digit, index) => {
|
|
2290
|
-
const result = `${acc}${digit}`;
|
|
2291
|
-
if (!this._isLastChar(index, digits)) {
|
|
2292
|
-
if (DOT_INDEXES.includes(index))
|
|
2293
|
-
return `${result}.`;
|
|
2294
|
-
if (SLASH_INDEXES.includes(index))
|
|
2295
|
-
return `${result}/`;
|
|
2296
|
-
if (HYPHEN_INDEXES.includes(index))
|
|
2297
|
-
return `${result}-`;
|
|
2317
|
+
cleanCnpj = cleanCnpj.slice(0, 14);
|
|
2318
|
+
const size = cleanCnpj.length;
|
|
2319
|
+
if (allowPartial) {
|
|
2320
|
+
if (size <= 2) {
|
|
2321
|
+
return cleanCnpj;
|
|
2298
2322
|
}
|
|
2299
|
-
|
|
2300
|
-
|
|
2323
|
+
if (size <= 5) {
|
|
2324
|
+
return `${cleanCnpj.slice(0, 2)}.${cleanCnpj.slice(2)}`;
|
|
2325
|
+
}
|
|
2326
|
+
if (size <= 8) {
|
|
2327
|
+
return `${cleanCnpj.slice(0, 2)}.${cleanCnpj.slice(2, 5)}.${cleanCnpj.slice(5)}`;
|
|
2328
|
+
}
|
|
2329
|
+
if (size <= 12) {
|
|
2330
|
+
return `${cleanCnpj.slice(0, 2)}.${cleanCnpj.slice(2, 5)}.${cleanCnpj.slice(5, 8)}/${cleanCnpj.slice(8)}`;
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
else if (size !== 14) {
|
|
2334
|
+
return '';
|
|
2335
|
+
}
|
|
2336
|
+
return cleanCnpj.replace(/(.{2})(.{3})(.{3})(.{4})(.{1,2})/, '$1.$2.$3/$4-$5');
|
|
2301
2337
|
}
|
|
2302
2338
|
/**
|
|
2303
|
-
*
|
|
2304
|
-
*
|
|
2305
|
-
*
|
|
2339
|
+
* Valida um CNPJ numérico ou alfanumérico.
|
|
2340
|
+
*
|
|
2341
|
+
* A função aceita CNPJ com ou sem máscara, remove os caracteres de formatação
|
|
2342
|
+
* e valida o dígito verificador conforme a regra oficial baseada no valor ASCII
|
|
2343
|
+
* do caractere subtraído de 48 (`charCodeAt(0) - 48`).
|
|
2344
|
+
*
|
|
2345
|
+
* Regras aplicadas:
|
|
2346
|
+
* - aceita CNPJ numérico e alfanumérico;
|
|
2347
|
+
* - aceita valores com máscara, como `12.345.678/0001-90`;
|
|
2348
|
+
* - aceita letras minúsculas, convertendo internamente para maiúsculas;
|
|
2349
|
+
* - exige exatamente 14 caracteres após a limpeza;
|
|
2350
|
+
* - exige que os 2 últimos caracteres sejam dígitos verificadores numéricos;
|
|
2351
|
+
* - rejeita sequências inválidas repetidas, como `00000000000000`, `11111111111111`, `AAAAAAAAAAAA00`, entre outras;
|
|
2352
|
+
* - rejeita caracteres não permitidos.
|
|
2353
|
+
*
|
|
2354
|
+
* @param cnpj O CNPJ que será validado.
|
|
2355
|
+
* @returns `true` se o CNPJ for válido, caso contrário `false`.
|
|
2356
|
+
*
|
|
2306
2357
|
* @example
|
|
2307
|
-
* DocumentUtil.isValidCnpj('12.345.678/0001-
|
|
2308
|
-
* DocumentUtil.isValidCnpj('
|
|
2309
|
-
* DocumentUtil.isValidCnpj('
|
|
2310
|
-
* DocumentUtil.isValidCnpj('123456780001090'); // Retorna `false`.
|
|
2358
|
+
* DocumentUtil.isValidCnpj('12.345.678/0001-90'); // Retorna: true ou false conforme os dígitos verificadores.
|
|
2359
|
+
* DocumentUtil.isValidCnpj('12ABC3450001XX'); // Retorna: false, pois os dois últimos caracteres devem ser números.
|
|
2360
|
+
* DocumentUtil.isValidCnpj('AAAAAAAAAAAA00'); // Retorna: false.
|
|
2311
2361
|
*/
|
|
2312
2362
|
static isValidCnpj(cnpj) {
|
|
2313
2363
|
if (StringUtil.isEmpty(cnpj)) {
|
|
2314
2364
|
return false;
|
|
2315
2365
|
}
|
|
2316
|
-
|
|
2317
|
-
if (StringUtil.isEmpty(cnpj) ||
|
|
2318
|
-
cnpj.length !== 14 ||
|
|
2319
|
-
cnpj === '00000000000000' ||
|
|
2320
|
-
cnpj === '11111111111111' ||
|
|
2321
|
-
cnpj === '22222222222222' ||
|
|
2322
|
-
cnpj === '33333333333333' ||
|
|
2323
|
-
cnpj === '44444444444444' ||
|
|
2324
|
-
cnpj === '55555555555555' ||
|
|
2325
|
-
cnpj === '66666666666666' ||
|
|
2326
|
-
cnpj === '77777777777777' ||
|
|
2327
|
-
cnpj === '88888888888888' ||
|
|
2328
|
-
cnpj === '99999999999999') {
|
|
2366
|
+
if (/[^A-Z0-9./-]/i.test(cnpj)) {
|
|
2329
2367
|
return false;
|
|
2330
2368
|
}
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
let sum = 0;
|
|
2335
|
-
let pos = length - 7;
|
|
2336
|
-
for (let i = length; i >= 1; i--) {
|
|
2337
|
-
sum += +numbers.charAt(length - i) * pos--;
|
|
2338
|
-
if (pos < 2) {
|
|
2339
|
-
pos = 9;
|
|
2340
|
-
}
|
|
2369
|
+
const cleanCnpj = this.clearFormat(cnpj).toUpperCase();
|
|
2370
|
+
if (!/^[A-Z0-9]{12}\d{2}$/.test(cleanCnpj)) {
|
|
2371
|
+
return false;
|
|
2341
2372
|
}
|
|
2342
|
-
|
|
2343
|
-
if (resultado !== +digits.charAt(0)) {
|
|
2373
|
+
if (/^([A-Z0-9])\1{13}$/.test(cleanCnpj)) {
|
|
2344
2374
|
return false;
|
|
2345
2375
|
}
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
sum = 0;
|
|
2349
|
-
pos = length - 7;
|
|
2350
|
-
for (let i = length; i >= 1; i--) {
|
|
2351
|
-
sum += +numbers.charAt(length - i) * pos--;
|
|
2352
|
-
if (pos < 2) {
|
|
2353
|
-
pos = 9;
|
|
2354
|
-
}
|
|
2376
|
+
if (/^([A-Z0-9])\1{11}\d{2}$/.test(cleanCnpj)) {
|
|
2377
|
+
return false;
|
|
2355
2378
|
}
|
|
2356
|
-
|
|
2357
|
-
|
|
2379
|
+
let size = 12;
|
|
2380
|
+
let numbers = cleanCnpj.substring(0, size);
|
|
2381
|
+
const digits = cleanCnpj.substring(size);
|
|
2382
|
+
let sum = 0;
|
|
2383
|
+
let weight = 2;
|
|
2384
|
+
for (let i = size - 1; i >= 0; i--) {
|
|
2385
|
+
const charValue = numbers.charCodeAt(i) - 48;
|
|
2386
|
+
sum += charValue * weight;
|
|
2387
|
+
weight = weight === 9 ? 2 : weight + 1;
|
|
2388
|
+
}
|
|
2389
|
+
let remainder = sum % 11;
|
|
2390
|
+
let result = remainder < 2 ? 0 : 11 - remainder;
|
|
2391
|
+
if (result !== parseInt(digits.charAt(0), 10)) {
|
|
2358
2392
|
return false;
|
|
2359
2393
|
}
|
|
2360
|
-
|
|
2394
|
+
size = 13;
|
|
2395
|
+
numbers = cleanCnpj.substring(0, size);
|
|
2396
|
+
sum = 0;
|
|
2397
|
+
weight = 2;
|
|
2398
|
+
for (let i = size - 1; i >= 0; i--) {
|
|
2399
|
+
const charValue = numbers.charCodeAt(i) - 48;
|
|
2400
|
+
sum += charValue * weight;
|
|
2401
|
+
weight = weight === 9 ? 2 : weight + 1;
|
|
2402
|
+
}
|
|
2403
|
+
remainder = sum % 11;
|
|
2404
|
+
result = remainder < 2 ? 0 : 11 - remainder;
|
|
2405
|
+
return result === parseInt(digits.charAt(1), 10);
|
|
2361
2406
|
}
|
|
2362
2407
|
/**
|
|
2363
2408
|
* Formata um CEP.
|
|
@@ -4151,7 +4196,7 @@ class BaseCrudService extends BaseService {
|
|
|
4151
4196
|
* deleteAll(['123e4567-e89b-12d3-a456-426614174000', '987e6543-e21b-12d3-a456-426614174001'])
|
|
4152
4197
|
* .subscribe(isDeleted => console.log(isDeleted));
|
|
4153
4198
|
*/
|
|
4154
|
-
deleteAll(idList, version) {
|
|
4199
|
+
deleteAll(idList, version = 'v2') {
|
|
4155
4200
|
for (const uuid of idList) {
|
|
4156
4201
|
if (!UUIDUtil.isValid(uuid)) {
|
|
4157
4202
|
return of(false);
|
|
@@ -5480,7 +5525,7 @@ class BaseListComponent extends BaseComponent {
|
|
|
5480
5525
|
cancel: () => this.loading.set(false),
|
|
5481
5526
|
});
|
|
5482
5527
|
}
|
|
5483
|
-
deleteAllRegister(idList, permission, fetchAgain = true, version) {
|
|
5528
|
+
deleteAllRegister(idList, permission, fetchAgain = true, version = 'v2') {
|
|
5484
5529
|
try {
|
|
5485
5530
|
idList = this.handleEntityIdList(idList);
|
|
5486
5531
|
if (ArrayUtil.isEmpty(idList)) {
|
|
@@ -23028,7 +23073,7 @@ class TreeTable {
|
|
|
23028
23073
|
return this._data;
|
|
23029
23074
|
}
|
|
23030
23075
|
constructor() {
|
|
23031
|
-
this.matPaginatorRef = viewChild
|
|
23076
|
+
this.matPaginatorRef = viewChild(MatPaginator, ...(ngDevMode ? [{ debugName: "matPaginatorRef" }] : []));
|
|
23032
23077
|
this.actionsRef = contentChild('actions', ...(ngDevMode ? [{ debugName: "actionsRef" }] : []));
|
|
23033
23078
|
this.menuContextRef = contentChild('menuContext', ...(ngDevMode ? [{ debugName: "menuContextRef" }] : []));
|
|
23034
23079
|
this._uniqueId = inject(_IdGenerator).getId('gipi-tree-table-');
|
|
@@ -23085,22 +23130,22 @@ class TreeTable {
|
|
|
23085
23130
|
this.onPage = output();
|
|
23086
23131
|
}
|
|
23087
23132
|
ngOnInit() {
|
|
23088
|
-
|
|
23089
|
-
|
|
23090
|
-
|
|
23091
|
-
.pipe(takeUntilDestroyed(this._destroyRef))
|
|
23092
|
-
.subscribe(() => this._emitPaginator());
|
|
23093
|
-
}
|
|
23133
|
+
this.matPaginatorRef()
|
|
23134
|
+
?.page.pipe(takeUntilDestroyed(this._destroyRef))
|
|
23135
|
+
.subscribe(() => this._emitPaginator());
|
|
23094
23136
|
}
|
|
23095
23137
|
_emitPaginator() {
|
|
23096
|
-
const
|
|
23097
|
-
|
|
23098
|
-
|
|
23099
|
-
|
|
23100
|
-
|
|
23101
|
-
|
|
23102
|
-
|
|
23103
|
-
|
|
23138
|
+
const paginator = this.matPaginatorRef();
|
|
23139
|
+
if (!paginator) {
|
|
23140
|
+
return;
|
|
23141
|
+
}
|
|
23142
|
+
this.onPage.emit({
|
|
23143
|
+
pageIndex: paginator.pageIndex,
|
|
23144
|
+
previousPageIndex: paginator.pageIndex - 1,
|
|
23145
|
+
pageSize: paginator.pageSize,
|
|
23146
|
+
length: paginator.length,
|
|
23147
|
+
pageSizeOptions: paginator.pageSizeOptions,
|
|
23148
|
+
});
|
|
23104
23149
|
}
|
|
23105
23150
|
_getNodeChildren(node) {
|
|
23106
23151
|
const propertyChildren = this.propertyTree;
|