@navservice/core 1.62.0 → 1.63.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/build/es/index.browser.d.ts +1 -0
- package/build/es/index.browser.js +520 -1
- package/build/es/utils.js +106 -106
- package/build/lib/index.browser.cjs +717 -42
- package/build/lib/index.browser.d.ts +1 -0
- package/build/lib/utils.cjs +71 -66
- package/package.json +1 -1
package/build/es/utils.js
CHANGED
|
@@ -118,96 +118,7 @@ var _type_response_TypeControllerResponse;
|
|
|
118
118
|
})(t.Geral || (t.Geral = {}));
|
|
119
119
|
})(types_t || (types_t = {}));
|
|
120
120
|
var types_t;
|
|
121
|
-
const
|
|
122
|
-
static adicionar_item_session_storage({ chave, novoItem }) {
|
|
123
|
-
try {
|
|
124
|
-
const valorAtual = window.sessionStorage.getItem(chave);
|
|
125
|
-
const listaAtual = valorAtual ? JSON.parse(valorAtual) : [];
|
|
126
|
-
const newDataItem = {
|
|
127
|
-
...listaAtual,
|
|
128
|
-
...novoItem
|
|
129
|
-
};
|
|
130
|
-
window.sessionStorage.setItem(chave, JSON.stringify(newDataItem));
|
|
131
|
-
} catch (error) {
|
|
132
|
-
console.error(error);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
static set_session_storage_sem_incremento({ chave, novoItem }) {
|
|
136
|
-
try {
|
|
137
|
-
window.sessionStorage.setItem(chave, JSON.stringify(novoItem));
|
|
138
|
-
} catch (error) {
|
|
139
|
-
console.error(error);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
static get_item_session_storage(chave) {
|
|
143
|
-
try {
|
|
144
|
-
if ("undefined" != typeof window) {
|
|
145
|
-
const valorAtual = window.sessionStorage.getItem(chave);
|
|
146
|
-
return valorAtual ? JSON.parse(valorAtual) : valorAtual;
|
|
147
|
-
}
|
|
148
|
-
return;
|
|
149
|
-
} catch (error) {
|
|
150
|
-
console.error(error);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
static remover_item_session_storage(chave) {
|
|
154
|
-
try {
|
|
155
|
-
window.sessionStorage.removeItem(chave);
|
|
156
|
-
} catch (error) {
|
|
157
|
-
console.error(error);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
const utils_session_storage = _session_storage;
|
|
162
|
-
const _api_api = class _api {
|
|
163
|
-
static servidor_pricipal = class {
|
|
164
|
-
static get #axios() {
|
|
165
|
-
return axios.create({
|
|
166
|
-
baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
static async post({ url, data, setToken = true }) {
|
|
170
|
-
return await this.#axios.post(url, data, _api.headers({
|
|
171
|
-
setToken: setToken
|
|
172
|
-
}));
|
|
173
|
-
}
|
|
174
|
-
static async get({ url, params, setToken = true }) {
|
|
175
|
-
const queryParams = new URLSearchParams();
|
|
176
|
-
if (params) Object.entries(params).forEach(([key, value])=>{
|
|
177
|
-
if (null != value) queryParams.append(key, value);
|
|
178
|
-
});
|
|
179
|
-
const queryString = queryParams.toString();
|
|
180
|
-
const fullUrl = queryString ? `${url}?${queryString}` : url;
|
|
181
|
-
return await this.#axios.get(fullUrl, _api.headers({
|
|
182
|
-
setToken: setToken
|
|
183
|
-
}));
|
|
184
|
-
}
|
|
185
|
-
static async patch({ url, data, setToken = true }) {
|
|
186
|
-
return await this.#axios.patch(url, data, _api.headers({
|
|
187
|
-
setToken: setToken
|
|
188
|
-
}));
|
|
189
|
-
}
|
|
190
|
-
static async delete({ url }) {
|
|
191
|
-
return await this.#axios.delete(url);
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
static headers({ setToken = true }) {
|
|
195
|
-
const get_auth_user = utils_session_storage.get_item_session_storage("auth_user");
|
|
196
|
-
if (true === setToken) return {
|
|
197
|
-
headers: {
|
|
198
|
-
Authorization: `Bearer ${get_auth_user?.data?.usuario?.token}`,
|
|
199
|
-
"Content-type": "application/json"
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
return {
|
|
203
|
-
headers: {
|
|
204
|
-
"Content-type": "application/json"
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
const utils_api = _api_api;
|
|
210
|
-
const _data = class {
|
|
121
|
+
const _data_data = class {
|
|
211
122
|
static YYYY_MM_DD_00_00_00(newData) {
|
|
212
123
|
let dataAtual = new Date();
|
|
213
124
|
if (newData) dataAtual = new Date(newData);
|
|
@@ -290,8 +201,8 @@ const _data = class {
|
|
|
290
201
|
return diferencaEmDias;
|
|
291
202
|
}
|
|
292
203
|
};
|
|
293
|
-
const utils_data =
|
|
294
|
-
class
|
|
204
|
+
const utils_data = _data_data;
|
|
205
|
+
class _form_form {
|
|
295
206
|
static regex_cpf_cnpj(value) {
|
|
296
207
|
let tempValue = value.replace(/\D/g, "");
|
|
297
208
|
if (tempValue.length > 14) tempValue = tempValue.slice(0, 14);
|
|
@@ -392,7 +303,7 @@ class _form {
|
|
|
392
303
|
}).format(Number(num) / 100);
|
|
393
304
|
}
|
|
394
305
|
}
|
|
395
|
-
const utils_form =
|
|
306
|
+
const utils_form = _form_form;
|
|
396
307
|
const geral = class {
|
|
397
308
|
static slice_file_name(filename, maxLength = 30) {
|
|
398
309
|
if (!filename || "string" != typeof filename) return "";
|
|
@@ -423,8 +334,8 @@ const geral = class {
|
|
|
423
334
|
return finalResult.substring(0, length);
|
|
424
335
|
};
|
|
425
336
|
};
|
|
426
|
-
const
|
|
427
|
-
const
|
|
337
|
+
const utils_geral = geral;
|
|
338
|
+
const _local_storage_local_storage = class {
|
|
428
339
|
static adicionar_item_local_storage(chave, novoItem) {
|
|
429
340
|
try {
|
|
430
341
|
const valorAtual = window.localStorage.getItem(chave);
|
|
@@ -464,8 +375,8 @@ const _local_storage = class {
|
|
|
464
375
|
}
|
|
465
376
|
}
|
|
466
377
|
};
|
|
467
|
-
const utils_local_storage =
|
|
468
|
-
const
|
|
378
|
+
const utils_local_storage = _local_storage_local_storage;
|
|
379
|
+
const _update_context_update_context = class {
|
|
469
380
|
static set_new_item_end = ({ oldArray = [], newItem = [], key = "_id" })=>{
|
|
470
381
|
try {
|
|
471
382
|
const hasValidIds = Array.isArray(newItem) ? newItem.every((item)=>item?.[key]) : newItem?.[key];
|
|
@@ -551,8 +462,49 @@ const _update_context = class {
|
|
|
551
462
|
];
|
|
552
463
|
}
|
|
553
464
|
};
|
|
554
|
-
const utils_update_context =
|
|
555
|
-
const
|
|
465
|
+
const utils_update_context = _update_context_update_context;
|
|
466
|
+
const _session_storage_session_storage = class {
|
|
467
|
+
static adicionar_item_session_storage({ chave, novoItem }) {
|
|
468
|
+
try {
|
|
469
|
+
const valorAtual = window.sessionStorage.getItem(chave);
|
|
470
|
+
const listaAtual = valorAtual ? JSON.parse(valorAtual) : [];
|
|
471
|
+
const newDataItem = {
|
|
472
|
+
...listaAtual,
|
|
473
|
+
...novoItem
|
|
474
|
+
};
|
|
475
|
+
window.sessionStorage.setItem(chave, JSON.stringify(newDataItem));
|
|
476
|
+
} catch (error) {
|
|
477
|
+
console.error(error);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
static set_session_storage_sem_incremento({ chave, novoItem }) {
|
|
481
|
+
try {
|
|
482
|
+
window.sessionStorage.setItem(chave, JSON.stringify(novoItem));
|
|
483
|
+
} catch (error) {
|
|
484
|
+
console.error(error);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
static get_item_session_storage(chave) {
|
|
488
|
+
try {
|
|
489
|
+
if ("undefined" != typeof window) {
|
|
490
|
+
const valorAtual = window.sessionStorage.getItem(chave);
|
|
491
|
+
return valorAtual ? JSON.parse(valorAtual) : valorAtual;
|
|
492
|
+
}
|
|
493
|
+
return;
|
|
494
|
+
} catch (error) {
|
|
495
|
+
console.error(error);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
static remover_item_session_storage(chave) {
|
|
499
|
+
try {
|
|
500
|
+
window.sessionStorage.removeItem(chave);
|
|
501
|
+
} catch (error) {
|
|
502
|
+
console.error(error);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
const utils_session_storage = _session_storage_session_storage;
|
|
507
|
+
const _sistema_sistema = {
|
|
556
508
|
empresa: {
|
|
557
509
|
nome: "Nav Software",
|
|
558
510
|
email_suporte: "suporte@navsoftware.com.br",
|
|
@@ -600,8 +552,8 @@ const _sistema = {
|
|
|
600
552
|
}
|
|
601
553
|
}
|
|
602
554
|
};
|
|
603
|
-
const utils_sistema =
|
|
604
|
-
class
|
|
555
|
+
const utils_sistema = _sistema_sistema;
|
|
556
|
+
class _hooks_hooks {
|
|
605
557
|
use_is_mobile() {
|
|
606
558
|
const [isMobile, setIsMobile] = useState(false);
|
|
607
559
|
useLayoutEffect(()=>{
|
|
@@ -622,17 +574,65 @@ class _hooks {
|
|
|
622
574
|
}
|
|
623
575
|
}
|
|
624
576
|
}
|
|
625
|
-
const utils_hooks = new
|
|
626
|
-
const
|
|
577
|
+
const utils_hooks = new _hooks_hooks;
|
|
578
|
+
const _api_api = class _api {
|
|
579
|
+
static servidor_pricipal = class {
|
|
580
|
+
static get #axios() {
|
|
581
|
+
return axios.create({
|
|
582
|
+
baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
static async post({ url, data, setToken = true }) {
|
|
586
|
+
return await this.#axios.post(url, data, _api.headers({
|
|
587
|
+
setToken: setToken
|
|
588
|
+
}));
|
|
589
|
+
}
|
|
590
|
+
static async get({ url, params, setToken = true }) {
|
|
591
|
+
const queryParams = new URLSearchParams();
|
|
592
|
+
if (params) Object.entries(params).forEach(([key, value])=>{
|
|
593
|
+
if (null != value) queryParams.append(key, value);
|
|
594
|
+
});
|
|
595
|
+
const queryString = queryParams.toString();
|
|
596
|
+
const fullUrl = queryString ? `${url}?${queryString}` : url;
|
|
597
|
+
return await this.#axios.get(fullUrl, _api.headers({
|
|
598
|
+
setToken: setToken
|
|
599
|
+
}));
|
|
600
|
+
}
|
|
601
|
+
static async patch({ url, data, setToken = true }) {
|
|
602
|
+
return await this.#axios.patch(url, data, _api.headers({
|
|
603
|
+
setToken: setToken
|
|
604
|
+
}));
|
|
605
|
+
}
|
|
606
|
+
static async delete({ url }) {
|
|
607
|
+
return await this.#axios.delete(url);
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
static headers({ setToken = true }) {
|
|
611
|
+
const get_auth_user = utils_session_storage.get_item_session_storage("auth_user");
|
|
612
|
+
if (true === setToken) return {
|
|
613
|
+
headers: {
|
|
614
|
+
Authorization: `Bearer ${get_auth_user?.data?.usuario?.token}`,
|
|
615
|
+
"Content-type": "application/json"
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
return {
|
|
619
|
+
headers: {
|
|
620
|
+
"Content-type": "application/json"
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
const utils_api = _api_api;
|
|
626
|
+
const utils_utils = {
|
|
627
627
|
api: utils_api,
|
|
628
628
|
data: utils_data,
|
|
629
629
|
form: utils_form,
|
|
630
|
-
geral:
|
|
630
|
+
geral: utils_geral,
|
|
631
631
|
local_storage: utils_local_storage,
|
|
632
632
|
update_context: utils_update_context,
|
|
633
633
|
session_sorage: utils_session_storage,
|
|
634
634
|
sistema: utils_sistema,
|
|
635
635
|
hooks: utils_hooks
|
|
636
636
|
};
|
|
637
|
-
const
|
|
638
|
-
export {
|
|
637
|
+
const src_utils_0 = utils_utils;
|
|
638
|
+
export { src_utils_0 as default };
|