jclib-ui 1.1.19 → 1.2.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,8 +1,8 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import React, { useEffect, createContext, useContext, useState, useRef, useCallback, useMemo, useLayoutEffect, forwardRef, useImperativeHandle } from "react";
5
- import { isMobile, isDarkMode, random, formatData, formatDataHora, formatValor, isDesktop, getDateTimeStr, getHash, validarCNPJ, validarCPF, retirarAcentuacao } from "jcinfo-utils";
4
+ import React, { useState, useEffect, useRef, useMemo, useCallback, useLayoutEffect, forwardRef, createContext, useContext, useImperativeHandle } from "react";
5
+ import { formatData, formatDataHora, formatValor, isDesktop, random, getDateTimeStr, getHash, validarCNPJ, validarCPF, isMobile, retirarAcentuacao, isDarkMode } from "jcinfo-utils";
6
6
  import { useDragControls, motion } from "framer-motion";
7
7
  import styled from "styled-components";
8
8
  import { Dropdown, DropdownMenu, DropdownItem, DropdownToggle, Spinner, Button, InputGroup, Input as Input$1 } from "reactstrap";
@@ -937,432 +937,6 @@ if (process.env.NODE_ENV === "production") {
937
937
  jsxRuntime.exports = requireReactJsxRuntime_development();
938
938
  }
939
939
  var jsxRuntimeExports = jsxRuntime.exports;
940
- const BorderTestServer = styled.div`
941
- position: fixed;
942
- top: 3px;
943
- left: 3px;
944
- width: 12px;
945
- aspect-ratio: 1/1;
946
- box-sizing: border-box;
947
- background-color: #2cbd64;
948
- border-radius: 99px;
949
- pointer-events: none;
950
- z-index: 9999999;
951
- `;
952
- const MARCADOR_LOCALHOST = " 🔴 ";
953
- const MARCADOR_TESTE = " 🟢 ";
954
- function useLocalhostBadge() {
955
- useEffect(() => {
956
- const inLocalhost = window.location.hostname == "localhost" || window.location.hostname == "127.0.0.1" || window.location.hostname == "[::1]" || window.location.hostname.startsWith("192.168.");
957
- if (inLocalhost && !document.title.includes(MARCADOR_LOCALHOST)) {
958
- document.title = `${MARCADOR_LOCALHOST}${document.title}`;
959
- }
960
- }, []);
961
- }
962
- function useTestDomainBadge(testDomain) {
963
- function inTestServer() {
964
- const domains = testDomain ? [].concat(testDomain) : ["test.", "test-", "dev."];
965
- return Boolean(
966
- domains.some((domain) => window.location.hostname.includes(domain))
967
- );
968
- }
969
- useEffect(() => {
970
- if (inTestServer() && !document.title.includes(MARCADOR_TESTE)) {
971
- document.title = `${MARCADOR_TESTE}${document.title}`;
972
- }
973
- }, [testDomain]);
974
- if (inTestServer() && isMobile()) {
975
- return /* @__PURE__ */ jsxRuntimeExports.jsx(BorderTestServer, {});
976
- }
977
- }
978
- const LibContext = createContext({
979
- modalList: [],
980
- theme: "light",
981
- toggleTheme: () => {
982
- },
983
- versionApp: "",
984
- addModal: (modalId, setVisible) => {
985
- },
986
- removeModal: (modalId) => {
987
- },
988
- clearModals: () => {
989
- },
990
- showBtnTop: false,
991
- setShowBtnTop: () => {
992
- },
993
- globalApiConfig: null,
994
- setTheme: () => {
995
- },
996
- canChangeTheme: false,
997
- reportType: 0,
998
- setReportType: (reportTypeNumber) => {
999
- }
1000
- });
1001
- const cTheme = "sys/theme";
1002
- let bootChecked = false;
1003
- const LibProvider = ({ apiConfig, children, versionApp, useTheme, testDomain }) => {
1004
- const canChangeTheme = typeof useTheme == "boolean" ? useTheme : false;
1005
- const [theme, setTheme] = useState(() => {
1006
- let result = "";
1007
- if (canChangeTheme) {
1008
- let value = localStorage.getItem(cTheme);
1009
- if (value) {
1010
- result = value;
1011
- } else {
1012
- result = isDarkMode() ? "dark" : "light";
1013
- }
1014
- }
1015
- return result;
1016
- });
1017
- const toggleTheme = () => setTheme(theme == "dark" ? "light" : "dark");
1018
- const [reportType, setReportType] = useLocalStorage("sys/reportType", 0);
1019
- const [modalList, setModalList] = useState([]);
1020
- const [showBtnTop, setShowBtnTop] = useState(false);
1021
- const histStack = useRef([]);
1022
- const histPending = useRef(/* @__PURE__ */ new Map());
1023
- const setVisibleMap = useRef(/* @__PURE__ */ new Map());
1024
- const ignorePop = useRef(0);
1025
- const pushHistory = (modalId) => {
1026
- if (histStack.current.includes(modalId) || histPending.current.has(modalId)) {
1027
- return;
1028
- }
1029
- const t = setTimeout(() => {
1030
- histPending.current.delete(modalId);
1031
- window.history.pushState({ jcModal: modalId }, "");
1032
- histStack.current.push(modalId);
1033
- }, 0);
1034
- histPending.current.set(modalId, t);
1035
- };
1036
- const releaseHistory = (modalId) => {
1037
- var _a;
1038
- if (histPending.current.has(modalId)) {
1039
- clearTimeout(histPending.current.get(modalId));
1040
- histPending.current.delete(modalId);
1041
- }
1042
- const stack = histStack.current;
1043
- const index = stack.indexOf(modalId);
1044
- if (index < 0) {
1045
- return;
1046
- }
1047
- stack.splice(index, 1);
1048
- if (((_a = window.history.state) == null ? void 0 : _a.jcModal) === modalId) {
1049
- ignorePop.current++;
1050
- window.history.back();
1051
- }
1052
- };
1053
- const closeByHistory = (modalId) => {
1054
- const setVisible = setVisibleMap.current.get(modalId);
1055
- setVisibleMap.current.delete(modalId);
1056
- setModalList((prev) => prev.filter((e) => e.modalId !== modalId));
1057
- if (setVisible) {
1058
- setVisible(false);
1059
- }
1060
- };
1061
- const addModal = (modalId, setVisible) => {
1062
- setVisibleMap.current.set(modalId, setVisible);
1063
- pushHistory(modalId);
1064
- setModalList((prev) => {
1065
- let arr = [...prev];
1066
- let index = arr.findIndex((e) => e.modalId === modalId);
1067
- if (index >= 0) {
1068
- arr[index] = { modalId, setVisible };
1069
- } else {
1070
- arr.push({ modalId, setVisible });
1071
- }
1072
- return arr;
1073
- });
1074
- };
1075
- const removeModal = (modalId) => {
1076
- let modal = modalList.find((e) => e.modalId === modalId);
1077
- if (modal) {
1078
- modal.setVisible(false);
1079
- }
1080
- setVisibleMap.current.delete(modalId);
1081
- releaseHistory(modalId);
1082
- setModalList((prev) => prev.filter((e) => e.modalId !== modalId));
1083
- return;
1084
- };
1085
- const clearModals = () => {
1086
- modalList.forEach((modal) => {
1087
- removeModal(modal.modalId);
1088
- });
1089
- };
1090
- const handleKeyDown = useCallback(
1091
- (e) => {
1092
- if (e.key === "Escape") {
1093
- if (modalList.length != 0) {
1094
- removeModal(modalList[modalList.length - 1].modalId);
1095
- }
1096
- }
1097
- },
1098
- [modalList]
1099
- );
1100
- useLocalhostBadge();
1101
- const borderTestServer = useTestDomainBadge(testDomain);
1102
- useEffect(() => {
1103
- if (canChangeTheme) {
1104
- localStorage.setItem(cTheme, theme);
1105
- document.body.dataset.bsTheme = theme == "dark" ? theme : "";
1106
- }
1107
- }, [theme, canChangeTheme]);
1108
- useEffect(() => {
1109
- window.addEventListener("keydown", handleKeyDown, false);
1110
- return () => window.removeEventListener("keydown", handleKeyDown, false);
1111
- }, [modalList]);
1112
- useEffect(() => {
1113
- var _a;
1114
- if (!bootChecked) {
1115
- bootChecked = true;
1116
- if ((_a = window.history.state) == null ? void 0 : _a.jcModal) {
1117
- window.history.back();
1118
- }
1119
- }
1120
- function onPopState() {
1121
- var _a2;
1122
- if (ignorePop.current > 0) {
1123
- ignorePop.current--;
1124
- return;
1125
- }
1126
- const current = (_a2 = window.history.state) == null ? void 0 : _a2.jcModal;
1127
- const stack = histStack.current;
1128
- while (stack.length && stack[stack.length - 1] !== current) {
1129
- closeByHistory(stack.pop());
1130
- }
1131
- if (current && !stack.includes(current)) {
1132
- ignorePop.current++;
1133
- window.history.back();
1134
- }
1135
- }
1136
- window.addEventListener("popstate", onPopState);
1137
- return () => {
1138
- window.removeEventListener("popstate", onPopState);
1139
- histPending.current.forEach((t) => clearTimeout(t));
1140
- histPending.current.clear();
1141
- };
1142
- }, []);
1143
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
1144
- LibContext.Provider,
1145
- {
1146
- value: {
1147
- versionApp,
1148
- addModal,
1149
- removeModal,
1150
- clearModals,
1151
- showBtnTop,
1152
- setShowBtnTop,
1153
- globalApiConfig: apiConfig,
1154
- theme,
1155
- setTheme,
1156
- toggleTheme,
1157
- canChangeTheme,
1158
- reportType,
1159
- setReportType
1160
- },
1161
- children: [
1162
- borderTestServer,
1163
- children
1164
- ]
1165
- }
1166
- );
1167
- };
1168
- function useLibContext() {
1169
- const context = useContext(LibContext);
1170
- if (!(context == null ? void 0 : context.addModal) && true) {
1171
- throw new Error("'ModalProvider' não encontrado!");
1172
- }
1173
- return context;
1174
- }
1175
- const AlertTypes = {
1176
- Alerta: 1,
1177
- Aviso: 2,
1178
- Confirmacao: 3
1179
- };
1180
- const cClassHideSB = "jc-alert-hide-sb";
1181
- function JCAlert({
1182
- type = AlertTypes.Aviso,
1183
- onConfirm,
1184
- onCancel,
1185
- title,
1186
- text: text2 = "",
1187
- children,
1188
- defaultBtn = 2
1189
- }) {
1190
- const buttonRef = useRef();
1191
- const containerRef = useRef();
1192
- const { addModal, removeModal } = useLibContext();
1193
- const [modalId] = useState("alert-" + random());
1194
- const controls = useDragControls();
1195
- let classColor = "jc-erro";
1196
- switch (type) {
1197
- case AlertTypes.Aviso:
1198
- classColor = "jc-aviso";
1199
- break;
1200
- case AlertTypes.Confirmacao:
1201
- classColor = "jc-conf";
1202
- break;
1203
- }
1204
- const handleKeys = useCallback(
1205
- (ev) => {
1206
- if (type === AlertTypes.Confirmacao) {
1207
- if (ev.code === "KeyS" && onConfirm) {
1208
- onConfirm();
1209
- }
1210
- if (ev.code === "KeyN" && onCancel) {
1211
- onCancel();
1212
- }
1213
- }
1214
- },
1215
- [onCancel, onConfirm, type]
1216
- );
1217
- useEffect(() => {
1218
- if (type === AlertTypes.Confirmacao) {
1219
- addModal(modalId, onCancel);
1220
- } else {
1221
- addModal(modalId, onConfirm);
1222
- }
1223
- return () => removeModal(modalId);
1224
- }, []);
1225
- useEffect(() => {
1226
- var _a;
1227
- (_a = buttonRef == null ? void 0 : buttonRef.current) == null ? void 0 : _a.focus();
1228
- }, [buttonRef]);
1229
- useEffect(() => {
1230
- document.addEventListener("keydown", handleKeys, false);
1231
- document.body.classList.add(cClassHideSB);
1232
- return () => {
1233
- document.removeEventListener("keydown", handleKeys, false);
1234
- document.body.classList.remove(cClassHideSB);
1235
- };
1236
- }, [handleKeys]);
1237
- function handleClose() {
1238
- if (type === AlertTypes.Confirmacao) {
1239
- onCancel();
1240
- } else {
1241
- onConfirm();
1242
- }
1243
- }
1244
- function startDrag(e) {
1245
- if (isMobile()) {
1246
- return;
1247
- }
1248
- controls.start(e);
1249
- }
1250
- return /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { className: "jc-alert--container", ref: containerRef, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1251
- motion.div,
1252
- {
1253
- className: "jc-alert " + classColor,
1254
- drag: true,
1255
- dragConstraints: containerRef,
1256
- dragElastic: 0.1,
1257
- dragMomentum: false,
1258
- dragControls: controls,
1259
- dragListener: false,
1260
- animate: { scale: 1 },
1261
- transition: {
1262
- ease: "easeOut",
1263
- duration: 0.3
1264
- },
1265
- children: [
1266
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "jc-close-button", onClick: handleClose, children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-xmark" }) }),
1267
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "jc-alert-header", onPointerDown: startDrag, children: [
1268
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "icon", children: [
1269
- type === AlertTypes.Aviso && /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-check" }),
1270
- type === AlertTypes.Alerta && /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-triangle-exclamation" }),
1271
- type === AlertTypes.Confirmacao && /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-question" })
1272
- ] }),
1273
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "jc-alert-title", children: title })
1274
- ] }),
1275
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "jc-alert-body", children: text2 && typeof text2 == "string" ? /* @__PURE__ */ jsxRuntimeExports.jsx(TextHTML, { value: text2 }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: text2 || children }) }),
1276
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "jc-alert-buttons", children: [
1277
- (type === AlertTypes.Alerta || type === AlertTypes.Aviso) && /* @__PURE__ */ jsxRuntimeExports.jsx(
1278
- "button",
1279
- {
1280
- ref: buttonRef,
1281
- type: "button",
1282
- className: "btn btn-confirm",
1283
- onClick: onConfirm,
1284
- children: "OK"
1285
- }
1286
- ),
1287
- type === AlertTypes.Confirmacao && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1288
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
1289
- "button",
1290
- {
1291
- type: "button",
1292
- className: "btn btn-confirm",
1293
- onClick: onConfirm,
1294
- tabIndex: 99,
1295
- ref: defaultBtn === 1 ? buttonRef : null,
1296
- children: [
1297
- /* @__PURE__ */ jsxRuntimeExports.jsx("u", { children: "S" }),
1298
- "im"
1299
- ]
1300
- }
1301
- ),
1302
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
1303
- "button",
1304
- {
1305
- type: "button",
1306
- className: "btn btn-confirm btn-nao",
1307
- onClick: onCancel,
1308
- tabIndex: 98,
1309
- ref: defaultBtn === 2 ? buttonRef : null,
1310
- children: [
1311
- /* @__PURE__ */ jsxRuntimeExports.jsx("u", { children: "N" }),
1312
- "ão"
1313
- ]
1314
- }
1315
- )
1316
- ] })
1317
- ] })
1318
- ]
1319
- }
1320
- ) });
1321
- }
1322
- function Aviso({ onConfirm, text: text2 = "", children }) {
1323
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
1324
- JCAlert,
1325
- {
1326
- type: AlertTypes.Aviso,
1327
- title: "Aviso!",
1328
- text: text2,
1329
- onConfirm,
1330
- children
1331
- }
1332
- );
1333
- }
1334
- function Confirma({
1335
- onConfirm,
1336
- onCancel,
1337
- text: text2 = "",
1338
- children,
1339
- defaultBtn = void 0
1340
- }) {
1341
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
1342
- JCAlert,
1343
- {
1344
- type: AlertTypes.Confirmacao,
1345
- title: "Confirmação!",
1346
- text: text2,
1347
- onConfirm,
1348
- onCancel,
1349
- defaultBtn,
1350
- children
1351
- }
1352
- );
1353
- }
1354
- function Alerta({ onConfirm, text: text2 = "", children }) {
1355
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
1356
- JCAlert,
1357
- {
1358
- type: AlertTypes.Alerta,
1359
- title: "Atenção!",
1360
- text: text2,
1361
- onConfirm,
1362
- children
1363
- }
1364
- );
1365
- }
1366
940
  const initConfig = {
1367
941
  baseURL: "",
1368
942
  timeout: 3e4,
@@ -1395,11 +969,11 @@ const Container$7 = styled.div`
1395
969
  `;
1396
970
  const TableContainer = styled.table`
1397
971
  --color-tb: var(--pn-color-border);
1398
- --color-bg: var(--bs-body);
972
+ --color-bg: var(--jc-superficie);
1399
973
  --table-border: 1px solid var(--bs-border-color);
1400
974
 
1401
975
  width: 100%;
1402
- /* margin-bottom: 8px; */
976
+ font-variant-numeric: tabular-nums; // valores alinhados
1403
977
 
1404
978
  border-collapse: separate;
1405
979
  border-spacing: 0;
@@ -1407,7 +981,7 @@ const TableContainer = styled.table`
1407
981
  border-top: ${({ hasBorder }) => hasBorder ? "var(--table-border)" : "none"};
1408
982
 
1409
983
  tr {
1410
- --table-line-height: 36px;
984
+ --table-line-height: 40px;
1411
985
  height: var(--table-line-height);
1412
986
  }
1413
987
 
@@ -1424,7 +998,7 @@ const TableContainer = styled.table`
1424
998
  }
1425
999
 
1426
1000
  thead {
1427
- background-color: var(--bs-body-bg);
1001
+ background-color: var(--jc-superficie-2);
1428
1002
 
1429
1003
  &.table-header--fixed {
1430
1004
  position: sticky;
@@ -1433,13 +1007,16 @@ const TableContainer = styled.table`
1433
1007
  }
1434
1008
 
1435
1009
  th {
1436
- border-bottom: 2px solid var(--bs-border-color);
1437
- padding: 5px;
1438
- color: var(--bs-body-color);
1439
- font-weight: bold;
1010
+ border-bottom: 1px solid var(--jc-borda);
1011
+ padding: var(--jc-esp-2);
1012
+ color: var(--jc-texto-suave);
1013
+ font-size: var(--jc-fs-xs);
1014
+ font-weight: var(--jc-peso-forte);
1015
+ text-transform: uppercase;
1016
+ letter-spacing: 0.04em;
1440
1017
 
1441
1018
  &:first-child {
1442
- border-left: ${({ hasBorder: border }) => border ? "5px solid #aaa" : "none"};
1019
+ border-left: ${({ hasBorder: border }) => border ? "3px solid var(--jc-borda)" : "none"};
1443
1020
  }
1444
1021
  }
1445
1022
  }
@@ -1457,16 +1034,25 @@ const TableContainer = styled.table`
1457
1034
  background-color: var(--table-hover);
1458
1035
  }
1459
1036
 
1460
- &.linha-marcada {
1461
- background-color: var(--table-marked) !important;
1037
+ // destaque somente quando não está no formato de card
1038
+ @media (min-width: ${({ sizeBreak }) => Number(sizeBreak || 767) + 1}px) {
1039
+ &.linha-marcada {
1040
+ background-color: var(--table-marked) !important;
1041
+
1042
+ td:first-child {
1043
+ box-shadow: inset 3px 0 0 var(--jc-destaque);
1044
+ }
1045
+ }
1462
1046
  }
1463
1047
  }
1464
1048
 
1465
1049
  td {
1466
- padding: 3px 5px;
1050
+ padding: var(--jc-esp-1) var(--jc-esp-2);
1051
+ // com border-collapse: separate a borda do tr não aparece; a divisória fica no td
1052
+ border-bottom: ${({ hasBorder: border }) => !border ? "1px solid var(--jc-borda)" : "var(--table-border)"};
1467
1053
 
1468
1054
  &:first-child {
1469
- border-left: ${({ hasBorder: border }) => border ? "5px solid var(--color-tb)" : "none"};
1055
+ border-left: ${({ hasBorder: border }) => border ? "3px solid var(--color-tb)" : "none"};
1470
1056
  }
1471
1057
  }
1472
1058
 
@@ -1515,9 +1101,10 @@ const TableContainer = styled.table`
1515
1101
  flex-direction: column;
1516
1102
  margin-bottom: 10px;
1517
1103
  background-color: var(--color-bg);
1518
- border-top: 8px solid var(--color-tb);
1519
- border-bottom: 2px solid var(--color-tb);
1520
- padding: 3px 0;
1104
+ border: 1px solid var(--jc-borda);
1105
+ border-top: 3px solid var(--color-tb);
1106
+ border-radius: var(--jc-raio);
1107
+ padding: var(--jc-esp-2) var(--jc-esp-1);
1521
1108
 
1522
1109
  &:nth-child(even),
1523
1110
  &:hover {
@@ -1543,9 +1130,9 @@ const TableContainer = styled.table`
1543
1130
 
1544
1131
  .titulo {
1545
1132
  display: inline;
1546
- font-size: calc(var(--font-size) - 1px);
1547
- font-weight: bold;
1548
- color: #888;
1133
+ font-size: var(--jc-fs-sm);
1134
+ font-weight: var(--jc-peso-medio);
1135
+ color: var(--jc-texto-suave);
1549
1136
  }
1550
1137
 
1551
1138
  .col-campo2 {
@@ -1555,7 +1142,7 @@ const TableContainer = styled.table`
1555
1142
  .acoes {
1556
1143
  margin-top: 5px;
1557
1144
  padding-top: 5px;
1558
- border-top: 1px solid var(--bs-border-color);
1145
+ border-top: 1px solid var(--jc-borda);
1559
1146
 
1560
1147
  .acoes-layout .btn {
1561
1148
  font-size: 17px;
@@ -1581,10 +1168,10 @@ styled.span`
1581
1168
  width: 15px;
1582
1169
  font-size: 10px;
1583
1170
  border: 1px solid
1584
- ${(props) => props.value ? "#346fdd" : "var(--bs-border-color)"};
1585
- border-radius: 1px;
1586
- color: ${(props) => props.value ? "#fff" : ""};
1587
- background-color: ${(props) => props.value ? "#346fdd" : "var(--bs-body-color"};
1171
+ ${(props) => props.value ? "var(--jc-secundaria)" : "var(--bs-border-color)"};
1172
+ border-radius: var(--jc-raio-sm);
1173
+ color: ${(props) => props.value ? "var(--jc-secundaria-contraste)" : ""};
1174
+ background-color: ${(props) => props.value ? "var(--jc-secundaria)" : "var(--jc-superficie)"};
1588
1175
  `;
1589
1176
  function DropDownButton({
1590
1177
  title,
@@ -1789,7 +1376,7 @@ function Table({
1789
1376
  }
1790
1377
  if (loading) {
1791
1378
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "py-2 hstack gap-2", children: [
1792
- /* @__PURE__ */ jsxRuntimeExports.jsx(Spinner, { size: "sm", color: "info" }),
1379
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Spinner, { size: "sm", color: "secundaria" }),
1793
1380
  " ",
1794
1381
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Carregando..." })
1795
1382
  ] });
@@ -1988,9 +1575,9 @@ styled.div`
1988
1575
  }
1989
1576
  `;
1990
1577
  styled.div`
1991
- background-color: white;
1992
- border: 1px solid ${(props) => props.color || "#7fb0c9"};
1993
- border-top: 8px solid ${(props) => props.color || "#7fb0c9"};
1578
+ background-color: var(--jc-superficie);
1579
+ border: 1px solid ${(props) => props.color || "var(--jc-borda)"};
1580
+ border-top: 8px solid ${(props) => props.color || "var(--jc-borda)"};
1994
1581
  border-radius: 0 0 6px 6px;
1995
1582
  padding-bottom: 8px;
1996
1583
  `;
@@ -1999,13 +1586,13 @@ styled.div`
1999
1586
  align-items: center;
2000
1587
  padding: 5px 0;
2001
1588
  margin: 5px 20px;
2002
- border-bottom: 1px solid #ccc;
1589
+ border-bottom: 1px solid var(--jc-borda);
2003
1590
  h3 {
2004
1591
  font-size: 20px;
2005
1592
  }
2006
1593
  `;
2007
1594
  styled.div`
2008
- background-color: white;
1595
+ background-color: var(--jc-superficie);
2009
1596
  padding: 5px 20px;
2010
1597
  `;
2011
1598
  styled.h3`
@@ -2017,11 +1604,11 @@ styled.div`
2017
1604
  cursor: pointer;
2018
1605
  font-size: 22px;
2019
1606
  text-align: center;
2020
- color: ${(props) => props.ativo ? "#232BFF" : "#888"};
1607
+ color: ${(props) => props.ativo ? "var(--jc-secundaria)" : "var(--jc-texto-suave)"};
2021
1608
  transition: all ease 0.5s;
2022
1609
  `;
2023
- const IconToggleOn = ({ color }) => /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-toggle-on", style: { color: color || "blue" } });
2024
- const IconToggleOff = ({ color }) => /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-toggle-off", style: { color: color || "gray" } });
1610
+ const IconToggleOn = ({ color }) => /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-toggle-on", style: { color: color || "var(--jc-secundaria)" } });
1611
+ const IconToggleOff = ({ color }) => /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-toggle-off", style: { color: color || "var(--jc-texto-suave)" } });
2025
1612
  const IconChecked = () => /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "far fa-check-circle" });
2026
1613
  const IconSearch = () => /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-search" });
2027
1614
  const IconClonar = () => /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "far fa-copy" });
@@ -2033,9 +1620,9 @@ styled.div`
2033
1620
  display: flex;
2034
1621
  justify-content: center;
2035
1622
  align-items: center;
2036
- color: white;
2037
- background-color: ${(props) => props.checked ? "#0067C0" : "white"};
2038
- border: 1px solid ${(props) => props.checked ? "#0067C0" : "silver"};
1623
+ color: var(--jc-secundaria-contraste);
1624
+ background-color: ${(props) => props.checked ? "var(--jc-secundaria)" : "var(--jc-superficie)"};
1625
+ border: 1px solid ${(props) => props.checked ? "var(--jc-secundaria)" : "var(--jc-borda)"};
2039
1626
  border-radius: 4px;
2040
1627
  cursor: ${(props) => props.onClick ? "pointer" : "default"};
2041
1628
  `;
@@ -2099,16 +1686,16 @@ const IconeSoma = () => /* @__PURE__ */ jsxRuntimeExports.jsx(
2099
1686
  const IconeOpenLink = ({ ...rest }) => /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-arrow-up-right-from-square", ...rest });
2100
1687
  const IconeQRCode = ({ ...rest }) => /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-qrcode", ...rest });
2101
1688
  function BotaoExcluir({ title = "Excluir o registro" }) {
2102
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "sm", color: "danger", title, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconeExcluir, {}) });
1689
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "sm", color: "outline-danger", title, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconeExcluir, {}) });
2103
1690
  }
2104
1691
  function BotaoEditar({ title = "Alterar o registro" }) {
2105
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "sm", color: "primary", title, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconeEditar, {}) });
1692
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "sm", color: "outline-secundaria", title, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconeEditar, {}) });
2106
1693
  }
2107
1694
  function BotaoIncluir({ caption = "Incluir", onClick, ...rest }) {
2108
1695
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
2109
1696
  Button,
2110
1697
  {
2111
- color: "success",
1698
+ color: "destaque",
2112
1699
  title: "Incluir um novo registro",
2113
1700
  onClick,
2114
1701
  ...rest,
@@ -2153,7 +1740,7 @@ function BotaoSalvar({
2153
1740
  Button,
2154
1741
  {
2155
1742
  type: onConfirm ? "button" : "submit",
2156
- color: "primary",
1743
+ color: "destaque",
2157
1744
  onClick: onConfirm,
2158
1745
  disabled: btnSaveDisabled && btnSaveDisabled == true,
2159
1746
  children: [
@@ -2162,7 +1749,7 @@ function BotaoSalvar({
2162
1749
  ]
2163
1750
  }
2164
1751
  ),
2165
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { type: "button", color: "outline-danger", onClick: cancelar, children: [
1752
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { type: "button", color: "terciaria", onClick: cancelar, children: [
2166
1753
  /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-times" }),
2167
1754
  "Cancelar"
2168
1755
  ] })
@@ -2345,7 +1932,7 @@ const ButtonStyled = styled.button`
2345
1932
  &.close {
2346
1933
  margin-right: var(--margin-hor);
2347
1934
  &:hover {
2348
- color: #ff4545;
1935
+ color: var(--jc-erro);
2349
1936
  }
2350
1937
  }
2351
1938
  `;
@@ -2436,7 +2023,7 @@ function ButtonOptions({ value, setValue, options = [], ...rest }) {
2436
2023
  Button,
2437
2024
  {
2438
2025
  active: index === value,
2439
- color: "outline-info",
2026
+ color: "outline-secundaria",
2440
2027
  onClick: () => setValue(index),
2441
2028
  children: opt
2442
2029
  },
@@ -2606,20 +2193,26 @@ const PanelHeader = styled.div`
2606
2193
  align-items: center;
2607
2194
  gap: 0 2px;
2608
2195
 
2609
- color: var(--pn-color-font);
2610
- font-size: 1.2rem;
2611
- /* background-color: var(--pn-color); */
2196
+ color: var(--jc-texto);
2197
+ font-size: var(--jc-fs-md);
2198
+ font-weight: var(--jc-peso-forte);
2199
+ letter-spacing: -0.01em;
2612
2200
  background: var(--pn-degrade);
2201
+ border-bottom: 1px solid var(--jc-borda);
2613
2202
  border-radius: var(--pn-internal-radius) var(--pn-internal-radius) 0 0;
2614
2203
 
2615
2204
  padding: var(--pn-padding);
2616
- min-height: 39px;
2205
+ min-height: 48px;
2617
2206
 
2618
2207
  .pn-title {
2619
2208
  display: flex;
2620
2209
  align-items: center;
2621
- gap: 5px;
2210
+ gap: var(--jc-esp-2);
2622
2211
  flex: 1;
2212
+
2213
+ svg {
2214
+ color: var(--jc-secundaria);
2215
+ }
2623
2216
  }
2624
2217
 
2625
2218
  @media print {
@@ -2647,7 +2240,7 @@ function PanelBadge({ value, isCount, ...rest }) {
2647
2240
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
2648
2241
  "div",
2649
2242
  {
2650
- className: "badge bg-info text-dark",
2243
+ className: "badge bg-secundaria-suave text-secundaria",
2651
2244
  style: { borderRadius: "var(--pn-border-radius)" },
2652
2245
  ...rest,
2653
2246
  children: total
@@ -3267,7 +2860,7 @@ function InputPesquisa({
3267
2860
  /* @__PURE__ */ jsxRuntimeExports.jsx(
3268
2861
  Button,
3269
2862
  {
3270
- color: "info",
2863
+ color: "secundaria",
3271
2864
  title: "Pesquisar",
3272
2865
  onClick: fnSearch,
3273
2866
  type: fnSearch ? "button" : "submit",
@@ -3302,6 +2895,7 @@ const ContainerFixed = styled.div`
3302
2895
  position: fixed;
3303
2896
  inset: 0 0 0;
3304
2897
  background-color: var(--jc-overlay-bg);
2898
+ backdrop-filter: blur(2px);
3305
2899
  z-index: 1031;
3306
2900
  padding: 0 8px;
3307
2901
 
@@ -3312,8 +2906,8 @@ const ContainerFixed = styled.div`
3312
2906
  padding-bottom: ${(p) => p.alignTop ? "30px" : "0"};
3313
2907
 
3314
2908
  & > .mod-panel {
3315
- background-color: var(--bs-body-bg);
3316
- border: 1px solid var(--pn-color);
2909
+ background-color: var(--jc-superficie);
2910
+ border: 1px solid var(--jc-borda);
3317
2911
  border-radius: var(--pn-border-radius);
3318
2912
 
3319
2913
  // no modo escuro a borda superior é mais clara
@@ -3566,12 +3160,12 @@ function InputQRCode({ value, setValue }) {
3566
3160
  value ? /* @__PURE__ */ jsxRuntimeExports.jsx(
3567
3161
  LinkToNewPage,
3568
3162
  {
3569
- className: "btn btn-info",
3163
+ className: "btn btn-secundaria",
3570
3164
  title: "Abrir o link do documento",
3571
3165
  to: value,
3572
3166
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconeOpenLink, {})
3573
3167
  }
3574
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { color: "info", disabled: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconeOpenLink, {}) })
3168
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { color: "secundaria", disabled: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconeOpenLink, {}) })
3575
3169
  ] }),
3576
3170
  showQrReader && /* @__PURE__ */ jsxRuntimeExports.jsx(
3577
3171
  QRCodeReader,
@@ -3833,7 +3427,7 @@ function InputCep({
3833
3427
  "button",
3834
3428
  {
3835
3429
  type: "button",
3836
- className: "btn btn-info",
3430
+ className: "btn btn-secundaria",
3837
3431
  onClick: () => handleClick(rest.value),
3838
3432
  disabled,
3839
3433
  children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-search" })
@@ -8450,7 +8044,7 @@ const InputSearch = ({
8450
8044
  "button",
8451
8045
  {
8452
8046
  type: "button",
8453
- className: "btn btn-info",
8047
+ className: "btn btn-secundaria",
8454
8048
  title: "Abrir tela de pesquisa",
8455
8049
  onClick: btnClick,
8456
8050
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconSearch, {})
@@ -8473,7 +8067,7 @@ const InputFinder$1 = ({ title, onFind, children, ...rest }) => {
8473
8067
  {
8474
8068
  type: "button",
8475
8069
  title: "Pesquisar...",
8476
- className: "btn btn-info",
8070
+ className: "btn btn-secundaria",
8477
8071
  onClick: onFind,
8478
8072
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconSearch, {})
8479
8073
  }
@@ -8686,7 +8280,7 @@ function InputFinder({
8686
8280
  {
8687
8281
  type: "button",
8688
8282
  title: "Pesquisar...",
8689
- className: "btn btn-info",
8283
+ className: "btn btn-secundaria",
8690
8284
  onClick: () => setShowSearchBox(true),
8691
8285
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconSearch, {})
8692
8286
  }
@@ -8857,7 +8451,7 @@ const Container$3 = styled.div`
8857
8451
  display: inline-block;
8858
8452
  `;
8859
8453
  const Label = styled.span`
8860
- color: ${(props) => props.disabled ? "silver" : "#333"};
8454
+ color: ${(props) => props.disabled ? "var(--jc-texto-suave)" : "var(--jc-texto)"};
8861
8455
  display: flex;
8862
8456
  align-items: center;
8863
8457
  margin: 0px 0 0;
@@ -9833,7 +9427,7 @@ function Paginacao({
9833
9427
  /* @__PURE__ */ jsxRuntimeExports.jsx(
9834
9428
  "button",
9835
9429
  {
9836
- className: "btn btn-outline-" + (page <= 1 ? "secondary" : "info"),
9430
+ className: "btn btn-outline-" + (page <= 1 ? "secondary" : "secundaria"),
9837
9431
  title: "Ir para a primeira página",
9838
9432
  onClick: () => updatePage(1),
9839
9433
  disabled: page <= 1,
@@ -9843,7 +9437,7 @@ function Paginacao({
9843
9437
  /* @__PURE__ */ jsxRuntimeExports.jsx(
9844
9438
  "button",
9845
9439
  {
9846
- className: "btn btn-outline-" + (page <= 1 ? "secondary" : "info"),
9440
+ className: "btn btn-outline-" + (page <= 1 ? "secondary" : "secundaria"),
9847
9441
  title: "Ir para página anterior",
9848
9442
  onClick: () => updatePage(Number(page) - 1),
9849
9443
  disabled: page <= 1,
@@ -9860,7 +9454,7 @@ function Paginacao({
9860
9454
  /* @__PURE__ */ jsxRuntimeExports.jsx(
9861
9455
  "button",
9862
9456
  {
9863
- className: "btn btn-outline-" + (page >= pages ? "secondary" : "info"),
9457
+ className: "btn btn-outline-" + (page >= pages ? "secondary" : "secundaria"),
9864
9458
  title: "Ir para próxima página",
9865
9459
  onClick: () => updatePage(Number(page) + 1),
9866
9460
  disabled: page >= pages,
@@ -9870,7 +9464,7 @@ function Paginacao({
9870
9464
  /* @__PURE__ */ jsxRuntimeExports.jsx(
9871
9465
  "button",
9872
9466
  {
9873
- className: "btn btn-outline-" + (page >= pages ? "secondary" : "info"),
9467
+ className: "btn btn-outline-" + (page >= pages ? "secondary" : "secundaria"),
9874
9468
  title: "Ir para a última página",
9875
9469
  onClick: () => updatePage(pages),
9876
9470
  disabled: page >= pages,
@@ -9884,7 +9478,7 @@ function Paginacao({
9884
9478
  }
9885
9479
  function PanelDashboard({
9886
9480
  title,
9887
- color = "var(--pn-color-border)",
9481
+ color = "var(--dash-top)",
9888
9482
  backColor = "var(--bs-body-bg)",
9889
9483
  className,
9890
9484
  minHeight,
@@ -9902,8 +9496,7 @@ function PanelDashboard({
9902
9496
  marginBottom,
9903
9497
  "--color": color,
9904
9498
  "--back-color": backColor,
9905
- "--degrade-margin-top": degrade ? "calc(calc(var(--panel-dash-top) * -1))" : "0px",
9906
- "--border-top-width": degrade ? "0px" : "6px"
9499
+ "--border-top-width": degrade ? "1px" : "3px"
9907
9500
  },
9908
9501
  ...rest,
9909
9502
  children: [
@@ -11585,9 +11178,9 @@ function TextHTML({ value }) {
11585
11178
  return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { dangerouslySetInnerHTML: { __html: purify.sanitize(html2) } });
11586
11179
  }
11587
11180
  const Container$2 = styled.div`
11588
- --toggle-color-on: #4169ed;
11589
- --toggle-color-off: #666;
11590
- --toggle-color-inactive: #999;
11181
+ --toggle-color-on: var(--jc-secundaria);
11182
+ --toggle-color-off: var(--jc-texto-suave);
11183
+ --toggle-color-inactive: var(--jc-borda);
11591
11184
  --toggle-color-white: #fff;
11592
11185
  --toggle-color-text: var(--bs-body-color);
11593
11186
 
@@ -12115,7 +11708,7 @@ function TabControl({
12115
11708
  }
12116
11709
  const Container = styled.div`
12117
11710
  /* margin: ${({ noMargin }) => noMargin ? "0" : "5px 0 8px"}; */
12118
- border: 1px solid var(--pn-color-border);
11711
+ border: 1px solid var(--tab-border);
12119
11712
  border-radius: ${(props) => props.open ? "0 0 var(--pn-border-radius) var(--pn-border-radius)" : "0"};
12120
11713
  background-color: var(--bs-body-bg);
12121
11714
  //overflow: hidden;
@@ -12125,7 +11718,7 @@ const Container = styled.div`
12125
11718
  outline: 0;
12126
11719
  border: none;
12127
11720
  border-bottom: ${({ open }) => open ? "1" : "0"}px solid
12128
- var(--pn-color-border);
11721
+ var(--tab-border);
12129
11722
  border-left: 8px solid var(--bi-color-detail);
12130
11723
  background-color: var(--bi-color-button);
12131
11724
  color: var(--pn-color-font);
@@ -14432,9 +14025,47 @@ function useSessionStorage(key, initialValue) {
14432
14025
  return initialValue;
14433
14026
  });
14434
14027
  useEffect(() => {
14435
- sessionStorage.setItem(key, JSON.stringify(storedValue));
14436
- }, [storedValue]);
14437
- return [storedValue, setStoredValue];
14028
+ sessionStorage.setItem(key, JSON.stringify(storedValue));
14029
+ }, [storedValue]);
14030
+ return [storedValue, setStoredValue];
14031
+ }
14032
+ const BorderTestServer = styled.div`
14033
+ position: fixed;
14034
+ top: 3px;
14035
+ left: 3px;
14036
+ width: 12px;
14037
+ aspect-ratio: 1/1;
14038
+ box-sizing: border-box;
14039
+ background-color: #2cbd64;
14040
+ border-radius: 99px;
14041
+ pointer-events: none;
14042
+ z-index: 9999999;
14043
+ `;
14044
+ const MARCADOR_LOCALHOST = " 🔴 ";
14045
+ const MARCADOR_TESTE = " 🟢 ";
14046
+ function useLocalhostBadge() {
14047
+ useEffect(() => {
14048
+ const inLocalhost = window.location.hostname == "localhost" || window.location.hostname == "127.0.0.1" || window.location.hostname == "[::1]" || window.location.hostname.startsWith("192.168.");
14049
+ if (inLocalhost && !document.title.includes(MARCADOR_LOCALHOST)) {
14050
+ document.title = `${MARCADOR_LOCALHOST}${document.title}`;
14051
+ }
14052
+ }, []);
14053
+ }
14054
+ function useTestDomainBadge(testDomain) {
14055
+ function inTestServer() {
14056
+ const domains = testDomain ? [].concat(testDomain) : ["test.", "test-", "dev."];
14057
+ return Boolean(
14058
+ domains.some((domain) => window.location.hostname.includes(domain))
14059
+ );
14060
+ }
14061
+ useEffect(() => {
14062
+ if (inTestServer() && !document.title.includes(MARCADOR_TESTE)) {
14063
+ document.title = `${MARCADOR_TESTE}${document.title}`;
14064
+ }
14065
+ }, [testDomain]);
14066
+ if (inTestServer() && isMobile()) {
14067
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(BorderTestServer, {});
14068
+ }
14438
14069
  }
14439
14070
  localforage.config({
14440
14071
  driver: localforage.INDEXEDDB,
@@ -14572,8 +14203,8 @@ const MenuOptionLink = styled(Link)`
14572
14203
 
14573
14204
  .menu-new {
14574
14205
  font-size: 0.7rem;
14575
- background-color: #3cb33c;
14576
- color: #fff;
14206
+ background-color: var(--jc-destaque);
14207
+ color: var(--jc-destaque-contraste);
14577
14208
  padding: 2px 4px 3px 9px;
14578
14209
  line-height: 100%;
14579
14210
  border-radius: 2px;
@@ -14681,37 +14312,414 @@ function MenuOption({
14681
14312
  enabledFavorite && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "menu-fav", onClick: (ev) => clickFavorite(ev, opc), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
14682
14313
  "i",
14683
14314
  {
14684
- title: "Clique para favoritar esta opção",
14685
- className: "fa-" + (isFav ? "solid" : "regular") + " fa-heart",
14686
- style: {
14687
- color: isFav ? "var(--nav-icon)" : "var(--nav-icon-fav)"
14688
- }
14315
+ title: "Clique para favoritar esta opção",
14316
+ className: "fa-" + (isFav ? "solid" : "regular") + " fa-heart",
14317
+ style: {
14318
+ color: isFav ? "var(--nav-icon)" : "var(--nav-icon-fav)"
14319
+ }
14320
+ }
14321
+ ) })
14322
+ ] })
14323
+ ] });
14324
+ } else if (opc == null ? void 0 : opc.isLine) {
14325
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Line, {});
14326
+ } else {
14327
+ return null;
14328
+ }
14329
+ }
14330
+ }
14331
+ const cKeyClosedMenus$1 = "sys/nav/closed";
14332
+ function Navbar({
14333
+ menusConfig: { brand, company, menus, routes, user, validatePermis },
14334
+ helpLink
14335
+ }) {
14336
+ const history = useHistory();
14337
+ const inputFiltro = useRef();
14338
+ const menuRef = useRef();
14339
+ const { theme, setTheme, canChangeTheme } = useLibContext();
14340
+ const [isOpen, setIsOpen] = useState(false);
14341
+ const [filter, setFilter] = useState("");
14342
+ const [opcoes, setOpcoes] = useState([]);
14343
+ const [favorites, setFavorites] = useState([]);
14344
+ let closedMenus = [];
14345
+ const value = localStorage.getItem(cKeyClosedMenus$1);
14346
+ if (value) {
14347
+ closedMenus = JSON.parse(value);
14348
+ }
14349
+ const [getFavorites] = useApi({
14350
+ url: routes.apiFavorites,
14351
+ onTerminated: (res) => {
14352
+ if (res.error) {
14353
+ console.info("Erro ao obter lista de favoritos!", res.error);
14354
+ } else {
14355
+ setFavorites(res.data);
14356
+ }
14357
+ }
14358
+ });
14359
+ const [patchFavorites] = useApi({
14360
+ url: routes.apiFavorites,
14361
+ method: "patch",
14362
+ onTerminated: (res) => {
14363
+ if (res.error) {
14364
+ console.info("Erro ao salvar favoritos!", res.error);
14365
+ }
14366
+ }
14367
+ });
14368
+ useEffect(() => {
14369
+ if (routes.apiFavorites) {
14370
+ getFavorites();
14371
+ }
14372
+ }, []);
14373
+ useEffect(() => {
14374
+ let favoriteOptions = [];
14375
+ favorites == null ? void 0 : favorites.forEach((favorite) => {
14376
+ menus.forEach((group, index) => {
14377
+ var _a;
14378
+ if (index > 0 && ((_a = group == null ? void 0 : group.menus) == null ? void 0 : _a.length) !== 0) {
14379
+ let indexOpt = group.menus.findIndex((opt) => opt.route === favorite.route);
14380
+ if (indexOpt >= 0) {
14381
+ let menuOption = group.menus[indexOpt];
14382
+ favoriteOptions.push({
14383
+ ...menuOption,
14384
+ caption: favorite.caption,
14385
+ index: String(index).padStart(2, "0") + String(indexOpt).padStart(2, 0)
14386
+ });
14387
+ }
14388
+ }
14389
+ });
14390
+ });
14391
+ if (menus[0].caption === "Favoritos") {
14392
+ menus[0].menus = favoriteOptions.sort((a, b) => {
14393
+ if (a.index > b.index) return 1;
14394
+ if (a.index < b.index) return -1;
14395
+ return 0;
14396
+ });
14397
+ }
14398
+ setOpcoes(configurarOpcoes(menus));
14399
+ }, [filter, favorites]);
14400
+ useEffect(() => {
14401
+ var _a, _b;
14402
+ if (isDesktop()) {
14403
+ (_a = inputFiltro == null ? void 0 : inputFiltro.current) == null ? void 0 : _a.focus();
14404
+ (_b = inputFiltro == null ? void 0 : inputFiltro.current) == null ? void 0 : _b.select();
14405
+ }
14406
+ }, [isOpen]);
14407
+ function saveFavorites(list) {
14408
+ if (routes.apiFavorites) {
14409
+ patchFavorites({ data: list });
14410
+ setFavorites(list);
14411
+ }
14412
+ }
14413
+ function configurarOpcoes(menus2) {
14414
+ let opts = [];
14415
+ const termo = normalizeText(filter);
14416
+ menus2.forEach((gr) => {
14417
+ let grupo = {
14418
+ caption: gr.caption,
14419
+ open: !closedMenus.includes(gr.caption) || gr.stayOpen,
14420
+ stayOpen: gr.stayOpen,
14421
+ isFavorite: gr == null ? void 0 : gr.isFavorite,
14422
+ prefix: gr == null ? void 0 : gr.prefix,
14423
+ menus: []
14424
+ };
14425
+ if (gr.menus && gr.menus.length > 0) {
14426
+ gr.menus.filter(
14427
+ (e) => (e == null ? void 0 : e.isLine) || !(e == null ? void 0 : e.isLine) && (normalizeText(e.caption).includes(termo) || normalizeText(e.shortcut).includes(termo))
14428
+ ).forEach((sub) => {
14429
+ if (validatePermis(sub == null ? void 0 : sub.permis, sub == null ? void 0 : sub.acesso)) {
14430
+ grupo.menus.push({ ...sub, prefix: grupo == null ? void 0 : grupo.prefix });
14431
+ }
14432
+ });
14433
+ }
14434
+ if (filter) {
14435
+ grupo.open = true;
14436
+ }
14437
+ opts.push(grupo);
14438
+ });
14439
+ opts.forEach((o) => {
14440
+ var _a;
14441
+ if (o.menus) {
14442
+ if ((_a = o.menus[0]) == null ? void 0 : _a.isLine) {
14443
+ o.menus = o.menus.filter((opc) => !(opc == null ? void 0 : opc.isLine));
14444
+ }
14445
+ o.menus = o.menus.filter((opc, index, arr) => {
14446
+ var _a2;
14447
+ if (index > 0 && ((_a2 = arr[index - 1]) == null ? void 0 : _a2.isLine) && opc.isLine) {
14448
+ return false;
14449
+ }
14450
+ return true;
14451
+ });
14452
+ o.menus = o.menus.filter((opc, index, arr) => {
14453
+ return !(index === arr.length - 1 && (opc == null ? void 0 : opc.isLine));
14454
+ });
14455
+ }
14456
+ });
14457
+ return opts;
14458
+ }
14459
+ function closeMenu() {
14460
+ setIsOpen(false);
14461
+ }
14462
+ function handleClickBackground(e) {
14463
+ if (e.target.id === "menu-background") {
14464
+ closeMenu();
14465
+ }
14466
+ }
14467
+ function clickGroup(grupo) {
14468
+ let newOpc = [...opcoes];
14469
+ let closed = [];
14470
+ newOpc.forEach((item) => {
14471
+ if (item === grupo) {
14472
+ item.open = !item.open;
14473
+ }
14474
+ if (!item.open) {
14475
+ closed.push(item.caption);
14476
+ }
14477
+ });
14478
+ localStorage.setItem(cKeyClosedMenus$1, JSON.stringify(closed));
14479
+ setOpcoes(newOpc);
14480
+ }
14481
+ function handleAbrirFecharGrupos(expand) {
14482
+ let newOpc = [...opcoes];
14483
+ newOpc.forEach((e) => {
14484
+ if (e == null ? void 0 : e.menus) {
14485
+ if (e == null ? void 0 : e.stayOpen) {
14486
+ e.open = e.stayOpen;
14487
+ } else {
14488
+ e.open = expand;
14489
+ }
14490
+ }
14491
+ });
14492
+ setOpcoes(newOpc);
14493
+ clickGroup(null);
14494
+ }
14495
+ function handleClickFavorite(ev, opcao) {
14496
+ ev.stopPropagation();
14497
+ ev.preventDefault();
14498
+ const newFav = favorites.filter((e) => e.route !== opcao.route);
14499
+ if (newFav.length === favorites.length) {
14500
+ newFav.push({
14501
+ caption: ((opcao == null ? void 0 : opcao.prefix) ? opcao.prefix + " / " : "") + opcao.caption,
14502
+ route: opcao.route
14503
+ });
14504
+ }
14505
+ saveFavorites(newFav);
14506
+ }
14507
+ function isFavorite(route) {
14508
+ return favorites.some((e) => e.route === route);
14509
+ }
14510
+ function handleKeyDown(e) {
14511
+ if (e.key != "Enter") {
14512
+ return;
14513
+ }
14514
+ for (const opc of opcoes) {
14515
+ if (opc.menus && opc.menus.length != 0) {
14516
+ const option = opc.menus.find((e2) => e2.route != null && e2.route != "");
14517
+ if (option) {
14518
+ history.push(option.route);
14519
+ setIsOpen(false);
14520
+ break;
14521
+ }
14522
+ }
14523
+ }
14524
+ }
14525
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
14526
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "navbar--area", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "navbar-content", children: [
14527
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14528
+ "button",
14529
+ {
14530
+ className: "btn-menu" + (isOpen ? " opened" : ""),
14531
+ title: "Abrir menu de opções",
14532
+ onClick: () => setIsOpen(!isOpen),
14533
+ children: isOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx(IconClose, { width: 20, height: 20 }) : /* @__PURE__ */ jsxRuntimeExports.jsx(IconMenu, { width: 20, height: 20 })
14534
+ }
14535
+ ),
14536
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "content", children: [
14537
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14538
+ Link,
14539
+ {
14540
+ to: routes.home,
14541
+ className: "brand",
14542
+ onClick: closeMenu,
14543
+ title: "Voltar para tela inicial",
14544
+ children: brand
14545
+ }
14546
+ ),
14547
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "company", children: [
14548
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "name", children: company }),
14549
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "doc", children: [
14550
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
14551
+ user == null ? void 0 : user.title,
14552
+ " "
14553
+ ] }),
14554
+ /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: user == null ? void 0 : user.name })
14555
+ ] })
14556
+ ] }),
14557
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "nav-btn-area", children: [
14558
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "btn-theme", children: canChangeTheme && /* @__PURE__ */ jsxRuntimeExports.jsx(
14559
+ "button",
14560
+ {
14561
+ title: "Alterar entre o tema claro/escuro",
14562
+ className: "btn nav-button",
14563
+ onClick: () => {
14564
+ const vtheme = theme == "light" ? "dark" : "light";
14565
+ setTheme(vtheme);
14566
+ document.body.dataset.bsTheme = vtheme;
14567
+ },
14568
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-circle-half-stroke" })
14689
14569
  }
14690
- ) })
14570
+ ) }),
14571
+ helpLink && /* @__PURE__ */ jsxRuntimeExports.jsx(
14572
+ "a",
14573
+ {
14574
+ title: "Abrir ajuda online",
14575
+ className: "btn nav-button",
14576
+ href: helpLink,
14577
+ target: "_blank",
14578
+ rel: "noreferrer noopener",
14579
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconeHelp, {})
14580
+ }
14581
+ ),
14582
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "btn-atalho", children: [
14583
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14584
+ Link,
14585
+ {
14586
+ to: routes.users,
14587
+ className: "nav-button",
14588
+ title: "Configurações do usuário",
14589
+ onClick: () => setIsOpen(false),
14590
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-user-gear" })
14591
+ }
14592
+ ),
14593
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14594
+ Link,
14595
+ {
14596
+ to: routes.exit,
14597
+ className: "nav-button",
14598
+ title: "Sair do sistema",
14599
+ onClick: () => setIsOpen(false),
14600
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-right-from-bracket" })
14601
+ }
14602
+ )
14603
+ ] })
14691
14604
  ] })
14692
- ] });
14693
- } else if (opc == null ? void 0 : opc.isLine) {
14694
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Line, {});
14695
- } else {
14696
- return null;
14697
- }
14605
+ ] })
14606
+ ] }) }),
14607
+ isOpen && /* @__PURE__ */ jsxRuntimeExports.jsx(
14608
+ "div",
14609
+ {
14610
+ id: "menu-background",
14611
+ className: "navbar--menu-background",
14612
+ onClick: handleClickBackground,
14613
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "menu-content", children: [
14614
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "search-area", children: [
14615
+ /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-search" }),
14616
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14617
+ "input",
14618
+ {
14619
+ ref: inputFiltro,
14620
+ placeholder: "Pesquisar...",
14621
+ value: filter,
14622
+ onChange: (e) => setFilter(e.target.value),
14623
+ onKeyDown: handleKeyDown
14624
+ }
14625
+ ),
14626
+ filter && /* @__PURE__ */ jsxRuntimeExports.jsx(
14627
+ "button",
14628
+ {
14629
+ className: "text-danger",
14630
+ title: "Limpar pesquisa",
14631
+ onClick: () => setFilter(""),
14632
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-times" })
14633
+ }
14634
+ ),
14635
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14636
+ "button",
14637
+ {
14638
+ title: "Fechar todos os grupos de opções",
14639
+ onClick: () => handleAbrirFecharGrupos(false),
14640
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-minus" })
14641
+ }
14642
+ ),
14643
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14644
+ "button",
14645
+ {
14646
+ title: "Expandir todos os grupos de opções",
14647
+ onClick: () => handleAbrirFecharGrupos(true),
14648
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-plus" })
14649
+ }
14650
+ )
14651
+ ] }),
14652
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "navbar--menu-area", ref: menuRef, children: opcoes.map((opc, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(
14653
+ MenuOption,
14654
+ {
14655
+ opc,
14656
+ closeMenu,
14657
+ clickGroup,
14658
+ clickFavorite: handleClickFavorite,
14659
+ isFavorite,
14660
+ enabledFavorite: routes.apiFavorites,
14661
+ filter
14662
+ },
14663
+ i
14664
+ )) }),
14665
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "menu-footer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: routes.exit, onClick: closeMenu, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "user", children: [
14666
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14667
+ "span",
14668
+ {
14669
+ className: "name",
14670
+ title: `Último acesso em ${user == null ? void 0 : user.lastAccess}`,
14671
+ children: user == null ? void 0 : user.name
14672
+ }
14673
+ ),
14674
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sair", children: [
14675
+ "Sair ",
14676
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IconeLogout, {})
14677
+ ] })
14678
+ ] }) }) })
14679
+ ] })
14680
+ }
14681
+ )
14682
+ ] });
14683
+ }
14684
+ const MenuBrand = ({ routes, closeMenu, brand }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "navbar-mu--brand", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
14685
+ Link,
14686
+ {
14687
+ to: routes.home,
14688
+ onClick: closeMenu,
14689
+ className: "brand",
14690
+ title: "Voltar para tela inicial",
14691
+ children: brand
14698
14692
  }
14693
+ ) });
14694
+ function MenuButton({ isOpen, setIsOpen, menuClose }) {
14695
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
14696
+ "button",
14697
+ {
14698
+ className: "btn-menu",
14699
+ title: "Abrir menu de opções",
14700
+ onClick: () => setIsOpen(!isOpen),
14701
+ children: menuClose ? /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-xmark icon-close" }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "icon-desk", children: [
14702
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", {}),
14703
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", {}),
14704
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", {})
14705
+ ] })
14706
+ }
14707
+ );
14699
14708
  }
14700
- const cKeyClosedMenus$1 = "sys/nav/closed";
14701
- function Navbar({
14702
- menusConfig: { brand, company, menus, routes, user, validatePermis },
14703
- helpLink
14709
+ const cKeyClosedMenus = "sys/nav/closed";
14710
+ function NavbarMU({
14711
+ menusConfig: { brand, company, menus, routes, user, validatePermis }
14704
14712
  }) {
14705
- const history = useHistory();
14706
14713
  const inputFiltro = useRef();
14707
14714
  const menuRef = useRef();
14715
+ const history = useHistory();
14708
14716
  const { theme, setTheme, canChangeTheme } = useLibContext();
14709
14717
  const [isOpen, setIsOpen] = useState(false);
14710
14718
  const [filter, setFilter] = useState("");
14711
14719
  const [opcoes, setOpcoes] = useState([]);
14712
14720
  const [favorites, setFavorites] = useState([]);
14713
14721
  let closedMenus = [];
14714
- const value = localStorage.getItem(cKeyClosedMenus$1);
14722
+ const value = localStorage.getItem(cKeyClosedMenus);
14715
14723
  if (value) {
14716
14724
  closedMenus = JSON.parse(value);
14717
14725
  }
@@ -14769,8 +14777,8 @@ function Navbar({
14769
14777
  useEffect(() => {
14770
14778
  var _a, _b;
14771
14779
  if (isDesktop()) {
14772
- (_a = inputFiltro == null ? void 0 : inputFiltro.current) == null ? void 0 : _a.focus();
14773
- (_b = inputFiltro == null ? void 0 : inputFiltro.current) == null ? void 0 : _b.select();
14780
+ (_a = inputFiltro == null ? void 0 : inputFiltro.current) == null ? void 0 : _a.select();
14781
+ (_b = inputFiltro == null ? void 0 : inputFiltro.current) == null ? void 0 : _b.focus();
14774
14782
  }
14775
14783
  }, [isOpen]);
14776
14784
  function saveFavorites(list) {
@@ -14781,7 +14789,6 @@ function Navbar({
14781
14789
  }
14782
14790
  function configurarOpcoes(menus2) {
14783
14791
  let opts = [];
14784
- const termo = normalizeText(filter);
14785
14792
  menus2.forEach((gr) => {
14786
14793
  let grupo = {
14787
14794
  caption: gr.caption,
@@ -14793,7 +14800,10 @@ function Navbar({
14793
14800
  };
14794
14801
  if (gr.menus && gr.menus.length > 0) {
14795
14802
  gr.menus.filter(
14796
- (e) => (e == null ? void 0 : e.isLine) || !(e == null ? void 0 : e.isLine) && (normalizeText(e.caption).includes(termo) || normalizeText(e.shortcut).includes(termo))
14803
+ (e) => {
14804
+ var _a;
14805
+ return (e == null ? void 0 : e.isLine) || !(e == null ? void 0 : e.isLine) && (e.caption.toLowerCase().includes(filter.toLowerCase()) || ((_a = e.shortcut) == null ? void 0 : _a.toLowerCase().includes(filter.toLowerCase())));
14806
+ }
14797
14807
  ).forEach((sub) => {
14798
14808
  if (validatePermis(sub == null ? void 0 : sub.permis, sub == null ? void 0 : sub.acesso)) {
14799
14809
  grupo.menus.push({ ...sub, prefix: grupo == null ? void 0 : grupo.prefix });
@@ -14844,7 +14854,7 @@ function Navbar({
14844
14854
  closed.push(item.caption);
14845
14855
  }
14846
14856
  });
14847
- localStorage.setItem(cKeyClosedMenus$1, JSON.stringify(closed));
14857
+ localStorage.setItem(cKeyClosedMenus, JSON.stringify(closed));
14848
14858
  setOpcoes(newOpc);
14849
14859
  }
14850
14860
  function handleAbrirFecharGrupos(expand) {
@@ -14876,6 +14886,11 @@ function Navbar({
14876
14886
  function isFavorite(route) {
14877
14887
  return favorites.some((e) => e.route === route);
14878
14888
  }
14889
+ function handleCancelFilter() {
14890
+ var _a;
14891
+ setFilter("");
14892
+ (_a = inputFiltro == null ? void 0 : inputFiltro.current) == null ? void 0 : _a.focus();
14893
+ }
14879
14894
  function handleKeyDown(e) {
14880
14895
  if (e.key != "Enter") {
14881
14896
  return;
@@ -14892,39 +14907,29 @@ function Navbar({
14892
14907
  }
14893
14908
  }
14894
14909
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
14895
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "navbar--area", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "navbar-content", children: [
14896
- /* @__PURE__ */ jsxRuntimeExports.jsx(
14897
- "button",
14898
- {
14899
- className: "btn-menu" + (isOpen ? " opened" : ""),
14900
- title: "Abrir menu de opções",
14901
- onClick: () => setIsOpen(!isOpen),
14902
- children: isOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx(IconClose, { width: 20, height: 20 }) : /* @__PURE__ */ jsxRuntimeExports.jsx(IconMenu, { width: 20, height: 20 })
14903
- }
14904
- ),
14905
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "content", children: [
14910
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "navbar-mu-area", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mu--container", children: [
14911
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MenuButton, { isOpen, setIsOpen }),
14912
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mu--content", children: [
14906
14913
  /* @__PURE__ */ jsxRuntimeExports.jsx(
14907
- Link,
14914
+ MenuBrand,
14908
14915
  {
14909
- to: routes.home,
14910
- className: "brand",
14911
- onClick: closeMenu,
14912
- title: "Voltar para tela inicial",
14913
- children: brand
14916
+ isOpen,
14917
+ setIsOpen,
14918
+ brand,
14919
+ closeMenu,
14920
+ routes
14914
14921
  }
14915
14922
  ),
14916
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "company", children: [
14917
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "name", children: company }),
14918
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "doc", children: [
14919
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
14920
- user == null ? void 0 : user.title,
14921
- " "
14922
- ] }),
14923
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mu--info", children: [
14924
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "info-line-1", children: company }),
14925
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "info-line-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
14926
+ user == null ? void 0 : user.title,
14927
+ " ",
14923
14928
  /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: user == null ? void 0 : user.name })
14924
- ] })
14929
+ ] }) })
14925
14930
  ] }),
14926
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "nav-btn-area", children: [
14927
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "btn-theme", children: canChangeTheme && /* @__PURE__ */ jsxRuntimeExports.jsx(
14931
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mu--buttons", children: [
14932
+ canChangeTheme && /* @__PURE__ */ jsxRuntimeExports.jsx(
14928
14933
  "button",
14929
14934
  {
14930
14935
  title: "Alterar entre o tema claro/escuro",
@@ -14936,51 +14941,60 @@ function Navbar({
14936
14941
  },
14937
14942
  children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-circle-half-stroke" })
14938
14943
  }
14939
- ) }),
14940
- helpLink && /* @__PURE__ */ jsxRuntimeExports.jsx(
14941
- "a",
14944
+ ),
14945
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14946
+ Link,
14942
14947
  {
14943
- title: "Abrir ajuda online",
14944
- className: "btn nav-button",
14945
- href: helpLink,
14946
- target: "_blank",
14947
- rel: "noreferrer noopener",
14948
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconeHelp, {})
14948
+ to: routes.users,
14949
+ className: "nav-button btn-users",
14950
+ title: "Configurações do usuário",
14951
+ onClick: () => setIsOpen(false),
14952
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-user-gear" })
14953
+ }
14954
+ ),
14955
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14956
+ Link,
14957
+ {
14958
+ to: routes.exit,
14959
+ className: "nav-button btn-exit",
14960
+ title: "Sair do sistema",
14961
+ onClick: () => setIsOpen(false),
14962
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-right-from-bracket" })
14949
14963
  }
14950
- ),
14951
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "btn-atalho", children: [
14964
+ )
14965
+ ] })
14966
+ ] })
14967
+ ] }) }),
14968
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14969
+ "div",
14970
+ {
14971
+ "data-open": isOpen,
14972
+ id: "menu-background",
14973
+ className: "nv-menu--background",
14974
+ onClick: handleClickBackground,
14975
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "nv-menu--content", "data-open": isOpen, children: [
14976
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "nv-menu--brand", children: [
14952
14977
  /* @__PURE__ */ jsxRuntimeExports.jsx(
14953
- Link,
14978
+ MenuButton,
14954
14979
  {
14955
- to: routes.users,
14956
- className: "nav-button",
14957
- title: "Configurações do usuário",
14958
- onClick: () => setIsOpen(false),
14959
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-user-gear" })
14980
+ isOpen,
14981
+ setIsOpen,
14982
+ menuClose: isMobile()
14960
14983
  }
14961
14984
  ),
14962
14985
  /* @__PURE__ */ jsxRuntimeExports.jsx(
14963
- Link,
14986
+ MenuBrand,
14964
14987
  {
14965
- to: routes.exit,
14966
- className: "nav-button",
14967
- title: "Sair do sistema",
14968
- onClick: () => setIsOpen(false),
14969
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-right-from-bracket" })
14988
+ isOpen,
14989
+ setIsOpen,
14990
+ brand,
14991
+ closeMenu,
14992
+ routes,
14993
+ showButtonClose: true
14970
14994
  }
14971
14995
  )
14972
- ] })
14973
- ] })
14974
- ] })
14975
- ] }) }),
14976
- isOpen && /* @__PURE__ */ jsxRuntimeExports.jsx(
14977
- "div",
14978
- {
14979
- id: "menu-background",
14980
- className: "navbar--menu-background",
14981
- onClick: handleClickBackground,
14982
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "menu-content", children: [
14983
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "search-area", children: [
14996
+ ] }),
14997
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "nv-menu--search", children: [
14984
14998
  /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-search" }),
14985
14999
  /* @__PURE__ */ jsxRuntimeExports.jsx(
14986
15000
  "input",
@@ -14997,7 +15011,7 @@ function Navbar({
14997
15011
  {
14998
15012
  className: "text-danger",
14999
15013
  title: "Limpar pesquisa",
15000
- onClick: () => setFilter(""),
15014
+ onClick: handleCancelFilter,
15001
15015
  children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-times" })
15002
15016
  }
15003
15017
  ),
@@ -15018,7 +15032,7 @@ function Navbar({
15018
15032
  }
15019
15033
  )
15020
15034
  ] }),
15021
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "navbar--menu-area", ref: menuRef, children: opcoes.map((opc, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(
15035
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nv-menu--opcoes", ref: menuRef, children: opcoes.map((opc, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(
15022
15036
  MenuOption,
15023
15037
  {
15024
15038
  opc,
@@ -15026,411 +15040,416 @@ function Navbar({
15026
15040
  clickGroup,
15027
15041
  clickFavorite: handleClickFavorite,
15028
15042
  isFavorite,
15029
- enabledFavorite: routes.apiFavorites,
15030
- filter
15043
+ enabledFavorite: routes.apiFavorites
15031
15044
  },
15032
15045
  i
15033
15046
  )) }),
15034
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "menu-footer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: routes.exit, onClick: closeMenu, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "user", children: [
15035
- /* @__PURE__ */ jsxRuntimeExports.jsx(
15036
- "span",
15037
- {
15038
- className: "name",
15039
- title: `Último acesso em ${user == null ? void 0 : user.lastAccess}`,
15040
- children: user == null ? void 0 : user.name
15041
- }
15042
- ),
15043
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sair", children: [
15047
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nv-menu--footer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: routes.exit, onClick: closeMenu, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "foo-user", children: [
15048
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "foo-name", children: user == null ? void 0 : user.name }),
15049
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "foo-sair", children: [
15044
15050
  "Sair ",
15045
15051
  /* @__PURE__ */ jsxRuntimeExports.jsx(IconeLogout, {})
15046
15052
  ] })
15047
- ] }) }) })
15053
+ ] }) }) }),
15054
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "nv-menu--copy", children: [
15055
+ "Último acesso em ",
15056
+ user == null ? void 0 : user.lastAccess
15057
+ ] })
15048
15058
  ] })
15049
15059
  }
15050
15060
  )
15051
15061
  ] });
15052
15062
  }
15053
- const MenuBrand = ({ routes, closeMenu, brand }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "navbar-mu--brand", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
15054
- Link,
15055
- {
15056
- to: routes.home,
15057
- onClick: closeMenu,
15058
- className: "brand",
15059
- title: "Voltar para tela inicial",
15060
- children: brand
15061
- }
15062
- ) });
15063
- function MenuButton({ isOpen, setIsOpen, menuClose }) {
15064
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
15065
- "button",
15066
- {
15067
- className: "btn-menu",
15068
- title: "Abrir menu de opções",
15069
- onClick: () => setIsOpen(!isOpen),
15070
- children: menuClose ? /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-xmark icon-close" }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "icon-desk", children: [
15071
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", {}),
15072
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", {}),
15073
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", {})
15074
- ] })
15075
- }
15076
- );
15063
+ function createMenuOptions(config) {
15064
+ return config;
15077
15065
  }
15078
- const cKeyClosedMenus = "sys/nav/closed";
15079
- function NavbarMU({
15080
- menusConfig: { brand, company, menus, routes, user, validatePermis }
15081
- }) {
15082
- const inputFiltro = useRef();
15083
- const menuRef = useRef();
15084
- const history = useHistory();
15085
- const { theme, setTheme, canChangeTheme } = useLibContext();
15086
- const [isOpen, setIsOpen] = useState(false);
15087
- const [filter, setFilter] = useState("");
15088
- const [opcoes, setOpcoes] = useState([]);
15089
- const [favorites, setFavorites] = useState([]);
15090
- let closedMenus = [];
15091
- const value = localStorage.getItem(cKeyClosedMenus);
15092
- if (value) {
15093
- closedMenus = JSON.parse(value);
15066
+ const LibContext = createContext({
15067
+ modalList: [],
15068
+ theme: "light",
15069
+ toggleTheme: () => {
15070
+ },
15071
+ versionApp: "",
15072
+ addModal: (modalId, setVisible) => {
15073
+ },
15074
+ removeModal: (modalId) => {
15075
+ },
15076
+ clearModals: () => {
15077
+ },
15078
+ showBtnTop: false,
15079
+ setShowBtnTop: () => {
15080
+ },
15081
+ globalApiConfig: null,
15082
+ setTheme: () => {
15083
+ },
15084
+ canChangeTheme: false,
15085
+ reportType: 0,
15086
+ setReportType: (reportTypeNumber) => {
15094
15087
  }
15095
- const [getFavorites] = useApi({
15096
- url: routes.apiFavorites,
15097
- onTerminated: (res) => {
15098
- if (res.error) {
15099
- console.info("Erro ao obter lista de favoritos!", res.error);
15088
+ });
15089
+ const cTheme = "sys/theme";
15090
+ let bootChecked = false;
15091
+ const LibProvider = ({ apiConfig, children, versionApp, useTheme, testDomain }) => {
15092
+ const canChangeTheme = typeof useTheme == "boolean" ? useTheme : false;
15093
+ const [theme, setTheme] = useState(() => {
15094
+ let result = "";
15095
+ if (canChangeTheme) {
15096
+ let value = localStorage.getItem(cTheme);
15097
+ if (value) {
15098
+ result = value;
15100
15099
  } else {
15101
- setFavorites(res.data);
15100
+ result = isDarkMode() ? "dark" : "light";
15102
15101
  }
15103
15102
  }
15103
+ return result;
15104
15104
  });
15105
- const [patchFavorites] = useApi({
15106
- url: routes.apiFavorites,
15107
- method: "patch",
15108
- onTerminated: (res) => {
15109
- if (res.error) {
15110
- console.info("Erro ao salvar favoritos!", res.error);
15111
- }
15105
+ const toggleTheme = () => setTheme(theme == "dark" ? "light" : "dark");
15106
+ const [reportType, setReportType] = useLocalStorage("sys/reportType", 0);
15107
+ const [modalList, setModalList] = useState([]);
15108
+ const [showBtnTop, setShowBtnTop] = useState(false);
15109
+ const histStack = useRef([]);
15110
+ const histPending = useRef(/* @__PURE__ */ new Map());
15111
+ const setVisibleMap = useRef(/* @__PURE__ */ new Map());
15112
+ const ignorePop = useRef(0);
15113
+ const pushHistory = (modalId) => {
15114
+ if (histStack.current.includes(modalId) || histPending.current.has(modalId)) {
15115
+ return;
15112
15116
  }
15113
- });
15114
- useEffect(() => {
15115
- if (routes.apiFavorites) {
15116
- getFavorites();
15117
+ const t = setTimeout(() => {
15118
+ histPending.current.delete(modalId);
15119
+ window.history.pushState({ jcModal: modalId }, "");
15120
+ histStack.current.push(modalId);
15121
+ }, 0);
15122
+ histPending.current.set(modalId, t);
15123
+ };
15124
+ const releaseHistory = (modalId) => {
15125
+ var _a;
15126
+ if (histPending.current.has(modalId)) {
15127
+ clearTimeout(histPending.current.get(modalId));
15128
+ histPending.current.delete(modalId);
15117
15129
  }
15118
- }, []);
15119
- useEffect(() => {
15120
- let favoriteOptions = [];
15121
- favorites == null ? void 0 : favorites.forEach((favorite) => {
15122
- menus.forEach((group, index) => {
15123
- var _a;
15124
- if (index > 0 && ((_a = group == null ? void 0 : group.menus) == null ? void 0 : _a.length) !== 0) {
15125
- let indexOpt = group.menus.findIndex((opt) => opt.route === favorite.route);
15126
- if (indexOpt >= 0) {
15127
- let menuOption = group.menus[indexOpt];
15128
- favoriteOptions.push({
15129
- ...menuOption,
15130
- caption: favorite.caption,
15131
- index: String(index).padStart(2, "0") + String(indexOpt).padStart(2, 0)
15132
- });
15133
- }
15134
- }
15135
- });
15130
+ const stack = histStack.current;
15131
+ const index = stack.indexOf(modalId);
15132
+ if (index < 0) {
15133
+ return;
15134
+ }
15135
+ stack.splice(index, 1);
15136
+ if (((_a = window.history.state) == null ? void 0 : _a.jcModal) === modalId) {
15137
+ ignorePop.current++;
15138
+ window.history.back();
15139
+ }
15140
+ };
15141
+ const closeByHistory = (modalId) => {
15142
+ const setVisible = setVisibleMap.current.get(modalId);
15143
+ setVisibleMap.current.delete(modalId);
15144
+ setModalList((prev) => prev.filter((e) => e.modalId !== modalId));
15145
+ if (setVisible) {
15146
+ setVisible(false);
15147
+ }
15148
+ };
15149
+ const addModal = (modalId, setVisible) => {
15150
+ setVisibleMap.current.set(modalId, setVisible);
15151
+ pushHistory(modalId);
15152
+ setModalList((prev) => {
15153
+ let arr = [...prev];
15154
+ let index = arr.findIndex((e) => e.modalId === modalId);
15155
+ if (index >= 0) {
15156
+ arr[index] = { modalId, setVisible };
15157
+ } else {
15158
+ arr.push({ modalId, setVisible });
15159
+ }
15160
+ return arr;
15136
15161
  });
15137
- if (menus[0].caption === "Favoritos") {
15138
- menus[0].menus = favoriteOptions.sort((a, b) => {
15139
- if (a.index > b.index) return 1;
15140
- if (a.index < b.index) return -1;
15141
- return 0;
15142
- });
15162
+ };
15163
+ const removeModal = (modalId) => {
15164
+ let modal = modalList.find((e) => e.modalId === modalId);
15165
+ if (modal) {
15166
+ modal.setVisible(false);
15143
15167
  }
15144
- setOpcoes(configurarOpcoes(menus));
15145
- }, [filter, favorites]);
15168
+ setVisibleMap.current.delete(modalId);
15169
+ releaseHistory(modalId);
15170
+ setModalList((prev) => prev.filter((e) => e.modalId !== modalId));
15171
+ return;
15172
+ };
15173
+ const clearModals = () => {
15174
+ modalList.forEach((modal) => {
15175
+ removeModal(modal.modalId);
15176
+ });
15177
+ };
15178
+ const handleKeyDown = useCallback(
15179
+ (e) => {
15180
+ if (e.key === "Escape") {
15181
+ if (modalList.length != 0) {
15182
+ removeModal(modalList[modalList.length - 1].modalId);
15183
+ }
15184
+ }
15185
+ },
15186
+ [modalList]
15187
+ );
15188
+ useLocalhostBadge();
15189
+ const borderTestServer = useTestDomainBadge(testDomain);
15146
15190
  useEffect(() => {
15147
- var _a, _b;
15148
- if (isDesktop()) {
15149
- (_a = inputFiltro == null ? void 0 : inputFiltro.current) == null ? void 0 : _a.select();
15150
- (_b = inputFiltro == null ? void 0 : inputFiltro.current) == null ? void 0 : _b.focus();
15191
+ if (canChangeTheme) {
15192
+ localStorage.setItem(cTheme, theme);
15193
+ document.body.dataset.bsTheme = theme == "dark" ? theme : "";
15151
15194
  }
15152
- }, [isOpen]);
15153
- function saveFavorites(list) {
15154
- if (routes.apiFavorites) {
15155
- patchFavorites({ data: list });
15156
- setFavorites(list);
15195
+ }, [theme, canChangeTheme]);
15196
+ useEffect(() => {
15197
+ window.addEventListener("keydown", handleKeyDown, false);
15198
+ return () => window.removeEventListener("keydown", handleKeyDown, false);
15199
+ }, [modalList]);
15200
+ useEffect(() => {
15201
+ var _a;
15202
+ if (!bootChecked) {
15203
+ bootChecked = true;
15204
+ if ((_a = window.history.state) == null ? void 0 : _a.jcModal) {
15205
+ window.history.back();
15206
+ }
15157
15207
  }
15158
- }
15159
- function configurarOpcoes(menus2) {
15160
- let opts = [];
15161
- menus2.forEach((gr) => {
15162
- let grupo = {
15163
- caption: gr.caption,
15164
- open: !closedMenus.includes(gr.caption) || gr.stayOpen,
15165
- stayOpen: gr.stayOpen,
15166
- isFavorite: gr == null ? void 0 : gr.isFavorite,
15167
- prefix: gr == null ? void 0 : gr.prefix,
15168
- menus: []
15169
- };
15170
- if (gr.menus && gr.menus.length > 0) {
15171
- gr.menus.filter(
15172
- (e) => {
15173
- var _a;
15174
- return (e == null ? void 0 : e.isLine) || !(e == null ? void 0 : e.isLine) && (e.caption.toLowerCase().includes(filter.toLowerCase()) || ((_a = e.shortcut) == null ? void 0 : _a.toLowerCase().includes(filter.toLowerCase())));
15175
- }
15176
- ).forEach((sub) => {
15177
- if (validatePermis(sub == null ? void 0 : sub.permis, sub == null ? void 0 : sub.acesso)) {
15178
- grupo.menus.push({ ...sub, prefix: grupo == null ? void 0 : grupo.prefix });
15179
- }
15180
- });
15208
+ function onPopState() {
15209
+ var _a2;
15210
+ if (ignorePop.current > 0) {
15211
+ ignorePop.current--;
15212
+ return;
15181
15213
  }
15182
- if (filter) {
15183
- grupo.open = true;
15214
+ const current = (_a2 = window.history.state) == null ? void 0 : _a2.jcModal;
15215
+ const stack = histStack.current;
15216
+ while (stack.length && stack[stack.length - 1] !== current) {
15217
+ closeByHistory(stack.pop());
15184
15218
  }
15185
- opts.push(grupo);
15186
- });
15187
- opts.forEach((o) => {
15188
- var _a;
15189
- if (o.menus) {
15190
- if ((_a = o.menus[0]) == null ? void 0 : _a.isLine) {
15191
- o.menus = o.menus.filter((opc) => !(opc == null ? void 0 : opc.isLine));
15192
- }
15193
- o.menus = o.menus.filter((opc, index, arr) => {
15194
- var _a2;
15195
- if (index > 0 && ((_a2 = arr[index - 1]) == null ? void 0 : _a2.isLine) && opc.isLine) {
15196
- return false;
15197
- }
15198
- return true;
15199
- });
15200
- o.menus = o.menus.filter((opc, index, arr) => {
15201
- return !(index === arr.length - 1 && (opc == null ? void 0 : opc.isLine));
15202
- });
15219
+ if (current && !stack.includes(current)) {
15220
+ ignorePop.current++;
15221
+ window.history.back();
15203
15222
  }
15204
- });
15205
- return opts;
15206
- }
15207
- function closeMenu() {
15208
- setIsOpen(false);
15209
- }
15210
- function handleClickBackground(e) {
15211
- if (e.target.id === "menu-background") {
15212
- closeMenu();
15213
15223
  }
15224
+ window.addEventListener("popstate", onPopState);
15225
+ return () => {
15226
+ window.removeEventListener("popstate", onPopState);
15227
+ histPending.current.forEach((t) => clearTimeout(t));
15228
+ histPending.current.clear();
15229
+ };
15230
+ }, []);
15231
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
15232
+ LibContext.Provider,
15233
+ {
15234
+ value: {
15235
+ versionApp,
15236
+ addModal,
15237
+ removeModal,
15238
+ clearModals,
15239
+ showBtnTop,
15240
+ setShowBtnTop,
15241
+ globalApiConfig: apiConfig,
15242
+ theme,
15243
+ setTheme,
15244
+ toggleTheme,
15245
+ canChangeTheme,
15246
+ reportType,
15247
+ setReportType
15248
+ },
15249
+ children: [
15250
+ borderTestServer,
15251
+ children
15252
+ ]
15253
+ }
15254
+ );
15255
+ };
15256
+ function useLibContext() {
15257
+ const context = useContext(LibContext);
15258
+ if (!(context == null ? void 0 : context.addModal) && true) {
15259
+ throw new Error("'ModalProvider' não encontrado!");
15214
15260
  }
15215
- function clickGroup(grupo) {
15216
- let newOpc = [...opcoes];
15217
- let closed = [];
15218
- newOpc.forEach((item) => {
15219
- if (item === grupo) {
15220
- item.open = !item.open;
15221
- }
15222
- if (!item.open) {
15223
- closed.push(item.caption);
15224
- }
15225
- });
15226
- localStorage.setItem(cKeyClosedMenus, JSON.stringify(closed));
15227
- setOpcoes(newOpc);
15261
+ return context;
15262
+ }
15263
+ const AlertTypes = {
15264
+ Alerta: 1,
15265
+ Aviso: 2,
15266
+ Confirmacao: 3
15267
+ };
15268
+ const cClassHideSB = "jc-alert-hide-sb";
15269
+ function JCAlert({
15270
+ type = AlertTypes.Aviso,
15271
+ onConfirm,
15272
+ onCancel,
15273
+ title,
15274
+ text: text2 = "",
15275
+ children,
15276
+ defaultBtn = 2
15277
+ }) {
15278
+ const buttonRef = useRef();
15279
+ const containerRef = useRef();
15280
+ const { addModal, removeModal } = useLibContext();
15281
+ const [modalId] = useState("alert-" + random());
15282
+ const controls = useDragControls();
15283
+ let classColor = "jc-erro";
15284
+ switch (type) {
15285
+ case AlertTypes.Aviso:
15286
+ classColor = "jc-aviso";
15287
+ break;
15288
+ case AlertTypes.Confirmacao:
15289
+ classColor = "jc-conf";
15290
+ break;
15228
15291
  }
15229
- function handleAbrirFecharGrupos(expand) {
15230
- let newOpc = [...opcoes];
15231
- newOpc.forEach((e) => {
15232
- if (e == null ? void 0 : e.menus) {
15233
- if (e == null ? void 0 : e.stayOpen) {
15234
- e.open = e.stayOpen;
15235
- } else {
15236
- e.open = expand;
15292
+ const handleKeys = useCallback(
15293
+ (ev) => {
15294
+ if (type === AlertTypes.Confirmacao) {
15295
+ if (ev.code === "KeyS" && onConfirm) {
15296
+ onConfirm();
15297
+ }
15298
+ if (ev.code === "KeyN" && onCancel) {
15299
+ onCancel();
15237
15300
  }
15238
15301
  }
15239
- });
15240
- setOpcoes(newOpc);
15241
- clickGroup(null);
15242
- }
15243
- function handleClickFavorite(ev, opcao) {
15244
- ev.stopPropagation();
15245
- ev.preventDefault();
15246
- const newFav = favorites.filter((e) => e.route !== opcao.route);
15247
- if (newFav.length === favorites.length) {
15248
- newFav.push({
15249
- caption: ((opcao == null ? void 0 : opcao.prefix) ? opcao.prefix + " / " : "") + opcao.caption,
15250
- route: opcao.route
15251
- });
15302
+ },
15303
+ [onCancel, onConfirm, type]
15304
+ );
15305
+ useEffect(() => {
15306
+ if (type === AlertTypes.Confirmacao) {
15307
+ addModal(modalId, onCancel);
15308
+ } else {
15309
+ addModal(modalId, onConfirm);
15252
15310
  }
15253
- saveFavorites(newFav);
15254
- }
15255
- function isFavorite(route) {
15256
- return favorites.some((e) => e.route === route);
15257
- }
15258
- function handleCancelFilter() {
15311
+ return () => removeModal(modalId);
15312
+ }, []);
15313
+ useEffect(() => {
15259
15314
  var _a;
15260
- setFilter("");
15261
- (_a = inputFiltro == null ? void 0 : inputFiltro.current) == null ? void 0 : _a.focus();
15315
+ (_a = buttonRef == null ? void 0 : buttonRef.current) == null ? void 0 : _a.focus();
15316
+ }, [buttonRef]);
15317
+ useEffect(() => {
15318
+ document.addEventListener("keydown", handleKeys, false);
15319
+ document.body.classList.add(cClassHideSB);
15320
+ return () => {
15321
+ document.removeEventListener("keydown", handleKeys, false);
15322
+ document.body.classList.remove(cClassHideSB);
15323
+ };
15324
+ }, [handleKeys]);
15325
+ function handleClose() {
15326
+ if (type === AlertTypes.Confirmacao) {
15327
+ onCancel();
15328
+ } else {
15329
+ onConfirm();
15330
+ }
15262
15331
  }
15263
- function handleKeyDown(e) {
15264
- if (e.key != "Enter") {
15332
+ function startDrag(e) {
15333
+ if (isMobile()) {
15265
15334
  return;
15266
15335
  }
15267
- for (const opc of opcoes) {
15268
- if (opc.menus && opc.menus.length != 0) {
15269
- const option = opc.menus.find((e2) => e2.route != null && e2.route != "");
15270
- if (option) {
15271
- history.push(option.route);
15272
- setIsOpen(false);
15273
- break;
15274
- }
15275
- }
15276
- }
15336
+ controls.start(e);
15277
15337
  }
15278
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
15279
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "navbar-mu-area", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mu--container", children: [
15280
- /* @__PURE__ */ jsxRuntimeExports.jsx(MenuButton, { isOpen, setIsOpen }),
15281
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mu--content", children: [
15282
- /* @__PURE__ */ jsxRuntimeExports.jsx(
15283
- MenuBrand,
15284
- {
15285
- isOpen,
15286
- setIsOpen,
15287
- brand,
15288
- closeMenu,
15289
- routes
15290
- }
15291
- ),
15292
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mu--info", children: [
15293
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "info-line-1", children: company }),
15294
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "info-line-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
15295
- user == null ? void 0 : user.title,
15296
- " ",
15297
- /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: user == null ? void 0 : user.name })
15298
- ] }) })
15338
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { className: "jc-alert--container", ref: containerRef, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
15339
+ motion.div,
15340
+ {
15341
+ className: "jc-alert " + classColor,
15342
+ drag: true,
15343
+ dragConstraints: containerRef,
15344
+ dragElastic: 0.1,
15345
+ dragMomentum: false,
15346
+ dragControls: controls,
15347
+ dragListener: false,
15348
+ animate: { scale: 1 },
15349
+ transition: {
15350
+ ease: "easeOut",
15351
+ duration: 0.3
15352
+ },
15353
+ children: [
15354
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "jc-close-button", onClick: handleClose, children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-xmark" }) }),
15355
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "jc-alert-header", onPointerDown: startDrag, children: [
15356
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "icon", children: [
15357
+ type === AlertTypes.Aviso && /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-check" }),
15358
+ type === AlertTypes.Alerta && /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-triangle-exclamation" }),
15359
+ type === AlertTypes.Confirmacao && /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-question" })
15360
+ ] }),
15361
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "jc-alert-title", children: title })
15299
15362
  ] }),
15300
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mu--buttons", children: [
15301
- canChangeTheme && /* @__PURE__ */ jsxRuntimeExports.jsx(
15363
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "jc-alert-body", children: text2 && typeof text2 == "string" ? /* @__PURE__ */ jsxRuntimeExports.jsx(TextHTML, { value: text2 }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: text2 || children }) }),
15364
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "jc-alert-buttons", children: [
15365
+ (type === AlertTypes.Alerta || type === AlertTypes.Aviso) && /* @__PURE__ */ jsxRuntimeExports.jsx(
15302
15366
  "button",
15303
15367
  {
15304
- title: "Alterar entre o tema claro/escuro",
15305
- className: "btn nav-button",
15306
- onClick: () => {
15307
- const vtheme = theme == "light" ? "dark" : "light";
15308
- setTheme(vtheme);
15309
- document.body.dataset.bsTheme = vtheme;
15310
- },
15311
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-circle-half-stroke" })
15312
- }
15313
- ),
15314
- /* @__PURE__ */ jsxRuntimeExports.jsx(
15315
- Link,
15316
- {
15317
- to: routes.users,
15318
- className: "nav-button btn-users",
15319
- title: "Configurações do usuário",
15320
- onClick: () => setIsOpen(false),
15321
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-user-gear" })
15368
+ ref: buttonRef,
15369
+ type: "button",
15370
+ className: "btn btn-confirm",
15371
+ onClick: onConfirm,
15372
+ children: "OK"
15322
15373
  }
15323
15374
  ),
15324
- /* @__PURE__ */ jsxRuntimeExports.jsx(
15325
- Link,
15326
- {
15327
- to: routes.exit,
15328
- className: "nav-button btn-exit",
15329
- title: "Sair do sistema",
15330
- onClick: () => setIsOpen(false),
15331
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-right-from-bracket" })
15332
- }
15333
- )
15334
- ] })
15335
- ] })
15336
- ] }) }),
15337
- /* @__PURE__ */ jsxRuntimeExports.jsx(
15338
- "div",
15339
- {
15340
- "data-open": isOpen,
15341
- id: "menu-background",
15342
- className: "nv-menu--background",
15343
- onClick: handleClickBackground,
15344
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "nv-menu--content", "data-open": isOpen, children: [
15345
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "nv-menu--brand", children: [
15346
- /* @__PURE__ */ jsxRuntimeExports.jsx(
15347
- MenuButton,
15348
- {
15349
- isOpen,
15350
- setIsOpen,
15351
- menuClose: isMobile()
15352
- }
15353
- ),
15354
- /* @__PURE__ */ jsxRuntimeExports.jsx(
15355
- MenuBrand,
15356
- {
15357
- isOpen,
15358
- setIsOpen,
15359
- brand,
15360
- closeMenu,
15361
- routes,
15362
- showButtonClose: true
15363
- }
15364
- )
15365
- ] }),
15366
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "nv-menu--search", children: [
15367
- /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-search" }),
15368
- /* @__PURE__ */ jsxRuntimeExports.jsx(
15369
- "input",
15370
- {
15371
- ref: inputFiltro,
15372
- placeholder: "Pesquisar...",
15373
- value: filter,
15374
- onChange: (e) => setFilter(e.target.value),
15375
- onKeyDown: handleKeyDown
15376
- }
15377
- ),
15378
- filter && /* @__PURE__ */ jsxRuntimeExports.jsx(
15379
- "button",
15380
- {
15381
- className: "text-danger",
15382
- title: "Limpar pesquisa",
15383
- onClick: handleCancelFilter,
15384
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-times" })
15385
- }
15386
- ),
15387
- /* @__PURE__ */ jsxRuntimeExports.jsx(
15375
+ type === AlertTypes.Confirmacao && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
15376
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
15388
15377
  "button",
15389
15378
  {
15390
- title: "Fechar todos os grupos de opções",
15391
- onClick: () => handleAbrirFecharGrupos(false),
15392
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-minus" })
15379
+ type: "button",
15380
+ className: "btn btn-confirm",
15381
+ onClick: onConfirm,
15382
+ tabIndex: 99,
15383
+ ref: defaultBtn === 1 ? buttonRef : null,
15384
+ children: [
15385
+ /* @__PURE__ */ jsxRuntimeExports.jsx("u", { children: "S" }),
15386
+ "im"
15387
+ ]
15393
15388
  }
15394
15389
  ),
15395
- /* @__PURE__ */ jsxRuntimeExports.jsx(
15390
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
15396
15391
  "button",
15397
15392
  {
15398
- title: "Expandir todos os grupos de opções",
15399
- onClick: () => handleAbrirFecharGrupos(true),
15400
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-plus" })
15393
+ type: "button",
15394
+ className: "btn btn-confirm btn-nao",
15395
+ onClick: onCancel,
15396
+ tabIndex: 98,
15397
+ ref: defaultBtn === 2 ? buttonRef : null,
15398
+ children: [
15399
+ /* @__PURE__ */ jsxRuntimeExports.jsx("u", { children: "N" }),
15400
+ "ão"
15401
+ ]
15401
15402
  }
15402
15403
  )
15403
- ] }),
15404
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nv-menu--opcoes", ref: menuRef, children: opcoes.map((opc, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(
15405
- MenuOption,
15406
- {
15407
- opc,
15408
- closeMenu,
15409
- clickGroup,
15410
- clickFavorite: handleClickFavorite,
15411
- isFavorite,
15412
- enabledFavorite: routes.apiFavorites
15413
- },
15414
- i
15415
- )) }),
15416
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nv-menu--footer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: routes.exit, onClick: closeMenu, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "foo-user", children: [
15417
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "foo-name", children: user == null ? void 0 : user.name }),
15418
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "foo-sair", children: [
15419
- "Sair ",
15420
- /* @__PURE__ */ jsxRuntimeExports.jsx(IconeLogout, {})
15421
- ] })
15422
- ] }) }) }),
15423
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "nv-menu--copy", children: [
15424
- "Último acesso em ",
15425
- user == null ? void 0 : user.lastAccess
15426
15404
  ] })
15427
15405
  ] })
15428
- }
15429
- )
15430
- ] });
15406
+ ]
15407
+ }
15408
+ ) });
15431
15409
  }
15432
- function createMenuOptions(config) {
15433
- return config;
15410
+ function Aviso({ onConfirm, text: text2 = "", children }) {
15411
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
15412
+ JCAlert,
15413
+ {
15414
+ type: AlertTypes.Aviso,
15415
+ title: "Aviso!",
15416
+ text: text2,
15417
+ onConfirm,
15418
+ children
15419
+ }
15420
+ );
15421
+ }
15422
+ function Confirma({
15423
+ onConfirm,
15424
+ onCancel,
15425
+ text: text2 = "",
15426
+ children,
15427
+ defaultBtn = void 0
15428
+ }) {
15429
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
15430
+ JCAlert,
15431
+ {
15432
+ type: AlertTypes.Confirmacao,
15433
+ title: "Confirmação!",
15434
+ text: text2,
15435
+ onConfirm,
15436
+ onCancel,
15437
+ defaultBtn,
15438
+ children
15439
+ }
15440
+ );
15441
+ }
15442
+ function Alerta({ onConfirm, text: text2 = "", children }) {
15443
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
15444
+ JCAlert,
15445
+ {
15446
+ type: AlertTypes.Alerta,
15447
+ title: "Atenção!",
15448
+ text: text2,
15449
+ onConfirm,
15450
+ children
15451
+ }
15452
+ );
15434
15453
  }
15435
15454
  export {
15436
15455
  Alerta,