@navservice/core 1.64.0 → 1.66.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.
@@ -1,877 +0,0 @@
1
- "use strict";
2
- const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
- return typeof document === 'undefined'
4
- ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
- : (document.currentScript && document.currentScript.src) ||
6
- new URL('main.js', document.baseURI).href;
7
- })();
8
- ;
9
- var __webpack_modules__ = ({
10
- "./src/index.browser.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
11
-
12
- // EXPORTS
13
- __webpack_require__.d(__webpack_exports__, {
14
- config_env_core: () => (/* reexport */ src_config_env)
15
- });
16
-
17
- // UNUSED EXPORTS: TypesCore, utils
18
-
19
- ;// CONCATENATED MODULE: ./src/config_env/index.ts
20
- class config_env {
21
- static SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
22
- static init(config) {
23
- config_env.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL = config.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL;
24
- }
25
- static get PUBLIC_BASE_URL_BACKEND_PRINCIPAL() {
26
- return this.SET_PUBLIC_BASE_URL_BACKEND_PRINCIPAL?.trim();
27
- }
28
- }
29
- /* export default */ const src_config_env = (config_env);
30
-
31
- ;// CONCATENATED MODULE: external "zod/v4"
32
- const v4_namespaceObject = require("zod/v4");
33
- var v4_default = /*#__PURE__*/__webpack_require__.n(v4_namespaceObject);
34
- ;// CONCATENATED MODULE: ./src/types/_usuario.ts
35
-
36
- (function(TypeControllerUsuario) {
37
- TypeControllerUsuario.AppEnum = [
38
- "service-usuario",
39
- "service-financeiro",
40
- "service-pages-ai"
41
- ];
42
- TypeControllerUsuario.UsuarioTipoEnum = [
43
- "padrao"
44
- ];
45
- const AppEnumZod = v4_default()["enum"]([
46
- "service-usuario",
47
- "service-financeiro",
48
- "service-pages-ai"
49
- ]);
50
- const UsuarioTipoEnumZod = v4_default()["enum"](TypeControllerUsuario.UsuarioTipoEnum);
51
- })(_usuario_TypeControllerUsuario || (_usuario_TypeControllerUsuario = {}));
52
- /* export default */ const _usuario = (_usuario_TypeControllerUsuario);
53
- var _usuario_TypeControllerUsuario;
54
-
55
- ;// CONCATENATED MODULE: ./src/types/_type_response.ts
56
-
57
- (function(TypeControllerResponse) {
58
- const StatusSchema = v4_default().union([
59
- v4_default().literal(200),
60
- v4_default().literal(201),
61
- v4_default().literal(202),
62
- v4_default().literal(204),
63
- v4_default().literal(400),
64
- v4_default().literal(401),
65
- v4_default().literal(403),
66
- v4_default().literal(404),
67
- v4_default().literal(409),
68
- v4_default().literal(422),
69
- v4_default().literal(500),
70
- v4_default().literal(428),
71
- v4_default().literal(405)
72
- ]);
73
- const TypeSchema = v4_default().union([
74
- v4_default().literal("success"),
75
- v4_default().literal("warning"),
76
- v4_default().literal("error")
77
- ]).default("success");
78
- const CodeSchema = v4_default().union([
79
- v4_default().literal("SUCCESS"),
80
- v4_default().literal("ACTION_REQUIRED"),
81
- v4_default().literal("CREATED"),
82
- v4_default().literal("WARNING"),
83
- v4_default().literal("AUTHORIZATION_ERROR"),
84
- v4_default().literal("SCHEMA_VALIDATION"),
85
- v4_default().literal("SERVER_ERROR"),
86
- v4_default().literal("UNAUTHORIZED"),
87
- v4_default().literal("INVALID_TOKEN"),
88
- v4_default().literal("NOT_FOUND"),
89
- v4_default().literal("SUCCESS_FILE"),
90
- v4_default().literal("DATABASE_ERROR")
91
- ]);
92
- const BaseResponseSchema = v4_default().object({
93
- status: StatusSchema,
94
- code: CodeSchema,
95
- type: TypeSchema,
96
- message: v4_default().string(),
97
- results: v4_default().unknown().optional(),
98
- error: v4_default().unknown().optional()
99
- });
100
- (function(C) {
101
- C.InputSchema = v4_default().object({
102
- status: StatusSchema,
103
- code: CodeSchema,
104
- type: TypeSchema.optional().default("success"),
105
- message: v4_default().string().optional(),
106
- results: v4_default().any(),
107
- c: v4_default().custom()
108
- });
109
- const FileResponseParamsSchema = v4_default().object({
110
- status: StatusSchema,
111
- message: v4_default().string().optional(),
112
- file_buffer: v4_default().union([
113
- v4_default()["instanceof"](Blob),
114
- v4_default()["instanceof"](ArrayBuffer),
115
- v4_default()["instanceof"](Uint8Array)
116
- ]),
117
- content_type: v4_default().string(),
118
- filename: v4_default().string().optional(),
119
- c: v4_default().custom().optional()
120
- });
121
- })(TypeControllerResponse.C || (TypeControllerResponse.C = {}));
122
- (function(Error) {
123
- Error.InputSchema = v4_default().object({
124
- message: v4_default().string().optional(),
125
- results: v4_default().union([
126
- v4_default().array(v4_default().unknown()),
127
- v4_default().unknown()
128
- ]).optional(),
129
- type: TypeSchema.optional().default("success"),
130
- code: CodeSchema,
131
- status: v4_default().number().optional().default(200)
132
- });
133
- })(TypeControllerResponse.Error || (TypeControllerResponse.Error = {}));
134
- })(_type_response_TypeControllerResponse || (_type_response_TypeControllerResponse = {}));
135
- /* export default */ const _type_response = (_type_response_TypeControllerResponse);
136
- var _type_response_TypeControllerResponse;
137
-
138
- ;// CONCATENATED MODULE: ./src/types/index.ts
139
- // ENTIDADES TIPADAS
140
-
141
- //GERAL
142
-
143
- (function(t) {
144
- (function(Controller) {
145
- Controller.Usuario = _usuario;
146
- })(t.Controller || (t.Controller = {}));
147
- (function(Geral) {
148
- Geral.Response = _type_response;
149
- })(t.Geral || (t.Geral = {}));
150
- })(types_t || (types_t = {}));
151
- /* export default */ const types = ((/* unused pure expression or super */ null && (types_t)));
152
- var types_t;
153
-
154
- // EXTERNAL MODULE: ./src/utils/index.ts + 11 modules
155
- var utils = __webpack_require__("./src/utils/index.ts");
156
- ;// CONCATENATED MODULE: ./src/index.browser.ts
157
-
158
-
159
-
160
-
161
-
162
- },
163
- "./src/utils/index.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
164
- // ESM COMPAT FLAG
165
- __webpack_require__.r(__webpack_exports__);
166
-
167
- // EXPORTS
168
- __webpack_require__.d(__webpack_exports__, {
169
- "default": () => (/* binding */ src_utils)
170
- });
171
-
172
- ;// CONCATENATED MODULE: external "axios"
173
- const external_axios_namespaceObject = require("axios");
174
- var external_axios_default = /*#__PURE__*/__webpack_require__.n(external_axios_namespaceObject);
175
- // EXTERNAL MODULE: ./src/index.browser.ts + 5 modules
176
- var index_browser = __webpack_require__("./src/index.browser.ts");
177
- ;// CONCATENATED MODULE: ./src/utils/_session_storage.ts
178
- const _session_storage = class _session_storage {
179
- static adicionar_item_session_storage({ chave, novoItem }) {
180
- try {
181
- const valorAtual = window.sessionStorage.getItem(chave);
182
- const listaAtual = valorAtual ? JSON.parse(valorAtual) : [];
183
- const newDataItem = {
184
- ...listaAtual,
185
- ...novoItem
186
- };
187
- window.sessionStorage.setItem(chave, JSON.stringify(newDataItem));
188
- } catch (error) {
189
- console.error(error);
190
- }
191
- }
192
- static set_session_storage_sem_incremento({ chave, novoItem }) {
193
- try {
194
- window.sessionStorage.setItem(chave, JSON.stringify(novoItem));
195
- } catch (error) {
196
- console.error(error);
197
- }
198
- }
199
- static get_item_session_storage(chave) {
200
- try {
201
- if (typeof window !== "undefined") {
202
- const valorAtual = window.sessionStorage.getItem(chave);
203
- return valorAtual ? JSON.parse(valorAtual) : valorAtual;
204
- }
205
- return;
206
- } catch (error) {
207
- console.error(error);
208
- }
209
- }
210
- static remover_item_session_storage(chave) {
211
- try {
212
- window.sessionStorage.removeItem(chave);
213
- } catch (error) {
214
- console.error(error);
215
- }
216
- }
217
- };
218
- /* export default */ const utils_session_storage = (_session_storage);
219
-
220
- ;// CONCATENATED MODULE: ./src/utils/_api.ts
221
-
222
-
223
-
224
- const _api_api = class _api {
225
- static servidor_pricipal = class servidor_pricipal {
226
- static get #axios() {
227
- return external_axios_default().create({
228
- baseURL: index_browser.config_env_core.PUBLIC_BASE_URL_BACKEND_PRINCIPAL
229
- });
230
- }
231
- static async post({ url, data, setToken = true }) {
232
- return await this.#axios.post(url, data, _api.headers({
233
- setToken: setToken
234
- }));
235
- }
236
- static async get({ url, params, setToken = true }) {
237
- const queryParams = new URLSearchParams();
238
- if (params) {
239
- Object.entries(params).forEach(([key, value])=>{
240
- if (value !== null && value !== undefined) {
241
- queryParams.append(key, value);
242
- }
243
- });
244
- }
245
- const queryString = queryParams.toString();
246
- const fullUrl = queryString ? `${url}?${queryString}` : url;
247
- return await this.#axios.get(fullUrl, _api.headers({
248
- setToken: setToken
249
- }));
250
- }
251
- static async patch({ url, data, setToken = true }) {
252
- return await this.#axios.patch(url, data, _api.headers({
253
- setToken: setToken
254
- }));
255
- }
256
- static async delete({ url }) {
257
- return await this.#axios.delete(url);
258
- }
259
- };
260
- static headers({ setToken = true }) {
261
- const get_auth_user = utils_session_storage.get_item_session_storage("auth_user");
262
- if (setToken === true) {
263
- return {
264
- headers: {
265
- Authorization: `Bearer ${get_auth_user?.data?.usuario?.token}`,
266
- "Content-type": "application/json"
267
- }
268
- };
269
- } else {
270
- return {
271
- headers: {
272
- "Content-type": "application/json"
273
- }
274
- };
275
- }
276
- }
277
- };
278
- /* export default */ const utils_api = (_api_api);
279
-
280
- ;// CONCATENATED MODULE: ./src/utils/_data.ts
281
- const _data = class _data {
282
- static YYYY_MM_DD_00_00_00(newData) {
283
- let dataAtual = new Date();
284
- if (newData) {
285
- dataAtual = new Date(newData);
286
- }
287
- const options = {
288
- timeZone: "America/Sao_Paulo",
289
- ano: "numeric",
290
- mes: "numeric",
291
- dia: "numeric",
292
- hora: "numeric"
293
- };
294
- const horarioFormatado = dataAtual.toLocaleString("pt-BR", options);
295
- const [data, hora] = horarioFormatado.split(",");
296
- const [dia, mes, ano] = data.split("/");
297
- return `${ano}-${mes}-${dia} ${hora}`;
298
- }
299
- static DD_MM_YYYY_00_00_00(newData) {
300
- let dataAtual = new Date();
301
- if (newData) {
302
- dataAtual = new Date(newData);
303
- }
304
- const options = {
305
- timeZone: "America/Sao_Paulo",
306
- ano: "numeric",
307
- mes: "numeric",
308
- dia: "numeric",
309
- hora: "numeric"
310
- };
311
- return dataAtual.toLocaleString("pt-BR", options);
312
- }
313
- static DD_MM_YYYY_00_00(newData) {
314
- let dataAtual = new Date();
315
- if (newData) {
316
- dataAtual = new Date(newData);
317
- }
318
- const options = {
319
- timeZone: "America/Sao_Paulo",
320
- ano: "numeric",
321
- mes: "numeric",
322
- dia: "numeric",
323
- hora: "numeric"
324
- };
325
- const dataFormatada = dataAtual.toLocaleString("pt-BR", options).replace(",", "");
326
- return dataFormatada;
327
- }
328
- static DD_MM_YYYY(newData) {
329
- let dataAtual = new Date();
330
- if (newData) {
331
- dataAtual = new Date(newData);
332
- }
333
- const options = {
334
- timeZone: "America/Sao_Paulo",
335
- ano: "numeric",
336
- mes: "numeric",
337
- dia: "numeric",
338
- hora: "numeric"
339
- };
340
- return dataAtual.toLocaleString("pt-BR", options);
341
- }
342
- static YYYY_MM_DD(newData) {
343
- let dataAtual = new Date();
344
- if (newData) {
345
- dataAtual = new Date(newData);
346
- }
347
- const options = {
348
- timeZone: "America/Sao_Paulo",
349
- ano: "numeric",
350
- mes: "numeric",
351
- dia: "numeric",
352
- hora: "numeric"
353
- };
354
- const horarioFormatado = dataAtual.toLocaleString("pt-BR", options);
355
- const [data] = horarioFormatado.split(",");
356
- const [dia, mes, ano] = data.split("/");
357
- return `${ano}-${mes}-${dia}`;
358
- }
359
- static DIFERENCA_SEGUNDOS(data) {
360
- var dataInicial = new Date(data);
361
- var dataAtual = new Date();
362
- var diferenca = Number(dataAtual) - Number(dataInicial);
363
- var diferencaEmSegundos = Math.floor(diferenca / 1000);
364
- return diferencaEmSegundos;
365
- }
366
- static DIFERENCA_DIAS(data) {
367
- var dataInicial = new Date(data);
368
- var dataAtual = new Date();
369
- var diferenca = dataAtual.getTime() - dataInicial.getTime(); // Obtém a diferença em milissegundos
370
- var diferencaEmDias = Math.floor(diferenca / (1000 * 60 * 60 * 24)); // Calcula a diferença em dias
371
- return diferencaEmDias;
372
- }
373
- };
374
- /* export default */ const utils_data = (_data);
375
-
376
- ;// CONCATENATED MODULE: ./src/utils/_form.ts
377
- class _form {
378
- static regex_cpf_cnpj(value) {
379
- let tempValue = value.replace(/\D/g, "");
380
- if (tempValue.length > 14) {
381
- tempValue = tempValue.slice(0, 14);
382
- }
383
- if (tempValue.length <= 11) {
384
- tempValue = tempValue.replace(/^(\d{0,3})(\d{0,3})(\d{0,3})(\d{0,2})$/, (match, p1, p2, p3, p4)=>{
385
- let result = p1;
386
- if (p2) result += "." + p2;
387
- if (p3) result += "." + p3;
388
- if (p4) result += "-" + p4;
389
- return result;
390
- });
391
- } else {
392
- tempValue = tempValue.replace(/^(\d{0,2})(\d{0,3})(\d{0,3})(\d{0,4})(\d{0,2})$/, (match, p1, p2, p3, p4, p5)=>{
393
- let result = p1;
394
- if (p2) result += "." + p2;
395
- if (p3) result += "." + p3;
396
- if (p4) result += "/" + p4;
397
- if (p5) result += "-" + p5;
398
- return result;
399
- });
400
- }
401
- return tempValue;
402
- }
403
- static formatar_cpf(value) {
404
- const cpf = value.replace(/\D/g, "");
405
- if (cpf.length > 11) {
406
- return cpf.slice(0, 11);
407
- }
408
- return cpf.replace(/^(\d{0,3})(\d{0,3})(\d{0,3})(\d{0,2})$/, (match, p1, p2, p3, p4)=>{
409
- let result = p1;
410
- if (p2) result += "." + p2;
411
- if (p3) result += "." + p3;
412
- if (p4) result += "-" + p4;
413
- return result;
414
- });
415
- }
416
- static formatar_cnpj(value) {
417
- const cnpj = value.replace(/\D/g, "");
418
- if (cnpj.length > 14) {
419
- return cnpj.slice(0, 14);
420
- }
421
- return cnpj.replace(/^(\d{0,2})(\d{0,3})(\d{0,3})(\d{0,4})(\d{0,2})$/, (match, p1, p2, p3, p4, p5)=>{
422
- let result = p1;
423
- if (p2) result += "." + p2;
424
- if (p3) result += "." + p3;
425
- if (p4) result += "/" + p4;
426
- if (p5) result += "-" + p5;
427
- return result;
428
- });
429
- }
430
- static formatar_cep(value) {
431
- const cep = value.replace(/\D/g, "");
432
- if (cep.length > 8) {
433
- return cep.slice(0, 8);
434
- }
435
- return cep.replace(/^(\d{0,5})(\d{0,3})$/, (match, p1, p2)=>{
436
- if (p2) return `${p1}-${p2}`;
437
- return p1;
438
- });
439
- }
440
- static formatar_telefone_fixo(value) {
441
- const telefone = value.replace(/\D/g, "");
442
- if (telefone.length > 10) {
443
- return telefone.slice(0, 10);
444
- }
445
- return telefone.replace(/^(\d{0,2})(\d{0,4})(\d{0,4})$/, (match, p1, p2, p3)=>{
446
- let result = "";
447
- if (p1) result += `(${p1}`;
448
- if (p2) result += `) ${p2}`;
449
- if (p3) result += `-${p3}`;
450
- return result;
451
- });
452
- }
453
- static formatar_celular(value) {
454
- const celular = value.replace(/\D/g, "");
455
- if (celular.length > 11) {
456
- return celular.slice(0, 11);
457
- }
458
- return celular.replace(/^(\d{0,2})(\d{0,5})(\d{0,4})$/, (match, p1, p2, p3)=>{
459
- let result = "";
460
- if (p1) result += `(${p1}`;
461
- if (p2) result += `) ${p2}`;
462
- if (p3) result += `-${p3}`;
463
- return result;
464
- });
465
- }
466
- static formatar_nome(name) {
467
- const lowercaseWords = [
468
- "de",
469
- "da",
470
- "do",
471
- "das",
472
- "dos",
473
- "e",
474
- "a",
475
- "o"
476
- ];
477
- const words = name.toLowerCase().split(" ");
478
- const formattedWords = words.map((word, index)=>{
479
- if (index === 0) {
480
- return word.charAt(0).toUpperCase() + word.slice(1);
481
- }
482
- if (lowercaseWords.includes(word)) {
483
- return word;
484
- }
485
- return word.charAt(0).toUpperCase() + word.slice(1);
486
- });
487
- return formattedWords.join(" ");
488
- }
489
- static formatar_reais_br(value) {
490
- let num = value.replace(/\D/g, "");
491
- return new Intl.NumberFormat("pt-BR", {
492
- style: "currency",
493
- currency: "BRL",
494
- minimumFractionDigits: 2
495
- }).format(Number(num) / 100);
496
- }
497
- }
498
- /* export default */ const utils_form = (_form);
499
-
500
- ;// CONCATENATED MODULE: ./src/utils/_geral.ts
501
- const geral = class geral {
502
- static slice_file_name(filename, maxLength = 30) {
503
- if (!filename || typeof filename !== "string") return "";
504
- // Encontra a última ocorrência do ponto para identificar a extensão
505
- const lastDotIndex = filename.lastIndexOf(".");
506
- // Se não houver extensão, trunca diretamente
507
- if (lastDotIndex === -1) {
508
- return filename.length > maxLength ? filename.substring(0, maxLength - 3) + "..." : filename;
509
- }
510
- const name = filename.substring(0, lastDotIndex);
511
- const extension = filename.substring(lastDotIndex);
512
- // Se o nome + extensão é menor que o máximo, retorna completo
513
- if (filename.length <= maxLength) return filename;
514
- // Calcula quanto espaço temos para o nome
515
- // Considerando: extensão + '...' + 1 caractere do nome
516
- const availableLength = maxLength - extension.length - 3;
517
- if (availableLength <= 0) {
518
- // Se não há espaço suficiente nem para 1 caractere do nome
519
- return name.substring(0, 1) + "..." + extension;
520
- }
521
- // Trunca o nome e mantém a extensão
522
- return name.substring(0, availableLength) + "..." + extension;
523
- }
524
- static extrair_id(array_enviado) {
525
- const ids = [];
526
- for(let i = 0; i < array_enviado.length; i++){
527
- if (array_enviado[i]?._id) ids.push(array_enviado[i]._id);
528
- }
529
- return ids;
530
- }
531
- static gerar_id = (length = 32)=>{
532
- // Caracteres permitidos (apenas alfanuméricos)
533
- const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
534
- // Timestamp em formato hexadecimal (sem separadores)
535
- const timestamp = Date.now().toString(16) + performance.now().toString(16).replace(".", "");
536
- // Inicializa resultado com timestamp para garantir unicidade temporal
537
- let result = timestamp;
538
- // Adiciona caracteres aleatórios até atingir o comprimento desejado
539
- while(result.length < length){
540
- const randomIndex = Math.floor(Math.random() * chars.length);
541
- result += chars[randomIndex];
542
- }
543
- // Combina com características do navegador para aumentar a unicidade
544
- const navigatorData = (window.navigator.userAgent + screen.width + screen.height).split("").map((c)=>c.charCodeAt(0)).reduce((a, b)=>a + b, 0).toString(36);
545
- // Combina os dados e corta para o tamanho correto
546
- const finalResult = (result + navigatorData).replace(/[^a-zA-Z0-9]/g, "");
547
- // Garante o comprimento exato
548
- return finalResult.substring(0, length);
549
- };
550
- };
551
- /* export default */ const _geral = (geral);
552
-
553
- ;// CONCATENATED MODULE: ./src/utils/_local_storage.ts
554
- const _local_storage = class _local_storage {
555
- static adicionar_item_local_storage(chave, novoItem) {
556
- try {
557
- const valorAtual = window.localStorage.getItem(chave);
558
- const listaAtual = valorAtual ? JSON.parse(valorAtual) : [];
559
- const newDataItem = {
560
- ...listaAtual,
561
- ...novoItem
562
- };
563
- window.localStorage.setItem(chave, JSON.stringify(newDataItem));
564
- } catch (error) {
565
- console.log(error);
566
- }
567
- }
568
- static set_local_storage_sem_incremento(chave, novoItem) {
569
- try {
570
- window.localStorage.setItem(chave, JSON.stringify(novoItem));
571
- } catch (error) {
572
- console.log(error);
573
- }
574
- }
575
- static get_item_local_storage(chave) {
576
- try {
577
- if (typeof window !== "undefined") {
578
- const valorAtual = window.localStorage.getItem(chave);
579
- return valorAtual ? JSON.parse(valorAtual) : valorAtual;
580
- }
581
- return;
582
- } catch (error) {
583
- console.log(error);
584
- }
585
- }
586
- static remover_item_local_storage(chave) {
587
- try {
588
- window.localStorage.removeItem(chave);
589
- } catch (error) {
590
- console.log(error);
591
- }
592
- }
593
- };
594
- // Para usar a classe, você pode fazer:
595
- /* export default */ const utils_local_storage = (_local_storage);
596
-
597
- ;// CONCATENATED MODULE: ./src/utils/_update_context.ts
598
- const _update_context = class _update_context {
599
- static set_new_item_end = ({ oldArray = [], newItem = [], key = "_id" })=>{
600
- try {
601
- const hasValidIds = Array.isArray(newItem) ? newItem.every((item)=>item?.[key]) : newItem?.[key];
602
- const newItemArray = hasValidIds ? Array.isArray(newItem) ? newItem : [
603
- newItem
604
- ] : oldArray;
605
- if (oldArray?.length === 0) return newItemArray;
606
- // Cria uma cópia rasa do array original
607
- const updatedArray = [
608
- ...oldArray
609
- ];
610
- // Itera sobre os novos itens
611
- newItemArray.forEach((novoItem)=>{
612
- const index = updatedArray.findIndex((oldItem)=>oldItem?.[key] === novoItem?.[key]);
613
- if (index !== -1) {
614
- // Atualiza o item existente mantendo as propriedades antigas que não estão no novo item
615
- novoItem.new = false;
616
- updatedArray[index] = {
617
- ...updatedArray[index],
618
- ...novoItem
619
- };
620
- } else {
621
- // Adiciona novo item no FINAL com a propriedade new = true
622
- novoItem.new = true;
623
- updatedArray.push(novoItem); // Usa push em vez de unshift
624
- }
625
- });
626
- return updatedArray;
627
- } catch (error) {
628
- console.error("Erro ao atualizar array:", error);
629
- return oldArray; // Retorna o array original em caso de erro
630
- }
631
- };
632
- static update_array_itens = ({ oldArray = [], newItem = [], key = "_id" })=>{
633
- try {
634
- const hasValidIds = Array.isArray(newItem) ? newItem.every((item)=>item?.[key]) : newItem?.[key];
635
- const newItemArray = hasValidIds ? Array.isArray(newItem) ? newItem : [
636
- newItem
637
- ] : oldArray;
638
- if (oldArray?.length === 0) return newItemArray;
639
- // Cria uma cópia rasa do array original
640
- const updatedArray = [
641
- ...oldArray
642
- ];
643
- // Itera sobre os novos itens
644
- newItemArray.forEach((novoItem)=>{
645
- const index = updatedArray.findIndex((oldItem)=>oldItem?.[key] === novoItem?.[key]);
646
- if (index !== -1) {
647
- // Atualiza o item existente mantendo as propriedades antigas que não estão no novo item
648
- novoItem.new = false;
649
- updatedArray[index] = {
650
- ...updatedArray[index],
651
- ...novoItem
652
- };
653
- } else {
654
- // Adiciona novo item no início com a propriedade new = true
655
- novoItem.new = true;
656
- updatedArray.unshift(novoItem);
657
- }
658
- });
659
- return updatedArray;
660
- } catch (error) {
661
- console.error("Erro ao atualizar array:", error);
662
- return oldArray; // Retorna o array original em caso de erro
663
- }
664
- };
665
- static remove_array_items = ({ oldArray = [], itemsToRemove = [], key = "_id" })=>{
666
- try {
667
- // Verifica se os argumentos são válidos
668
- if (!Array.isArray(oldArray) || oldArray.length === 0) return oldArray;
669
- if (!itemsToRemove) return oldArray;
670
- // Converte itemsToRemove para array se for um único item
671
- const itemsArray = Array.isArray(itemsToRemove) ? itemsToRemove : [
672
- itemsToRemove
673
- ];
674
- // Se não houver itens para remover, retorna o array original
675
- if (itemsArray.length === 0) return oldArray;
676
- // Cria um Set com os IDs dos itens a serem removidos para busca mais eficiente
677
- const removeIds = new Set(itemsArray.filter((item)=>item?.[key]).map((item)=>item[key]));
678
- // Filtra o array original removendo os itens cujos IDs estão no Set
679
- const updatedArray = oldArray.filter((item)=>!removeIds.has(item?.[key]));
680
- return updatedArray;
681
- } catch (error) {
682
- console.error("Erro ao remover itens do array:", error);
683
- return oldArray; // Retorna o array original em caso de erro
684
- }
685
- };
686
- static compare_arrays({ arrayAntigo, arrayNovo }) {
687
- // Cria Sets para performance
688
- const idsAntigos = new Set(arrayAntigo.map((item)=>item._id));
689
- const idsNovos = new Set(arrayNovo.map((item)=>item._id));
690
- // Mantém apenas os itens do array antigo que ainda existem no novo
691
- const itensMantidos = arrayAntigo.filter((item)=>idsNovos.has(item._id));
692
- // Adiciona os itens novos que não existiam no array antigo
693
- const itensNovos = arrayNovo.filter((item)=>!idsAntigos.has(item._id));
694
- // Combina os arrays
695
- return [
696
- ...itensMantidos,
697
- ...itensNovos
698
- ];
699
- }
700
- };
701
- /* export default */ const utils_update_context = (_update_context);
702
-
703
- ;// CONCATENATED MODULE: ./src/utils/_sistema.ts
704
- const _sistema = {
705
- empresa: {
706
- nome: "Nav Software",
707
- email_suporte: "suporte@navsoftware.com.br",
708
- email_no_replay: "no-replay@navsoftware.com.br",
709
- razaoSocial: "Nav Software Desenvolvimento de Sistemas Ltda",
710
- cnpj: "00.000.000/0001-00",
711
- inscricaoEstadual: "000.000.000.000",
712
- inscricaoMunicipal: "000000",
713
- endereco: {
714
- logradouro: "Rua Exemplo",
715
- numero: "000",
716
- complemento: "Sala 00",
717
- bairro: "Centro",
718
- cidade: "Navegantes",
719
- estado: "SC",
720
- cep: "88370-000",
721
- pais: "Brasil"
722
- },
723
- contato: {
724
- telefone: "(47) 0000-0000",
725
- celular: "(47) 90000-0000",
726
- email: "contato@navsoftware.com.br",
727
- site: "https://www.navsoftware.com.br"
728
- },
729
- dadosBancarios: {
730
- banco: "000 - Banco Exemplo",
731
- agencia: "0000",
732
- conta: "00000-0",
733
- tipoConta: "Conta Corrente",
734
- pix: "contato@navsoftware.com.br"
735
- },
736
- responsavel: {
737
- nome: "Nome do Responsável",
738
- cpf: "000.000.000-00",
739
- cargo: "Diretor",
740
- email: "responsavel@navsoftware.com.br"
741
- },
742
- configuracoes: {
743
- ativo: true,
744
- dataFundacao: "2020-01-01",
745
- regimeTributario: "Simples Nacional",
746
- ramoAtividade: "Desenvolvimento de Software",
747
- cnae: "62.01-5-00",
748
- porteEmpresa: "ME" // ME, EPP, ou outro
749
- }
750
- }
751
- };
752
- /* export default */ const utils_sistema = (_sistema);
753
-
754
- ;// CONCATENATED MODULE: external "react"
755
- const external_react_namespaceObject = require("react");
756
- ;// CONCATENATED MODULE: ./src/utils/_hooks.ts
757
-
758
- class _hooks {
759
- use_is_mobile() {
760
- const [isMobile, setIsMobile] = (0,external_react_namespaceObject.useState)(false);
761
- (0,external_react_namespaceObject.useLayoutEffect)(()=>{
762
- const updateSize = ()=>setIsMobile(window.innerWidth < 768);
763
- window.addEventListener("resize", updateSize);
764
- updateSize();
765
- return ()=>window.removeEventListener("resize", updateSize);
766
- }, []);
767
- return isMobile;
768
- }
769
- use_dark_mode() {
770
- if (localStorage.getItem("theme") === "dark") {
771
- document.documentElement.classList.add("dark");
772
- localStorage.setItem("theme", "dark");
773
- } else {
774
- document.documentElement.classList.remove("dark");
775
- localStorage.setItem("theme", "light");
776
- }
777
- }
778
- }
779
- /* export default */ const utils_hooks = (new _hooks);
780
-
781
- ;// CONCATENATED MODULE: ./src/utils/index.ts
782
-
783
-
784
-
785
-
786
-
787
-
788
-
789
-
790
-
791
- const utils = {
792
- api: utils_api,
793
- data: utils_data,
794
- form: utils_form,
795
- geral: _geral,
796
- local_storage: utils_local_storage,
797
- update_context: utils_update_context,
798
- session_sorage: utils_session_storage,
799
- sistema: utils_sistema,
800
- hooks: utils_hooks
801
- };
802
- /* export default */ const src_utils = (utils);
803
-
804
-
805
- },
806
-
807
- });
808
- // The module cache
809
- var __webpack_module_cache__ = {};
810
-
811
- // The require function
812
- function __webpack_require__(moduleId) {
813
-
814
- // Check if module is in cache
815
- var cachedModule = __webpack_module_cache__[moduleId];
816
- if (cachedModule !== undefined) {
817
- return cachedModule.exports;
818
- }
819
- // Create a new module (and put it into the cache)
820
- var module = (__webpack_module_cache__[moduleId] = {
821
- exports: {}
822
- });
823
- // Execute the module function
824
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
825
-
826
- // Return the exports of the module
827
- return module.exports;
828
-
829
- }
830
-
831
- // webpack/runtime/compat_get_default_export
832
- (() => {
833
- // getDefaultExport function for compatibility with non-ESM modules
834
- __webpack_require__.n = (module) => {
835
- var getter = module && module.__esModule ?
836
- () => (module['default']) :
837
- () => (module);
838
- __webpack_require__.d(getter, { a: getter });
839
- return getter;
840
- };
841
-
842
- })();
843
- // webpack/runtime/define_property_getters
844
- (() => {
845
- __webpack_require__.d = (exports, definition) => {
846
- for(var key in definition) {
847
- if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
848
- Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
849
- }
850
- }
851
- };
852
- })();
853
- // webpack/runtime/has_own_property
854
- (() => {
855
- __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
856
- })();
857
- // webpack/runtime/make_namespace_object
858
- (() => {
859
- // define __esModule on exports
860
- __webpack_require__.r = (exports) => {
861
- if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
862
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
863
- }
864
- Object.defineProperty(exports, '__esModule', { value: true });
865
- };
866
- })();
867
- // startup
868
- // Load entry module and return exports
869
- // This entry module is referenced by other modules so it can't be inlined
870
- var __webpack_exports__ = __webpack_require__("./src/utils/index.ts");
871
- exports["default"] = __webpack_exports__["default"];
872
- for(var __rspack_i in __webpack_exports__) {
873
- if(["default"].indexOf(__rspack_i) === -1) {
874
- exports[__rspack_i] = __webpack_exports__[__rspack_i];
875
- }
876
- }
877
- Object.defineProperty(exports, '__esModule', { value: true });