teraprox-core-sdk 0.2.0 → 0.3.1
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/dist/chunk-N7KKTEAH.mjs +190 -0
- package/dist/dev.d.mts +39 -0
- package/dist/dev.d.ts +39 -0
- package/dist/dev.js +470 -0
- package/dist/dev.mjs +442 -0
- package/dist/federation-BANKXvQ5.d.mts +254 -0
- package/dist/federation-BANKXvQ5.d.ts +254 -0
- package/dist/federation.d.mts +3 -0
- package/dist/federation.d.ts +3 -0
- package/dist/federation.js +230 -0
- package/dist/federation.mjs +12 -0
- package/dist/index.d.mts +115 -56
- package/dist/index.d.ts +115 -56
- package/dist/index.js +542 -38
- package/dist/index.mjs +341 -40
- package/package.json +18 -3
package/dist/index.js
CHANGED
|
@@ -31,23 +31,51 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
CoreServiceContext: () => CoreServiceContext,
|
|
34
|
+
DevAutoLogin: () => DevAutoLogin,
|
|
35
|
+
FederatedBridge: () => FederatedBridge,
|
|
34
36
|
RecursoDisplayer: () => RecursoDisplayer_default,
|
|
37
|
+
StandaloneProvider: () => StandaloneProvider,
|
|
38
|
+
addDays: () => addDays,
|
|
35
39
|
branchLevelReducer: () => branchLevelReducer_default,
|
|
40
|
+
capitalize: () => capitalize,
|
|
36
41
|
clearBranchLevelForm: () => clearBranchLevelForm,
|
|
42
|
+
clearPicker: () => clearPicker,
|
|
43
|
+
createReducersBundle: () => createReducersBundle,
|
|
44
|
+
daysBetween: () => daysBetween,
|
|
45
|
+
formatDate: () => formatDate,
|
|
46
|
+
formatDateTime: () => formatDateTime,
|
|
47
|
+
isBlank: () => isBlank,
|
|
48
|
+
isDateAfter: () => isDateAfter,
|
|
49
|
+
isDateBefore: () => isDateBefore,
|
|
37
50
|
pickTextColorBasedOnBgColorAdvanced: () => pickTextColorBasedOnBgColorAdvanced,
|
|
51
|
+
pickerReducer: () => pickerReducer_default,
|
|
38
52
|
populateToEdit: () => populateToEdit,
|
|
53
|
+
removeAccents: () => removeAccents,
|
|
39
54
|
setColor: () => setColor,
|
|
40
55
|
setExcludeLevels: () => setExcludeLevels,
|
|
41
56
|
setHaveComponente: () => setHaveComponente,
|
|
42
57
|
setLevel: () => setLevel,
|
|
43
58
|
setLevels: () => setLevels,
|
|
44
59
|
setNome: () => setNome,
|
|
60
|
+
setPickerContext: () => setPickerContext,
|
|
61
|
+
setPickerItems: () => setPickerItems,
|
|
62
|
+
setPickerSelected: () => setPickerSelected,
|
|
63
|
+
setPickerVisible: () => setPickerVisible,
|
|
64
|
+
slugify: () => slugify,
|
|
65
|
+
toISOString: () => toISOString,
|
|
66
|
+
truncate: () => truncate,
|
|
67
|
+
useAnexoUpload: () => useAnexoUpload,
|
|
45
68
|
useCoreService: () => useCoreService,
|
|
69
|
+
useFetchData: () => useFetchData,
|
|
70
|
+
useFormStorage: () => useFormStorage,
|
|
46
71
|
useHttpController: () => useHttpController,
|
|
47
72
|
useMatchingObject: () => useMatchingObject,
|
|
48
73
|
useNavigator: () => useNavigator,
|
|
49
74
|
useNotifications: () => useNotifications,
|
|
50
|
-
|
|
75
|
+
usePostData: () => usePostData,
|
|
76
|
+
useSmartSearch: () => useSmartSearch,
|
|
77
|
+
useToast: () => useToast,
|
|
78
|
+
useValidation: () => useValidation
|
|
51
79
|
});
|
|
52
80
|
module.exports = __toCommonJS(index_exports);
|
|
53
81
|
|
|
@@ -163,8 +191,195 @@ function useNavigator(config) {
|
|
|
163
191
|
);
|
|
164
192
|
}
|
|
165
193
|
|
|
166
|
-
// src/
|
|
194
|
+
// src/hooks/useFetchData.ts
|
|
195
|
+
var import_react6 = require("react");
|
|
196
|
+
function useFetchData() {
|
|
197
|
+
const { createController } = useCoreService();
|
|
198
|
+
const [data, setData] = (0, import_react6.useState)(null);
|
|
199
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
200
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
201
|
+
const activeRef = (0, import_react6.useRef)(true);
|
|
202
|
+
const fetchData = (0, import_react6.useCallback)(
|
|
203
|
+
async (context, path, endpoint) => {
|
|
204
|
+
const controller = createController(context, endpoint);
|
|
205
|
+
setLoading(true);
|
|
206
|
+
setError(null);
|
|
207
|
+
try {
|
|
208
|
+
const result = await controller.get(path);
|
|
209
|
+
if (activeRef.current) setData(result);
|
|
210
|
+
return result;
|
|
211
|
+
} catch (err) {
|
|
212
|
+
if (activeRef.current) setError(err);
|
|
213
|
+
throw err;
|
|
214
|
+
} finally {
|
|
215
|
+
if (activeRef.current) setLoading(false);
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
[createController]
|
|
219
|
+
);
|
|
220
|
+
const reset = (0, import_react6.useCallback)(() => {
|
|
221
|
+
setData(null);
|
|
222
|
+
setLoading(false);
|
|
223
|
+
setError(null);
|
|
224
|
+
}, []);
|
|
225
|
+
return { data, loading, error, fetchData, reset };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// src/hooks/usePostData.ts
|
|
229
|
+
var import_react7 = require("react");
|
|
230
|
+
function usePostData() {
|
|
231
|
+
const { createController } = useCoreService();
|
|
232
|
+
const [result, setResult] = (0, import_react7.useState)(null);
|
|
233
|
+
const [loading, setLoading] = (0, import_react7.useState)(false);
|
|
234
|
+
const [error, setError] = (0, import_react7.useState)(null);
|
|
235
|
+
const postData = (0, import_react7.useCallback)(
|
|
236
|
+
async (context, path, payload, endpoint) => {
|
|
237
|
+
const controller = createController(context, endpoint);
|
|
238
|
+
setLoading(true);
|
|
239
|
+
setError(null);
|
|
240
|
+
try {
|
|
241
|
+
const res = await controller.post(path, payload);
|
|
242
|
+
setResult(res);
|
|
243
|
+
return res;
|
|
244
|
+
} catch (err) {
|
|
245
|
+
setError(err);
|
|
246
|
+
throw err;
|
|
247
|
+
} finally {
|
|
248
|
+
setLoading(false);
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
[createController]
|
|
252
|
+
);
|
|
253
|
+
return { result, loading, error, postData };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// src/hooks/useAnexoUpload.ts
|
|
257
|
+
var import_react8 = require("react");
|
|
258
|
+
function useAnexoUpload() {
|
|
259
|
+
const { createController } = useCoreService();
|
|
260
|
+
const toast = useToast();
|
|
261
|
+
const [uploading, setUploading] = (0, import_react8.useState)(false);
|
|
262
|
+
const [progress, setProgress] = (0, import_react8.useState)(0);
|
|
263
|
+
const upload = (0, import_react8.useCallback)(
|
|
264
|
+
async (context, path, file, extraHeaders) => {
|
|
265
|
+
const controller = createController(context);
|
|
266
|
+
setUploading(true);
|
|
267
|
+
setProgress(0);
|
|
268
|
+
try {
|
|
269
|
+
const formData = new FormData();
|
|
270
|
+
formData.append("file", file);
|
|
271
|
+
const result = await controller.post(path, formData, {
|
|
272
|
+
"Content-Type": "multipart/form-data",
|
|
273
|
+
...extraHeaders
|
|
274
|
+
});
|
|
275
|
+
setProgress(100);
|
|
276
|
+
return result;
|
|
277
|
+
} catch (err) {
|
|
278
|
+
toast.error((err == null ? void 0 : err.message) || "Erro ao enviar anexo");
|
|
279
|
+
throw err;
|
|
280
|
+
} finally {
|
|
281
|
+
setUploading(false);
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
[createController, toast]
|
|
285
|
+
);
|
|
286
|
+
const uploadMultiple = (0, import_react8.useCallback)(
|
|
287
|
+
async (context, path, files, extraHeaders) => {
|
|
288
|
+
const fileArray = Array.from(files);
|
|
289
|
+
const results = [];
|
|
290
|
+
for (let i = 0; i < fileArray.length; i++) {
|
|
291
|
+
setProgress(Math.round(i / fileArray.length * 100));
|
|
292
|
+
const res = await upload(context, path, fileArray[i], extraHeaders);
|
|
293
|
+
results.push(res);
|
|
294
|
+
}
|
|
295
|
+
setProgress(100);
|
|
296
|
+
return results;
|
|
297
|
+
},
|
|
298
|
+
[upload]
|
|
299
|
+
);
|
|
300
|
+
return { uploading, progress, upload, uploadMultiple };
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// src/hooks/useFormStorage.ts
|
|
304
|
+
var import_react9 = require("react");
|
|
305
|
+
function useFormStorage(key, initialValue) {
|
|
306
|
+
const storageKey = `teraprox_form_${key}`;
|
|
307
|
+
const [value, setValue] = (0, import_react9.useState)(() => {
|
|
308
|
+
try {
|
|
309
|
+
const stored = localStorage.getItem(storageKey);
|
|
310
|
+
return stored ? JSON.parse(stored) : initialValue;
|
|
311
|
+
} catch (e) {
|
|
312
|
+
return initialValue;
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
(0, import_react9.useEffect)(() => {
|
|
316
|
+
try {
|
|
317
|
+
localStorage.setItem(storageKey, JSON.stringify(value));
|
|
318
|
+
} catch (e) {
|
|
319
|
+
}
|
|
320
|
+
}, [value, storageKey]);
|
|
321
|
+
const clear = (0, import_react9.useCallback)(() => {
|
|
322
|
+
localStorage.removeItem(storageKey);
|
|
323
|
+
setValue(initialValue);
|
|
324
|
+
}, [storageKey, initialValue]);
|
|
325
|
+
return [value, setValue, clear];
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// src/hooks/useSmartSearch.ts
|
|
329
|
+
var import_react10 = require("react");
|
|
330
|
+
function useSmartSearch(data, searchFields, options) {
|
|
331
|
+
const [searchTerm, setSearchTerm] = (0, import_react10.useState)("");
|
|
332
|
+
const { caseSensitive = false, minLength = 1 } = options || {};
|
|
333
|
+
const filteredData = (0, import_react10.useMemo)(() => {
|
|
334
|
+
if (!searchTerm || searchTerm.length < minLength) return data;
|
|
335
|
+
const term = caseSensitive ? searchTerm : searchTerm.toLowerCase();
|
|
336
|
+
return data.filter(
|
|
337
|
+
(item) => searchFields.some((field) => {
|
|
338
|
+
const value = item == null ? void 0 : item[field];
|
|
339
|
+
if (value == null) return false;
|
|
340
|
+
const str = String(value);
|
|
341
|
+
return (caseSensitive ? str : str.toLowerCase()).includes(term);
|
|
342
|
+
})
|
|
343
|
+
);
|
|
344
|
+
}, [data, searchTerm, searchFields, caseSensitive, minLength]);
|
|
345
|
+
const clearSearch = (0, import_react10.useCallback)(() => setSearchTerm(""), []);
|
|
346
|
+
return { searchTerm, setSearchTerm, filteredData, clearSearch };
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// src/hooks/useValidation.ts
|
|
167
350
|
var import_react11 = require("react");
|
|
351
|
+
function useValidation(rules) {
|
|
352
|
+
const toast = useToast();
|
|
353
|
+
const [errors, setErrors] = (0, import_react11.useState)({});
|
|
354
|
+
const validate = (0, import_react11.useCallback)(
|
|
355
|
+
(form) => {
|
|
356
|
+
const newErrors = {};
|
|
357
|
+
let valid = true;
|
|
358
|
+
for (const rule of rules) {
|
|
359
|
+
if (!rule.validate(form[rule.field], form)) {
|
|
360
|
+
newErrors[rule.field] = rule.message;
|
|
361
|
+
valid = false;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
setErrors(newErrors);
|
|
365
|
+
if (!valid) {
|
|
366
|
+
const firstError = Object.values(newErrors)[0];
|
|
367
|
+
toast.warning(firstError);
|
|
368
|
+
}
|
|
369
|
+
return valid;
|
|
370
|
+
},
|
|
371
|
+
[rules, toast]
|
|
372
|
+
);
|
|
373
|
+
const clearErrors = (0, import_react11.useCallback)(() => setErrors({}), []);
|
|
374
|
+
const setFieldError = (0, import_react11.useCallback)(
|
|
375
|
+
(field, message) => setErrors((prev) => ({ ...prev, [field]: message })),
|
|
376
|
+
[]
|
|
377
|
+
);
|
|
378
|
+
return { errors, validate, clearErrors, setFieldError };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// src/components/recurso/RecursoDisplayer.tsx
|
|
382
|
+
var import_react17 = require("react");
|
|
168
383
|
var import_react_bootstrap2 = require("react-bootstrap");
|
|
169
384
|
var import_react_redux3 = require("react-redux");
|
|
170
385
|
|
|
@@ -223,7 +438,7 @@ var {
|
|
|
223
438
|
var branchLevelReducer_default = branchLevelSlice.reducer;
|
|
224
439
|
|
|
225
440
|
// src/components/recurso/BranchDropDisplay.tsx
|
|
226
|
-
var
|
|
441
|
+
var import_react12 = require("react");
|
|
227
442
|
var import_fa = require("react-icons/fa");
|
|
228
443
|
var import_md = require("react-icons/md");
|
|
229
444
|
|
|
@@ -253,17 +468,17 @@ var BranchDropDisplay = ({
|
|
|
253
468
|
branches,
|
|
254
469
|
singleReturn
|
|
255
470
|
}) => {
|
|
256
|
-
const [fontColor, setFontColor] = (0,
|
|
257
|
-
const [searchTerm, setSearchTerm] = (0,
|
|
258
|
-
const [show, setShow] = (0,
|
|
259
|
-
const [multiSelected, setMultiSelected] = (0,
|
|
260
|
-
const dropdownRef = (0,
|
|
261
|
-
(0,
|
|
471
|
+
const [fontColor, setFontColor] = (0, import_react12.useState)("#000");
|
|
472
|
+
const [searchTerm, setSearchTerm] = (0, import_react12.useState)("");
|
|
473
|
+
const [show, setShow] = (0, import_react12.useState)(false);
|
|
474
|
+
const [multiSelected, setMultiSelected] = (0, import_react12.useState)([]);
|
|
475
|
+
const dropdownRef = (0, import_react12.useRef)(null);
|
|
476
|
+
(0, import_react12.useEffect)(() => {
|
|
262
477
|
setFontColor(
|
|
263
478
|
pickTextColorBasedOnBgColorAdvanced(branch.branchLevel.color, "#FFFFFF", "#000000")
|
|
264
479
|
);
|
|
265
480
|
}, [branch.branchLevel.color]);
|
|
266
|
-
(0,
|
|
481
|
+
(0, import_react12.useEffect)(() => {
|
|
267
482
|
const handleClickOutside = (event) => {
|
|
268
483
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
269
484
|
setShow(false);
|
|
@@ -502,11 +717,11 @@ var BranchDropDisplay = ({
|
|
|
502
717
|
var BranchDropDisplay_default = BranchDropDisplay;
|
|
503
718
|
|
|
504
719
|
// src/components/recurso/FindRecursoByTagField.tsx
|
|
505
|
-
var
|
|
720
|
+
var import_react16 = require("react");
|
|
506
721
|
var import_gr = require("react-icons/gr");
|
|
507
722
|
|
|
508
723
|
// src/components/recurso/AutoComplete.tsx
|
|
509
|
-
var
|
|
724
|
+
var import_react13 = require("react");
|
|
510
725
|
var import_react_bootstrap = require("react-bootstrap");
|
|
511
726
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
512
727
|
var AutoComplete = ({
|
|
@@ -543,25 +758,25 @@ var AutoComplete = ({
|
|
|
543
758
|
isRequired = false,
|
|
544
759
|
ty = "text"
|
|
545
760
|
}) => {
|
|
546
|
-
const [liItem, setListItem] = (0,
|
|
547
|
-
const [options, setOptions] = (0,
|
|
548
|
-
const [input, setInput] = (0,
|
|
549
|
-
const [hide, setHide] = (0,
|
|
550
|
-
const [onLoaded, setOnLoaded] = (0,
|
|
761
|
+
const [liItem, setListItem] = (0, import_react13.useState)([]);
|
|
762
|
+
const [options, setOptions] = (0, import_react13.useState)([]);
|
|
763
|
+
const [input, setInput] = (0, import_react13.useState)("");
|
|
764
|
+
const [hide, setHide] = (0, import_react13.useState)(true);
|
|
765
|
+
const [onLoaded, setOnLoaded] = (0, import_react13.useState)(false);
|
|
551
766
|
const sortOptions = (opts, key) => {
|
|
552
767
|
if (!key || !Array.isArray(opts)) return opts != null ? opts : [];
|
|
553
768
|
return [...opts].sort((a, b) => String(a[key]).localeCompare(String(b[key])));
|
|
554
769
|
};
|
|
555
|
-
(0,
|
|
770
|
+
(0, import_react13.useEffect)(() => {
|
|
556
771
|
if (value) setInput(value);
|
|
557
772
|
else setInput("");
|
|
558
773
|
}, [value]);
|
|
559
|
-
(0,
|
|
774
|
+
(0, import_react13.useEffect)(() => {
|
|
560
775
|
const sortedOptions = sortOptions(ops, sortKey);
|
|
561
776
|
setListItem(sortedOptions);
|
|
562
777
|
setOptions(sortedOptions);
|
|
563
778
|
}, [ops, sortKey]);
|
|
564
|
-
(0,
|
|
779
|
+
(0, import_react13.useEffect)(() => {
|
|
565
780
|
const loadFunction = async () => {
|
|
566
781
|
if (loadCondition && loadFunc) {
|
|
567
782
|
try {
|
|
@@ -728,19 +943,19 @@ var AutoComplete = ({
|
|
|
728
943
|
var AutoComplete_default = AutoComplete;
|
|
729
944
|
|
|
730
945
|
// src/components/recurso/QrCodeScanButton.tsx
|
|
731
|
-
var
|
|
946
|
+
var import_react15 = require("react");
|
|
732
947
|
var import_bs = require("react-icons/bs");
|
|
733
948
|
|
|
734
949
|
// src/components/recurso/QrReader.tsx
|
|
735
950
|
var import_qr_scanner = __toESM(require("qr-scanner"));
|
|
736
|
-
var
|
|
951
|
+
var import_react14 = require("react");
|
|
737
952
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
738
953
|
var QrReader = ({ callback }) => {
|
|
739
|
-
const scanner = (0,
|
|
740
|
-
const videoEl = (0,
|
|
741
|
-
const qrBoxEl = (0,
|
|
742
|
-
const [qrOn, setQrOn] = (0,
|
|
743
|
-
const [scannedResult, setScannedResult] = (0,
|
|
954
|
+
const scanner = (0, import_react14.useRef)(null);
|
|
955
|
+
const videoEl = (0, import_react14.useRef)(null);
|
|
956
|
+
const qrBoxEl = (0, import_react14.useRef)(null);
|
|
957
|
+
const [qrOn, setQrOn] = (0, import_react14.useState)(true);
|
|
958
|
+
const [scannedResult, setScannedResult] = (0, import_react14.useState)("");
|
|
744
959
|
const onScanSuccess = (result) => {
|
|
745
960
|
setScannedResult(result == null ? void 0 : result.data);
|
|
746
961
|
callback(result == null ? void 0 : result.data);
|
|
@@ -748,7 +963,7 @@ var QrReader = ({ callback }) => {
|
|
|
748
963
|
const onScanFail = (err) => {
|
|
749
964
|
console.error(err);
|
|
750
965
|
};
|
|
751
|
-
(0,
|
|
966
|
+
(0, import_react14.useEffect)(() => {
|
|
752
967
|
if ((videoEl == null ? void 0 : videoEl.current) && !scanner.current) {
|
|
753
968
|
scanner.current = new import_qr_scanner.default(videoEl.current, onScanSuccess, {
|
|
754
969
|
onDecodeError: onScanFail,
|
|
@@ -768,7 +983,7 @@ var QrReader = ({ callback }) => {
|
|
|
768
983
|
}
|
|
769
984
|
};
|
|
770
985
|
}, []);
|
|
771
|
-
(0,
|
|
986
|
+
(0, import_react14.useEffect)(() => {
|
|
772
987
|
if (!qrOn)
|
|
773
988
|
alert(
|
|
774
989
|
"Camera est\xE1 bloqueada ou inacess\xEDvel. Por Favor habilite a camera nas permiss\xF5es do seu navegador e recarregue a p\xE1gina."
|
|
@@ -800,7 +1015,7 @@ var QrReader_default = QrReader;
|
|
|
800
1015
|
// src/components/recurso/QrCodeScanButton.tsx
|
|
801
1016
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
802
1017
|
var QrCodeScanButton = ({ callback }) => {
|
|
803
|
-
const [showQr, setShowQr] = (0,
|
|
1018
|
+
const [showQr, setShowQr] = (0, import_react15.useState)(false);
|
|
804
1019
|
const qrShowHandler = () => {
|
|
805
1020
|
setShowQr((prev) => !prev);
|
|
806
1021
|
};
|
|
@@ -846,8 +1061,8 @@ var QrCodeScanButton_default = QrCodeScanButton;
|
|
|
846
1061
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
847
1062
|
var FindRecursoByTagField = ({ callback }) => {
|
|
848
1063
|
const recursoController = useHttpController("recurso");
|
|
849
|
-
const [selectedTag, setSelectedTag] = (0,
|
|
850
|
-
const [reachedRecurso, setReachedRecurso] = (0,
|
|
1064
|
+
const [selectedTag, setSelectedTag] = (0, import_react16.useState)(null);
|
|
1065
|
+
const [reachedRecurso, setReachedRecurso] = (0, import_react16.useState)(null);
|
|
851
1066
|
const findRecursoByTagIdHandler = async (tagId) => {
|
|
852
1067
|
const r = await recursoController.read("findRecursoByTagId", tagId);
|
|
853
1068
|
setReachedRecurso(r);
|
|
@@ -914,12 +1129,12 @@ var RecursoDisplayer = ({
|
|
|
914
1129
|
}) => {
|
|
915
1130
|
const arvoreEstruturalController = useHttpController("arvoreEstrutural");
|
|
916
1131
|
const branchLevelController = useHttpController("branchLevel");
|
|
917
|
-
const [branches, setBranches] = (0,
|
|
1132
|
+
const [branches, setBranches] = (0, import_react17.useState)([]);
|
|
918
1133
|
const dispatch = (0, import_react_redux3.useDispatch)();
|
|
919
|
-
const [localSelected, setLocalSelected] = (0,
|
|
920
|
-
const [selectorDisplay, setSelectorDisplay] = (0,
|
|
921
|
-
const [multiMode, setMultiMode] = (0,
|
|
922
|
-
(0,
|
|
1134
|
+
const [localSelected, setLocalSelected] = (0, import_react17.useState)(selectedList);
|
|
1135
|
+
const [selectorDisplay, setSelectorDisplay] = (0, import_react17.useState)("");
|
|
1136
|
+
const [multiMode, setMultiMode] = (0, import_react17.useState)(false);
|
|
1137
|
+
(0, import_react17.useEffect)(() => {
|
|
923
1138
|
const init = async () => {
|
|
924
1139
|
const b = await arvoreEstruturalController.get("branchByBranchLevel/1");
|
|
925
1140
|
setBranches(b);
|
|
@@ -992,24 +1207,313 @@ var RecursoDisplayer = ({
|
|
|
992
1207
|
] });
|
|
993
1208
|
};
|
|
994
1209
|
var RecursoDisplayer_default = RecursoDisplayer;
|
|
1210
|
+
|
|
1211
|
+
// src/reducers/pickerReducer.ts
|
|
1212
|
+
var import_toolkit2 = require("@reduxjs/toolkit");
|
|
1213
|
+
var initialState2 = {
|
|
1214
|
+
selected: null,
|
|
1215
|
+
items: [],
|
|
1216
|
+
visible: false,
|
|
1217
|
+
context: ""
|
|
1218
|
+
};
|
|
1219
|
+
var pickerSlice = (0, import_toolkit2.createSlice)({
|
|
1220
|
+
name: "picker",
|
|
1221
|
+
initialState: initialState2,
|
|
1222
|
+
reducers: {
|
|
1223
|
+
setPickerSelected(state, action) {
|
|
1224
|
+
state.selected = action.payload;
|
|
1225
|
+
},
|
|
1226
|
+
setPickerItems(state, action) {
|
|
1227
|
+
state.items = action.payload;
|
|
1228
|
+
},
|
|
1229
|
+
setPickerVisible(state, action) {
|
|
1230
|
+
state.visible = action.payload;
|
|
1231
|
+
},
|
|
1232
|
+
setPickerContext(state, action) {
|
|
1233
|
+
state.context = action.payload;
|
|
1234
|
+
},
|
|
1235
|
+
clearPicker() {
|
|
1236
|
+
return initialState2;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
});
|
|
1240
|
+
var {
|
|
1241
|
+
setPickerSelected,
|
|
1242
|
+
setPickerItems,
|
|
1243
|
+
setPickerVisible,
|
|
1244
|
+
setPickerContext,
|
|
1245
|
+
clearPicker
|
|
1246
|
+
} = pickerSlice.actions;
|
|
1247
|
+
var pickerReducer_default = pickerSlice.reducer;
|
|
1248
|
+
|
|
1249
|
+
// src/utils/dateUtils.ts
|
|
1250
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
1251
|
+
function formatDate(date, format = "DD/MM/YYYY") {
|
|
1252
|
+
if (!date) return "";
|
|
1253
|
+
return (0, import_dayjs.default)(date).format(format);
|
|
1254
|
+
}
|
|
1255
|
+
function formatDateTime(date) {
|
|
1256
|
+
return formatDate(date, "DD/MM/YYYY HH:mm");
|
|
1257
|
+
}
|
|
1258
|
+
function isDateBefore(date1, date2) {
|
|
1259
|
+
return (0, import_dayjs.default)(date1).isBefore((0, import_dayjs.default)(date2));
|
|
1260
|
+
}
|
|
1261
|
+
function isDateAfter(date1, date2) {
|
|
1262
|
+
return (0, import_dayjs.default)(date1).isAfter((0, import_dayjs.default)(date2));
|
|
1263
|
+
}
|
|
1264
|
+
function daysBetween(start, end) {
|
|
1265
|
+
return (0, import_dayjs.default)(end).diff((0, import_dayjs.default)(start), "day");
|
|
1266
|
+
}
|
|
1267
|
+
function addDays(date, days) {
|
|
1268
|
+
return (0, import_dayjs.default)(date).add(days, "day").toDate();
|
|
1269
|
+
}
|
|
1270
|
+
function toISOString(date) {
|
|
1271
|
+
return (0, import_dayjs.default)(date).toISOString();
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
// src/utils/stringUtils.ts
|
|
1275
|
+
function capitalize(str) {
|
|
1276
|
+
if (!str) return "";
|
|
1277
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
1278
|
+
}
|
|
1279
|
+
function truncate(str, maxLength, suffix = "...") {
|
|
1280
|
+
if (!str || str.length <= maxLength) return str || "";
|
|
1281
|
+
return str.substring(0, maxLength) + suffix;
|
|
1282
|
+
}
|
|
1283
|
+
function removeAccents(str) {
|
|
1284
|
+
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
1285
|
+
}
|
|
1286
|
+
function slugify(str) {
|
|
1287
|
+
return removeAccents(str).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
1288
|
+
}
|
|
1289
|
+
function isBlank(str) {
|
|
1290
|
+
return !str || str.trim().length === 0;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// src/federation/FederatedBridge.tsx
|
|
1294
|
+
var import_react18 = require("react");
|
|
1295
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1296
|
+
function FederatedBridge({ coreService, children }) {
|
|
1297
|
+
(0, import_react18.useEffect)(() => {
|
|
1298
|
+
if (typeof window === "undefined") return;
|
|
1299
|
+
window.__TERAPROX_HOSTED_BY_CORE__ = true;
|
|
1300
|
+
return () => {
|
|
1301
|
+
;
|
|
1302
|
+
window.__TERAPROX_HOSTED_BY_CORE__ = false;
|
|
1303
|
+
};
|
|
1304
|
+
}, []);
|
|
1305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CoreServiceContext.Provider, { value: coreService, children });
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
// src/federation/createReducersBundle.ts
|
|
1309
|
+
function createReducersBundle(config) {
|
|
1310
|
+
const { reducers, contextMap, defaults = [] } = config;
|
|
1311
|
+
const allKeys = Object.keys(reducers);
|
|
1312
|
+
const getReducerKeysByContext = (context) => {
|
|
1313
|
+
const contextKeys = contextMap[context];
|
|
1314
|
+
if (!contextKeys) return allKeys;
|
|
1315
|
+
return [.../* @__PURE__ */ new Set([...defaults, ...contextKeys])];
|
|
1316
|
+
};
|
|
1317
|
+
const getReducersForKeys = async (keys = []) => {
|
|
1318
|
+
const uniqueKeys = [...new Set(keys)].filter((key) => !!reducers[key]);
|
|
1319
|
+
const loaded = await Promise.all(
|
|
1320
|
+
uniqueKeys.map(async (key) => {
|
|
1321
|
+
const module2 = await reducers[key]();
|
|
1322
|
+
return [key, module2.default || module2];
|
|
1323
|
+
})
|
|
1324
|
+
);
|
|
1325
|
+
return Object.fromEntries(loaded);
|
|
1326
|
+
};
|
|
1327
|
+
const getReducersForModule = async ({
|
|
1328
|
+
context
|
|
1329
|
+
} = {}) => {
|
|
1330
|
+
const keys = getReducerKeysByContext(context || "");
|
|
1331
|
+
return getReducersForKeys(keys);
|
|
1332
|
+
};
|
|
1333
|
+
const loadAllReducers = () => getReducersForKeys(allKeys);
|
|
1334
|
+
return {
|
|
1335
|
+
getReducerKeysByContext,
|
|
1336
|
+
getReducersForKeys,
|
|
1337
|
+
getReducersForModule,
|
|
1338
|
+
loadAllReducers,
|
|
1339
|
+
baseReducers: {}
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
// src/federation/StandaloneProvider.tsx
|
|
1344
|
+
var import_react19 = require("react");
|
|
1345
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1346
|
+
function StandaloneProvider({ createController, addToast, firebaseConfig, tenant, children }) {
|
|
1347
|
+
const [subscriptions] = (0, import_react19.useState)([]);
|
|
1348
|
+
const subscriptionsRef = (0, import_react19.useRef)(subscriptions);
|
|
1349
|
+
subscriptionsRef.current = subscriptions;
|
|
1350
|
+
const toast = (0, import_react19.useMemo)(
|
|
1351
|
+
() => ({
|
|
1352
|
+
success: (msg, opts) => addToast(msg, { appearance: "success", autoDismiss: true, ...opts }),
|
|
1353
|
+
warning: (msg, opts) => addToast(msg, { appearance: "warning", autoDismiss: true, ...opts }),
|
|
1354
|
+
error: (msg, opts) => addToast(msg, { appearance: "error", autoDismiss: true, ...opts }),
|
|
1355
|
+
info: (msg, opts) => addToast(msg, { appearance: "info", autoDismiss: true, ...opts })
|
|
1356
|
+
}),
|
|
1357
|
+
[addToast]
|
|
1358
|
+
);
|
|
1359
|
+
const subscribe = (0, import_react19.useCallback)(
|
|
1360
|
+
(mo) => {
|
|
1361
|
+
subscriptions.push(mo);
|
|
1362
|
+
},
|
|
1363
|
+
[subscriptions]
|
|
1364
|
+
);
|
|
1365
|
+
const unsubscribe = (0, import_react19.useCallback)(
|
|
1366
|
+
(mo) => {
|
|
1367
|
+
const idx = subscriptions.findIndex(
|
|
1368
|
+
(s) => s.context === mo.context && s.location === mo.location
|
|
1369
|
+
);
|
|
1370
|
+
if (idx >= 0) subscriptions.splice(idx, 1);
|
|
1371
|
+
},
|
|
1372
|
+
[subscriptions]
|
|
1373
|
+
);
|
|
1374
|
+
(0, import_react19.useEffect)(() => {
|
|
1375
|
+
if (!firebaseConfig || !tenant || Object.keys(firebaseConfig).length === 0) return;
|
|
1376
|
+
let cleanup;
|
|
1377
|
+
(async () => {
|
|
1378
|
+
try {
|
|
1379
|
+
const { initializeApp, getApps } = await import("firebase/app");
|
|
1380
|
+
const { getDatabase, ref, onChildAdded, off } = await import("firebase/database");
|
|
1381
|
+
if (!getApps().length) {
|
|
1382
|
+
initializeApp(firebaseConfig);
|
|
1383
|
+
}
|
|
1384
|
+
const db = getDatabase();
|
|
1385
|
+
const moRef = ref(db, `${tenant}/matchingObjects`);
|
|
1386
|
+
const unsub = onChildAdded(moRef, (snapshot) => {
|
|
1387
|
+
const data = snapshot.val();
|
|
1388
|
+
if (!data) return;
|
|
1389
|
+
const items = Array.isArray(data) ? data : [data];
|
|
1390
|
+
for (const mo of items) {
|
|
1391
|
+
if (typeof mo !== "object") continue;
|
|
1392
|
+
const subs = subscriptionsRef.current || [];
|
|
1393
|
+
for (const sub of subs) {
|
|
1394
|
+
const sameContext = sub.context === mo.context;
|
|
1395
|
+
const sameLocation = sub.location === mo.location || sub.location === "*" || mo.location === "*" || !sub.location || !mo.location;
|
|
1396
|
+
if (sameContext && sameLocation && sub.refresher) {
|
|
1397
|
+
try {
|
|
1398
|
+
sub.refresher(mo.payload, () => {
|
|
1399
|
+
});
|
|
1400
|
+
} catch (e) {
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
});
|
|
1406
|
+
cleanup = () => {
|
|
1407
|
+
off(moRef, "child_added", unsub);
|
|
1408
|
+
};
|
|
1409
|
+
} catch (err) {
|
|
1410
|
+
console.warn("[StandaloneProvider] Firebase RTDB listener failed \u2014 continuing without real-time:", err);
|
|
1411
|
+
}
|
|
1412
|
+
})();
|
|
1413
|
+
return () => {
|
|
1414
|
+
cleanup == null ? void 0 : cleanup();
|
|
1415
|
+
};
|
|
1416
|
+
}, [firebaseConfig, tenant]);
|
|
1417
|
+
const value = (0, import_react19.useMemo)(
|
|
1418
|
+
() => ({
|
|
1419
|
+
createController,
|
|
1420
|
+
toast,
|
|
1421
|
+
subscribe,
|
|
1422
|
+
unsubscribe,
|
|
1423
|
+
subscribeEvent: () => {
|
|
1424
|
+
},
|
|
1425
|
+
unsubscribeEvent: () => {
|
|
1426
|
+
},
|
|
1427
|
+
handleLogout: () => {
|
|
1428
|
+
},
|
|
1429
|
+
hostedByCore: false
|
|
1430
|
+
}),
|
|
1431
|
+
[createController, toast, subscribe, unsubscribe]
|
|
1432
|
+
);
|
|
1433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CoreServiceContext.Provider, { value, children });
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
// src/federation/DevAutoLogin.tsx
|
|
1437
|
+
var import_react20 = require("react");
|
|
1438
|
+
var import_react_redux4 = require("react-redux");
|
|
1439
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1440
|
+
var DEFAULT_DEV_USER = {
|
|
1441
|
+
firstName: "Dev",
|
|
1442
|
+
lastName: "User",
|
|
1443
|
+
token: "dev-standalone-token",
|
|
1444
|
+
email: "dev@teraprox.local",
|
|
1445
|
+
id: "dev-user-id",
|
|
1446
|
+
role: "admin",
|
|
1447
|
+
user: "devuser",
|
|
1448
|
+
userName: "devuser",
|
|
1449
|
+
setor: "Desenvolvimento",
|
|
1450
|
+
userSetor: { setorId: "dev-setor-id" },
|
|
1451
|
+
companyName: "Dev Company",
|
|
1452
|
+
companyId: "dev-company-id",
|
|
1453
|
+
filters: []
|
|
1454
|
+
};
|
|
1455
|
+
function DevAutoLogin({ actions, devUser, children }) {
|
|
1456
|
+
const dispatch = (0, import_react_redux4.useDispatch)();
|
|
1457
|
+
const token = (0, import_react_redux4.useSelector)((state) => {
|
|
1458
|
+
var _a;
|
|
1459
|
+
return (_a = state.global) == null ? void 0 : _a.token;
|
|
1460
|
+
});
|
|
1461
|
+
const hostedByCore = typeof window !== "undefined" && window.__TERAPROX_HOSTED_BY_CORE__ === true;
|
|
1462
|
+
(0, import_react20.useEffect)(() => {
|
|
1463
|
+
if (process.env.NODE_ENV === "development" && !hostedByCore && !token) {
|
|
1464
|
+
const user = { ...DEFAULT_DEV_USER, ...devUser };
|
|
1465
|
+
dispatch(actions.setCompany(user.companyId));
|
|
1466
|
+
dispatch(actions.logIn(user));
|
|
1467
|
+
}
|
|
1468
|
+
}, [dispatch, hostedByCore, token, actions, devUser]);
|
|
1469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children });
|
|
1470
|
+
}
|
|
995
1471
|
// Annotate the CommonJS export names for ESM import in node:
|
|
996
1472
|
0 && (module.exports = {
|
|
997
1473
|
CoreServiceContext,
|
|
1474
|
+
DevAutoLogin,
|
|
1475
|
+
FederatedBridge,
|
|
998
1476
|
RecursoDisplayer,
|
|
1477
|
+
StandaloneProvider,
|
|
1478
|
+
addDays,
|
|
999
1479
|
branchLevelReducer,
|
|
1480
|
+
capitalize,
|
|
1000
1481
|
clearBranchLevelForm,
|
|
1482
|
+
clearPicker,
|
|
1483
|
+
createReducersBundle,
|
|
1484
|
+
daysBetween,
|
|
1485
|
+
formatDate,
|
|
1486
|
+
formatDateTime,
|
|
1487
|
+
isBlank,
|
|
1488
|
+
isDateAfter,
|
|
1489
|
+
isDateBefore,
|
|
1001
1490
|
pickTextColorBasedOnBgColorAdvanced,
|
|
1491
|
+
pickerReducer,
|
|
1002
1492
|
populateToEdit,
|
|
1493
|
+
removeAccents,
|
|
1003
1494
|
setColor,
|
|
1004
1495
|
setExcludeLevels,
|
|
1005
1496
|
setHaveComponente,
|
|
1006
1497
|
setLevel,
|
|
1007
1498
|
setLevels,
|
|
1008
1499
|
setNome,
|
|
1500
|
+
setPickerContext,
|
|
1501
|
+
setPickerItems,
|
|
1502
|
+
setPickerSelected,
|
|
1503
|
+
setPickerVisible,
|
|
1504
|
+
slugify,
|
|
1505
|
+
toISOString,
|
|
1506
|
+
truncate,
|
|
1507
|
+
useAnexoUpload,
|
|
1009
1508
|
useCoreService,
|
|
1509
|
+
useFetchData,
|
|
1510
|
+
useFormStorage,
|
|
1010
1511
|
useHttpController,
|
|
1011
1512
|
useMatchingObject,
|
|
1012
1513
|
useNavigator,
|
|
1013
1514
|
useNotifications,
|
|
1014
|
-
|
|
1515
|
+
usePostData,
|
|
1516
|
+
useSmartSearch,
|
|
1517
|
+
useToast,
|
|
1518
|
+
useValidation
|
|
1015
1519
|
});
|